Latest update.
This commit is contained in:
@@ -519,6 +519,31 @@ static int test_modexp_mont5(void)
|
||||
if (!TEST_BN_eq(c, d))
|
||||
goto err;
|
||||
|
||||
/*
|
||||
* rsaz_1024_mul_avx2 expects fully-reduced inputs.
|
||||
* BN_mod_exp_mont_consttime should reduce the input first.
|
||||
*/
|
||||
BN_hex2bn(&a,
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2020202020DF");
|
||||
BN_hex2bn(&b,
|
||||
"1FA53F26F8811C58BE0357897AA5E165693230BC9DF5F01DFA6A2D59229EC69D"
|
||||
"9DE6A89C36E3B6957B22D6FAAD5A3C73AE587B710DBE92E83D3A9A3339A085CB"
|
||||
"B58F508CA4F837924BB52CC1698B7FDC2FD74362456A595A5B58E38E38E38E38"
|
||||
"E38E38E38E38E38E38E38E38E38E38E38E38E38E38E38E38E38E38E38E38E38E");
|
||||
BN_hex2bn(&n,
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2020202020DF");
|
||||
BN_MONT_CTX_set(mont, n, ctx);
|
||||
BN_mod_exp_mont_consttime(c, a, b, n, ctx, mont);
|
||||
BN_zero(d);
|
||||
if (!TEST_BN_eq(c, d))
|
||||
goto err;
|
||||
|
||||
/* Zero input */
|
||||
BN_bntest_rand(p, 1024, 0, 0);
|
||||
BN_zero(a);
|
||||
|
||||
@@ -392,7 +392,6 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=main
|
||||
PROGRAMS_NO_INST=shlibloadtest
|
||||
SOURCE[shlibloadtest]=shlibloadtest.c
|
||||
INCLUDE[shlibloadtest]=../include ../crypto/include
|
||||
DEPEND[shlibloadtest]=libtestutil.a
|
||||
ENDIF
|
||||
|
||||
IF[{- $disabled{shared} -}]
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIC7DCCAdSgAwIBAgIBATANBgkqhkiG9w0BAQsFADASMRAwDgYDVQQDDAdSb290
|
||||
IENBMCAXDTE2MDExNTA4MTk0OVoYDzIxMTYwMTE2MDgxOTQ5WjASMRAwDgYDVQQD
|
||||
DAdSb290IENBMIIBHTAIBgRVCAEBBQADggEPADCCAQoCggEBAOHmAPUGvKBGOHkP
|
||||
Px5xGRNtAt8rm3Zr/KywIe3WkQhCO6VjNexSW6CiSsXWAJQDl1o9uWco0n3jIVyk
|
||||
7cY8jY6E0Z1Uwz3ZdKKWdmdx+cYaUHez/XjuW+DjjIkjwpoi7D7UN54HzcArVREX
|
||||
OjRCHGkNOhiw7RWUXsb9nofGHOeUGpLAXwXBc0PlA94JkckkztiOi34u4DFI0YYq
|
||||
alUmeugLNk6XseCkydpcaUsDgAhWg6Mfsiq4wUz+xbFN1MABqu2+ziW97mmt9gfN
|
||||
biuhiVT1aOuYCe3JYGbLM2JKA7Bo1g6rX8E1VX79Ru6669y2oqPthX9337VoIkN+
|
||||
ZiQjr8UCAwEAAaNQME4wHQYDVR0OBBYEFI71Ja8em2uEPXyAmslTnE1y96NSMB8G
|
||||
A1UdIwQYMBaAFI71Ja8em2uEPXyAmslTnE1y96NSMAwGA1UdEwQFMAMBAf8wDQYJ
|
||||
KoZIhvcNAQELBQADggEBAJ0OIdog3uQ1pmsjv1Qtf1w4If1geOn5uK0EOj2wYBHt
|
||||
NxlFn7l8d9+51QMZFO+RlQJ0s3Webyo1ReuaL2dMn2LGJhWMoSBAwrMALAENU3lv
|
||||
8jioRbfO2OamsdpJpKxQUyUJYudNe+BoKNX/ry3rxezmsFsRr9nDMiJZpmBCXiMm
|
||||
mFFJOJkG0CheexBbMkua4kyStIOwO4rb5bSHszVso/9ucdGHBSC7oRcJXoWSDjBx
|
||||
PdQPPBK5g4yqL8Lz26ehgsmhRKL9k32eVyjDKcIzgpmgcPTfTqNbd1KHQJKx4ssb
|
||||
7nEpGKHalSo5Oq5L9s9qYrUv37kwBY4OpJFtmGaodoI=
|
||||
-----END CERTIFICATE-----
|
||||
+10
-19
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -106,12 +106,9 @@ static int single_kat_no_reseed(const struct drbg_kat *td)
|
||||
failures++;
|
||||
|
||||
err:
|
||||
if (buff != NULL)
|
||||
OPENSSL_free(buff);
|
||||
if (drbg != NULL) {
|
||||
RAND_DRBG_uninstantiate(drbg);
|
||||
RAND_DRBG_free(drbg);
|
||||
}
|
||||
OPENSSL_free(buff);
|
||||
RAND_DRBG_uninstantiate(drbg);
|
||||
RAND_DRBG_free(drbg);
|
||||
return failures == 0;
|
||||
}
|
||||
|
||||
@@ -176,12 +173,9 @@ static int single_kat_pr_false(const struct drbg_kat *td)
|
||||
failures++;
|
||||
|
||||
err:
|
||||
if (buff != NULL)
|
||||
OPENSSL_free(buff);
|
||||
if (drbg != NULL) {
|
||||
RAND_DRBG_uninstantiate(drbg);
|
||||
RAND_DRBG_free(drbg);
|
||||
}
|
||||
OPENSSL_free(buff);
|
||||
RAND_DRBG_uninstantiate(drbg);
|
||||
RAND_DRBG_free(drbg);
|
||||
return failures == 0;
|
||||
}
|
||||
|
||||
@@ -249,12 +243,9 @@ static int single_kat_pr_true(const struct drbg_kat *td)
|
||||
failures++;
|
||||
|
||||
err:
|
||||
if (buff != NULL)
|
||||
OPENSSL_free(buff);
|
||||
if (drbg != NULL) {
|
||||
RAND_DRBG_uninstantiate(drbg);
|
||||
RAND_DRBG_free(drbg);
|
||||
}
|
||||
OPENSSL_free(buff);
|
||||
RAND_DRBG_uninstantiate(drbg);
|
||||
RAND_DRBG_free(drbg);
|
||||
return failures == 0;
|
||||
}
|
||||
|
||||
|
||||
+12
-9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2015-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -1761,15 +1761,18 @@ static int encode_test_init(EVP_TEST *t, const char *encoding)
|
||||
} else if (strcmp(encoding, "invalid") == 0) {
|
||||
edata->encoding = BASE64_INVALID_ENCODING;
|
||||
if (!TEST_ptr(t->expected_err = OPENSSL_strdup("DECODE_ERROR")))
|
||||
return 0;
|
||||
goto err;
|
||||
} else {
|
||||
TEST_error("Bad encoding: %s."
|
||||
" Should be one of {canonical, valid, invalid}",
|
||||
encoding);
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
t->data = edata;
|
||||
return 1;
|
||||
err:
|
||||
OPENSSL_free(edata);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void encode_test_cleanup(EVP_TEST *t)
|
||||
@@ -1798,7 +1801,7 @@ static int encode_test_run(EVP_TEST *t)
|
||||
ENCODE_DATA *expected = t->data;
|
||||
unsigned char *encode_out = NULL, *decode_out = NULL;
|
||||
int output_len, chunk_len;
|
||||
EVP_ENCODE_CTX *decode_ctx;
|
||||
EVP_ENCODE_CTX *decode_ctx = NULL, *encode_ctx = NULL;
|
||||
|
||||
if (!TEST_ptr(decode_ctx = EVP_ENCODE_CTX_new())) {
|
||||
t->err = "INTERNAL_ERROR";
|
||||
@@ -1806,7 +1809,6 @@ static int encode_test_run(EVP_TEST *t)
|
||||
}
|
||||
|
||||
if (expected->encoding == BASE64_CANONICAL_ENCODING) {
|
||||
EVP_ENCODE_CTX *encode_ctx;
|
||||
|
||||
if (!TEST_ptr(encode_ctx = EVP_ENCODE_CTX_new())
|
||||
|| !TEST_ptr(encode_out =
|
||||
@@ -1814,15 +1816,15 @@ static int encode_test_run(EVP_TEST *t)
|
||||
goto err;
|
||||
|
||||
EVP_EncodeInit(encode_ctx);
|
||||
EVP_EncodeUpdate(encode_ctx, encode_out, &chunk_len,
|
||||
expected->input, expected->input_len);
|
||||
if (!TEST_true(EVP_EncodeUpdate(encode_ctx, encode_out, &chunk_len,
|
||||
expected->input, expected->input_len)))
|
||||
goto err;
|
||||
|
||||
output_len = chunk_len;
|
||||
|
||||
EVP_EncodeFinal(encode_ctx, encode_out + chunk_len, &chunk_len);
|
||||
output_len += chunk_len;
|
||||
|
||||
EVP_ENCODE_CTX_free(encode_ctx);
|
||||
|
||||
if (!memory_err_compare(t, "BAD_ENCODING",
|
||||
expected->output, expected->output_len,
|
||||
encode_out, output_len))
|
||||
@@ -1860,6 +1862,7 @@ static int encode_test_run(EVP_TEST *t)
|
||||
OPENSSL_free(encode_out);
|
||||
OPENSSL_free(decode_out);
|
||||
EVP_ENCODE_CTX_free(decode_ctx);
|
||||
EVP_ENCODE_CTX_free(encode_ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ sub verify {
|
||||
run(app([@args]));
|
||||
}
|
||||
|
||||
plan tests => 134;
|
||||
plan tests => 135;
|
||||
|
||||
# Canonical success
|
||||
ok(verify("ee-cert", "sslserver", ["root-cert"], ["ca-cert"]),
|
||||
@@ -361,6 +361,8 @@ ok(verify("some-names2", "sslserver", ["many-constraints"], ["many-constraints"]
|
||||
"Not too many names and constraints to check (2)");
|
||||
ok(verify("some-names2", "sslserver", ["many-constraints"], ["many-constraints"], ),
|
||||
"Not too many names and constraints to check (3)");
|
||||
ok(verify("root-cert-rsa2", "sslserver", ["root-cert-rsa2"], [], "-check_ss_sig"),
|
||||
"Public Key Algorithm rsa instead of rsaEncryption");
|
||||
|
||||
SKIP: {
|
||||
skip "Ed25519 is not supported by this OpenSSL build", 1
|
||||
|
||||
@@ -88,9 +88,11 @@ sub inject_duplicate_extension
|
||||
foreach my $message (@{$proxy->message_list}) {
|
||||
if ($message->mt == $message_type) {
|
||||
my %extensions = %{$message->extension_data};
|
||||
# Add a duplicate (unknown) extension.
|
||||
$message->set_extension(TLSProxy::Message::EXT_DUPLICATE_EXTENSION, "");
|
||||
$message->set_extension(TLSProxy::Message::EXT_DUPLICATE_EXTENSION, "");
|
||||
# Add a duplicate extension. We use cryptopro_bug since we never
|
||||
# normally write that one, and it is allowed as unsolicited in the
|
||||
# ServerHello
|
||||
$message->set_extension(TLSProxy::Message::EXT_CRYPTOPRO_BUG_EXTENSION, "");
|
||||
$message->dupext(TLSProxy::Message::EXT_CRYPTOPRO_BUG_EXTENSION);
|
||||
$message->repack();
|
||||
}
|
||||
}
|
||||
@@ -173,9 +175,23 @@ sub inject_unsolicited_extension
|
||||
$sent_unsolisited_extension = 1;
|
||||
}
|
||||
|
||||
sub inject_cryptopro_extension
|
||||
{
|
||||
my $proxy = shift;
|
||||
|
||||
# We're only interested in the initial ClientHello
|
||||
if ($proxy->flight != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $message = ${$proxy->message_list}[0];
|
||||
$message->set_extension(TLSProxy::Message::EXT_CRYPTOPRO_BUG_EXTENSION, "");
|
||||
$message->repack();
|
||||
}
|
||||
|
||||
# Test 1-2: Sending a duplicate extension should fail.
|
||||
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
|
||||
plan tests => 7;
|
||||
plan tests => 8;
|
||||
ok($fatal_alert, "Duplicate ClientHello extension");
|
||||
|
||||
$fatal_alert = 0;
|
||||
@@ -234,3 +250,11 @@ SKIP: {
|
||||
$proxy->start();
|
||||
ok($fatal_alert, "Unsolicited server name extension (TLSv1.3)");
|
||||
}
|
||||
|
||||
#Test 8: Send the cryptopro extension in a ClientHello. Normally this is an
|
||||
# unsolicited extension only ever seen in the ServerHello. We should
|
||||
# ignore it in a ClientHello
|
||||
$proxy->clear();
|
||||
$proxy->filter(\&inject_cryptopro_extension);
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->success(), "Cryptopro extension in ClientHello");
|
||||
@@ -12,11 +12,11 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
||||
setup("test_gost");
|
||||
|
||||
# The GOST ciphers are dynamically loaded via the GOST engine, so we must be
|
||||
# able to support that. The engine also uses DSA and CMS symbols, so we skip
|
||||
# this test on no-dsa or no-cms.
|
||||
# able to support that. The engine also uses DSA, CMS and CMAC symbols, so we
|
||||
# skip this test on no-dsa, no-cms or no-cmac.
|
||||
plan skip_all => "GOST support is disabled in this OpenSSL build"
|
||||
if disabled("gost") || disabled("engine") || disabled("dynamic-engine")
|
||||
|| disabled("dsa") || disabled("cms");
|
||||
|| disabled("dsa") || disabled("cms") || disabled("cmac");
|
||||
|
||||
plan skip_all => "TLSv1.3 or TLSv1.2 are disabled in this OpenSSL build"
|
||||
if disabled("tls1_3") || disabled("tls1_2");
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
use OpenSSL::Test qw/:DEFAULT bldtop_dir bldtop_file/;
|
||||
use OpenSSL::Test::Utils;
|
||||
use File::Temp qw(tempfile);
|
||||
|
||||
#Load configdata.pm
|
||||
|
||||
@@ -20,7 +21,7 @@ use configdata;
|
||||
plan skip_all => "Test only supported in a shared build" if disabled("shared");
|
||||
plan skip_all => "Test is disabled on AIX" if config('target') =~ m|^aix|;
|
||||
|
||||
plan tests => 4;
|
||||
plan tests => 10;
|
||||
|
||||
# When libssl and libcrypto are compiled on Linux with "-rpath", but not
|
||||
# "--enable-new-dtags", the RPATH takes precedence over LD_LIBRARY_PATH,
|
||||
@@ -30,14 +31,31 @@ plan tests => 4;
|
||||
my $libcrypto = bldtop_file(shlib('libcrypto'));
|
||||
my $libssl = bldtop_file(shlib('libssl'));
|
||||
|
||||
ok(run(test(["shlibloadtest", "-crypto_first", $libcrypto, $libssl])),
|
||||
"running shlibloadtest -crypto_first");
|
||||
ok(run(test(["shlibloadtest", "-ssl_first", $libcrypto, $libssl])),
|
||||
"running shlibloadtest -ssl_first");
|
||||
ok(run(test(["shlibloadtest", "-just_crypto", $libcrypto, $libssl])),
|
||||
"running shlibloadtest -just_crypto");
|
||||
ok(run(test(["shlibloadtest", "-dso_ref", $libcrypto, $libssl])),
|
||||
"running shlibloadtest -dso_ref");
|
||||
(my $fh, my $filename) = tempfile();
|
||||
ok(run(test(["shlibloadtest", "-crypto_first", $libcrypto, $libssl, $filename])),
|
||||
"running shlibloadtest -crypto_first $filename");
|
||||
ok(check_atexit($fh));
|
||||
unlink $filename;
|
||||
($fh, $filename) = tempfile();
|
||||
ok(run(test(["shlibloadtest", "-ssl_first", $libcrypto, $libssl, $filename])),
|
||||
"running shlibloadtest -ssl_first $filename");
|
||||
ok(check_atexit($fh));
|
||||
unlink $filename;
|
||||
($fh, $filename) = tempfile();
|
||||
ok(run(test(["shlibloadtest", "-just_crypto", $libcrypto, $libssl, $filename])),
|
||||
"running shlibloadtest -just_crypto $filename");
|
||||
ok(check_atexit($fh));
|
||||
unlink $filename;
|
||||
($fh, $filename) = tempfile();
|
||||
ok(run(test(["shlibloadtest", "-dso_ref", $libcrypto, $libssl, $filename])),
|
||||
"running shlibloadtest -dso_ref $filename");
|
||||
ok(check_atexit($fh));
|
||||
unlink $filename;
|
||||
($fh, $filename) = tempfile();
|
||||
ok(run(test(["shlibloadtest", "-no_atexit", $libcrypto, $libssl, $filename])),
|
||||
"running shlibloadtest -no_atexit $filename");
|
||||
ok(!check_atexit($fh));
|
||||
unlink $filename;
|
||||
|
||||
sub shlib {
|
||||
my $lib = shift;
|
||||
@@ -49,3 +67,12 @@ sub shlib {
|
||||
$lib =~ s|\.\$\(SHLIB_VERSION_NUMBER\)|.$config{shlib_version}|;
|
||||
return $lib;
|
||||
}
|
||||
|
||||
sub check_atexit {
|
||||
my $fh = shift;
|
||||
my $data = <$fh>;
|
||||
|
||||
return 1 if (defined $data && $data =~ m/atexit\(\) run/);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+152
-69
@@ -14,13 +14,14 @@
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/ossl_typ.h>
|
||||
#include "internal/dso_conf.h"
|
||||
#include "testutil.h"
|
||||
|
||||
typedef void DSO;
|
||||
|
||||
typedef const SSL_METHOD * (*TLS_method_t)(void);
|
||||
typedef SSL_CTX * (*SSL_CTX_new_t)(const SSL_METHOD *meth);
|
||||
typedef void (*SSL_CTX_free_t)(SSL_CTX *);
|
||||
typedef int (*OPENSSL_init_crypto_t)(uint64_t, void *);
|
||||
typedef int (*OPENSSL_atexit_t)(void (*handler)(void));
|
||||
typedef unsigned long (*ERR_get_error_t)(void);
|
||||
typedef unsigned long (*OPENSSL_version_major_t)(void);
|
||||
typedef unsigned long (*OPENSSL_version_minor_t)(void);
|
||||
@@ -32,12 +33,14 @@ typedef enum test_types_en {
|
||||
CRYPTO_FIRST,
|
||||
SSL_FIRST,
|
||||
JUST_CRYPTO,
|
||||
DSO_REFTEST
|
||||
DSO_REFTEST,
|
||||
NO_ATEXIT
|
||||
} TEST_TYPE;
|
||||
|
||||
static TEST_TYPE test_type;
|
||||
static const char *path_crypto;
|
||||
static const char *path_ssl;
|
||||
static const char *path_atexit;
|
||||
|
||||
#ifdef DSO_DLFCN
|
||||
|
||||
@@ -101,6 +104,20 @@ static int shlib_close(SHLIB lib)
|
||||
|
||||
#if defined(DSO_DLFCN) || defined(DSO_WIN32)
|
||||
|
||||
static int atexit_handler_done = 0;
|
||||
|
||||
static void atexit_handler(void)
|
||||
{
|
||||
FILE *atexit_file = fopen(path_atexit, "w");
|
||||
|
||||
if (atexit_file == NULL)
|
||||
return;
|
||||
|
||||
fprintf(atexit_file, "atexit() run\n");
|
||||
fclose(atexit_file);
|
||||
atexit_handler_done++;
|
||||
}
|
||||
|
||||
static int test_lib(void)
|
||||
{
|
||||
SHLIB ssllib = SHLIB_INIT;
|
||||
@@ -109,7 +126,7 @@ static int test_lib(void)
|
||||
union {
|
||||
void (*func)(void);
|
||||
SHLIB_SYM sym;
|
||||
} symbols[4];
|
||||
} symbols[5];
|
||||
TLS_method_t myTLS_method;
|
||||
SSL_CTX_new_t mySSL_CTX_new;
|
||||
SSL_CTX_free_t mySSL_CTX_free;
|
||||
@@ -117,65 +134,100 @@ static int test_lib(void)
|
||||
OPENSSL_version_major_t myOPENSSL_version_major;
|
||||
OPENSSL_version_minor_t myOPENSSL_version_minor;
|
||||
OPENSSL_version_patch_t myOPENSSL_version_patch;
|
||||
OPENSSL_atexit_t myOPENSSL_atexit;
|
||||
int result = 0;
|
||||
|
||||
switch (test_type) {
|
||||
case JUST_CRYPTO:
|
||||
if (!TEST_true(shlib_load(path_crypto, &cryptolib)))
|
||||
goto end;
|
||||
break;
|
||||
case CRYPTO_FIRST:
|
||||
if (!TEST_true(shlib_load(path_crypto, &cryptolib))
|
||||
|| !TEST_true(shlib_load(path_ssl, &ssllib)))
|
||||
goto end;
|
||||
break;
|
||||
case SSL_FIRST:
|
||||
if (!TEST_true(shlib_load(path_ssl, &ssllib))
|
||||
|| !TEST_true(shlib_load(path_crypto, &cryptolib)))
|
||||
goto end;
|
||||
break;
|
||||
case DSO_REFTEST:
|
||||
if (!TEST_true(shlib_load(path_crypto, &cryptolib)))
|
||||
case NO_ATEXIT:
|
||||
case CRYPTO_FIRST:
|
||||
if (!shlib_load(path_crypto, &cryptolib)) {
|
||||
fprintf(stderr, "Failed to load libcrypto\n");
|
||||
goto end;
|
||||
}
|
||||
if (test_type != CRYPTO_FIRST)
|
||||
break;
|
||||
/* Fall through */
|
||||
|
||||
case SSL_FIRST:
|
||||
if (!shlib_load(path_ssl, &ssllib)) {
|
||||
fprintf(stderr, "Failed to load libssl\n");
|
||||
goto end;
|
||||
}
|
||||
if (test_type != SSL_FIRST)
|
||||
break;
|
||||
if (!shlib_load(path_crypto, &cryptolib)) {
|
||||
fprintf(stderr, "Failed to load libcrypto\n");
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (test_type != JUST_CRYPTO && test_type != DSO_REFTEST) {
|
||||
if (!TEST_true(shlib_sym(ssllib, "TLS_method", &symbols[0].sym))
|
||||
|| !TEST_true(shlib_sym(ssllib, "SSL_CTX_new", &symbols[1].sym))
|
||||
|| !TEST_true(shlib_sym(ssllib, "SSL_CTX_free", &symbols[2].sym)))
|
||||
if (test_type == NO_ATEXIT) {
|
||||
OPENSSL_init_crypto_t myOPENSSL_init_crypto;
|
||||
|
||||
if (!shlib_sym(cryptolib, "OPENSSL_init_crypto", &symbols[0].sym)) {
|
||||
fprintf(stderr, "Failed to load OPENSSL_init_crypto symbol\n");
|
||||
goto end;
|
||||
}
|
||||
myOPENSSL_init_crypto = (OPENSSL_init_crypto_t)symbols[0].func;
|
||||
if (!myOPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, NULL)) {
|
||||
fprintf(stderr, "Failed to initialise libcrypto\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (test_type != JUST_CRYPTO
|
||||
&& test_type != DSO_REFTEST
|
||||
&& test_type != NO_ATEXIT) {
|
||||
if (!shlib_sym(ssllib, "TLS_method", &symbols[0].sym)
|
||||
|| !shlib_sym(ssllib, "SSL_CTX_new", &symbols[1].sym)
|
||||
|| !shlib_sym(ssllib, "SSL_CTX_free", &symbols[2].sym)) {
|
||||
fprintf(stderr, "Failed to load libssl symbols\n");
|
||||
goto end;
|
||||
}
|
||||
myTLS_method = (TLS_method_t)symbols[0].func;
|
||||
mySSL_CTX_new = (SSL_CTX_new_t)symbols[1].func;
|
||||
mySSL_CTX_free = (SSL_CTX_free_t)symbols[2].func;
|
||||
if (!TEST_ptr(ctx = mySSL_CTX_new(myTLS_method())))
|
||||
ctx = mySSL_CTX_new(myTLS_method());
|
||||
if (ctx == NULL) {
|
||||
fprintf(stderr, "Failed to create SSL_CTX\n");
|
||||
goto end;
|
||||
}
|
||||
mySSL_CTX_free(ctx);
|
||||
}
|
||||
|
||||
if (!TEST_true(shlib_sym(cryptolib, "ERR_get_error", &symbols[0].sym))
|
||||
|| !TEST_true(shlib_sym(cryptolib, "OPENSSL_version_major",
|
||||
&symbols[1].sym))
|
||||
|| !TEST_true(shlib_sym(cryptolib, "OPENSSL_version_minor",
|
||||
&symbols[2].sym))
|
||||
|| !TEST_true(shlib_sym(cryptolib, "OPENSSL_version_patch",
|
||||
&symbols[3].sym)))
|
||||
if (!shlib_sym(cryptolib, "ERR_get_error", &symbols[0].sym)
|
||||
|| !shlib_sym(cryptolib, "OPENSSL_version_major", &symbols[1].sym)
|
||||
|| !shlib_sym(cryptolib, "OPENSSL_version_minor", &symbols[2].sym)
|
||||
|| !shlib_sym(cryptolib, "OPENSSL_version_patch", &symbols[3].sym)
|
||||
|| !shlib_sym(cryptolib, "OPENSSL_atexit", &symbols[4].sym)) {
|
||||
fprintf(stderr, "Failed to load libcrypto symbols\n");
|
||||
goto end;
|
||||
}
|
||||
myERR_get_error = (ERR_get_error_t)symbols[0].func;
|
||||
if (!TEST_int_eq(myERR_get_error(), 0))
|
||||
if (myERR_get_error() != 0) {
|
||||
fprintf(stderr, "Unexpected ERR_get_error() response\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Make sure the libraries are a compatible version */
|
||||
/* Library and header version should be identical in this test */
|
||||
myOPENSSL_version_major = (OPENSSL_version_major_t)symbols[1].func;
|
||||
myOPENSSL_version_minor = (OPENSSL_version_minor_t)symbols[2].func;
|
||||
myOPENSSL_version_patch = (OPENSSL_version_patch_t)symbols[3].func;
|
||||
if (!TEST_int_eq(myOPENSSL_version_major(), OPENSSL_VERSION_MAJOR))
|
||||
if (myOPENSSL_version_major() != OPENSSL_VERSION_MAJOR
|
||||
|| myOPENSSL_version_minor() != OPENSSL_VERSION_MINOR
|
||||
|| myOPENSSL_version_patch() != OPENSSL_VERSION_PATCH) {
|
||||
fprintf(stderr, "Invalid library version number\n");
|
||||
goto end;
|
||||
if (!TEST_int_ge(myOPENSSL_version_minor(), OPENSSL_VERSION_MINOR))
|
||||
goto end;
|
||||
if (myOPENSSL_version_minor() == OPENSSL_VERSION_MINOR
|
||||
&& !TEST_int_ge(myOPENSSL_version_patch(), OPENSSL_VERSION_PATCH))
|
||||
}
|
||||
|
||||
myOPENSSL_atexit = (OPENSSL_atexit_t)symbols[4].func;
|
||||
if (!myOPENSSL_atexit(atexit_handler)) {
|
||||
fprintf(stderr, "Failed to register atexit handler\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (test_type == DSO_REFTEST) {
|
||||
# ifdef DSO_DLFCN
|
||||
@@ -190,10 +242,11 @@ static int test_lib(void)
|
||||
* will always return an error, because DSO_pathbyaddr() is not
|
||||
* implemented there.
|
||||
*/
|
||||
if (!TEST_true(shlib_sym(cryptolib, "DSO_dsobyaddr", &symbols[0].sym))
|
||||
|| !TEST_true(shlib_sym(cryptolib, "DSO_free",
|
||||
&symbols[1].sym)))
|
||||
if (!shlib_sym(cryptolib, "DSO_dsobyaddr", &symbols[0].sym)
|
||||
|| !shlib_sym(cryptolib, "DSO_free", &symbols[1].sym)) {
|
||||
fprintf(stderr, "Unable to load DSO symbols\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
myDSO_dsobyaddr = (DSO_dsobyaddr_t)symbols[0].func;
|
||||
myDSO_free = (DSO_free_t)symbols[1].func;
|
||||
@@ -201,34 +254,45 @@ static int test_lib(void)
|
||||
{
|
||||
DSO *hndl;
|
||||
/* use known symbol from crypto module */
|
||||
if (!TEST_ptr(hndl = myDSO_dsobyaddr((void (*)(void))ERR_get_error, 0)))
|
||||
hndl = myDSO_dsobyaddr((void (*)(void))myERR_get_error, 0);
|
||||
if (hndl == NULL) {
|
||||
fprintf(stderr, "DSO_dsobyaddr() failed\n");
|
||||
goto end;
|
||||
}
|
||||
myDSO_free(hndl);
|
||||
}
|
||||
# endif /* DSO_DLFCN */
|
||||
}
|
||||
|
||||
switch (test_type) {
|
||||
case JUST_CRYPTO:
|
||||
if (!TEST_true(shlib_close(cryptolib)))
|
||||
goto end;
|
||||
break;
|
||||
case CRYPTO_FIRST:
|
||||
if (!TEST_true(shlib_close(cryptolib))
|
||||
|| !TEST_true(shlib_close(ssllib)))
|
||||
goto end;
|
||||
break;
|
||||
case SSL_FIRST:
|
||||
if (!TEST_true(shlib_close(ssllib))
|
||||
|| !TEST_true(shlib_close(cryptolib)))
|
||||
goto end;
|
||||
break;
|
||||
case DSO_REFTEST:
|
||||
if (!TEST_true(shlib_close(cryptolib)))
|
||||
goto end;
|
||||
break;
|
||||
if (!shlib_close(cryptolib)) {
|
||||
fprintf(stderr, "Failed to close libcrypto\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (test_type == CRYPTO_FIRST || test_type == SSL_FIRST) {
|
||||
if (!shlib_close(ssllib)) {
|
||||
fprintf(stderr, "Failed to close libssl\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
# if defined(OPENSSL_NO_PINSHARED) \
|
||||
&& defined(__GLIBC__) \
|
||||
&& defined(__GLIBC_PREREQ) \
|
||||
&& defined(OPENSSL_SYS_LINUX)
|
||||
# if __GLIBC_PREREQ(2, 3)
|
||||
/*
|
||||
* If we didn't pin the so then we are hopefully on a platform that supports
|
||||
* running atexit() on so unload. If not we might crash. We know this is
|
||||
* true on linux since glibc 2.2.3
|
||||
*/
|
||||
if (test_type != NO_ATEXIT && atexit_handler_done != 1) {
|
||||
fprintf(stderr, "atexit() handler did not run\n");
|
||||
goto end;
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
result = 1;
|
||||
end:
|
||||
return result;
|
||||
@@ -236,9 +300,21 @@ end:
|
||||
#endif
|
||||
|
||||
|
||||
int setup_tests(void)
|
||||
/*
|
||||
* shlibloadtest should not use the normal test framework because we don't want
|
||||
* it to link against libcrypto (which the framework uses). The point of the
|
||||
* test is to check dynamic loading and unloading of libcrypto/libssl.
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *p = test_get_argument(0);
|
||||
const char *p;
|
||||
|
||||
if (argc != 5) {
|
||||
fprintf(stderr, "Incorrect number of arguments\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
p = argv[1];
|
||||
|
||||
if (strcmp(p, "-crypto_first") == 0) {
|
||||
test_type = CRYPTO_FIRST;
|
||||
@@ -247,17 +323,24 @@ int setup_tests(void)
|
||||
} else if (strcmp(p, "-just_crypto") == 0) {
|
||||
test_type = JUST_CRYPTO;
|
||||
} else if (strcmp(p, "-dso_ref") == 0) {
|
||||
test_type = JUST_CRYPTO;
|
||||
test_type = DSO_REFTEST;
|
||||
} else if (strcmp(p, "-no_atexit") == 0) {
|
||||
test_type = NO_ATEXIT;
|
||||
} else {
|
||||
TEST_error("Unrecognised argument");
|
||||
return 0;
|
||||
fprintf(stderr, "Unrecognised argument\n");
|
||||
return 1;
|
||||
}
|
||||
path_crypto = argv[2];
|
||||
path_ssl = argv[3];
|
||||
path_atexit = argv[4];
|
||||
if (path_crypto == NULL || path_ssl == NULL) {
|
||||
fprintf(stderr, "Invalid libcrypto/libssl path\n");
|
||||
return 1;
|
||||
}
|
||||
if (!TEST_ptr(path_crypto = test_get_argument(1))
|
||||
|| !TEST_ptr(path_ssl = test_get_argument(2)))
|
||||
return 0;
|
||||
|
||||
#if defined(DSO_DLFCN) || defined(DSO_WIN32)
|
||||
ADD_TEST(test_lib);
|
||||
if (!test_lib())
|
||||
return 1;
|
||||
#endif
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
+4
-2
@@ -657,7 +657,8 @@ static int execute_test_large_message(const SSL_METHOD *smeth,
|
||||
return testresult;
|
||||
}
|
||||
|
||||
#if !defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_KTLS)
|
||||
#if !defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_KTLS) \
|
||||
&& !defined(OPENSSL_NO_SOCK)
|
||||
|
||||
/* sock must be connected */
|
||||
static int ktls_chk_platform(int sock)
|
||||
@@ -6053,7 +6054,8 @@ int setup_tests(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_KTLS)
|
||||
#if !defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_KTLS) \
|
||||
&& !defined(OPENSSL_NO_SOCK)
|
||||
ADD_TEST(test_ktls_client_server);
|
||||
ADD_TEST(test_ktls_no_client_server);
|
||||
ADD_TEST(test_ktls_client_no_server);
|
||||
|
||||
+6
-9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -436,7 +436,7 @@ int mempacket_test_inject(BIO *bio, const char *in, int inl, int pktnum,
|
||||
{
|
||||
MEMPACKET_TEST_CTX *ctx = BIO_get_data(bio);
|
||||
MEMPACKET *thispkt = NULL, *looppkt, *nextpkt, *allpkts[3];
|
||||
int i, duprec = ctx->duprec > 0;
|
||||
int i, duprec;
|
||||
const unsigned char *inu = (const unsigned char *)in;
|
||||
size_t len = ((inu[RECORD_LEN_HI] << 8) | inu[RECORD_LEN_LO])
|
||||
+ DTLS1_RT_HEADER_LENGTH;
|
||||
@@ -449,6 +449,8 @@ int mempacket_test_inject(BIO *bio, const char *in, int inl, int pktnum,
|
||||
|
||||
if ((size_t)inl == len)
|
||||
duprec = 0;
|
||||
else
|
||||
duprec = ctx->duprec > 0;
|
||||
|
||||
/* We don't support arbitrary injection when duplicating records */
|
||||
if (duprec && pktnum != -1)
|
||||
@@ -663,7 +665,7 @@ int create_ssl_ctx_pair(const SSL_METHOD *sm, const SSL_METHOD *cm,
|
||||
|
||||
#define MAXLOOPS 1000000
|
||||
|
||||
#ifndef OPENSSL_NO_KTLS
|
||||
#if !defined(OPENSSL_NO_KTLS) && !defined(OPENSSL_NO_SOCK)
|
||||
static int set_nb(int fd)
|
||||
{
|
||||
int flags;
|
||||
@@ -736,12 +738,6 @@ success:
|
||||
close(afd);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
int create_test_sockets(int *cfd, int *sfd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int create_ssl_objects2(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,
|
||||
SSL **cssl, int sfd, int cfd)
|
||||
@@ -775,6 +771,7 @@ int create_ssl_objects2(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,
|
||||
BIO_free(c_to_s_bio);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NOTE: Transfers control of the BIOs - this function will free them on error
|
||||
|
||||
Reference in New Issue
Block a user