Latest update
This commit is contained in:
+3
-2
@@ -6,7 +6,8 @@ test/recipes/, named {nn}-test_{name}.t, where {nn} is a two digit number and
|
||||
{name} is a unique name of your choice.
|
||||
|
||||
Please note that if a test involves a new testing executable, you will need to
|
||||
do some additions in test/Makefile. More on this later.
|
||||
do some additions in test/build.info. Please refer to the section "Changes to
|
||||
test/build.info" below.
|
||||
|
||||
|
||||
Naming conventions
|
||||
@@ -100,7 +101,7 @@ to modify the include paths and source files if you don't want to use the
|
||||
basic test framework:
|
||||
|
||||
SOURCE[{name}]={name}.c
|
||||
INCLUDE[{name}]=.. ../include
|
||||
INCLUDE[{name}]=.. ../include ../apps/include
|
||||
DEPEND[{name}]=../libcrypto libtestutil.a
|
||||
|
||||
Generic form of C test executables
|
||||
|
||||
@@ -24,8 +24,8 @@ struct testdata {
|
||||
int expected_type; /* expected type after set/set_string_gmt */
|
||||
int check_result; /* check result */
|
||||
time_t t; /* expected time_t*/
|
||||
int cmp_result; /* compariston to baseline result */
|
||||
int convert_result; /* convertion result */
|
||||
int cmp_result; /* comparison to baseline result */
|
||||
int convert_result; /* conversion result */
|
||||
};
|
||||
|
||||
static struct testdata tbl_testdata_pos[] = {
|
||||
|
||||
@@ -181,6 +181,45 @@ finish:
|
||||
return ok;
|
||||
}
|
||||
|
||||
static int test_bio_nonclear_rst(void)
|
||||
{
|
||||
int ok = 0;
|
||||
BIO *bio = NULL;
|
||||
char data[16];
|
||||
|
||||
bio = BIO_new(BIO_s_mem());
|
||||
if (!TEST_ptr(bio))
|
||||
goto finish;
|
||||
if (!TEST_int_eq(BIO_puts(bio, "Hello World\n"), 12))
|
||||
goto finish;
|
||||
|
||||
BIO_set_flags(bio, BIO_FLAGS_NONCLEAR_RST);
|
||||
|
||||
if (!TEST_int_eq(BIO_read(bio, data, 16), 12))
|
||||
goto finish;
|
||||
if (!TEST_mem_eq(data, 12, "Hello World\n", 12))
|
||||
goto finish;
|
||||
if (!TEST_int_gt(BIO_reset(bio), 0))
|
||||
goto finish;
|
||||
|
||||
if (!TEST_int_eq(BIO_read(bio, data, 16), 12))
|
||||
goto finish;
|
||||
if (!TEST_mem_eq(data, 12, "Hello World\n", 12))
|
||||
goto finish;
|
||||
|
||||
BIO_clear_flags(bio, BIO_FLAGS_NONCLEAR_RST);
|
||||
if (!TEST_int_gt(BIO_reset(bio), 0))
|
||||
goto finish;
|
||||
|
||||
if (!TEST_int_lt(BIO_read(bio, data, 16), 1))
|
||||
goto finish;
|
||||
|
||||
ok = 1;
|
||||
|
||||
finish:
|
||||
BIO_free(bio);
|
||||
return ok;
|
||||
}
|
||||
|
||||
int global_init(void)
|
||||
{
|
||||
@@ -196,5 +235,6 @@ int setup_tests(void)
|
||||
ADD_TEST(test_bio_new_mem_buf);
|
||||
ADD_TEST(test_bio_rdonly_mem_buf);
|
||||
ADD_TEST(test_bio_rdwr_rdonly);
|
||||
ADD_TEST(test_bio_nonclear_rst);
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by statistics/bn_rand_range.py in the OpenSSL tool repository.
|
||||
*
|
||||
* Copyright 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
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
static const struct {
|
||||
unsigned int range;
|
||||
unsigned int iterations;
|
||||
double critical;
|
||||
} rand_range_cases[] = {
|
||||
{ 2, 200, 3.841459 },
|
||||
{ 3, 300, 5.991465 },
|
||||
{ 4, 400, 7.814728 },
|
||||
{ 5, 500, 9.487729 },
|
||||
{ 6, 600, 11.070498 },
|
||||
{ 7, 700, 12.591587 },
|
||||
{ 8, 800, 14.067140 },
|
||||
{ 9, 900, 15.507313 },
|
||||
{ 10, 1000, 16.918978 },
|
||||
{ 11, 1100, 18.307038 },
|
||||
{ 12, 1200, 19.675138 },
|
||||
{ 13, 1300, 21.026070 },
|
||||
{ 14, 1400, 22.362032 },
|
||||
{ 15, 1500, 23.684791 },
|
||||
{ 16, 1600, 24.995790 },
|
||||
{ 17, 1700, 26.296228 },
|
||||
{ 18, 1800, 27.587112 },
|
||||
{ 19, 1900, 28.869299 },
|
||||
{ 20, 2000, 30.143527 },
|
||||
{ 30, 3000, 42.556968 },
|
||||
{ 40, 4000, 54.572228 },
|
||||
{ 50, 5000, 66.338649 },
|
||||
{ 60, 6000, 77.930524 },
|
||||
{ 70, 7000, 89.391208 },
|
||||
{ 80, 8000, 100.748619 },
|
||||
{ 90, 9000, 112.021986 },
|
||||
{ 100, 10000, 123.225221 },
|
||||
{ 1000, 10000, 1073.642651 },
|
||||
{ 2000, 20000, 2104.128222 },
|
||||
{ 3000, 30000, 3127.515432 },
|
||||
{ 4000, 40000, 4147.230012 },
|
||||
{ 5000, 50000, 5164.598069 },
|
||||
{ 6000, 60000, 6180.299514 },
|
||||
{ 7000, 70000, 7194.738181 },
|
||||
{ 8000, 80000, 8208.177159 },
|
||||
{ 9000, 90000, 9220.799176 },
|
||||
{ 10000, 100000, 10232.737266 },
|
||||
};
|
||||
|
||||
static const int binomial_critical = 29;
|
||||
|
||||
+100
-31
@@ -1956,25 +1956,27 @@ static int test_rand(void)
|
||||
|
||||
/*
|
||||
* Run some statistical tests to provide a degree confidence that the
|
||||
* BN_rand_range() function works as expected. The critical value
|
||||
* is computed using the R statistical suite:
|
||||
* BN_rand_range() function works as expected. The test cases and
|
||||
* critical values are generated by the bn_rand_range script.
|
||||
*
|
||||
* qchisq(alpha, df=iterations - 1)
|
||||
* Each individual test is a Chi^2 goodness of fit for a specified number
|
||||
* of samples and range. The samples are assumed to be independent and
|
||||
* that they are from a discrete uniform distribution.
|
||||
*
|
||||
* where alpha is the significance level (0.95 is used here) and iterations
|
||||
* is the number of samples being drawn.
|
||||
* Some of these individual tests are expected to fail, the success/failure
|
||||
* of each is an independent Bernoulli trial. The number of such successes
|
||||
* will form a binomial distribution. The count of the successes is compared
|
||||
* against a precomputed critical value to determine the overall outcome.
|
||||
*/
|
||||
static const struct {
|
||||
struct rand_range_case {
|
||||
unsigned int range;
|
||||
unsigned int iterations;
|
||||
double critical;
|
||||
} rand_range_cases[] = {
|
||||
{ 2, 100, 123.2252 /* = qchisq(.95, df=99) */ },
|
||||
{ 12, 1000, 1073.643 /* = qchisq(.95, df=999) */ },
|
||||
{ 1023, 100000, 100735.7 /* = qchisq(.95, df=99999) */ },
|
||||
};
|
||||
|
||||
static int test_rand_range(int n)
|
||||
#include "bn_rand_range.h"
|
||||
|
||||
static int test_rand_range_single(size_t n)
|
||||
{
|
||||
const unsigned int range = rand_range_cases[n].range;
|
||||
const unsigned int iterations = rand_range_cases[n].iterations;
|
||||
@@ -1998,22 +2000,20 @@ static int test_rand_range(int n)
|
||||
counts[v]++;
|
||||
}
|
||||
|
||||
TEST_note("range %u iterations %u critical %.4f", range, iterations,
|
||||
critical);
|
||||
if (range < 20) {
|
||||
TEST_note("frequencies (expected %.2f)", expected);
|
||||
for (i = 0; i < range; i++)
|
||||
TEST_note(" %2u %6zu", i, counts[i]);
|
||||
}
|
||||
for (i = 0; i < range; i++) {
|
||||
const double delta = counts[i] - expected;
|
||||
sum += delta * delta;
|
||||
}
|
||||
sum /= expected;
|
||||
TEST_note("test statistic %.4f", sum);
|
||||
|
||||
if (TEST_double_lt(sum, critical))
|
||||
res = 1;
|
||||
if (sum > critical) {
|
||||
TEST_info("Chi^2 test negative %.4f > %4.f", sum, critical);
|
||||
TEST_note("test case %zu range %u iterations %u", n + 1, range,
|
||||
iterations);
|
||||
goto err;
|
||||
}
|
||||
|
||||
res = 1;
|
||||
err:
|
||||
BN_free(rng);
|
||||
BN_free(val);
|
||||
@@ -2021,6 +2021,19 @@ err:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int test_rand_range(void)
|
||||
{
|
||||
int n_success = 0;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < OSSL_NELEM(rand_range_cases); i++)
|
||||
n_success += test_rand_range_single(i);
|
||||
if (TEST_int_ge(n_success, binomial_critical))
|
||||
return 1;
|
||||
TEST_note("This test is expeced to fail by chance 0.01%% of the time.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_negzero(void)
|
||||
{
|
||||
BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL;
|
||||
@@ -2236,18 +2249,50 @@ static int test_expmodone(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_smallprime(void)
|
||||
static int test_smallprime(int kBits)
|
||||
{
|
||||
static const int kBits = 10;
|
||||
BIGNUM *r;
|
||||
int st = 0;
|
||||
|
||||
if (!TEST_ptr(r = BN_new())
|
||||
|| !TEST_true(BN_generate_prime_ex(r, (int)kBits, 0,
|
||||
NULL, NULL, NULL))
|
||||
|| !TEST_int_eq(BN_num_bits(r), kBits))
|
||||
if (!TEST_ptr(r = BN_new()))
|
||||
goto err;
|
||||
|
||||
if (kBits <= 1) {
|
||||
if (!TEST_false(BN_generate_prime_ex(r, kBits, 0,
|
||||
NULL, NULL, NULL)))
|
||||
goto err;
|
||||
} else {
|
||||
if (!TEST_true(BN_generate_prime_ex(r, kBits, 0,
|
||||
NULL, NULL, NULL))
|
||||
|| !TEST_int_eq(BN_num_bits(r), kBits))
|
||||
goto err;
|
||||
}
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
BN_free(r);
|
||||
return st;
|
||||
}
|
||||
|
||||
static int test_smallsafeprime(int kBits)
|
||||
{
|
||||
BIGNUM *r;
|
||||
int st = 0;
|
||||
|
||||
if (!TEST_ptr(r = BN_new()))
|
||||
goto err;
|
||||
|
||||
if (kBits <= 5 && kBits != 3) {
|
||||
if (!TEST_false(BN_generate_prime_ex(r, kBits, 1,
|
||||
NULL, NULL, NULL)))
|
||||
goto err;
|
||||
} else {
|
||||
if (!TEST_true(BN_generate_prime_ex(r, kBits, 1,
|
||||
NULL, NULL, NULL))
|
||||
|| !TEST_int_eq(BN_num_bits(r), kBits))
|
||||
goto err;
|
||||
}
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
BN_free(r);
|
||||
@@ -2448,11 +2493,18 @@ static int run_file_tests(int i)
|
||||
return c == 0;
|
||||
}
|
||||
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1,
|
||||
OPT_EOF = 0,
|
||||
OPT_STOCHASTIC_TESTS,
|
||||
OPT_TEST_ENUM
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS *test_get_options(void)
|
||||
{
|
||||
enum { OPT_TEST_ENUM };
|
||||
static const OPTIONS test_options[] = {
|
||||
OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("[file...]\n"),
|
||||
{ "stochastic", OPT_STOCHASTIC_TESTS, '-', "Run stochastic tests" },
|
||||
{ OPT_HELP_STR, 1, '-',
|
||||
"file\tFile to run tests on. Normal tests are not run\n" },
|
||||
{ NULL }
|
||||
@@ -2462,7 +2514,22 @@ const OPTIONS *test_get_options(void)
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
int n = test_get_argument_count();
|
||||
OPTION_CHOICE o;
|
||||
int n, stochastic = 0;
|
||||
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_STOCHASTIC_TESTS:
|
||||
stochastic = 1;
|
||||
break;
|
||||
case OPT_TEST_CASES:
|
||||
break;
|
||||
default:
|
||||
case OPT_ERR:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
n = test_get_argument_count();
|
||||
|
||||
if (!TEST_ptr(ctx = BN_CTX_new()))
|
||||
return 0;
|
||||
@@ -2483,7 +2550,8 @@ int setup_tests(void)
|
||||
ADD_TEST(test_badmod);
|
||||
ADD_TEST(test_expmodzero);
|
||||
ADD_TEST(test_expmodone);
|
||||
ADD_TEST(test_smallprime);
|
||||
ADD_ALL_TESTS(test_smallprime, 16);
|
||||
ADD_ALL_TESTS(test_smallsafeprime, 16);
|
||||
ADD_TEST(test_swap);
|
||||
ADD_TEST(test_ctx_consttime_flag);
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
@@ -2499,7 +2567,8 @@ int setup_tests(void)
|
||||
#endif
|
||||
ADD_ALL_TESTS(test_is_prime, (int)OSSL_NELEM(primes));
|
||||
ADD_ALL_TESTS(test_not_prime, (int)OSSL_NELEM(not_primes));
|
||||
ADD_ALL_TESTS(test_rand_range, OSSL_NELEM(rand_range_cases));
|
||||
if (stochastic)
|
||||
ADD_TEST(test_rand_range);
|
||||
} else {
|
||||
ADD_ALL_TESTS(run_file_tests, n);
|
||||
}
|
||||
|
||||
+27
-14
@@ -1,15 +1,20 @@
|
||||
SUBDIRS=ossl_shim
|
||||
{-
|
||||
use File::Spec::Functions;
|
||||
sub rebase_files
|
||||
{
|
||||
my ($base, $files) = @_;
|
||||
return join(" ", map { "$base/$_" } split(/\s+/, $files));
|
||||
}
|
||||
our $apps_aux_src =
|
||||
join(' ', map { "../apps/$_" } split(/\s+/, $target{apps_aux_src}));
|
||||
""
|
||||
-}
|
||||
|
||||
# TODO: use ../apps/libapps.a instead of direct ../apps source.
|
||||
# This can't currently be done, because some of its units drag in too many
|
||||
# unresolved references that don't apply here. Most of all, ../apps/apps.c
|
||||
# needs to be divided in smaller pieces to be useful here.
|
||||
#
|
||||
# Auxilliary program source (copied from ../apps/build.info)
|
||||
IF[{- $config{target} =~ /^(?:VC-|mingw)/ -}]
|
||||
# It's called 'init', but doesn't have much 'init' in it...
|
||||
$AUXLIBAPPSSRC=../apps/win32_init.c
|
||||
ENDIF
|
||||
IF[{- $config{target} =~ /^vms-/ -}]
|
||||
$AUXLIBAPPSSRC=../apps/vms_term_sock.c ../apps/vms_decc_argv.c
|
||||
ENDIF
|
||||
$LIBAPPSSRC=../apps/opt.c ../apps/bf_prefix.c $AUXLIBAPPSSRC
|
||||
|
||||
IF[{- !$disabled{tests} -}]
|
||||
LIBS{noinst,has_main}=libtestutil.a
|
||||
SOURCE[libtestutil.a]=testutil/basic_output.c testutil/output_helpers.c \
|
||||
@@ -17,7 +22,7 @@ IF[{- !$disabled{tests} -}]
|
||||
testutil/format_output.c testutil/tap_bio.c \
|
||||
testutil/test_cleanup.c testutil/main.c testutil/init.c \
|
||||
testutil/options.c testutil/test_options.c \
|
||||
testutil/apps_mem.c ../apps/opt.c {- $apps_aux_src; -}
|
||||
testutil/apps_mem.c $LIBAPPSSRC
|
||||
INCLUDE[libtestutil.a]=../include ../apps/include ..
|
||||
DEPEND[libtestutil.a]=../libcrypto
|
||||
|
||||
@@ -182,6 +187,9 @@ IF[{- !$disabled{tests} -}]
|
||||
SOURCE[evp_test]=evp_test.c
|
||||
INCLUDE[evp_test]=../include ../apps/include
|
||||
DEPEND[evp_test]=../libcrypto libtestutil.a
|
||||
IF[{- $disabled{legacy} || !$target{dso_scheme} -}]
|
||||
DEFINE[evp_test]=NO_LEGACY_MODULE
|
||||
ENDIF
|
||||
|
||||
SOURCE[evp_extra_test]=evp_extra_test.c
|
||||
INCLUDE[evp_extra_test]=../include ../apps/include ../crypto/include
|
||||
@@ -363,13 +371,13 @@ IF[{- !$disabled{tests} -}]
|
||||
DEPEND[recordlentest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[drbgtest]=drbgtest.c
|
||||
INCLUDE[drbgtest]=../include ../apps/include
|
||||
INCLUDE[drbgtest]=../include ../apps/include ../crypto/include
|
||||
DEPEND[drbgtest]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[drbg_cavs_test]=drbg_cavs_test.c drbg_cavs_data_ctr.c \
|
||||
drbg_cavs_data_hash.c drbg_cavs_data_hmac.c
|
||||
|
||||
INCLUDE[drbg_cavs_test]=../include ../apps/include . ..
|
||||
INCLUDE[drbg_cavs_test]=../include ../apps/include . .. ../crypto/include
|
||||
DEPEND[drbg_cavs_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[x509_dup_cert_test]=x509_dup_cert_test.c
|
||||
@@ -634,6 +642,11 @@ IF[{- !$disabled{tests} -}]
|
||||
SOURCE[params_test]=params_test.c
|
||||
INCLUDE[params_test]=.. ../include ../apps/include
|
||||
DEPEND[params_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
PROGRAMS{noinst}=namemap_internal_test
|
||||
SOURCE[namemap_internal_test]=namemap_internal_test.c
|
||||
INCLUDE[namemap_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[namemap_internal_test]=../libcrypto.a libtestutil.a
|
||||
ENDIF
|
||||
|
||||
{-
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIIBMTCB1wIBADB1MQswCQYDVQQGEwJDTjERMA8GA1UECAwITGlhb25pbmcxETAP
|
||||
BgNVBAcMCFNoZW55YW5nMQwwCgYDVQQKDANUZXQxDDAKBgNVBAsMA1RldDELMAkG
|
||||
A1UEAwwCb28xFzAVBgkqhkiG9w0BCQEWCG9vQG9vLm9vMFkwEwYHKoZIzj0CAQYI
|
||||
KoEcz1UBgi0DQgAE1NjdOpldcjTkuZpdGDNyHAnhK9cB2RZ7jAmFzt7jgEs9OHSg
|
||||
rb3crjz+qGZfqyJ5AyZulQ7gdARzb1H55jvw5qAAMAoGCCqBHM9VAYN1A0kAMEYC
|
||||
IQCacUXA8kyTTDwEm89Yz9qjsbfd8/N32lnzKxuKCcXJwQIhAIpugCbfeWuPxUQO
|
||||
7AvQS3yxBp1yn0FbTT2XVSyYy6To
|
||||
-----END CERTIFICATE REQUEST-----
|
||||
@@ -0,0 +1,14 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICJDCCAcqgAwIBAgIJAOlkpDpSrmVbMAoGCCqBHM9VAYN1MGgxCzAJBgNVBAYT
|
||||
AkNOMQswCQYDVQQIDAJMTjERMA8GA1UEBwwIU2hlbnlhbmcxETAPBgNVBAoMCFRl
|
||||
c3QgT3JnMRAwDgYDVQQLDAdUZXN0IE9VMRQwEgYDVQQDDAtUZXN0IFNNMiBDQTAe
|
||||
Fw0xOTAyMTkwNzA1NDhaFw0yMzAzMzAwNzA1NDhaMGgxCzAJBgNVBAYTAkNOMQsw
|
||||
CQYDVQQIDAJMTjERMA8GA1UEBwwIU2hlbnlhbmcxETAPBgNVBAoMCFRlc3QgT3Jn
|
||||
MRAwDgYDVQQLDAdUZXN0IE9VMRQwEgYDVQQDDAtUZXN0IFNNMiBDQTBZMBMGByqG
|
||||
SM49AgEGCCqBHM9VAYItA0IABHRYnqErofBdXPptvvO7+BSVJxcpHuTGnZ+UPrbU
|
||||
5kVEUMaUnNOeMJZl/vRGimZCm/AkReJmRfnb15ESHR+ssp6jXTBbMB0GA1UdDgQW
|
||||
BBTFjcWu/zJgSZ5SKUlU5Vx4/0W5dDAfBgNVHSMEGDAWgBTFjcWu/zJgSZ5SKUlU
|
||||
5Vx4/0W5dDAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIBBjAKBggqgRzPVQGDdQNI
|
||||
ADBFAiEAs6byi1nSQtFELOw/2tQIv5AEsZFR5MJ/oB2ztXzs2LYCIEfIw4xlUH6X
|
||||
YFhs4RnIa0K9Ng1ebsGPrifYkudwBIk3
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,5 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIGHAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBG0wawIBAQQglktdVbLA5tyXMc+9
|
||||
KV4ikyDaFZNnXqfNAzUVqTlqn8GhRANCAAR0WJ6hK6HwXVz6bb7zu/gUlScXKR7k
|
||||
xp2flD621OZFRFDGlJzTnjCWZf70RopmQpvwJEXiZkX529eREh0frLKe
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -141,7 +141,7 @@ static int test_check_null_numbers(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that a NULL config with a missing envrionment variable returns
|
||||
* Verify that a NULL config with a missing environment variable returns
|
||||
* a failure code.
|
||||
*/
|
||||
if (!TEST_int_eq(unsetenv("FNORD"), 0)
|
||||
|
||||
+1
-1
@@ -193,7 +193,7 @@ static int dh_test(void)
|
||||
BN_free(q);
|
||||
BN_free(g);
|
||||
err2:
|
||||
/* an error occured before priv_key was assigned to dh */
|
||||
/* an error occurred before priv_key was assigned to dh */
|
||||
BN_free(priv_key);
|
||||
err3:
|
||||
success:
|
||||
|
||||
+8
-9
@@ -332,7 +332,7 @@ static int error_check(DRBG_SELFTEST_DATA *td)
|
||||
* Personalisation string tests
|
||||
*/
|
||||
|
||||
/* Test detection of too large personlisation string */
|
||||
/* Test detection of too large personalisation string */
|
||||
if (!init(drbg, td, &t)
|
||||
|| RAND_DRBG_instantiate(drbg, td->pers, drbg->max_perslen + 1) > 0)
|
||||
goto err;
|
||||
@@ -1264,7 +1264,8 @@ static const size_t crngt_num_cases = 6;
|
||||
|
||||
static size_t crngt_case, crngt_idx;
|
||||
|
||||
static int crngt_entropy_cb(unsigned char *buf, unsigned char *md,
|
||||
static int crngt_entropy_cb(OPENSSL_CTX *ctx, RAND_POOL *pool,
|
||||
unsigned char *buf, unsigned char *md,
|
||||
unsigned int *md_size)
|
||||
{
|
||||
size_t i, z;
|
||||
@@ -1288,19 +1289,16 @@ static int test_crngt(int n)
|
||||
size_t ent;
|
||||
int res = 0;
|
||||
int expect;
|
||||
OPENSSL_CTX *ctx = OPENSSL_CTX_new();
|
||||
|
||||
if (!TEST_true(rand_crngt_single_init()))
|
||||
return 0;
|
||||
rand_crngt_cleanup();
|
||||
|
||||
if (!TEST_ptr(drbg = RAND_DRBG_new(dt->nid, dt->flags, NULL)))
|
||||
if (!TEST_ptr(ctx))
|
||||
return 0;
|
||||
if (!TEST_ptr(drbg = RAND_DRBG_new_ex(ctx, dt->nid, dt->flags, NULL)))
|
||||
goto err;
|
||||
ent = (drbg->min_entropylen + CRNGT_BUFSIZ - 1) / CRNGT_BUFSIZ;
|
||||
crngt_case = n % crngt_num_cases;
|
||||
crngt_idx = 0;
|
||||
crngt_get_entropy = &crngt_entropy_cb;
|
||||
if (!TEST_true(rand_crngt_init()))
|
||||
goto err;
|
||||
#ifndef FIPS_MODE
|
||||
if (!TEST_true(RAND_DRBG_set_callbacks(drbg, &rand_crngt_get_entropy,
|
||||
&rand_crngt_cleanup_entropy,
|
||||
@@ -1333,6 +1331,7 @@ err:
|
||||
uninstantiate(drbg);
|
||||
RAND_DRBG_free(drbg);
|
||||
crngt_get_entropy = &rand_crngt_get_entropy_cb;
|
||||
OPENSSL_CTX_free(ctx);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ static int test_dtls_unprocessed(int testidx)
|
||||
|
||||
/*
|
||||
* Create the connection. We use "create_bare_ssl_connection" here so that
|
||||
* we can force the connection to not do "SSL_read" once partly conencted.
|
||||
* we can force the connection to not do "SSL_read" once partly connected.
|
||||
* We don't want to accidentally read the dummy records we injected because
|
||||
* they will fail to decrypt.
|
||||
*/
|
||||
|
||||
@@ -118,6 +118,11 @@ static int x9_62_tests(int n)
|
||||
|
||||
TEST_info("ECDSA KATs for curve %s", OBJ_nid2sn(nid));
|
||||
|
||||
#ifdef FIPS_MODE
|
||||
if (EC_curve_nid2nist(nid) == NULL)
|
||||
return TEST_skip("skip non approved curves");
|
||||
#endif /* FIPS_MODE */
|
||||
|
||||
if (!TEST_ptr(mctx = EVP_MD_CTX_new())
|
||||
/* get the message digest */
|
||||
|| !TEST_ptr(message = OPENSSL_hexstr2buf(tbs, &msg_len))
|
||||
|
||||
+1
-1
@@ -1820,7 +1820,7 @@ static int parameter_test(void)
|
||||
unsigned char *buf = NULL;
|
||||
int r = 0, len;
|
||||
|
||||
if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(NID_secp112r1))
|
||||
if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(NID_secp224r1))
|
||||
|| !TEST_ptr(ecparameters = EC_GROUP_get_ecparameters(group, NULL))
|
||||
|| !TEST_ptr(group2 = EC_GROUP_new_from_ecparameters(ecparameters))
|
||||
|| !TEST_int_eq(EC_GROUP_cmp(group, group2, NULL), 0))
|
||||
|
||||
+1
-1
@@ -279,7 +279,7 @@ static int test_redirect(void)
|
||||
* Try setting test key engine. Both should fail because the
|
||||
* engine has no public key methods.
|
||||
*/
|
||||
if (!TEST_ptr_null(EVP_PKEY_CTX_new(pkey, e))
|
||||
if (!TEST_ptr_null(ctx = EVP_PKEY_CTX_new(pkey, e))
|
||||
|| !TEST_int_le(EVP_PKEY_set1_engine(pkey, e), 0))
|
||||
goto err;
|
||||
|
||||
|
||||
@@ -32,8 +32,21 @@ static int preserves_system_error(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Test that calls to ERR_add_error_[v]data append */
|
||||
static int vdata_appends(void)
|
||||
{
|
||||
const char *data;
|
||||
|
||||
CRYPTOerr(0, ERR_R_MALLOC_FAILURE);
|
||||
ERR_add_error_data(1, "hello ");
|
||||
ERR_add_error_data(1, "world");
|
||||
ERR_get_error_line_data(NULL, NULL, &data, NULL);
|
||||
return TEST_str_eq(data, "hello world");
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(preserves_system_error);
|
||||
ADD_TEST(vdata_appends);
|
||||
return 1;
|
||||
}
|
||||
+11
-6
@@ -301,7 +301,7 @@ static const unsigned char kExampleECPubKeyDER[] = {
|
||||
};
|
||||
|
||||
/*
|
||||
* kExampleBadECKeyDER is a sample EC public key with a wrong OID
|
||||
* kExampleBadECPubKeyDER is a sample EC public key with a wrong OID
|
||||
* 1.2.840.10045.2.2 instead of 1.2.840.10045.2.1 - EC Public Key
|
||||
*/
|
||||
static const unsigned char kExampleBadECPubKeyDER[] = {
|
||||
@@ -599,7 +599,7 @@ static int test_EVP_PKCS82PKEY(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
#if !defined(OPENSSL_NO_SM2) && !defined(FIPS_MODE)
|
||||
|
||||
static int test_EVP_SM2_verify(void)
|
||||
{
|
||||
@@ -1150,8 +1150,8 @@ static int test_EVP_MD_fetch(int tst)
|
||||
|| !TEST_int_eq(EVP_MD_block_size(md), SHA256_CBLOCK))
|
||||
goto err;
|
||||
|
||||
/* Also test EVP_MD_upref() while we're doing this */
|
||||
if (!TEST_true(EVP_MD_upref(md)))
|
||||
/* Also test EVP_MD_up_ref() while we're doing this */
|
||||
if (!TEST_true(EVP_MD_up_ref(md)))
|
||||
goto err;
|
||||
/* Ref count should now be 2. Release both */
|
||||
EVP_MD_meth_free(md);
|
||||
@@ -1178,7 +1178,7 @@ static int test_EVP_MD_fetch(int tst)
|
||||
md = NULL;
|
||||
|
||||
/*
|
||||
* Explicitly asking for the default implementation should succeeed except
|
||||
* Explicitly asking for the default implementation should succeed except
|
||||
* in test 4 where the default provider is not loaded.
|
||||
*/
|
||||
md = EVP_MD_fetch(ctx, "SHA256", "default=yes");
|
||||
@@ -1220,6 +1220,11 @@ static int test_EVP_MD_fetch(int tst)
|
||||
EVP_MD_meth_free(md);
|
||||
OSSL_PROVIDER_unload(defltprov);
|
||||
OSSL_PROVIDER_unload(fipsprov);
|
||||
/* Not normally needed, but we would like to test that
|
||||
* OPENSSL_thread_stop_ex() behaves as expected.
|
||||
*/
|
||||
if (ctx != NULL)
|
||||
OPENSSL_thread_stop_ex(ctx);
|
||||
OPENSSL_CTX_free(ctx);
|
||||
return ret;
|
||||
}
|
||||
@@ -1233,7 +1238,7 @@ int setup_tests(void)
|
||||
#ifndef OPENSSL_NO_EC
|
||||
ADD_TEST(test_EVP_PKCS82PKEY);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
#if !defined(OPENSSL_NO_SM2) && !defined(FIPS_MODE)
|
||||
ADD_TEST(test_EVP_SM2);
|
||||
ADD_TEST(test_EVP_SM2_verify);
|
||||
#endif
|
||||
|
||||
+83
-16
@@ -74,24 +74,57 @@ static int test_kdf_pbkdf2(void)
|
||||
{
|
||||
int ret;
|
||||
EVP_KDF_CTX *kctx;
|
||||
unsigned char out[32];
|
||||
static const unsigned char expected[sizeof(out)] = {
|
||||
0xae, 0x4d, 0x0c, 0x95, 0xaf, 0x6b, 0x46, 0xd3,
|
||||
0x2d, 0x0a, 0xdf, 0xf9, 0x28, 0xf0, 0x6d, 0xd0,
|
||||
0x2a, 0x30, 0x3f, 0x8e, 0xf3, 0xc2, 0x51, 0xdf,
|
||||
0xd6, 0xe2, 0xd8, 0x5a, 0x95, 0x47, 0x4c, 0x43
|
||||
unsigned char out[25];
|
||||
size_t len = 0;
|
||||
const unsigned char expected[sizeof(out)] = {
|
||||
0x34, 0x8c, 0x89, 0xdb, 0xcb, 0xd3, 0x2b, 0x2f,
|
||||
0x32, 0xd8, 0x14, 0xb8, 0x11, 0x6e, 0x84, 0xcf,
|
||||
0x2b, 0x17, 0x34, 0x7e, 0xbc, 0x18, 0x00, 0x18,
|
||||
0x1c
|
||||
};
|
||||
|
||||
ret =
|
||||
TEST_ptr(kctx = EVP_KDF_CTX_new_id(EVP_KDF_PBKDF2))
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PASS, "password",
|
||||
(size_t)8), 0)
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, "salt",
|
||||
(size_t)4), 0)
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_ITER, 2), 0)
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()), 0)
|
||||
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out)), 0)
|
||||
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
|
||||
if (sizeof(len) > 32)
|
||||
len = SIZE_MAX;
|
||||
|
||||
ret = TEST_ptr(kctx = EVP_KDF_CTX_new_id(EVP_KDF_PBKDF2))
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PASS,
|
||||
"passwordPASSWORDpassword",
|
||||
(size_t)24), 0)
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT,
|
||||
"saltSALTsaltSALTsaltSALTsaltSALTsalt",
|
||||
(size_t)36), 0)
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_ITER, 4096), 0)
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()),
|
||||
0)
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PBKDF2_PKCS5_MODE,
|
||||
0), 0)
|
||||
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out)), 0)
|
||||
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected))
|
||||
/* A key length that is too small should fail */
|
||||
&& TEST_int_eq(EVP_KDF_derive(kctx, out, 112 / 8 - 1), 0)
|
||||
/* A key length that is too large should fail */
|
||||
&& (len == 0 || TEST_int_eq(EVP_KDF_derive(kctx, out, len), 0))
|
||||
/* Salt length less than 128 bits should fail */
|
||||
&& TEST_int_eq(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT,
|
||||
"123456781234567",
|
||||
(size_t)15), 0)
|
||||
/* A small iteration count should fail */
|
||||
&& TEST_int_eq(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_ITER, 1), 0)
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PBKDF2_PKCS5_MODE,
|
||||
1), 0)
|
||||
/* Small salts will pass if the "pkcs5" mode is enabled */
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT,
|
||||
"123456781234567",
|
||||
(size_t)15), 0)
|
||||
/* A small iteration count will pass if "pkcs5" mode is enabled */
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_ITER, 1), 0)
|
||||
/*
|
||||
* If the "pkcs5" mode is disabled then the small salt and iter will
|
||||
* fail when the derive gets called.
|
||||
*/
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PBKDF2_PKCS5_MODE,
|
||||
0), 0)
|
||||
&& TEST_int_eq(EVP_KDF_derive(kctx, out, sizeof(out)), 0);
|
||||
|
||||
EVP_KDF_CTX_free(kctx);
|
||||
return ret;
|
||||
@@ -374,6 +407,37 @@ static int test_kdf_get_kdf(void)
|
||||
&& TEST_ptr_eq(kdf1, kdf2);
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_CMS
|
||||
static int test_kdf_x942_asn1(void)
|
||||
{
|
||||
int ret;
|
||||
EVP_KDF_CTX *kctx = NULL;
|
||||
unsigned char out[24];
|
||||
/* RFC2631 Section 2.1.6 Test data */
|
||||
static const unsigned char z[] = {
|
||||
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,
|
||||
0x0e,0x0f,0x10,0x11,0x12,0x13
|
||||
};
|
||||
static const unsigned char expected[sizeof(out)] = {
|
||||
0xa0,0x96,0x61,0x39,0x23,0x76,0xf7,0x04,
|
||||
0x4d,0x90,0x52,0xa3,0x97,0x88,0x32,0x46,
|
||||
0xb6,0x7f,0x5f,0x1e,0xf6,0x3e,0xb5,0xfb
|
||||
};
|
||||
|
||||
ret =
|
||||
TEST_ptr(kctx = EVP_KDF_CTX_new_id(EVP_KDF_X942))
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha1()), 0)
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, z, sizeof(z)), 0)
|
||||
&& TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_CEK_ALG,
|
||||
SN_id_smime_alg_CMS3DESwrap), 0)
|
||||
&& TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out)), 0)
|
||||
&& TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
|
||||
|
||||
EVP_KDF_CTX_free(kctx);
|
||||
return ret;
|
||||
}
|
||||
#endif /* OPENSSL_NO_CMS */
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_kdf_get_kdf);
|
||||
@@ -388,5 +452,8 @@ int setup_tests(void)
|
||||
ADD_TEST(test_kdf_ss_kmac);
|
||||
ADD_TEST(test_kdf_sshkdf);
|
||||
ADD_TEST(test_kdf_x963);
|
||||
#ifndef OPENSSL_NO_CMS
|
||||
ADD_TEST(test_kdf_x942_asn1);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -21,43 +21,119 @@
|
||||
#include <openssl/ec.h>
|
||||
#include "testutil.h"
|
||||
|
||||
static int pkey_param_types[] = {
|
||||
#ifndef OPENSSL_NO_DH
|
||||
EVP_PKEY_DH,
|
||||
static const unsigned char dhparam_bin[] = {
|
||||
0x30,0x82,0x01,0x08,0x02,0x82,0x01,0x01,0x00,0xc0,0xd1,0x2e,0x14,0x18,0xbd,0x03,
|
||||
0xfd,0x39,0xe1,0x99,0xf4,0x93,0x06,0x2d,0x49,0xc6,0xb5,0xb9,0xf0,0x91,0xcb,0x2f,
|
||||
0x48,0x54,0x79,0x7d,0xc4,0x65,0x11,0x55,0xf7,0x99,0xde,0x42,0x83,0x84,0xc0,0xf8,
|
||||
0x88,0x89,0xa0,0xff,0xff,0x7d,0xe8,0xef,0x9e,0xbc,0xf7,0x1d,0x70,0x6d,0x3a,0x33,
|
||||
0x49,0x28,0xa1,0xa3,0xe1,0x41,0xc4,0x8b,0x91,0xf9,0xf2,0xb6,0xe2,0x77,0x79,0x38,
|
||||
0x7d,0x21,0xb3,0xdf,0x79,0x9c,0x5e,0x65,0x16,0x00,0x16,0x82,0xb2,0x36,0x46,0x21,
|
||||
0xac,0xaf,0x86,0xc7,0xe3,0x10,0x44,0x48,0xfb,0xbd,0xad,0x4e,0x11,0x73,0x4c,0x25,
|
||||
0xb0,0x8c,0x1c,0x1e,0x8e,0x58,0x50,0x5e,0x43,0x89,0xe4,0xd9,0x34,0xf8,0x3b,0xcc,
|
||||
0x36,0x2c,0x1b,0xb3,0xb2,0x77,0x0c,0xa5,0x96,0xc1,0x8a,0x38,0xd4,0xe3,0x9c,0x2a,
|
||||
0xde,0x49,0x46,0xc7,0xd4,0xa2,0x47,0xc9,0x0a,0xbd,0x84,0xd4,0x1c,0xbc,0xb6,0x19,
|
||||
0x04,0x94,0x64,0xfa,0x8a,0x11,0x9c,0x5f,0x4a,0x4c,0x0f,0x58,0x81,0x02,0xbf,0xcf,
|
||||
0x87,0x27,0x2b,0xae,0x8e,0xe2,0x61,0x7a,0xdb,0xba,0x23,0x39,0x25,0x44,0xdc,0x22,
|
||||
0x75,0xc3,0x28,0xd9,0x12,0x33,0x84,0x32,0xd4,0x5d,0xd9,0x77,0xf8,0x04,0x90,0x38,
|
||||
0x0a,0xec,0x84,0x93,0x43,0xce,0xe7,0x07,0x42,0x7d,0x2d,0xe0,0x21,0x3b,0x19,0x22,
|
||||
0xa7,0x8f,0x50,0x31,0xda,0xd0,0x0d,0xd3,0x0b,0xdb,0xad,0xed,0x94,0x92,0xff,0x83,
|
||||
0x06,0x7f,0x7f,0xd7,0x7b,0x42,0x5b,0xba,0x93,0x7a,0xeb,0x43,0x5f,0xce,0x59,0x26,
|
||||
0xe8,0x76,0xdc,0xee,0xe2,0xbe,0x36,0x7a,0x83,0x02,0x01,0x02
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
static const unsigned char dsaparam_bin[] = {
|
||||
0x30,0x82,0x02,0x28,0x02,0x82,0x01,0x01,0x00,0xf2,0x85,0x01,0xa5,0xb9,0x56,0x65,
|
||||
0x19,0xff,0x9a,0x7d,0xf9,0x90,0xd6,0xaa,0x73,0xac,0xf7,0x94,0xfa,0x8a,0x64,0x6d,
|
||||
0xa0,0x01,0x42,0xe5,0x45,0xfc,0x53,0x72,0xb0,0x7c,0xe6,0x3b,0xfb,0x09,0x33,0x41,
|
||||
0x27,0xbd,0x00,0xb5,0x18,0x87,0x62,0xa8,0x2b,0xfc,0xd0,0x52,0x4a,0x14,0x2d,0xaa,
|
||||
0x36,0xc6,0xf3,0xa9,0xe3,0x90,0x1b,0x74,0xdf,0x0a,0x6d,0x33,0xba,0xf4,0x32,0x6d,
|
||||
0xba,0x36,0x68,0x1d,0x83,0x36,0x50,0xc6,0x62,0xc0,0x40,0x67,0x0e,0xf6,0x22,0x00,
|
||||
0x62,0x1b,0x76,0x72,0x62,0x5f,0xa0,0xdf,0x38,0xb1,0x1d,0x26,0x70,0x9b,0x84,0x64,
|
||||
0xbb,0x16,0x15,0xc2,0x66,0xb9,0x97,0xd0,0x07,0xf1,0x4b,0x70,0x02,0x03,0xf1,0xd2,
|
||||
0x03,0xdb,0x78,0x8b,0xb4,0xda,0x6f,0x3c,0xe2,0x31,0xa8,0x1c,0x99,0xea,0x9c,0x75,
|
||||
0x28,0x96,0x82,0x16,0x77,0xac,0x79,0x32,0x61,0x87,0xec,0xb7,0xb4,0xc3,0xea,0x12,
|
||||
0x62,0x1f,0x08,0xb8,0x16,0xab,0xcc,0xef,0x28,0xdf,0x06,0x07,0xbe,0xb0,0xdc,0x78,
|
||||
0x83,0x8a,0x70,0x80,0x34,0xe6,0x91,0xe3,0xd3,0x92,0xd9,0xf4,0x56,0x53,0x52,0xb7,
|
||||
0x35,0xf6,0x2a,0xec,0x4b,0xcb,0xa2,0x3c,0xc3,0x0c,0x94,0xa7,0x4e,0x1c,0x42,0x9c,
|
||||
0x72,0x99,0x60,0x8c,0xfe,0xfb,0x60,0x57,0x75,0xf5,0x23,0x11,0x12,0xba,0x97,0xcd,
|
||||
0xad,0x5a,0x0b,0xa6,0x1f,0x6a,0x48,0x2e,0x8d,0xda,0x95,0xc6,0x0e,0x14,0xde,0xf7,
|
||||
0x22,0x55,0xa8,0x6b,0x25,0xdf,0xa2,0xab,0x33,0x65,0x56,0xfc,0x78,0x4f,0x62,0xdf,
|
||||
0x48,0xdd,0xce,0x8b,0xe1,0x76,0xf4,0xf6,0x7f,0x02,0x1d,0x00,0xac,0xb0,0xb8,0x92,
|
||||
0x3b,0x6b,0x61,0xcf,0x36,0x6d,0xf2,0x1e,0x5d,0xe0,0x7b,0xf5,0x73,0x48,0xa3,0x8b,
|
||||
0x86,0x9e,0x88,0xce,0x40,0xf8,0x27,0x6d,0x02,0x82,0x01,0x00,0x77,0x6b,0x89,0xd6,
|
||||
0x8f,0x3d,0xce,0x52,0x30,0x74,0xb2,0xa1,0x13,0x96,0xd5,0x92,0xf2,0xf1,0x6b,0x10,
|
||||
0x31,0x0b,0xf3,0x69,0xaa,0xbf,0x4b,0x6c,0xcb,0x3f,0x6d,0x58,0x76,0x44,0x09,0xf9,
|
||||
0x28,0xef,0xa0,0xe4,0x55,0x77,0x57,0xe0,0xfb,0xcc,0x9a,0x6a,0x2c,0x90,0xec,0x72,
|
||||
0x24,0x0b,0x43,0xc5,0xbc,0x31,0xed,0x1a,0x46,0x2c,0x76,0x42,0x9e,0xc0,0x82,0xfc,
|
||||
0xff,0xf9,0x7e,0xe2,0x1f,0x39,0xf3,0x3b,0xdb,0x27,0x36,0xe7,0xf5,0x3b,0xc2,0x23,
|
||||
0xb6,0xd0,0xcf,0x5b,0x85,0x2e,0x1b,0x00,0x5b,0x31,0xaa,0x72,0x8f,0x37,0xee,0x56,
|
||||
0x71,0xc4,0xfd,0x3c,0x8d,0xfa,0x5b,0xab,0xb1,0xa9,0x52,0x76,0xa0,0xe4,0xe3,0x78,
|
||||
0x83,0x64,0x5d,0xd7,0x6c,0xec,0x9b,0x40,0x65,0xe2,0x0a,0x11,0x19,0x60,0xdd,0xce,
|
||||
0x29,0x9f,0xc6,0x1d,0x0a,0xab,0x8e,0x59,0x25,0xc5,0x0b,0x9c,0x02,0x45,0xba,0x99,
|
||||
0x74,0x22,0x1d,0xc1,0x57,0xca,0x50,0x8c,0x5e,0xdf,0xd8,0x5d,0x43,0xae,0x06,0x28,
|
||||
0x29,0x82,0xf6,0x5a,0xa9,0x51,0xa2,0x04,0x1d,0xbf,0x88,0x15,0x98,0xce,0x8a,0xb4,
|
||||
0x3b,0xe5,0x30,0x29,0xce,0x0c,0x9b,0xf8,0xdb,0xbf,0x06,0x9f,0xd0,0x59,0x18,0xd4,
|
||||
0x0b,0x94,0xbf,0xe9,0x67,0x6b,0x9e,0xf0,0x72,0xc6,0xbf,0x79,0x8f,0x1e,0xa3,0x95,
|
||||
0x24,0xe3,0xcb,0x58,0xb5,0x67,0xd3,0xae,0x79,0xb0,0x28,0x9c,0x9a,0xd0,0xa4,0xe7,
|
||||
0x22,0x15,0xc1,0x8b,0x04,0xb9,0x8a,0xa8,0xb7,0x1b,0x62,0x44,0xc6,0xef,0x4b,0x74,
|
||||
0xd0,0xfd,0xa9,0xb4,0x4e,0xdd,0x7d,0x38,0x60,0xd1,0x40,0xcd
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_EC
|
||||
static const unsigned char ecparam_bin[] = {
|
||||
0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01,0x07
|
||||
};
|
||||
#endif
|
||||
|
||||
static const struct {
|
||||
int type;
|
||||
const unsigned char *param_bin;
|
||||
size_t param_bin_len;
|
||||
} pkey_params [] = {
|
||||
#ifndef OPENSSL_NO_DH
|
||||
{ EVP_PKEY_DH, dhparam_bin, sizeof(dhparam_bin) },
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
EVP_PKEY_DSA,
|
||||
{ EVP_PKEY_DSA, dsaparam_bin, sizeof(dsaparam_bin) },
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
EVP_PKEY_EC
|
||||
{ EVP_PKEY_EC, ecparam_bin, sizeof(ecparam_bin) }
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_EC)
|
||||
|
||||
static int params_bio_test(int id)
|
||||
{
|
||||
int ret;
|
||||
BIO *mem_bio = NULL;
|
||||
int ret, out_len;
|
||||
BIO *in = NULL, *out = NULL;
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
EVP_PKEY *params_key = NULL, *out_key = NULL;
|
||||
int type = pkey_param_types[id];
|
||||
EVP_PKEY *in_key = NULL, *out_key = NULL;
|
||||
unsigned char *out_bin;
|
||||
int type = pkey_params[id].type;
|
||||
|
||||
ret =
|
||||
TEST_ptr(mem_bio = BIO_new(BIO_s_mem()))
|
||||
&& TEST_ptr(ctx = EVP_PKEY_CTX_new_id(type, NULL))
|
||||
&& TEST_int_gt(EVP_PKEY_paramgen_init(ctx), 0)
|
||||
&& (type != EVP_PKEY_EC
|
||||
|| EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, NID_secp256k1) > 0)
|
||||
&& TEST_int_gt(EVP_PKEY_paramgen(ctx, ¶ms_key), 0)
|
||||
&& TEST_int_gt(i2d_KeyParams_bio(mem_bio, params_key), 0)
|
||||
&& TEST_ptr(d2i_KeyParams_bio(type, &out_key, mem_bio))
|
||||
&& TEST_int_gt(EVP_PKEY_cmp_parameters(out_key, params_key), 0);
|
||||
ret = TEST_ptr(ctx = EVP_PKEY_CTX_new_id(type, NULL))
|
||||
&& TEST_ptr(in = BIO_new_mem_buf(pkey_params[id].param_bin,
|
||||
(int)pkey_params[id].param_bin_len))
|
||||
/* Load in pkey params from binary */
|
||||
&& TEST_ptr(d2i_KeyParams_bio(type, &in_key, in))
|
||||
&& TEST_ptr(out = BIO_new(BIO_s_mem()))
|
||||
/* Save pkey params to binary */
|
||||
&& TEST_int_gt(i2d_KeyParams_bio(out, in_key), 0)
|
||||
/* test the output binary is the expected value */
|
||||
&& TEST_int_gt(out_len = BIO_get_mem_data(out, &out_bin), 0)
|
||||
&& TEST_mem_eq(pkey_params[id].param_bin,
|
||||
(int)pkey_params[id].param_bin_len,
|
||||
out_bin, out_len);
|
||||
|
||||
BIO_free(mem_bio);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
EVP_PKEY_free(params_key);
|
||||
BIO_free(in);
|
||||
BIO_free(out);
|
||||
EVP_PKEY_free(in_key);
|
||||
EVP_PKEY_free(out_key);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@@ -67,7 +143,7 @@ int setup_tests(void)
|
||||
#if defined(OPENSSL_NO_DH) && defined(OPENSSL_NO_DSA) && defined(OPENSSL_NO_EC)
|
||||
TEST_note("No DH/DSA/EC support");
|
||||
#else
|
||||
ADD_ALL_TESTS(params_bio_test, OSSL_NELEM(pkey_param_types));
|
||||
ADD_ALL_TESTS(params_bio_test, OSSL_NELEM(pkey_params));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
+53
-3
@@ -14,6 +14,7 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/provider.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/pkcs12.h>
|
||||
#include <openssl/kdf.h>
|
||||
@@ -75,6 +76,9 @@ static int find_key(EVP_PKEY **ppk, const char *name, KEY_LIST *lst);
|
||||
|
||||
static int parse_bin(const char *value, unsigned char **buf, size_t *buflen);
|
||||
|
||||
static OSSL_PROVIDER *defltprov = NULL;
|
||||
static OSSL_PROVIDER *legacyprov = NULL;
|
||||
|
||||
/*
|
||||
* Compare two memory regions for equality, returning zero if they differ.
|
||||
* However, if there is expected to be an error and the actual error
|
||||
@@ -370,6 +374,11 @@ static int digest_test_parse(EVP_TEST *t,
|
||||
return evp_test_buffer_set_count(value, mdata->input);
|
||||
if (strcmp(keyword, "Ncopy") == 0)
|
||||
return evp_test_buffer_ncopy(value, mdata->input);
|
||||
if (strcmp(keyword, "Legacy") == 0) {
|
||||
if (legacyprov == NULL)
|
||||
t->skip = 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -652,6 +661,14 @@ static int cipher_test_enc(EVP_TEST *t, int enc,
|
||||
t->err = "KEY_SET_ERROR";
|
||||
goto err;
|
||||
}
|
||||
/* Check that we get the same IV back */
|
||||
if (expected->iv != NULL
|
||||
&& (EVP_CIPHER_flags(expected->cipher) & EVP_CIPH_CUSTOM_IV) == 0
|
||||
&& !TEST_mem_eq(expected->iv, expected->iv_len,
|
||||
EVP_CIPHER_CTX_iv(ctx), expected->iv_len)) {
|
||||
t->err = "INVALID_IV";
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (expected->aead == EVP_CIPH_CCM_MODE) {
|
||||
if (!EVP_CipherUpdate(ctx, NULL, &tmplen, NULL, out_len)) {
|
||||
@@ -1956,7 +1973,14 @@ static int kdf_test_init(EVP_TEST *t, const char *name)
|
||||
t->skip = 1;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* OPENSSL_NO_SCRYPT */
|
||||
|
||||
#ifdef OPENSSL_NO_CMS
|
||||
if (strcmp(name, "X942KDF") == 0) {
|
||||
t->skip = 1;
|
||||
return 1;
|
||||
}
|
||||
#endif /* OPENSSL_NO_CMS */
|
||||
|
||||
kdf = EVP_get_kdfbyname(name);
|
||||
if (kdf == NULL)
|
||||
@@ -2088,7 +2112,14 @@ static int pkey_kdf_test_init(EVP_TEST *t, const char *name)
|
||||
t->skip = 1;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* OPENSSL_NO_SCRYPT */
|
||||
|
||||
#ifdef OPENSSL_NO_CMS
|
||||
if (strcmp(name, "X942KDF") == 0) {
|
||||
t->skip = 1;
|
||||
return 1;
|
||||
}
|
||||
#endif /* OPENSSL_NO_CMS */
|
||||
|
||||
if (kdf_nid == NID_undef)
|
||||
kdf_nid = OBJ_ln2nid(name);
|
||||
@@ -3053,8 +3084,10 @@ static int run_file_tests(int i)
|
||||
|
||||
while (!BIO_eof(t->s.fp)) {
|
||||
c = parse(t);
|
||||
if (t->skip)
|
||||
if (t->skip) {
|
||||
t->s.numskip++;
|
||||
continue;
|
||||
}
|
||||
if (c == 0 || !run_test(t)) {
|
||||
t->s.errors++;
|
||||
break;
|
||||
@@ -3080,6 +3113,23 @@ int setup_tests(void)
|
||||
if (n == 0)
|
||||
return 0;
|
||||
|
||||
defltprov = OSSL_PROVIDER_load(NULL, "default");
|
||||
if (!TEST_ptr(defltprov))
|
||||
return 0;
|
||||
#ifndef NO_LEGACY_MODULE
|
||||
legacyprov = OSSL_PROVIDER_load(NULL, "legacy");
|
||||
if (!TEST_ptr(legacyprov)) {
|
||||
OSSL_PROVIDER_unload(defltprov);
|
||||
return 0;
|
||||
}
|
||||
#endif /* NO_LEGACY_MODULE */
|
||||
|
||||
ADD_ALL_TESTS(run_file_tests, n);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
OSSL_PROVIDER_unload(legacyprov);
|
||||
OSSL_PROVIDER_unload(defltprov);
|
||||
}
|
||||
+16
-6
@@ -8,7 +8,10 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/provider.h>
|
||||
#include <openssl/params.h>
|
||||
#include <openssl/ossl_typ.h>
|
||||
#include <openssl/core_names.h>
|
||||
#include "internal/nelem.h"
|
||||
#include "testutil.h"
|
||||
|
||||
@@ -36,12 +39,19 @@ static unsigned char pad2[16] = {
|
||||
|
||||
static int test_mdc2(void)
|
||||
{
|
||||
int testresult = 0;
|
||||
int testresult = 0, pad_type = 2;
|
||||
unsigned char md[MDC2_DIGEST_LENGTH];
|
||||
EVP_MD_CTX *c;
|
||||
static char text[] = "Now is the time for all ";
|
||||
size_t tlen = strlen(text);
|
||||
size_t tlen = strlen(text), i = 0;
|
||||
OSSL_PROVIDER *prov = NULL;
|
||||
OSSL_PARAM params[2];
|
||||
|
||||
params[i++] = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_PAD_TYPE,
|
||||
&pad_type),
|
||||
params[i++] = OSSL_PARAM_construct_end();
|
||||
|
||||
prov = OSSL_PROVIDER_load(NULL, "legacy");
|
||||
# ifdef CHARSET_EBCDIC
|
||||
ebcdic2ascii(text, text, tlen);
|
||||
# endif
|
||||
@@ -55,9 +65,8 @@ static int test_mdc2(void)
|
||||
|| !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL)))
|
||||
goto end;
|
||||
|
||||
/* FIXME: use a ctl function? */
|
||||
((MDC2_CTX *)EVP_MD_CTX_md_data(c))->pad_type = 2;
|
||||
if (!TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))
|
||||
if (!TEST_int_gt(EVP_MD_CTX_set_params(c, params), 0)
|
||||
|| !TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))
|
||||
|| !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL))
|
||||
|| !TEST_mem_eq(md, MDC2_DIGEST_LENGTH, pad2, MDC2_DIGEST_LENGTH))
|
||||
goto end;
|
||||
@@ -65,6 +74,7 @@ static int test_mdc2(void)
|
||||
testresult = 1;
|
||||
end:
|
||||
EVP_MD_CTX_free(c);
|
||||
OSSL_PROVIDER_unload(prov);
|
||||
return testresult;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 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
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "internal/namemap.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define NAME1 "name1"
|
||||
#define NAME2 "name2"
|
||||
#define ALIAS1 "alias1"
|
||||
#define ALIAS1_UC "ALIAS1"
|
||||
|
||||
static int test_namemap(OSSL_NAMEMAP *nm)
|
||||
{
|
||||
int num1 = ossl_namemap_add(nm, 0, NAME1);
|
||||
int num2 = ossl_namemap_add(nm, 0, NAME2);
|
||||
int num3 = ossl_namemap_add(nm, num1, ALIAS1);
|
||||
int num4 = ossl_namemap_add(nm, 0, ALIAS1_UC);
|
||||
int check1 = ossl_namemap_name2num(nm, NAME1);
|
||||
int check2 = ossl_namemap_name2num(nm, NAME2);
|
||||
int check3 = ossl_namemap_name2num(nm, ALIAS1);
|
||||
int check4 = ossl_namemap_name2num(nm, ALIAS1_UC);
|
||||
int false1 = ossl_namemap_name2num(nm, "foo");
|
||||
|
||||
return TEST_int_ne(num1, 0)
|
||||
&& TEST_int_ne(num2, 0)
|
||||
&& TEST_int_eq(num1, num3)
|
||||
&& TEST_int_eq(num3, num4)
|
||||
&& TEST_int_eq(num1, check1)
|
||||
&& TEST_int_eq(num2, check2)
|
||||
&& TEST_int_eq(num3, check3)
|
||||
&& TEST_int_eq(num4, check4)
|
||||
&& TEST_int_eq(false1, 0);
|
||||
}
|
||||
|
||||
static int test_namemap_independent(void)
|
||||
{
|
||||
OSSL_NAMEMAP *nm = ossl_namemap_new();
|
||||
int ok = nm != NULL && test_namemap(nm);
|
||||
|
||||
ossl_namemap_free(nm);
|
||||
return ok;
|
||||
}
|
||||
|
||||
static int test_namemap_stored(void)
|
||||
{
|
||||
OSSL_NAMEMAP *nm = ossl_namemap_stored(NULL);
|
||||
|
||||
return nm != NULL
|
||||
&& test_namemap(nm);
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_namemap_independent);
|
||||
ADD_TEST(test_namemap_stored);
|
||||
return 1;
|
||||
}
|
||||
+9
-9
@@ -47,10 +47,10 @@ static const OSSL_ITEM *p_get_param_types(void *_)
|
||||
return p_param_types;
|
||||
}
|
||||
|
||||
static int p_get_params(void *vprov, const OSSL_PARAM params[])
|
||||
static int p_get_params(void *vprov, OSSL_PARAM params[])
|
||||
{
|
||||
const OSSL_PROVIDER *prov = vprov;
|
||||
const OSSL_PARAM *p = params;
|
||||
OSSL_PARAM *p = params;
|
||||
int ok = 1;
|
||||
|
||||
for (; ok && p->key != NULL; p++) {
|
||||
@@ -58,18 +58,18 @@ static int p_get_params(void *vprov, const OSSL_PARAM params[])
|
||||
static char *opensslv;
|
||||
static char *provname;
|
||||
static char *greeting;
|
||||
static const OSSL_PARAM counter_request[] = {
|
||||
static OSSL_PARAM counter_request[] = {
|
||||
/* Known libcrypto provided parameters */
|
||||
{ "openssl-version", OSSL_PARAM_UTF8_PTR,
|
||||
&opensslv, sizeof(&opensslv), NULL },
|
||||
&opensslv, sizeof(&opensslv), 0 },
|
||||
{ "provider-name", OSSL_PARAM_UTF8_PTR,
|
||||
&provname, sizeof(&provname), NULL},
|
||||
&provname, sizeof(&provname), 0},
|
||||
|
||||
/* This might be present, if there's such a configuration */
|
||||
{ "greeting", OSSL_PARAM_UTF8_PTR,
|
||||
&greeting, sizeof(&greeting), NULL },
|
||||
&greeting, sizeof(&greeting), 0 },
|
||||
|
||||
{ NULL, 0, NULL, 0, NULL }
|
||||
{ NULL, 0, NULL, 0, 0 }
|
||||
};
|
||||
char buf[256];
|
||||
size_t buf_l;
|
||||
@@ -90,9 +90,9 @@ static int p_get_params(void *vprov, const OSSL_PARAM params[])
|
||||
sprintf(buf, "Howdy stranger...");
|
||||
}
|
||||
|
||||
*p->return_size = buf_l = strlen(buf) + 1;
|
||||
p->return_size = buf_l = strlen(buf) + 1;
|
||||
if (p->data_size >= buf_l)
|
||||
strncpy(p->data, buf, buf_l);
|
||||
strcpy(p->data, buf);
|
||||
else
|
||||
ok = 0;
|
||||
}
|
||||
|
||||
+43
-67
@@ -58,8 +58,8 @@ static const struct {
|
||||
0x89, 0x67, 0xf2, 0x68, 0x33, 0xa0, 0x14, 0xb0 } },
|
||||
};
|
||||
|
||||
static int test_param_type_extra(const OSSL_PARAM *param,
|
||||
const unsigned char *cmp, size_t width)
|
||||
static int test_param_type_extra(OSSL_PARAM *param, const unsigned char *cmp,
|
||||
size_t width)
|
||||
{
|
||||
int32_t i32;
|
||||
int64_t i64;
|
||||
@@ -374,24 +374,22 @@ static int test_param_bignum(int n)
|
||||
{
|
||||
unsigned char buf[MAX_LEN], bnbuf[MAX_LEN];
|
||||
const size_t len = raw_values[n].len;
|
||||
size_t bnsize;
|
||||
BIGNUM *b = NULL, *c = NULL;
|
||||
OSSL_PARAM param = OSSL_PARAM_DEFN("bn", OSSL_PARAM_UNSIGNED_INTEGER,
|
||||
NULL, 0, NULL);
|
||||
NULL, 0);
|
||||
int ret = 0;
|
||||
|
||||
param.data = bnbuf;
|
||||
param.data_size = len;
|
||||
param.return_size = &bnsize;
|
||||
|
||||
le_copy(buf, raw_values[n].value, len);
|
||||
if (!TEST_ptr(b = BN_lebin2bn(raw_values[n].value, (int)len, NULL)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(OSSL_PARAM_set_BN(¶m, b))
|
||||
|| !TEST_mem_eq(bnbuf, bnsize, buf, bnsize))
|
||||
|| !TEST_mem_eq(bnbuf, param.return_size, buf, param.return_size))
|
||||
goto err;
|
||||
param.data_size = *param.return_size;
|
||||
param.data_size = param.return_size;
|
||||
if (!TEST_true(OSSL_PARAM_get_BN(¶m, &c))
|
||||
|| !TEST_BN_eq(b, c))
|
||||
goto err;
|
||||
@@ -413,23 +411,6 @@ static int test_param_real(void)
|
||||
&& TEST_double_eq(p, 3.14159);
|
||||
}
|
||||
|
||||
/*
|
||||
* The tests are a bit special in that they are trying to do both sides
|
||||
* of the param passing. This means that the OSSL_PARAM structure needs to
|
||||
* be updated so that a get call matches size with the corresponding set call.
|
||||
* This is not a problem in normal usage because the owner of the OSSL_PARAM
|
||||
* "knows" the size of what it wants to put in and gets the size back via the
|
||||
* return_size pointer when it needs to get data out. That is, the owner
|
||||
* does not need to call these APIs since it has direct access.
|
||||
*
|
||||
* The result is that the tests need the locate call to return a non-const
|
||||
* pointer at times. Hence the cast here.
|
||||
*/
|
||||
static OSSL_PARAM *locate(OSSL_PARAM *p, const char *name)
|
||||
{
|
||||
return (OSSL_PARAM *)OSSL_PARAM_locate(p, name);
|
||||
}
|
||||
|
||||
static int test_param_construct(void)
|
||||
{
|
||||
static const char *int_names[] = {
|
||||
@@ -446,8 +427,7 @@ static int test_param_construct(void)
|
||||
char buf[100], buf2[100], *bufp, *bufp2;
|
||||
unsigned char ubuf[100];
|
||||
void *vp, *vpn = NULL, *vp2;
|
||||
OSSL_PARAM *p;
|
||||
const OSSL_PARAM *cp;
|
||||
OSSL_PARAM *cp;
|
||||
int i, n = 0, ret = 0;
|
||||
unsigned int u;
|
||||
long int l;
|
||||
@@ -456,27 +436,25 @@ static int test_param_construct(void)
|
||||
uint32_t u32;
|
||||
int64_t i64;
|
||||
uint64_t u64;
|
||||
size_t j, k, s, sz;
|
||||
size_t j, k, s;
|
||||
double d, d2;
|
||||
BIGNUM *bn = NULL, *bn2 = NULL;
|
||||
|
||||
params[n++] = OSSL_PARAM_construct_int("int", &i, &sz);
|
||||
params[n++] = OSSL_PARAM_construct_uint("uint", &u, &sz);
|
||||
params[n++] = OSSL_PARAM_construct_long("long", &l, &sz);
|
||||
params[n++] = OSSL_PARAM_construct_ulong("ulong", &ul, &sz);
|
||||
params[n++] = OSSL_PARAM_construct_int32("int32", &i32, &sz);
|
||||
params[n++] = OSSL_PARAM_construct_int64("int64", &i64, &sz);
|
||||
params[n++] = OSSL_PARAM_construct_uint32("uint32", &u32, &sz);
|
||||
params[n++] = OSSL_PARAM_construct_uint64("uint64", &u64, &sz);
|
||||
params[n++] = OSSL_PARAM_construct_size_t("size_t", &s, &sz);
|
||||
params[n++] = OSSL_PARAM_construct_double("double", &d, &sz);
|
||||
params[n++] = OSSL_PARAM_construct_BN("bignum", ubuf, sizeof(ubuf), &sz);
|
||||
params[n++] = OSSL_PARAM_construct_utf8_string("utf8str", buf, sizeof(buf),
|
||||
&sz);
|
||||
params[n++] = OSSL_PARAM_construct_octet_string("octstr", buf, sizeof(buf),
|
||||
&sz);
|
||||
params[n++] = OSSL_PARAM_construct_utf8_ptr("utf8ptr", &bufp, 0, &sz);
|
||||
params[n++] = OSSL_PARAM_construct_octet_ptr("octptr", &vp, 0, &sz);
|
||||
params[n++] = OSSL_PARAM_construct_int("int", &i);
|
||||
params[n++] = OSSL_PARAM_construct_uint("uint", &u);
|
||||
params[n++] = OSSL_PARAM_construct_long("long", &l);
|
||||
params[n++] = OSSL_PARAM_construct_ulong("ulong", &ul);
|
||||
params[n++] = OSSL_PARAM_construct_int32("int32", &i32);
|
||||
params[n++] = OSSL_PARAM_construct_int64("int64", &i64);
|
||||
params[n++] = OSSL_PARAM_construct_uint32("uint32", &u32);
|
||||
params[n++] = OSSL_PARAM_construct_uint64("uint64", &u64);
|
||||
params[n++] = OSSL_PARAM_construct_size_t("size_t", &s);
|
||||
params[n++] = OSSL_PARAM_construct_double("double", &d);
|
||||
params[n++] = OSSL_PARAM_construct_BN("bignum", ubuf, sizeof(ubuf));
|
||||
params[n++] = OSSL_PARAM_construct_utf8_string("utf8str", buf, sizeof(buf));
|
||||
params[n++] = OSSL_PARAM_construct_octet_string("octstr", buf, sizeof(buf));
|
||||
params[n++] = OSSL_PARAM_construct_utf8_ptr("utf8ptr", &bufp, 0);
|
||||
params[n++] = OSSL_PARAM_construct_octet_ptr("octptr", &vp, 0);
|
||||
params[n] = OSSL_PARAM_construct_end();
|
||||
|
||||
/* Search failure */
|
||||
@@ -488,7 +466,7 @@ static int test_param_construct(void)
|
||||
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, int_names[j]))
|
||||
|| !TEST_true(OSSL_PARAM_set_int32(cp, (int32_t)(3 + j)))
|
||||
|| !TEST_true(OSSL_PARAM_get_int64(cp, &i64))
|
||||
|| !TEST_size_t_eq(cp->data_size, sz)
|
||||
|| !TEST_size_t_eq(cp->data_size, cp->return_size)
|
||||
|| !TEST_size_t_eq((size_t)i64, 3 + j)) {
|
||||
TEST_note("iteration %zu var %s", j + 1, int_names[j]);
|
||||
goto err;
|
||||
@@ -499,7 +477,7 @@ static int test_param_construct(void)
|
||||
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, uint_names[j]))
|
||||
|| !TEST_true(OSSL_PARAM_set_uint32(cp, (uint32_t)(3 + j)))
|
||||
|| !TEST_true(OSSL_PARAM_get_uint64(cp, &u64))
|
||||
|| !TEST_size_t_eq(cp->data_size, sz)
|
||||
|| !TEST_size_t_eq(cp->data_size, cp->return_size)
|
||||
|| !TEST_size_t_eq((size_t)u64, 3 + j)) {
|
||||
TEST_note("iteration %zu var %s", j + 1, uint_names[j]);
|
||||
goto err;
|
||||
@@ -509,14 +487,14 @@ static int test_param_construct(void)
|
||||
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "double"))
|
||||
|| !TEST_true(OSSL_PARAM_set_double(cp, 3.14))
|
||||
|| !TEST_true(OSSL_PARAM_get_double(cp, &d2))
|
||||
|| !TEST_size_t_eq(sz, sizeof(double))
|
||||
|| !TEST_size_t_eq(cp->return_size, sizeof(double))
|
||||
|| !TEST_double_eq(d, d2))
|
||||
goto err;
|
||||
/* UTF8 string */
|
||||
bufp = NULL;
|
||||
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "utf8str"))
|
||||
|| !TEST_true(OSSL_PARAM_set_utf8_string(cp, "abcdef"))
|
||||
|| !TEST_size_t_eq(sz, sizeof("abcdef"))
|
||||
|| !TEST_size_t_eq(cp->return_size, sizeof("abcdef"))
|
||||
|| !TEST_true(OSSL_PARAM_get_utf8_string(cp, &bufp, 0))
|
||||
|| !TEST_str_eq(bufp, "abcdef"))
|
||||
goto err;
|
||||
@@ -527,56 +505,54 @@ static int test_param_construct(void)
|
||||
goto err;
|
||||
/* UTF8 pointer */
|
||||
bufp = buf;
|
||||
sz = 0;
|
||||
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "utf8ptr"))
|
||||
|| !TEST_true(OSSL_PARAM_set_utf8_ptr(cp, "tuvwxyz"))
|
||||
|| !TEST_size_t_eq(sz, sizeof("tuvwxyz"))
|
||||
|| !TEST_size_t_eq(cp->return_size, sizeof("tuvwxyz"))
|
||||
|| !TEST_str_eq(bufp, "tuvwxyz")
|
||||
|| !TEST_true(OSSL_PARAM_get_utf8_ptr(cp, (const char **)&bufp2))
|
||||
|| !TEST_ptr_eq(bufp2, bufp))
|
||||
goto err;
|
||||
/* OCTET string */
|
||||
if (!TEST_ptr(p = locate(params, "octstr"))
|
||||
|| !TEST_true(OSSL_PARAM_set_octet_string(p, "abcdefghi",
|
||||
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "octstr"))
|
||||
|| !TEST_true(OSSL_PARAM_set_octet_string(cp, "abcdefghi",
|
||||
sizeof("abcdefghi")))
|
||||
|| !TEST_size_t_eq(sz, sizeof("abcdefghi")))
|
||||
|| !TEST_size_t_eq(cp->return_size, sizeof("abcdefghi")))
|
||||
goto err;
|
||||
/* Match the return size to avoid trailing garbage bytes */
|
||||
p->data_size = *p->return_size;
|
||||
if (!TEST_true(OSSL_PARAM_get_octet_string(p, &vpn, 0, &s))
|
||||
cp->data_size = cp->return_size;
|
||||
if (!TEST_true(OSSL_PARAM_get_octet_string(cp, &vpn, 0, &s))
|
||||
|| !TEST_size_t_eq(s, sizeof("abcdefghi"))
|
||||
|| !TEST_mem_eq(vpn, sizeof("abcdefghi"),
|
||||
"abcdefghi", sizeof("abcdefghi")))
|
||||
goto err;
|
||||
vp = buf2;
|
||||
if (!TEST_true(OSSL_PARAM_get_octet_string(p, &vp, sizeof(buf2), &s))
|
||||
if (!TEST_true(OSSL_PARAM_get_octet_string(cp, &vp, sizeof(buf2), &s))
|
||||
|| !TEST_size_t_eq(s, sizeof("abcdefghi"))
|
||||
|| !TEST_mem_eq(vp, sizeof("abcdefghi"),
|
||||
"abcdefghi", sizeof("abcdefghi")))
|
||||
goto err;
|
||||
/* OCTET pointer */
|
||||
vp = &l;
|
||||
sz = 0;
|
||||
if (!TEST_ptr(p = locate(params, "octptr"))
|
||||
|| !TEST_true(OSSL_PARAM_set_octet_ptr(p, &ul, sizeof(ul)))
|
||||
|| !TEST_size_t_eq(sz, sizeof(ul))
|
||||
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "octptr"))
|
||||
|| !TEST_true(OSSL_PARAM_set_octet_ptr(cp, &ul, sizeof(ul)))
|
||||
|| !TEST_size_t_eq(cp->return_size, sizeof(ul))
|
||||
|| !TEST_ptr_eq(vp, &ul))
|
||||
goto err;
|
||||
/* Match the return size to avoid trailing garbage bytes */
|
||||
p->data_size = *p->return_size;
|
||||
if (!TEST_true(OSSL_PARAM_get_octet_ptr(p, (const void **)&vp2, &k))
|
||||
cp->data_size = cp->return_size;
|
||||
if (!TEST_true(OSSL_PARAM_get_octet_ptr(cp, (const void **)&vp2, &k))
|
||||
|| !TEST_size_t_eq(k, sizeof(ul))
|
||||
|| !TEST_ptr_eq(vp2, vp))
|
||||
goto err;
|
||||
/* BIGNUM */
|
||||
if (!TEST_ptr(p = locate(params, "bignum"))
|
||||
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "bignum"))
|
||||
|| !TEST_ptr(bn = BN_lebin2bn(bn_val, (int)sizeof(bn_val), NULL))
|
||||
|| !TEST_true(OSSL_PARAM_set_BN(p, bn))
|
||||
|| !TEST_size_t_eq(sz, sizeof(bn_val)))
|
||||
|| !TEST_true(OSSL_PARAM_set_BN(cp, bn))
|
||||
|| !TEST_size_t_eq(cp->return_size, sizeof(bn_val)))
|
||||
goto err;
|
||||
/* Match the return size to avoid trailing garbage bytes */
|
||||
p->data_size = *p->return_size;
|
||||
if(!TEST_true(OSSL_PARAM_get_BN(p, &bn2))
|
||||
cp->data_size = cp->return_size;
|
||||
if(!TEST_true(OSSL_PARAM_get_BN(cp, &bn2))
|
||||
|| !TEST_BN_eq(bn, bn2))
|
||||
goto err;
|
||||
ret = 1;
|
||||
|
||||
@@ -9,16 +9,18 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <openssl/params.h>
|
||||
#include "testutil.h"
|
||||
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
# define strcasecmp _stricmp
|
||||
#endif
|
||||
/* On machines that dont support <inttypes.h> just disable the tests */
|
||||
#if !defined(OPENSSL_NO_INTTYPES_H)
|
||||
|
||||
# ifdef OPENSSL_SYS_WINDOWS
|
||||
# define strcasecmp _stricmp
|
||||
# endif
|
||||
|
||||
typedef struct {
|
||||
const OSSL_PARAM *param;
|
||||
OSSL_PARAM *param;
|
||||
int32_t i32;
|
||||
int64_t i64;
|
||||
uint32_t u32;
|
||||
@@ -37,7 +39,7 @@ static int param_conversion_load_stanza(PARAM_CONVERSION *pc, const STANZA *s)
|
||||
static uint32_t datum_u32, ref_u32;
|
||||
static uint64_t datum_u64, ref_u64;
|
||||
static double datum_d, ref_d;
|
||||
static const OSSL_PARAM params[] = {
|
||||
static OSSL_PARAM params[] = {
|
||||
OSSL_PARAM_int32("int32", &datum_i32),
|
||||
OSSL_PARAM_int64("int64", &datum_i64),
|
||||
OSSL_PARAM_uint32("uint32", &datum_u32),
|
||||
@@ -320,6 +322,8 @@ end:
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif /* OPENSSL_NO_INTTYPES_H */
|
||||
|
||||
OPT_TEST_DECLARE_USAGE("file...\n")
|
||||
|
||||
int setup_tests(void)
|
||||
@@ -329,6 +333,9 @@ int setup_tests(void)
|
||||
if (n == 0)
|
||||
return 0;
|
||||
|
||||
#if !defined(OPENSSL_NO_INTTYPES_H)
|
||||
ADD_ALL_TESTS(run_param_file_tests, n);
|
||||
#endif /* OPENSSL_NO_INTTYPES_H */
|
||||
|
||||
return 1;
|
||||
}
|
||||
+59
-75
@@ -46,13 +46,13 @@ struct object_st {
|
||||
double p2;
|
||||
/*
|
||||
* Documented as an arbitrarly large unsigned integer.
|
||||
* The data size must be large enough to accomodate.
|
||||
* The data size must be large enough to accommodate.
|
||||
* Assumed data type OSSL_PARAM_UNSIGNED_INTEGER
|
||||
*/
|
||||
BIGNUM *p3;
|
||||
/*
|
||||
* Documented as a C string.
|
||||
* The data size must be large enough to accomodate.
|
||||
* The data size must be large enough to accommodate.
|
||||
* Assumed data type OSSL_PARAM_UTF8_STRING
|
||||
*/
|
||||
char *p4;
|
||||
@@ -152,40 +152,35 @@ static int raw_set_params(void *vobj, const OSSL_PARAM *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int raw_get_params(void *vobj, const OSSL_PARAM *params)
|
||||
static int raw_get_params(void *vobj, OSSL_PARAM *params)
|
||||
{
|
||||
struct object_st *obj = vobj;
|
||||
|
||||
for (; params->key != NULL; params++)
|
||||
if (strcmp(params->key, "p1") == 0) {
|
||||
if (params->return_size != NULL)
|
||||
*params->return_size = sizeof(obj->p1);
|
||||
params->return_size = sizeof(obj->p1);
|
||||
*(int *)params->data = obj->p1;
|
||||
} else if (strcmp(params->key, "p2") == 0) {
|
||||
if (params->return_size != NULL)
|
||||
*params->return_size = sizeof(obj->p2);
|
||||
params->return_size = sizeof(obj->p2);
|
||||
*(double *)params->data = obj->p2;
|
||||
} else if (strcmp(params->key, "p3") == 0) {
|
||||
size_t bytes = BN_num_bytes(obj->p3);
|
||||
|
||||
if (params->return_size != NULL)
|
||||
*params->return_size = bytes;
|
||||
params->return_size = bytes;
|
||||
if (!TEST_size_t_ge(params->data_size, bytes))
|
||||
return 0;
|
||||
BN_bn2nativepad(obj->p3, params->data, bytes);
|
||||
} else if (strcmp(params->key, "p4") == 0) {
|
||||
size_t bytes = strlen(obj->p4) + 1;
|
||||
|
||||
if (params->return_size != NULL)
|
||||
*params->return_size = bytes;
|
||||
params->return_size = bytes;
|
||||
if (!TEST_size_t_ge(params->data_size, bytes))
|
||||
return 0;
|
||||
strcpy(params->data, obj->p4);
|
||||
} else if (strcmp(params->key, "p5") == 0) {
|
||||
size_t bytes = strlen(obj->p5) + 1;
|
||||
|
||||
if (params->return_size != NULL)
|
||||
*params->return_size = bytes;
|
||||
params->return_size = bytes;
|
||||
if (!TEST_size_t_ge(params->data_size, bytes))
|
||||
return 0;
|
||||
strcpy(params->data, obj->p5);
|
||||
@@ -198,8 +193,7 @@ static int raw_get_params(void *vobj, const OSSL_PARAM *params)
|
||||
*/
|
||||
size_t bytes = strlen(obj->p6) + 1;
|
||||
|
||||
if (params->return_size != NULL)
|
||||
*params->return_size = bytes;
|
||||
params->return_size = bytes;
|
||||
*(const char **)params->data = obj->p6;
|
||||
}
|
||||
|
||||
@@ -215,29 +209,29 @@ static int api_set_params(void *vobj, const OSSL_PARAM *params)
|
||||
struct object_st *obj = vobj;
|
||||
const OSSL_PARAM *p = NULL;
|
||||
|
||||
if ((p = OSSL_PARAM_locate(params, "p1")) != NULL
|
||||
if ((p = OSSL_PARAM_locate_const(params, "p1")) != NULL
|
||||
&& !TEST_true(OSSL_PARAM_get_int(p, &obj->p1)))
|
||||
return 0;
|
||||
if ((p = OSSL_PARAM_locate(params, "p2")) != NULL
|
||||
if ((p = OSSL_PARAM_locate_const(params, "p2")) != NULL
|
||||
&& !TEST_true(OSSL_PARAM_get_double(p, &obj->p2)))
|
||||
return 0;
|
||||
if ((p = OSSL_PARAM_locate(params, "p3")) != NULL
|
||||
if ((p = OSSL_PARAM_locate_const(params, "p3")) != NULL
|
||||
&& !TEST_true(OSSL_PARAM_get_BN(p, &obj->p3)))
|
||||
return 0;
|
||||
if ((p = OSSL_PARAM_locate(params, "p4")) != NULL) {
|
||||
if ((p = OSSL_PARAM_locate_const(params, "p4")) != NULL) {
|
||||
OPENSSL_free(obj->p4);
|
||||
obj->p4 = NULL;
|
||||
/* If the value pointer is NULL, we get it automatically allocated */
|
||||
if (!TEST_true(OSSL_PARAM_get_utf8_string(p, &obj->p4, 0)))
|
||||
return 0;
|
||||
}
|
||||
if ((p = OSSL_PARAM_locate(params, "p5")) != NULL) {
|
||||
if ((p = OSSL_PARAM_locate_const(params, "p5")) != NULL) {
|
||||
char *p5_ptr = obj->p5;
|
||||
if (!TEST_true(OSSL_PARAM_get_utf8_string(p, &p5_ptr, sizeof(obj->p5))))
|
||||
return 0;
|
||||
obj->p5_l = strlen(obj->p5) + 1;
|
||||
}
|
||||
if ((p = OSSL_PARAM_locate(params, "p6")) != NULL) {
|
||||
if ((p = OSSL_PARAM_locate_const(params, "p6")) != NULL) {
|
||||
if (!TEST_true(OSSL_PARAM_get_utf8_ptr(p, &obj->p6)))
|
||||
return 0;
|
||||
obj->p6_l = strlen(obj->p6) + 1;
|
||||
@@ -246,10 +240,10 @@ static int api_set_params(void *vobj, const OSSL_PARAM *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int api_get_params(void *vobj, const OSSL_PARAM *params)
|
||||
static int api_get_params(void *vobj, OSSL_PARAM *params)
|
||||
{
|
||||
struct object_st *obj = vobj;
|
||||
const OSSL_PARAM *p = NULL;
|
||||
OSSL_PARAM *p = NULL;
|
||||
|
||||
if ((p = OSSL_PARAM_locate(params, "p1")) != NULL
|
||||
&& !TEST_true(OSSL_PARAM_set_int(p, obj->p1)))
|
||||
@@ -279,7 +273,7 @@ static int api_get_params(void *vobj, const OSSL_PARAM *params)
|
||||
*/
|
||||
struct provider_dispatch_st {
|
||||
int (*set_params)(void *obj, const OSSL_PARAM *params);
|
||||
int (*get_params)(void *obj, const OSSL_PARAM *params);
|
||||
int (*get_params)(void *obj, OSSL_PARAM *params);
|
||||
};
|
||||
|
||||
/* "raw" provider */
|
||||
@@ -299,7 +293,7 @@ static const struct provider_dispatch_st provider_api = {
|
||||
|
||||
/* In all our tests, these are variables that get manipulated as parameters
|
||||
*
|
||||
* These arrays consistenly do nothing with the "p2" parameter, and
|
||||
* These arrays consistently do nothing with the "p2" parameter, and
|
||||
* always include a "foo" parameter. This is to check that the
|
||||
* set_params and get_params calls ignore the lack of parameters that
|
||||
* the application isn't interested in, as well as ignore parameters
|
||||
@@ -310,15 +304,10 @@ static int app_p1; /* "p1" */
|
||||
static double app_p2; /* "p2" is ignored */
|
||||
static BIGNUM *app_p3 = NULL; /* "p3" */
|
||||
static unsigned char bignumbin[4096]; /* "p3" */
|
||||
static size_t bignumbin_l; /* "p3" */
|
||||
static char app_p4[256]; /* "p4" */
|
||||
static size_t app_p4_l; /* "p4" */
|
||||
static char app_p5[256]; /* "p5" */
|
||||
static size_t app_p5_l; /* "p5" */
|
||||
static const char *app_p6 = NULL; /* "p6" */
|
||||
static size_t app_p6_l; /* "p6" */
|
||||
static unsigned char foo[1]; /* "foo" */
|
||||
static size_t foo_l; /* "foo" */
|
||||
|
||||
#define app_p1_init 17 /* A random number */
|
||||
#define app_p2_init 47.11 /* Another random number */
|
||||
@@ -346,14 +335,10 @@ static int init_app_variables(void)
|
||||
if (!BN_hex2bn(&app_p3, app_p3_init)
|
||||
|| (l = BN_bn2nativepad(app_p3, bignumbin, sizeof(bignumbin))) < 0)
|
||||
return 0;
|
||||
bignumbin_l = (size_t)l;
|
||||
strcpy(app_p4, app_p4_init);
|
||||
app_p4_l = sizeof(app_p4_init);
|
||||
strcpy(app_p5, app_p5_init);
|
||||
app_p5_l = sizeof(app_p5_init);
|
||||
app_p6 = app_p6_init;
|
||||
foo[0] = app_foo_init;
|
||||
foo_l = sizeof(app_foo_init);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -363,30 +348,26 @@ static int init_app_variables(void)
|
||||
*/
|
||||
|
||||
/* An array of OSSL_PARAM, specific in the most raw manner possible */
|
||||
static const OSSL_PARAM static_raw_params[] = {
|
||||
{ "p1", OSSL_PARAM_INTEGER, &app_p1, sizeof(app_p1), NULL },
|
||||
{ "p3", OSSL_PARAM_UNSIGNED_INTEGER, &bignumbin, sizeof(bignumbin),
|
||||
&bignumbin_l },
|
||||
{ "p4", OSSL_PARAM_UTF8_STRING, &app_p4, sizeof(app_p4), &app_p4_l },
|
||||
{ "p5", OSSL_PARAM_UTF8_STRING, &app_p5, sizeof(app_p5), &app_p5_l },
|
||||
static OSSL_PARAM static_raw_params[] = {
|
||||
{ "p1", OSSL_PARAM_INTEGER, &app_p1, sizeof(app_p1), 0 },
|
||||
{ "p3", OSSL_PARAM_UNSIGNED_INTEGER, &bignumbin, sizeof(bignumbin), 0 },
|
||||
{ "p4", OSSL_PARAM_UTF8_STRING, &app_p4, sizeof(app_p4), 0 },
|
||||
{ "p5", OSSL_PARAM_UTF8_STRING, &app_p5, sizeof(app_p5), 0 },
|
||||
/* sizeof(app_p6_init), because we know that's what we're using */
|
||||
{ "p6", OSSL_PARAM_UTF8_PTR, &app_p6, sizeof(app_p6_init), &app_p6_l },
|
||||
{ "foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo), &foo_l },
|
||||
{ NULL, 0, NULL, 0, NULL }
|
||||
{ "p6", OSSL_PARAM_UTF8_PTR, &app_p6, sizeof(app_p6_init), 0 },
|
||||
{ "foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo), 0 },
|
||||
{ NULL, 0, NULL, 0, 0 }
|
||||
};
|
||||
|
||||
/* The same array of OSSL_PARAM, specified with the macros from params.h */
|
||||
static const OSSL_PARAM static_api_params[] = {
|
||||
static OSSL_PARAM static_api_params[] = {
|
||||
OSSL_PARAM_int("p1", &app_p1),
|
||||
OSSL_PARAM_SIZED_BN("p3", &bignumbin, sizeof(bignumbin), bignumbin_l),
|
||||
OSSL_PARAM_DEFN("p4", OSSL_PARAM_UTF8_STRING,
|
||||
&app_p4, sizeof(app_p4), &app_p4_l),
|
||||
OSSL_PARAM_DEFN("p5", OSSL_PARAM_UTF8_STRING,
|
||||
&app_p5, sizeof(app_p5), &app_p5_l),
|
||||
OSSL_PARAM_BN("p3", &bignumbin, sizeof(bignumbin)),
|
||||
OSSL_PARAM_DEFN("p4", OSSL_PARAM_UTF8_STRING, &app_p4, sizeof(app_p4)),
|
||||
OSSL_PARAM_DEFN("p5", OSSL_PARAM_UTF8_STRING, &app_p5, sizeof(app_p5)),
|
||||
/* sizeof(app_p6_init), because we know that's what we're using */
|
||||
OSSL_PARAM_DEFN("p6", OSSL_PARAM_UTF8_PTR,
|
||||
&app_p6, sizeof(app_p6_init), &app_p6_l),
|
||||
OSSL_PARAM_DEFN("foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo), &foo_l),
|
||||
OSSL_PARAM_DEFN("p6", OSSL_PARAM_UTF8_PTR, &app_p6, sizeof(app_p6_init)),
|
||||
OSSL_PARAM_DEFN("foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo)),
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
|
||||
@@ -399,25 +380,23 @@ static OSSL_PARAM *construct_api_params(void)
|
||||
size_t n = 0;
|
||||
static OSSL_PARAM params[10];
|
||||
|
||||
params[n++] = OSSL_PARAM_construct_int("p1", &app_p1, NULL);
|
||||
params[n++] = OSSL_PARAM_construct_BN("p3", bignumbin, sizeof(bignumbin),
|
||||
&bignumbin_l);
|
||||
params[n++] = OSSL_PARAM_construct_utf8_string("p4", app_p4, sizeof(app_p4),
|
||||
&app_p4_l);
|
||||
params[n++] = OSSL_PARAM_construct_int("p1", &app_p1);
|
||||
params[n++] = OSSL_PARAM_construct_BN("p3", bignumbin, sizeof(bignumbin));
|
||||
params[n++] = OSSL_PARAM_construct_utf8_string("p4", app_p4,
|
||||
sizeof(app_p4));
|
||||
params[n++] = OSSL_PARAM_construct_utf8_string("p5", app_p5,
|
||||
sizeof(app_p5), &app_p5_l);
|
||||
sizeof(app_p5));
|
||||
/* sizeof(app_p6_init), because we know that's what we're using */
|
||||
params[n++] = OSSL_PARAM_construct_utf8_ptr("p6", (char **)&app_p6,
|
||||
sizeof(app_p6_init), &app_p6_l);
|
||||
params[n++] = OSSL_PARAM_construct_octet_string("foo", &foo, sizeof(foo),
|
||||
&foo_l);
|
||||
sizeof(app_p6_init));
|
||||
params[n++] = OSSL_PARAM_construct_octet_string("foo", &foo, sizeof(foo));
|
||||
params[n++] = OSSL_PARAM_construct_end();
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
struct param_owner_st {
|
||||
const OSSL_PARAM *static_params;
|
||||
OSSL_PARAM *static_params;
|
||||
OSSL_PARAM *(*constructed_params)(void);
|
||||
};
|
||||
|
||||
@@ -452,12 +431,12 @@ static struct {
|
||||
};
|
||||
|
||||
/* Generic tester of combinations of "providers" and params */
|
||||
static int test_case_variant(const OSSL_PARAM *params,
|
||||
const struct provider_dispatch_st *prov)
|
||||
static int test_case_variant(OSSL_PARAM *params, const struct provider_dispatch_st *prov)
|
||||
{
|
||||
BIGNUM *verify_p3 = NULL;
|
||||
void *obj = NULL;
|
||||
int errcnt = 0;
|
||||
OSSL_PARAM *p;
|
||||
|
||||
/*
|
||||
* Initialize
|
||||
@@ -477,15 +456,19 @@ static int test_case_variant(const OSSL_PARAM *params,
|
||||
if (!TEST_true(prov->get_params(obj, params))
|
||||
|| !TEST_int_eq(app_p1, p1_init) /* "provider" value */
|
||||
|| !TEST_double_eq(app_p2, app_p2_init) /* Should remain untouched */
|
||||
|| !TEST_ptr(BN_native2bn(bignumbin, bignumbin_l, app_p3))
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "p3"))
|
||||
|| !TEST_ptr(BN_native2bn(bignumbin, p->return_size, app_p3))
|
||||
|| !TEST_BN_eq(app_p3, verify_p3) /* "provider" value */
|
||||
|| !TEST_str_eq(app_p4, p4_init) /* "provider" value */
|
||||
|| !TEST_size_t_eq(app_p5_l, sizeof(p5_init)) /* "provider" value */
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "p5"))
|
||||
|| !TEST_size_t_eq(p->return_size, sizeof(p5_init)) /* "provider" value */
|
||||
|| !TEST_str_eq(app_p5, p5_init) /* "provider" value */
|
||||
|| !TEST_size_t_eq(app_p6_l, sizeof(p6_init)) /* "provider" value */
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "p6"))
|
||||
|| !TEST_size_t_eq(p->return_size, sizeof(p6_init)) /* "provider" value */
|
||||
|| !TEST_str_eq(app_p6, p6_init) /* "provider" value */
|
||||
|| !TEST_char_eq(foo[0], app_foo_init) /* Should remain untouched */
|
||||
|| !TEST_int_eq(foo_l, sizeof(app_foo_init)))
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "foo"))
|
||||
|| !TEST_int_eq(p->return_size, 0))
|
||||
errcnt++;
|
||||
|
||||
/*
|
||||
@@ -503,10 +486,7 @@ static int test_case_variant(const OSSL_PARAM *params,
|
||||
|| !TEST_double_eq(sneakpeek->p2, p2_init) /* Should remain untouched */
|
||||
|| !TEST_BN_eq(sneakpeek->p3, app_p3) /* app value set */
|
||||
|| !TEST_str_eq(sneakpeek->p4, app_p4) /* app value set */
|
||||
|| !TEST_size_t_eq(sneakpeek->p5_l, app_p5_l) /* app value set */
|
||||
|| !TEST_str_eq(sneakpeek->p5, app_p5) /* app value set */
|
||||
|| !TEST_size_t_eq(sneakpeek->p6_l,
|
||||
sizeof(app_p6_init)) /* app value set */
|
||||
|| !TEST_str_eq(sneakpeek->p6, app_p6)) /* app value set */
|
||||
errcnt++;
|
||||
}
|
||||
@@ -526,17 +506,21 @@ static int test_case_variant(const OSSL_PARAM *params,
|
||||
if (!TEST_true(prov->get_params(obj, params))
|
||||
|| !TEST_int_eq(app_p1, app_p1_init) /* app value */
|
||||
|| !TEST_double_eq(app_p2, app_p2_init) /* Should remain untouched */
|
||||
|| !TEST_ptr(BN_native2bn(bignumbin, bignumbin_l, app_p3))
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "p3"))
|
||||
|| !TEST_ptr(BN_native2bn(bignumbin, p->return_size, app_p3))
|
||||
|| !TEST_BN_eq(app_p3, verify_p3) /* app value */
|
||||
|| !TEST_str_eq(app_p4, app_p4_init) /* app value */
|
||||
|| !TEST_size_t_eq(app_p5_l,
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "p5"))
|
||||
|| !TEST_size_t_eq(p->return_size,
|
||||
sizeof(app_p5_init)) /* app value */
|
||||
|| !TEST_str_eq(app_p5, app_p5_init) /* app value */
|
||||
|| !TEST_size_t_eq(app_p6_l,
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "p6"))
|
||||
|| !TEST_size_t_eq(p->return_size,
|
||||
sizeof(app_p6_init)) /* app value */
|
||||
|| !TEST_str_eq(app_p6, app_p6_init) /* app value */
|
||||
|| !TEST_char_eq(foo[0], app_foo_init) /* Should remain untouched */
|
||||
|| !TEST_int_eq(foo_l, sizeof(app_foo_init)))
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "foo"))
|
||||
|| !TEST_int_eq(p->return_size, 0))
|
||||
errcnt++;
|
||||
|
||||
fin:
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
extern OSSL_provider_init_fn PROVIDER_INIT_FUNCTION_NAME;
|
||||
|
||||
static char buf[256];
|
||||
static size_t buf_l = 0;
|
||||
static OSSL_PARAM greeting_request[] = {
|
||||
{ "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf), &buf_l },
|
||||
{ NULL, 0, NULL, 0, NULL }
|
||||
{ "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf), 0 },
|
||||
{ NULL, 0, NULL, 0, 0 }
|
||||
};
|
||||
|
||||
static int test_provider(OSSL_PROVIDER *prov, const char *expected_greeting)
|
||||
|
||||
@@ -14,10 +14,9 @@
|
||||
extern OSSL_provider_init_fn PROVIDER_INIT_FUNCTION_NAME;
|
||||
|
||||
static char buf[256];
|
||||
static size_t buf_l = 0;
|
||||
static OSSL_PARAM greeting_request[] = {
|
||||
{ "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf), &buf_l },
|
||||
{ NULL, 0, NULL, 0, NULL }
|
||||
{ "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf) },
|
||||
{ NULL, 0, NULL, 0, 0 }
|
||||
};
|
||||
|
||||
static int test_provider(const char *name)
|
||||
|
||||
+5
-2
@@ -181,7 +181,8 @@ static int test_rc5_ecb(int n)
|
||||
RC5_32_KEY key;
|
||||
unsigned char buf[8], buf2[8];
|
||||
|
||||
RC5_32_set_key(&key, 16, &RC5key[n][0], 12);
|
||||
if (!TEST_true(RC5_32_set_key(&key, 16, &RC5key[n][0], 12)))
|
||||
return 0;
|
||||
|
||||
RC5_32_ecb_encrypt(&RC5plain[n][0], buf, &key, RC5_ENCRYPT);
|
||||
if (!TEST_mem_eq(&RC5cipher[n][0], sizeof(RC5cipher[0]), buf, sizeof(buf)))
|
||||
@@ -203,7 +204,9 @@ static int test_rc5_cbc(int n)
|
||||
|
||||
i = rc5_cbc_rounds[n];
|
||||
if (i >= 8) {
|
||||
RC5_32_set_key(&key, rc5_cbc_key[n][0], &rc5_cbc_key[n][1], i);
|
||||
if (!TEST_true(RC5_32_set_key(&key, rc5_cbc_key[n][0],
|
||||
&rc5_cbc_key[n][1], i)))
|
||||
return 0;
|
||||
|
||||
memcpy(ivb, &rc5_cbc_iv[n][0], 8);
|
||||
RC5_32_cbc_encrypt(&rc5_cbc_plain[n][0], buf, 8,
|
||||
|
||||
@@ -104,18 +104,31 @@ foreach my $errname (@posix_errors) {
|
||||
my @oerr = run(app([ qw(openssl errstr), sprintf("2%06x", $errnum) ]),
|
||||
capture => 1);
|
||||
$oerr[0] =~ s|\R$||;
|
||||
$oerr[0] =~ s|.*system library:||g; # The actual message is last
|
||||
|
||||
ok($oerr[0] eq $perr, "($errnum) '$oerr[0]' == '$perr'");
|
||||
@oerr = split_error($oerr[0]);
|
||||
ok($oerr[3] eq $perr, "($errnum) '$oerr[3]' == '$perr'");
|
||||
}
|
||||
}
|
||||
|
||||
my @after = run(app([ qw(openssl errstr 2000080) ]), capture => 1);
|
||||
$after[0] =~ s|\R$||;
|
||||
$after[0] =~ s|.*system library:||g;
|
||||
ok($after[0] eq "reason(128)", "(128) '$after[0]' == 'reason(128)'");
|
||||
@after = split_error($after[0]);
|
||||
ok($after[3] eq "reason(128)", "(128) '$after[3]' == 'reason(128)'");
|
||||
|
||||
my @zero = run(app([ qw(openssl errstr 2000000) ]), capture => 1);
|
||||
$zero[0] =~ s|\R$||;
|
||||
$zero[0] =~ s|.*system library:||g;
|
||||
ok($zero[0] eq "system library", "(0) '$zero[0]' == 'system library'");
|
||||
@zero = split_error($zero[0]);
|
||||
ok($zero[3] eq "system library", "(0) '$zero[3]' == 'system library'");
|
||||
|
||||
# For an error string "error:xxxxxxxx:lib:func:reason", this returns
|
||||
# the following array:
|
||||
#
|
||||
# ( "xxxxxxxx", "lib", "func", "reason" )
|
||||
sub split_error {
|
||||
# Limit to 5 items, in case the reason contains a colon
|
||||
my @erritems = split /:/, $_[0], 5;
|
||||
|
||||
# Remove the first item, which is always "error"
|
||||
shift @erritems;
|
||||
|
||||
return @erritems;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 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
|
||||
# in the file LICENSE in the source distribution or at
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
use strict;
|
||||
use OpenSSL::Test; # get 'plan'
|
||||
use OpenSSL::Test::Simple;
|
||||
use OpenSSL::Test::Utils;
|
||||
|
||||
setup("test_internal_namemap");
|
||||
|
||||
simple_test("test_internal_namemap", "namemap_internal_test");
|
||||
@@ -7,6 +7,20 @@
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
|
||||
use OpenSSL::Test::Simple;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
simple_test("test_mdc2", "mdc2test", "mdc2");
|
||||
use OpenSSL::Test qw/:DEFAULT bldtop_dir/;
|
||||
use OpenSSL::Test::Utils;
|
||||
|
||||
setup("test_mdc2");
|
||||
|
||||
if (disabled("mdc2") || disabled("legacy")) {
|
||||
plan skip_all => "mdc2 is not supported by this OpenSSL build";
|
||||
}
|
||||
|
||||
plan tests => 1;
|
||||
|
||||
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
|
||||
|
||||
ok(run(test(["mdc2test"])), "running mdc2test");
|
||||
@@ -25,8 +25,8 @@ my @kdf_tests = (
|
||||
{ cmd => [qw{openssl kdf -keylen 10 -kdfopt digest:SHA256 -kdfopt key:secret -kdfopt salt:salt -kdfopt info:label HKDF}],
|
||||
expected => '2a:c4:36:9f:52:59:96:f8:de:13',
|
||||
desc => 'HKDF SHA256' },
|
||||
{ cmd => [qw{openssl kdf -keylen 32 -kdfopt digest:SHA256 -kdfopt pass:password -kdfopt salt:salt -kdfopt iter:2 PBKDF2}],
|
||||
expected => 'ae:4d:0c:95:af:6b:46:d3:2d:0a:df:f9:28:f0:6d:d0:2a:30:3f:8e:f3:c2:51:df:d6:e2:d8:5a:95:47:4c:43',
|
||||
{ cmd => [qw{openssl kdf -keylen 25 -kdfopt digest:SHA256 -kdfopt pass:passwordPASSWORDpassword -kdfopt salt:saltSALTsaltSALTsaltSALTsaltSALTsalt -kdfopt iter:4096 PBKDF2}],
|
||||
expected => '34:8C:89:DB:CB:D3:2B:2F:32:D8:14:B8:11:6E:84:CF:2B:17:34:7E:BC:18:00:18:1C',
|
||||
desc => 'PBKDF2 SHA256'},
|
||||
{ cmd => [qw{openssl kdf -keylen 64 -kdfopt mac:KMAC128 -kdfopt maclen:20 -kdfopt hexkey:b74a149a161546f8c20b06ac4ed4 -kdfopt hexinfo:348a37a27ef1282f5f020dcc -kdfopt hexsalt:3638271ccd68a25dc24ecddd39ef3f89 SSKDF}],
|
||||
expected => 'e9:c1:84:53:a0:62:b5:3b:db:fc:bb:5a:34:bd:b8:e5:e7:07:ee:bb:5d:d1:34:42:43:d8:cf:c2:c2:e6:33:2f:91:bd:a5:86:f3:7d:e4:8a:65:d4:c5:14:fd:ef:aa:1e:67:54:f3:73:d2:38:e1:95:ae:15:7e:1d:e8:14:98:03',
|
||||
|
||||
@@ -10,7 +10,7 @@ use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Spec;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file ok_nofips/;
|
||||
use OpenSSL::Test::Utils;
|
||||
|
||||
setup("test_pkeyutl");
|
||||
@@ -24,13 +24,13 @@ SKIP: {
|
||||
if disabled("ec") || disabled("sm2") || disabled("sm3");
|
||||
|
||||
# SM2
|
||||
ok(run(app(([ 'openssl', 'pkeyutl', '-sign',
|
||||
ok_nofips(run(app(([ 'openssl', 'pkeyutl', '-sign',
|
||||
'-in', srctop_file('test', 'certs', 'sm2.pem'),
|
||||
'-inkey', srctop_file('test', 'certs', 'sm2.key'),
|
||||
'-out', 'signature.dat', '-rawin',
|
||||
'-digest', 'sm3', '-pkeyopt', 'sm2_id:someid']))),
|
||||
"Sign a piece of data using SM2");
|
||||
ok(run(app(([ 'openssl', 'pkeyutl', '-verify', '-certin',
|
||||
ok_nofips(run(app(([ 'openssl', 'pkeyutl', '-verify', '-certin',
|
||||
'-in', srctop_file('test', 'certs', 'sm2.pem'),
|
||||
'-inkey', srctop_file('test', 'certs', 'sm2.pem'),
|
||||
'-sigfile', 'signature.dat', '-rawin',
|
||||
|
||||
@@ -15,7 +15,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
||||
|
||||
setup("test_req");
|
||||
|
||||
plan tests => 9;
|
||||
plan tests => 10;
|
||||
|
||||
require_ok(srctop_file('test','recipes','tconversion.pl'));
|
||||
|
||||
@@ -58,6 +58,25 @@ subtest "generating certificate requests" => sub {
|
||||
"Verifying signature on request");
|
||||
};
|
||||
|
||||
subtest "generating SM2 certificate requests" => sub {
|
||||
plan tests => 2;
|
||||
|
||||
SKIP: {
|
||||
skip "SM2 is not supported by this OpenSSL build", 2
|
||||
if disabled("sm2");
|
||||
ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
|
||||
"-new", "-key", srctop_file("test", "certs", "sm2.key"),
|
||||
"-sigopt", "sm2_id:1234567812345678",
|
||||
"-out", "testreq.pem", "-sm3"])),
|
||||
"Generating SM2 certificate request");
|
||||
|
||||
ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
|
||||
"-verify", "-in", "testreq.pem", "-noout",
|
||||
"-sm2-id", "1234567812345678", "-sm3"])),
|
||||
"Verifying signature on SM2 certificate request");
|
||||
}
|
||||
};
|
||||
|
||||
my @openssl_args = ("req", "-config", srctop_file("apps", "openssl.cnf"));
|
||||
|
||||
run_conversion('req conversions',
|
||||
|
||||
@@ -11,7 +11,7 @@ use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Spec::Functions qw/canonpath/;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file ok_nofips/;
|
||||
use OpenSSL::Test::Utils;
|
||||
|
||||
setup("test_verify");
|
||||
@@ -379,9 +379,9 @@ SKIP: {
|
||||
if disabled("sm2");
|
||||
|
||||
# Test '-sm2-id' and '-sm2-hex-id' option
|
||||
ok(verify("sm2", "any", ["sm2-ca-cert"], [], "-sm2-id", "1234567812345678"),
|
||||
ok_nofips(verify("sm2", "any", ["sm2-ca-cert"], [], "-sm2-id", "1234567812345678"),
|
||||
"SM2 ID test");
|
||||
ok(verify("sm2", "any", ["sm2-ca-cert"], [], "-sm2-hex-id",
|
||||
ok_nofips(verify("sm2", "any", ["sm2-ca-cert"], [], "-sm2-hex-id",
|
||||
"31323334353637383132333435363738"),
|
||||
"SM2 hex ID test");
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use OpenSSL::Test qw/:DEFAULT data_file/;
|
||||
use OpenSSL::Test qw(:DEFAULT data_file bldtop_dir);
|
||||
|
||||
setup("test_evp");
|
||||
|
||||
@@ -20,6 +20,8 @@ my @files = ( "evpciph.txt", "evpdigest.txt", "evpencod.txt", "evpkdf.txt",
|
||||
|
||||
plan tests => scalar(@files);
|
||||
|
||||
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
|
||||
|
||||
foreach my $f ( @files ) {
|
||||
ok(run(test(["evp_test", data_file("$f")])),
|
||||
"running evp_test $f");
|
||||
|
||||
@@ -1190,13 +1190,34 @@ Result = CIPHERFINAL_ERROR
|
||||
|
||||
Title = AES XTS test vectors from IEEE Std 1619-2007
|
||||
|
||||
# Using the same key twice for encryption is always banned.
|
||||
Cipher = aes-128-xts
|
||||
Operation = ENCRYPT
|
||||
Key = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
Plaintext = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
Ciphertext = 917cf69ebd68b2ec9b9fe9a3eadda692cd43d2f59598ed858c02c2652fbf922e
|
||||
Result = KEY_SET_ERROR
|
||||
|
||||
# Using the same key twice for decryption is banned in FIPS mode.
|
||||
#Cipher = aes-128-xts
|
||||
#FIPS = YES
|
||||
#Operation = DECRYPT
|
||||
#Key = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
#IV = 00000000000000000000000000000000
|
||||
#Plaintext = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
#Ciphertext = 917cf69ebd68b2ec9b9fe9a3eadda692cd43d2f59598ed858c02c2652fbf922e
|
||||
#Result = KEY_SET_ERROR
|
||||
|
||||
# Using the same key twice for decryption is allowed outside of FIPS mode.
|
||||
Cipher = aes-128-xts
|
||||
#FIPS = NO
|
||||
Operation = DECRYPT
|
||||
Key = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
Plaintext = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
Ciphertext = 917cf69ebd68b2ec9b9fe9a3eadda692cd43d2f59598ed858c02c2652fbf922e
|
||||
|
||||
Cipher = aes-128-xts
|
||||
Key = 1111111111111111111111111111111122222222222222222222222222222222
|
||||
IV = 33333333330000000000000000000000
|
||||
|
||||
@@ -276,104 +276,127 @@ Title = MD4 tests
|
||||
Digest = MD4
|
||||
Input = ""
|
||||
Output = 31d6cfe0d16ae931b73c59d7e0c089c0
|
||||
Legacy = 1
|
||||
|
||||
Digest = MD4
|
||||
Input = "a"
|
||||
Output = bde52cb31de33e46245e05fbdbd6fb24
|
||||
Legacy = 1
|
||||
|
||||
Digest = MD4
|
||||
Input = "abc"
|
||||
Output = a448017aaf21d8525fc10ae87aa6729d
|
||||
Legacy = 1
|
||||
|
||||
Digest = MD4
|
||||
Input = "message digest"
|
||||
Output = d9130a8164549fe818874806e1c7014b
|
||||
Legacy = 1
|
||||
|
||||
Digest = MD4
|
||||
Input = "abcdefghijklmnopqrstuvwxyz"
|
||||
Output = d79e1c308aa5bbcdeea8ed63df412da9
|
||||
Legacy = 1
|
||||
|
||||
Digest = MD4
|
||||
Input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
Output = 043f8582f241db351ce627e153e7f0e4
|
||||
Legacy = 1
|
||||
|
||||
Digest = MD4
|
||||
Input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
Output = e33b4ddc9c38f2199c3e7b164fcc0536
|
||||
Legacy = 1
|
||||
|
||||
Title = RIPEMD160 tests
|
||||
|
||||
Digest = RIPEMD160
|
||||
Input = ""
|
||||
Output = 9c1185a5c5e9fc54612808977ee8f548b2258d31
|
||||
Legacy = 1
|
||||
|
||||
Digest = RIPEMD160
|
||||
Input = "a"
|
||||
Output = 0bdc9d2d256b3ee9daae347be6f4dc835a467ffe
|
||||
Legacy = 1
|
||||
|
||||
Digest = RIPEMD160
|
||||
Input = "abc"
|
||||
Output = 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc
|
||||
Legacy = 1
|
||||
|
||||
Digest = RIPEMD160
|
||||
Input = "message digest"
|
||||
Output = 5d0689ef49d2fae572b881b123a85ffa21595f36
|
||||
Legacy = 1
|
||||
|
||||
Digest = RIPEMD160
|
||||
Input = "abcdefghijklmnopqrstuvwxyz"
|
||||
Output = f71c27109c692c1b56bbdceb5b9d2865b3708dbc
|
||||
Legacy = 1
|
||||
|
||||
Digest = RIPEMD160
|
||||
Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
|
||||
Output = 12a053384a9c0c88e405a06c27dcf49ada62eb2b
|
||||
Legacy = 1
|
||||
|
||||
Digest = RIPEMD160
|
||||
Input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
Output = b0e20b6e3116640286ed3a87a5713079b21f5189
|
||||
Legacy = 1
|
||||
|
||||
Digest = RIPEMD160
|
||||
Input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
Output = 9b752e45573d4b39f4dbd3323cab82bf63326bfb
|
||||
Legacy = 1
|
||||
|
||||
Title = Whirlpool (from ISO/IEC 10118-3 test vector set)
|
||||
|
||||
Digest = whirlpool
|
||||
Input = ""
|
||||
Output = 19FA61D75522A4669B44E39C1D2E1726C530232130D407F89AFEE0964997F7A73E83BE698B288FEBCF88E3E03C4F0757EA8964E59B63D93708B138CC42A66EB3
|
||||
Legacy = 1
|
||||
|
||||
Digest = whirlpool
|
||||
Input = "a"
|
||||
Output = 8ACA2602792AEC6F11A67206531FB7D7F0DFF59413145E6973C45001D0087B42D11BC645413AEFF63A42391A39145A591A92200D560195E53B478584FDAE231A
|
||||
Legacy = 1
|
||||
|
||||
Digest = whirlpool
|
||||
Input = "abc"
|
||||
Output = 4E2448A4C6F486BB16B6562C73B4020BF3043E3A731BCE721AE1B303D97E6D4C7181EEBDB6C57E277D0E34957114CBD6C797FC9D95D8B582D225292076D4EEF5
|
||||
Legacy = 1
|
||||
|
||||
Digest = whirlpool
|
||||
Input = "message digest"
|
||||
Output = 378C84A4126E2DC6E56DCC7458377AAC838D00032230F53CE1F5700C0FFB4D3B8421557659EF55C106B4B52AC5A4AAA692ED920052838F3362E86DBD37A8903E
|
||||
Legacy = 1
|
||||
|
||||
Digest = whirlpool
|
||||
Input = "abcdefghijklmnopqrstuvwxyz"
|
||||
Output = F1D754662636FFE92C82EBB9212A484A8D38631EAD4238F5442EE13B8054E41B08BF2A9251C30B6A0B8AAE86177AB4A6F68F673E7207865D5D9819A3DBA4EB3B
|
||||
Legacy = 1
|
||||
|
||||
Digest = whirlpool
|
||||
Input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
Output = DC37E008CF9EE69BF11F00ED9ABA26901DD7C28CDEC066CC6AF42E40F82F3A1E08EBA26629129D8FB7CB57211B9281A65517CC879D7B962142C65F5A7AF01467
|
||||
Legacy = 1
|
||||
|
||||
Digest = whirlpool
|
||||
Input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
Output = 466EF18BABB0154D25B9D38A6414F5C08784372BCCB204D6549C4AFADB6014294D5BD8DF2A6C44E538CD047B2681A51A2C60481E88C5A20B2C2A80CF3A9A083B
|
||||
Legacy = 1
|
||||
|
||||
Digest = whirlpool
|
||||
Input = "abcdbcdecdefdefgefghfghighijhijk"
|
||||
Output = 2A987EA40F917061F5D6F0A0E4644F488A7A5A52DEEE656207C562F988E95C6916BDC8031BC5BE1B7B947639FE050B56939BAAA0ADFF9AE6745B7B181C3BE3FD
|
||||
Legacy = 1
|
||||
|
||||
Digest = whirlpool
|
||||
Input = "aaaaaaaaaa"
|
||||
Count = 100000
|
||||
Output = 0C99005BEB57EFF50A7CF005560DDF5D29057FD86B20BFD62DECA0F1CCEA4AF51FC15490EDDC47AF32BB2B66C34FF9AD8C6008AD677F77126953B226E4ED8B01
|
||||
|
||||
Legacy = 1
|
||||
|
||||
Title = SHA3
|
||||
|
||||
|
||||
@@ -306,6 +306,7 @@ Result = INTERNAL_ERROR
|
||||
Title = PBKDF2 tests
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:1
|
||||
@@ -313,6 +314,7 @@ Ctrl.digest = digest:sha1
|
||||
Output = 0c60c80f961f0e71f3a9b524af6012062fe037a6
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:1
|
||||
@@ -320,6 +322,7 @@ Ctrl.digest = digest:sha256
|
||||
Output = 120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:1
|
||||
@@ -327,6 +330,7 @@ Ctrl.digest = digest:sha512
|
||||
Output = 867f70cf1ade02cff3752599a3a53dc4af34c7a669815ae5d513554e1c8cf252c02d470a285a0501bad999bfe943c08f050235d7d68b1da55e63f73b60a57fce
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:2
|
||||
@@ -334,6 +338,7 @@ Ctrl.digest = digest:sha1
|
||||
Output = ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:2
|
||||
@@ -341,6 +346,7 @@ Ctrl.digest = digest:sha256
|
||||
Output = ae4d0c95af6b46d32d0adff928f06dd02a303f8ef3c251dfd6e2d85a95474c43
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:2
|
||||
@@ -348,6 +354,7 @@ Ctrl.digest = digest:sha512
|
||||
Output = e1d9c16aa681708a45f5c7c4e215ceb66e011a2e9f0040713f18aefdb866d53cf76cab2868a39b9f7840edce4fef5a82be67335c77a6068e04112754f27ccf4e
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:4096
|
||||
@@ -355,6 +362,7 @@ Ctrl.digest = digest:sha1
|
||||
Output = 4b007901b765489abead49d926f721d065a429c1
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:4096
|
||||
@@ -362,6 +370,7 @@ Ctrl.digest = digest:sha256
|
||||
Output = c5e478d59288c841aa530db6845c4c8d962893a001ce4e11a4963873aa98134a
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:4096
|
||||
@@ -390,6 +399,7 @@ Ctrl.digest = digest:sha512
|
||||
Output = 8c0511f4c6e597c6ac6315d8f0362e225f3c501495ba23b868c005174dc4ee71115b59f9e60cd9532fa33e0f75aefe30225c583a186cd82bd4daea9724a3d3b8
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.hexpass = hexpass:7061737300776f7264
|
||||
Ctrl.hexsalt = hexsalt:7361006c74
|
||||
Ctrl.iter = iter:4096
|
||||
@@ -397,6 +407,7 @@ Ctrl.digest = digest:sha1
|
||||
Output = 56fa6aa75548099dcc37d7f03425e0c3
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.hexpass = hexpass:7061737300776f7264
|
||||
Ctrl.hexsalt = hexsalt:7361006c74
|
||||
Ctrl.iter = iter:4096
|
||||
@@ -404,6 +415,7 @@ Ctrl.digest = digest:sha256
|
||||
Output = 89b69d0516f829893c696226650a8687
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.hexpass = hexpass:7061737300776f7264
|
||||
Ctrl.hexsalt = hexsalt:7361006c74
|
||||
Ctrl.iter = iter:4096
|
||||
@@ -413,6 +425,7 @@ Output = 9d9e9c4cd21fe4be24d5b8244c759665
|
||||
Title = PBKDF2 tests for empty inputs
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.pass = pass:
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:1
|
||||
@@ -420,6 +433,7 @@ Ctrl.digest = digest:sha1
|
||||
Output = a33dddc30478185515311f8752895d36ea4363a2
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.pass = pass:
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:1
|
||||
@@ -427,6 +441,7 @@ Ctrl.digest = digest:sha256
|
||||
Output = f135c27993baf98773c5cdb40a5706ce6a345cde
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pkcs5 = pkcs5:1
|
||||
Ctrl.pass = pass:
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:1
|
||||
@@ -6473,3 +6488,18 @@ Ctrl.digest = digest:SHA512
|
||||
Ctrl.hexsecret = hexsecret:0037cd001a0ad87f35ddf58ab355d6144ba2ed0749a7435dab548ba0bfbe723c047e2396b4eef99653412a92c8db74bb5c03063f2eb0525ae87356750ae3676faa86
|
||||
Ctrl.hexinfo = hexinfo:eb17da8851c41c7ac6710b1c49f324f8
|
||||
Output = 829a28b81f9e95b5f306604067499c07d5944ca034ed130d513951f7143e4e162bad8adb2833e53b8235c293cd2a809659ac7f7e392cba6a543660e5d95070c0c9e6a9cdc38123e22da61bb4cbb6ad6d1a58a069e934fc231bd9fe39a24afcbf322ccea385f0418f3b01c1edd6e7124593a1cefe3e48fcd95daaf72cfd973c59
|
||||
|
||||
Title = X9.42 KDF tests (from RFC2631 test vectors)
|
||||
|
||||
KDF = X942KDF
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.hexsecret = hexsecret:000102030405060708090a0b0c0d0e0f10111213
|
||||
Ctrl.cekalg = cekalg:id-smime-alg-CMS3DESwrap
|
||||
Output = a09661392376f7044d9052a397883246b67f5f1ef63eb5fb
|
||||
|
||||
KDF = X942KDF
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.hexsecret = hexsecret:000102030405060708090a0b0c0d0e0f10111213
|
||||
Ctrl.cekalg = cekalg:id-smime-alg-CMSRC2wrap
|
||||
Ctrl.hexukm = hexukm:0123456789abcdeffedcba98765432010123456789abcdeffedcba98765432010123456789abcdeffedcba98765432010123456789abcdeffedcba9876543201
|
||||
Output = 48950c46e0530075403cce72889604e0
|
||||
@@ -15,6 +15,10 @@ setup("test_clienthello");
|
||||
plan skip_all => "No TLS/SSL protocols are supported by this OpenSSL build"
|
||||
if alldisabled(grep { $_ ne "ssl3" } available_protocols("tls"));
|
||||
|
||||
#No EC with TLSv1.3 confuses the padding calculations in this test
|
||||
plan skip_all => "No EC with TLSv1.3 is not supported by this test"
|
||||
if disabled("ec") && !disabled("tls1_3");
|
||||
|
||||
plan tests => 1;
|
||||
|
||||
ok(run(test(["clienthellotest", srctop_file("test", "session.pem")])),
|
||||
|
||||
@@ -36,7 +36,9 @@ use constant {
|
||||
|
||||
use constant {
|
||||
X25519 => 0x1d,
|
||||
P_256 => 0x17
|
||||
P_256 => 0x17,
|
||||
FFDHE2048 => 0x0100,
|
||||
FFDHE3072 => 0x0101
|
||||
};
|
||||
|
||||
my $testtype;
|
||||
@@ -74,7 +76,11 @@ my $proxy = TLSProxy::Proxy->new(
|
||||
$testtype = EMPTY_EXTENSION;
|
||||
$direction = CLIENT_TO_SERVER;
|
||||
$proxy->filter(\&modify_key_shares_filter);
|
||||
$proxy->serverflags("-curves P-256");
|
||||
if (disabled("ec")) {
|
||||
$proxy->serverflags("-groups ffdhe3072");
|
||||
} else {
|
||||
$proxy->serverflags("-groups P-256");
|
||||
}
|
||||
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
|
||||
plan tests => 22;
|
||||
ok(TLSProxy::Message->success(), "Success after HRR");
|
||||
@@ -95,31 +101,52 @@ ok(TLSProxy::Message->fail(), "Missing key_shares extension");
|
||||
# HelloRetryRequest
|
||||
$proxy->clear();
|
||||
$proxy->filter(undef);
|
||||
$proxy->serverflags("-curves P-256");
|
||||
if (disabled("ec")) {
|
||||
$proxy->serverflags("-groups ffdhe3072");
|
||||
} else {
|
||||
$proxy->serverflags("-groups P-256");
|
||||
}
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->success(), "No initial acceptable key_shares");
|
||||
|
||||
#Test 5: No acceptable key_shares and no shared groups should fail
|
||||
$proxy->clear();
|
||||
$proxy->filter(undef);
|
||||
$proxy->serverflags("-curves P-256");
|
||||
$proxy->clientflags("-curves P-384");
|
||||
if (disabled("ec")) {
|
||||
$proxy->serverflags("-groups ffdhe2048");
|
||||
} else {
|
||||
$proxy->serverflags("-groups P-256");
|
||||
}
|
||||
if (disabled("ec")) {
|
||||
$proxy->clientflags("-groups ffdhe3072");
|
||||
} else {
|
||||
$proxy->clientflags("-groups P-384");
|
||||
}
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->fail(), "No acceptable key_shares");
|
||||
|
||||
#Test 6: A non preferred but acceptable key_share should succeed
|
||||
$proxy->clear();
|
||||
$proxy->clientflags("-curves P-256");
|
||||
if (disabled("ec")) {
|
||||
$proxy->clientflags("-groups ffdhe3072");
|
||||
} else {
|
||||
$proxy->clientflags("-groups P-256");
|
||||
}
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->success(), "Non preferred key_share");
|
||||
$proxy->filter(\&modify_key_shares_filter);
|
||||
|
||||
#Test 7: An acceptable key_share after a list of non-acceptable ones should
|
||||
#succeed
|
||||
$proxy->clear();
|
||||
$testtype = ACCEPTABLE_AT_END;
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->success(), "Acceptable key_share at end of list");
|
||||
SKIP: {
|
||||
skip "No ec support in this OpenSSL build", 1 if disabled("ec");
|
||||
|
||||
#Test 7: An acceptable key_share after a list of non-acceptable ones should
|
||||
#succeed
|
||||
$proxy->clear();
|
||||
$testtype = ACCEPTABLE_AT_END;
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->success(), "Acceptable key_share at end of list");
|
||||
}
|
||||
|
||||
#Test 8: An acceptable key_share but for a group not in supported_groups should
|
||||
#fail
|
||||
@@ -156,22 +183,45 @@ ok(TLSProxy::Message->fail(), "key_share list trailing data");
|
||||
$proxy->clear();
|
||||
$direction = SERVER_TO_CLIENT;
|
||||
$testtype = LOOK_ONLY;
|
||||
$proxy->clientflags("-curves P-256:X25519");
|
||||
$selectedgroupid = 0;
|
||||
if (disabled("ec")) {
|
||||
$proxy->clientflags("-groups ffdhe3072:ffdhe2048");
|
||||
} else {
|
||||
$proxy->clientflags("-groups P-256:X25519");
|
||||
}
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->success() && ($selectedgroupid == P_256),
|
||||
"Multiple acceptable key_shares");
|
||||
if (disabled("ec")) {
|
||||
ok(TLSProxy::Message->success() && ($selectedgroupid == FFDHE3072),
|
||||
"Multiple acceptable key_shares");
|
||||
} else {
|
||||
ok(TLSProxy::Message->success() && ($selectedgroupid == P_256),
|
||||
"Multiple acceptable key_shares");
|
||||
}
|
||||
|
||||
#Test 14: Multiple acceptable key_shares - we choose the first one (part 2)
|
||||
$proxy->clear();
|
||||
$proxy->clientflags("-curves X25519:P-256");
|
||||
if (disabled("ec")) {
|
||||
$proxy->clientflags("-curves ffdhe2048:ffdhe3072");
|
||||
} else {
|
||||
$proxy->clientflags("-curves X25519:P-256");
|
||||
}
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->success() && ($selectedgroupid == X25519),
|
||||
"Multiple acceptable key_shares (part 2)");
|
||||
if (disabled("ec")) {
|
||||
ok(TLSProxy::Message->success() && ($selectedgroupid == FFDHE2048),
|
||||
"Multiple acceptable key_shares (part 2)");
|
||||
} else {
|
||||
ok(TLSProxy::Message->success() && ($selectedgroupid == X25519),
|
||||
"Multiple acceptable key_shares (part 2)");
|
||||
}
|
||||
|
||||
#Test 15: Server sends key_share that wasn't offered should fail
|
||||
$proxy->clear();
|
||||
$testtype = SELECT_X25519;
|
||||
$proxy->clientflags("-curves P-256");
|
||||
if (disabled("ec")) {
|
||||
$proxy->clientflags("-groups ffdhe3072");
|
||||
} else {
|
||||
$proxy->clientflags("-groups P-256");
|
||||
}
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->fail(), "Non offered key_share");
|
||||
|
||||
@@ -229,7 +279,11 @@ SKIP: {
|
||||
$proxy->clear();
|
||||
$direction = SERVER_TO_CLIENT;
|
||||
$testtype = NO_KEY_SHARES_IN_HRR;
|
||||
$proxy->serverflags("-curves X25519");
|
||||
if (disabled("ec")) {
|
||||
$proxy->serverflags("-groups ffdhe2048");
|
||||
} else {
|
||||
$proxy->serverflags("-groups X25519");
|
||||
}
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->fail(), "Server sends HRR with no key_shares");
|
||||
|
||||
|
||||
@@ -217,7 +217,10 @@ SKIP: {
|
||||
$proxy->clientflags("-no_tls1_3 -noservername");
|
||||
$proxy->start();
|
||||
ok($fatal_alert, "Unsolicited server name extension");
|
||||
|
||||
}
|
||||
SKIP: {
|
||||
skip "TLS <= 1.2 disabled or EC disabled", 1
|
||||
if $no_below_tls13 || disabled("ec");
|
||||
#Test 5: Inject a noncompliant supported_groups extension (<= TLSv1.2)
|
||||
$proxy->clear();
|
||||
$proxy->filter(\&inject_unsolicited_extension);
|
||||
|
||||
@@ -46,17 +46,27 @@ my $testtype;
|
||||
#Test 1: Inserting a cookie into an HRR should see it echoed in the ClientHello
|
||||
$testtype = COOKIE_ONLY;
|
||||
$proxy->filter(\&cookie_filter);
|
||||
$proxy->serverflags("-curves X25519");
|
||||
$proxy->serverflags("-curves X25519") if !disabled("ec");
|
||||
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
|
||||
plan tests => 2;
|
||||
ok(TLSProxy::Message->success() && $cookieseen == 1, "Cookie seen");
|
||||
SKIP: {
|
||||
skip "EC disabled", 1, if disabled("ec");
|
||||
ok(TLSProxy::Message->success() && $cookieseen == 1, "Cookie seen");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#Test 2: Same as test 1 but should also work where a new key_share is also
|
||||
# required
|
||||
$testtype = COOKIE_AND_KEY_SHARE;
|
||||
$proxy->clear();
|
||||
$proxy->clientflags("-curves P-256:X25519");
|
||||
$proxy->serverflags("-curves X25519");
|
||||
if (disabled("ec")) {
|
||||
$proxy->clientflags("-curves ffdhe3072:ffdhe2048");
|
||||
$proxy->serverflags("-curves ffdhe2048");
|
||||
} else {
|
||||
$proxy->clientflags("-curves P-256:X25519");
|
||||
$proxy->serverflags("-curves X25519");
|
||||
}
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->success() && $cookieseen == 1, "Cookie seen");
|
||||
|
||||
|
||||
@@ -43,7 +43,11 @@ use constant {
|
||||
#Test 1: A client should fail if the server changes the ciphersuite between the
|
||||
# HRR and the SH
|
||||
$proxy->filter(\&hrr_filter);
|
||||
$proxy->serverflags("-curves P-256");
|
||||
if (disabled("ec")) {
|
||||
$proxy->serverflags("-curves ffdhe3072");
|
||||
} else {
|
||||
$proxy->serverflags("-curves P-256");
|
||||
}
|
||||
my $testtype = CHANGE_HRR_CIPHERSUITE;
|
||||
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
|
||||
plan tests => 2;
|
||||
@@ -52,7 +56,11 @@ ok(TLSProxy::Message->fail(), "Server ciphersuite changes");
|
||||
#Test 2: It is an error if the client changes the offered ciphersuites so that
|
||||
# we end up selecting a different ciphersuite between HRR and the SH
|
||||
$proxy->clear();
|
||||
$proxy->serverflags("-curves P-256");
|
||||
if (disabled("ec")) {
|
||||
$proxy->serverflags("-curves ffdhe3072");
|
||||
} else {
|
||||
$proxy->serverflags("-curves P-256");
|
||||
}
|
||||
$proxy->ciphersuitess("TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384");
|
||||
$testtype = CHANGE_CH1_CIPHERSUITE;
|
||||
$proxy->start();
|
||||
|
||||
@@ -28,6 +28,9 @@ plan skip_all => "$test_name needs the sock feature enabled"
|
||||
plan skip_all => "$test_name needs TLSv1.3 enabled"
|
||||
if disabled("tls1_3");
|
||||
|
||||
plan skip_all => "$test_name needs EC enabled"
|
||||
if disabled("ec");
|
||||
|
||||
$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
|
||||
$ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.conf");
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@ plan skip_all => "$test_name needs the sock feature enabled"
|
||||
plan skip_all => "$test_name needs TLSv1.3 enabled"
|
||||
if disabled("tls1_3");
|
||||
|
||||
plan skip_all => "$test_name needs EC enabled"
|
||||
if disabled("ec");
|
||||
|
||||
$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
|
||||
$ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.conf");
|
||||
|
||||
|
||||
@@ -66,7 +66,11 @@ ok(TLSProxy::Message->fail(), "PSK not last");
|
||||
# ciphersuite. Should see PSK on second ClientHello
|
||||
$proxy->clear();
|
||||
$proxy->clientflags("-sess_in ".$session);
|
||||
$proxy->serverflags("-curves P-256");
|
||||
if (disabled("ec")) {
|
||||
$proxy->serverflags("-curves ffdhe3072");
|
||||
} else {
|
||||
$proxy->serverflags("-curves P-256");
|
||||
}
|
||||
$proxy->filter(undef);
|
||||
$proxy->start();
|
||||
#Check if the PSK is present in the second ClientHello
|
||||
@@ -81,7 +85,11 @@ ok($pskseen, "PSK hash matches");
|
||||
$proxy->clear();
|
||||
$proxy->clientflags("-sess_in ".$session);
|
||||
$proxy->filter(\&modify_psk_filter);
|
||||
$proxy->serverflags("-curves P-256");
|
||||
if (disabled("ec")) {
|
||||
$proxy->serverflags("-curves ffdhe3072");
|
||||
} else {
|
||||
$proxy->serverflags("-curves P-256");
|
||||
}
|
||||
$proxy->ciphersuitesc("TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384");
|
||||
$proxy->ciphersuitess("TLS_AES_256_GCM_SHA384");
|
||||
#We force an early failure because TLS Proxy doesn't actually support
|
||||
|
||||
@@ -16,4 +16,5 @@ plan tests => 1;
|
||||
ok(run(test(["verify_extra_test",
|
||||
srctop_file("test", "certs", "roots.pem"),
|
||||
srctop_file("test", "certs", "untrusted.pem"),
|
||||
srctop_file("test", "certs", "bad.pem")])));
|
||||
srctop_file("test", "certs", "bad.pem"),
|
||||
srctop_file("test", "certs", "sm2-csr.pem")])));
|
||||
@@ -23,7 +23,7 @@ my $std_openssl_cnf =
|
||||
|
||||
rmtree("demoCA", { safe => 0 });
|
||||
|
||||
plan tests => 5;
|
||||
plan tests => 6;
|
||||
SKIP: {
|
||||
$ENV{OPENSSL_CONFIG} = '-config "'.srctop_file("test", "CAss.cnf").'"';
|
||||
skip "failed creating CA structure", 4
|
||||
@@ -51,9 +51,25 @@ plan tests => 5;
|
||||
'creating new pre-certificate');
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip "SM2 is not supported by this OpenSSL build", 1
|
||||
if disabled("sm2");
|
||||
|
||||
is(yes(cmdstr(app(["openssl", "ca", "-config",
|
||||
srctop_file("test", "CAss.cnf"),
|
||||
"-in", srctop_file("test", "certs", "sm2-csr.pem"),
|
||||
"-out", "sm2-test.crt",
|
||||
"-sigopt", "sm2_id:1234567812345678",
|
||||
"-sm2-id", "1234567812345678",
|
||||
"-md", "sm3",
|
||||
"-cert", srctop_file("test", "certs", "sm2-root.crt"),
|
||||
"-keyfile", srctop_file("test", "certs", "sm2-root.key")]))),
|
||||
0,
|
||||
"Signing SM2 certificate request");
|
||||
}
|
||||
|
||||
rmtree("demoCA", { safe => 0 });
|
||||
unlink "newcert.pem", "newreq.pem", "newkey.pem";
|
||||
unlink "newcert.pem", "newreq.pem", "newkey.pem", "sm2-test.crt";
|
||||
|
||||
|
||||
sub yes {
|
||||
|
||||
@@ -21,12 +21,13 @@ setup("test_cms");
|
||||
plan skip_all => "CMS is not supported by this OpenSSL build"
|
||||
if disabled("cms");
|
||||
|
||||
my $datadir = srctop_dir("test", "recipes", "80-test_cms_data");
|
||||
my $smdir = srctop_dir("test", "smime-certs");
|
||||
my $smcont = srctop_file("test", "smcont.txt");
|
||||
my ($no_des, $no_dh, $no_dsa, $no_ec, $no_ec2m, $no_rc2, $no_zlib)
|
||||
= disabled qw/des dh dsa ec ec2m rc2 zlib/;
|
||||
|
||||
plan tests => 4;
|
||||
plan tests => 6;
|
||||
|
||||
my @smime_pkcs7_tests = (
|
||||
|
||||
@@ -416,6 +417,26 @@ my @smime_cms_param_tests = (
|
||||
]
|
||||
);
|
||||
|
||||
my @contenttype_cms_test = (
|
||||
[ "signed content test - check that content type is added to additional signerinfo, RSA keys",
|
||||
[ "-sign", "-binary", "-nodetach", "-stream", "-in", $smcont, "-outform", "DER",
|
||||
"-signer", catfile($smdir, "smrsa1.pem"), "-md", "SHA256",
|
||||
"-out", "test.cms" ],
|
||||
[ "-resign", "-binary", "-nodetach", "-in", "test.cms", "-inform", "DER", "-outform", "DER",
|
||||
"-signer", catfile($smdir, "smrsa2.pem"), "-md", "SHA256",
|
||||
"-out", "test2.cms" ],
|
||||
[ "-verify", "-in", "test2.cms", "-inform", "DER",
|
||||
"-CAfile", catfile($smdir, "smroot.pem"), "-out", "smtst.txt" ]
|
||||
],
|
||||
);
|
||||
|
||||
my @incorrect_attribute_cms_test = (
|
||||
"bad_signtime_attr.cms",
|
||||
"no_ct_attr.cms",
|
||||
"no_md_attr.cms",
|
||||
"ct_multiple_attr.cms"
|
||||
);
|
||||
|
||||
subtest "CMS => PKCS#7 compatibility tests\n" => sub {
|
||||
plan tests => scalar @smime_pkcs7_tests;
|
||||
|
||||
@@ -509,6 +530,52 @@ subtest "CMS <=> CMS consistency tests, modified key parameters\n" => sub {
|
||||
}
|
||||
};
|
||||
|
||||
# Returns the number of matches of a Content Type Attribute in a binary file.
|
||||
sub contentType_matches {
|
||||
# Read in a binary file
|
||||
my ($in) = @_;
|
||||
open (HEX_IN, "$in") or die("open failed for $in : $!");
|
||||
binmode(HEX_IN);
|
||||
local $/;
|
||||
my $str = <HEX_IN>;
|
||||
|
||||
# Find ASN1 data for a Content Type Attribute (with a OID of PKCS7 data)
|
||||
my @c = $str =~ /\x30\x18\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x09\x03\x31\x0B\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x07\x01/gs;
|
||||
|
||||
close(HEX_IN);
|
||||
return scalar(@c);
|
||||
}
|
||||
|
||||
subtest "CMS Check the content type attribute is added for additional signers\n" => sub {
|
||||
plan tests =>
|
||||
(scalar @contenttype_cms_test);
|
||||
|
||||
foreach (@contenttype_cms_test) {
|
||||
SKIP: {
|
||||
my $skip_reason = check_availability($$_[0]);
|
||||
skip $skip_reason, 1 if $skip_reason;
|
||||
|
||||
ok(run(app(["openssl", "cms", @{$$_[1]}]))
|
||||
&& run(app(["openssl", "cms", @{$$_[2]}]))
|
||||
&& contentType_matches("test2.cms") == 2
|
||||
&& run(app(["openssl", "cms", @{$$_[3]}])),
|
||||
$$_[0]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
subtest "CMS Check that bad attributes fail when verifying signers\n" => sub {
|
||||
plan tests =>
|
||||
(scalar @incorrect_attribute_cms_test);
|
||||
|
||||
foreach my $name (@incorrect_attribute_cms_test) {
|
||||
ok(!run(app(["openssl", "cms", "-verify", "-in",
|
||||
catfile($datadir, $name), "-inform", "DER", "-CAfile",
|
||||
catfile($smdir, "smroot.pem"), "-out", "smtst.txt" ])),
|
||||
$name);
|
||||
}
|
||||
};
|
||||
|
||||
unlink "test.cms";
|
||||
unlink "test2.cms";
|
||||
unlink "smtst.txt";
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -59,7 +59,7 @@ my %conf_dependent_tests = (
|
||||
|| !disabled("sctp"),
|
||||
"05-sni.conf" => disabled("tls1_1"),
|
||||
"07-dtls-protocol-version.conf" => !$is_default_dtls || !disabled("sctp"),
|
||||
"10-resumption.conf" => !$is_default_tls,
|
||||
"10-resumption.conf" => !$is_default_tls || $no_ec,
|
||||
"11-dtls_resumption.conf" => !$is_default_dtls || !disabled("sctp"),
|
||||
"16-dtls-certstatus.conf" => !$is_default_dtls || !disabled("sctp"),
|
||||
"17-renegotiate.conf" => disabled("tls1_2"),
|
||||
|
||||
@@ -21,6 +21,10 @@ plan skip_all => "GOST support is disabled in this OpenSSL build"
|
||||
plan skip_all => "TLSv1.3 or TLSv1.2 are disabled in this OpenSSL build"
|
||||
if disabled("tls1_3") || disabled("tls1_2");
|
||||
|
||||
plan skip_all => "EC is disabled in this OpenSSL build"
|
||||
if disabled("ec");
|
||||
|
||||
|
||||
plan skip_all => "No test GOST engine found"
|
||||
if !$ENV{OPENSSL_GOST_ENGINE_SO};
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ sub generate_resumption_tests {
|
||||
"client" => {
|
||||
},
|
||||
"server" => {
|
||||
"Curves" => "P-256"
|
||||
"Curves" => disabled("ec") ? "ffdhe3072" : "P-256"
|
||||
},
|
||||
"resume_client" => {
|
||||
},
|
||||
|
||||
+257
-2
@@ -2960,8 +2960,13 @@ static int early_data_skip_helper(int testtype, int idx)
|
||||
|
||||
if (testtype == 1 || testtype == 2) {
|
||||
/* Force an HRR to occur */
|
||||
#if defined(OPENSSL_NO_EC)
|
||||
if (!TEST_true(SSL_set1_groups_list(serverssl, "ffdhe3072")))
|
||||
goto end;
|
||||
#else
|
||||
if (!TEST_true(SSL_set1_groups_list(serverssl, "P-256")))
|
||||
goto end;
|
||||
#endif
|
||||
} else if (idx == 2) {
|
||||
/*
|
||||
* We force early_data rejection by ensuring the PSK identity is
|
||||
@@ -3735,6 +3740,122 @@ static int test_ciphersuite_change(void)
|
||||
return testresult;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test TLSv1.3 Key exchange
|
||||
* Test 0 = Test ECDHE Key exchange
|
||||
* Test 1 = Test ECDHE with TLSv1.2 client and TLSv1.2 server
|
||||
* Test 2 = Test FFDHE Key exchange
|
||||
* Test 3 = Test FFDHE with TLSv1.2 client and TLSv1.2 server
|
||||
*/
|
||||
static int test_tls13_key_exchange(int idx)
|
||||
{
|
||||
SSL_CTX *sctx = NULL, *cctx = NULL;
|
||||
SSL *serverssl = NULL, *clientssl = NULL;
|
||||
int testresult = 0;
|
||||
#ifndef OPENSSL_NO_EC
|
||||
int ecdhe_kexch_groups[] = {NID_X9_62_prime256v1, NID_secp384r1, NID_secp521r1,
|
||||
NID_X25519, NID_X448};
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DH
|
||||
int ffdhe_kexch_groups[] = {NID_ffdhe2048, NID_ffdhe3072, NID_ffdhe4096,
|
||||
NID_ffdhe6144, NID_ffdhe8192};
|
||||
#endif
|
||||
int *kexch_groups = NULL;
|
||||
int kexch_groups_size = 0;
|
||||
int max_version = TLS1_3_VERSION;
|
||||
int want_err = SSL_ERROR_NONE;
|
||||
int expected_err_func = 0;
|
||||
int expected_err_reason = 0;
|
||||
|
||||
switch (idx) {
|
||||
#ifndef OPENSSL_NO_DH
|
||||
case 3:
|
||||
max_version = TLS1_2_VERSION;
|
||||
/* Fall through */
|
||||
case 2:
|
||||
kexch_groups = ffdhe_kexch_groups;
|
||||
kexch_groups_size = OSSL_NELEM(ffdhe_kexch_groups);
|
||||
break;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
case 1:
|
||||
max_version = TLS1_2_VERSION;
|
||||
/* Fall through */
|
||||
case 0:
|
||||
kexch_groups = ecdhe_kexch_groups;
|
||||
kexch_groups_size = OSSL_NELEM(ecdhe_kexch_groups);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
/* We're skipping this test */
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
|
||||
TLS1_VERSION, max_version,
|
||||
&sctx, &cctx, cert, privkey)))
|
||||
goto end;
|
||||
|
||||
if (!TEST_true(SSL_CTX_set_ciphersuites(sctx, TLS1_3_RFC_AES_128_GCM_SHA256)))
|
||||
goto end;
|
||||
|
||||
if (!TEST_true(SSL_CTX_set_ciphersuites(cctx, TLS1_3_RFC_AES_128_GCM_SHA256)))
|
||||
goto end;
|
||||
|
||||
if (!TEST_true(SSL_CTX_set_cipher_list(sctx, TLS1_TXT_RSA_WITH_AES_128_SHA)))
|
||||
goto end;
|
||||
|
||||
/*
|
||||
* Must include an EC ciphersuite so that we send supported groups in
|
||||
* TLSv1.2
|
||||
*/
|
||||
if (!TEST_true(SSL_CTX_set_cipher_list(cctx,
|
||||
TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM ":"
|
||||
TLS1_TXT_RSA_WITH_AES_128_SHA)))
|
||||
goto end;
|
||||
|
||||
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
|
||||
NULL, NULL)))
|
||||
goto end;
|
||||
|
||||
if (!TEST_true(SSL_set1_groups(serverssl, kexch_groups, kexch_groups_size))
|
||||
|| !TEST_true(SSL_set1_groups(clientssl, kexch_groups, kexch_groups_size)))
|
||||
goto end;
|
||||
|
||||
if (!TEST_true(create_ssl_connection(serverssl, clientssl, want_err))) {
|
||||
/* Fail only if no error is expected in handshake */
|
||||
if (expected_err_func == 0)
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Fail if expected error is not happening for failure testcases */
|
||||
if (expected_err_func) {
|
||||
unsigned long err_code = ERR_get_error();
|
||||
ERR_print_errors_fp(stdout);
|
||||
if (TEST_int_eq(ERR_GET_FUNC(err_code), expected_err_func)
|
||||
&& TEST_int_eq(ERR_GET_REASON(err_code), expected_err_reason))
|
||||
testresult = 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/*
|
||||
* If Handshake succeeds the negotiated kexch alg should the first one in
|
||||
* configured, except in the case of FFDHE groups which are TLSv1.3 only
|
||||
* so we expect no shared group to exist.
|
||||
*/
|
||||
if (!TEST_int_eq(SSL_get_shared_group(serverssl, 0),
|
||||
idx == 3 ? 0 : kexch_groups[0]))
|
||||
goto end;
|
||||
|
||||
testresult = 1;
|
||||
end:
|
||||
SSL_free(serverssl);
|
||||
SSL_free(clientssl);
|
||||
SSL_CTX_free(sctx);
|
||||
SSL_CTX_free(cctx);
|
||||
return testresult;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test TLSv1.3 PSKs
|
||||
* Test 0 = Test new style callbacks
|
||||
@@ -3878,8 +3999,13 @@ static int test_tls13_psk(int idx)
|
||||
goto end;
|
||||
|
||||
/* Force an HRR */
|
||||
#if defined(OPENSSL_NO_EC)
|
||||
if (!TEST_true(SSL_set1_groups_list(serverssl, "ffdhe3072")))
|
||||
goto end;
|
||||
#else
|
||||
if (!TEST_true(SSL_set1_groups_list(serverssl, "P-256")))
|
||||
goto end;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check we can create a connection, the PSK is used and the callbacks are
|
||||
@@ -4737,6 +4863,11 @@ static int test_key_update(void)
|
||||
|| !TEST_int_eq(SSL_read(serverssl, buf, sizeof(buf)),
|
||||
strlen(mess)))
|
||||
goto end;
|
||||
|
||||
if (!TEST_int_eq(SSL_write(serverssl, mess, strlen(mess)), strlen(mess))
|
||||
|| !TEST_int_eq(SSL_read(clientssl, buf, sizeof(buf)),
|
||||
strlen(mess)))
|
||||
goto end;
|
||||
}
|
||||
|
||||
testresult = 1;
|
||||
@@ -4749,6 +4880,91 @@ static int test_key_update(void)
|
||||
|
||||
return testresult;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test we can handle a KeyUpdate (update requested) message while write data
|
||||
* is pending.
|
||||
* Test 0: Client sends KeyUpdate while Server is writing
|
||||
* Test 1: Server sends KeyUpdate while Client is writing
|
||||
*/
|
||||
static int test_key_update_in_write(int tst)
|
||||
{
|
||||
SSL_CTX *cctx = NULL, *sctx = NULL;
|
||||
SSL *clientssl = NULL, *serverssl = NULL;
|
||||
int testresult = 0;
|
||||
char buf[20];
|
||||
static char *mess = "A test message";
|
||||
BIO *bretry = BIO_new(bio_s_always_retry());
|
||||
BIO *tmp = NULL;
|
||||
SSL *peerupdate = NULL, *peerwrite = NULL;
|
||||
|
||||
if (!TEST_ptr(bretry)
|
||||
|| !TEST_true(create_ssl_ctx_pair(TLS_server_method(),
|
||||
TLS_client_method(),
|
||||
TLS1_3_VERSION,
|
||||
0,
|
||||
&sctx, &cctx, cert, privkey))
|
||||
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
|
||||
NULL, NULL))
|
||||
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
|
||||
SSL_ERROR_NONE)))
|
||||
goto end;
|
||||
|
||||
peerupdate = tst == 0 ? clientssl : serverssl;
|
||||
peerwrite = tst == 0 ? serverssl : clientssl;
|
||||
|
||||
if (!TEST_true(SSL_key_update(peerupdate, SSL_KEY_UPDATE_REQUESTED))
|
||||
|| !TEST_true(SSL_do_handshake(peerupdate)))
|
||||
goto end;
|
||||
|
||||
/* Swap the writing endpoint's write BIO to force a retry */
|
||||
tmp = SSL_get_wbio(peerwrite);
|
||||
if (!TEST_ptr(tmp) || !TEST_true(BIO_up_ref(tmp))) {
|
||||
tmp = NULL;
|
||||
goto end;
|
||||
}
|
||||
SSL_set0_wbio(peerwrite, bretry);
|
||||
bretry = NULL;
|
||||
|
||||
/* Write data that we know will fail with SSL_ERROR_WANT_WRITE */
|
||||
if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), -1)
|
||||
|| !TEST_int_eq(SSL_get_error(peerwrite, 0), SSL_ERROR_WANT_WRITE))
|
||||
goto end;
|
||||
|
||||
/* Reinstate the original writing endpoint's write BIO */
|
||||
SSL_set0_wbio(peerwrite, tmp);
|
||||
tmp = NULL;
|
||||
|
||||
/* Now read some data - we will read the key update */
|
||||
if (!TEST_int_eq(SSL_read(peerwrite, buf, sizeof(buf)), -1)
|
||||
|| !TEST_int_eq(SSL_get_error(peerwrite, 0), SSL_ERROR_WANT_READ))
|
||||
goto end;
|
||||
|
||||
/*
|
||||
* Complete the write we started previously and read it from the other
|
||||
* endpoint
|
||||
*/
|
||||
if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), strlen(mess))
|
||||
|| !TEST_int_eq(SSL_read(peerupdate, buf, sizeof(buf)), strlen(mess)))
|
||||
goto end;
|
||||
|
||||
/* Write more data to ensure we send the KeyUpdate message back */
|
||||
if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), strlen(mess))
|
||||
|| !TEST_int_eq(SSL_read(peerupdate, buf, sizeof(buf)), strlen(mess)))
|
||||
goto end;
|
||||
|
||||
testresult = 1;
|
||||
|
||||
end:
|
||||
SSL_free(serverssl);
|
||||
SSL_free(clientssl);
|
||||
SSL_CTX_free(sctx);
|
||||
SSL_CTX_free(cctx);
|
||||
BIO_free(bretry);
|
||||
BIO_free(tmp);
|
||||
|
||||
return testresult;
|
||||
}
|
||||
#endif /* OPENSSL_NO_TLS1_3 */
|
||||
|
||||
static int test_ssl_clear(int idx)
|
||||
@@ -6023,6 +6239,9 @@ static int cert_cb_cnt;
|
||||
static int cert_cb(SSL *s, void *arg)
|
||||
{
|
||||
SSL_CTX *ctx = (SSL_CTX *)arg;
|
||||
BIO *in = NULL;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
X509 *x509 = NULL;
|
||||
|
||||
if (cert_cb_cnt == 0) {
|
||||
/* Suspend the handshake */
|
||||
@@ -6043,9 +6262,39 @@ static int cert_cb(SSL *s, void *arg)
|
||||
return 0;
|
||||
cert_cb_cnt++;
|
||||
return 1;
|
||||
} else if (cert_cb_cnt == 3) {
|
||||
int rv;
|
||||
if (!TEST_ptr(in = BIO_new(BIO_s_file()))
|
||||
|| !TEST_int_ge(BIO_read_filename(in, cert), 0)
|
||||
|| !TEST_ptr(x509 = PEM_read_bio_X509(in, NULL, NULL, NULL)))
|
||||
goto out;
|
||||
BIO_free(in);
|
||||
if (!TEST_ptr(in = BIO_new(BIO_s_file()))
|
||||
|| !TEST_int_ge(BIO_read_filename(in, privkey), 0)
|
||||
|| !TEST_ptr(pkey = PEM_read_bio_PrivateKey(in, NULL, NULL, NULL)))
|
||||
goto out;
|
||||
rv = SSL_check_chain(s, x509, pkey, NULL);
|
||||
/*
|
||||
* If the cert doesn't show as valid here (e.g., because we don't
|
||||
* have any shared sigalgs), then we will not set it, and there will
|
||||
* be no certificate at all on the SSL or SSL_CTX. This, in turn,
|
||||
* will cause tls_choose_sigalgs() to fail the connection.
|
||||
*/
|
||||
if ((rv & CERT_PKEY_VALID)) {
|
||||
if (!SSL_use_cert_and_key(s, x509, pkey, NULL, 1))
|
||||
goto out;
|
||||
}
|
||||
BIO_free(in);
|
||||
EVP_PKEY_free(pkey);
|
||||
X509_free(x509);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Abort the handshake */
|
||||
out:
|
||||
BIO_free(in);
|
||||
EVP_PKEY_free(pkey);
|
||||
X509_free(x509);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6070,6 +6319,8 @@ static int test_cert_cb_int(int prot, int tst)
|
||||
|
||||
if (tst == 0)
|
||||
cert_cb_cnt = -1;
|
||||
else if (tst == 3)
|
||||
cert_cb_cnt = 3;
|
||||
else
|
||||
cert_cb_cnt = 0;
|
||||
if (tst == 2)
|
||||
@@ -6082,7 +6333,8 @@ static int test_cert_cb_int(int prot, int tst)
|
||||
|
||||
ret = create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE);
|
||||
if (!TEST_true(tst == 0 ? !ret : ret)
|
||||
|| (tst > 0 && !TEST_int_eq(cert_cb_cnt, 2))) {
|
||||
|| (tst > 0
|
||||
&& !TEST_int_eq((cert_cb_cnt - 2) * (cert_cb_cnt - 3), 0))) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -6446,6 +6698,7 @@ int setup_tests(void)
|
||||
#else
|
||||
ADD_ALL_TESTS(test_tls13_psk, 4);
|
||||
#endif /* OPENSSL_NO_PSK */
|
||||
ADD_ALL_TESTS(test_tls13_key_exchange, 4);
|
||||
ADD_ALL_TESTS(test_custom_exts, 5);
|
||||
ADD_TEST(test_stateless);
|
||||
ADD_TEST(test_pha_key_update);
|
||||
@@ -6457,6 +6710,7 @@ int setup_tests(void)
|
||||
#ifndef OPENSSL_NO_TLS1_3
|
||||
ADD_ALL_TESTS(test_export_key_mat_early, 3);
|
||||
ADD_TEST(test_key_update);
|
||||
ADD_ALL_TESTS(test_key_update_in_write, 2);
|
||||
#endif
|
||||
ADD_ALL_TESTS(test_ssl_clear, 2);
|
||||
ADD_ALL_TESTS(test_max_fragment_len_ext, OSSL_NELEM(max_fragment_len_test));
|
||||
@@ -6468,7 +6722,7 @@ int setup_tests(void)
|
||||
ADD_ALL_TESTS(test_ssl_get_shared_ciphers, OSSL_NELEM(shared_ciphers_data));
|
||||
ADD_ALL_TESTS(test_ticket_callbacks, 12);
|
||||
ADD_ALL_TESTS(test_shutdown, 7);
|
||||
ADD_ALL_TESTS(test_cert_cb, 3);
|
||||
ADD_ALL_TESTS(test_cert_cb, 4);
|
||||
ADD_ALL_TESTS(test_client_cert_cb, 2);
|
||||
ADD_ALL_TESTS(test_ca_names, 3);
|
||||
return 1;
|
||||
@@ -6477,4 +6731,5 @@ int setup_tests(void)
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
bio_s_mempacket_test_free();
|
||||
bio_s_always_retry_free();
|
||||
}
|
||||
+1
-1
@@ -71,7 +71,7 @@
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
# include <winsock.h>
|
||||
#else
|
||||
# include OPENSSL_UNISTD
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
static SSL_CTX *s_ctx = NULL;
|
||||
|
||||
+97
-1
@@ -70,9 +70,11 @@ static int tls_dump_puts(BIO *bp, const char *str);
|
||||
/* Choose a sufficiently large type likely to be unused for this custom BIO */
|
||||
#define BIO_TYPE_TLS_DUMP_FILTER (0x80 | BIO_TYPE_FILTER)
|
||||
#define BIO_TYPE_MEMPACKET_TEST 0x81
|
||||
#define BIO_TYPE_ALWAYS_RETRY 0x82
|
||||
|
||||
static BIO_METHOD *method_tls_dump = NULL;
|
||||
static BIO_METHOD *meth_mem = NULL;
|
||||
static BIO_METHOD *meth_always_retry = NULL;
|
||||
|
||||
/* Note: Not thread safe! */
|
||||
const BIO_METHOD *bio_f_tls_dump_filter(void)
|
||||
@@ -620,6 +622,100 @@ static int mempacket_test_puts(BIO *bio, const char *str)
|
||||
return mempacket_test_write(bio, str, strlen(str));
|
||||
}
|
||||
|
||||
static int always_retry_new(BIO *bi);
|
||||
static int always_retry_free(BIO *a);
|
||||
static int always_retry_read(BIO *b, char *out, int outl);
|
||||
static int always_retry_write(BIO *b, const char *in, int inl);
|
||||
static long always_retry_ctrl(BIO *b, int cmd, long num, void *ptr);
|
||||
static int always_retry_gets(BIO *bp, char *buf, int size);
|
||||
static int always_retry_puts(BIO *bp, const char *str);
|
||||
|
||||
const BIO_METHOD *bio_s_always_retry(void)
|
||||
{
|
||||
if (meth_always_retry == NULL) {
|
||||
if (!TEST_ptr(meth_always_retry = BIO_meth_new(BIO_TYPE_ALWAYS_RETRY,
|
||||
"Always Retry"))
|
||||
|| !TEST_true(BIO_meth_set_write(meth_always_retry,
|
||||
always_retry_write))
|
||||
|| !TEST_true(BIO_meth_set_read(meth_always_retry,
|
||||
always_retry_read))
|
||||
|| !TEST_true(BIO_meth_set_puts(meth_always_retry,
|
||||
always_retry_puts))
|
||||
|| !TEST_true(BIO_meth_set_gets(meth_always_retry,
|
||||
always_retry_gets))
|
||||
|| !TEST_true(BIO_meth_set_ctrl(meth_always_retry,
|
||||
always_retry_ctrl))
|
||||
|| !TEST_true(BIO_meth_set_create(meth_always_retry,
|
||||
always_retry_new))
|
||||
|| !TEST_true(BIO_meth_set_destroy(meth_always_retry,
|
||||
always_retry_free)))
|
||||
return NULL;
|
||||
}
|
||||
return meth_always_retry;
|
||||
}
|
||||
|
||||
void bio_s_always_retry_free(void)
|
||||
{
|
||||
BIO_meth_free(meth_always_retry);
|
||||
}
|
||||
|
||||
static int always_retry_new(BIO *bio)
|
||||
{
|
||||
BIO_set_init(bio, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int always_retry_free(BIO *bio)
|
||||
{
|
||||
BIO_set_data(bio, NULL);
|
||||
BIO_set_init(bio, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int always_retry_read(BIO *bio, char *out, int outl)
|
||||
{
|
||||
BIO_set_retry_read(bio);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int always_retry_write(BIO *bio, const char *in, int inl)
|
||||
{
|
||||
BIO_set_retry_write(bio);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static long always_retry_ctrl(BIO *bio, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret = 1;
|
||||
|
||||
switch (cmd) {
|
||||
case BIO_CTRL_FLUSH:
|
||||
BIO_set_retry_write(bio);
|
||||
/* fall through */
|
||||
case BIO_CTRL_EOF:
|
||||
case BIO_CTRL_RESET:
|
||||
case BIO_CTRL_DUP:
|
||||
case BIO_CTRL_PUSH:
|
||||
case BIO_CTRL_POP:
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int always_retry_gets(BIO *bio, char *buf, int size)
|
||||
{
|
||||
BIO_set_retry_read(bio);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int always_retry_puts(BIO *bio, const char *str)
|
||||
{
|
||||
BIO_set_retry_write(bio);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int create_ssl_ctx_pair(const SSL_METHOD *sm, const SSL_METHOD *cm,
|
||||
int min_proto_version, int max_proto_version,
|
||||
SSL_CTX **sctx, SSL_CTX **cctx, char *certfile,
|
||||
@@ -940,7 +1036,7 @@ int create_ssl_connection(SSL *serverssl, SSL *clientssl, int want)
|
||||
/*
|
||||
* We attempt to read some data on the client side which we expect to fail.
|
||||
* This will ensure we have received the NewSessionTicket in TLSv1.3 where
|
||||
* appropriate. We do this twice because there are 2 NewSesionTickets.
|
||||
* appropriate. We do this twice because there are 2 NewSessionTickets.
|
||||
*/
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (SSL_read_ex(clientssl, &buf, sizeof(buf), &readbytes) > 0) {
|
||||
|
||||
@@ -33,6 +33,9 @@ void bio_f_tls_dump_filter_free(void);
|
||||
const BIO_METHOD *bio_s_mempacket_test(void);
|
||||
void bio_s_mempacket_test_free(void);
|
||||
|
||||
const BIO_METHOD *bio_s_always_retry(void);
|
||||
void bio_s_always_retry_free(void);
|
||||
|
||||
/* Packet types - value 0 is reserved */
|
||||
#define INJECT_PACKET 1
|
||||
#define INJECT_PACKET_IGNORE_REC_SEQ 2
|
||||
|
||||
@@ -353,6 +353,8 @@ int run_tests(const char *test_prog_name)
|
||||
verdict = all_tests[i].test_fn();
|
||||
test_verdict(verdict, "%d - %s", ii + 1, test_title);
|
||||
finalize(verdict != 0);
|
||||
if (verdict == 0)
|
||||
num_failed++;
|
||||
} else {
|
||||
int num_failed_inner = 0;
|
||||
|
||||
|
||||
+129
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 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
|
||||
@@ -7,9 +7,137 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <openssl/opensslconf.h>
|
||||
#include <openssl/trace.h>
|
||||
#include "apps.h"
|
||||
#include "../testutil.h"
|
||||
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
typedef struct tracedata_st {
|
||||
BIO *bio;
|
||||
unsigned int ingroup:1;
|
||||
} tracedata;
|
||||
|
||||
static size_t internal_trace_cb(const char *buf, size_t cnt,
|
||||
int category, int cmd, void *vdata)
|
||||
{
|
||||
int ret = 0;
|
||||
tracedata *trace_data = vdata;
|
||||
char buffer[256], *hex;
|
||||
CRYPTO_THREAD_ID tid;
|
||||
|
||||
switch (cmd) {
|
||||
case OSSL_TRACE_CTRL_BEGIN:
|
||||
trace_data->ingroup = 1;
|
||||
|
||||
tid = CRYPTO_THREAD_get_current_id();
|
||||
hex = OPENSSL_buf2hexstr((const unsigned char *)&tid, sizeof(tid));
|
||||
BIO_snprintf(buffer, sizeof(buffer), "TRACE[%s]:%s: ",
|
||||
hex, OSSL_trace_get_category_name(category));
|
||||
OPENSSL_free(hex);
|
||||
BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX,
|
||||
strlen(buffer), buffer);
|
||||
break;
|
||||
case OSSL_TRACE_CTRL_WRITE:
|
||||
ret = BIO_write(trace_data->bio, buf, cnt);
|
||||
break;
|
||||
case OSSL_TRACE_CTRL_END:
|
||||
trace_data->ingroup = 0;
|
||||
|
||||
BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX, 0, NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret < 0 ? 0 : ret;
|
||||
}
|
||||
|
||||
DEFINE_STACK_OF(tracedata)
|
||||
static STACK_OF(tracedata) *trace_data_stack;
|
||||
|
||||
static void tracedata_free(tracedata *data)
|
||||
{
|
||||
BIO_free_all(data->bio);
|
||||
OPENSSL_free(data);
|
||||
}
|
||||
|
||||
static STACK_OF(tracedata) *trace_data_stack;
|
||||
|
||||
static void cleanup_trace(void)
|
||||
{
|
||||
sk_tracedata_pop_free(trace_data_stack, tracedata_free);
|
||||
}
|
||||
|
||||
static void setup_trace_category(int category)
|
||||
{
|
||||
BIO *channel;
|
||||
tracedata *trace_data;
|
||||
|
||||
if (OSSL_trace_enabled(category))
|
||||
return;
|
||||
|
||||
channel = BIO_push(BIO_new(apps_bf_prefix()),
|
||||
BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT));
|
||||
trace_data = OPENSSL_zalloc(sizeof(*trace_data));
|
||||
|
||||
if (trace_data == NULL
|
||||
|| (trace_data->bio = channel) == NULL
|
||||
|| OSSL_trace_set_callback(category, internal_trace_cb,
|
||||
trace_data) == 0
|
||||
|| sk_tracedata_push(trace_data_stack, trace_data) == 0) {
|
||||
|
||||
fprintf(stderr,
|
||||
"warning: unable to setup trace callback for category '%s'.\n",
|
||||
OSSL_trace_get_category_name(category));
|
||||
|
||||
OSSL_trace_set_callback(category, NULL, NULL);
|
||||
BIO_free_all(channel);
|
||||
}
|
||||
}
|
||||
|
||||
static void setup_trace(const char *str)
|
||||
{
|
||||
char *val;
|
||||
|
||||
/*
|
||||
* We add this handler as early as possible to ensure it's executed
|
||||
* as late as possible, i.e. after the TRACE code has done its cleanup
|
||||
* (which happens last in OPENSSL_cleanup).
|
||||
*/
|
||||
atexit(cleanup_trace);
|
||||
|
||||
trace_data_stack = sk_tracedata_new_null();
|
||||
val = OPENSSL_strdup(str);
|
||||
|
||||
if (val != NULL) {
|
||||
char *valp = val;
|
||||
char *item;
|
||||
|
||||
for (valp = val; (item = strtok(valp, ",")) != NULL; valp = NULL) {
|
||||
int category = OSSL_trace_get_category_num(item);
|
||||
|
||||
if (category == OSSL_TRACE_CATEGORY_ALL) {
|
||||
while (++category < OSSL_TRACE_CATEGORY_NUM)
|
||||
setup_trace_category(category);
|
||||
break;
|
||||
} else if (category > 0) {
|
||||
setup_trace_category(category);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"warning: unknown trace category: '%s'.\n", item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OPENSSL_free(val);
|
||||
}
|
||||
#endif /* OPENSSL_NO_TRACE */
|
||||
|
||||
int global_init(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
setup_trace(getenv("OPENSSL_TRACE"));
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -315,8 +315,15 @@ static int test_tls13ccs(int tst)
|
||||
|
||||
if ((tst >= 3 && tst <= 5) || tst >= 9) {
|
||||
/* HRR handshake */
|
||||
#if defined(OPENSSL_NO_EC)
|
||||
# if !defined(OPENSSL_NO_DH)
|
||||
if (!TEST_true(SSL_CTX_set1_groups_list(sctx, "ffdhe3072")))
|
||||
goto err;
|
||||
# endif
|
||||
#else
|
||||
if (!TEST_true(SSL_CTX_set1_groups_list(sctx, "P-256")))
|
||||
goto err;
|
||||
#endif
|
||||
}
|
||||
|
||||
s_to_c_fbio = BIO_new(bio_f_watchccs_filter());
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#define KEYLEN 16
|
||||
|
||||
/*
|
||||
* Based on the test vectors availble in:
|
||||
* Based on the test vectors available in:
|
||||
* https://tools.ietf.org/html/draft-ietf-tls-tls13-vectors-06
|
||||
*/
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
static const char *roots_f;
|
||||
static const char *untrusted_f;
|
||||
static const char *bad_f;
|
||||
static const char *req_f;
|
||||
|
||||
static STACK_OF(X509) *load_certs_from_file(const char *filename)
|
||||
{
|
||||
@@ -218,19 +219,61 @@ static int test_sm2_id(void)
|
||||
BIO_free(bio);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_req_sm2_id(void)
|
||||
{
|
||||
/* we only need an X509_REQ structure, no matter if it's a real SM2 cert */
|
||||
X509_REQ *x = NULL;
|
||||
BIO *bio = NULL;
|
||||
int ret = 0;
|
||||
ASN1_OCTET_STRING *v = NULL, *v2 = NULL;
|
||||
char *sm2id = "this is an ID";
|
||||
|
||||
bio = BIO_new_file(req_f, "r");
|
||||
if (bio == NULL)
|
||||
goto err;
|
||||
|
||||
x = PEM_read_bio_X509_REQ(bio, NULL, 0, NULL);
|
||||
if (x == NULL)
|
||||
goto err;
|
||||
|
||||
v = ASN1_OCTET_STRING_new();
|
||||
if (v == NULL)
|
||||
goto err;
|
||||
|
||||
if (!ASN1_OCTET_STRING_set(v, (unsigned char *)sm2id, (int)strlen(sm2id))) {
|
||||
ASN1_OCTET_STRING_free(v);
|
||||
goto err;
|
||||
}
|
||||
|
||||
X509_REQ_set0_sm2_id(x, v);
|
||||
|
||||
v2 = X509_REQ_get0_sm2_id(x);
|
||||
if (!TEST_ptr(v2)
|
||||
|| !TEST_int_eq(ASN1_OCTET_STRING_cmp(v, v2), 0))
|
||||
goto err;
|
||||
|
||||
ret = 1;
|
||||
err:
|
||||
X509_REQ_free(x);
|
||||
BIO_free(bio);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (!TEST_ptr(roots_f = test_get_argument(0))
|
||||
|| !TEST_ptr(untrusted_f = test_get_argument(1))
|
||||
|| !TEST_ptr(bad_f = test_get_argument(2)))
|
||||
|| !TEST_ptr(bad_f = test_get_argument(2))
|
||||
|| !TEST_ptr(req_f = test_get_argument(3)))
|
||||
return 0;
|
||||
|
||||
ADD_TEST(test_alt_chains_cert_forgery);
|
||||
ADD_TEST(test_store_ctx);
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
ADD_TEST(test_sm2_id);
|
||||
ADD_TEST(test_req_sm2_id);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -110,10 +110,11 @@ const OPTIONS *test_get_options(void)
|
||||
{
|
||||
enum { OPT_TEST_ENUM };
|
||||
static const OPTIONS test_options[] = {
|
||||
OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("certname key.pem type expected\n"),
|
||||
{ OPT_HELP_STR, 1, '-', "certname\tCertificate filename .pem/.req\n" },
|
||||
{ OPT_HELP_STR, 1, '-', "type\t\tvalue must be 'pem' or 'req'\n" },
|
||||
{ OPT_HELP_STR, 1, '-', "expected\tthe expected return value\n" },
|
||||
OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("cert key type expected\n"),
|
||||
{ OPT_HELP_STR, 1, '-', "cert\tcertificate or CSR filename in PEM\n" },
|
||||
{ OPT_HELP_STR, 1, '-', "key\tprivate key filename in PEM\n" },
|
||||
{ OPT_HELP_STR, 1, '-', "type\t\tvalue must be 'cert' or 'req'\n" },
|
||||
{ OPT_HELP_STR, 1, '-', "expected\tthe expected return value, either 'ok' or 'failed'\n" },
|
||||
{ NULL }
|
||||
};
|
||||
return test_options;
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
*
|
||||
***/
|
||||
|
||||
#include "../crypto/x509v3/ext_dat.h"
|
||||
#include "../crypto/x509v3/standard_exts.h"
|
||||
#include "../crypto/x509/ext_dat.h"
|
||||
#include "../crypto/x509/standard_exts.h"
|
||||
|
||||
static int test_standard_exts(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user