Latest update
This commit is contained in:
+122
-39
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-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
|
||||
@@ -123,7 +123,7 @@ static int getint(STANZA *s, int *out, const char *attribute)
|
||||
|
||||
*out = (int)word;
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(ret);
|
||||
return st;
|
||||
}
|
||||
@@ -138,7 +138,6 @@ static int equalBN(const char *op, const BIGNUM *expected, const BIGNUM *actual)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return a "random" flag for if a BN should be negated.
|
||||
*/
|
||||
@@ -150,7 +149,6 @@ static int rand_neg(void)
|
||||
return sign[(neg++) % 8];
|
||||
}
|
||||
|
||||
|
||||
static int test_swap(void)
|
||||
{
|
||||
BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL;
|
||||
@@ -166,7 +164,7 @@ static int test_swap(void)
|
||||
BN_bntest_rand(b, 1024, 1, 0);
|
||||
BN_copy(c, a);
|
||||
BN_copy(d, b);
|
||||
top = BN_num_bits(a)/BN_BITS2;
|
||||
top = BN_num_bits(a) / BN_BITS2;
|
||||
|
||||
/* regular swap */
|
||||
BN_swap(a, b);
|
||||
@@ -252,14 +250,13 @@ static int test_sub(void)
|
||||
goto err;
|
||||
}
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(b);
|
||||
BN_free(c);
|
||||
return st;
|
||||
}
|
||||
|
||||
|
||||
static int test_div_recip(void)
|
||||
{
|
||||
BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL;
|
||||
@@ -293,7 +290,7 @@ static int test_div_recip(void)
|
||||
goto err;
|
||||
}
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(b);
|
||||
BN_free(c);
|
||||
@@ -303,7 +300,6 @@ err:
|
||||
return st;
|
||||
}
|
||||
|
||||
|
||||
static int test_mod(void)
|
||||
{
|
||||
BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL;
|
||||
@@ -328,7 +324,7 @@ static int test_mod(void)
|
||||
goto err;
|
||||
}
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(b);
|
||||
BN_free(c);
|
||||
@@ -573,7 +569,7 @@ static int test_modexp_mont5(void)
|
||||
|
||||
st = 1;
|
||||
|
||||
err:
|
||||
err:
|
||||
BN_MONT_CTX_free(mont);
|
||||
BN_free(a);
|
||||
BN_free(p);
|
||||
@@ -1141,7 +1137,7 @@ static int file_sum(STANZA *s)
|
||||
}
|
||||
st = 1;
|
||||
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(b);
|
||||
BN_free(sum);
|
||||
@@ -1190,7 +1186,7 @@ static int file_lshift1(STANZA *s)
|
||||
goto err;
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(lshift1);
|
||||
BN_free(zero);
|
||||
@@ -1219,7 +1215,7 @@ static int file_lshift(STANZA *s)
|
||||
goto err;
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(lshift);
|
||||
BN_free(ret);
|
||||
@@ -1249,7 +1245,7 @@ static int file_rshift(STANZA *s)
|
||||
}
|
||||
st = 1;
|
||||
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(rshift);
|
||||
BN_free(ret);
|
||||
@@ -1306,7 +1302,7 @@ static int file_square(STANZA *s)
|
||||
#endif
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(square);
|
||||
BN_free(zero);
|
||||
@@ -1343,7 +1339,7 @@ static int file_product(STANZA *s)
|
||||
goto err;
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(b);
|
||||
BN_free(product);
|
||||
@@ -1426,7 +1422,7 @@ static int file_quotient(STANZA *s)
|
||||
}
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(b);
|
||||
BN_free(quotient);
|
||||
@@ -1480,7 +1476,7 @@ static int file_modmul(STANZA *s)
|
||||
}
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(b);
|
||||
BN_free(m);
|
||||
@@ -1532,7 +1528,7 @@ static int file_modexp(STANZA *s)
|
||||
goto err;
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(b);
|
||||
BN_free(c);
|
||||
@@ -1560,7 +1556,7 @@ static int file_exp(STANZA *s)
|
||||
goto err;
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(e);
|
||||
BN_free(exp);
|
||||
@@ -1591,7 +1587,7 @@ static int file_modsqrt(STANZA *s)
|
||||
goto err;
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(p);
|
||||
BN_free(mod_sqrt);
|
||||
@@ -1621,8 +1617,8 @@ static int test_bn2padded(void)
|
||||
|
||||
/* Test a random numbers at various byte lengths. */
|
||||
for (size_t bytes = 128 - 7; bytes <= 128; bytes++) {
|
||||
#define TOP_BIT_ON 0
|
||||
#define BOTTOM_BIT_NOTOUCH 0
|
||||
# define TOP_BIT_ON 0
|
||||
# define BOTTOM_BIT_NOTOUCH 0
|
||||
if (!TEST_true(BN_rand(n, bytes * 8, TOP_BIT_ON, BOTTOM_BIT_NOTOUCH)))
|
||||
goto err;
|
||||
if (!TEST_int_eq(BN_num_bytes(n),A) bytes
|
||||
@@ -1653,7 +1649,7 @@ static int test_bn2padded(void)
|
||||
}
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(n);
|
||||
return st;
|
||||
#else
|
||||
@@ -1725,7 +1721,7 @@ static int test_dec2bn(void)
|
||||
goto err;
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(bn);
|
||||
return st;
|
||||
}
|
||||
@@ -1791,7 +1787,7 @@ static int test_hex2bn(void)
|
||||
goto err;
|
||||
st = 1;
|
||||
|
||||
err:
|
||||
err:
|
||||
BN_free(bn);
|
||||
return st;
|
||||
}
|
||||
@@ -1845,7 +1841,7 @@ static int test_asc2bn(void)
|
||||
goto err;
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(bn);
|
||||
return st;
|
||||
}
|
||||
@@ -1889,7 +1885,7 @@ static int test_mpi(int i)
|
||||
BN_free(bn2);
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(bn);
|
||||
return st;
|
||||
}
|
||||
@@ -1915,7 +1911,7 @@ static int test_rand(void)
|
||||
goto err;
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(bn);
|
||||
return st;
|
||||
}
|
||||
@@ -1979,7 +1975,7 @@ static int test_negzero(void)
|
||||
goto err;
|
||||
st = 1;
|
||||
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(b);
|
||||
BN_free(c);
|
||||
@@ -2020,7 +2016,7 @@ static int test_badmod(void)
|
||||
ERR_clear_error();
|
||||
|
||||
if (!TEST_false(BN_mod_exp_mont_consttime(a, BN_value_one(), BN_value_one(),
|
||||
zero, ctx, NULL)))
|
||||
zero, ctx, NULL)))
|
||||
goto err;
|
||||
ERR_clear_error();
|
||||
|
||||
@@ -2042,12 +2038,12 @@ static int test_badmod(void)
|
||||
ERR_clear_error();
|
||||
|
||||
if (!TEST_false(BN_mod_exp_mont_consttime(a, BN_value_one(), BN_value_one(),
|
||||
b, ctx, NULL)))
|
||||
b, ctx, NULL)))
|
||||
goto err;
|
||||
ERR_clear_error();
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(a);
|
||||
BN_free(b);
|
||||
BN_free(zero);
|
||||
@@ -2081,7 +2077,7 @@ static int test_expmodzero(void)
|
||||
goto err;
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(zero);
|
||||
BN_free(a);
|
||||
BN_free(r);
|
||||
@@ -2127,7 +2123,7 @@ static int test_expmodone(void)
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(r);
|
||||
BN_free(a);
|
||||
BN_free(p);
|
||||
@@ -2148,7 +2144,7 @@ static int test_smallprime(void)
|
||||
goto err;
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(r);
|
||||
return st;
|
||||
}
|
||||
@@ -2172,7 +2168,7 @@ static int test_is_prime(int i)
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(r);
|
||||
return ret;
|
||||
}
|
||||
@@ -2195,11 +2191,97 @@ static int test_not_prime(int i)
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
err:
|
||||
err:
|
||||
BN_free(r);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_ctx_set_ct_flag(BN_CTX *c)
|
||||
{
|
||||
int st = 0;
|
||||
size_t i;
|
||||
BIGNUM *b[15];
|
||||
|
||||
BN_CTX_start(c);
|
||||
for (i = 0; i < OSSL_NELEM(b); i++) {
|
||||
if (!TEST_ptr(b[i] = BN_CTX_get(c)))
|
||||
goto err;
|
||||
if (i % 2 == 1)
|
||||
BN_set_flags(b[i], BN_FLG_CONSTTIME);
|
||||
}
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
BN_CTX_end(c);
|
||||
return st;
|
||||
}
|
||||
|
||||
static int test_ctx_check_ct_flag(BN_CTX *c)
|
||||
{
|
||||
int st = 0;
|
||||
size_t i;
|
||||
BIGNUM *b[30];
|
||||
|
||||
BN_CTX_start(c);
|
||||
for (i = 0; i < OSSL_NELEM(b); i++) {
|
||||
if (!TEST_ptr(b[i] = BN_CTX_get(c)))
|
||||
goto err;
|
||||
if (!TEST_false(BN_get_flags(b[i], BN_FLG_CONSTTIME)))
|
||||
goto err;
|
||||
}
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
BN_CTX_end(c);
|
||||
return st;
|
||||
}
|
||||
|
||||
static int test_ctx_consttime_flag(void)
|
||||
{
|
||||
/*-
|
||||
* The constant-time flag should not "leak" among BN_CTX frames:
|
||||
*
|
||||
* - test_ctx_set_ct_flag() starts a frame in the given BN_CTX and
|
||||
* sets the BN_FLG_CONSTTIME flag on some of the BIGNUMs obtained
|
||||
* from the frame before ending it.
|
||||
* - test_ctx_check_ct_flag() then starts a new frame and gets a
|
||||
* number of BIGNUMs from it. In absence of leaks, none of the
|
||||
* BIGNUMs in the new frame should have BN_FLG_CONSTTIME set.
|
||||
*
|
||||
* In actual BN_CTX usage inside libcrypto the leak could happen at
|
||||
* any depth level in the BN_CTX stack, with varying results
|
||||
* depending on the patterns of sibling trees of nested function
|
||||
* calls sharing the same BN_CTX object, and the effect of
|
||||
* unintended BN_FLG_CONSTTIME on the called BN_* functions.
|
||||
*
|
||||
* This simple unit test abstracts away this complexity and verifies
|
||||
* that the leak does not happen between two sibling functions
|
||||
* sharing the same BN_CTX object at the same level of nesting.
|
||||
*
|
||||
*/
|
||||
BN_CTX *nctx = NULL;
|
||||
BN_CTX *sctx = NULL;
|
||||
size_t i = 0;
|
||||
int st = 0;
|
||||
|
||||
if (!TEST_ptr(nctx = BN_CTX_new())
|
||||
|| !TEST_ptr(sctx = BN_CTX_secure_new()))
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
BN_CTX *c = i == 0 ? nctx : sctx;
|
||||
if (!TEST_true(test_ctx_set_ct_flag(c))
|
||||
|| !TEST_true(test_ctx_check_ct_flag(c)))
|
||||
goto err;
|
||||
}
|
||||
|
||||
st = 1;
|
||||
err:
|
||||
BN_CTX_free(nctx);
|
||||
BN_CTX_free(sctx);
|
||||
return st;
|
||||
}
|
||||
|
||||
static int file_test_run(STANZA *s)
|
||||
{
|
||||
static const FILETEST filetests[] = {
|
||||
@@ -2298,6 +2380,7 @@ int setup_tests(void)
|
||||
ADD_TEST(test_expmodone);
|
||||
ADD_TEST(test_smallprime);
|
||||
ADD_TEST(test_swap);
|
||||
ADD_TEST(test_ctx_consttime_flag);
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
ADD_TEST(test_gf2m_add);
|
||||
ADD_TEST(test_gf2m_mod);
|
||||
|
||||
+140
-117
@@ -15,7 +15,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 ../apps/opt.c
|
||||
INCLUDE[libtestutil.a]=../include ..
|
||||
INCLUDE[libtestutil.a]=../include ../apps/include ..
|
||||
DEPEND[libtestutil.a]=../libcrypto
|
||||
|
||||
PROGRAMS{noinst}=\
|
||||
@@ -30,7 +30,7 @@ IF[{- !$disabled{tests} -}]
|
||||
dhtest enginetest casttest \
|
||||
bftest ssltest_old dsatest dsa_no_digest_size_test exptest rsa_test \
|
||||
evp_test evp_extra_test igetest v3nametest v3ext \
|
||||
crltest danetest bad_dtls_test lhash_test \
|
||||
crltest danetest bad_dtls_test lhash_test sparse_array_test \
|
||||
conf_include_test \
|
||||
constant_time_test verify_extra_test clienthellotest \
|
||||
packettest asynctest secmemtest srptest memleaktest stack_test \
|
||||
@@ -38,244 +38,246 @@ IF[{- !$disabled{tests} -}]
|
||||
ssl_test_ctx_test ssl_test x509aux cipherlist_test asynciotest \
|
||||
bio_callback_test bio_memleak_test \
|
||||
bioprinttest sslapitest dtlstest sslcorrupttest bio_enc_test \
|
||||
pkey_meth_test pkey_meth_kdf_test uitest cipherbytes_test \
|
||||
pkey_meth_test pkey_meth_kdf_test evp_kdf_test uitest \
|
||||
cipherbytes_test \
|
||||
asn1_encode_test asn1_decode_test asn1_string_table_test \
|
||||
x509_time_test x509_dup_cert_test x509_check_cert_pkey_test \
|
||||
recordlentest drbgtest sslbuffertest \
|
||||
recordlentest drbgtest drbg_cavs_test sslbuffertest \
|
||||
time_offset_test pemtest ssl_cert_table_internal_test ciphername_test \
|
||||
servername_test ocspapitest rsa_mp_test fatalerrtest tls13ccstest \
|
||||
sysdefaulttest errtest gosttest
|
||||
sysdefaulttest errtest gosttest \
|
||||
context_internal_test
|
||||
|
||||
SOURCE[versions]=versions.c
|
||||
INCLUDE[versions]=../include
|
||||
INCLUDE[versions]=../include ../apps/include
|
||||
DEPEND[versions]=../libcrypto
|
||||
|
||||
SOURCE[aborttest]=aborttest.c
|
||||
INCLUDE[aborttest]=../include
|
||||
INCLUDE[aborttest]=../include ../apps/include
|
||||
DEPEND[aborttest]=../libcrypto
|
||||
|
||||
SOURCE[sanitytest]=sanitytest.c
|
||||
INCLUDE[sanitytest]=../include
|
||||
INCLUDE[sanitytest]=../include ../apps/include
|
||||
DEPEND[sanitytest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[rsa_complex]=rsa_complex.c
|
||||
INCLUDE[rsa_complex]=../include
|
||||
INCLUDE[rsa_complex]=../include ../apps/include
|
||||
|
||||
SOURCE[test_test]=test_test.c
|
||||
INCLUDE[test_test]=../include
|
||||
INCLUDE[test_test]=../include ../apps/include
|
||||
DEPEND[test_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[exdatatest]=exdatatest.c
|
||||
INCLUDE[exdatatest]=../include
|
||||
INCLUDE[exdatatest]=../include ../apps/include
|
||||
DEPEND[exdatatest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[bntest]=bntest.c
|
||||
INCLUDE[bntest]=../include
|
||||
INCLUDE[bntest]=../include ../apps/include
|
||||
DEPEND[bntest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[ectest]=ectest.c
|
||||
INCLUDE[ectest]=../include
|
||||
INCLUDE[ectest]=../include ../apps/include
|
||||
DEPEND[ectest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[ecstresstest]=ecstresstest.c
|
||||
INCLUDE[ecstresstest]=../include
|
||||
INCLUDE[ecstresstest]=../include ../apps/include
|
||||
DEPEND[ecstresstest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[ecdsatest]=ecdsatest.c
|
||||
INCLUDE[ecdsatest]=../include
|
||||
INCLUDE[ecdsatest]=../include ../apps/include
|
||||
DEPEND[ecdsatest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[gmdifftest]=gmdifftest.c
|
||||
INCLUDE[gmdifftest]=../include
|
||||
INCLUDE[gmdifftest]=../include ../apps/include
|
||||
DEPEND[gmdifftest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[pbelutest]=pbelutest.c
|
||||
INCLUDE[pbelutest]=../include
|
||||
INCLUDE[pbelutest]=../include ../apps/include
|
||||
DEPEND[pbelutest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[ideatest]=ideatest.c
|
||||
INCLUDE[ideatest]=../include
|
||||
INCLUDE[ideatest]=../include ../apps/include
|
||||
DEPEND[ideatest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[md2test]=md2test.c
|
||||
INCLUDE[md2test]=../include
|
||||
INCLUDE[md2test]=../include ../apps/include
|
||||
DEPEND[md2test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[hmactest]=hmactest.c
|
||||
INCLUDE[hmactest]=../include
|
||||
INCLUDE[hmactest]=../include ../apps/include
|
||||
DEPEND[hmactest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[rc2test]=rc2test.c
|
||||
INCLUDE[rc2test]=../include
|
||||
INCLUDE[rc2test]=../include ../apps/include
|
||||
DEPEND[rc2test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[rc4test]=rc4test.c
|
||||
INCLUDE[rc4test]=../include
|
||||
INCLUDE[rc4test]=../include ../apps/include
|
||||
DEPEND[rc4test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[rc5test]=rc5test.c
|
||||
INCLUDE[rc5test]=../include
|
||||
INCLUDE[rc5test]=../include ../apps/include
|
||||
DEPEND[rc5test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[destest]=destest.c
|
||||
INCLUDE[destest]=../include
|
||||
INCLUDE[destest]=../include ../apps/include
|
||||
DEPEND[destest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[mdc2test]=mdc2test.c
|
||||
INCLUDE[mdc2test]=../include
|
||||
INCLUDE[mdc2test]=../include ../apps/include
|
||||
DEPEND[mdc2test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[dhtest]=dhtest.c
|
||||
INCLUDE[dhtest]=../include
|
||||
INCLUDE[dhtest]=../include ../apps/include
|
||||
DEPEND[dhtest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[enginetest]=enginetest.c
|
||||
INCLUDE[enginetest]=../include
|
||||
INCLUDE[enginetest]=../include ../apps/include
|
||||
DEPEND[enginetest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[casttest]=casttest.c
|
||||
INCLUDE[casttest]=../include
|
||||
INCLUDE[casttest]=../include ../apps/include
|
||||
DEPEND[casttest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[bftest]=bftest.c
|
||||
INCLUDE[bftest]=../include
|
||||
INCLUDE[bftest]=../include ../apps/include
|
||||
DEPEND[bftest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[ssltest_old]=ssltest_old.c
|
||||
INCLUDE[ssltest_old]=.. ../include
|
||||
INCLUDE[ssltest_old]=.. ../include ../apps/include
|
||||
DEPEND[ssltest_old]=../libcrypto ../libssl
|
||||
|
||||
SOURCE[dsatest]=dsatest.c
|
||||
INCLUDE[dsatest]=../include
|
||||
INCLUDE[dsatest]=../include ../apps/include
|
||||
DEPEND[dsatest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[dsa_no_digest_size_test]=dsa_no_digest_size_test.c
|
||||
INCLUDE[dsa_no_digest_size_test]=../include
|
||||
INCLUDE[dsa_no_digest_size_test]=../include ../apps/include
|
||||
DEPEND[dsa_no_digest_size_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[exptest]=exptest.c
|
||||
INCLUDE[exptest]=../include
|
||||
INCLUDE[exptest]=../include ../apps/include
|
||||
DEPEND[exptest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[rsa_test]=rsa_test.c
|
||||
INCLUDE[rsa_test]=../include
|
||||
INCLUDE[rsa_test]=../include ../apps/include
|
||||
DEPEND[rsa_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[rsa_mp_test]=rsa_mp_test.c
|
||||
INCLUDE[rsa_mp_test]=../include
|
||||
INCLUDE[rsa_mp_test]=../include ../apps/include
|
||||
DEPEND[rsa_mp_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[fatalerrtest]=fatalerrtest.c ssltestlib.c
|
||||
INCLUDE[fatalerrtest]=../include
|
||||
INCLUDE[fatalerrtest]=../include ../apps/include
|
||||
DEPEND[fatalerrtest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[tls13ccstest]=tls13ccstest.c ssltestlib.c
|
||||
INCLUDE[tls13ccstest]=../include
|
||||
INCLUDE[tls13ccstest]=../include ../apps/include
|
||||
DEPEND[tls13ccstest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[evp_test]=evp_test.c
|
||||
INCLUDE[evp_test]=../include
|
||||
INCLUDE[evp_test]=../include ../apps/include
|
||||
DEPEND[evp_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[evp_extra_test]=evp_extra_test.c
|
||||
INCLUDE[evp_extra_test]=../include ../crypto/include
|
||||
INCLUDE[evp_extra_test]=../include ../apps/include ../crypto/include
|
||||
DEPEND[evp_extra_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[igetest]=igetest.c
|
||||
INCLUDE[igetest]=../include
|
||||
INCLUDE[igetest]=../include ../apps/include
|
||||
DEPEND[igetest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[v3nametest]=v3nametest.c
|
||||
INCLUDE[v3nametest]=../include
|
||||
INCLUDE[v3nametest]=../include ../apps/include
|
||||
DEPEND[v3nametest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[crltest]=crltest.c
|
||||
INCLUDE[crltest]=../include
|
||||
INCLUDE[crltest]=../include ../apps/include
|
||||
DEPEND[crltest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[v3ext]=v3ext.c
|
||||
INCLUDE[v3ext]=../include
|
||||
INCLUDE[v3ext]=../include ../apps/include
|
||||
DEPEND[v3ext]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[danetest]=danetest.c
|
||||
INCLUDE[danetest]=../include
|
||||
INCLUDE[danetest]=../include ../apps/include
|
||||
DEPEND[danetest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[constant_time_test]=constant_time_test.c
|
||||
INCLUDE[constant_time_test]=../include
|
||||
INCLUDE[constant_time_test]=../include ../apps/include
|
||||
DEPEND[constant_time_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[verify_extra_test]=verify_extra_test.c
|
||||
INCLUDE[verify_extra_test]=../include
|
||||
INCLUDE[verify_extra_test]=../include ../apps/include
|
||||
DEPEND[verify_extra_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[clienthellotest]=clienthellotest.c
|
||||
INCLUDE[clienthellotest]=../include
|
||||
INCLUDE[clienthellotest]=../include ../apps/include
|
||||
DEPEND[clienthellotest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[bad_dtls_test]=bad_dtls_test.c
|
||||
INCLUDE[bad_dtls_test]=../include
|
||||
INCLUDE[bad_dtls_test]=../include ../apps/include
|
||||
DEPEND[bad_dtls_test]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[packettest]=packettest.c
|
||||
INCLUDE[packettest]=../include
|
||||
INCLUDE[packettest]=../include ../apps/include
|
||||
DEPEND[packettest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[asynctest]=asynctest.c
|
||||
INCLUDE[asynctest]=../include
|
||||
INCLUDE[asynctest]=../include ../apps/include
|
||||
DEPEND[asynctest]=../libcrypto
|
||||
|
||||
SOURCE[secmemtest]=secmemtest.c
|
||||
INCLUDE[secmemtest]=../include
|
||||
INCLUDE[secmemtest]=../include ../apps/include
|
||||
DEPEND[secmemtest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[srptest]=srptest.c
|
||||
INCLUDE[srptest]=../include
|
||||
INCLUDE[srptest]=../include ../apps/include
|
||||
DEPEND[srptest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[memleaktest]=memleaktest.c
|
||||
INCLUDE[memleaktest]=../include
|
||||
INCLUDE[memleaktest]=../include ../apps/include
|
||||
DEPEND[memleaktest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[stack_test]=stack_test.c
|
||||
INCLUDE[stack_test]=../include
|
||||
INCLUDE[stack_test]=../include ../apps/include
|
||||
DEPEND[stack_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[lhash_test]=lhash_test.c
|
||||
INCLUDE[lhash_test]=../include
|
||||
INCLUDE[lhash_test]=../include ../apps/include
|
||||
DEPEND[lhash_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[dtlsv1listentest]=dtlsv1listentest.c
|
||||
INCLUDE[dtlsv1listentest]=../include
|
||||
INCLUDE[dtlsv1listentest]=../include ../apps/include
|
||||
DEPEND[dtlsv1listentest]=../libssl libtestutil.a
|
||||
|
||||
SOURCE[ct_test]=ct_test.c
|
||||
INCLUDE[ct_test]=../include
|
||||
INCLUDE[ct_test]=../include ../apps/include
|
||||
DEPEND[ct_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[threadstest]=threadstest.c
|
||||
INCLUDE[threadstest]=../include
|
||||
INCLUDE[threadstest]=../include ../apps/include
|
||||
DEPEND[threadstest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[afalgtest]=afalgtest.c
|
||||
INCLUDE[afalgtest]=../include
|
||||
INCLUDE[afalgtest]=../include ../apps/include
|
||||
DEPEND[afalgtest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[d2i_test]=d2i_test.c
|
||||
INCLUDE[d2i_test]=../include
|
||||
INCLUDE[d2i_test]=../include ../apps/include
|
||||
DEPEND[d2i_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[ssl_test_ctx_test]=ssl_test_ctx_test.c ssl_test_ctx.c
|
||||
INCLUDE[ssl_test_ctx_test]=../include
|
||||
INCLUDE[ssl_test_ctx_test]=../include ../apps/include
|
||||
DEPEND[ssl_test_ctx_test]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[ssl_test]=ssl_test.c ssl_test_ctx.c handshake_helper.c
|
||||
INCLUDE[ssl_test]=../include
|
||||
INCLUDE[ssl_test]=../include ../apps/include
|
||||
DEPEND[ssl_test]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[cipherlist_test]=cipherlist_test.c
|
||||
INCLUDE[cipherlist_test]=../include
|
||||
INCLUDE[cipherlist_test]=../include ../apps/include
|
||||
DEPEND[cipherlist_test]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
INCLUDE[ssl_test_ctx.o]=../include
|
||||
@@ -283,148 +285,152 @@ IF[{- !$disabled{tests} -}]
|
||||
INCLUDE[ssltestlib.o]=.. ../include
|
||||
|
||||
SOURCE[x509aux]=x509aux.c
|
||||
INCLUDE[x509aux]=../include
|
||||
INCLUDE[x509aux]=../include ../apps/include
|
||||
DEPEND[x509aux]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[asynciotest]=asynciotest.c ssltestlib.c
|
||||
INCLUDE[asynciotest]=../include
|
||||
INCLUDE[asynciotest]=../include ../apps/include
|
||||
DEPEND[asynciotest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[bio_callback_test]=bio_callback_test.c
|
||||
INCLUDE[bio_callback_test]=../include
|
||||
INCLUDE[bio_callback_test]=../include ../apps/include
|
||||
DEPEND[bio_callback_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[bio_memleak_test]=bio_memleak_test.c
|
||||
INCLUDE[bio_memleak_test]=../include
|
||||
INCLUDE[bio_memleak_test]=../include ../apps/include
|
||||
DEPEND[bio_memleak_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[bioprinttest]=bioprinttest.c
|
||||
INCLUDE[bioprinttest]=../include
|
||||
INCLUDE[bioprinttest]=../include ../apps/include
|
||||
DEPEND[bioprinttest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[sslapitest]=sslapitest.c ssltestlib.c
|
||||
INCLUDE[sslapitest]=../include ..
|
||||
INCLUDE[sslapitest]=../include ../apps/include ..
|
||||
DEPEND[sslapitest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[ocspapitest]=ocspapitest.c
|
||||
INCLUDE[ocspapitest]=../include
|
||||
INCLUDE[ocspapitest]=../include ../apps/include
|
||||
DEPEND[ocspapitest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[dtlstest]=dtlstest.c ssltestlib.c
|
||||
INCLUDE[dtlstest]=../include
|
||||
INCLUDE[dtlstest]=../include ../apps/include
|
||||
DEPEND[dtlstest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[sslcorrupttest]=sslcorrupttest.c ssltestlib.c
|
||||
INCLUDE[sslcorrupttest]=../include
|
||||
INCLUDE[sslcorrupttest]=../include ../apps/include
|
||||
DEPEND[sslcorrupttest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[bio_enc_test]=bio_enc_test.c
|
||||
INCLUDE[bio_enc_test]=../include
|
||||
INCLUDE[bio_enc_test]=../include ../apps/include
|
||||
DEPEND[bio_enc_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[pkey_meth_test]=pkey_meth_test.c
|
||||
INCLUDE[pkey_meth_test]=../include
|
||||
INCLUDE[pkey_meth_test]=../include ../apps/include
|
||||
DEPEND[pkey_meth_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[pkey_meth_kdf_test]=pkey_meth_kdf_test.c
|
||||
INCLUDE[pkey_meth_kdf_test]=../include
|
||||
INCLUDE[pkey_meth_kdf_test]=../include ../apps/include
|
||||
DEPEND[pkey_meth_kdf_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[evp_kdf_test]=evp_kdf_test.c
|
||||
INCLUDE[evp_kdf_test]=../include ../apps/include
|
||||
DEPEND[evp_kdf_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[x509_time_test]=x509_time_test.c
|
||||
INCLUDE[x509_time_test]=../include
|
||||
INCLUDE[x509_time_test]=../include ../apps/include
|
||||
DEPEND[x509_time_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[recordlentest]=recordlentest.c ssltestlib.c
|
||||
INCLUDE[recordlentest]=../include
|
||||
INCLUDE[recordlentest]=../include ../apps/include
|
||||
DEPEND[recordlentest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[drbgtest]=drbgtest.c
|
||||
INCLUDE[drbgtest]=../include
|
||||
INCLUDE[drbgtest]=../include ../apps/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 . ..
|
||||
INCLUDE[drbg_cavs_test]=../include ../apps/include . ..
|
||||
DEPEND[drbg_cavs_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[x509_dup_cert_test]=x509_dup_cert_test.c
|
||||
INCLUDE[x509_dup_cert_test]=../include
|
||||
INCLUDE[x509_dup_cert_test]=../include ../apps/include
|
||||
DEPEND[x509_dup_cert_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[x509_check_cert_pkey_test]=x509_check_cert_pkey_test.c
|
||||
INCLUDE[x509_check_cert_pkey_test]=../include
|
||||
INCLUDE[x509_check_cert_pkey_test]=../include ../apps/include
|
||||
DEPEND[x509_check_cert_pkey_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[pemtest]=pemtest.c
|
||||
INCLUDE[pemtest]=../include
|
||||
INCLUDE[pemtest]=../include ../apps/include
|
||||
DEPEND[pemtest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[ssl_cert_table_internal_test]=ssl_cert_table_internal_test.c
|
||||
INCLUDE[ssl_cert_table_internal_test]=.. ../include
|
||||
INCLUDE[ssl_cert_table_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[ssl_cert_table_internal_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[ciphername_test]=ciphername_test.c
|
||||
INCLUDE[ciphername_test]=../include
|
||||
INCLUDE[ciphername_test]=../include ../apps/include
|
||||
DEPEND[ciphername_test]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[servername_test]=servername_test.c ssltestlib.c
|
||||
INCLUDE[servername_test]=../include
|
||||
INCLUDE[servername_test]=../include ../apps/include
|
||||
DEPEND[servername_test]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
IF[{- !$disabled{cms} -}]
|
||||
PROGRAMS{noinst}=cmsapitest
|
||||
SOURCE[cmsapitest]=cmsapitest.c
|
||||
INCLUDE[cmsapitest]=../include
|
||||
INCLUDE[cmsapitest]=../include ../apps/include
|
||||
DEPEND[cmsapitest]=../libcrypto libtestutil.a
|
||||
ENDIF
|
||||
|
||||
IF[{- !$disabled{psk} -}]
|
||||
PROGRAMS{noinst}=dtls_mtu_test
|
||||
SOURCE[dtls_mtu_test]=dtls_mtu_test.c ssltestlib.c
|
||||
INCLUDE[dtls_mtu_test]=.. ../include
|
||||
INCLUDE[dtls_mtu_test]=.. ../include ../apps/include
|
||||
DEPEND[dtls_mtu_test]=../libcrypto ../libssl libtestutil.a
|
||||
ENDIF
|
||||
|
||||
IF[{- !$disabled{shared} -}]
|
||||
PROGRAMS{noinst}=shlibloadtest
|
||||
SOURCE[shlibloadtest]=shlibloadtest.c
|
||||
INCLUDE[shlibloadtest]=../include ../crypto/include
|
||||
INCLUDE[shlibloadtest]=../include ../apps/include ../crypto/include
|
||||
ENDIF
|
||||
|
||||
IF[{- $disabled{shared} -}]
|
||||
PROGRAMS{noinst}=cipher_overhead_test
|
||||
SOURCE[cipher_overhead_test]=cipher_overhead_test.c
|
||||
INCLUDE[cipher_overhead_test]=.. ../include
|
||||
INCLUDE[cipher_overhead_test]=.. ../include ../apps/include
|
||||
DEPEND[cipher_overhead_test]=../libcrypto ../libssl libtestutil.a
|
||||
ENDIF
|
||||
|
||||
SOURCE[uitest]=uitest.c ../apps/apps_ui.c
|
||||
INCLUDE[uitest]=.. ../include ../apps
|
||||
INCLUDE[uitest]=.. ../include ../apps/include
|
||||
DEPEND[uitest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[cipherbytes_test]=cipherbytes_test.c
|
||||
INCLUDE[cipherbytes_test]=../include
|
||||
INCLUDE[cipherbytes_test]=../include ../apps/include
|
||||
DEPEND[cipherbytes_test]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[asn1_encode_test]=asn1_encode_test.c
|
||||
INCLUDE[asn1_encode_test]=../include
|
||||
INCLUDE[asn1_encode_test]=../include ../apps/include
|
||||
DEPEND[asn1_encode_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[asn1_decode_test]=asn1_decode_test.c
|
||||
INCLUDE[asn1_decode_test]=../include
|
||||
INCLUDE[asn1_decode_test]=../include ../apps/include
|
||||
DEPEND[asn1_decode_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[asn1_string_table_test]=asn1_string_table_test.c
|
||||
INCLUDE[asn1_string_table_test]=../include
|
||||
INCLUDE[asn1_string_table_test]=../include ../apps/include
|
||||
DEPEND[asn1_string_table_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[time_offset_test]=time_offset_test.c
|
||||
INCLUDE[time_offset_test]=../include
|
||||
INCLUDE[time_offset_test]=../include ../apps/include
|
||||
DEPEND[time_offset_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[conf_include_test]=conf_include_test.c
|
||||
INCLUDE[conf_include_test]=../include
|
||||
INCLUDE[conf_include_test]=../include ../apps/include
|
||||
DEPEND[conf_include_test]=../libcrypto libtestutil.a
|
||||
|
||||
# Internal test programs. These are essentially a collection of internal
|
||||
@@ -436,7 +442,7 @@ IF[{- !$disabled{tests} -}]
|
||||
IF[1]
|
||||
PROGRAMS{noinst}=asn1_internal_test modes_internal_test x509_internal_test \
|
||||
tls13encryptiontest wpackettest ctype_internal_test \
|
||||
rdrand_sanitytest
|
||||
rdrand_sanitytest property_test
|
||||
IF[{- !$disabled{poly1305} -}]
|
||||
PROGRAMS{noinst}=poly1305_internal_test
|
||||
ENDIF
|
||||
@@ -453,59 +459,71 @@ IF[{- !$disabled{tests} -}]
|
||||
PROGRAMS{noinst}=sm4_internal_test
|
||||
ENDIF
|
||||
IF[{- !$disabled{ec} -}]
|
||||
PROGRAMS{noinst}=curve448_internal_test
|
||||
PROGRAMS{noinst}=ec_internal_test curve448_internal_test
|
||||
ENDIF
|
||||
|
||||
SOURCE[poly1305_internal_test]=poly1305_internal_test.c
|
||||
INCLUDE[poly1305_internal_test]=.. ../include ../crypto/include
|
||||
INCLUDE[poly1305_internal_test]=.. ../include ../apps/include ../crypto/include
|
||||
DEPEND[poly1305_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[chacha_internal_test]=chacha_internal_test.c
|
||||
INCLUDE[chacha_internal_test]=.. ../include ../crypto/include
|
||||
INCLUDE[chacha_internal_test]=.. ../include ../apps/include ../crypto/include
|
||||
DEPEND[chacha_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[asn1_internal_test]=asn1_internal_test.c
|
||||
INCLUDE[asn1_internal_test]=.. ../include ../crypto/include
|
||||
INCLUDE[asn1_internal_test]=.. ../include ../apps/include ../crypto/include
|
||||
DEPEND[asn1_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[modes_internal_test]=modes_internal_test.c
|
||||
INCLUDE[modes_internal_test]=.. ../include
|
||||
INCLUDE[modes_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[modes_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[x509_internal_test]=x509_internal_test.c
|
||||
INCLUDE[x509_internal_test]=.. ../include
|
||||
INCLUDE[x509_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[x509_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[tls13encryptiontest]=tls13encryptiontest.c
|
||||
INCLUDE[tls13encryptiontest]=.. ../include
|
||||
INCLUDE[tls13encryptiontest]=.. ../include ../apps/include
|
||||
DEPEND[tls13encryptiontest]=../libcrypto ../libssl.a libtestutil.a
|
||||
|
||||
SOURCE[wpackettest]=wpackettest.c
|
||||
INCLUDE[wpackettest]=../include
|
||||
INCLUDE[wpackettest]=../include ../apps/include
|
||||
DEPEND[wpackettest]=../libcrypto ../libssl.a libtestutil.a
|
||||
|
||||
SOURCE[property_test]=property_test.c
|
||||
INCLUDE[property_test]=../include ../apps/include
|
||||
DEPEND[property_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[ctype_internal_test]=ctype_internal_test.c
|
||||
INCLUDE[ctype_internal_test]=.. ../crypto/include ../include
|
||||
INCLUDE[ctype_internal_test]=.. ../crypto/include ../include ../apps/include
|
||||
DEPEND[ctype_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[sparse_array_test]=sparse_array_test.c
|
||||
INCLUDE[sparse_array_test]=../crypto/include ../include ../apps/include
|
||||
DEPEND[sparse_array_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[siphash_internal_test]=siphash_internal_test.c
|
||||
INCLUDE[siphash_internal_test]=.. ../include ../crypto/include
|
||||
INCLUDE[siphash_internal_test]=.. ../include ../apps/include ../crypto/include
|
||||
DEPEND[siphash_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[sm2_internal_test]=sm2_internal_test.c
|
||||
INCLUDE[sm2_internal_test]=../include ../crypto/include
|
||||
INCLUDE[sm2_internal_test]=../include ../apps/include ../crypto/include
|
||||
DEPEND[sm2_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[sm4_internal_test]=sm4_internal_test.c
|
||||
INCLUDE[sm4_internal_test]=.. ../include ../crypto/include
|
||||
INCLUDE[sm4_internal_test]=.. ../include ../apps/include ../crypto/include
|
||||
DEPEND[sm4_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[ec_internal_test]=ec_internal_test.c
|
||||
INCLUDE[ec_internal_test]=../include ../crypto/ec ../apps/include ../crypto/include
|
||||
DEPEND[ec_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[curve448_internal_test]=curve448_internal_test.c
|
||||
INCLUDE[curve448_internal_test]=.. ../include ../crypto/ec/curve448
|
||||
INCLUDE[curve448_internal_test]=.. ../include ../apps/include ../crypto/ec/curve448
|
||||
DEPEND[curve448_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[rdrand_sanitytest]=rdrand_sanitytest.c
|
||||
INCLUDE[rdrand_sanitytest]=../include
|
||||
INCLUDE[rdrand_sanitytest]=../include ../apps/include
|
||||
DEPEND[rdrand_sanitytest]=../libcrypto.a libtestutil.a
|
||||
ENDIF
|
||||
|
||||
@@ -514,12 +532,12 @@ IF[{- !$disabled{tests} -}]
|
||||
ENDIF
|
||||
|
||||
SOURCE[mdc2_internal_test]=mdc2_internal_test.c
|
||||
INCLUDE[mdc2_internal_test]=.. ../include
|
||||
INCLUDE[mdc2_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[mdc2_internal_test]=../libcrypto libtestutil.a
|
||||
|
||||
PROGRAMS{noinst}=asn1_time_test
|
||||
SOURCE[asn1_time_test]=asn1_time_test.c
|
||||
INCLUDE[asn1_time_test]=../include
|
||||
INCLUDE[asn1_time_test]=../include ../apps/include
|
||||
DEPEND[asn1_time_test]=../libcrypto libtestutil.a
|
||||
|
||||
# We disable this test completely in a shared build because it deliberately
|
||||
@@ -529,25 +547,30 @@ IF[{- !$disabled{tests} -}]
|
||||
PROGRAMS{noinst}=tls13secretstest
|
||||
SOURCE[tls13secretstest]=tls13secretstest.c
|
||||
SOURCE[tls13secretstest]= ../ssl/tls13_enc.c ../ssl/packet.c
|
||||
INCLUDE[tls13secretstest]=.. ../include
|
||||
INCLUDE[tls13secretstest]=.. ../include ../apps/include
|
||||
DEPEND[tls13secretstest]=../libcrypto ../libssl libtestutil.a
|
||||
ENDIF
|
||||
|
||||
SOURCE[sslbuffertest]=sslbuffertest.c ssltestlib.c
|
||||
INCLUDE[sslbuffertest]=../include
|
||||
INCLUDE[sslbuffertest]=../include ../apps/include
|
||||
DEPEND[sslbuffertest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[sysdefaulttest]=sysdefaulttest.c
|
||||
INCLUDE[sysdefaulttest]=../include
|
||||
INCLUDE[sysdefaulttest]=../include ../apps/include
|
||||
DEPEND[sysdefaulttest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[errtest]=errtest.c
|
||||
INCLUDE[errtest]=../include
|
||||
INCLUDE[errtest]=../include ../apps/include
|
||||
DEPEND[errtest]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[gosttest]=gosttest.c ssltestlib.c
|
||||
INCLUDE[gosttest]=../include ..
|
||||
INCLUDE[gosttest]=../include ../apps/include ..
|
||||
DEPEND[gosttest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
PROGRAMS{noinst}=context_internal_test
|
||||
SOURCE[context_internal_test]=context_internal_test.c
|
||||
INCLUDE[context_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[context_internal_test]=../libcrypto.a libtestutil.a
|
||||
ENDIF
|
||||
|
||||
{-
|
||||
|
||||
@@ -215,9 +215,44 @@ static int test_default_cipherlist_explicit(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* SSL_CTX_set_cipher_list() should fail if it clears all TLSv1.2 ciphers. */
|
||||
static int test_default_cipherlist_clear(void)
|
||||
{
|
||||
SETUP_CIPHERLIST_TEST_FIXTURE();
|
||||
SSL *s = NULL;
|
||||
|
||||
if (fixture == NULL)
|
||||
return 0;
|
||||
|
||||
if (!TEST_int_eq(SSL_CTX_set_cipher_list(fixture->server, "no-such"), 0))
|
||||
goto end;
|
||||
|
||||
if (!TEST_int_eq(ERR_GET_REASON(ERR_get_error()), SSL_R_NO_CIPHER_MATCH))
|
||||
goto end;
|
||||
|
||||
s = SSL_new(fixture->client);
|
||||
|
||||
if (!TEST_ptr(s))
|
||||
goto end;
|
||||
|
||||
if (!TEST_int_eq(SSL_set_cipher_list(s, "no-such"), 0))
|
||||
goto end;
|
||||
|
||||
if (!TEST_int_eq(ERR_GET_REASON(ERR_get_error()),
|
||||
SSL_R_NO_CIPHER_MATCH))
|
||||
goto end;
|
||||
|
||||
result = 1;
|
||||
end:
|
||||
SSL_free(s);
|
||||
tear_down(fixture);
|
||||
return result;
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_default_cipherlist_implicit);
|
||||
ADD_TEST(test_default_cipherlist_explicit);
|
||||
ADD_TEST(test_default_cipherlist_clear);
|
||||
return 1;
|
||||
}
|
||||
@@ -99,8 +99,9 @@ static int test_client_hello(int currtest)
|
||||
* ClientHello is already going to be quite long. To avoid getting one
|
||||
* that is too long for this test we use a restricted ciphersuite list
|
||||
*/
|
||||
if (!TEST_true(SSL_CTX_set_cipher_list(ctx, "")))
|
||||
if (!TEST_false(SSL_CTX_set_cipher_list(ctx, "")))
|
||||
goto end;
|
||||
ERR_clear_error();
|
||||
/* Fall through */
|
||||
case TEST_ADD_PADDING:
|
||||
case TEST_PADDING_NOT_NEEDED:
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* Internal tests for the OpenSSL library context */
|
||||
|
||||
#include "internal/cryptlib.h"
|
||||
#include "testutil.h"
|
||||
|
||||
/*
|
||||
* Everything between BEGIN EXAMPLE and END EXAMPLE is copied from
|
||||
* doc/internal/man3/openssl_ctx_get_data.pod
|
||||
*/
|
||||
|
||||
/*
|
||||
* ======================================================================
|
||||
* BEGIN EXAMPLE
|
||||
*/
|
||||
|
||||
/* The index will always be entirely global, and dynamically allocated */
|
||||
static int foo_index = -1;
|
||||
|
||||
typedef struct foo_st {
|
||||
int i;
|
||||
void *data;
|
||||
} FOO;
|
||||
|
||||
static void *foo_new(void)
|
||||
{
|
||||
FOO *ptr = OPENSSL_zalloc(sizeof(*ptr));
|
||||
if (ptr != NULL)
|
||||
ptr->i = 42;
|
||||
return ptr;
|
||||
}
|
||||
static void foo_free(void *ptr)
|
||||
{
|
||||
OPENSSL_free(ptr);
|
||||
}
|
||||
static const OPENSSL_CTX_METHOD foo_method = {
|
||||
foo_new,
|
||||
foo_free
|
||||
};
|
||||
|
||||
static int foo_init(void)
|
||||
{
|
||||
if (foo_index == -1)
|
||||
foo_index = openssl_ctx_new_index(&foo_method);
|
||||
|
||||
return foo_index != -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* END EXAMPLE
|
||||
* ======================================================================
|
||||
*/
|
||||
|
||||
static int test_context(OPENSSL_CTX *ctx)
|
||||
{
|
||||
FOO *data = NULL;
|
||||
|
||||
return
|
||||
TEST_true(foo_init())
|
||||
&& TEST_ptr(data = openssl_ctx_get_data(ctx, foo_index))
|
||||
/* OPENSSL_zalloc in foo_new() initialized it to zero */
|
||||
&& TEST_int_eq(data->i, 42);
|
||||
}
|
||||
|
||||
static int test_app_context(void)
|
||||
{
|
||||
OPENSSL_CTX *ctx = NULL;
|
||||
int result =
|
||||
TEST_true(foo_init())
|
||||
&& TEST_ptr(ctx = OPENSSL_CTX_new())
|
||||
&& test_context(ctx);
|
||||
|
||||
OPENSSL_CTX_free(ctx);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_def_context(void)
|
||||
{
|
||||
return test_context(NULL);
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_app_context);
|
||||
ADD_TEST(test_def_context);
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* 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/nelem.h"
|
||||
#include "testutil.h"
|
||||
#include <openssl/ec.h>
|
||||
#include "ec_lcl.h"
|
||||
#include <openssl/objects.h>
|
||||
|
||||
static size_t crv_len = 0;
|
||||
static EC_builtin_curve *curves = NULL;
|
||||
|
||||
/* sanity checks field_inv function pointer in EC_METHOD */
|
||||
static int group_field_tests(const EC_GROUP *group, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *a = NULL, *b = NULL, *c = NULL;
|
||||
int ret = 0;
|
||||
|
||||
if (group->meth->field_inv == NULL || group->meth->field_mul == NULL)
|
||||
return 1;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
a = BN_CTX_get(ctx);
|
||||
b = BN_CTX_get(ctx);
|
||||
if (!TEST_ptr(c = BN_CTX_get(ctx))
|
||||
/* 1/1 = 1 */
|
||||
|| !TEST_true(group->meth->field_inv(group, b, BN_value_one(), ctx))
|
||||
|| !TEST_true(BN_is_one(b))
|
||||
/* (1/a)*a = 1 */
|
||||
|| !TEST_true(BN_pseudo_rand(a, BN_num_bits(group->field) - 1,
|
||||
BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))
|
||||
|| !TEST_true(group->meth->field_inv(group, b, a, ctx))
|
||||
|| (group->meth->field_encode &&
|
||||
!TEST_true(group->meth->field_encode(group, a, a, ctx)))
|
||||
|| (group->meth->field_encode &&
|
||||
!TEST_true(group->meth->field_encode(group, b, b, ctx)))
|
||||
|| !TEST_true(group->meth->field_mul(group, c, a, b, ctx))
|
||||
|| (group->meth->field_decode &&
|
||||
!TEST_true(group->meth->field_decode(group, c, c, ctx)))
|
||||
|| !TEST_true(BN_is_one(c)))
|
||||
goto err;
|
||||
|
||||
/* 1/0 = error */
|
||||
BN_zero(a);
|
||||
if (!TEST_false(group->meth->field_inv(group, b, a, ctx))
|
||||
|| !TEST_true(ERR_GET_LIB(ERR_peek_last_error()) == ERR_LIB_EC)
|
||||
|| !TEST_true(ERR_GET_REASON(ERR_peek_last_error()) ==
|
||||
EC_R_CANNOT_INVERT)
|
||||
/* 1/p = error */
|
||||
|| !TEST_false(group->meth->field_inv(group, b, group->field, ctx))
|
||||
|| !TEST_true(ERR_GET_LIB(ERR_peek_last_error()) == ERR_LIB_EC)
|
||||
|| !TEST_true(ERR_GET_REASON(ERR_peek_last_error()) ==
|
||||
EC_R_CANNOT_INVERT))
|
||||
goto err;
|
||||
|
||||
ERR_clear_error();
|
||||
ret = 1;
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* wrapper for group_field_tests for explicit curve params and EC_METHOD */
|
||||
static int field_tests(const EC_METHOD *meth, const unsigned char *params,
|
||||
int len)
|
||||
{
|
||||
BN_CTX *ctx = NULL;
|
||||
BIGNUM *p = NULL, *a = NULL, *b = NULL;
|
||||
EC_GROUP *group = NULL;
|
||||
int ret = 0;
|
||||
|
||||
if (!TEST_ptr(ctx = BN_CTX_new()))
|
||||
return 0;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
p = BN_CTX_get(ctx);
|
||||
a = BN_CTX_get(ctx);
|
||||
if (!TEST_ptr(b = BN_CTX_get(ctx))
|
||||
|| !TEST_ptr(group = EC_GROUP_new(meth))
|
||||
|| !TEST_true(BN_bin2bn(params, len, p))
|
||||
|| !TEST_true(BN_bin2bn(params + len, len, a))
|
||||
|| !TEST_true(BN_bin2bn(params + 2 * len, len, b))
|
||||
|| !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx))
|
||||
|| !group_field_tests(group, ctx))
|
||||
goto err;
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
if (group != NULL)
|
||||
EC_GROUP_free(group);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* NIST prime curve P-256 */
|
||||
static const unsigned char params_p256[] = {
|
||||
/* p */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/* a */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC,
|
||||
/* b */
|
||||
0x5A, 0xC6, 0x35, 0xD8, 0xAA, 0x3A, 0x93, 0xE7, 0xB3, 0xEB, 0xBD, 0x55,
|
||||
0x76, 0x98, 0x86, 0xBC, 0x65, 0x1D, 0x06, 0xB0, 0xCC, 0x53, 0xB0, 0xF6,
|
||||
0x3B, 0xCE, 0x3C, 0x3E, 0x27, 0xD2, 0x60, 0x4B
|
||||
};
|
||||
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
/* NIST binary curve B-283 */
|
||||
static const unsigned char params_b283[] = {
|
||||
/* p */
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xA1,
|
||||
/* a */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
/* b */
|
||||
0x02, 0x7B, 0x68, 0x0A, 0xC8, 0xB8, 0x59, 0x6D, 0xA5, 0xA4, 0xAF, 0x8A,
|
||||
0x19, 0xA0, 0x30, 0x3F, 0xCA, 0x97, 0xFD, 0x76, 0x45, 0x30, 0x9F, 0xA2,
|
||||
0xA5, 0x81, 0x48, 0x5A, 0xF6, 0x26, 0x3E, 0x31, 0x3B, 0x79, 0xA2, 0xF5
|
||||
};
|
||||
#endif
|
||||
|
||||
/* test EC_GFp_simple_method directly */
|
||||
static int field_tests_ecp_simple(void)
|
||||
{
|
||||
TEST_info("Testing EC_GFp_simple_method()\n");
|
||||
return field_tests(EC_GFp_simple_method(), params_p256,
|
||||
sizeof(params_p256) / 3);
|
||||
}
|
||||
|
||||
/* test EC_GFp_mont_method directly */
|
||||
static int field_tests_ecp_mont(void)
|
||||
{
|
||||
TEST_info("Testing EC_GFp_mont_method()\n");
|
||||
return field_tests(EC_GFp_mont_method(), params_p256,
|
||||
sizeof(params_p256) / 3);
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
/* test EC_GF2m_simple_method directly */
|
||||
static int field_tests_ec2_simple(void)
|
||||
{
|
||||
TEST_info("Testing EC_GF2m_simple_method()\n");
|
||||
return field_tests(EC_GF2m_simple_method(), params_b283,
|
||||
sizeof(params_b283) / 3);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* test default method for a named curve */
|
||||
static int field_tests_default(int n)
|
||||
{
|
||||
BN_CTX *ctx = NULL;
|
||||
EC_GROUP *group = NULL;
|
||||
int nid = curves[n].nid;
|
||||
int ret = 0;
|
||||
|
||||
TEST_info("Testing curve %s\n", OBJ_nid2sn(nid));
|
||||
|
||||
if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(nid))
|
||||
|| !TEST_ptr(ctx = BN_CTX_new())
|
||||
|| !group_field_tests(group, ctx))
|
||||
goto err;
|
||||
|
||||
ret = 1;
|
||||
err:
|
||||
if (group != NULL)
|
||||
EC_GROUP_free(group);
|
||||
if (ctx != NULL)
|
||||
BN_CTX_free(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
crv_len = EC_get_builtin_curves(NULL, 0);
|
||||
if (!TEST_ptr(curves = OPENSSL_malloc(sizeof(*curves) * crv_len))
|
||||
|| !TEST_true(EC_get_builtin_curves(curves, crv_len)))
|
||||
return 0;
|
||||
|
||||
ADD_TEST(field_tests_ecp_simple);
|
||||
ADD_TEST(field_tests_ecp_mont);
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
ADD_TEST(field_tests_ec2_simple);
|
||||
#endif
|
||||
ADD_ALL_TESTS(field_tests_default, crv_len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
OPENSSL_free(curves);
|
||||
}
|
||||
+3
-3
@@ -223,7 +223,7 @@ static int test_builtin(void)
|
||||
const BIGNUM *sig_r, *sig_s;
|
||||
BIGNUM *modified_r = NULL, *modified_s = NULL;
|
||||
BIGNUM *unmodified_r = NULL, *unmodified_s = NULL;
|
||||
unsigned int sig_len, degree, r_len, s_len, bn_len, buf_len;
|
||||
unsigned int sig_len, order, r_len, s_len, bn_len, buf_len;
|
||||
int nid, ret = 0;
|
||||
|
||||
/* fill digest values with some random data */
|
||||
@@ -251,7 +251,7 @@ static int test_builtin(void)
|
||||
|| !TEST_true(EC_KEY_set_group(eckey, group)))
|
||||
goto builtin_err;
|
||||
EC_GROUP_free(group);
|
||||
degree = EC_GROUP_get_degree(EC_KEY_get0_group(eckey));
|
||||
order = EC_GROUP_order_bits(EC_KEY_get0_group(eckey));
|
||||
|
||||
TEST_info("testing %s", OBJ_nid2sn(nid));
|
||||
|
||||
@@ -316,7 +316,7 @@ static int test_builtin(void)
|
||||
/* Store the two BIGNUMs in raw_buf. */
|
||||
r_len = BN_num_bytes(sig_r);
|
||||
s_len = BN_num_bytes(sig_s);
|
||||
bn_len = (degree + 7) / 8;
|
||||
bn_len = (order + 7) / 8;
|
||||
if (!TEST_false(r_len > bn_len)
|
||||
|| !TEST_false(s_len > bn_len))
|
||||
goto builtin_err;
|
||||
|
||||
@@ -1159,6 +1159,43 @@ static int internal_curve_test_method(int n)
|
||||
return r;
|
||||
}
|
||||
|
||||
static int group_field_test(void)
|
||||
{
|
||||
int r = 1;
|
||||
BIGNUM *secp521r1_field = NULL;
|
||||
BIGNUM *sect163r2_field = NULL;
|
||||
EC_GROUP *secp521r1_group = NULL;
|
||||
EC_GROUP *sect163r2_group = NULL;
|
||||
|
||||
BN_hex2bn(&secp521r1_field,
|
||||
"01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||
"FFFF");
|
||||
|
||||
|
||||
BN_hex2bn(§163r2_field,
|
||||
"08000000000000000000000000000000"
|
||||
"00000000C9");
|
||||
|
||||
secp521r1_group = EC_GROUP_new_by_curve_name(NID_secp521r1);
|
||||
if (BN_cmp(secp521r1_field, EC_GROUP_get0_field(secp521r1_group)))
|
||||
r = 0;
|
||||
|
||||
# ifndef OPENSSL_NO_EC2M
|
||||
sect163r2_group = EC_GROUP_new_by_curve_name(NID_sect163r2);
|
||||
if (BN_cmp(sect163r2_field, EC_GROUP_get0_field(sect163r2_group)))
|
||||
r = 0;
|
||||
# endif
|
||||
|
||||
EC_GROUP_free(secp521r1_group);
|
||||
EC_GROUP_free(sect163r2_group);
|
||||
BN_free(secp521r1_field);
|
||||
BN_free(sect163r2_field);
|
||||
return r;
|
||||
}
|
||||
|
||||
# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
/*
|
||||
* nistp_test_params contains magic numbers for testing our optimized
|
||||
@@ -1513,6 +1550,7 @@ int setup_tests(void)
|
||||
# endif
|
||||
ADD_ALL_TESTS(internal_curve_test, crv_len);
|
||||
ADD_ALL_TESTS(internal_curve_test_method, crv_len);
|
||||
ADD_TEST(group_field_test);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2018-2019, Oracle and/or its affiliates. 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
|
||||
*/
|
||||
|
||||
/* Tests of the EVP_KDF_CTX APIs */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/kdf.h>
|
||||
#include "testutil.h"
|
||||
|
||||
static int test_kdf_tls1_prf(void)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_KDF_CTX *kctx;
|
||||
unsigned char out[16];
|
||||
|
||||
if ((kctx = EVP_KDF_CTX_new_id(EVP_KDF_TLS1_PRF)) == NULL) {
|
||||
TEST_error("EVP_KDF_TLS1_PRF");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_MD");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_TLS_SECRET,
|
||||
"secret", (size_t)6) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_TLS_SECRET");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_ADD_TLS_SEED, "seed", (size_t)4) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_ADD_TLS_SEED");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
|
||||
TEST_error("EVP_KDF_derive");
|
||||
goto err;
|
||||
}
|
||||
|
||||
{
|
||||
const unsigned char expected[sizeof(out)] = {
|
||||
0x8e, 0x4d, 0x93, 0x25, 0x30, 0xd7, 0x65, 0xa0,
|
||||
0xaa, 0xe9, 0x74, 0xc3, 0x04, 0x73, 0x5e, 0xcc
|
||||
};
|
||||
if (!TEST_mem_eq(out, sizeof(out), expected, sizeof(expected))) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
EVP_KDF_CTX_free(kctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_kdf_hkdf(void)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_KDF_CTX *kctx;
|
||||
unsigned char out[10];
|
||||
|
||||
if ((kctx = EVP_KDF_CTX_new_id(EVP_KDF_HKDF)) == NULL) {
|
||||
TEST_error("EVP_KDF_HKDF");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_MD");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, "salt", (size_t)4) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_SALT");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, "secret", (size_t)6) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_KEY");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_ADD_HKDF_INFO,
|
||||
"label", (size_t)5) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_ADD_HKDF_INFO");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
|
||||
TEST_error("EVP_KDF_derive");
|
||||
goto err;
|
||||
}
|
||||
|
||||
{
|
||||
const unsigned char expected[sizeof(out)] = {
|
||||
0x2a, 0xc4, 0x36, 0x9f, 0x52, 0x59, 0x96, 0xf8, 0xde, 0x13
|
||||
};
|
||||
if (!TEST_mem_eq(out, sizeof(out), expected, sizeof(expected))) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
EVP_KDF_CTX_free(kctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_kdf_pbkdf2(void)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_KDF_CTX *kctx;
|
||||
unsigned char out[32];
|
||||
|
||||
if ((kctx = EVP_KDF_CTX_new_id(EVP_KDF_PBKDF2)) == NULL) {
|
||||
TEST_error("EVP_KDF_PBKDF2");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PASS, "password", (size_t)8) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_PASS");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, "salt", (size_t)4) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_SALT");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_ITER, 2) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_ITER");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_MD");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
|
||||
TEST_error("EVP_KDF_derive");
|
||||
goto err;
|
||||
}
|
||||
|
||||
{
|
||||
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
|
||||
};
|
||||
if (!TEST_mem_eq(out, sizeof(out), expected, sizeof(expected))) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
EVP_KDF_CTX_free(kctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_SCRYPT
|
||||
static int test_kdf_scrypt(void)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_KDF_CTX *kctx;
|
||||
unsigned char out[64];
|
||||
|
||||
if ((kctx = EVP_KDF_CTX_new_id(EVP_KDF_SCRYPT)) == NULL) {
|
||||
TEST_error("EVP_KDF_SCRYPT");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PASS, "password", (size_t)8) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_PASS");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, "NaCl", (size_t)4) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_SALT");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SCRYPT_N, (uint64_t)1024) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_SCRYPT_N");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SCRYPT_R, (uint32_t)8) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_SCRYPT_R");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SCRYPT_P, (uint32_t)16) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_SCRYPT_P");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MAXMEM_BYTES, (uint64_t)16) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_MAXMEM_BYTES");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_derive(kctx, out, sizeof(out)) > 0) {
|
||||
TEST_error("EVP_KDF_derive should have failed");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MAXMEM_BYTES,
|
||||
(uint64_t)(10 * 1024 * 1024)) <= 0) {
|
||||
TEST_error("EVP_KDF_CTRL_SET_MAXMEM_BYTES");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
|
||||
TEST_error("EVP_KDF_derive");
|
||||
goto err;
|
||||
}
|
||||
|
||||
{
|
||||
const unsigned char expected[sizeof(out)] = {
|
||||
0xfd, 0xba, 0xbe, 0x1c, 0x9d, 0x34, 0x72, 0x00,
|
||||
0x78, 0x56, 0xe7, 0x19, 0x0d, 0x01, 0xe9, 0xfe,
|
||||
0x7c, 0x6a, 0xd7, 0xcb, 0xc8, 0x23, 0x78, 0x30,
|
||||
0xe7, 0x73, 0x76, 0x63, 0x4b, 0x37, 0x31, 0x62,
|
||||
0x2e, 0xaf, 0x30, 0xd9, 0x2e, 0x22, 0xa3, 0x88,
|
||||
0x6f, 0xf1, 0x09, 0x27, 0x9d, 0x98, 0x30, 0xda,
|
||||
0xc7, 0x27, 0xaf, 0xb9, 0x4a, 0x83, 0xee, 0x6d,
|
||||
0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06, 0x40
|
||||
};
|
||||
if (!TEST_mem_eq(out, sizeof(out), expected, sizeof(expected))) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
EVP_KDF_CTX_free(kctx);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_kdf_tls1_prf);
|
||||
ADD_TEST(test_kdf_hkdf);
|
||||
ADD_TEST(test_kdf_pbkdf2);
|
||||
#ifndef OPENSSL_NO_SCRYPT
|
||||
ADD_TEST(test_kdf_scrypt);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
+150
-18
@@ -1892,13 +1892,14 @@ static const EVP_TEST_METHOD encode_test_method = {
|
||||
encode_test_run,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*** KDF TESTS
|
||||
**/
|
||||
|
||||
typedef struct kdf_data_st {
|
||||
/* Context for this operation */
|
||||
EVP_PKEY_CTX *ctx;
|
||||
EVP_KDF_CTX *ctx;
|
||||
/* Expected output */
|
||||
unsigned char *output;
|
||||
size_t output_len;
|
||||
@@ -1913,6 +1914,137 @@ static int kdf_test_init(EVP_TEST *t, const char *name)
|
||||
KDF_DATA *kdata;
|
||||
int kdf_nid = OBJ_sn2nid(name);
|
||||
|
||||
#ifdef OPENSSL_NO_SCRYPT
|
||||
if (strcmp(name, "scrypt") == 0) {
|
||||
t->skip = 1;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (kdf_nid == NID_undef)
|
||||
kdf_nid = OBJ_ln2nid(name);
|
||||
|
||||
if (!TEST_ptr(kdata = OPENSSL_zalloc(sizeof(*kdata))))
|
||||
return 0;
|
||||
kdata->ctx = EVP_KDF_CTX_new_id(kdf_nid);
|
||||
if (kdata->ctx == NULL) {
|
||||
OPENSSL_free(kdata);
|
||||
return 0;
|
||||
}
|
||||
t->data = kdata;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void kdf_test_cleanup(EVP_TEST *t)
|
||||
{
|
||||
KDF_DATA *kdata = t->data;
|
||||
OPENSSL_free(kdata->output);
|
||||
EVP_KDF_CTX_free(kdata->ctx);
|
||||
}
|
||||
|
||||
static int kdf_test_ctrl(EVP_TEST *t, EVP_KDF_CTX *kctx,
|
||||
const char *value)
|
||||
{
|
||||
int rv;
|
||||
char *p, *tmpval;
|
||||
|
||||
if (!TEST_ptr(tmpval = OPENSSL_strdup(value)))
|
||||
return 0;
|
||||
p = strchr(tmpval, ':');
|
||||
if (p != NULL)
|
||||
*p++ = '\0';
|
||||
rv = EVP_KDF_ctrl_str(kctx, tmpval, p);
|
||||
if (rv == -2) {
|
||||
t->err = "KDF_CTRL_INVALID";
|
||||
rv = 1;
|
||||
} else if (p != NULL && rv <= 0) {
|
||||
/* If p has an OID and lookup fails assume disabled algorithm */
|
||||
int nid = OBJ_sn2nid(p);
|
||||
|
||||
if (nid == NID_undef)
|
||||
nid = OBJ_ln2nid(p);
|
||||
if (nid != NID_undef
|
||||
&& EVP_get_digestbynid(nid) == NULL
|
||||
&& EVP_get_cipherbynid(nid) == NULL) {
|
||||
t->skip = 1;
|
||||
rv = 1;
|
||||
} else {
|
||||
t->err = "KDF_CTRL_ERROR";
|
||||
rv = 1;
|
||||
}
|
||||
}
|
||||
OPENSSL_free(tmpval);
|
||||
return rv > 0;
|
||||
}
|
||||
|
||||
static int kdf_test_parse(EVP_TEST *t,
|
||||
const char *keyword, const char *value)
|
||||
{
|
||||
KDF_DATA *kdata = t->data;
|
||||
|
||||
if (strcmp(keyword, "Output") == 0)
|
||||
return parse_bin(value, &kdata->output, &kdata->output_len);
|
||||
if (strncmp(keyword, "Ctrl", 4) == 0)
|
||||
return kdf_test_ctrl(t, kdata->ctx, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int kdf_test_run(EVP_TEST *t)
|
||||
{
|
||||
KDF_DATA *expected = t->data;
|
||||
unsigned char *got = NULL;
|
||||
size_t got_len = expected->output_len;
|
||||
|
||||
if (!TEST_ptr(got = OPENSSL_malloc(got_len))) {
|
||||
t->err = "INTERNAL_ERROR";
|
||||
goto err;
|
||||
}
|
||||
if (EVP_KDF_derive(expected->ctx, got, got_len) <= 0) {
|
||||
t->err = "KDF_DERIVE_ERROR";
|
||||
goto err;
|
||||
}
|
||||
if (!memory_err_compare(t, "KDF_MISMATCH",
|
||||
expected->output, expected->output_len,
|
||||
got, got_len))
|
||||
goto err;
|
||||
|
||||
t->err = NULL;
|
||||
|
||||
err:
|
||||
OPENSSL_free(got);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const EVP_TEST_METHOD kdf_test_method = {
|
||||
"KDF",
|
||||
kdf_test_init,
|
||||
kdf_test_cleanup,
|
||||
kdf_test_parse,
|
||||
kdf_test_run
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*** PKEY KDF TESTS
|
||||
**/
|
||||
|
||||
typedef struct pkey_kdf_data_st {
|
||||
/* Context for this operation */
|
||||
EVP_PKEY_CTX *ctx;
|
||||
/* Expected output */
|
||||
unsigned char *output;
|
||||
size_t output_len;
|
||||
} PKEY_KDF_DATA;
|
||||
|
||||
/*
|
||||
* Perform public key operation setup: lookup key, allocated ctx and call
|
||||
* the appropriate initialisation function
|
||||
*/
|
||||
static int pkey_kdf_test_init(EVP_TEST *t, const char *name)
|
||||
{
|
||||
PKEY_KDF_DATA *kdata;
|
||||
int kdf_nid = OBJ_sn2nid(name);
|
||||
|
||||
#ifdef OPENSSL_NO_SCRYPT
|
||||
if (strcmp(name, "scrypt") == 0) {
|
||||
t->skip = 1;
|
||||
@@ -1939,17 +2071,17 @@ static int kdf_test_init(EVP_TEST *t, const char *name)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void kdf_test_cleanup(EVP_TEST *t)
|
||||
static void pkey_kdf_test_cleanup(EVP_TEST *t)
|
||||
{
|
||||
KDF_DATA *kdata = t->data;
|
||||
PKEY_KDF_DATA *kdata = t->data;
|
||||
OPENSSL_free(kdata->output);
|
||||
EVP_PKEY_CTX_free(kdata->ctx);
|
||||
}
|
||||
|
||||
static int kdf_test_parse(EVP_TEST *t,
|
||||
const char *keyword, const char *value)
|
||||
static int pkey_kdf_test_parse(EVP_TEST *t,
|
||||
const char *keyword, const char *value)
|
||||
{
|
||||
KDF_DATA *kdata = t->data;
|
||||
PKEY_KDF_DATA *kdata = t->data;
|
||||
|
||||
if (strcmp(keyword, "Output") == 0)
|
||||
return parse_bin(value, &kdata->output, &kdata->output_len);
|
||||
@@ -1958,9 +2090,9 @@ static int kdf_test_parse(EVP_TEST *t,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int kdf_test_run(EVP_TEST *t)
|
||||
static int pkey_kdf_test_run(EVP_TEST *t)
|
||||
{
|
||||
KDF_DATA *expected = t->data;
|
||||
PKEY_KDF_DATA *expected = t->data;
|
||||
unsigned char *got = NULL;
|
||||
size_t got_len = expected->output_len;
|
||||
|
||||
@@ -1972,11 +2104,10 @@ static int kdf_test_run(EVP_TEST *t)
|
||||
t->err = "KDF_DERIVE_ERROR";
|
||||
goto err;
|
||||
}
|
||||
if (!memory_err_compare(t, "KDF_MISMATCH",
|
||||
expected->output, expected->output_len,
|
||||
got, got_len))
|
||||
if (!TEST_mem_eq(expected->output, expected->output_len, got, got_len)) {
|
||||
t->err = "KDF_MISMATCH";
|
||||
goto err;
|
||||
|
||||
}
|
||||
t->err = NULL;
|
||||
|
||||
err:
|
||||
@@ -1984,12 +2115,12 @@ static int kdf_test_run(EVP_TEST *t)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const EVP_TEST_METHOD kdf_test_method = {
|
||||
"KDF",
|
||||
kdf_test_init,
|
||||
kdf_test_cleanup,
|
||||
kdf_test_parse,
|
||||
kdf_test_run
|
||||
static const EVP_TEST_METHOD pkey_kdf_test_method = {
|
||||
"PKEYKDF",
|
||||
pkey_kdf_test_init,
|
||||
pkey_kdf_test_cleanup,
|
||||
pkey_kdf_test_parse,
|
||||
pkey_kdf_test_run
|
||||
};
|
||||
|
||||
|
||||
@@ -2497,6 +2628,7 @@ static const EVP_TEST_METHOD *evp_test_list[] = {
|
||||
&digestverify_test_method,
|
||||
&encode_test_method,
|
||||
&kdf_test_method,
|
||||
&pkey_kdf_test_method,
|
||||
&keypair_test_method,
|
||||
&keygen_test_method,
|
||||
&mac_test_method,
|
||||
|
||||
+57
-11
@@ -18,6 +18,7 @@ static long saved_argl;
|
||||
static void *saved_argp;
|
||||
static int saved_idx;
|
||||
static int saved_idx2;
|
||||
static int saved_idx3;
|
||||
static int gbl_result;
|
||||
|
||||
/*
|
||||
@@ -71,12 +72,13 @@ static void exnew2(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp)
|
||||
{
|
||||
MYOBJ_EX_DATA *ex_data = OPENSSL_zalloc(sizeof(*ex_data));
|
||||
if (!TEST_int_eq(idx, saved_idx2)
|
||||
|
||||
if (!TEST_true(idx == saved_idx2 || idx == saved_idx3)
|
||||
|| !TEST_long_eq(argl, saved_argl)
|
||||
|| !TEST_ptr_eq(argp, saved_argp)
|
||||
|| !TEST_ptr_null(ptr)
|
||||
|| !TEST_ptr(ex_data)
|
||||
|| !TEST_true(CRYPTO_set_ex_data(ad, saved_idx2, ex_data))) {
|
||||
|| !TEST_true(CRYPTO_set_ex_data(ad, idx, ex_data))) {
|
||||
gbl_result = 0;
|
||||
OPENSSL_free(ex_data);
|
||||
} else {
|
||||
@@ -88,13 +90,14 @@ static int exdup2(CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from,
|
||||
void *from_d, int idx, long argl, void *argp)
|
||||
{
|
||||
MYOBJ_EX_DATA **update_ex_data = (MYOBJ_EX_DATA**)from_d;
|
||||
MYOBJ_EX_DATA *ex_data = CRYPTO_get_ex_data(to, saved_idx2);
|
||||
if (!TEST_int_eq(idx, saved_idx2)
|
||||
MYOBJ_EX_DATA *ex_data = NULL;
|
||||
|
||||
if (!TEST_true(idx == saved_idx2 || idx == saved_idx3)
|
||||
|| !TEST_long_eq(argl, saved_argl)
|
||||
|| !TEST_ptr_eq(argp, saved_argp)
|
||||
|| !TEST_ptr(from_d)
|
||||
|| !TEST_ptr(*update_ex_data)
|
||||
|| !TEST_ptr(ex_data)
|
||||
|| !TEST_ptr(ex_data = CRYPTO_get_ex_data(to, idx))
|
||||
|| !TEST_true(ex_data->new)) {
|
||||
gbl_result = 0;
|
||||
} else {
|
||||
@@ -111,14 +114,14 @@ static int exdup2(CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from,
|
||||
static void exfree2(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp)
|
||||
{
|
||||
MYOBJ_EX_DATA *ex_data = CRYPTO_get_ex_data(ad, saved_idx2);
|
||||
OPENSSL_free(ex_data);
|
||||
if (!TEST_int_eq(idx, saved_idx2)
|
||||
MYOBJ_EX_DATA *ex_data = CRYPTO_get_ex_data(ad, idx);
|
||||
|
||||
if (!TEST_true(idx == saved_idx2 || idx == saved_idx3)
|
||||
|| !TEST_long_eq(argl, saved_argl)
|
||||
|| !TEST_ptr_eq(argp, saved_argp)
|
||||
|| !TEST_ptr(ex_data)
|
||||
|| !TEST_true(CRYPTO_set_ex_data(ad, saved_idx2, NULL)))
|
||||
|| !TEST_true(CRYPTO_set_ex_data(ad, idx, NULL)))
|
||||
gbl_result = 0;
|
||||
OPENSSL_free(ex_data);
|
||||
}
|
||||
|
||||
typedef struct myobj_st {
|
||||
@@ -152,6 +155,7 @@ static char *MYOBJ_gethello(MYOBJ *obj)
|
||||
static void MYOBJ_sethello2(MYOBJ *obj, char *cp)
|
||||
{
|
||||
MYOBJ_EX_DATA* ex_data = CRYPTO_get_ex_data(&obj->ex_data, saved_idx2);
|
||||
|
||||
if (TEST_ptr(ex_data))
|
||||
ex_data->hello = cp;
|
||||
else
|
||||
@@ -161,6 +165,31 @@ static void MYOBJ_sethello2(MYOBJ *obj, char *cp)
|
||||
static char *MYOBJ_gethello2(MYOBJ *obj)
|
||||
{
|
||||
MYOBJ_EX_DATA* ex_data = CRYPTO_get_ex_data(&obj->ex_data, saved_idx2);
|
||||
|
||||
if (TEST_ptr(ex_data))
|
||||
return ex_data->hello;
|
||||
|
||||
obj->st = gbl_result = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void MYOBJ_allochello3(MYOBJ *obj, char *cp)
|
||||
{
|
||||
MYOBJ_EX_DATA* ex_data = NULL;
|
||||
|
||||
if (TEST_ptr_null(ex_data = CRYPTO_get_ex_data(&obj->ex_data, saved_idx3))
|
||||
&& TEST_true(CRYPTO_alloc_ex_data(CRYPTO_EX_INDEX_APP, obj,
|
||||
&obj->ex_data, saved_idx3))
|
||||
&& TEST_ptr(ex_data = CRYPTO_get_ex_data(&obj->ex_data, saved_idx3)))
|
||||
ex_data->hello = cp;
|
||||
else
|
||||
obj->st = gbl_result = 0;
|
||||
}
|
||||
|
||||
static char *MYOBJ_gethello3(MYOBJ *obj)
|
||||
{
|
||||
MYOBJ_EX_DATA* ex_data = CRYPTO_get_ex_data(&obj->ex_data, saved_idx3);
|
||||
|
||||
if (TEST_ptr(ex_data))
|
||||
return ex_data->hello;
|
||||
|
||||
@@ -207,7 +236,15 @@ static int test_exdata(void)
|
||||
return 0;
|
||||
if (!TEST_ptr(CRYPTO_get_ex_data(&t1->ex_data, saved_idx2)))
|
||||
return 0;
|
||||
if (!TEST_ptr(CRYPTO_get_ex_data(&t2->ex_data, saved_idx2)))
|
||||
|
||||
/*
|
||||
* saved_idx3 differs from other indexes by being created after the exdata
|
||||
* was initialized.
|
||||
*/
|
||||
saved_idx3 = CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_APP,
|
||||
saved_argl, saved_argp,
|
||||
exnew2, exdup2, exfree2);
|
||||
if (!TEST_ptr_null(CRYPTO_get_ex_data(&t1->ex_data, saved_idx3)))
|
||||
return 0;
|
||||
|
||||
MYOBJ_sethello(t1, p);
|
||||
@@ -220,6 +257,11 @@ static int test_exdata(void)
|
||||
if (!TEST_ptr_eq(cp, p))
|
||||
return 0;
|
||||
|
||||
MYOBJ_allochello3(t1, p);
|
||||
cp = MYOBJ_gethello3(t1);
|
||||
if (!TEST_ptr_eq(cp, p))
|
||||
return 0;
|
||||
|
||||
cp = MYOBJ_gethello(t2);
|
||||
if (!TEST_ptr_null(cp))
|
||||
return 0;
|
||||
@@ -246,6 +288,10 @@ static int test_exdata(void)
|
||||
if (!TEST_ptr_eq(cp, p))
|
||||
return 0;
|
||||
|
||||
cp = MYOBJ_gethello3(t3);
|
||||
if (!TEST_ptr_eq(cp, p))
|
||||
return 0;
|
||||
|
||||
MYOBJ_free(t1);
|
||||
MYOBJ_free(t2);
|
||||
MYOBJ_free(t3);
|
||||
|
||||
+49
-31
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -18,30 +18,34 @@
|
||||
|
||||
static int test_kdf_tls1_prf(void)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_PKEY_CTX *pctx;
|
||||
unsigned char out[16];
|
||||
size_t outlen = sizeof(out);
|
||||
pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);
|
||||
|
||||
if ((pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL)) == NULL) {
|
||||
TEST_error("EVP_PKEY_TLS1_PRF");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_derive_init(pctx) <= 0) {
|
||||
TEST_error("EVP_PKEY_derive_init");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set_tls1_prf_md(pctx, EVP_sha256()) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set_tls1_prf_md");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, "secret", 6) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set1_tls1_prf_secret");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, "seed", 4) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_add1_tls1_prf_seed");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_derive(pctx, out, &outlen) <= 0) {
|
||||
TEST_error("EVP_PKEY_derive");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -50,43 +54,49 @@ static int test_kdf_tls1_prf(void)
|
||||
0xaa, 0xe9, 0x74, 0xc3, 0x04, 0x73, 0x5e, 0xcc
|
||||
};
|
||||
if (!TEST_mem_eq(out, sizeof(out), expected, sizeof(expected))) {
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
return 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_kdf_hkdf(void)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_PKEY_CTX *pctx;
|
||||
unsigned char out[10];
|
||||
size_t outlen = sizeof(out);
|
||||
pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL);
|
||||
|
||||
if ((pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL)) == NULL) {
|
||||
TEST_error("EVP_PKEY_HKDF");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_derive_init(pctx) <= 0) {
|
||||
TEST_error("EVP_PKEY_derive_init");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256()) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set_hkdf_md");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set1_hkdf_salt(pctx, "salt", 4) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set1_hkdf_salt");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set1_hkdf_key(pctx, "secret", 6) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set1_hkdf_key");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_add1_hkdf_info(pctx, "label", 5) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set1_hkdf_info");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_derive(pctx, out, &outlen) <= 0) {
|
||||
TEST_error("EVP_PKEY_derive");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -94,60 +104,66 @@ static int test_kdf_hkdf(void)
|
||||
0x2a, 0xc4, 0x36, 0x9f, 0x52, 0x59, 0x96, 0xf8, 0xde, 0x13
|
||||
};
|
||||
if (!TEST_mem_eq(out, sizeof(out), expected, sizeof(expected))) {
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
return 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_SCRYPT
|
||||
static int test_kdf_scrypt(void)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_PKEY_CTX *pctx;
|
||||
unsigned char out[64];
|
||||
size_t outlen = sizeof(out);
|
||||
pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_SCRYPT, NULL);
|
||||
|
||||
if ((pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_SCRYPT, NULL)) == NULL) {
|
||||
TEST_error("EVP_PKEY_SCRYPT");
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_derive_init(pctx) <= 0) {
|
||||
TEST_error("EVP_PKEY_derive_init");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set1_pbe_pass(pctx, "password", 8) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set1_pbe_pass");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set1_scrypt_salt(pctx, "NaCl", 4) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set1_scrypt_salt");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set_scrypt_N(pctx, 1024) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set_scrypt_N");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set_scrypt_r(pctx, 8) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set_scrypt_r");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set_scrypt_p(pctx, 16) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set_scrypt_p");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set_scrypt_maxmem_bytes(pctx, 16) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set_maxmem_bytes");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_derive(pctx, out, &outlen) > 0) {
|
||||
TEST_error("EVP_PKEY_derive should have failed");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set_scrypt_maxmem_bytes(pctx, 10 * 1024 * 1024) <= 0) {
|
||||
TEST_error("EVP_PKEY_CTX_set_maxmem_bytes");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_derive(pctx, out, &outlen) <= 0) {
|
||||
TEST_error("EVP_PKEY_derive");
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -162,11 +178,13 @@ static int test_kdf_scrypt(void)
|
||||
0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06, 0x40
|
||||
};
|
||||
if (!TEST_mem_eq(out, sizeof(out), expected, sizeof(expected))) {
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
return 1;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,374 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. 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 <stdarg.h>
|
||||
#include "testutil.h"
|
||||
#include "internal/nelem.h"
|
||||
#include "internal/property.h"
|
||||
#include "../crypto/property/property_lcl.h"
|
||||
|
||||
static int add_property_names(const char *n, ...)
|
||||
{
|
||||
va_list args;
|
||||
int res = 1;
|
||||
|
||||
va_start(args, n);
|
||||
do {
|
||||
if (!TEST_int_ne(ossl_property_name(n, 1), 0))
|
||||
res = 0;
|
||||
} while ((n = va_arg(args, const char *)) != NULL);
|
||||
va_end(args);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int test_property_string(void)
|
||||
{
|
||||
OSSL_METHOD_STORE *store;
|
||||
int res = 0;
|
||||
OSSL_PROPERTY_IDX i, j;
|
||||
|
||||
if (TEST_ptr(store = ossl_method_store_new())
|
||||
&& TEST_int_eq(ossl_property_name("fnord", 0), 0)
|
||||
&& TEST_int_ne(ossl_property_name("fnord", 1), 0)
|
||||
&& TEST_int_ne(ossl_property_name("name", 1), 0)
|
||||
/* Property value checks */
|
||||
&& TEST_int_eq(ossl_property_value("fnord", 0), 0)
|
||||
&& TEST_int_ne(i = ossl_property_value("no", 0), 0)
|
||||
&& TEST_int_ne(j = ossl_property_value("yes", 0), 0)
|
||||
&& TEST_int_ne(i, j)
|
||||
&& TEST_int_eq(ossl_property_value("yes", 1), j)
|
||||
&& TEST_int_eq(ossl_property_value("no", 1), i)
|
||||
&& TEST_int_ne(i = ossl_property_value("illuminati", 1), 0)
|
||||
&& TEST_int_eq(j = ossl_property_value("fnord", 1), i + 1)
|
||||
&& TEST_int_eq(ossl_property_value("fnord", 1), j)
|
||||
/* Check name and values are distinct */
|
||||
&& TEST_int_eq(ossl_property_value("cold", 0), 0)
|
||||
&& TEST_int_ne(ossl_property_name("fnord", 0),
|
||||
ossl_property_value("fnord", 0)))
|
||||
res = 1;
|
||||
ossl_method_store_free(store);
|
||||
return res;
|
||||
}
|
||||
|
||||
static const struct {
|
||||
const char *defn;
|
||||
const char *query;
|
||||
int e;
|
||||
} parser_tests[] = {
|
||||
{ "", "sky=blue", 0 },
|
||||
{ "", "sky!=blue", 1 },
|
||||
{ "groan", "", 1 },
|
||||
{ "cold=yes", "cold=yes", 1 },
|
||||
{ "cold=yes", "cold", 1 },
|
||||
{ "cold=yes", "cold!=no", 1 },
|
||||
{ "groan", "groan=yes", 1 },
|
||||
{ "groan", "groan=no", 0 },
|
||||
{ "groan", "groan!=yes", 0 },
|
||||
{ "cold=no", "cold", 0 },
|
||||
{ "cold=no", "cold=no", 1 },
|
||||
{ "groan", "cold", 0 },
|
||||
{ "groan", "cold=no", 1 },
|
||||
{ "groan", "cold!=yes", 1 },
|
||||
{ "groan=blue", "groan=yellow", 0 },
|
||||
{ "groan=blue", "groan!=yellow", 1 },
|
||||
{ "today=monday, tomorrow=3", "today!=2", 1 },
|
||||
{ "today=monday, tomorrow=3", "today!='monday'", 0 },
|
||||
{ "today=monday, tomorrow=3", "tomorrow=3", 1 },
|
||||
{ "n=0x3", "n=3", 1 },
|
||||
{ "n=0x3", "n=-3", 0 },
|
||||
{ "n=0x33", "n=51", 1 },
|
||||
{ "n=033", "n=27", 1 },
|
||||
{ "n=0", "n=00", 1 },
|
||||
{ "n=0x0", "n=0", 1 },
|
||||
};
|
||||
|
||||
static int test_property_parse(int n)
|
||||
{
|
||||
OSSL_METHOD_STORE *store;
|
||||
OSSL_PROPERTY_LIST *p = NULL, *q = NULL;
|
||||
int r = 0;
|
||||
|
||||
if (TEST_ptr(store = ossl_method_store_new())
|
||||
&& add_property_names("sky", "groan", "cold", "today", "tomorrow", "n",
|
||||
NULL)
|
||||
&& TEST_ptr(p = ossl_parse_property(parser_tests[n].defn))
|
||||
&& TEST_ptr(q = ossl_parse_query(parser_tests[n].query))
|
||||
&& TEST_int_eq(ossl_property_match(q, p), parser_tests[n].e))
|
||||
r = 1;
|
||||
ossl_property_free(p);
|
||||
ossl_property_free(q);
|
||||
ossl_method_store_free(store);
|
||||
return r;
|
||||
}
|
||||
|
||||
static const struct {
|
||||
const char *q_global;
|
||||
const char *q_local;
|
||||
const char *prop;
|
||||
} merge_tests[] = {
|
||||
{ "", "colour=blue", "colour=blue" },
|
||||
{ "colour=blue", "", "colour=blue" },
|
||||
{ "colour=red", "colour=blue", "colour=blue" },
|
||||
{ "clouds=pink, urn=red", "urn=blue, colour=green",
|
||||
"urn=blue, colour=green, clouds=pink" },
|
||||
{ "pot=gold", "urn=blue", "pot=gold, urn=blue" },
|
||||
{ "night", "day", "day=yes, night=yes" },
|
||||
{ "day", "night", "day=yes, night=yes" },
|
||||
{ "", "", "" },
|
||||
/*
|
||||
* The following four leave 'day' unspecified in the query, and will match
|
||||
* any definition
|
||||
*/
|
||||
{ "day=yes", "-day", "day=no" },
|
||||
{ "day=yes", "-day", "day=yes" },
|
||||
{ "day=yes", "-day", "day=arglebargle" },
|
||||
{ "day=yes", "-day", "pot=sesquioxidizing" },
|
||||
{ "day, night", "-night, day", "day=yes, night=no" },
|
||||
{ "-day", "day=yes", "day=yes" },
|
||||
};
|
||||
|
||||
static int test_property_merge(int n)
|
||||
{
|
||||
OSSL_METHOD_STORE *store;
|
||||
OSSL_PROPERTY_LIST *q_global = NULL, *q_local = NULL;
|
||||
OSSL_PROPERTY_LIST *q_combined = NULL, *prop = NULL;
|
||||
int r = 0;
|
||||
|
||||
if (TEST_ptr(store = ossl_method_store_new())
|
||||
&& add_property_names("colour", "urn", "clouds", "pot", "day", "night",
|
||||
NULL)
|
||||
&& TEST_ptr(prop = ossl_parse_property(merge_tests[n].prop))
|
||||
&& TEST_ptr(q_global = ossl_parse_query(merge_tests[n].q_global))
|
||||
&& TEST_ptr(q_local = ossl_parse_query(merge_tests[n].q_local))
|
||||
&& TEST_ptr(q_combined = ossl_property_merge(q_local, q_global))
|
||||
&& TEST_true(ossl_property_match(q_combined, prop)))
|
||||
r = 1;
|
||||
ossl_property_free(q_global);
|
||||
ossl_property_free(q_local);
|
||||
ossl_property_free(q_combined);
|
||||
ossl_property_free(prop);
|
||||
ossl_method_store_free(store);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int test_property_defn_cache(void)
|
||||
{
|
||||
OSSL_METHOD_STORE *store;
|
||||
OSSL_PROPERTY_LIST *red, *blue;
|
||||
int r = 0;
|
||||
|
||||
if (TEST_ptr(store = ossl_method_store_new())
|
||||
&& add_property_names("red", "blue", NULL)
|
||||
&& TEST_ptr(red = ossl_parse_property("red"))
|
||||
&& TEST_ptr(blue = ossl_parse_property("blue"))
|
||||
&& TEST_ptr_ne(red, blue)
|
||||
&& TEST_true(ossl_prop_defn_set("red", red))
|
||||
&& TEST_true(ossl_prop_defn_set("blue", blue))
|
||||
&& TEST_ptr_eq(ossl_prop_defn_get("red"), red)
|
||||
&& TEST_ptr_eq(ossl_prop_defn_get("blue"), blue))
|
||||
r = 1;
|
||||
ossl_method_store_free(store);
|
||||
return r;
|
||||
}
|
||||
|
||||
static const struct {
|
||||
const char *defn;
|
||||
const char *query;
|
||||
int e;
|
||||
} definition_tests[] = {
|
||||
{ "alpha", "alpha=yes", 1 },
|
||||
{ "alpha=no", "alpha", 0 },
|
||||
{ "alpha=1", "alpha=1", 1 },
|
||||
{ "alpha=2", "alpha=1", 0 },
|
||||
{ "alpha", "omega", 0 }
|
||||
};
|
||||
|
||||
static int test_definition_compares(int n)
|
||||
{
|
||||
OSSL_METHOD_STORE *store;
|
||||
OSSL_PROPERTY_LIST *d = NULL, *q = NULL;
|
||||
int r;
|
||||
|
||||
r = TEST_ptr(store = ossl_method_store_new())
|
||||
&& add_property_names("alpha", "omega", NULL)
|
||||
&& TEST_ptr(d = ossl_parse_property(definition_tests[n].defn))
|
||||
&& TEST_ptr(q = ossl_parse_query(definition_tests[n].query))
|
||||
&& TEST_int_eq(ossl_property_match(q, d), definition_tests[n].e);
|
||||
|
||||
ossl_property_free(d);
|
||||
ossl_property_free(q);
|
||||
ossl_method_store_free(store);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int test_register_deregister(void)
|
||||
{
|
||||
static const struct {
|
||||
int nid;
|
||||
const char *prop;
|
||||
char *impl;
|
||||
} impls[] = {
|
||||
{ 6, "position=1", "a" },
|
||||
{ 6, "position=2", "b" },
|
||||
{ 6, "position=3", "c" },
|
||||
{ 6, "position=4", "d" },
|
||||
};
|
||||
size_t i;
|
||||
int ret = 0;
|
||||
OSSL_METHOD_STORE *store;
|
||||
|
||||
if (!TEST_ptr(store = ossl_method_store_new())
|
||||
|| !add_property_names("position", NULL))
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < OSSL_NELEM(impls); i++)
|
||||
if (!TEST_true(ossl_method_store_add(store, impls[i].nid, impls[i].prop,
|
||||
impls[i].impl, NULL))) {
|
||||
TEST_note("iteration %zd", i + 1);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Deregister in a different order to registration */
|
||||
for (i = 0; i < OSSL_NELEM(impls); i++) {
|
||||
const size_t j = (1 + i * 3) % OSSL_NELEM(impls);
|
||||
int nid = impls[j].nid;
|
||||
void *impl = impls[j].impl;
|
||||
|
||||
if (!TEST_true(ossl_method_store_remove(store, nid, impl))
|
||||
|| !TEST_false(ossl_method_store_remove(store, nid, impl))) {
|
||||
TEST_note("iteration %zd, position %zd", i + 1, j + 1);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (TEST_false(ossl_method_store_remove(store, impls[0].nid, impls[0].impl)))
|
||||
ret = 1;
|
||||
err:
|
||||
ossl_method_store_free(store);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_property(void)
|
||||
{
|
||||
static const struct {
|
||||
int nid;
|
||||
const char *prop;
|
||||
char *impl;
|
||||
} impls[] = {
|
||||
{ 1, "fast=no, colour=green", "a" },
|
||||
{ 1, "fast, colour=blue", "b" },
|
||||
{ 1, "", "-" },
|
||||
{ 9, "sky=blue, furry", "c" },
|
||||
{ 3, NULL, "d" },
|
||||
{ 6, "sky.colour=blue, sky=green, old.data", "e" },
|
||||
};
|
||||
static struct {
|
||||
int nid;
|
||||
const char *prop;
|
||||
char *expected;
|
||||
} queries[] = {
|
||||
{ 1, "fast", "b" },
|
||||
{ 1, "fast=yes", "b" },
|
||||
{ 1, "fast=no, colour=green", "a" },
|
||||
{ 1, "colour=blue, fast", "b" },
|
||||
{ 1, "colour=blue", "b" },
|
||||
{ 9, "furry", "c" },
|
||||
{ 6, "sky.colour=blue", "e" },
|
||||
{ 6, "old.data", "e" },
|
||||
{ 9, "furry=yes, sky=blue", "c" },
|
||||
{ 1, "", "a" },
|
||||
{ 3, "", "d" },
|
||||
};
|
||||
OSSL_METHOD_STORE *store;
|
||||
size_t i;
|
||||
int ret = 0;
|
||||
void *result;
|
||||
|
||||
if (!TEST_ptr(store = ossl_method_store_new())
|
||||
|| !add_property_names("fast", "colour", "sky", "furry", NULL))
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < OSSL_NELEM(impls); i++)
|
||||
if (!TEST_true(ossl_method_store_add(store, impls[i].nid, impls[i].prop,
|
||||
impls[i].impl, NULL))) {
|
||||
TEST_note("iteration %zd", i + 1);
|
||||
goto err;
|
||||
}
|
||||
for (i = 0; i < OSSL_NELEM(queries); i++) {
|
||||
OSSL_PROPERTY_LIST *pq = NULL;
|
||||
|
||||
if (!TEST_true(ossl_property_read_lock(store))
|
||||
|| !TEST_true(ossl_method_store_fetch(store, queries[i].nid,
|
||||
queries[i].prop, &result))
|
||||
|| !TEST_true(ossl_property_unlock(store))
|
||||
|| !TEST_str_eq((char *)result, queries[i].expected)) {
|
||||
TEST_note("iteration %zd", i + 1);
|
||||
ossl_property_free(pq);
|
||||
goto err;
|
||||
}
|
||||
ossl_property_free(pq);
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
ossl_method_store_free(store);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_query_cache_stochastic(void)
|
||||
{
|
||||
const int max = 10000, tail = 10;
|
||||
OSSL_METHOD_STORE *store;
|
||||
int i, res = 0;
|
||||
char buf[50];
|
||||
void *result;
|
||||
int errors = 0;
|
||||
int v[10001];
|
||||
|
||||
if (!TEST_ptr(store = ossl_method_store_new())
|
||||
|| !add_property_names("n", NULL))
|
||||
goto err;
|
||||
|
||||
for (i = 1; i <= max; i++) {
|
||||
v[i] = 2 * i;
|
||||
BIO_snprintf(buf, sizeof(buf), "n=%d\n", i);
|
||||
if (!TEST_true(ossl_method_store_add(store, i, buf, "abc", NULL))
|
||||
|| !TEST_true(ossl_method_store_cache_set(store, i, buf, v + i))
|
||||
|| !TEST_true(ossl_method_store_cache_set(store, i, "n=1234",
|
||||
"miss"))) {
|
||||
TEST_note("iteration %d", i);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
for (i = 1; i <= max; i++) {
|
||||
BIO_snprintf(buf, sizeof(buf), "n=%d\n", i);
|
||||
if (!ossl_method_store_cache_get(store, i, buf, &result)
|
||||
|| result != v + i)
|
||||
errors++;
|
||||
}
|
||||
/* There is a tiny probability that this will fail when it shouldn't */
|
||||
res = TEST_int_gt(errors, tail) && TEST_int_lt(errors, max - tail);
|
||||
|
||||
err:
|
||||
ossl_method_store_free(store);
|
||||
return res;
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_property_string);
|
||||
ADD_ALL_TESTS(test_property_parse, OSSL_NELEM(parser_tests));
|
||||
ADD_ALL_TESTS(test_property_merge, OSSL_NELEM(merge_tests));
|
||||
ADD_TEST(test_property_defn_cache);
|
||||
ADD_ALL_TESTS(test_definition_compares, OSSL_NELEM(definition_tests));
|
||||
ADD_TEST(test_register_deregister);
|
||||
ADD_TEST(test_property);
|
||||
ADD_TEST(test_query_cache_stochastic);
|
||||
return 1;
|
||||
}
|
||||
@@ -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_context");
|
||||
|
||||
simple_test("test_internal_context", "context_internal_test");
|
||||
@@ -0,0 +1,12 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright (c) 2019, Oracle and/or its affiliates. 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 OpenSSL::Test::Simple;
|
||||
|
||||
simple_test("test_sparse_array", "sparse_array_test");
|
||||
@@ -0,0 +1,19 @@
|
||||
#! /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_ec");
|
||||
|
||||
plan skip_all => "This test is unsupported in a no-ec build"
|
||||
if disabled("ec");
|
||||
|
||||
simple_test("test_internal_ec", "ec_internal_test");
|
||||
@@ -0,0 +1,12 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright (c) 2019, Oracle and/or its affiliates. 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 OpenSSL::Test::Simple;
|
||||
|
||||
simple_test("test_property", "property_test");
|
||||
@@ -15,8 +15,8 @@ use OpenSSL::Test qw/:DEFAULT data_file/;
|
||||
setup("test_evp");
|
||||
|
||||
my @files = ( "evpciph.txt", "evpdigest.txt", "evpencod.txt", "evpkdf.txt",
|
||||
"evpmac.txt", "evppbe.txt", "evppkey.txt", "evppkey_ecc.txt",
|
||||
"evpcase.txt", "evpaessiv.txt" );
|
||||
"evppkey_kdf.txt", "evpmac.txt", "evppbe.txt", "evppkey.txt",
|
||||
"evppkey_ecc.txt", "evpcase.txt", "evpaessiv.txt" );
|
||||
|
||||
plan tests => scalar(@files);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2001-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2001-2018 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
|
||||
@@ -15,7 +15,7 @@
|
||||
Title = TLS1 PRF tests (from NIST test vectors)
|
||||
|
||||
KDF=TLS1-PRF
|
||||
Ctrl.md = md:MD5-SHA1
|
||||
Ctrl.digest = digest:MD5-SHA1
|
||||
Ctrl.Secret = hexsecret:bded7fa5c1699c010be23dd06ada3a48349f21e5f86263d512c0c5cc379f0e780ec55d9844b2f1db02a96453513568d0
|
||||
Ctrl.label = seed:master secret
|
||||
Ctrl.client_random = hexseed:e5acaf549cd25c22d964c0d930fa4b5261d2507fad84c33715b7b9a864020693
|
||||
@@ -23,7 +23,7 @@ Ctrl.server_random = hexseed:135e4d557fdf3aa6406d82975d5c606a9734c9334b42136e969
|
||||
Output = 2f6962dfbc744c4b2138bb6b3d33054c5ecc14f24851d9896395a44ab3964efc2090c5bf51a0891209f46c1e1e998f62
|
||||
|
||||
KDF=TLS1-PRF
|
||||
Ctrl.md = md:MD5-SHA1
|
||||
Ctrl.digest = digest:MD5-SHA1
|
||||
Ctrl.Secret = hexsecret:2f6962dfbc744c4b2138bb6b3d33054c5ecc14f24851d9896395a44ab3964efc2090c5bf51a0891209f46c1e1e998f62
|
||||
Ctrl.label = seed:key expansion
|
||||
Ctrl.server_random = hexseed:67267e650eb32444119d222a368c191af3082888dc35afe8368e638c828874be
|
||||
@@ -31,7 +31,7 @@ Ctrl.client_random = hexseed:d58a7b1cd4fedaa232159df652ce188f9d997e061b9bf48e83b
|
||||
Output = 3088825988e77fce68d19f756e18e43eb7fe672433504feaf99b3c503d9091b164f166db301d70c9fc0870b4a94563907bee1a61fb786cb717576890bcc51cb9ead97e01d0a2fea99c953377b195205ff07b369589178796edc963fd80fdbe518a2fc1c35c18ae8d
|
||||
|
||||
KDF=TLS1-PRF
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.digest = digest:SHA256
|
||||
Ctrl.Secret = hexsecret:f8938ecc9edebc5030c0c6a441e213cd24e6f770a50dda07876f8d55da062bcadb386b411fd4fe4313a604fce6c17fbc
|
||||
Ctrl.label = seed:master secret
|
||||
Ctrl.client_random = hexseed:36c129d01a3200894b9179faac589d9835d58775f9b5ea3587cb8fd0364cae8c
|
||||
@@ -39,7 +39,7 @@ Ctrl.server_random = hexseed:f6c9575ed7ddd73e1f7d16eca115415812a43c2b747daaaae04
|
||||
Output = 202c88c00f84a17a20027079604787461176455539e705be730890602c289a5001e34eeb3a043e5d52a65e66125188bf
|
||||
|
||||
KDF=TLS1-PRF
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.digest = digest:SHA256
|
||||
Ctrl.Secret = hexsecret:202c88c00f84a17a20027079604787461176455539e705be730890602c289a5001e34eeb3a043e5d52a65e66125188bf
|
||||
Ctrl.label = seed:key expansion
|
||||
Ctrl.server_random = hexseed:ae6c806f8ad4d80784549dff28a4b58fd837681a51d928c3e30ee5ff14f39868
|
||||
@@ -48,7 +48,7 @@ Output = d06139889fffac1e3a71865f504aa5d0d2a2e89506c6f2279b670c3e1b74f531016a253
|
||||
|
||||
# As above but use long name for KDF
|
||||
KDF=tls1-prf
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.digest = digest:SHA256
|
||||
Ctrl.Secret = hexsecret:202c88c00f84a17a20027079604787461176455539e705be730890602c289a5001e34eeb3a043e5d52a65e66125188bf
|
||||
Ctrl.label = seed:key expansion
|
||||
Ctrl.server_random = hexseed:ae6c806f8ad4d80784549dff28a4b58fd837681a51d928c3e30ee5ff14f39868
|
||||
@@ -64,7 +64,7 @@ Result = KDF_DERIVE_ERROR
|
||||
|
||||
# Missing secret.
|
||||
KDF=TLS1-PRF
|
||||
Ctrl.md = md:MD5-SHA1
|
||||
Ctrl.digest = digest:MD5-SHA1
|
||||
Ctrl.Seed = hexseed:02
|
||||
Output = 03
|
||||
Result = KDF_DERIVE_ERROR
|
||||
@@ -72,7 +72,7 @@ Result = KDF_DERIVE_ERROR
|
||||
Title = HKDF tests (from RFC5869 test vectors)
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.digest = digest:SHA256
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = hexsalt:000102030405060708090a0b0c
|
||||
Ctrl.info = hexinfo:f0f1f2f3f4f5f6f7f8f9
|
||||
@@ -80,20 +80,20 @@ Output = 3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf3400720
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.digest = digest:SHA256
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = hexsalt:000102030405060708090a0b0c
|
||||
Output = 077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.digest = digest:SHA256
|
||||
Ctrl.IKM = hexkey:077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5
|
||||
Ctrl.info = hexinfo:f0f1f2f3f4f5f6f7f8f9
|
||||
Output = 3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.digest = digest:SHA256
|
||||
Ctrl.IKM = hexkey:000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f
|
||||
Ctrl.salt = hexsalt:606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf
|
||||
Ctrl.info = hexinfo:b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
|
||||
@@ -101,20 +101,20 @@ Output = b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a9
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.digest = digest:SHA256
|
||||
Ctrl.IKM = hexkey:000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f
|
||||
Ctrl.salt = hexsalt:606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf
|
||||
Output = 06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.digest = digest:SHA256
|
||||
Ctrl.IKM = hexkey:06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244
|
||||
Ctrl.info = hexinfo:b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
|
||||
Output = b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.digest = digest:SHA256
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = salt:
|
||||
Ctrl.info = info:
|
||||
@@ -122,7 +122,7 @@ Output = 8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d20139
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.digest = digest:SHA256
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = salt:
|
||||
Ctrl.info = info:
|
||||
@@ -130,13 +130,13 @@ Output = 19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.digest = digest:SHA256
|
||||
Ctrl.IKM = hexkey:19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04
|
||||
Ctrl.info = info:
|
||||
Output = 8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = hexsalt:000102030405060708090a0b0c
|
||||
Ctrl.info = hexinfo:f0f1f2f3f4f5f6f7f8f9
|
||||
@@ -144,20 +144,20 @@ Output = 085a01ea1b10f36933068b56efa5ad81a4f14b822f5b091568a9cdd4f155fda2c22e422
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = hexsalt:000102030405060708090a0b0c
|
||||
Output = 9b6c18c432a7bf8f0e71c8eb88f4b30baa2ba243
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:9b6c18c432a7bf8f0e71c8eb88f4b30baa2ba243
|
||||
Ctrl.info = hexinfo:f0f1f2f3f4f5f6f7f8f9
|
||||
Output = 085a01ea1b10f36933068b56efa5ad81a4f14b822f5b091568a9cdd4f155fda2c22e422478d305f3f896
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f
|
||||
Ctrl.salt = hexsalt:606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf
|
||||
Ctrl.info = hexinfo:b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
|
||||
@@ -165,20 +165,20 @@ Output = 0bd770a74d1160f7c9f12cd5912a06ebff6adcae899d92191fe4305673ba2ffe8fa3f1a
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f
|
||||
Ctrl.salt = hexsalt:606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf
|
||||
Output = 8adae09a2a307059478d309b26c4115a224cfaf6
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:8adae09a2a307059478d309b26c4115a224cfaf6
|
||||
Ctrl.info = hexinfo:b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
|
||||
Output = 0bd770a74d1160f7c9f12cd5912a06ebff6adcae899d92191fe4305673ba2ffe8fa3f1a4e5ad79f3f334b3b202b2173c486ea37ce3d397ed034c7f9dfeb15c5e927336d0441f4c4300e2cff0d0900b52d3b4
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = salt:
|
||||
Ctrl.info = info:
|
||||
@@ -186,20 +186,20 @@ Output = 0ac1af7002b3d761d1e55298da9d0506b9ae52057220a306e07b6b87e8df21d0ea00033
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = salt:
|
||||
Output = da8c8a73c7fa77288ec6f5e7c297786aa0d32d01
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:da8c8a73c7fa77288ec6f5e7c297786aa0d32d01
|
||||
Ctrl.info = info:
|
||||
Output = 0ac1af7002b3d761d1e55298da9d0506b9ae52057220a306e07b6b87e8df21d0ea00033de03984d34918
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
||||
Ctrl.salt = salt:
|
||||
Ctrl.info = info:
|
||||
@@ -207,14 +207,14 @@ Output = 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
||||
Ctrl.salt = salt:
|
||||
Output = 2adccada18779e7c2077ad2eb19d3f3e731385dd
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:2adccada18779e7c2077ad2eb19d3f3e731385dd
|
||||
Ctrl.info = info:
|
||||
Output = 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48
|
||||
@@ -227,27 +227,27 @@ Output = 00
|
||||
Result = KDF_DERIVE_ERROR
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.salt = salt:
|
||||
Ctrl.info = info:
|
||||
Output = 00
|
||||
Result = KDF_DERIVE_ERROR
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
||||
Ctrl.info = info:
|
||||
Output = 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
||||
Ctrl.salt = salt:
|
||||
Output = 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48
|
||||
|
||||
KDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_AND_EXPAND
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.digest = digest:SHA1
|
||||
Ctrl.IKM = hexkey:0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
||||
Ctrl.salt = salt:
|
||||
Output = 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48
|
||||
@@ -303,3 +303,133 @@ Ctrl.r = r:8
|
||||
Ctrl.p = p:1
|
||||
Result = INTERNAL_ERROR
|
||||
|
||||
Title = PBKDF2 tests
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:1
|
||||
Ctrl.digest = digest:sha1
|
||||
Output = 0c60c80f961f0e71f3a9b524af6012062fe037a6
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:1
|
||||
Ctrl.digest = digest:sha256
|
||||
Output = 120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:1
|
||||
Ctrl.digest = digest:sha512
|
||||
Output = 867f70cf1ade02cff3752599a3a53dc4af34c7a669815ae5d513554e1c8cf252c02d470a285a0501bad999bfe943c08f050235d7d68b1da55e63f73b60a57fce
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:2
|
||||
Ctrl.digest = digest:sha1
|
||||
Output = ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:2
|
||||
Ctrl.digest = digest:sha256
|
||||
Output = ae4d0c95af6b46d32d0adff928f06dd02a303f8ef3c251dfd6e2d85a95474c43
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:2
|
||||
Ctrl.digest = digest:sha512
|
||||
Output = e1d9c16aa681708a45f5c7c4e215ceb66e011a2e9f0040713f18aefdb866d53cf76cab2868a39b9f7840edce4fef5a82be67335c77a6068e04112754f27ccf4e
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:4096
|
||||
Ctrl.digest = digest:sha1
|
||||
Output = 4b007901b765489abead49d926f721d065a429c1
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:4096
|
||||
Ctrl.digest = digest:sha256
|
||||
Output = c5e478d59288c841aa530db6845c4c8d962893a001ce4e11a4963873aa98134a
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:4096
|
||||
Ctrl.digest = digest:sha512
|
||||
Output = d197b1b33db0143e018b12f3d1d1479e6cdebdcc97c5c0f87f6902e072f457b5143f30602641b3d55cd335988cb36b84376060ecd532e039b742a239434af2d5
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:passwordPASSWORDpassword
|
||||
Ctrl.salt = salt:saltSALTsaltSALTsaltSALTsaltSALTsalt
|
||||
Ctrl.iter = iter:4096
|
||||
Ctrl.digest = digest:sha1
|
||||
Output = 3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:passwordPASSWORDpassword
|
||||
Ctrl.salt = salt:saltSALTsaltSALTsaltSALTsaltSALTsalt
|
||||
Ctrl.iter = iter:4096
|
||||
Ctrl.digest = digest:sha256
|
||||
Output = 348c89dbcbd32b2f32d814b8116e84cf2b17347ebc1800181c4e2a1fb8dd53e1c635518c7dac47e9
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:passwordPASSWORDpassword
|
||||
Ctrl.salt = salt:saltSALTsaltSALTsaltSALTsaltSALTsalt
|
||||
Ctrl.iter = iter:4096
|
||||
Ctrl.digest = digest:sha512
|
||||
Output = 8c0511f4c6e597c6ac6315d8f0362e225f3c501495ba23b868c005174dc4ee71115b59f9e60cd9532fa33e0f75aefe30225c583a186cd82bd4daea9724a3d3b8
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.hexpass = hexpass:7061737300776f7264
|
||||
Ctrl.hexsalt = hexsalt:7361006c74
|
||||
Ctrl.iter = iter:4096
|
||||
Ctrl.digest = digest:sha1
|
||||
Output = 56fa6aa75548099dcc37d7f03425e0c3
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.hexpass = hexpass:7061737300776f7264
|
||||
Ctrl.hexsalt = hexsalt:7361006c74
|
||||
Ctrl.iter = iter:4096
|
||||
Ctrl.digest = digest:sha256
|
||||
Output = 89b69d0516f829893c696226650a8687
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.hexpass = hexpass:7061737300776f7264
|
||||
Ctrl.hexsalt = hexsalt:7361006c74
|
||||
Ctrl.iter = iter:4096
|
||||
Ctrl.digest = digest:sha512
|
||||
Output = 9d9e9c4cd21fe4be24d5b8244c759665
|
||||
|
||||
Title = PBKDF2 tests for empty inputs
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:1
|
||||
Ctrl.digest = digest:sha1
|
||||
Output = a33dddc30478185515311f8752895d36ea4363a2
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:1
|
||||
Ctrl.digest = digest:sha256
|
||||
Output = f135c27993baf98773c5cdb40a5706ce6a345cde
|
||||
|
||||
KDF = PBKDF2
|
||||
Ctrl.pass = pass:
|
||||
Ctrl.salt = salt:salt
|
||||
Ctrl.iter = iter:1
|
||||
Ctrl.digest = digest:sha512
|
||||
Output = 00ef42cdbfc98d29db20976608e455567fdddf14
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
#
|
||||
# Copyright 2001-2018 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
|
||||
|
||||
# Tests start with one of these keywords
|
||||
# Cipher Decrypt Derive Digest Encoding KDF PKEYKDF MAC PBE
|
||||
# PrivPubKeyPair Sign Verify VerifyRecover
|
||||
# and continue until a blank line. Lines starting with a pound sign,
|
||||
# like this prolog, are ignored.
|
||||
|
||||
Title = TLS1 PRF tests (from NIST test vectors)
|
||||
|
||||
PKEYKDF=TLS1-PRF
|
||||
Ctrl.md = md:MD5-SHA1
|
||||
Ctrl.Secret = hexsecret:bded7fa5c1699c010be23dd06ada3a48349f21e5f86263d512c0c5cc379f0e780ec55d9844b2f1db02a96453513568d0
|
||||
Ctrl.label = seed:master secret
|
||||
Ctrl.client_random = hexseed:e5acaf549cd25c22d964c0d930fa4b5261d2507fad84c33715b7b9a864020693
|
||||
Ctrl.server_random = hexseed:135e4d557fdf3aa6406d82975d5c606a9734c9334b42136e96990fbd5358cdb2
|
||||
Output = 2f6962dfbc744c4b2138bb6b3d33054c5ecc14f24851d9896395a44ab3964efc2090c5bf51a0891209f46c1e1e998f62
|
||||
|
||||
PKEYKDF=TLS1-PRF
|
||||
Ctrl.md = md:MD5-SHA1
|
||||
Ctrl.Secret = hexsecret:2f6962dfbc744c4b2138bb6b3d33054c5ecc14f24851d9896395a44ab3964efc2090c5bf51a0891209f46c1e1e998f62
|
||||
Ctrl.label = seed:key expansion
|
||||
Ctrl.server_random = hexseed:67267e650eb32444119d222a368c191af3082888dc35afe8368e638c828874be
|
||||
Ctrl.client_random = hexseed:d58a7b1cd4fedaa232159df652ce188f9d997e061b9bf48e83b62990440931f6
|
||||
Output = 3088825988e77fce68d19f756e18e43eb7fe672433504feaf99b3c503d9091b164f166db301d70c9fc0870b4a94563907bee1a61fb786cb717576890bcc51cb9ead97e01d0a2fea99c953377b195205ff07b369589178796edc963fd80fdbe518a2fc1c35c18ae8d
|
||||
|
||||
PKEYKDF=TLS1-PRF
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.Secret = hexsecret:f8938ecc9edebc5030c0c6a441e213cd24e6f770a50dda07876f8d55da062bcadb386b411fd4fe4313a604fce6c17fbc
|
||||
Ctrl.label = seed:master secret
|
||||
Ctrl.client_random = hexseed:36c129d01a3200894b9179faac589d9835d58775f9b5ea3587cb8fd0364cae8c
|
||||
Ctrl.server_random = hexseed:f6c9575ed7ddd73e1f7d16eca115415812a43c2b747daaaae043abfb50053fce
|
||||
Output = 202c88c00f84a17a20027079604787461176455539e705be730890602c289a5001e34eeb3a043e5d52a65e66125188bf
|
||||
|
||||
PKEYKDF=TLS1-PRF
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.Secret = hexsecret:202c88c00f84a17a20027079604787461176455539e705be730890602c289a5001e34eeb3a043e5d52a65e66125188bf
|
||||
Ctrl.label = seed:key expansion
|
||||
Ctrl.server_random = hexseed:ae6c806f8ad4d80784549dff28a4b58fd837681a51d928c3e30ee5ff14f39868
|
||||
Ctrl.client_random = hexseed:62e1fd91f23f558a605f28478c58cf72637b89784d959df7e946d3f07bd1b616
|
||||
Output = d06139889fffac1e3a71865f504aa5d0d2a2e89506c6f2279b670c3e1b74f531016a2530c51a3a0f7e1d6590d0f0566b2f387f8d11fd4f731cdd572d2eae927f6f2f81410b25e6960be68985add6c38445ad9f8c64bf8068bf9a6679485d966f1ad6f68b43495b10a683755ea2b858d70ccac7ec8b053c6bd41ca299d4e51928
|
||||
|
||||
# As above but use long name for KDF
|
||||
PKEYKDF=tls1-prf
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.Secret = hexsecret:202c88c00f84a17a20027079604787461176455539e705be730890602c289a5001e34eeb3a043e5d52a65e66125188bf
|
||||
Ctrl.label = seed:key expansion
|
||||
Ctrl.server_random = hexseed:ae6c806f8ad4d80784549dff28a4b58fd837681a51d928c3e30ee5ff14f39868
|
||||
Ctrl.client_random = hexseed:62e1fd91f23f558a605f28478c58cf72637b89784d959df7e946d3f07bd1b616
|
||||
Output = d06139889fffac1e3a71865f504aa5d0d2a2e89506c6f2279b670c3e1b74f531016a2530c51a3a0f7e1d6590d0f0566b2f387f8d11fd4f731cdd572d2eae927f6f2f81410b25e6960be68985add6c38445ad9f8c64bf8068bf9a6679485d966f1ad6f68b43495b10a683755ea2b858d70ccac7ec8b053c6bd41ca299d4e51928
|
||||
|
||||
# Missing digest.
|
||||
PKEYKDF=TLS1-PRF
|
||||
Ctrl.Secret = hexsecret:01
|
||||
Ctrl.Seed = hexseed:02
|
||||
Output = 03
|
||||
Result = KDF_DERIVE_ERROR
|
||||
|
||||
# Missing secret.
|
||||
PKEYKDF=TLS1-PRF
|
||||
Ctrl.md = md:MD5-SHA1
|
||||
Ctrl.Seed = hexseed:02
|
||||
Output = 03
|
||||
Result = KDF_DERIVE_ERROR
|
||||
|
||||
Title = HKDF tests (from RFC5869 test vectors)
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = hexsalt:000102030405060708090a0b0c
|
||||
Ctrl.info = hexinfo:f0f1f2f3f4f5f6f7f8f9
|
||||
Output = 3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = hexsalt:000102030405060708090a0b0c
|
||||
Output = 077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.IKM = hexkey:077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5
|
||||
Ctrl.info = hexinfo:f0f1f2f3f4f5f6f7f8f9
|
||||
Output = 3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.IKM = hexkey:000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f
|
||||
Ctrl.salt = hexsalt:606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf
|
||||
Ctrl.info = hexinfo:b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
|
||||
Output = b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.IKM = hexkey:000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f
|
||||
Ctrl.salt = hexsalt:606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf
|
||||
Output = 06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.IKM = hexkey:06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244
|
||||
Ctrl.info = hexinfo:b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
|
||||
Output = b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = salt:
|
||||
Ctrl.info = info:
|
||||
Output = 8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = salt:
|
||||
Ctrl.info = info:
|
||||
Output = 19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA256
|
||||
Ctrl.IKM = hexkey:19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04
|
||||
Ctrl.info = info:
|
||||
Output = 8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = hexsalt:000102030405060708090a0b0c
|
||||
Ctrl.info = hexinfo:f0f1f2f3f4f5f6f7f8f9
|
||||
Output = 085a01ea1b10f36933068b56efa5ad81a4f14b822f5b091568a9cdd4f155fda2c22e422478d305f3f896
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = hexsalt:000102030405060708090a0b0c
|
||||
Output = 9b6c18c432a7bf8f0e71c8eb88f4b30baa2ba243
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:9b6c18c432a7bf8f0e71c8eb88f4b30baa2ba243
|
||||
Ctrl.info = hexinfo:f0f1f2f3f4f5f6f7f8f9
|
||||
Output = 085a01ea1b10f36933068b56efa5ad81a4f14b822f5b091568a9cdd4f155fda2c22e422478d305f3f896
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f
|
||||
Ctrl.salt = hexsalt:606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf
|
||||
Ctrl.info = hexinfo:b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
|
||||
Output = 0bd770a74d1160f7c9f12cd5912a06ebff6adcae899d92191fe4305673ba2ffe8fa3f1a4e5ad79f3f334b3b202b2173c486ea37ce3d397ed034c7f9dfeb15c5e927336d0441f4c4300e2cff0d0900b52d3b4
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f
|
||||
Ctrl.salt = hexsalt:606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf
|
||||
Output = 8adae09a2a307059478d309b26c4115a224cfaf6
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:8adae09a2a307059478d309b26c4115a224cfaf6
|
||||
Ctrl.info = hexinfo:b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
|
||||
Output = 0bd770a74d1160f7c9f12cd5912a06ebff6adcae899d92191fe4305673ba2ffe8fa3f1a4e5ad79f3f334b3b202b2173c486ea37ce3d397ed034c7f9dfeb15c5e927336d0441f4c4300e2cff0d0900b52d3b4
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = salt:
|
||||
Ctrl.info = info:
|
||||
Output = 0ac1af7002b3d761d1e55298da9d0506b9ae52057220a306e07b6b87e8df21d0ea00033de03984d34918
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
Ctrl.salt = salt:
|
||||
Output = da8c8a73c7fa77288ec6f5e7c297786aa0d32d01
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:da8c8a73c7fa77288ec6f5e7c297786aa0d32d01
|
||||
Ctrl.info = info:
|
||||
Output = 0ac1af7002b3d761d1e55298da9d0506b9ae52057220a306e07b6b87e8df21d0ea00033de03984d34918
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
||||
Ctrl.salt = salt:
|
||||
Ctrl.info = info:
|
||||
Output = 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
||||
Ctrl.salt = salt:
|
||||
Output = 2adccada18779e7c2077ad2eb19d3f3e731385dd
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXPAND_ONLY
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:2adccada18779e7c2077ad2eb19d3f3e731385dd
|
||||
Ctrl.info = info:
|
||||
Output = 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.IKM = hexkey:0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
||||
Ctrl.salt = salt:
|
||||
Ctrl.info = info:
|
||||
Output = 00
|
||||
Result = KDF_DERIVE_ERROR
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.salt = salt:
|
||||
Ctrl.info = info:
|
||||
Output = 00
|
||||
Result = KDF_DERIVE_ERROR
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
||||
Ctrl.info = info:
|
||||
Output = 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
||||
Ctrl.salt = salt:
|
||||
Output = 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48
|
||||
|
||||
PKEYKDF = HKDF
|
||||
Ctrl.mode = mode:EXTRACT_AND_EXPAND
|
||||
Ctrl.md = md:SHA1
|
||||
Ctrl.IKM = hexkey:0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
|
||||
Ctrl.salt = salt:
|
||||
Output = 2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48
|
||||
|
||||
Title = id-scrypt tests (from draft-josefsson-id-scrypt-kdf-03 and others)
|
||||
|
||||
PKEYKDF = scrypt
|
||||
Ctrl.pass = pass:
|
||||
Ctrl.salt = salt:
|
||||
Ctrl.N = N:16
|
||||
Ctrl.r = r:1
|
||||
Ctrl.p = p:1
|
||||
Output = 77d6576238657b203b19ca42c18a0497f16b4844e3074ae8dfdffa3fede21442fcd0069ded0948f8326a753a0fc81f17e8d3e0fb2e0d3628cf35e20c38d18906
|
||||
|
||||
PKEYKDF = scrypt
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.salt = salt:NaCl
|
||||
Ctrl.N = N:1024
|
||||
Ctrl.r = r:8
|
||||
Ctrl.p = p:16
|
||||
Output = fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640
|
||||
|
||||
PKEYKDF = scrypt
|
||||
Ctrl.hexpass = hexpass:70617373776f7264
|
||||
Ctrl.salt = salt:NaCl
|
||||
Ctrl.N = N:1024
|
||||
Ctrl.r = r:8
|
||||
Ctrl.p = p:16
|
||||
Output = fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640
|
||||
|
||||
PKEYKDF = scrypt
|
||||
Ctrl.pass = pass:password
|
||||
Ctrl.hexsalt = hexsalt:4e61436c
|
||||
Ctrl.N = N:1024
|
||||
Ctrl.r = r:8
|
||||
Ctrl.p = p:16
|
||||
Output = fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640
|
||||
|
||||
PKEYKDF = scrypt
|
||||
Ctrl.pass = pass:pleaseletmein
|
||||
Ctrl.salt = salt:SodiumChloride
|
||||
Ctrl.N = N:16384
|
||||
Ctrl.r = r:8
|
||||
Ctrl.p = p:1
|
||||
Output = 7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887
|
||||
|
||||
# Out of memory
|
||||
PKEYKDF = scrypt
|
||||
Ctrl.pass = pass:pleaseletmein
|
||||
Ctrl.salt = salt:SodiumChloride
|
||||
Ctrl.N = N:1048576
|
||||
Ctrl.r = r:8
|
||||
Ctrl.p = p:1
|
||||
Result = INTERNAL_ERROR
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright (c) 2018, Oracle and/or its affiliates. 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 OpenSSL::Test::Simple;
|
||||
|
||||
simple_test("test_evp_kdf", "evp_kdf_test");
|
||||
@@ -44,7 +44,7 @@ my $content_type = TLSProxy::Record::RT_APPLICATION_DATA;
|
||||
my $inject_recs_num = 1;
|
||||
$proxy->serverflags("-tls1_2");
|
||||
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
|
||||
plan tests => 18;
|
||||
plan tests => 20;
|
||||
ok($fatal_alert, "Out of context empty records test");
|
||||
|
||||
#Test 2: Injecting in context empty records should succeed
|
||||
@@ -155,7 +155,7 @@ ok($fatal_alert, "Changed record version in TLS1.2");
|
||||
|
||||
#TLS1.3 specific tests
|
||||
SKIP: {
|
||||
skip "TLSv1.3 disabled", 6 if disabled("tls1_3");
|
||||
skip "TLSv1.3 disabled", 8 if disabled("tls1_3");
|
||||
|
||||
#Test 13: Sending a different record version in TLS1.3 should fail
|
||||
$proxy->clear();
|
||||
@@ -181,7 +181,9 @@ SKIP: {
|
||||
use constant {
|
||||
DATA_AFTER_SERVER_HELLO => 0,
|
||||
DATA_AFTER_FINISHED => 1,
|
||||
DATA_AFTER_KEY_UPDATE => 2
|
||||
DATA_AFTER_KEY_UPDATE => 2,
|
||||
DATA_BETWEEN_KEY_UPDATE => 3,
|
||||
NO_DATA_BETWEEN_KEY_UPDATE => 4,
|
||||
};
|
||||
|
||||
#Test 16: Sending a ServerHello which doesn't end on a record boundary
|
||||
@@ -198,7 +200,6 @@ SKIP: {
|
||||
$fatal_alert = 0;
|
||||
$proxy->clear();
|
||||
$boundary_test_type = DATA_AFTER_FINISHED;
|
||||
$proxy->filter(\¬_on_record_boundary);
|
||||
$proxy->start();
|
||||
ok($fatal_alert, "Record not on boundary in TLS1.3 (Finished)");
|
||||
|
||||
@@ -207,9 +208,24 @@ SKIP: {
|
||||
$fatal_alert = 0;
|
||||
$proxy->clear();
|
||||
$boundary_test_type = DATA_AFTER_KEY_UPDATE;
|
||||
$proxy->filter(\¬_on_record_boundary);
|
||||
$proxy->start();
|
||||
ok($fatal_alert, "Record not on boundary in TLS1.3 (KeyUpdate)");
|
||||
|
||||
#Test 19: Sending application data in the middle of a fragmented KeyUpdate
|
||||
# should fail. Strictly speaking this is not a record boundary test
|
||||
# but we use the same filter.
|
||||
$fatal_alert = 0;
|
||||
$proxy->clear();
|
||||
$boundary_test_type = DATA_BETWEEN_KEY_UPDATE;
|
||||
$proxy->start();
|
||||
ok($fatal_alert, "Data between KeyUpdate");
|
||||
|
||||
#Test 20: Fragmented KeyUpdate. This should succeed. Strictly speaking this
|
||||
# is not a record boundary test but we use the same filter.
|
||||
$proxy->clear();
|
||||
$boundary_test_type = NO_DATA_BETWEEN_KEY_UPDATE;
|
||||
$proxy->start();
|
||||
ok(TLSProxy::Message->success(), "No data between KeyUpdate");
|
||||
}
|
||||
|
||||
|
||||
@@ -573,7 +589,7 @@ sub not_on_record_boundary
|
||||
#Update the record
|
||||
$last_record->data($data);
|
||||
$last_record->len(length $data);
|
||||
} else {
|
||||
} elsif ($boundary_test_type == DATA_AFTER_KEY_UPDATE) {
|
||||
return if @{$proxy->{message_list}}[-1]->{mt}
|
||||
!= TLSProxy::Message::MT_FINISHED;
|
||||
|
||||
@@ -605,5 +621,79 @@ sub not_on_record_boundary
|
||||
$record->data($data);
|
||||
$record->len(length $data);
|
||||
push @{$records}, $record;
|
||||
} else {
|
||||
return if @{$proxy->{message_list}}[-1]->{mt}
|
||||
!= TLSProxy::Message::MT_FINISHED;
|
||||
|
||||
my $record = TLSProxy::Record->new(
|
||||
1,
|
||||
TLSProxy::Record::RT_APPLICATION_DATA,
|
||||
TLSProxy::Record::VERS_TLS_1_2,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"",
|
||||
""
|
||||
);
|
||||
|
||||
#Add a partial KeyUpdate message into the record
|
||||
$data = pack "C1",
|
||||
0x18; # KeyUpdate message type. Omit the rest of the message header
|
||||
|
||||
#Add content type and tag
|
||||
$data .= pack("C", TLSProxy::Record::RT_HANDSHAKE).("\0"x16);
|
||||
|
||||
$record->data($data);
|
||||
$record->len(length $data);
|
||||
push @{$records}, $record;
|
||||
|
||||
if ($boundary_test_type == DATA_BETWEEN_KEY_UPDATE) {
|
||||
#Now add an app data record
|
||||
$record = TLSProxy::Record->new(
|
||||
1,
|
||||
TLSProxy::Record::RT_APPLICATION_DATA,
|
||||
TLSProxy::Record::VERS_TLS_1_2,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"",
|
||||
""
|
||||
);
|
||||
|
||||
#Add an empty app data record (just content type and tag)
|
||||
$data = pack("C", TLSProxy::Record::RT_APPLICATION_DATA).("\0"x16);
|
||||
|
||||
$record->data($data);
|
||||
$record->len(length $data);
|
||||
push @{$records}, $record;
|
||||
}
|
||||
|
||||
#Now add the rest of the KeyUpdate message
|
||||
$record = TLSProxy::Record->new(
|
||||
1,
|
||||
TLSProxy::Record::RT_APPLICATION_DATA,
|
||||
TLSProxy::Record::VERS_TLS_1_2,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"",
|
||||
""
|
||||
);
|
||||
|
||||
#Add the last 4 bytes of the KeyUpdate record
|
||||
$data = pack "C4",
|
||||
0x00, 0x00, 0x01, # Message length
|
||||
0x00; # Update not requested
|
||||
|
||||
#Add content type and tag
|
||||
$data .= pack("C", TLSProxy::Record::RT_HANDSHAKE).("\0"x16);
|
||||
|
||||
$record->data($data);
|
||||
$record->len(length $data);
|
||||
push @{$records}, $record;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ map { s/\^// } @conf_files if $^O eq "VMS";
|
||||
|
||||
# We hard-code the number of tests to double-check that the globbing above
|
||||
# finds all files as expected.
|
||||
plan tests => 29; # = scalar @conf_srcs
|
||||
plan tests => 30; # = scalar @conf_srcs
|
||||
|
||||
# Some test results depend on the configuration of enabled protocols. We only
|
||||
# verify generated sources in the default configuration.
|
||||
@@ -70,6 +70,7 @@ my %conf_dependent_tests = (
|
||||
"25-cipher.conf" => disabled("poly1305") || disabled("chacha"),
|
||||
"27-ticket-appdata.conf" => !$is_default_tls,
|
||||
"28-seclevel.conf" => disabled("tls1_2") || $no_ec,
|
||||
"30-extended-master-secret.conf" => disabled("tls1_2"),
|
||||
);
|
||||
|
||||
# Add your test here if it should be skipped for some compile-time
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. 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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include <internal/nelem.h>
|
||||
|
||||
#include "internal/sparse_array.h"
|
||||
#include "testutil.h"
|
||||
|
||||
/* The macros below generate unused functions which error out one of the clang
|
||||
* builds. We disable this check here.
|
||||
*/
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
DEFINE_SPARSE_ARRAY_OF(char);
|
||||
|
||||
static int test_sparse_array(void)
|
||||
{
|
||||
static const struct {
|
||||
size_t n;
|
||||
char *v;
|
||||
} cases[] = {
|
||||
{ 22, "a" }, { 0, "z" }, { 1, "b" }, { 290, "c" },
|
||||
{ INT_MAX, "m" }, { 6666666, "d" }, { (size_t)-1, "H" },
|
||||
{ 99, "e" }
|
||||
};
|
||||
SPARSE_ARRAY_OF(char) *sa;
|
||||
size_t i, j;
|
||||
int res = 0;
|
||||
|
||||
if (!TEST_ptr(sa = ossl_sa_char_new())
|
||||
|| !TEST_ptr_null(ossl_sa_char_get(sa, 3))
|
||||
|| !TEST_ptr_null(ossl_sa_char_get(sa, 0))
|
||||
|| !TEST_ptr_null(ossl_sa_char_get(sa, UINT_MAX)))
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < OSSL_NELEM(cases); i++) {
|
||||
if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))) {
|
||||
TEST_note("iteration %zu", i + 1);
|
||||
goto err;
|
||||
}
|
||||
for (j = 0; j <= i; j++)
|
||||
if (!TEST_str_eq(ossl_sa_char_get(sa, cases[j].n), cases[j].v)) {
|
||||
TEST_note("iteration %zu / %zu", i + 1, j + 1);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
res = 1;
|
||||
err:
|
||||
ossl_sa_char_free(sa);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int test_sparse_array_num(void)
|
||||
{
|
||||
static const struct {
|
||||
size_t num;
|
||||
size_t n;
|
||||
char *v;
|
||||
} cases[] = {
|
||||
{ 1, 22, "a" }, { 2, 1021, "b" }, { 3, 3, "c" }, { 2, 22, NULL },
|
||||
{ 2, 3, "d" }, { 3, 22, "e" }, { 3, 666, NULL }, { 4, 666, "f" },
|
||||
{ 3, 3, NULL }, { 2, 22, NULL }, { 1, 666, NULL }, { 2, 64000, "g" },
|
||||
{ 1, 1021, NULL }, { 0, 64000, NULL }, { 1, 23, "h" }, { 0, 23, NULL }
|
||||
};
|
||||
SPARSE_ARRAY_OF(char) *sa = NULL;
|
||||
size_t i;
|
||||
int res = 0;
|
||||
|
||||
if (!TEST_size_t_eq(ossl_sa_char_num(NULL), 0)
|
||||
|| !TEST_ptr(sa = ossl_sa_char_new())
|
||||
|| !TEST_size_t_eq(ossl_sa_char_num(sa), 0))
|
||||
goto err;
|
||||
for (i = 0; i < OSSL_NELEM(cases); i++)
|
||||
if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))
|
||||
|| !TEST_size_t_eq(ossl_sa_char_num(sa), cases[i].num))
|
||||
goto err;
|
||||
res = 1;
|
||||
err:
|
||||
ossl_sa_char_free(sa);
|
||||
return res;
|
||||
}
|
||||
|
||||
struct index_cases_st {
|
||||
size_t n;
|
||||
char *v;
|
||||
int del;
|
||||
};
|
||||
|
||||
struct doall_st {
|
||||
SPARSE_ARRAY_OF(char) *sa;
|
||||
size_t num_cases;
|
||||
const struct index_cases_st *cases;
|
||||
int res;
|
||||
int all;
|
||||
};
|
||||
|
||||
static void leaf_check_all(size_t n, char *value, void *arg)
|
||||
{
|
||||
struct doall_st *doall_data = (struct doall_st *)arg;
|
||||
const struct index_cases_st *cases = doall_data->cases;
|
||||
size_t i;
|
||||
|
||||
doall_data->res = 0;
|
||||
for (i = 0; i < doall_data->num_cases; i++)
|
||||
if ((doall_data->all || !cases[i].del)
|
||||
&& n == cases[i].n && strcmp(value, cases[i].v) == 0) {
|
||||
doall_data->res = 1;
|
||||
return;
|
||||
}
|
||||
TEST_error("Index %zu with value %s not found", n, value);
|
||||
}
|
||||
|
||||
static void leaf_delete(size_t n, char *value, void *arg)
|
||||
{
|
||||
struct doall_st *doall_data = (struct doall_st *)arg;
|
||||
const struct index_cases_st *cases = doall_data->cases;
|
||||
size_t i;
|
||||
|
||||
doall_data->res = 0;
|
||||
for (i = 0; i < doall_data->num_cases; i++)
|
||||
if (n == cases[i].n && strcmp(value, cases[i].v) == 0) {
|
||||
doall_data->res = 1;
|
||||
ossl_sa_char_set(doall_data->sa, n, NULL);
|
||||
return;
|
||||
}
|
||||
TEST_error("Index %zu with value %s not found", n, value);
|
||||
}
|
||||
|
||||
static int test_sparse_array_doall(void)
|
||||
{
|
||||
static const struct index_cases_st cases[] = {
|
||||
{ 22, "A", 1 }, { 1021, "b", 0 }, { 3, "c", 0 }, { INT_MAX, "d", 1 },
|
||||
{ (size_t)-1, "H", 0 }, { (size_t)-2, "i", 1 }, { 666666666, "s", 1 },
|
||||
{ 1234567890, "t", 0 },
|
||||
};
|
||||
struct doall_st doall_data;
|
||||
size_t i;
|
||||
SPARSE_ARRAY_OF(char) *sa = NULL;
|
||||
int res = 0;
|
||||
|
||||
if (!TEST_ptr(sa = ossl_sa_char_new()))
|
||||
goto err;
|
||||
doall_data.num_cases = OSSL_NELEM(cases);
|
||||
doall_data.cases = cases;
|
||||
doall_data.all = 1;
|
||||
doall_data.sa = NULL;
|
||||
for (i = 0; i < OSSL_NELEM(cases); i++)
|
||||
if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))) {
|
||||
TEST_note("failed at iteration %zu", i + 1);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ossl_sa_char_doall_arg(sa, &leaf_check_all, &doall_data);
|
||||
if (doall_data.res == 0) {
|
||||
TEST_info("while checking all elements");
|
||||
goto err;
|
||||
}
|
||||
doall_data.all = 0;
|
||||
doall_data.sa = sa;
|
||||
ossl_sa_char_doall_arg(sa, &leaf_delete, &doall_data);
|
||||
if (doall_data.res == 0) {
|
||||
TEST_info("while deleting selected elements");
|
||||
goto err;
|
||||
}
|
||||
ossl_sa_char_doall_arg(sa, &leaf_check_all, &doall_data);
|
||||
if (doall_data.res == 0) {
|
||||
TEST_info("while checking for deleted elements");
|
||||
goto err;
|
||||
}
|
||||
res = 1;
|
||||
|
||||
err:
|
||||
ossl_sa_char_free(sa);
|
||||
return res;
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_sparse_array);
|
||||
ADD_TEST(test_sparse_array_num);
|
||||
ADD_TEST(test_sparse_array_doall);
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
# Generated with generate_ssl_tests.pl
|
||||
|
||||
num_tests = 7
|
||||
|
||||
test-0 = 0-disable-extended-master-secret-server-sha
|
||||
test-1 = 1-disable-extended-master-secret-client-sha
|
||||
test-2 = 2-disable-extended-master-secret-both-sha
|
||||
test-3 = 3-disable-extended-master-secret-both-resume
|
||||
test-4 = 4-disable-extended-master-secret-server-sha2
|
||||
test-5 = 5-disable-extended-master-secret-client-sha2
|
||||
test-6 = 6-disable-extended-master-secret-both-sha2
|
||||
# ===========================================================
|
||||
|
||||
[0-disable-extended-master-secret-server-sha]
|
||||
ssl_conf = 0-disable-extended-master-secret-server-sha-ssl
|
||||
|
||||
[0-disable-extended-master-secret-server-sha-ssl]
|
||||
server = 0-disable-extended-master-secret-server-sha-server
|
||||
client = 0-disable-extended-master-secret-server-sha-client
|
||||
|
||||
[0-disable-extended-master-secret-server-sha-server]
|
||||
Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
|
||||
CipherString = DEFAULT
|
||||
Options = -ExtendedMasterSecret
|
||||
PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
|
||||
|
||||
[0-disable-extended-master-secret-server-sha-client]
|
||||
CipherString = AES128-SHA
|
||||
MaxProtocol = TLSv1.2
|
||||
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
|
||||
VerifyMode = Peer
|
||||
|
||||
[test-0]
|
||||
ExpectedResult = Success
|
||||
|
||||
|
||||
# ===========================================================
|
||||
|
||||
[1-disable-extended-master-secret-client-sha]
|
||||
ssl_conf = 1-disable-extended-master-secret-client-sha-ssl
|
||||
|
||||
[1-disable-extended-master-secret-client-sha-ssl]
|
||||
server = 1-disable-extended-master-secret-client-sha-server
|
||||
client = 1-disable-extended-master-secret-client-sha-client
|
||||
|
||||
[1-disable-extended-master-secret-client-sha-server]
|
||||
Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
|
||||
CipherString = DEFAULT
|
||||
PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
|
||||
|
||||
[1-disable-extended-master-secret-client-sha-client]
|
||||
CipherString = AES128-SHA
|
||||
MaxProtocol = TLSv1.2
|
||||
Options = -ExtendedMasterSecret
|
||||
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
|
||||
VerifyMode = Peer
|
||||
|
||||
[test-1]
|
||||
ExpectedResult = Success
|
||||
|
||||
|
||||
# ===========================================================
|
||||
|
||||
[2-disable-extended-master-secret-both-sha]
|
||||
ssl_conf = 2-disable-extended-master-secret-both-sha-ssl
|
||||
|
||||
[2-disable-extended-master-secret-both-sha-ssl]
|
||||
server = 2-disable-extended-master-secret-both-sha-server
|
||||
client = 2-disable-extended-master-secret-both-sha-client
|
||||
|
||||
[2-disable-extended-master-secret-both-sha-server]
|
||||
Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
|
||||
CipherString = DEFAULT
|
||||
Options = -ExtendedMasterSecret
|
||||
PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
|
||||
|
||||
[2-disable-extended-master-secret-both-sha-client]
|
||||
CipherString = AES128-SHA
|
||||
MaxProtocol = TLSv1.2
|
||||
Options = -ExtendedMasterSecret
|
||||
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
|
||||
VerifyMode = Peer
|
||||
|
||||
[test-2]
|
||||
ExpectedResult = Success
|
||||
|
||||
|
||||
# ===========================================================
|
||||
|
||||
[3-disable-extended-master-secret-both-resume]
|
||||
ssl_conf = 3-disable-extended-master-secret-both-resume-ssl
|
||||
|
||||
[3-disable-extended-master-secret-both-resume-ssl]
|
||||
server = 3-disable-extended-master-secret-both-resume-server
|
||||
client = 3-disable-extended-master-secret-both-resume-client
|
||||
resume-server = 3-disable-extended-master-secret-both-resume-resume-server
|
||||
resume-client = 3-disable-extended-master-secret-both-resume-resume-client
|
||||
|
||||
[3-disable-extended-master-secret-both-resume-server]
|
||||
Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
|
||||
CipherString = DEFAULT
|
||||
Options = -ExtendedMasterSecret
|
||||
PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
|
||||
|
||||
[3-disable-extended-master-secret-both-resume-resume-server]
|
||||
Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
|
||||
CipherString = DEFAULT
|
||||
PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
|
||||
|
||||
[3-disable-extended-master-secret-both-resume-client]
|
||||
CipherString = AES128-SHA
|
||||
MaxProtocol = TLSv1.2
|
||||
Options = -ExtendedMasterSecret
|
||||
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
|
||||
VerifyMode = Peer
|
||||
|
||||
[3-disable-extended-master-secret-both-resume-resume-client]
|
||||
CipherString = AES128-SHA
|
||||
MaxProtocol = TLSv1.2
|
||||
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
|
||||
VerifyMode = Peer
|
||||
|
||||
[test-3]
|
||||
ExpectedResult = Success
|
||||
HandshakeMode = Resume
|
||||
|
||||
|
||||
# ===========================================================
|
||||
|
||||
[4-disable-extended-master-secret-server-sha2]
|
||||
ssl_conf = 4-disable-extended-master-secret-server-sha2-ssl
|
||||
|
||||
[4-disable-extended-master-secret-server-sha2-ssl]
|
||||
server = 4-disable-extended-master-secret-server-sha2-server
|
||||
client = 4-disable-extended-master-secret-server-sha2-client
|
||||
|
||||
[4-disable-extended-master-secret-server-sha2-server]
|
||||
Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
|
||||
CipherString = DEFAULT
|
||||
Options = -ExtendedMasterSecret
|
||||
PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
|
||||
|
||||
[4-disable-extended-master-secret-server-sha2-client]
|
||||
CipherString = AES128-SHA256
|
||||
MaxProtocol = TLSv1.2
|
||||
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
|
||||
VerifyMode = Peer
|
||||
|
||||
[test-4]
|
||||
ExpectedResult = Success
|
||||
|
||||
|
||||
# ===========================================================
|
||||
|
||||
[5-disable-extended-master-secret-client-sha2]
|
||||
ssl_conf = 5-disable-extended-master-secret-client-sha2-ssl
|
||||
|
||||
[5-disable-extended-master-secret-client-sha2-ssl]
|
||||
server = 5-disable-extended-master-secret-client-sha2-server
|
||||
client = 5-disable-extended-master-secret-client-sha2-client
|
||||
|
||||
[5-disable-extended-master-secret-client-sha2-server]
|
||||
Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
|
||||
CipherString = DEFAULT
|
||||
PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
|
||||
|
||||
[5-disable-extended-master-secret-client-sha2-client]
|
||||
CipherString = AES128-SHA256
|
||||
MaxProtocol = TLSv1.2
|
||||
Options = -ExtendedMasterSecret
|
||||
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
|
||||
VerifyMode = Peer
|
||||
|
||||
[test-5]
|
||||
ExpectedResult = Success
|
||||
|
||||
|
||||
# ===========================================================
|
||||
|
||||
[6-disable-extended-master-secret-both-sha2]
|
||||
ssl_conf = 6-disable-extended-master-secret-both-sha2-ssl
|
||||
|
||||
[6-disable-extended-master-secret-both-sha2-ssl]
|
||||
server = 6-disable-extended-master-secret-both-sha2-server
|
||||
client = 6-disable-extended-master-secret-both-sha2-client
|
||||
|
||||
[6-disable-extended-master-secret-both-sha2-server]
|
||||
Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
|
||||
CipherString = DEFAULT
|
||||
Options = -ExtendedMasterSecret
|
||||
PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
|
||||
|
||||
[6-disable-extended-master-secret-both-sha2-client]
|
||||
CipherString = AES128-SHA256
|
||||
MaxProtocol = TLSv1.2
|
||||
Options = -ExtendedMasterSecret
|
||||
VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
|
||||
VerifyMode = Peer
|
||||
|
||||
[test-6]
|
||||
ExpectedResult = Success
|
||||
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
# -*- mode: perl; -*-
|
||||
# Copyright 2016-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (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
|
||||
|
||||
|
||||
## SSL test configurations
|
||||
|
||||
package ssltests;
|
||||
|
||||
use OpenSSL::Test::Utils;
|
||||
|
||||
our @tests = ();
|
||||
|
||||
my @tests_tls1_2 = (
|
||||
{
|
||||
name => "disable-extended-master-secret-server-sha",
|
||||
server => {
|
||||
"Options" => "-ExtendedMasterSecret",
|
||||
},
|
||||
client => {
|
||||
"CipherString" => "AES128-SHA",
|
||||
"MaxProtocol" => "TLSv1.2"
|
||||
},
|
||||
test => {
|
||||
"ExpectedResult" => "Success",
|
||||
},
|
||||
},
|
||||
{
|
||||
name => "disable-extended-master-secret-client-sha",
|
||||
server => {
|
||||
},
|
||||
client => {
|
||||
"CipherString" => "AES128-SHA",
|
||||
"Options" => "-ExtendedMasterSecret",
|
||||
"MaxProtocol" => "TLSv1.2"
|
||||
},
|
||||
test => {
|
||||
"ExpectedResult" => "Success",
|
||||
},
|
||||
},
|
||||
{
|
||||
name => "disable-extended-master-secret-both-sha",
|
||||
server => {
|
||||
"Options" => "-ExtendedMasterSecret",
|
||||
},
|
||||
client => {
|
||||
"CipherString" => "AES128-SHA",
|
||||
"Options" => "-ExtendedMasterSecret",
|
||||
"MaxProtocol" => "TLSv1.2"
|
||||
},
|
||||
test => {
|
||||
"ExpectedResult" => "Success",
|
||||
},
|
||||
},
|
||||
{
|
||||
name => "disable-extended-master-secret-both-resume",
|
||||
server => {
|
||||
"Options" => "-ExtendedMasterSecret",
|
||||
},
|
||||
resume_server => {
|
||||
},
|
||||
client => {
|
||||
"CipherString" => "AES128-SHA",
|
||||
"Options" => "-ExtendedMasterSecret",
|
||||
"MaxProtocol" => "TLSv1.2"
|
||||
},
|
||||
resume_client => {
|
||||
"CipherString" => "AES128-SHA",
|
||||
"MaxProtocol" => "TLSv1.2"
|
||||
},
|
||||
test => {
|
||||
"HandshakeMode" => "Resume",
|
||||
"ExpectedResult" => "Success",
|
||||
},
|
||||
},
|
||||
{
|
||||
name => "disable-extended-master-secret-server-sha2",
|
||||
server => {
|
||||
"Options" => "-ExtendedMasterSecret",
|
||||
},
|
||||
client => {
|
||||
"CipherString" => "AES128-SHA256",
|
||||
"MaxProtocol" => "TLSv1.2"
|
||||
},
|
||||
test => {
|
||||
"ExpectedResult" => "Success",
|
||||
},
|
||||
},
|
||||
{
|
||||
name => "disable-extended-master-secret-client-sha2",
|
||||
server => {
|
||||
},
|
||||
client => {
|
||||
"CipherString" => "AES128-SHA256",
|
||||
"Options" => "-ExtendedMasterSecret",
|
||||
"MaxProtocol" => "TLSv1.2"
|
||||
},
|
||||
test => {
|
||||
"ExpectedResult" => "Success",
|
||||
},
|
||||
},
|
||||
{
|
||||
name => "disable-extended-master-secret-both-sha2",
|
||||
server => {
|
||||
"Options" => "-ExtendedMasterSecret",
|
||||
},
|
||||
client => {
|
||||
"CipherString" => "AES128-SHA256",
|
||||
"Options" => "-ExtendedMasterSecret",
|
||||
"MaxProtocol" => "TLSv1.2"
|
||||
},
|
||||
test => {
|
||||
"ExpectedResult" => "Success",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
push @tests, @tests_tls1_2 unless disabled("tls1_2");
|
||||
+67
-28
@@ -571,6 +571,51 @@ static int test_client_hello_cb(void)
|
||||
|
||||
testresult = 1;
|
||||
|
||||
end:
|
||||
SSL_free(serverssl);
|
||||
SSL_free(clientssl);
|
||||
SSL_CTX_free(sctx);
|
||||
SSL_CTX_free(cctx);
|
||||
|
||||
return testresult;
|
||||
}
|
||||
|
||||
static int test_no_ems(void)
|
||||
{
|
||||
SSL_CTX *cctx = NULL, *sctx = NULL;
|
||||
SSL *clientssl = NULL, *serverssl = NULL;
|
||||
int testresult = 0;
|
||||
|
||||
if (!create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
|
||||
TLS1_VERSION, TLS1_2_VERSION,
|
||||
&sctx, &cctx, cert, privkey)) {
|
||||
printf("Unable to create SSL_CTX pair\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
SSL_CTX_set_options(sctx, SSL_OP_NO_EXTENDED_MASTER_SECRET);
|
||||
|
||||
if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
|
||||
printf("Unable to create SSL objects\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)) {
|
||||
printf("Creating SSL connection failed\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (SSL_get_extms_support(serverssl)) {
|
||||
printf("Server reports Extended Master Secret support\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (SSL_get_extms_support(clientssl)) {
|
||||
printf("Client reports Extended Master Secret support\n");
|
||||
goto end;
|
||||
}
|
||||
testresult = 1;
|
||||
|
||||
end:
|
||||
SSL_free(serverssl);
|
||||
SSL_free(clientssl);
|
||||
@@ -4919,18 +4964,14 @@ static struct info_cb_states_st {
|
||||
{SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWEE"}, {SSL_CB_LOOP, "TWSC"},
|
||||
{SSL_CB_LOOP, "TRSCV"}, {SSL_CB_LOOP, "TWFIN"}, {SSL_CB_LOOP, "TED"},
|
||||
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TED"}, {SSL_CB_LOOP, "TRFIN"},
|
||||
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
|
||||
{SSL_CB_LOOP, "TWST"}, {SSL_CB_HANDSHAKE_DONE, NULL},
|
||||
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "TWST"},
|
||||
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
|
||||
{SSL_CB_ALERT, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
|
||||
{SSL_CB_LOOP, "PINIT "}, {SSL_CB_LOOP, "PINIT "}, {SSL_CB_LOOP, "TRCH"},
|
||||
{SSL_CB_LOOP, "TWSH"}, {SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWEE"},
|
||||
{SSL_CB_LOOP, "TWFIN"}, {SSL_CB_LOOP, "TED"}, {SSL_CB_EXIT, NULL},
|
||||
{SSL_CB_LOOP, "TED"}, {SSL_CB_LOOP, "TRFIN"},
|
||||
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
|
||||
{SSL_CB_LOOP, "TWST"}, {SSL_CB_HANDSHAKE_DONE, NULL},
|
||||
{SSL_CB_EXIT, NULL}, {0, NULL},
|
||||
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_LOOP, "TWST"},
|
||||
{SSL_CB_LOOP, "TWST"}, {SSL_CB_EXIT, NULL}, {SSL_CB_ALERT, NULL},
|
||||
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT "},
|
||||
{SSL_CB_LOOP, "PINIT "}, {SSL_CB_LOOP, "TRCH"}, {SSL_CB_LOOP, "TWSH"},
|
||||
{SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWEE"}, {SSL_CB_LOOP, "TWFIN"},
|
||||
{SSL_CB_LOOP, "TED"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "TED"},
|
||||
{SSL_CB_LOOP, "TRFIN"}, {SSL_CB_HANDSHAKE_DONE, NULL},
|
||||
{SSL_CB_LOOP, "TWST"}, {SSL_CB_EXIT, NULL}, {0, NULL},
|
||||
}, {
|
||||
/* TLSv1.3 client followed by resumption */
|
||||
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT "},
|
||||
@@ -4938,20 +4979,16 @@ static struct info_cb_states_st {
|
||||
{SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TREE"}, {SSL_CB_LOOP, "TRSC"},
|
||||
{SSL_CB_LOOP, "TRSCV"}, {SSL_CB_LOOP, "TRFIN"}, {SSL_CB_LOOP, "TWCCS"},
|
||||
{SSL_CB_LOOP, "TWFIN"}, {SSL_CB_HANDSHAKE_DONE, NULL},
|
||||
{SSL_CB_EXIT, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
|
||||
{SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "TRST"},
|
||||
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
|
||||
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "SSLOK "},
|
||||
{SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "TRST"},
|
||||
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
|
||||
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "SSLOK "},
|
||||
{SSL_CB_LOOP, "TRST"}, {SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "SSLOK "},
|
||||
{SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "TRST"}, {SSL_CB_EXIT, NULL},
|
||||
{SSL_CB_ALERT, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
|
||||
{SSL_CB_LOOP, "PINIT "}, {SSL_CB_LOOP, "TWCH"}, {SSL_CB_EXIT, NULL},
|
||||
{SSL_CB_LOOP, "TWCH"}, {SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TREE"},
|
||||
{SSL_CB_LOOP, "TRFIN"}, {SSL_CB_LOOP, "TWCCS"}, {SSL_CB_LOOP, "TWFIN"},
|
||||
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
|
||||
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "SSLOK "},
|
||||
{SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "TRST"},
|
||||
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL}, {0, NULL},
|
||||
{SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "TRST"},
|
||||
{SSL_CB_EXIT, NULL}, {0, NULL},
|
||||
}, {
|
||||
/* TLSv1.3 server, early_data */
|
||||
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "PINIT "},
|
||||
@@ -4960,8 +4997,7 @@ static struct info_cb_states_st {
|
||||
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL},
|
||||
{SSL_CB_HANDSHAKE_START, NULL}, {SSL_CB_LOOP, "TED"},
|
||||
{SSL_CB_LOOP, "TED"}, {SSL_CB_LOOP, "TWEOED"}, {SSL_CB_LOOP, "TRFIN"},
|
||||
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
|
||||
{SSL_CB_LOOP, "TWST"}, {SSL_CB_HANDSHAKE_DONE, NULL},
|
||||
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_LOOP, "TWST"},
|
||||
{SSL_CB_EXIT, NULL}, {0, NULL},
|
||||
}, {
|
||||
/* TLSv1.3 client, early_data */
|
||||
@@ -4972,9 +5008,8 @@ static struct info_cb_states_st {
|
||||
{SSL_CB_LOOP, "TED"}, {SSL_CB_LOOP, "TRSH"}, {SSL_CB_LOOP, "TREE"},
|
||||
{SSL_CB_LOOP, "TRFIN"}, {SSL_CB_LOOP, "TPEDE"}, {SSL_CB_LOOP, "TWEOED"},
|
||||
{SSL_CB_LOOP, "TWFIN"}, {SSL_CB_HANDSHAKE_DONE, NULL},
|
||||
{SSL_CB_EXIT, NULL}, {SSL_CB_HANDSHAKE_START, NULL},
|
||||
{SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "TRST"},
|
||||
{SSL_CB_HANDSHAKE_DONE, NULL}, {SSL_CB_EXIT, NULL}, {0, NULL},
|
||||
{SSL_CB_EXIT, NULL}, {SSL_CB_LOOP, "SSLOK "}, {SSL_CB_LOOP, "SSLOK "},
|
||||
{SSL_CB_LOOP, "TRST"}, {SSL_CB_EXIT, NULL}, {0, NULL},
|
||||
}, {
|
||||
{0, NULL},
|
||||
}
|
||||
@@ -5013,8 +5048,11 @@ static void sslapi_info_callback(const SSL *s, int where, int ret)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check that, if we've got SSL_CB_HANDSHAKE_DONE we are not in init */
|
||||
if ((where & SSL_CB_HANDSHAKE_DONE) && SSL_in_init((SSL *)s) != 0) {
|
||||
/*
|
||||
* Check that, if we've got SSL_CB_HANDSHAKE_DONE we are not in init
|
||||
*/
|
||||
if ((where & SSL_CB_HANDSHAKE_DONE)
|
||||
&& SSL_in_init((SSL *)s) != 0) {
|
||||
info_cb_failed = 1;
|
||||
return;
|
||||
}
|
||||
@@ -6094,6 +6132,7 @@ int setup_tests(void)
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1_2
|
||||
ADD_TEST(test_client_hello_cb);
|
||||
ADD_TEST(test_no_ems);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1_3
|
||||
ADD_ALL_TESTS(test_early_data_read_write, 3);
|
||||
|
||||
+46
-5
@@ -1382,11 +1382,52 @@ int main(int argc, char *argv[])
|
||||
goto end;
|
||||
|
||||
if (cipher != NULL) {
|
||||
if (!SSL_CTX_set_cipher_list(c_ctx, cipher)
|
||||
|| !SSL_CTX_set_cipher_list(s_ctx, cipher)
|
||||
|| !SSL_CTX_set_cipher_list(s_ctx2, cipher)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
if (strcmp(cipher, "") == 0) {
|
||||
if (!SSL_CTX_set_cipher_list(c_ctx, cipher)) {
|
||||
if (ERR_GET_REASON(ERR_peek_error()) == SSL_R_NO_CIPHER_MATCH) {
|
||||
ERR_clear_error();
|
||||
} else {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
/* Should have failed when clearing all TLSv1.2 ciphers. */
|
||||
fprintf(stderr, "CLEARING ALL TLSv1.2 CIPHERS SHOULD FAIL\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!SSL_CTX_set_cipher_list(s_ctx, cipher)) {
|
||||
if (ERR_GET_REASON(ERR_peek_error()) == SSL_R_NO_CIPHER_MATCH) {
|
||||
ERR_clear_error();
|
||||
} else {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
/* Should have failed when clearing all TLSv1.2 ciphers. */
|
||||
fprintf(stderr, "CLEARING ALL TLSv1.2 CIPHERS SHOULD FAIL\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!SSL_CTX_set_cipher_list(s_ctx2, cipher)) {
|
||||
if (ERR_GET_REASON(ERR_peek_error()) == SSL_R_NO_CIPHER_MATCH) {
|
||||
ERR_clear_error();
|
||||
} else {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
/* Should have failed when clearing all TLSv1.2 ciphers. */
|
||||
fprintf(stderr, "CLEARING ALL TLSv1.2 CIPHERS SHOULD FAIL\n");
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
if (!SSL_CTX_set_cipher_list(c_ctx, cipher)
|
||||
|| !SSL_CTX_set_cipher_list(s_ctx, cipher)
|
||||
|| !SSL_CTX_set_cipher_list(s_ctx2, cipher)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ciphersuites != NULL) {
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/e_os2.h>
|
||||
#include <openssl/bn.h>
|
||||
#include "../apps/opt.h"
|
||||
#include "opt.h"
|
||||
|
||||
/*-
|
||||
* Simple unit tests should implement setup_tests().
|
||||
|
||||
Reference in New Issue
Block a user