Latest update.
This commit is contained in:
+36
-20
@@ -50,10 +50,9 @@ IF[{- !$disabled{tests} -}]
|
||||
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 \
|
||||
recordlentest drbgtest drbg_cavs_test drbg_extra_test sslbuffertest \
|
||||
time_offset_test pemtest ssl_cert_table_internal_test ciphername_test \
|
||||
servername_test ocspapitest rsa_mp_test fatalerrtest tls13ccstest \
|
||||
http_test servername_test ocspapitest rsa_mp_test fatalerrtest tls13ccstest \
|
||||
sysdefaulttest errtest ssl_ctx_test gosttest \
|
||||
context_internal_test aesgcmtest params_test evp_pkey_dparams_test \
|
||||
keymgmt_internal_test
|
||||
@@ -141,11 +140,11 @@ IF[{- !$disabled{tests} -}]
|
||||
ENDIF
|
||||
|
||||
SOURCE[evp_extra_test]=evp_extra_test.c
|
||||
INCLUDE[evp_extra_test]=../include ../apps/include ../crypto/include
|
||||
INCLUDE[evp_extra_test]=../include ../apps/include
|
||||
DEPEND[evp_extra_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[evp_fetch_prov_test]=evp_fetch_prov_test.c
|
||||
INCLUDE[evp_fetch_prov_test]=../include ../apps/include ../crypto/include
|
||||
INCLUDE[evp_fetch_prov_test]=../include ../apps/include
|
||||
DEPEND[evp_fetch_prov_test]=../libcrypto libtestutil.a
|
||||
IF[{- $disabled{fips} || !$target{dso_scheme} -}]
|
||||
DEFINE[evp_extra_test]=NO_FIPS_MODULE
|
||||
@@ -357,15 +356,19 @@ IF[{- !$disabled{tests} -}]
|
||||
DEPEND[recordlentest]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[drbgtest]=drbgtest.c
|
||||
INCLUDE[drbgtest]=../include ../apps/include ../crypto/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 ../apps/include . .. ../crypto/include
|
||||
INCLUDE[drbg_cavs_test]=../include ../apps/include . ..
|
||||
DEPEND[drbg_cavs_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[drbg_extra_test]=drbg_extra_test.c
|
||||
INCLUDE[drbg_extra_test]=../include . .. ../apps/include
|
||||
DEPEND[drbg_extra_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[x509_dup_cert_test]=x509_dup_cert_test.c
|
||||
INCLUDE[x509_dup_cert_test]=../include ../apps/include
|
||||
DEPEND[x509_dup_cert_test]=../libcrypto libtestutil.a
|
||||
@@ -386,6 +389,10 @@ IF[{- !$disabled{tests} -}]
|
||||
INCLUDE[ciphername_test]=../include ../apps/include
|
||||
DEPEND[ciphername_test]=../libcrypto ../libssl libtestutil.a
|
||||
|
||||
SOURCE[http_test]=http_test.c
|
||||
INCLUDE[http_test]=../include ../apps/include
|
||||
DEPEND[http_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[servername_test]=servername_test.c ssltestlib.c
|
||||
INCLUDE[servername_test]=../include ../apps/include
|
||||
DEPEND[servername_test]=../libcrypto ../libssl libtestutil.a
|
||||
@@ -407,7 +414,7 @@ IF[{- !$disabled{tests} -}]
|
||||
IF[{- !$disabled{shared} -}]
|
||||
PROGRAMS{noinst}=shlibloadtest
|
||||
SOURCE[shlibloadtest]=shlibloadtest.c
|
||||
INCLUDE[shlibloadtest]=../include ../apps/include ../crypto/include
|
||||
INCLUDE[shlibloadtest]=../include ../apps/include
|
||||
ENDIF
|
||||
|
||||
# cipher_overhead_test uses internal symbols, so it must be linked with
|
||||
@@ -447,7 +454,8 @@ IF[{- !$disabled{tests} -}]
|
||||
|
||||
IF[{- !$disabled{cmp} -}]
|
||||
PROGRAMS{noinst}=cmp_asn_test cmp_ctx_test cmp_status_test cmp_hdr_test \
|
||||
cmp_protect_test cmp_msg_test cmp_vfy_test
|
||||
cmp_protect_test cmp_msg_test cmp_vfy_test \
|
||||
cmp_server_test cmp_client_test
|
||||
ENDIF
|
||||
|
||||
SOURCE[cmp_asn_test]=cmp_asn_test.c cmp_testlib.c
|
||||
@@ -474,10 +482,18 @@ IF[{- !$disabled{tests} -}]
|
||||
INCLUDE[cmp_msg_test]=.. ../include ../apps/include
|
||||
DEPEND[cmp_msg_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[cmp_vfy_test]=cmp_status_test.c cmp_testlib.c
|
||||
SOURCE[cmp_vfy_test]=cmp_vfy_test.c cmp_testlib.c
|
||||
INCLUDE[cmp_vfy_test]=.. ../include ../apps/include
|
||||
DEPEND[cmp_vfy_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[cmp_server_test]=cmp_server_test.c cmp_testlib.c
|
||||
INCLUDE[cmp_server_test]=.. ../include ../apps/include
|
||||
DEPEND[cmp_server_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[cmp_client_test]=cmp_client_test.c cmp_testlib.c ../apps/cmp_mock_srv.c
|
||||
INCLUDE[cmp_client_test]=.. ../include ../apps/include
|
||||
DEPEND[cmp_client_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
# Internal test programs. These are essentially a collection of internal
|
||||
# test routines. Some of them need to reach internal symbols that aren't
|
||||
# available through the shared library (at least on Linux, Solaris, Windows
|
||||
@@ -513,19 +529,19 @@ IF[{- !$disabled{tests} -}]
|
||||
ENDIF
|
||||
|
||||
SOURCE[poly1305_internal_test]=poly1305_internal_test.c
|
||||
INCLUDE[poly1305_internal_test]=.. ../include ../apps/include ../crypto/include
|
||||
INCLUDE[poly1305_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[poly1305_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[chacha_internal_test]=chacha_internal_test.c
|
||||
INCLUDE[chacha_internal_test]=.. ../include ../apps/include ../crypto/include
|
||||
INCLUDE[chacha_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[chacha_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[asn1_internal_test]=asn1_internal_test.c
|
||||
INCLUDE[asn1_internal_test]=.. ../include ../apps/include ../crypto/include
|
||||
INCLUDE[asn1_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[asn1_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[modes_internal_test]=modes_internal_test.c
|
||||
INCLUDE[modes_internal_test]=.. ../include ../apps/include ../crypto/include
|
||||
INCLUDE[modes_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[modes_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[x509_internal_test]=x509_internal_test.c
|
||||
@@ -566,7 +582,7 @@ IF[{- !$disabled{tests} -}]
|
||||
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
|
||||
INCLUDE[sparse_array_test]=../include ../apps/include
|
||||
DEPEND[sparse_array_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[dhtest]=dhtest.c
|
||||
@@ -578,15 +594,15 @@ IF[{- !$disabled{tests} -}]
|
||||
DEPEND[hmactest]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[siphash_internal_test]=siphash_internal_test.c
|
||||
INCLUDE[siphash_internal_test]=.. ../include ../apps/include ../crypto/include
|
||||
INCLUDE[siphash_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[siphash_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[sm2_internal_test]=sm2_internal_test.c
|
||||
INCLUDE[sm2_internal_test]=../include ../apps/include ../crypto/include
|
||||
INCLUDE[sm2_internal_test]=../include ../apps/include
|
||||
DEPEND[sm2_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[sm4_internal_test]=sm4_internal_test.c
|
||||
INCLUDE[sm4_internal_test]=.. ../include ../apps/include ../crypto/include
|
||||
INCLUDE[sm4_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[sm4_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[destest]=destest.c
|
||||
@@ -606,7 +622,7 @@ IF[{- !$disabled{tests} -}]
|
||||
DEPEND[rc5test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[ec_internal_test]=ec_internal_test.c
|
||||
INCLUDE[ec_internal_test]=../include ../crypto/ec ../apps/include ../crypto/include
|
||||
INCLUDE[ec_internal_test]=../include ../crypto/ec ../apps/include
|
||||
DEPEND[ec_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[curve448_internal_test]=curve448_internal_test.c
|
||||
@@ -630,7 +646,7 @@ IF[{- !$disabled{tests} -}]
|
||||
DEPEND[bn_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[asn1_dsa_internal_test]=asn1_dsa_internal_test.c
|
||||
INCLUDE[asn1_dsa_internal_test]=.. ../include ../apps/include ../crypto/include
|
||||
INCLUDE[asn1_dsa_internal_test]=.. ../include ../apps/include
|
||||
DEPEND[asn1_dsa_internal_test]=../libcrypto.a libtestutil.a
|
||||
|
||||
SOURCE[keymgmt_internal_test]=keymgmt_internal_test.c
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICszCCAZugAwIBAgIBAjANBgkqhkiG9w0BAQsFADANMQswCQYDVQQDDAJDQTAg
|
||||
Fw0yMDA0MDMwODA0MTVaGA8yMTIwMDQwNDA4MDQxNVowGTEXMBUGA1UEAwwOc2Vy
|
||||
dmVyLmV4YW1wbGUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCo/4lY
|
||||
YYWu3tssD9Vz++K3qBt6dWAr1H08c3a1rt6TL38kkG3JHPSKOM2fooAWVsu0LLuT
|
||||
5Rcf/w3GQ/4xNPgo2HXpo7uIgu+jcuJTYgVFTeAxl++qnRDSWA2eBp4yuxsIVl1l
|
||||
Dz9mjsI2oBH/wFk1/Ukc3RxCMwZ4rgQ4I+XndWfTlK1aqUAfrFkQ9QzBZK1KxMY1
|
||||
U7OWaoIbFYvRmavknm+UqtKW5Vf7jJFkijwkFsbSGb6CYBM7YrDtPh2zyvlr3zG5
|
||||
ep5LR2inKcc/SuIiJ7TvkGPX79ByST5brbkb1Ctvhmjd1XMSuEPJ3EEPoqNGT4tn
|
||||
iIQPYf55NB9KiR+3AgMBAAGjEDAOMAwGA1UdEwQFMAMCAQAwDQYJKoZIhvcNAQEL
|
||||
BQADggEBAApOUnWWd09I0ts3xa1oK7eakc+fKTF4d7pbGznFNONaCR3KFRgnBVlG
|
||||
Bm8/oehrrQ28Ad3XPSug34DQQ5kM6JIuaddx50/n4Xkgj8/fgXVA0HXizOJ3QpKC
|
||||
IojLVajXlQHhpo72VUQuNOha0UxG9daYjS20iXRhanTm9rUz7qQZEugVQCiR0z/f
|
||||
9NgM7FU9UaSidzH3gZu/Ufc4Ggn6nZV7LM9sf4IUV+KszS1VpcK+9phAmsB6BaAi
|
||||
cFXvVXZjTNualQgPyPwOD8c+vVCIfIemfF5TZ6fyqpOjprWQAphwrTtfNDSmqRTz
|
||||
FRhDf+vJERQclgUtg37EgWGKtnNQeRY=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFGDCCBMegAwIBAgIQDIxAk7vmk71DC/UYJgMdBTAIBgYqhQMCAgMwggEWMRgw
|
||||
FgYFKoUDZAESDTEwMjc3MzkzMzQ0NzkxGjAYBggqhQMDgQMBARIMMDA3NzA2MjI4
|
||||
MjE4MTowOAYDVQQJDDHQlNC10YDQsdC10L3QtdCy0YHQutCw0Y8g0L3QsNCxLiDQ
|
||||
tC4gNyDRgdGC0YAuIDE1MR8wHQYJKoZIhvcNAQkBFhBwa2ktZ3JmY0BncmZjLnJ1
|
||||
MQswCQYDVQQGEwJSVTEcMBoGA1UECAwTNzcg0LMuINCc0L7RgdC60LLQsDEVMBMG
|
||||
A1UEBwwM0JzQvtGB0LrQstCwMRwwGgYDVQQKDBPQpNCT0KPQnyAi0JPQoNCn0KYi
|
||||
MSEwHwYDVQQDDBjQo9CmINCk0JPQo9CfICLQk9Cg0KfQpiIwHhcNMTMwMzEyMDcz
|
||||
ODI2WhcNMjgwMzEyMDc0NjAwWjCCARYxGDAWBgUqhQNkARINMTAyNzczOTMzNDQ3
|
||||
OTEaMBgGCCqFAwOBAwEBEgwwMDc3MDYyMjgyMTgxOjA4BgNVBAkMMdCU0LXRgNCx
|
||||
0LXQvdC10LLRgdC60LDRjyDQvdCw0LEuINC0LiA3INGB0YLRgC4gMTUxHzAdBgkq
|
||||
hkiG9w0BCQEWEHBraS1ncmZjQGdyZmMucnUxCzAJBgNVBAYTAlJVMRwwGgYDVQQI
|
||||
DBM3NyDQsy4g0JzQvtGB0LrQstCwMRUwEwYDVQQHDAzQnNC+0YHQutCy0LAxHDAa
|
||||
BgNVBAoME9Ck0JPQo9CfICLQk9Cg0KfQpiIxITAfBgNVBAMMGNCj0KYg0KTQk9Cj
|
||||
0J8gItCT0KDQp9CmIjBjMBwGBiqFAwICEzASBgcqhQMCAiMBBgcqhQMCAh4BA0MA
|
||||
BECWU7YnkJgff0sdJ+i50FXAYZlpcSz8wO/2AnfCzGC+PMj/NGOKMMWcv8I9eN7W
|
||||
eEXwIuRc96StDM8zJigQGd/1o4IB6TCCAeUwNgYFKoUDZG8ELQwrItCa0YDQuNC/
|
||||
0YLQvtCf0YDQviBDU1AiICjQstC10YDRgdC40Y8gMy42KTCCATMGBSqFA2RwBIIB
|
||||
KDCCASQMKyLQmtGA0LjQv9GC0L7Qn9GA0L4gQ1NQIiAo0LLQtdGA0YHQuNGPIDMu
|
||||
NikMUyLQo9C00L7RgdGC0L7QstC10YDRj9GO0YnQuNC5INGG0LXQvdGC0YAgItCa
|
||||
0YDQuNC/0YLQvtCf0YDQviDQo9CmIiDQstC10YDRgdC40LggMS41DE/QodC10YDR
|
||||
gtC40YTQuNC60LDRgiDRgdC+0L7RgtCy0LXRgtGB0YLQstC40Y8g4oSWINCh0KQv
|
||||
MTIxLTE4NTkg0L7RgiAxNy4wNi4yMDEyDE/QodC10YDRgtC40YTQuNC60LDRgiDR
|
||||
gdC+0L7RgtCy0LXRgtGB0YLQstC40Y8g4oSWINCh0KQvMTI4LTE4MjIg0L7RgiAw
|
||||
MS4wNi4yMDEyMAsGA1UdDwQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW
|
||||
BBRrAIaDidIAz1a4a+TjNhAeH3KuwzAQBgkrBgEEAYI3FQEEAwIBADAlBgNVHSAE
|
||||
HjAcMAgGBiqFA2RxATAIBgYqhQNkcQIwBgYEVR0gADAIBgYqhQMCAgMDQQC9ld1f
|
||||
Oit0pSliIMIkqIugExoh9UrWLrE/9VDplqCiyXkJFaJBwGDhHT8ljYj0TGDzD07j
|
||||
KW64bgG0AywHjyc3
|
||||
-----END CERTIFICATE-----
|
||||
+3
-1
@@ -154,7 +154,7 @@ openssl x509 -in sca-cert.pem -trustout \
|
||||
-addtrust anyExtendedKeyUsage -out sca+anyEKU.pem
|
||||
|
||||
# Primary leaf cert: ee-cert
|
||||
# ee variants: expired, issuer-key2, issuer-name2
|
||||
# ee variants: expired, issuer-key2, issuer-name2, bad-pathlen
|
||||
# trust variants: +serverAuth, -serverAuth, +clientAuth, -clientAuth
|
||||
# purpose variants: client
|
||||
#
|
||||
@@ -163,6 +163,8 @@ openssl x509 -in sca-cert.pem -trustout \
|
||||
./mkcert.sh genee server.example ee-key ee-cert2 ca-key2 ca-cert2
|
||||
./mkcert.sh genee server.example ee-key ee-name2 ca-key ca-name2
|
||||
./mkcert.sh genee -p clientAuth server.example ee-key ee-client ca-key ca-cert
|
||||
./mkcert.sh genee server.example ee-key ee-pathlen ca-key ca-cert \
|
||||
-extfile <(echo "basicConstraints=CA:FALSE,pathlen:0")
|
||||
#
|
||||
openssl x509 -in ee-cert.pem -trustout \
|
||||
-addtrust serverAuth -out ee+serverAuth.pem
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017 BaishanCloud. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License");
|
||||
@@ -431,7 +431,7 @@ static int test_cipher_name(void)
|
||||
for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) {
|
||||
c = sk_SSL_CIPHER_value(sk, i);
|
||||
id = SSL_CIPHER_get_id(c) & 0xFFFF;
|
||||
if ((id == 0xFF85) || (id == 0xFF87))
|
||||
if ((id == 0xC102) || (id == 0xFF85) ||(id == 0xFF87))
|
||||
/* skip GOST2012-GOST8912-GOST891 and GOST2012-NULL-GOST12 */
|
||||
continue;
|
||||
p = SSL_CIPHER_standard_name(c);
|
||||
|
||||
@@ -0,0 +1,393 @@
|
||||
/*
|
||||
* Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright Nokia 2007-2019
|
||||
* Copyright Siemens AG 2015-2019
|
||||
*
|
||||
* 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 "cmp_testlib.h"
|
||||
|
||||
#include "apps/cmp_mock_srv.h"
|
||||
|
||||
#ifndef NDEBUG /* tests need mock server, which is available only if !NDEBUG */
|
||||
|
||||
static const char *server_key_f;
|
||||
static const char *server_cert_f;
|
||||
static const char *client_key_f;
|
||||
static const char *client_cert_f;
|
||||
static const char *pkcs10_f;
|
||||
|
||||
typedef struct test_fixture {
|
||||
const char *test_case_name;
|
||||
OSSL_CMP_CTX *cmp_ctx;
|
||||
OSSL_CMP_SRV_CTX *srv_ctx;
|
||||
int expected;
|
||||
X509 *(*exec_cert_ses_cb) (OSSL_CMP_CTX *);
|
||||
STACK_OF(X509) *caPubs;
|
||||
} CMP_SES_TEST_FIXTURE;
|
||||
|
||||
static EVP_PKEY *server_key = NULL;
|
||||
static X509 *server_cert = NULL;
|
||||
static EVP_PKEY *client_key = NULL;
|
||||
static X509 *client_cert = NULL;
|
||||
static unsigned char ref[CMP_TEST_REFVALUE_LENGTH];
|
||||
|
||||
/*
|
||||
* For these unit tests, the client abandons message protection, and for
|
||||
* error messages the mock server does so as well.
|
||||
* Message protection and verification is tested in cmp_lib_test.c
|
||||
*/
|
||||
|
||||
static void tear_down(CMP_SES_TEST_FIXTURE *fixture)
|
||||
{
|
||||
OSSL_CMP_CTX_free(fixture->cmp_ctx);
|
||||
ossl_cmp_mock_srv_free(fixture->srv_ctx);
|
||||
sk_X509_free(fixture->caPubs);
|
||||
OPENSSL_free(fixture);
|
||||
}
|
||||
|
||||
static CMP_SES_TEST_FIXTURE *set_up(const char *const test_case_name)
|
||||
{
|
||||
CMP_SES_TEST_FIXTURE *fixture;
|
||||
OSSL_CMP_CTX *srv_cmp_ctx = NULL;
|
||||
OSSL_CMP_CTX *ctx = NULL; /* for client */
|
||||
|
||||
if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture))))
|
||||
return NULL;
|
||||
fixture->test_case_name = test_case_name;
|
||||
if (!TEST_ptr(fixture->srv_ctx = ossl_cmp_mock_srv_new())
|
||||
|| !OSSL_CMP_SRV_CTX_set_accept_unprotected(fixture->srv_ctx, 1)
|
||||
|| !ossl_cmp_mock_srv_set1_certOut(fixture->srv_ctx, client_cert)
|
||||
|| (srv_cmp_ctx =
|
||||
OSSL_CMP_SRV_CTX_get0_cmp_ctx(fixture->srv_ctx)) == NULL
|
||||
|| !OSSL_CMP_CTX_set1_clCert(srv_cmp_ctx, server_cert)
|
||||
|| !OSSL_CMP_CTX_set1_pkey(srv_cmp_ctx, server_key))
|
||||
goto err;
|
||||
if (!TEST_ptr(fixture->cmp_ctx = ctx = OSSL_CMP_CTX_new())
|
||||
|| !OSSL_CMP_CTX_set_log_cb(fixture->cmp_ctx, print_to_bio_out)
|
||||
|| !OSSL_CMP_CTX_set_transfer_cb(ctx, OSSL_CMP_CTX_server_perform)
|
||||
|| !OSSL_CMP_CTX_set_transfer_cb_arg(ctx, fixture->srv_ctx)
|
||||
|| !OSSL_CMP_CTX_set_option(ctx, OSSL_CMP_OPT_UNPROTECTED_SEND, 1)
|
||||
|| !OSSL_CMP_CTX_set_option(ctx, OSSL_CMP_OPT_UNPROTECTED_ERRORS, 1)
|
||||
|| !OSSL_CMP_CTX_set1_oldCert(ctx, client_cert)
|
||||
|| !OSSL_CMP_CTX_set1_pkey(ctx, client_key)
|
||||
|| !OSSL_CMP_CTX_set1_srvCert(ctx, server_cert)
|
||||
|| !OSSL_CMP_CTX_set1_referenceValue(ctx, ref, sizeof(ref)))
|
||||
goto err;
|
||||
fixture->exec_cert_ses_cb = NULL;
|
||||
return fixture;
|
||||
|
||||
err:
|
||||
tear_down(fixture);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int execute_exec_RR_ses_test(CMP_SES_TEST_FIXTURE *fixture)
|
||||
{
|
||||
return TEST_int_eq(fixture->expected,
|
||||
OSSL_CMP_exec_RR_ses(fixture->cmp_ctx) == client_cert);
|
||||
}
|
||||
|
||||
static int execute_exec_GENM_ses_test(CMP_SES_TEST_FIXTURE *fixture)
|
||||
{
|
||||
STACK_OF(OSSL_CMP_ITAV) *itavs = NULL;
|
||||
if (!TEST_ptr(itavs = OSSL_CMP_exec_GENM_ses(fixture->cmp_ctx)))
|
||||
return 0;
|
||||
sk_OSSL_CMP_ITAV_pop_free(itavs, OSSL_CMP_ITAV_free);
|
||||
/* TODO: check if the returned value is the expected one (same as sent) */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int execute_exec_certrequest_ses_test(CMP_SES_TEST_FIXTURE *fixture)
|
||||
{
|
||||
X509 *res;
|
||||
|
||||
if (fixture->expected == 0)
|
||||
return TEST_ptr_null(fixture->exec_cert_ses_cb(fixture->cmp_ctx));
|
||||
|
||||
if (!TEST_ptr(res = fixture->exec_cert_ses_cb(fixture->cmp_ctx))
|
||||
|| !TEST_int_eq(X509_cmp(res, client_cert), 0))
|
||||
return 0;
|
||||
/* TODO: check that cerfConf has been exchanged unless implicitConfirm */
|
||||
if (fixture->caPubs != NULL) {
|
||||
STACK_OF(X509) *caPubs = OSSL_CMP_CTX_get1_caPubs(fixture->cmp_ctx);
|
||||
int ret = TEST_int_eq(STACK_OF_X509_cmp(fixture->caPubs, caPubs), 0);
|
||||
|
||||
sk_X509_pop_free(caPubs, X509_free);
|
||||
return ret;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int test_exec_RR_ses(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
fixture->expected = 1;
|
||||
EXECUTE_TEST(execute_exec_RR_ses_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_exec_RR_ses_receive_error(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
ossl_cmp_mock_srv_set_statusInfo(fixture->srv_ctx,
|
||||
OSSL_CMP_PKISTATUS_rejection,
|
||||
OSSL_CMP_CTX_FAILINFO_signerNotTrusted,
|
||||
"test string");
|
||||
ossl_cmp_mock_srv_set_send_error(fixture->srv_ctx, 1);
|
||||
fixture->expected = 0;
|
||||
EXECUTE_TEST(execute_exec_RR_ses_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_exec_IR_ses(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
fixture->exec_cert_ses_cb = OSSL_CMP_exec_IR_ses;
|
||||
fixture->expected = 1;
|
||||
fixture->caPubs = sk_X509_new_null();
|
||||
sk_X509_push(fixture->caPubs, server_cert);
|
||||
sk_X509_push(fixture->caPubs, server_cert);
|
||||
ossl_cmp_mock_srv_set1_caPubsOut(fixture->srv_ctx, fixture->caPubs);
|
||||
EXECUTE_TEST(execute_exec_certrequest_ses_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
static const int checkAfter = 1;
|
||||
static int test_exec_IR_ses_poll(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
fixture->exec_cert_ses_cb = OSSL_CMP_exec_IR_ses;
|
||||
fixture->expected = 1;
|
||||
ossl_cmp_mock_srv_set_pollCount(fixture->srv_ctx, 2);
|
||||
ossl_cmp_mock_srv_set_checkAfterTime(fixture->srv_ctx, checkAfter);
|
||||
EXECUTE_TEST(execute_exec_certrequest_ses_test, tear_down);
|
||||
/* TODO: check that 2 rounds are done or session takes 2..3 seconds */
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_exec_IR_ses_poll_timeout(void)
|
||||
{
|
||||
const int pollCount = 3;
|
||||
const int tout = pollCount * checkAfter;
|
||||
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
fixture->exec_cert_ses_cb = OSSL_CMP_exec_IR_ses;
|
||||
fixture->expected = 0;
|
||||
ossl_cmp_mock_srv_set_pollCount(fixture->srv_ctx, pollCount + 1);
|
||||
ossl_cmp_mock_srv_set_checkAfterTime(fixture->srv_ctx, checkAfter);
|
||||
OSSL_CMP_CTX_set_option(fixture->cmp_ctx, OSSL_CMP_OPT_TOTAL_TIMEOUT, tout);
|
||||
EXECUTE_TEST(execute_exec_certrequest_ses_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static int test_exec_CR_ses(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
fixture->exec_cert_ses_cb = OSSL_CMP_exec_CR_ses;
|
||||
fixture->expected = 1;
|
||||
EXECUTE_TEST(execute_exec_certrequest_ses_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_exec_CR_ses_implicit_confirm(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
fixture->exec_cert_ses_cb = OSSL_CMP_exec_CR_ses;
|
||||
fixture->expected = 1;
|
||||
OSSL_CMP_CTX_set_option(fixture->cmp_ctx,
|
||||
OSSL_CMP_OPT_IMPLICIT_CONFIRM, 1);
|
||||
OSSL_CMP_SRV_CTX_set_grant_implicit_confirm(fixture->srv_ctx, 1);
|
||||
EXECUTE_TEST(execute_exec_certrequest_ses_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_exec_KUR_ses(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
fixture->exec_cert_ses_cb = OSSL_CMP_exec_KUR_ses;
|
||||
fixture->expected = 1;
|
||||
EXECUTE_TEST(execute_exec_certrequest_ses_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_exec_P10CR_ses(void)
|
||||
{
|
||||
X509_REQ *req = NULL;
|
||||
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
fixture->exec_cert_ses_cb = OSSL_CMP_exec_P10CR_ses;
|
||||
fixture->expected = 1;
|
||||
if (!TEST_ptr(req = load_csr(pkcs10_f))
|
||||
|| !TEST_true(OSSL_CMP_CTX_set1_p10CSR(fixture->cmp_ctx, req))) {
|
||||
tear_down(fixture);
|
||||
fixture = NULL;
|
||||
}
|
||||
X509_REQ_free(req);
|
||||
EXECUTE_TEST(execute_exec_certrequest_ses_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int execute_try_certreq_poll_test(CMP_SES_TEST_FIXTURE *fixture)
|
||||
{
|
||||
OSSL_CMP_CTX *ctx = fixture->cmp_ctx;
|
||||
int check_after;
|
||||
const int CHECK_AFTER = 5;
|
||||
const int TYPE = OSSL_CMP_KUR;
|
||||
|
||||
ossl_cmp_mock_srv_set_pollCount(fixture->srv_ctx, 3);
|
||||
ossl_cmp_mock_srv_set_checkAfterTime(fixture->srv_ctx, CHECK_AFTER);
|
||||
return TEST_int_eq(-1, OSSL_CMP_try_certreq(ctx, TYPE, &check_after))
|
||||
&& check_after == CHECK_AFTER
|
||||
&& TEST_ptr_eq(OSSL_CMP_CTX_get0_newCert(ctx), NULL)
|
||||
&& TEST_int_eq(-1, OSSL_CMP_try_certreq(ctx, TYPE, &check_after))
|
||||
&& check_after == CHECK_AFTER
|
||||
&& TEST_ptr_eq(OSSL_CMP_CTX_get0_newCert(ctx), NULL)
|
||||
&& TEST_int_eq(fixture->expected, OSSL_CMP_try_certreq(ctx, TYPE, NULL))
|
||||
&& TEST_int_eq(0, X509_cmp(OSSL_CMP_CTX_get0_newCert(ctx), client_cert));
|
||||
}
|
||||
|
||||
static int test_try_certreq_poll(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
fixture->expected = 1;
|
||||
EXECUTE_TEST(execute_try_certreq_poll_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int execute_try_certreq_poll_abort_test(CMP_SES_TEST_FIXTURE *fixture)
|
||||
{
|
||||
OSSL_CMP_CTX *ctx = fixture->cmp_ctx;
|
||||
int check_after;
|
||||
const int CHECK_AFTER = INT_MAX;
|
||||
const int TYPE = OSSL_CMP_CR;
|
||||
|
||||
ossl_cmp_mock_srv_set_pollCount(fixture->srv_ctx, 3);
|
||||
ossl_cmp_mock_srv_set_checkAfterTime(fixture->srv_ctx, CHECK_AFTER);
|
||||
return TEST_int_eq(-1, OSSL_CMP_try_certreq(ctx, TYPE, &check_after))
|
||||
&& check_after == CHECK_AFTER
|
||||
&& TEST_ptr_eq(OSSL_CMP_CTX_get0_newCert(ctx), NULL)
|
||||
&& TEST_int_eq(fixture->expected, OSSL_CMP_try_certreq(ctx, -1, NULL))
|
||||
&& TEST_ptr_eq(OSSL_CMP_CTX_get0_newCert(fixture->cmp_ctx), NULL);
|
||||
}
|
||||
|
||||
static int test_try_certreq_poll_abort(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
fixture->expected = 1;
|
||||
EXECUTE_TEST(execute_try_certreq_poll_abort_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_exec_GENM_ses(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
EXECUTE_TEST(execute_exec_GENM_ses_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int execute_exchange_certConf_test(CMP_SES_TEST_FIXTURE *fixture)
|
||||
{
|
||||
int res =
|
||||
ossl_cmp_exchange_certConf(fixture->cmp_ctx,
|
||||
OSSL_CMP_PKIFAILUREINFO_addInfoNotAvailable,
|
||||
"abcdefg");
|
||||
return TEST_int_eq(fixture->expected, res);
|
||||
}
|
||||
|
||||
static int execute_exchange_error_test(CMP_SES_TEST_FIXTURE *fixture)
|
||||
{
|
||||
int res =
|
||||
ossl_cmp_exchange_error(fixture->cmp_ctx,
|
||||
OSSL_CMP_PKISTATUS_rejection,
|
||||
1 << OSSL_CMP_PKIFAILUREINFO_unsupportedVersion,
|
||||
"foo_status", 999, "foo_details");
|
||||
|
||||
return TEST_int_eq(fixture->expected, res);
|
||||
}
|
||||
|
||||
static int test_exchange_certConf(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
fixture->expected = 0; /* client should not send certConf immediately */
|
||||
if (!ossl_cmp_ctx_set0_newCert(fixture->cmp_ctx, X509_dup(client_cert))) {
|
||||
tear_down(fixture);
|
||||
fixture = NULL;
|
||||
}
|
||||
EXECUTE_TEST(execute_exchange_certConf_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_exchange_error(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
|
||||
fixture->expected = 1; /* client may send error any time */
|
||||
EXECUTE_TEST(execute_exchange_error_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
X509_free(server_cert);
|
||||
EVP_PKEY_free(server_key);
|
||||
X509_free(client_cert);
|
||||
EVP_PKEY_free(client_key);
|
||||
return;
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (!test_skip_common_options()) {
|
||||
TEST_error("Error parsing test options\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!TEST_ptr(server_key_f = test_get_argument(0))
|
||||
|| !TEST_ptr(server_cert_f = test_get_argument(1))
|
||||
|| !TEST_ptr(client_key_f = test_get_argument(2))
|
||||
|| !TEST_ptr(client_cert_f = test_get_argument(3))
|
||||
|| !TEST_ptr(pkcs10_f = test_get_argument(4))) {
|
||||
TEST_error("usage: cmp_client_test server.key server.crt client.key client.crt client.csr\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!TEST_ptr(server_key = load_pem_key(server_key_f))
|
||||
|| !TEST_ptr(server_cert = load_pem_cert(server_cert_f))
|
||||
|| !TEST_ptr(client_key = load_pem_key(client_key_f))
|
||||
|| !TEST_ptr(client_cert = load_pem_cert(client_cert_f))
|
||||
|| !TEST_int_eq(1, RAND_bytes(ref, sizeof(ref)))) {
|
||||
cleanup_tests();
|
||||
return 0;
|
||||
}
|
||||
|
||||
ADD_TEST(test_exec_RR_ses);
|
||||
ADD_TEST(test_exec_RR_ses_receive_error);
|
||||
ADD_TEST(test_exec_CR_ses);
|
||||
ADD_TEST(test_exec_CR_ses_implicit_confirm);
|
||||
ADD_TEST(test_exec_IR_ses);
|
||||
ADD_TEST(test_exec_IR_ses_poll);
|
||||
ADD_TEST(test_exec_IR_ses_poll_timeout);
|
||||
ADD_TEST(test_exec_KUR_ses);
|
||||
ADD_TEST(test_exec_P10CR_ses);
|
||||
ADD_TEST(test_try_certreq_poll);
|
||||
ADD_TEST(test_try_certreq_poll_abort);
|
||||
ADD_TEST(test_exec_GENM_ses);
|
||||
ADD_TEST(test_exchange_certConf);
|
||||
ADD_TEST(test_exchange_error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else /* !defined (NDEBUG) */
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
TEST_note("CMP session tests are disabled in this build (NDEBUG).");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
+14
-14
@@ -118,6 +118,7 @@ static int msg_total_size_log_cb(const char *func, const char *file, int line,
|
||||
OSSL_CMP_severity level, const char *msg)
|
||||
{
|
||||
msg_total_size += strlen(msg);
|
||||
TEST_note("total=%d len=%zu msg='%s'\n", msg_total_size, strlen(msg), msg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -491,7 +492,6 @@ static X509_STORE *X509_STORE_new_1(void)
|
||||
|
||||
#define IS_NEG(x) ((x) < 0)
|
||||
#define IS_0(x) ((x) == 0) /* for any type */
|
||||
#define IS_DEFAULT_PORT(x) ((x) == OSSL_CMP_DEFAULT_PORT)
|
||||
#define DROP(x) (void)(x) /* dummy free() for non-pointer and function types */
|
||||
|
||||
#define ERR(x) (CMPerr(0, CMP_R_NULL_ARGUMENT), x)
|
||||
@@ -519,7 +519,7 @@ static X509_STORE *X509_STORE_new_1(void)
|
||||
#define DEFINE_SET_TEST_DEFAULT(OSSL_CMP, CTX, N, DUP, FIELD, TYPE, DEFAULT) \
|
||||
static TYPE *OSSL_CMP_CTX_get0_##FIELD(const CMP_CTX *ctx) \
|
||||
{ \
|
||||
return ctx == NULL ? ERR(NULL) : ctx->FIELD; \
|
||||
return ctx == NULL ? ERR(NULL) : (TYPE *)ctx->FIELD; \
|
||||
} \
|
||||
DEFINE_SET_GET_TEST_DEFAULT(OSSL_CMP, CTX, N, 0, DUP, FIELD, TYPE, DEFAULT)
|
||||
#define DEFINE_SET_TEST(OSSL_CMP, CTX, N, DUP, FIELD, TYPE) \
|
||||
@@ -534,16 +534,16 @@ static X509_STORE *X509_STORE_new_1(void)
|
||||
STACK_OF(TYPE)*, NULL, IS_0, \
|
||||
sk_##TYPE##_new_null(), sk_##TYPE##_free)
|
||||
|
||||
typedef OSSL_HTTP_bio_cb_t OSSL_cmp_http_cb_t;
|
||||
typedef OSSL_HTTP_bio_cb_t OSSL_CMP_http_cb_t;
|
||||
#define DEFINE_SET_CB_TEST(FIELD) \
|
||||
static OSSL_cmp_##FIELD##_t OSSL_CMP_CTX_get_##FIELD(const CMP_CTX *ctx) \
|
||||
static OSSL_CMP_##FIELD##_t OSSL_CMP_CTX_get_##FIELD(const CMP_CTX *ctx) \
|
||||
{ \
|
||||
if (ctx == NULL) \
|
||||
CMPerr(0, CMP_R_NULL_ARGUMENT); \
|
||||
return ctx == NULL ? NULL /* cannot use ERR(NULL) here */ : ctx->FIELD;\
|
||||
} \
|
||||
DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set, get, 0, FIELD, \
|
||||
OSSL_cmp_##FIELD##_t, NULL, IS_0, \
|
||||
OSSL_CMP_##FIELD##_t, NULL, IS_0, \
|
||||
test_##FIELD, DROP)
|
||||
#define DEFINE_SET_GET_P_VOID_TEST(FIELD) \
|
||||
DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set, get, 0, FIELD, void *, \
|
||||
@@ -554,12 +554,12 @@ typedef OSSL_HTTP_bio_cb_t OSSL_cmp_http_cb_t;
|
||||
DEFAULT, 1, DROP)
|
||||
#define DEFINE_SET_GET_INT_TEST(OSSL_CMP, CTX, FIELD) \
|
||||
DEFINE_SET_GET_INT_TEST_DEFAULT(OSSL_CMP, CTX, FIELD, IS_NEG)
|
||||
#define DEFINE_SET_PORT_TEST(FIELD) \
|
||||
#define DEFINE_SET_INT_TEST(FIELD) \
|
||||
static int OSSL_CMP_CTX_get_##FIELD(const CMP_CTX *ctx) \
|
||||
{ \
|
||||
return ctx == NULL ? ERR(-1) : ctx->FIELD; \
|
||||
} \
|
||||
DEFINE_SET_GET_INT_TEST_DEFAULT(OSSL_CMP, CTX, FIELD, IS_DEFAULT_PORT)
|
||||
DEFINE_SET_GET_INT_TEST_DEFAULT(OSSL_CMP, CTX, FIELD, IS_0)
|
||||
|
||||
#define DEFINE_SET_GET_ARG_FN(SETN, GETN, FIELD, ARG, T) \
|
||||
static int OSSL_CMP_CTX_##SETN##_##FIELD##_##ARG(CMP_CTX *ctx, T val) \
|
||||
@@ -715,10 +715,10 @@ DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set, get, 0, option_16, int, -1, IS_0, \
|
||||
DEFINE_SET_CB_TEST(log_cb)
|
||||
|
||||
DEFINE_SET_TEST_DEFAULT(OSSL_CMP, CTX, 1, 1, serverPath, char, IS_0)
|
||||
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, serverName, char)
|
||||
DEFINE_SET_PORT_TEST(serverPort)
|
||||
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, proxyName, char)
|
||||
DEFINE_SET_PORT_TEST(proxyPort)
|
||||
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, server, char)
|
||||
DEFINE_SET_INT_TEST(serverPort)
|
||||
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, proxy, char)
|
||||
DEFINE_SET_TEST(OSSL_CMP, CTX, 1, 1, no_proxy, char)
|
||||
DEFINE_SET_CB_TEST(http_cb)
|
||||
DEFINE_SET_GET_P_VOID_TEST(http_cb_arg)
|
||||
DEFINE_SET_CB_TEST(transfer_cb)
|
||||
@@ -800,10 +800,10 @@ int setup_tests(void)
|
||||
#endif
|
||||
/* message transfer: */
|
||||
ADD_TEST(test_CTX_set1_get0_serverPath);
|
||||
ADD_TEST(test_CTX_set1_get0_serverName);
|
||||
ADD_TEST(test_CTX_set1_get0_server);
|
||||
ADD_TEST(test_CTX_set_get_serverPort);
|
||||
ADD_TEST(test_CTX_set1_get0_proxyName);
|
||||
ADD_TEST(test_CTX_set_get_proxyPort);
|
||||
ADD_TEST(test_CTX_set1_get0_proxy);
|
||||
ADD_TEST(test_CTX_set1_get0_no_proxy);
|
||||
ADD_TEST(test_CTX_set_get_http_cb);
|
||||
ADD_TEST(test_CTX_set_get_http_cb_arg);
|
||||
ADD_TEST(test_CTX_set_get_transfer_cb);
|
||||
|
||||
+4
-13
@@ -350,9 +350,9 @@ static int
|
||||
execute_HDR_set_and_check_implicitConfirm_test(CMP_HDR_TEST_FIXTURE
|
||||
* fixture)
|
||||
{
|
||||
return TEST_false(ossl_cmp_hdr_check_implicitConfirm(fixture->hdr))
|
||||
return TEST_false(ossl_cmp_hdr_has_implicitConfirm(fixture->hdr))
|
||||
&& TEST_true(ossl_cmp_hdr_set_implicitConfirm(fixture->hdr))
|
||||
&& TEST_true(ossl_cmp_hdr_check_implicitConfirm(fixture->hdr));
|
||||
&& TEST_true(ossl_cmp_hdr_has_implicitConfirm(fixture->hdr));
|
||||
}
|
||||
|
||||
static int test_HDR_set_and_check_implicit_confirm(void)
|
||||
@@ -397,7 +397,7 @@ static int execute_HDR_init_test(CMP_HDR_TEST_FIXTURE *fixture)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int test_HDR_init(void)
|
||||
static int test_HDR_init_with_ref(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_HDR_TEST_FIXTURE, set_up);
|
||||
unsigned char ref[CMP_TEST_REFVALUE_LENGTH];
|
||||
@@ -431,14 +431,6 @@ static int test_HDR_init_with_subject(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_HDR_init_no_ref_no_subject(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_HDR_TEST_FIXTURE, set_up);
|
||||
fixture->expected = 0;
|
||||
EXECUTE_TEST(execute_HDR_init_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
@@ -464,9 +456,8 @@ int setup_tests(void)
|
||||
/* also tests public function OSSL_CMP_HDR_get0_transactionID(): */
|
||||
/* also tests public function OSSL_CMP_HDR_get0_recipNonce(): */
|
||||
/* also tests internal function ossl_cmp_hdr_get_pvno(): */
|
||||
ADD_TEST(test_HDR_init);
|
||||
ADD_TEST(test_HDR_init_with_ref);
|
||||
ADD_TEST(test_HDR_init_with_subject);
|
||||
ADD_TEST(test_HDR_init_no_ref_no_subject);
|
||||
/*
|
||||
* TODO make sure that total number of tests (here currently 24) is shown,
|
||||
* also for other cmp_*text.c. Currently the test drivers always show 1.
|
||||
|
||||
+6
-8
@@ -91,8 +91,7 @@ static int execute_errormsg_create_test(CMP_MSG_TEST_FIXTURE *fixture)
|
||||
{
|
||||
EXECUTE_MSG_CREATION_TEST(ossl_cmp_error_new(fixture->cmp_ctx, fixture->si,
|
||||
fixture->err_code,
|
||||
NULL /* fixture->free_text */,
|
||||
0));
|
||||
"details", 0));
|
||||
}
|
||||
|
||||
static int execute_rr_create_test(CMP_MSG_TEST_FIXTURE *fixture)
|
||||
@@ -163,6 +162,7 @@ static int test_cmp_create_ir_protection_fails(void)
|
||||
fixture->expected = 0;
|
||||
if (!TEST_true(OSSL_CMP_CTX_set1_pkey(fixture->cmp_ctx, newkey))
|
||||
|| !TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0))
|
||||
/* newkey used by default for signing does not match cert: */
|
||||
|| !TEST_true(OSSL_CMP_CTX_set1_clCert(fixture->cmp_ctx, cert))) {
|
||||
tear_down(fixture);
|
||||
fixture = NULL;
|
||||
@@ -317,7 +317,7 @@ static int test_cmp_create_certconf_fail_info_max(void)
|
||||
static int test_cmp_create_error_msg(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_MSG_TEST_FIXTURE, set_up);
|
||||
fixture->si = ossl_cmp_statusinfo_new(OSSL_CMP_PKISTATUS_rejection,
|
||||
fixture->si = OSSL_CMP_STATUSINFO_new(OSSL_CMP_PKISTATUS_rejection,
|
||||
OSSL_CMP_PKIFAILUREINFO_systemFailure,
|
||||
NULL);
|
||||
fixture->err_code = -1;
|
||||
@@ -358,8 +358,7 @@ static int test_cmp_create_genm(void)
|
||||
SETUP_TEST_FIXTURE(CMP_MSG_TEST_FIXTURE, set_up);
|
||||
fixture->expected = 1;
|
||||
iv = OSSL_CMP_ITAV_create(OBJ_nid2obj(NID_id_it_implicitConfirm), NULL);
|
||||
if (!TEST_true(SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 1))
|
||||
|| !TEST_ptr(iv)
|
||||
if (!TEST_ptr(iv)
|
||||
|| !TEST_true(OSSL_CMP_CTX_push0_genm_ITAV(fixture->cmp_ctx, iv))) {
|
||||
OSSL_CMP_ITAV_free(iv);
|
||||
tear_down(fixture);
|
||||
@@ -419,7 +418,7 @@ static int test_cmp_create_certrep(void)
|
||||
|
||||
static int execute_rp_create(CMP_MSG_TEST_FIXTURE *fixture)
|
||||
{
|
||||
OSSL_CMP_PKISI *si = ossl_cmp_statusinfo_new(33, 44, "a text");
|
||||
OSSL_CMP_PKISI *si = OSSL_CMP_STATUSINFO_new(33, 44, "a text");
|
||||
X509_NAME *issuer = X509_NAME_new();
|
||||
ASN1_INTEGER *serial = ASN1_INTEGER_new();
|
||||
OSSL_CRMF_CERTID *cid = NULL;
|
||||
@@ -439,8 +438,7 @@ static int execute_rp_create(CMP_MSG_TEST_FIXTURE *fixture)
|
||||
if (!TEST_ptr(ossl_cmp_revrepcontent_get_CertId(rpmsg->body->value.rp, 0)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(ossl_cmp_revrepcontent_get_pkistatusinfo(rpmsg->body->
|
||||
value.rp, 0)))
|
||||
if (!TEST_ptr(ossl_cmp_revrepcontent_get_pkisi(rpmsg->body->value.rp, 0)))
|
||||
goto err;
|
||||
|
||||
res = 1;
|
||||
|
||||
+34
-1
@@ -278,6 +278,38 @@ static int test_MSG_protect_no_key_no_secret(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_MSG_protect_pbmac_no_sender(int with_ref)
|
||||
{
|
||||
static unsigned char secret[] = { 47, 11, 8, 15 };
|
||||
static unsigned char ref[] = { 0xca, 0xfe, 0xba, 0xbe };
|
||||
|
||||
SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up);
|
||||
fixture->expected = with_ref;
|
||||
if (!TEST_ptr(fixture->msg = OSSL_CMP_MSG_dup(ir_unprotected))
|
||||
|| !SET_OPT_UNPROTECTED_SEND(fixture->cmp_ctx, 0)
|
||||
|| !ossl_cmp_hdr_set1_sender(fixture->msg->header, NULL)
|
||||
|| !OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx,
|
||||
secret, sizeof(secret))
|
||||
|| (!OSSL_CMP_CTX_set1_referenceValue(fixture->cmp_ctx,
|
||||
with_ref ? ref : NULL,
|
||||
sizeof(ref)))) {
|
||||
tear_down(fixture);
|
||||
fixture = NULL;
|
||||
}
|
||||
EXECUTE_TEST(execute_MSG_protect_test, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_MSG_protect_pbmac_no_sender_with_ref(void)
|
||||
{
|
||||
return test_MSG_protect_pbmac_no_sender(1);
|
||||
}
|
||||
|
||||
static int test_MSG_protect_pbmac_no_sender_no_ref(void)
|
||||
{
|
||||
return test_MSG_protect_pbmac_no_sender(0);
|
||||
}
|
||||
|
||||
static int execute_MSG_add_extraCerts_test(CMP_PROTECT_TEST_FIXTURE *fixture)
|
||||
{
|
||||
return TEST_true(ossl_cmp_msg_add_extraCerts(fixture->cmp_ctx,
|
||||
@@ -511,7 +543,8 @@ int setup_tests(void)
|
||||
ADD_TEST(test_MSG_protect_certificate_based_without_cert);
|
||||
ADD_TEST(test_MSG_protect_unprotected_request);
|
||||
ADD_TEST(test_MSG_protect_no_key_no_secret);
|
||||
|
||||
ADD_TEST(test_MSG_protect_pbmac_no_sender_with_ref);
|
||||
ADD_TEST(test_MSG_protect_pbmac_no_sender_no_ref);
|
||||
ADD_TEST(test_MSG_add_extraCerts);
|
||||
|
||||
#ifndef OPENSSL_NO_EC
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright Nokia 2007-2020
|
||||
* Copyright Siemens AG 2015-2020
|
||||
*
|
||||
* 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 "cmp_testlib.h"
|
||||
|
||||
typedef struct test_fixture {
|
||||
const char *test_case_name;
|
||||
int expected;
|
||||
OSSL_CMP_SRV_CTX *srv_ctx;
|
||||
OSSL_CMP_MSG *req;
|
||||
} CMP_SRV_TEST_FIXTURE;
|
||||
|
||||
static OSSL_CMP_MSG *request = NULL;
|
||||
|
||||
static void tear_down(CMP_SRV_TEST_FIXTURE *fixture)
|
||||
{
|
||||
OSSL_CMP_SRV_CTX_free(fixture->srv_ctx);
|
||||
OPENSSL_free(fixture);
|
||||
}
|
||||
|
||||
static CMP_SRV_TEST_FIXTURE *set_up(const char *const test_case_name)
|
||||
{
|
||||
CMP_SRV_TEST_FIXTURE *fixture;
|
||||
|
||||
if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture))))
|
||||
return NULL;
|
||||
fixture->test_case_name = test_case_name;
|
||||
if (!TEST_ptr(fixture->srv_ctx = OSSL_CMP_SRV_CTX_new()))
|
||||
goto err;
|
||||
return fixture;
|
||||
|
||||
err:
|
||||
tear_down(fixture);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int dummy_errorCode = CMP_R_MULTIPLE_SAN_SOURCES; /* any reason code */
|
||||
|
||||
static OSSL_CMP_PKISI *process_cert_request(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||
const OSSL_CMP_MSG *cert_req,
|
||||
int certReqId,
|
||||
const OSSL_CRMF_MSG *crm,
|
||||
const X509_REQ *p10cr,
|
||||
X509 **certOut,
|
||||
STACK_OF(X509) **chainOut,
|
||||
STACK_OF(X509) **caPubs)
|
||||
{
|
||||
CMPerr(0, dummy_errorCode);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int execute_test_handle_request(CMP_SRV_TEST_FIXTURE *fixture)
|
||||
{
|
||||
OSSL_CMP_SRV_CTX *ctx = fixture->srv_ctx;
|
||||
OSSL_CMP_CTX *client_ctx;
|
||||
OSSL_CMP_CTX *cmp_ctx;
|
||||
char *dummy_custom_ctx = "@test_dummy", *custom_ctx;
|
||||
OSSL_CMP_MSG *rsp = NULL;
|
||||
OSSL_CMP_ERRORMSGCONTENT *errorContent;
|
||||
int res = 0;
|
||||
|
||||
if (!TEST_ptr(client_ctx = OSSL_CMP_CTX_new())
|
||||
|| !TEST_true(OSSL_CMP_CTX_set_transfer_cb_arg(client_ctx, ctx)))
|
||||
goto end;
|
||||
|
||||
if (!TEST_true(OSSL_CMP_SRV_CTX_init(ctx, dummy_custom_ctx,
|
||||
process_cert_request, NULL, NULL,
|
||||
NULL, NULL, NULL))
|
||||
|| !TEST_ptr(custom_ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(ctx))
|
||||
|| !TEST_int_eq(strcmp(custom_ctx, dummy_custom_ctx), 0))
|
||||
goto end;
|
||||
|
||||
if (!TEST_true(OSSL_CMP_SRV_CTX_set_send_unprotected_errors(ctx, 0))
|
||||
|| !TEST_true(OSSL_CMP_SRV_CTX_set_accept_unprotected(ctx, 0))
|
||||
|| !TEST_true(OSSL_CMP_SRV_CTX_set_accept_raverified(ctx, 1))
|
||||
|| !TEST_true(OSSL_CMP_SRV_CTX_set_grant_implicit_confirm(ctx, 1)))
|
||||
goto end;
|
||||
|
||||
if (!TEST_ptr(cmp_ctx = OSSL_CMP_SRV_CTX_get0_cmp_ctx(ctx))
|
||||
|| !OSSL_CMP_CTX_set1_referenceValue(cmp_ctx,
|
||||
(unsigned char *)"server", 6)
|
||||
|| !OSSL_CMP_CTX_set1_secretValue(cmp_ctx,
|
||||
(unsigned char *)"1234", 4))
|
||||
goto end;
|
||||
|
||||
if (!TEST_ptr(rsp = OSSL_CMP_CTX_server_perform(client_ctx, fixture->req))
|
||||
|| !TEST_int_eq(ossl_cmp_msg_get_bodytype(rsp),
|
||||
OSSL_CMP_PKIBODY_ERROR)
|
||||
|| !TEST_ptr(errorContent = rsp->body->value.error)
|
||||
|| !TEST_int_eq(ASN1_INTEGER_get(errorContent->errorCode),
|
||||
dummy_errorCode))
|
||||
goto end;
|
||||
|
||||
res = 1;
|
||||
|
||||
end:
|
||||
OSSL_CMP_MSG_free(rsp);
|
||||
OSSL_CMP_CTX_free(client_ctx);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int test_handle_request(void)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_SRV_TEST_FIXTURE, set_up);
|
||||
fixture->req = request;
|
||||
fixture->expected = 1;
|
||||
EXECUTE_TEST(execute_test_handle_request, tear_down);
|
||||
return result;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
OSSL_CMP_MSG_free(request);
|
||||
return;
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
const char *request_f;
|
||||
|
||||
if (!test_skip_common_options()) {
|
||||
TEST_error("Error parsing test options\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!TEST_ptr(request_f = test_get_argument(0))) {
|
||||
TEST_error("usage: cmp_server_test CR_protected_PBM_1234.der\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!TEST_ptr(request = load_pkimsg(request_f))) {
|
||||
cleanup_tests();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* this (indirectly) calls
|
||||
* OSSL_CMP_SRV_CTX_new(),
|
||||
* OSSL_CMP_SRV_CTX_free(),
|
||||
* OSSL_CMP_CTX_server_perform(),
|
||||
* OSSL_CMP_SRV_process_request(),
|
||||
* OSSL_CMP_SRV_CTX_init(),
|
||||
* OSSL_CMP_SRV_CTX_get0_cmp_ctx(),
|
||||
* OSSL_CMP_SRV_CTX_get0_custom_ctx(),
|
||||
* OSSL_CMP_SRV_CTX_set_send_unprotected_errors(),
|
||||
* OSSL_CMP_SRV_CTX_set_accept_unprotected(),
|
||||
* OSSL_CMP_SRV_CTX_set_accept_raverified(), and
|
||||
* OSSL_CMP_SRV_CTX_set_grant_implicit_confirm()
|
||||
*/
|
||||
ADD_TEST(test_handle_request);
|
||||
return 1;
|
||||
}
|
||||
@@ -45,18 +45,18 @@ static int execute_PKISI_test(CMP_STATUS_TEST_FIXTURE *fixture)
|
||||
ASN1_UTF8STRING *statusString = NULL;
|
||||
int res = 0, i;
|
||||
|
||||
if (!TEST_ptr(si = ossl_cmp_statusinfo_new(fixture->pkistatus,
|
||||
if (!TEST_ptr(si = OSSL_CMP_STATUSINFO_new(fixture->pkistatus,
|
||||
fixture->pkifailure,
|
||||
fixture->text)))
|
||||
goto end;
|
||||
|
||||
status = ossl_cmp_pkisi_get_pkistatus(si);
|
||||
status = ossl_cmp_pkisi_get_status(si);
|
||||
if (!TEST_int_eq(fixture->pkistatus, status)
|
||||
|| !TEST_str_eq(fixture->str, ossl_cmp_PKIStatus_to_string(status)))
|
||||
goto end;
|
||||
|
||||
if (!TEST_ptr(statusString =
|
||||
sk_ASN1_UTF8STRING_value(ossl_cmp_pkisi_get0_statusstring(si),
|
||||
sk_ASN1_UTF8STRING_value(ossl_cmp_pkisi_get0_statusString(si),
|
||||
0))
|
||||
|| !TEST_str_eq(fixture->text, (char *)statusString->data))
|
||||
goto end;
|
||||
@@ -66,7 +66,7 @@ static int execute_PKISI_test(CMP_STATUS_TEST_FIXTURE *fixture)
|
||||
goto end;
|
||||
for (i = 0; i <= OSSL_CMP_PKIFAILUREINFO_MAX; i++)
|
||||
if (!TEST_int_eq((fixture->pkifailure >> i) & 1,
|
||||
ossl_cmp_pkisi_pkifailureinfo_check(si, i)))
|
||||
ossl_cmp_pkisi_check_pkifailureinfo(si, i)))
|
||||
goto end;
|
||||
|
||||
res = 1;
|
||||
@@ -99,12 +99,12 @@ int setup_tests(void)
|
||||
{
|
||||
/*-
|
||||
* this tests all of:
|
||||
* ossl_cmp_statusinfo_new()
|
||||
* ossl_cmp_pkisi_get_pkistatus()
|
||||
* OSSL_CMP_STATUSINFO_new()
|
||||
* ossl_cmp_pkisi_get_status()
|
||||
* ossl_cmp_PKIStatus_to_string()
|
||||
* ossl_cmp_pkisi_get0_statusstring()
|
||||
* ossl_cmp_pkisi_get0_statusString()
|
||||
* ossl_cmp_pkisi_get_pkifailureinfo()
|
||||
* ossl_cmp_pkisi_pkifailureinfo_check()
|
||||
* ossl_cmp_pkisi_check_pkifailureinfo()
|
||||
*/
|
||||
ADD_TEST(test_PKISI);
|
||||
return 1;
|
||||
|
||||
@@ -126,3 +126,9 @@ int STACK_OF_X509_push1(STACK_OF(X509) *sk, X509 *cert)
|
||||
X509_free(cert); /* down-ref */
|
||||
return res;
|
||||
}
|
||||
|
||||
int print_to_bio_out(const char *func, const char *file, int line,
|
||||
OSSL_CMP_severity level, const char *msg)
|
||||
{
|
||||
return OSSL_CMP_print_to_bio(bio_out, func, file, line, level, msg);
|
||||
}
|
||||
@@ -30,6 +30,8 @@ int valid_asn1_encoding(const OSSL_CMP_MSG *msg);
|
||||
EVP_PKEY *gen_rsa(void);
|
||||
int STACK_OF_X509_cmp(const STACK_OF(X509) *sk1, const STACK_OF(X509) *sk2);
|
||||
int STACK_OF_X509_push1(STACK_OF(X509) *sk, X509 *cert);
|
||||
int print_to_bio_out(const char *func, const char *file, int line,
|
||||
OSSL_CMP_severity level, const char *msg);
|
||||
# endif
|
||||
|
||||
#endif /* OSSL_TEST_CMP_TESTLIB_H */
|
||||
+8
-10
@@ -44,12 +44,6 @@ static void tear_down(CMP_VFY_TEST_FIXTURE *fixture)
|
||||
OPENSSL_free(fixture);
|
||||
}
|
||||
|
||||
static int print_to_bio_out(const char *func, const char *file, int line,
|
||||
OSSL_CMP_severity level, const char *msg)
|
||||
{
|
||||
return OSSL_CMP_print_to_bio(bio_out, func, file, line, level, msg);
|
||||
}
|
||||
|
||||
static time_t test_time_valid = 0, test_time_after_expiration = 0;
|
||||
|
||||
static CMP_VFY_TEST_FIXTURE *set_up(const char *const test_case_name)
|
||||
@@ -69,7 +63,7 @@ static CMP_VFY_TEST_FIXTURE *set_up(const char *const test_case_name)
|
||||
return NULL;
|
||||
}
|
||||
X509_VERIFY_PARAM_set_time(X509_STORE_get0_param(ts), test_time_valid);
|
||||
X509_STORE_set_verify_cb(ts, OSSL_CMP_print_cert_verify_cb);
|
||||
X509_STORE_set_verify_cb(ts, X509_STORE_CTX_print_verify_cb);
|
||||
return fixture;
|
||||
}
|
||||
|
||||
@@ -313,7 +307,7 @@ static int test_validate_msg_signature_sender_cert_absent(void)
|
||||
}
|
||||
|
||||
|
||||
static int test_validate_with_sender(X509_NAME *name, int expected)
|
||||
static int test_validate_with_sender(const X509_NAME *name, int expected)
|
||||
{
|
||||
SETUP_TEST_FIXTURE(CMP_VFY_TEST_FIXTURE, set_up);
|
||||
fixture->expected = expected;
|
||||
@@ -437,8 +431,7 @@ static void setup_check_received(CMP_VFY_TEST_FIXTURE **fixture, int expected,
|
||||
nonce_data, nonce_len))) {
|
||||
tear_down((*fixture));
|
||||
(*fixture) = NULL;
|
||||
}
|
||||
else if (trid_data != NULL) {
|
||||
} else if (trid_data != NULL) {
|
||||
ASN1_OCTET_STRING *trid = ASN1_OCTET_STRING_new();
|
||||
if (trid == NULL
|
||||
|| !ASN1_OCTET_STRING_set(trid, trid_data,
|
||||
@@ -549,6 +542,11 @@ int setup_tests(void)
|
||||
ts.tm_year += 10; /* February 18th 2028 */
|
||||
test_time_after_expiration = mktime(&ts);
|
||||
|
||||
if (!test_skip_common_options()) {
|
||||
TEST_error("Error parsing test options\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
RAND_bytes(rand_data, OSSL_CMP_TRANSACTIONID_LENGTH);
|
||||
if (!TEST_ptr(server_f = test_get_argument(0))
|
||||
|| !TEST_ptr(client_f = test_get_argument(1))
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright 2020 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
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "internal/nelem.h"
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/obj_mac.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/aes.h>
|
||||
#include "../crypto/rand/rand_local.h"
|
||||
|
||||
#include "testutil.h"
|
||||
#include "drbg_extra_test.h"
|
||||
|
||||
static unsigned char zerobuff[32];
|
||||
|
||||
static size_t kat_entropy(RAND_DRBG *drbg, unsigned char **pout,
|
||||
int entropy, size_t min_len, size_t max_len,
|
||||
int prediction_resistance)
|
||||
{
|
||||
*pout = zerobuff;
|
||||
return sizeof(zerobuff);
|
||||
}
|
||||
|
||||
static size_t kat_nonce(RAND_DRBG *drbg, unsigned char **pout,
|
||||
int entropy, size_t min_len, size_t max_len)
|
||||
{
|
||||
*pout = zerobuff;
|
||||
return sizeof(zerobuff);
|
||||
}
|
||||
|
||||
static int run_extra_kat(const struct drbg_extra_kat *td)
|
||||
{
|
||||
unsigned long long i;
|
||||
RAND_DRBG *drbg = NULL;
|
||||
unsigned char buff[BUFFSIZE];
|
||||
unsigned int flags = 0;
|
||||
int failures = 0;
|
||||
|
||||
if (!TEST_ptr(drbg = RAND_DRBG_new(td->nid, flags, NULL)))
|
||||
return 0;
|
||||
|
||||
/* Set deterministic entropy callback. */
|
||||
if (!TEST_true(RAND_DRBG_set_callbacks(drbg, kat_entropy, NULL,
|
||||
kat_nonce, NULL))) {
|
||||
failures++;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Set fixed reseed intervall. */
|
||||
if (!TEST_true(RAND_DRBG_set_reseed_interval(drbg, RESEEDINTERVAL))) {
|
||||
failures++;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!TEST_true(RAND_DRBG_instantiate(drbg, NULL, 0)))
|
||||
failures++;
|
||||
|
||||
for (i = 0; i < td->ngen; i++) {
|
||||
if(!TEST_true(RAND_DRBG_generate(drbg, buff, sizeof(buff), 0, NULL,
|
||||
0)))
|
||||
failures++;
|
||||
}
|
||||
|
||||
if (!TEST_true(RAND_DRBG_uninstantiate(drbg))
|
||||
|| !TEST_mem_eq(td->expected, sizeof(buff), buff, sizeof(buff)))
|
||||
failures++;
|
||||
|
||||
err:
|
||||
if (drbg != NULL) {
|
||||
RAND_DRBG_uninstantiate(drbg);
|
||||
RAND_DRBG_free(drbg);
|
||||
}
|
||||
return failures == 0;
|
||||
}
|
||||
|
||||
static int test_extra_kats(int i)
|
||||
{
|
||||
return run_extra_kat(drbg_extra_test[i]);
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_ALL_TESTS(test_extra_kats, OSSL_NELEM(drbg_extra_test));
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright 2020 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* Self generated known answer test (KATs) for NIST SP800-90A AES CTR_DRBG.
|
||||
* Test overflow of V after |ngen| generate operation.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef DRBG_EXTRA_TEST_H
|
||||
# define DRBG_EXTRA_TEST_H
|
||||
|
||||
# define BUFFSIZE 512
|
||||
# define RESEEDINTERVAL ((1 << 24) - 1)
|
||||
|
||||
struct drbg_extra_kat {
|
||||
int nid;
|
||||
const unsigned char *expected;
|
||||
unsigned long long ngen;
|
||||
};
|
||||
|
||||
static const unsigned char expected128[BUFFSIZE] = {
|
||||
0x39, 0x10, 0x06, 0x64, 0x68, 0x7d, 0x77, 0x64, 0xf9, 0xb8, 0xe8, 0x3c,
|
||||
0x55, 0xb0, 0xf1, 0x8c, 0xeb, 0x11, 0x23, 0x50, 0x15, 0x28, 0x44, 0x38,
|
||||
0x84, 0x47, 0x7b, 0xc2, 0x78, 0x16, 0x73, 0x57, 0x9f, 0x01, 0x57, 0xf0,
|
||||
0x17, 0x14, 0xa3, 0xa8, 0xdf, 0x3b, 0x87, 0x78, 0x37, 0xf8, 0x53, 0x23,
|
||||
0x18, 0xd2, 0xbc, 0x82, 0xc5, 0xed, 0x51, 0x84, 0x30, 0x14, 0xaa, 0x01,
|
||||
0xb8, 0xb5, 0xed, 0x33, 0x14, 0xe7, 0x6c, 0xa7, 0x38, 0x02, 0x60, 0x69,
|
||||
0x52, 0x0f, 0x5b, 0x7f, 0x4c, 0x82, 0x25, 0x05, 0x10, 0xaa, 0xd5, 0xc6,
|
||||
0xac, 0x44, 0x7c, 0xef, 0x0f, 0x69, 0xc7, 0x4d, 0x07, 0x54, 0x83, 0xb5,
|
||||
0xf2, 0x05, 0x0f, 0x69, 0xfd, 0x85, 0x8f, 0x63, 0x27, 0xe6, 0xff, 0xa5,
|
||||
0x26, 0xd9, 0xf0, 0x8b, 0x31, 0x89, 0xbc, 0x51, 0xb8, 0x62, 0x06, 0x88,
|
||||
0xe7, 0x95, 0xa7, 0x69, 0x7d, 0x43, 0x9c, 0x2b, 0x3c, 0x59, 0x9f, 0xa9,
|
||||
0x63, 0xa3, 0x80, 0x1b, 0xe9, 0x96, 0x6b, 0xde, 0xf2, 0xdb, 0x0c, 0x07,
|
||||
0x22, 0xb1, 0x30, 0xd0, 0x08, 0x66, 0x23, 0x31, 0x63, 0xd2, 0x86, 0xbf,
|
||||
0x6e, 0xcb, 0x44, 0xb7, 0x6a, 0x44, 0xac, 0xe6, 0x53, 0x0b, 0x32, 0x20,
|
||||
0xb6, 0xcb, 0x10, 0x22, 0x57, 0xa5, 0x7f, 0x7d, 0x9e, 0x83, 0xb9, 0xdb,
|
||||
0x27, 0x1b, 0x04, 0xf5, 0x67, 0x94, 0x6e, 0x44, 0xba, 0x77, 0xc2, 0xf6,
|
||||
0x6a, 0xcd, 0xfa, 0x71, 0x44, 0x07, 0x5e, 0x09, 0x6f, 0x42, 0x5c, 0x06,
|
||||
0x55, 0x4f, 0xae, 0xc7, 0x53, 0x73, 0x89, 0x80, 0x2d, 0x5a, 0x73, 0x3c,
|
||||
0x11, 0x8f, 0x76, 0xa1, 0x3b, 0xb6, 0xbe, 0x6b, 0xd2, 0x1f, 0xa7, 0x63,
|
||||
0x7c, 0x99, 0x46, 0x3d, 0x6b, 0x0d, 0x2a, 0xfe, 0x10, 0x00, 0x77, 0x43,
|
||||
0x5b, 0xd0, 0x52, 0x79, 0x8d, 0x1d, 0xfd, 0xe2, 0x9a, 0xac, 0x5c, 0x77,
|
||||
0x69, 0x68, 0xec, 0xf1, 0x92, 0xa8, 0xb7, 0x26, 0xcd, 0x64, 0xef, 0x8f,
|
||||
0x55, 0xa0, 0x83, 0x3f, 0x27, 0xf0, 0x34, 0xc3, 0x61, 0x74, 0xf9, 0x44,
|
||||
0x2d, 0xe1, 0xb3, 0xad, 0x02, 0xc2, 0x45, 0x40, 0x40, 0xc0, 0x0f, 0x05,
|
||||
0x72, 0xdb, 0x71, 0xae, 0x84, 0x4c, 0x3d, 0xd0, 0x61, 0x5d, 0x79, 0x52,
|
||||
0x16, 0xb1, 0x02, 0x07, 0xaf, 0xfa, 0x9a, 0xe0, 0x21, 0xbf, 0x1c, 0xc4,
|
||||
0x21, 0xf9, 0x76, 0x95, 0xc4, 0x92, 0x57, 0xb7, 0x1e, 0xce, 0xb8, 0xd5,
|
||||
0x1c, 0x68, 0x7c, 0xed, 0x8f, 0x45, 0x09, 0x0b, 0xef, 0x30, 0x68, 0xab,
|
||||
0x5f, 0x26, 0x4a, 0xf2, 0x8a, 0x55, 0x97, 0x3d, 0x1c, 0xa0, 0x33, 0x20,
|
||||
0x10, 0x9e, 0x10, 0x77, 0x93, 0xa2, 0xcb, 0x72, 0x33, 0xf3, 0x6f, 0xdc,
|
||||
0x41, 0x46, 0x83, 0xb1, 0x59, 0x22, 0xf0, 0x9b, 0x9f, 0x50, 0x9f, 0x14,
|
||||
0x2e, 0xe0, 0xb8, 0xa3, 0xf7, 0x40, 0x9d, 0xe0, 0x76, 0x78, 0xa6, 0xd4,
|
||||
0xf6, 0xd4, 0x29, 0x33, 0x97, 0x76, 0x54, 0xdf, 0x3e, 0xf0, 0x82, 0x9f,
|
||||
0x4f, 0xf1, 0x0b, 0x0a, 0x61, 0xa2, 0x3f, 0xde, 0xda, 0xfe, 0x93, 0xe1,
|
||||
0x51, 0x19, 0x93, 0x8c, 0xc0, 0x07, 0x76, 0xdb, 0x4a, 0x9c, 0xef, 0x42,
|
||||
0x5f, 0x7b, 0x5b, 0x2c, 0xff, 0xe7, 0x5f, 0x6d, 0xcb, 0x7e, 0x9b, 0xc9,
|
||||
0xf3, 0x94, 0xe9, 0x73, 0xd6, 0xa3, 0x00, 0x7d, 0x11, 0xf8, 0xd6, 0x58,
|
||||
0x97, 0x3e, 0xdf, 0xb9, 0xd5, 0x57, 0xde, 0x51, 0x9e, 0x39, 0x5d, 0x59,
|
||||
0xe5, 0x50, 0x29, 0x3e, 0x58, 0x90, 0x37, 0xa6, 0xcc, 0x06, 0x89, 0xb1,
|
||||
0xa6, 0xa7, 0xef, 0x96, 0x30, 0xf5, 0xc1, 0xea, 0x03, 0xde, 0x46, 0x9a,
|
||||
0x5f, 0xa2, 0x5d, 0xb6, 0x74, 0xfd, 0xbf, 0xde, 0x77, 0x8e, 0x3e, 0x90,
|
||||
0x55, 0x3b, 0x4d, 0x59, 0xde, 0x19, 0x43, 0xcd, 0x5d, 0x1b, 0xba, 0x29,
|
||||
0xa9, 0x59, 0xad, 0xef, 0x2d, 0x9c, 0x3b, 0xc0
|
||||
};
|
||||
static const struct drbg_extra_kat drbg_extra_test128 = {
|
||||
NID_aes_128_ctr,
|
||||
expected128,
|
||||
61335566ULL
|
||||
};
|
||||
|
||||
static const unsigned char expected192[BUFFSIZE] = {
|
||||
0x19, 0x1b, 0xe3, 0xa9, 0x58, 0xb4, 0xcc, 0x3a, 0x3a, 0x06, 0x30, 0x6a,
|
||||
0xdc, 0x8c, 0x78, 0xb2, 0x1e, 0xb5, 0x83, 0xa0, 0x04, 0x72, 0xae, 0xed,
|
||||
0xae, 0x88, 0x7c, 0x63, 0x8b, 0xe6, 0x20, 0x9b, 0xb4, 0x04, 0x14, 0xa9,
|
||||
0x83, 0xce, 0xb4, 0xd1, 0x69, 0xc2, 0x00, 0xa5, 0xf4, 0x45, 0xdb, 0xa1,
|
||||
0xcb, 0xd7, 0xfe, 0xf7, 0x19, 0x5d, 0x4d, 0x26, 0x7d, 0x7a, 0x2f, 0xde,
|
||||
0xc1, 0xb3, 0x8e, 0x3e, 0x19, 0xd1, 0xff, 0x25, 0x9b, 0x81, 0x90, 0x11,
|
||||
0x71, 0xb6, 0x08, 0x46, 0x76, 0x58, 0xca, 0x78, 0xae, 0xc3, 0x90, 0x29,
|
||||
0x07, 0x07, 0x85, 0x9d, 0x90, 0xd9, 0xf5, 0x5a, 0x8d, 0x28, 0x87, 0xd3,
|
||||
0x88, 0xd1, 0x14, 0xc1, 0xa8, 0x96, 0xa3, 0x7e, 0x6b, 0xe4, 0x1d, 0xf6,
|
||||
0x0d, 0xfb, 0x3d, 0xee, 0xa9, 0x8c, 0x70, 0xc9, 0x3f, 0x87, 0xad, 0x57,
|
||||
0xd9, 0xe3, 0x4e, 0xfc, 0x03, 0xeb, 0x79, 0xb8, 0xb9, 0xe9, 0xe4, 0x55,
|
||||
0x78, 0x4b, 0xdb, 0xfa, 0xb6, 0x5e, 0x1e, 0x5b, 0xab, 0x11, 0x35, 0x3c,
|
||||
0x97, 0x10, 0x0d, 0x7e, 0x68, 0x47, 0x1a, 0xd0, 0x59, 0xac, 0x41, 0x61,
|
||||
0x8e, 0xfc, 0xd1, 0x12, 0xf6, 0x81, 0x44, 0x5c, 0x78, 0xe4, 0x32, 0x2f,
|
||||
0xa5, 0x4c, 0x6e, 0xf8, 0xbf, 0x35, 0xc2, 0x66, 0xc0, 0x04, 0x77, 0x2e,
|
||||
0x1d, 0xe9, 0xc9, 0x8f, 0xca, 0xd7, 0x2a, 0xf0, 0x35, 0x34, 0x3a, 0xf6,
|
||||
0x7e, 0x0d, 0xc6, 0xc2, 0x4a, 0xd0, 0x91, 0x5d, 0xf5, 0x47, 0xdb, 0x32,
|
||||
0x88, 0x52, 0x98, 0xf0, 0xca, 0xc9, 0x57, 0x34, 0x10, 0xca, 0xfa, 0x9d,
|
||||
0x23, 0x61, 0x41, 0x55, 0xc8, 0x65, 0xa4, 0x4e, 0xa5, 0x8b, 0x1a, 0xdc,
|
||||
0x14, 0x80, 0x26, 0xe7, 0x72, 0x98, 0x90, 0x14, 0x01, 0x52, 0xa4, 0x9f,
|
||||
0x55, 0xe4, 0xaa, 0x15, 0x20, 0xd4, 0x34, 0x3f, 0x36, 0xce, 0x93, 0x5d,
|
||||
0x7b, 0x49, 0x29, 0x3f, 0xef, 0x78, 0xe9, 0x2e, 0x4c, 0x87, 0xa1, 0xb6,
|
||||
0x28, 0xb7, 0xa3, 0xb4, 0x49, 0x84, 0xf5, 0x5d, 0x24, 0x7d, 0x57, 0x57,
|
||||
0x79, 0xf5, 0xa1, 0x67, 0x5b, 0x8c, 0x59, 0x43, 0x3a, 0x1f, 0x10, 0x51,
|
||||
0x57, 0xa0, 0xe5, 0x18, 0xba, 0xdd, 0xca, 0x2d, 0xa9, 0xc5, 0xef, 0xad,
|
||||
0x7e, 0xd5, 0x17, 0xa3, 0x66, 0xe0, 0x93, 0x00, 0xda, 0xfc, 0x90, 0x89,
|
||||
0x64, 0x01, 0x10, 0x6a, 0xe7, 0x51, 0x7e, 0x5c, 0x16, 0x87, 0x4a, 0xc2,
|
||||
0x04, 0x27, 0x5c, 0x71, 0xdb, 0xcb, 0xb4, 0x70, 0xfc, 0x5e, 0xfb, 0xce,
|
||||
0xba, 0xc8, 0x20, 0x80, 0x5d, 0x73, 0xdb, 0xb4, 0x30, 0x8b, 0xfc, 0xcf,
|
||||
0xd1, 0x09, 0xa1, 0x93, 0xa3, 0x3e, 0x86, 0x76, 0x86, 0x5a, 0xa4, 0xba,
|
||||
0xda, 0xb8, 0x03, 0x1d, 0x69, 0x99, 0x29, 0xef, 0xe1, 0x7b, 0x6a, 0xd3,
|
||||
0x95, 0x9e, 0x98, 0x5a, 0x39, 0xb0, 0xde, 0x53, 0x49, 0x09, 0x7d, 0xdd,
|
||||
0x89, 0xed, 0x90, 0xc6, 0xa3, 0x8c, 0xe6, 0x15, 0x2f, 0x5a, 0x47, 0x8a,
|
||||
0x66, 0xf7, 0x1f, 0x38, 0x9e, 0xae, 0x9b, 0x46, 0x71, 0x96, 0x21, 0xbf,
|
||||
0x9f, 0x8e, 0x60, 0x2c, 0xda, 0xd6, 0x38, 0xf0, 0xc5, 0xe6, 0x27, 0x4b,
|
||||
0xfa, 0xc2, 0x13, 0x1a, 0x6b, 0xf5, 0x47, 0x97, 0x2f, 0xd0, 0x34, 0xe7,
|
||||
0x71, 0x9f, 0x8b, 0xc7, 0x22, 0xec, 0x97, 0x38, 0xe2, 0x07, 0x2b, 0x02,
|
||||
0x76, 0xf7, 0xb5, 0xdc, 0x55, 0xaf, 0x8e, 0xe6, 0x92, 0x57, 0x82, 0x82,
|
||||
0xf2, 0x1e, 0x10, 0x37, 0x40, 0xc4, 0x91, 0x25, 0xa7, 0x5c, 0xed, 0x1b,
|
||||
0x61, 0xc7, 0xc4, 0x47, 0xac, 0xe5, 0xb8, 0x7b, 0xdc, 0xfc, 0xaa, 0xd4,
|
||||
0x0c, 0xcc, 0x93, 0xee, 0x69, 0xd7, 0x35, 0xcf, 0xd7, 0x47, 0x05, 0xfc,
|
||||
0x88, 0xeb, 0x29, 0x0b, 0x62, 0x8e, 0x51, 0xb0, 0xd6, 0x71, 0xa0, 0xf2,
|
||||
0x17, 0x74, 0x1a, 0x2d, 0x4f, 0xb0, 0xd9, 0x8b
|
||||
};
|
||||
static const struct drbg_extra_kat drbg_extra_test192 = {
|
||||
NID_aes_192_ctr,
|
||||
expected192,
|
||||
10132467ULL
|
||||
};
|
||||
|
||||
static const unsigned char expected256[BUFFSIZE] = {
|
||||
0x3f, 0x6d, 0x24, 0x4d, 0xe8, 0xdf, 0x93, 0xe5, 0xde, 0x4f, 0xba, 0x25,
|
||||
0x9c, 0x97, 0xfa, 0xbb, 0x78, 0x6f, 0xe7, 0xce, 0x74, 0x66, 0xa3, 0x81,
|
||||
0xf1, 0x0e, 0xf9, 0xea, 0xb6, 0xfc, 0xc2, 0xc5, 0xf0, 0x25, 0x0d, 0x45,
|
||||
0x45, 0x8a, 0x3e, 0xf2, 0x93, 0xf3, 0x2c, 0x41, 0x46, 0x2d, 0x58, 0x56,
|
||||
0x7e, 0x6a, 0x5c, 0x8a, 0x51, 0x3f, 0xd1, 0x76, 0x09, 0x6d, 0xf4, 0xf0,
|
||||
0x01, 0x8f, 0x60, 0x68, 0x9c, 0x52, 0xb2, 0xb1, 0xd2, 0x3e, 0x07, 0x10,
|
||||
0xab, 0x6c, 0xc9, 0x78, 0x22, 0xf4, 0xde, 0xbc, 0xee, 0x23, 0xa9, 0xb5,
|
||||
0x81, 0x2c, 0x4c, 0xf7, 0xd6, 0x35, 0x53, 0x1f, 0x66, 0x42, 0x1d, 0x7a,
|
||||
0x6d, 0x6e, 0x56, 0x8d, 0xbc, 0x03, 0xac, 0x76, 0x6c, 0x46, 0x4a, 0x80,
|
||||
0x87, 0x97, 0x62, 0xc6, 0xe8, 0x21, 0x35, 0xbd, 0x1d, 0x17, 0x28, 0x80,
|
||||
0x79, 0x6a, 0xe0, 0xc5, 0x33, 0x51, 0x38, 0xa6, 0xdf, 0x8d, 0xf6, 0xb3,
|
||||
0x69, 0x4f, 0x3b, 0xb2, 0xb1, 0x8e, 0x28, 0x8a, 0x3b, 0xba, 0x80, 0x43,
|
||||
0x7a, 0x92, 0x5e, 0x11, 0xd7, 0x4a, 0x8d, 0xa5, 0xee, 0x7c, 0x30, 0x69,
|
||||
0x7c, 0x27, 0x0f, 0xb8, 0x10, 0xd4, 0x32, 0x5f, 0xad, 0x27, 0xf4, 0xf1,
|
||||
0x31, 0xfe, 0x41, 0x08, 0x8c, 0x09, 0xe5, 0x9c, 0x55, 0x97, 0xa5, 0x38,
|
||||
0x7f, 0x72, 0x5b, 0x0a, 0xb3, 0x44, 0x2d, 0x4f, 0x65, 0xba, 0x74, 0x0c,
|
||||
0x35, 0x2f, 0x57, 0xfb, 0x21, 0x9c, 0x80, 0x2a, 0xd8, 0x0d, 0x56, 0xa7,
|
||||
0x99, 0x8b, 0xd9, 0xaf, 0x6f, 0x45, 0x06, 0x94, 0xf5, 0x6f, 0x56, 0x32,
|
||||
0x3d, 0x6c, 0xd6, 0x91, 0x30, 0x88, 0xdd, 0x61, 0x79, 0xa8, 0xac, 0x03,
|
||||
0xcf, 0x1c, 0x53, 0xd4, 0xdf, 0x6f, 0x39, 0x9c, 0x9f, 0xa9, 0xb5, 0x8c,
|
||||
0x8b, 0xc3, 0x20, 0x89, 0x5e, 0xf9, 0x74, 0x0c, 0xda, 0x7b, 0x2a, 0x22,
|
||||
0xa4, 0xcc, 0x00, 0x78, 0x66, 0x5e, 0xe5, 0x49, 0x5b, 0x3e, 0xfe, 0x85,
|
||||
0xcd, 0x9a, 0xa7, 0xcd, 0xb0, 0xf1, 0x2b, 0xe7, 0x3b, 0x23, 0x09, 0xb2,
|
||||
0x26, 0x66, 0x6c, 0x64, 0xd9, 0x35, 0x69, 0xd4, 0xfe, 0xc1, 0x3f, 0xbd,
|
||||
0xf3, 0x15, 0x15, 0x83, 0x1f, 0x92, 0x5f, 0x25, 0x0b, 0x1f, 0x54, 0xeb,
|
||||
0xfc, 0x40, 0x96, 0xb4, 0x71, 0x2a, 0x3b, 0xa3, 0x94, 0xfa, 0x41, 0xfa,
|
||||
0x43, 0x4e, 0xf1, 0x85, 0xc4, 0x2d, 0x40, 0xf0, 0x1a, 0x0d, 0x88, 0xf2,
|
||||
0xd4, 0x1f, 0x9d, 0x80, 0x69, 0x56, 0xb1, 0xa4, 0xcb, 0xa1, 0x35, 0x98,
|
||||
0xda, 0xa4, 0xa3, 0x6d, 0xd8, 0x01, 0x98, 0xe0, 0x2e, 0x13, 0xc2, 0x7d,
|
||||
0x74, 0x6a, 0x62, 0x7a, 0xef, 0x93, 0x65, 0x94, 0x37, 0xa6, 0x5b, 0xcb,
|
||||
0x23, 0xe6, 0x23, 0x3d, 0xa5, 0x7e, 0x30, 0x59, 0x36, 0x85, 0xee, 0xfb,
|
||||
0xe8, 0x33, 0x3c, 0xf5, 0xc3, 0x4e, 0xf2, 0xc4, 0x70, 0xc8, 0x4f, 0x00,
|
||||
0x39, 0x7d, 0x20, 0x7f, 0x72, 0x57, 0xd9, 0xb9, 0xf6, 0xfe, 0xf2, 0x50,
|
||||
0x44, 0xed, 0x53, 0xdc, 0xd6, 0xd5, 0x1f, 0x94, 0xea, 0x62, 0x9e, 0x64,
|
||||
0x23, 0xd6, 0x6d, 0x8a, 0x6e, 0xfb, 0xc2, 0xb3, 0x7e, 0x72, 0x26, 0xad,
|
||||
0x31, 0x30, 0x81, 0xb7, 0x62, 0x10, 0xaf, 0x8e, 0x45, 0x74, 0x6e, 0x8f,
|
||||
0x07, 0x5a, 0xfe, 0xe3, 0xa7, 0xe8, 0x47, 0x80, 0x7e, 0x1d, 0xb5, 0x8c,
|
||||
0xab, 0xcb, 0x0b, 0x95, 0xb2, 0x95, 0x64, 0x5e, 0xea, 0x42, 0x14, 0x6f,
|
||||
0x6b, 0xe4, 0x81, 0x51, 0x78, 0xb4, 0x0e, 0x0c, 0x6e, 0x22, 0x31, 0xb2,
|
||||
0x50, 0xd9, 0x78, 0xc6, 0xfa, 0xa4, 0xb6, 0xf4, 0x17, 0x20, 0xbe, 0xe3,
|
||||
0x69, 0xfa, 0x6c, 0xb9, 0x98, 0xad, 0xca, 0xba, 0x72, 0xa2, 0x22, 0x4c,
|
||||
0x0a, 0xb3, 0x6d, 0x9b, 0x11, 0x8a, 0x59, 0x06, 0xf1, 0xda, 0x43, 0xc2,
|
||||
0xae, 0xb0, 0x80, 0x35, 0x86, 0xbf, 0xf0, 0x8c
|
||||
};
|
||||
static const struct drbg_extra_kat drbg_extra_test256 = {
|
||||
NID_aes_256_ctr,
|
||||
expected256,
|
||||
40870394ULL
|
||||
};
|
||||
|
||||
static const struct drbg_extra_kat *drbg_extra_test[] = {
|
||||
&drbg_extra_test128,
|
||||
&drbg_extra_test192,
|
||||
&drbg_extra_test256,
|
||||
};
|
||||
|
||||
#endif
|
||||
+13
-32
@@ -212,20 +212,9 @@ static int set_sm2_id(EVP_MD_CTX *mctx, EVP_PKEY *pkey)
|
||||
static const char sm2_id[] = { 1, 2, 3, 4, 'l', 'e', 't', 't', 'e', 'r' };
|
||||
EVP_PKEY_CTX *pctx;
|
||||
|
||||
if (!TEST_ptr(pctx = EVP_PKEY_CTX_new(pkey, NULL))
|
||||
if (!TEST_ptr(pctx = EVP_MD_CTX_pkey_ctx(mctx))
|
||||
|| !TEST_int_gt(EVP_PKEY_CTX_set1_id(pctx, sm2_id, sizeof(sm2_id)), 0))
|
||||
return 0;
|
||||
EVP_MD_CTX_set_pkey_ctx(mctx, pctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int clean_sm2_id(EVP_MD_CTX *mctx)
|
||||
{
|
||||
EVP_PKEY_CTX *pctx;
|
||||
|
||||
if (!TEST_ptr(pctx = EVP_MD_CTX_pkey_ctx(mctx)))
|
||||
return 0;
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -283,46 +272,40 @@ static int test_builtin(int n, int as)
|
||||
if (!TEST_int_ge(temp, 0)
|
||||
|| !TEST_ptr(sig = OPENSSL_malloc(sig_len = (size_t)temp))
|
||||
/* create a signature */
|
||||
|| (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_true(EVP_DigestSignInit(mctx, NULL, NULL, NULL, pkey))
|
||||
|| (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_true(EVP_DigestSign(mctx, sig, &sig_len, tbs, sizeof(tbs)))
|
||||
|| !TEST_int_le(sig_len, ECDSA_size(eckey))
|
||||
|| (as == EVP_PKEY_SM2 && !clean_sm2_id(mctx))
|
||||
|| !TEST_true(EVP_MD_CTX_reset(mctx))
|
||||
/* negative test, verify with wrong key, 0 return */
|
||||
|| (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey_neg))
|
||||
|| !TEST_true(EVP_DigestVerifyInit(mctx, NULL, NULL, NULL, pkey_neg))
|
||||
|| (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey_neg))
|
||||
|| !TEST_int_eq(EVP_DigestVerify(mctx, sig, sig_len, tbs, sizeof(tbs)), 0)
|
||||
|| (as == EVP_PKEY_SM2 && !clean_sm2_id(mctx))
|
||||
|| !TEST_true(EVP_MD_CTX_reset(mctx))
|
||||
/* negative test, verify with wrong signature length, -1 return */
|
||||
|| (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_true(EVP_DigestVerifyInit(mctx, NULL, NULL, NULL, pkey))
|
||||
|| (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_int_eq(EVP_DigestVerify(mctx, sig, sig_len - 1, tbs, sizeof(tbs)), -1)
|
||||
|| (as == EVP_PKEY_SM2 && !clean_sm2_id(mctx))
|
||||
|| !TEST_true(EVP_MD_CTX_reset(mctx))
|
||||
/* positive test, verify with correct key, 1 return */
|
||||
|| (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_true(EVP_DigestVerifyInit(mctx, NULL, NULL, NULL, pkey))
|
||||
|| (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_int_eq(EVP_DigestVerify(mctx, sig, sig_len, tbs, sizeof(tbs)), 1)
|
||||
|| (as == EVP_PKEY_SM2 && !clean_sm2_id(mctx))
|
||||
|| !TEST_true(EVP_MD_CTX_reset(mctx)))
|
||||
goto err;
|
||||
|
||||
/* muck with the message, test it fails with 0 return */
|
||||
tbs[0] ^= 1;
|
||||
if ((as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_true(EVP_DigestVerifyInit(mctx, NULL, NULL, NULL, pkey))
|
||||
if (!TEST_true(EVP_DigestVerifyInit(mctx, NULL, NULL, NULL, pkey))
|
||||
|| (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_int_eq(EVP_DigestVerify(mctx, sig, sig_len, tbs, sizeof(tbs)), 0)
|
||||
|| (as == EVP_PKEY_SM2 && !clean_sm2_id(mctx))
|
||||
|| !TEST_true(EVP_MD_CTX_reset(mctx)))
|
||||
goto err;
|
||||
/* un-muck and test it verifies */
|
||||
tbs[0] ^= 1;
|
||||
if ((as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_true(EVP_DigestVerifyInit(mctx, NULL, NULL, NULL, pkey))
|
||||
if (!TEST_true(EVP_DigestVerifyInit(mctx, NULL, NULL, NULL, pkey))
|
||||
|| (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_int_eq(EVP_DigestVerify(mctx, sig, sig_len, tbs, sizeof(tbs)), 1)
|
||||
|| (as == EVP_PKEY_SM2 && !clean_sm2_id(mctx))
|
||||
|| !TEST_true(EVP_MD_CTX_reset(mctx)))
|
||||
goto err;
|
||||
|
||||
@@ -355,18 +338,16 @@ static int test_builtin(int n, int as)
|
||||
offset = tbs[0] % sig_len;
|
||||
dirt = tbs[1] ? tbs[1] : 1;
|
||||
sig[offset] ^= dirt;
|
||||
if ((as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_true(EVP_DigestVerifyInit(mctx, NULL, NULL, NULL, pkey))
|
||||
if (!TEST_true(EVP_DigestVerifyInit(mctx, NULL, NULL, NULL, pkey))
|
||||
|| (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_int_ne(EVP_DigestVerify(mctx, sig, sig_len, tbs, sizeof(tbs)), 1)
|
||||
|| (as == EVP_PKEY_SM2 && !clean_sm2_id(mctx))
|
||||
|| !TEST_true(EVP_MD_CTX_reset(mctx)))
|
||||
goto err;
|
||||
/* un-muck and test it verifies */
|
||||
sig[offset] ^= dirt;
|
||||
if ((as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_true(EVP_DigestVerifyInit(mctx, NULL, NULL, NULL, pkey))
|
||||
if (!TEST_true(EVP_DigestVerifyInit(mctx, NULL, NULL, NULL, pkey))
|
||||
|| (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey))
|
||||
|| !TEST_int_eq(EVP_DigestVerify(mctx, sig, sig_len, tbs, sizeof(tbs)), 1)
|
||||
|| (as == EVP_PKEY_SM2 && !clean_sm2_id(mctx))
|
||||
|| !TEST_true(EVP_MD_CTX_reset(mctx)))
|
||||
goto err;
|
||||
|
||||
|
||||
@@ -1302,7 +1302,8 @@ static int test_EVP_PKEY_CTX_get_set_params(EVP_PKEY *pkey)
|
||||
*/
|
||||
mdctx = EVP_MD_CTX_new();
|
||||
if (!TEST_ptr(mdctx)
|
||||
|| !TEST_true(EVP_DigestSignInit_ex(mdctx, NULL, "SHA1", NULL, pkey)))
|
||||
|| !TEST_true(EVP_DigestSignInit_ex(mdctx, NULL, "SHA1", NULL, pkey,
|
||||
NULL)))
|
||||
goto err;
|
||||
|
||||
/*
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <openssl/provider.h>
|
||||
#include "testutil.h"
|
||||
|
||||
static char *config_file = NULL;
|
||||
static char *alg = "digest";
|
||||
static int use_default_ctx = 0;
|
||||
static char *fetch_property = NULL;
|
||||
@@ -32,6 +33,7 @@ typedef enum OPTION_choice {
|
||||
OPT_FETCH_PROPERTY,
|
||||
OPT_FETCH_FAILURE,
|
||||
OPT_USE_DEFAULTCTX,
|
||||
OPT_CONFIG_FILE,
|
||||
OPT_TEST_ENUM
|
||||
} OPTION_CHOICE;
|
||||
|
||||
@@ -39,6 +41,7 @@ const OPTIONS *test_get_options(void)
|
||||
{
|
||||
static const OPTIONS test_options[] = {
|
||||
OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("[provname...]\n"),
|
||||
{ "config", OPT_CONFIG_FILE, '<', "The configuration file to use for the libctx" },
|
||||
{ "type", OPT_ALG_FETCH_TYPE, 's', "The fetch type to test" },
|
||||
{ "property", OPT_FETCH_PROPERTY, 's', "The fetch property e.g. provider=fips" },
|
||||
{ "fetchfail", OPT_FETCH_FAILURE, '-', "fetch is expected to fail" },
|
||||
@@ -75,7 +78,7 @@ static int calculate_digest(const EVP_MD *md, const char *msg, size_t len,
|
||||
|
||||
static int load_providers(OPENSSL_CTX **libctx, OSSL_PROVIDER *prov[])
|
||||
{
|
||||
OPENSSL_CTX *ctx;
|
||||
OPENSSL_CTX *ctx = NULL;
|
||||
int ret = 0;
|
||||
size_t i;
|
||||
|
||||
@@ -83,6 +86,8 @@ static int load_providers(OPENSSL_CTX **libctx, OSSL_PROVIDER *prov[])
|
||||
if (!TEST_ptr(ctx))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(OPENSSL_CTX_load_config(ctx, config_file)))
|
||||
goto err;
|
||||
if (test_get_argument_count() > 2)
|
||||
goto err;
|
||||
|
||||
@@ -92,9 +97,12 @@ static int load_providers(OPENSSL_CTX **libctx, OSSL_PROVIDER *prov[])
|
||||
if (!TEST_ptr(prov[i]))
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
*libctx = ctx;
|
||||
err:
|
||||
if (ret == 0)
|
||||
OPENSSL_CTX_free(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -231,6 +239,9 @@ int setup_tests(void)
|
||||
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_CONFIG_FILE:
|
||||
config_file = opt_arg();
|
||||
break;
|
||||
case OPT_ALG_FETCH_TYPE:
|
||||
alg = opt_arg();
|
||||
break;
|
||||
|
||||
+244
-29
@@ -7,6 +7,7 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <string.h> /* memset */
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/serializer.h>
|
||||
@@ -15,7 +16,7 @@
|
||||
#include <openssl/core_names.h>
|
||||
#include "crypto/ecx.h"
|
||||
#include "internal/nelem.h"
|
||||
#include "internal/param_build.h"
|
||||
#include "openssl/param_build.h"
|
||||
#include "crypto/evp.h" /* For the internal API */
|
||||
#include "testutil.h"
|
||||
|
||||
@@ -260,9 +261,9 @@ static int test_print_key_using_serializer(const char *alg, const EVP_PKEY *pk)
|
||||
|
||||
static int test_fromdata_rsa(void)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret = 0, i;
|
||||
EVP_PKEY_CTX *ctx = NULL, *key_ctx = NULL;
|
||||
EVP_PKEY *pk = NULL;
|
||||
EVP_PKEY *pk = NULL, *copy_pk = NULL;
|
||||
/*
|
||||
* 32-bit RSA key, extracted from this command,
|
||||
* executed with OpenSSL 1.0.2:
|
||||
@@ -283,13 +284,15 @@ static int test_fromdata_rsa(void)
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_N, &key_numbers[N]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_E, &key_numbers[E]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_D, &key_numbers[D]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_FACTOR, &key_numbers[P]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_FACTOR, &key_numbers[Q]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_EXPONENT, &key_numbers[DP]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_EXPONENT, &key_numbers[DQ]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_COEFFICIENT, &key_numbers[QINV]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_FACTOR1, &key_numbers[P]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_FACTOR2, &key_numbers[Q]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_EXPONENT1, &key_numbers[DP]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_EXPONENT2, &key_numbers[DQ]),
|
||||
OSSL_PARAM_ulong(OSSL_PKEY_PARAM_RSA_COEFFICIENT1, &key_numbers[QINV]),
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
BIGNUM *bn = BN_new();
|
||||
BIGNUM *bn_from = BN_new();
|
||||
|
||||
if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL)))
|
||||
goto err;
|
||||
@@ -310,17 +313,83 @@ static int test_fromdata_rsa(void)
|
||||
|| !TEST_true(EVP_PKEY_pairwise_check(key_ctx)))
|
||||
goto err;
|
||||
|
||||
/* EVP_PKEY_copy_parameters() should fail for RSA */
|
||||
if (!TEST_ptr(copy_pk = EVP_PKEY_new())
|
||||
|| !TEST_false(EVP_PKEY_copy_parameters(copy_pk, pk)))
|
||||
goto err;
|
||||
|
||||
for (i = 0; fromdata_params[i].key != NULL; ++i) {
|
||||
if (!TEST_true(BN_set_word(bn_from, key_numbers[i]))
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, fromdata_params[i].key, &bn))
|
||||
|| !TEST_BN_eq(bn, bn_from))
|
||||
goto err;
|
||||
}
|
||||
ret = test_print_key_using_pem("RSA", pk)
|
||||
&& test_print_key_using_serializer("RSA", pk);
|
||||
|
||||
err:
|
||||
BN_free(bn_from);
|
||||
BN_free(bn);
|
||||
EVP_PKEY_free(pk);
|
||||
EVP_PKEY_free(copy_pk);
|
||||
EVP_PKEY_CTX_free(key_ctx);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_evp_pkey_get_bn_param_large(void)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_PKEY_CTX *ctx = NULL, *key_ctx = NULL;
|
||||
EVP_PKEY *pk = NULL;
|
||||
OSSL_PARAM_BLD *bld = NULL;
|
||||
OSSL_PARAM *fromdata_params = NULL;
|
||||
BIGNUM *n = NULL, *e = NULL, *d = NULL, *n_out = NULL;
|
||||
/*
|
||||
* The buffer size chosen here for n_data larger than the buffer used
|
||||
* internally in EVP_PKEY_get_bn_param.
|
||||
*/
|
||||
static unsigned char n_data[2050];
|
||||
static const unsigned char e_data[] = {
|
||||
0x1, 0x00, 0x01
|
||||
};
|
||||
static const unsigned char d_data[]= {
|
||||
0x99, 0x33, 0x13, 0x7b
|
||||
};
|
||||
|
||||
/* N is a large buffer */
|
||||
memset(n_data, 0xCE, sizeof(n_data));
|
||||
|
||||
if (!TEST_ptr(bld = OSSL_PARAM_BLD_new())
|
||||
|| !TEST_ptr(n = BN_bin2bn(n_data, sizeof(n_data), NULL))
|
||||
|| !TEST_ptr(e = BN_bin2bn(e_data, sizeof(e_data), NULL))
|
||||
|| !TEST_ptr(d = BN_bin2bn(d_data, sizeof(d_data), NULL))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_N, n))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_E, e))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_D, d))
|
||||
|| !TEST_ptr(fromdata_params = OSSL_PARAM_BLD_to_param(bld))
|
||||
|| !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL))
|
||||
|| !TEST_true(EVP_PKEY_key_fromdata_init(ctx))
|
||||
|| !TEST_true(EVP_PKEY_fromdata(ctx, &pk, fromdata_params))
|
||||
|| !TEST_ptr(key_ctx = EVP_PKEY_CTX_new_from_pkey(NULL, pk, ""))
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_RSA_N, &n_out))
|
||||
|| !TEST_BN_eq(n, n_out))
|
||||
goto err;
|
||||
ret = 1;
|
||||
err:
|
||||
BN_free(n_out);
|
||||
BN_free(n);
|
||||
BN_free(e);
|
||||
BN_free(d);
|
||||
EVP_PKEY_free(pk);
|
||||
EVP_PKEY_CTX_free(key_ctx);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
OSSL_PARAM_BLD_free_params(fromdata_params);
|
||||
OSSL_PARAM_BLD_free(bld);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#ifndef OPENSSL_NO_DH
|
||||
/* Array indexes used in test_fromdata_dh */
|
||||
#define PRIV_KEY 0
|
||||
@@ -332,7 +401,7 @@ static int test_fromdata_dh(void)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_PKEY_CTX *ctx = NULL, *key_ctx = NULL;
|
||||
EVP_PKEY *pk = NULL;
|
||||
EVP_PKEY *pk = NULL, *copy_pk = NULL;
|
||||
/*
|
||||
* 32-bit DH key, extracted from this command,
|
||||
* executed with OpenSSL 1.0.2:
|
||||
@@ -364,6 +433,10 @@ static int test_fromdata_dh(void)
|
||||
|| !TEST_int_eq(EVP_PKEY_size(pk), 4))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(copy_pk = EVP_PKEY_new())
|
||||
|| !TEST_true(EVP_PKEY_copy_parameters(copy_pk, pk)))
|
||||
goto err;
|
||||
|
||||
ret = test_print_key_using_pem("DH", pk)
|
||||
&& test_print_key_using_serializer("DH", pk);
|
||||
|
||||
@@ -378,6 +451,7 @@ static int test_fromdata_dh(void)
|
||||
|
||||
err:
|
||||
EVP_PKEY_free(pk);
|
||||
EVP_PKEY_free(copy_pk);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
EVP_PKEY_CTX_free(key_ctx);
|
||||
|
||||
@@ -392,16 +466,21 @@ static int test_fromdata_dh(void)
|
||||
|
||||
# define X25519_IDX 0
|
||||
# define X448_IDX 1
|
||||
# define ED25519_IDX 2
|
||||
# define ED448_IDX 3
|
||||
|
||||
static int test_fromdata_ecx(int tst)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
EVP_PKEY *pk = NULL;
|
||||
const char *alg = (tst == X25519_IDX) ? "X25519" : "X448";
|
||||
EVP_PKEY *pk = NULL, *copy_pk = NULL;
|
||||
const char *alg = NULL;
|
||||
size_t len;
|
||||
unsigned char out_pub[ED448_KEYLEN];
|
||||
unsigned char out_priv[ED448_KEYLEN];
|
||||
|
||||
/* X448_KEYLEN > X25519_KEYLEN */
|
||||
static unsigned char key_numbers[2][2][X448_KEYLEN] = {
|
||||
/* ED448_KEYLEN > X448_KEYLEN > X25519_KEYLEN == ED25519_KEYLEN */
|
||||
static unsigned char key_numbers[4][2][ED448_KEYLEN] = {
|
||||
/* X25519: Keys from RFC 7748 6.1 */
|
||||
{
|
||||
/* Private Key */
|
||||
@@ -439,6 +518,44 @@ static int test_fromdata_ecx(int tst)
|
||||
0x0c, 0x5b, 0x12, 0xda, 0x88, 0x12, 0x0d, 0x53, 0x17, 0x7f,
|
||||
0x80, 0xe5, 0x32, 0xc4, 0x1f, 0xa0
|
||||
}
|
||||
},
|
||||
/* ED25519: Keys from RFC 8032 */
|
||||
{
|
||||
/* Private Key */
|
||||
{
|
||||
0x9d, 0x61, 0xb1, 0x9d, 0xef, 0xfd, 0x5a, 0x60, 0xba, 0x84,
|
||||
0x4a, 0xf4, 0x92, 0xec, 0x2c, 0xc4, 0x44, 0x49, 0xc5, 0x69,
|
||||
0x7b, 0x32, 0x69, 0x19, 0x70, 0x3b, 0xac, 0x03, 0x1c, 0xae,
|
||||
0x7f, 0x60
|
||||
},
|
||||
/* Public Key */
|
||||
{
|
||||
0xd7, 0x5a, 0x98, 0x01, 0x82, 0xb1, 0x0a, 0xb7, 0xd5, 0x4b,
|
||||
0xfe, 0xd3, 0xc9, 0x64, 0x07, 0x3a, 0x0e, 0xe1, 0x72, 0xf3,
|
||||
0xda, 0xa6, 0x23, 0x25, 0xaf, 0x02, 0x1a, 0x68, 0xf7, 0x07,
|
||||
0x51, 0x1a
|
||||
}
|
||||
},
|
||||
/* ED448: Keys from RFC 8032 */
|
||||
{
|
||||
/* Private Key */
|
||||
{
|
||||
0x6c, 0x82, 0xa5, 0x62, 0xcb, 0x80, 0x8d, 0x10, 0xd6, 0x32,
|
||||
0xbe, 0x89, 0xc8, 0x51, 0x3e, 0xbf, 0x6c, 0x92, 0x9f, 0x34,
|
||||
0xdd, 0xfa, 0x8c, 0x9f, 0x63, 0xc9, 0x96, 0x0e, 0xf6, 0xe3,
|
||||
0x48, 0xa3, 0x52, 0x8c, 0x8a, 0x3f, 0xcc, 0x2f, 0x04, 0x4e,
|
||||
0x39, 0xa3, 0xfc, 0x5b, 0x94, 0x49, 0x2f, 0x8f, 0x03, 0x2e,
|
||||
0x75, 0x49, 0xa2, 0x00, 0x98, 0xf9, 0x5b
|
||||
},
|
||||
/* Public Key */
|
||||
{
|
||||
0x5f, 0xd7, 0x44, 0x9b, 0x59, 0xb4, 0x61, 0xfd, 0x2c, 0xe7,
|
||||
0x87, 0xec, 0x61, 0x6a, 0xd4, 0x6a, 0x1d, 0xa1, 0x34, 0x24,
|
||||
0x85, 0xa7, 0x0e, 0x1f, 0x8a, 0x0e, 0xa7, 0x5d, 0x80, 0xe9,
|
||||
0x67, 0x78, 0xed, 0xf1, 0x24, 0x76, 0x9b, 0x46, 0xc7, 0x06,
|
||||
0x1b, 0xd6, 0x78, 0x3d, 0xf1, 0xe5, 0x0f, 0x6c, 0xd1, 0xfa,
|
||||
0x1a, 0xbe, 0xaf, 0xe8, 0x25, 0x61, 0x80
|
||||
}
|
||||
}
|
||||
};
|
||||
OSSL_PARAM x25519_fromdata_params[] = {
|
||||
@@ -459,19 +576,59 @@ static int test_fromdata_ecx(int tst)
|
||||
X448_KEYLEN),
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
OSSL_PARAM *fromdata_params;
|
||||
int bits, security_bits, size;
|
||||
OSSL_PARAM ed25519_fromdata_params[] = {
|
||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY,
|
||||
key_numbers[ED25519_IDX][PRIV_KEY],
|
||||
ED25519_KEYLEN),
|
||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PUB_KEY,
|
||||
key_numbers[ED25519_IDX][PUB_KEY],
|
||||
ED25519_KEYLEN),
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
OSSL_PARAM ed448_fromdata_params[] = {
|
||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY,
|
||||
key_numbers[ED448_IDX][PRIV_KEY],
|
||||
ED448_KEYLEN),
|
||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PUB_KEY,
|
||||
key_numbers[ED448_IDX][PUB_KEY],
|
||||
ED448_KEYLEN),
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
OSSL_PARAM *fromdata_params = NULL;
|
||||
int bits = 0, security_bits = 0, size = 0;
|
||||
|
||||
if (tst == X25519_IDX) {
|
||||
switch (tst) {
|
||||
case X25519_IDX:
|
||||
fromdata_params = x25519_fromdata_params;
|
||||
bits = X25519_BITS;
|
||||
security_bits = X25519_SECURITY_BITS;
|
||||
size = X25519_KEYLEN;
|
||||
} else {
|
||||
alg = "X25519";
|
||||
break;
|
||||
|
||||
case X448_IDX:
|
||||
fromdata_params = x448_fromdata_params;
|
||||
bits = X448_BITS;
|
||||
security_bits = X448_SECURITY_BITS;
|
||||
size = X448_KEYLEN;
|
||||
alg = "X448";
|
||||
break;
|
||||
|
||||
case ED25519_IDX:
|
||||
fromdata_params = ed25519_fromdata_params;
|
||||
bits = ED25519_BITS;
|
||||
security_bits = ED25519_SECURITY_BITS;
|
||||
size = ED25519_KEYLEN;
|
||||
alg = "ED25519";
|
||||
break;
|
||||
|
||||
case ED448_IDX:
|
||||
fromdata_params = ed448_fromdata_params;
|
||||
bits = ED448_BITS;
|
||||
security_bits = ED448_SECURITY_BITS;
|
||||
size = ED448_KEYLEN;
|
||||
alg = "ED448";
|
||||
break;
|
||||
}
|
||||
|
||||
ctx = EVP_PKEY_CTX_new_from_name(NULL, alg, NULL);
|
||||
@@ -485,27 +642,51 @@ static int test_fromdata_ecx(int tst)
|
||||
|| !TEST_int_eq(EVP_PKEY_size(pk), size))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(copy_pk = EVP_PKEY_new())
|
||||
|| !TEST_false(EVP_PKEY_copy_parameters(copy_pk, pk)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(EVP_PKEY_get_octet_string_param(
|
||||
pk, fromdata_params[PRIV_KEY].key,
|
||||
out_priv, sizeof(out_priv), &len))
|
||||
|| !TEST_mem_eq(out_priv, len,
|
||||
fromdata_params[PRIV_KEY].data,
|
||||
fromdata_params[PRIV_KEY].data_size)
|
||||
|| !TEST_true(EVP_PKEY_get_octet_string_param(
|
||||
pk, fromdata_params[PUB_KEY].key,
|
||||
out_pub, sizeof(out_pub), &len))
|
||||
|| !TEST_mem_eq(out_pub, len,
|
||||
fromdata_params[PUB_KEY].data,
|
||||
fromdata_params[PUB_KEY].data_size))
|
||||
goto err;
|
||||
|
||||
ret = test_print_key_using_pem(alg, pk)
|
||||
&& test_print_key_using_serializer(alg, pk);
|
||||
|
||||
err:
|
||||
EVP_PKEY_free(pk);
|
||||
EVP_PKEY_free(copy_pk);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define CURVE_NAME 2
|
||||
|
||||
static int test_fromdata_ec(void)
|
||||
{
|
||||
int ret = 0;
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
EVP_PKEY *pk = NULL;
|
||||
OSSL_PARAM_BLD bld;
|
||||
EVP_PKEY *pk = NULL, *copy_pk = NULL;
|
||||
OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new();
|
||||
BIGNUM *ec_priv_bn = NULL;
|
||||
BIGNUM *bn_priv = NULL;
|
||||
OSSL_PARAM *fromdata_params = NULL;
|
||||
const char *alg = "EC";
|
||||
const char *curve = "prime256v1";
|
||||
/* UNCOMPRESSED FORMAT */
|
||||
static const unsigned char ec_pub_keydata[] = {
|
||||
0x04,
|
||||
POINT_CONVERSION_UNCOMPRESSED,
|
||||
0x1b, 0x93, 0x67, 0x55, 0x1c, 0x55, 0x9f, 0x63,
|
||||
0xd1, 0x22, 0xa4, 0xd8, 0xd1, 0x0a, 0x60, 0x6d,
|
||||
0x02, 0xa5, 0x77, 0x57, 0xc8, 0xa3, 0x47, 0x73,
|
||||
@@ -521,23 +702,29 @@ static int test_fromdata_ec(void)
|
||||
0xcc, 0x0d, 0x9a, 0x24, 0x6c, 0x86, 0x1b, 0x2e,
|
||||
0xdc, 0x4b, 0x4d, 0x35, 0x43, 0xe1, 0x1b, 0xad
|
||||
};
|
||||
const int compressed_sz = 1 + (sizeof(ec_pub_keydata) - 1) / 2;
|
||||
unsigned char out_pub[sizeof(ec_pub_keydata)];
|
||||
char out_curve_name[80];
|
||||
const OSSL_PARAM *gettable = NULL;
|
||||
size_t len;
|
||||
|
||||
ossl_param_bld_init(&bld);
|
||||
|
||||
if (!TEST_ptr(bld))
|
||||
goto err;
|
||||
if (!TEST_ptr(ec_priv_bn = BN_bin2bn(ec_priv_keydata,
|
||||
sizeof(ec_priv_keydata), NULL)))
|
||||
goto err;
|
||||
|
||||
if (ossl_param_bld_push_utf8_string(&bld, OSSL_PKEY_PARAM_EC_NAME,
|
||||
"prime256v1", 0) <= 0)
|
||||
if (OSSL_PARAM_BLD_push_utf8_string(bld, OSSL_PKEY_PARAM_EC_NAME,
|
||||
curve, 0) <= 0)
|
||||
goto err;
|
||||
if (ossl_param_bld_push_octet_string(&bld, OSSL_PKEY_PARAM_PUB_KEY,
|
||||
if (OSSL_PARAM_BLD_push_octet_string(bld, OSSL_PKEY_PARAM_PUB_KEY,
|
||||
ec_pub_keydata,
|
||||
sizeof(ec_pub_keydata)) <= 0)
|
||||
goto err;
|
||||
if (ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_PRIV_KEY, ec_priv_bn) <= 0)
|
||||
if (OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PRIV_KEY, ec_priv_bn) <= 0)
|
||||
goto err;
|
||||
if (!TEST_ptr(fromdata_params = ossl_param_bld_to_param(&bld)))
|
||||
if (!TEST_ptr(fromdata_params = OSSL_PARAM_BLD_to_param(bld)))
|
||||
goto err;
|
||||
ctx = EVP_PKEY_CTX_new_from_name(NULL, alg, NULL);
|
||||
if (!TEST_ptr(ctx))
|
||||
@@ -550,12 +737,39 @@ static int test_fromdata_ec(void)
|
||||
|| !TEST_int_eq(EVP_PKEY_size(pk), 2 + 35 * 2))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(copy_pk = EVP_PKEY_new())
|
||||
|| !TEST_true(EVP_PKEY_copy_parameters(copy_pk, pk)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(gettable = EVP_PKEY_gettable_params(pk))
|
||||
|| !TEST_ptr(OSSL_PARAM_locate_const(gettable, OSSL_PKEY_PARAM_EC_NAME))
|
||||
|| !TEST_ptr(OSSL_PARAM_locate_const(gettable, OSSL_PKEY_PARAM_PUB_KEY))
|
||||
|| !TEST_ptr(OSSL_PARAM_locate_const(gettable, OSSL_PKEY_PARAM_PRIV_KEY)))
|
||||
goto err;
|
||||
|
||||
if (!EVP_PKEY_get_utf8_string_param(pk, OSSL_PKEY_PARAM_EC_NAME,
|
||||
out_curve_name, sizeof(out_curve_name),
|
||||
&len)
|
||||
|| !TEST_str_eq(out_curve_name, curve)
|
||||
|| !EVP_PKEY_get_octet_string_param(pk, OSSL_PKEY_PARAM_PUB_KEY,
|
||||
out_pub, sizeof(out_pub), &len)
|
||||
|| !TEST_true(out_pub[0] == (POINT_CONVERSION_COMPRESSED + 1))
|
||||
|| !TEST_mem_eq(out_pub + 1, len - 1,
|
||||
ec_pub_keydata + 1, compressed_sz - 1)
|
||||
|| !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_PRIV_KEY,
|
||||
&bn_priv))
|
||||
|| !TEST_BN_eq(ec_priv_bn, bn_priv))
|
||||
goto err;
|
||||
|
||||
ret = test_print_key_using_pem(alg, pk)
|
||||
&& test_print_key_using_serializer(alg, pk);
|
||||
err:
|
||||
BN_free(bn_priv);
|
||||
BN_free(ec_priv_bn);
|
||||
ossl_param_bld_free(fromdata_params);
|
||||
OSSL_PARAM_BLD_free_params(fromdata_params);
|
||||
OSSL_PARAM_BLD_free(bld);
|
||||
EVP_PKEY_free(pk);
|
||||
EVP_PKEY_free(copy_pk);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
return ret;
|
||||
}
|
||||
@@ -572,12 +786,13 @@ int setup_tests(void)
|
||||
if (!TEST_ptr(datadir = test_get_argument(0)))
|
||||
return 0;
|
||||
|
||||
ADD_TEST(test_evp_pkey_get_bn_param_large);
|
||||
ADD_TEST(test_fromdata_rsa);
|
||||
#ifndef OPENSSL_NO_DH
|
||||
ADD_TEST(test_fromdata_dh);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
ADD_ALL_TESTS(test_fromdata_ecx, 2);
|
||||
ADD_ALL_TESTS(test_fromdata_ecx, 4);
|
||||
ADD_TEST(test_fromdata_ec);
|
||||
#endif
|
||||
return 1;
|
||||
|
||||
+5
-4
@@ -2504,8 +2504,8 @@ static int keygen_test_run(EVP_TEST *t)
|
||||
{
|
||||
KEYGEN_TEST_DATA *keygen = t->data;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
int rv = 1;
|
||||
|
||||
t->err = NULL;
|
||||
if (EVP_PKEY_keygen(keygen->genctx, &pkey) <= 0) {
|
||||
t->err = "KEYGEN_GENERATE_ERROR";
|
||||
goto err;
|
||||
@@ -2514,6 +2514,7 @@ static int keygen_test_run(EVP_TEST *t)
|
||||
if (keygen->keyname != NULL) {
|
||||
KEY_LIST *key;
|
||||
|
||||
rv = 0;
|
||||
if (find_key(NULL, keygen->keyname, private_keys)) {
|
||||
TEST_info("Duplicate key %s", keygen->keyname);
|
||||
goto err;
|
||||
@@ -2526,15 +2527,15 @@ static int keygen_test_run(EVP_TEST *t)
|
||||
key->key = pkey;
|
||||
key->next = private_keys;
|
||||
private_keys = key;
|
||||
rv = 1;
|
||||
} else {
|
||||
EVP_PKEY_free(pkey);
|
||||
}
|
||||
|
||||
return 1;
|
||||
t->err = NULL;
|
||||
|
||||
err:
|
||||
EVP_PKEY_free(pkey);
|
||||
return 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
static const EVP_TEST_METHOD keygen_test_method = {
|
||||
|
||||
+9
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2018-2020 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
|
||||
@@ -28,6 +28,14 @@ static struct {
|
||||
/* Server doesn't have a TLSv1.3 capable cert - should use TLSv1.2 */
|
||||
{"GOST2012-GOST8912-GOST8912", TLS1_2_VERSION, 1},
|
||||
/* Server doesn't have a TLSv1.3 capable cert - should use TLSv1.2 */
|
||||
{"IANA-GOST2012-GOST8912-GOST8912", TLS1_2_VERSION, 0},
|
||||
/* Server doesn't have a TLSv1.3 capable cert - should use TLSv1.2 */
|
||||
{"IANA-GOST2012-GOST8912-GOST8912", TLS1_2_VERSION, 1},
|
||||
/* Server doesn't have a TLSv1.3 capable cert - should use TLSv1.2 */
|
||||
{"LEGACY-GOST2012-GOST8912-GOST8912", TLS1_2_VERSION, 0},
|
||||
/* Server doesn't have a TLSv1.3 capable cert - should use TLSv1.2 */
|
||||
{"LEGACY-GOST2012-GOST8912-GOST8912", TLS1_2_VERSION, 1},
|
||||
/* Server doesn't have a TLSv1.3 capable cert - should use TLSv1.2 */
|
||||
{"GOST2001-GOST89-GOST89", TLS1_2_VERSION, 0},
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -125,14 +125,14 @@ static int test_http_x509(int do_get)
|
||||
rcert = (X509 *)
|
||||
(do_get ?
|
||||
OSSL_HTTP_get_asn1("http://"SERVER":"PORT"/"RPATH,
|
||||
NULL /* proxy */, NULL /* proxy_port */,
|
||||
NULL /* proxy */, NULL /* no_proxy */,
|
||||
wbio, rbio, NULL /* bio_update_fn */, NULL,
|
||||
headers, 0 /* maxline */,
|
||||
0 /* max_resp_len */, 0 /* timeout */,
|
||||
"application/x-x509-ca-cert", x509_it)
|
||||
:
|
||||
OSSL_HTTP_post_asn1(SERVER, PORT, RPATH, 0 /* use_ssl */,
|
||||
NULL /* proxy */, NULL /* proxy_port */,
|
||||
NULL /* proxy */, NULL /* no_proxy */,
|
||||
wbio, rbio, NULL /* bio_update_fn */, NULL,
|
||||
headers, "application/x-x509-ca-cert",
|
||||
(ASN1_VALUE *)x509, x509_it, 0 /* maxline */,
|
||||
|
||||
@@ -66,7 +66,7 @@ static FIXTURE *set_up(const char *testcase_name)
|
||||
#define DQ 7
|
||||
#define E3 8 /* Extra exponent */
|
||||
#define QINV 9
|
||||
#define C3 10 /* Extra coefficient */
|
||||
#define C2 10 /* Extra coefficient */
|
||||
|
||||
/*
|
||||
* We have to do this because OSSL_PARAM_get_ulong() can't handle params
|
||||
@@ -92,10 +92,6 @@ static int export_cb(const OSSL_PARAM *params, void *arg)
|
||||
{
|
||||
unsigned long *keydata = arg;
|
||||
const OSSL_PARAM *p = NULL;
|
||||
int factors_idx;
|
||||
int exponents_idx;
|
||||
int coefficients_idx;
|
||||
int ret = 1; /* Ever so hopeful */
|
||||
|
||||
if (keydata == NULL)
|
||||
return 0;
|
||||
@@ -106,35 +102,31 @@ static int export_cb(const OSSL_PARAM *params, void *arg)
|
||||
|| !TEST_true(get_ulong_via_BN(p, &keydata[E]))
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_D))
|
||||
|| !TEST_true(get_ulong_via_BN(p, &keydata[D])))
|
||||
ret = 0;
|
||||
return 0;
|
||||
|
||||
for (p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_FACTOR),
|
||||
factors_idx = P;
|
||||
p != NULL && factors_idx <= F3;
|
||||
p = OSSL_PARAM_locate_const(p + 1, OSSL_PKEY_PARAM_RSA_FACTOR),
|
||||
factors_idx++)
|
||||
if (!TEST_true(get_ulong_via_BN(p, &keydata[factors_idx])))
|
||||
ret = 0;
|
||||
for (p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_EXPONENT),
|
||||
exponents_idx = DP;
|
||||
p != NULL && exponents_idx <= E3;
|
||||
p = OSSL_PARAM_locate_const(p + 1, OSSL_PKEY_PARAM_RSA_EXPONENT),
|
||||
exponents_idx++)
|
||||
if (!TEST_true(get_ulong_via_BN(p, &keydata[exponents_idx])))
|
||||
ret = 0;
|
||||
for (p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_COEFFICIENT),
|
||||
coefficients_idx = QINV;
|
||||
p != NULL && coefficients_idx <= C3;
|
||||
p = OSSL_PARAM_locate_const(p + 1, OSSL_PKEY_PARAM_RSA_COEFFICIENT),
|
||||
coefficients_idx++)
|
||||
if (!TEST_true(get_ulong_via_BN(p, &keydata[coefficients_idx])))
|
||||
ret = 0;
|
||||
if (!TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_FACTOR1))
|
||||
|| !TEST_true(get_ulong_via_BN(p, &keydata[P]))
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_FACTOR2))
|
||||
|| !TEST_true(get_ulong_via_BN(p, &keydata[Q]))
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_FACTOR3))
|
||||
|| !TEST_true(get_ulong_via_BN(p, &keydata[F3])))
|
||||
return 0;
|
||||
|
||||
if (!TEST_int_le(factors_idx, F3)
|
||||
|| !TEST_int_le(exponents_idx, E3)
|
||||
|| !TEST_int_le(coefficients_idx, C3))
|
||||
ret = 0;
|
||||
return ret;
|
||||
if (!TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_EXPONENT1))
|
||||
|| !TEST_true(get_ulong_via_BN(p, &keydata[DP]))
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_EXPONENT2))
|
||||
|| !TEST_true(get_ulong_via_BN(p, &keydata[DQ]))
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_EXPONENT3))
|
||||
|| !TEST_true(get_ulong_via_BN(p, &keydata[E3])))
|
||||
return 0;
|
||||
|
||||
if (!TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_COEFFICIENT1))
|
||||
|| !TEST_true(get_ulong_via_BN(p, &keydata[QINV]))
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_COEFFICIENT2))
|
||||
|| !TEST_true(get_ulong_via_BN(p, &keydata[C2])))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int test_pass_rsa(FIXTURE *fixture)
|
||||
@@ -146,9 +138,13 @@ static int test_pass_rsa(FIXTURE *fixture)
|
||||
EVP_PKEY *pk = NULL;
|
||||
EVP_KEYMGMT *km1 = NULL, *km2 = NULL;
|
||||
void *provkey = NULL;
|
||||
BIGNUM *bn_primes[1] = { NULL };
|
||||
BIGNUM *bn_exps[1] = { NULL };
|
||||
BIGNUM *bn_coeffs[1] = { NULL };
|
||||
/*
|
||||
* 32-bit RSA key, extracted from this command,
|
||||
* executed with OpenSSL 1.0.2:
|
||||
* An extra factor was added just for testing purposes.
|
||||
*
|
||||
* openssl genrsa 32 | openssl rsa -text
|
||||
*/
|
||||
@@ -158,12 +154,12 @@ static int test_pass_rsa(FIXTURE *fixture)
|
||||
0x7b133399, /* D */
|
||||
0xe963, /* P */
|
||||
0xceb7, /* Q */
|
||||
0, /* F3 */
|
||||
1, /* F3 */
|
||||
0x8599, /* DP */
|
||||
0xbd87, /* DQ */
|
||||
0, /* E3 */
|
||||
2, /* E3 */
|
||||
0xcc3b, /* QINV */
|
||||
0, /* C3 */
|
||||
3, /* C3 */
|
||||
0 /* Extra, should remain zero */
|
||||
};
|
||||
static unsigned long keydata[OSSL_NELEM(expected)] = { 0, };
|
||||
@@ -197,6 +193,16 @@ static int test_pass_rsa(FIXTURE *fixture)
|
||||
goto err;
|
||||
bn1 = bn2 = bn3 = NULL;
|
||||
|
||||
if (!TEST_ptr(bn_primes[0] = BN_new())
|
||||
|| !TEST_true(BN_set_word(bn_primes[0], expected[F3]))
|
||||
|| !TEST_ptr(bn_exps[0] = BN_new())
|
||||
|| !TEST_true(BN_set_word(bn_exps[0], expected[E3]))
|
||||
|| !TEST_ptr(bn_coeffs[0] = BN_new())
|
||||
|| !TEST_true(BN_set_word(bn_coeffs[0], expected[C2]))
|
||||
|| !TEST_true(RSA_set0_multi_prime_params(rsa, bn_primes, bn_exps,
|
||||
bn_coeffs, 1)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(pk = EVP_PKEY_new())
|
||||
|| !TEST_true(EVP_PKEY_assign_RSA(pk, rsa)))
|
||||
goto err;
|
||||
@@ -207,14 +213,10 @@ static int test_pass_rsa(FIXTURE *fixture)
|
||||
|| !TEST_ptr_ne(km1, km2))
|
||||
goto err;
|
||||
|
||||
if (!TEST_ptr(evp_pkey_export_to_provider(pk, NULL, &km1, NULL))
|
||||
|| !TEST_ptr(evp_pkey_upgrade_to_provider(pk, NULL, &km1, NULL))
|
||||
|| !TEST_ptr(provkey = evp_keymgmt_util_export_to_provider(pk, km2)))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(evp_keymgmt_export(km2, provkey,
|
||||
OSSL_KEYMGMT_SELECT_KEYPAIR,
|
||||
&export_cb, keydata)))
|
||||
if (!TEST_ptr(provkey = evp_pkey_export_to_provider(pk, NULL, &km1, NULL))
|
||||
|| !TEST_true(evp_keymgmt_export(km2, provkey,
|
||||
OSSL_KEYMGMT_SELECT_KEYPAIR,
|
||||
&export_cb, keydata)))
|
||||
goto err;
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -182,7 +182,7 @@ err:
|
||||
|
||||
static int test_ocsp_url_svcloc_new(void)
|
||||
{
|
||||
static const char * urls[] = {
|
||||
static const char *urls[] = {
|
||||
"www.openssl.org",
|
||||
"www.openssl.net",
|
||||
NULL
|
||||
|
||||
@@ -41,6 +41,7 @@ static const OSSL_PARAM p_param_types[] = {
|
||||
/* This is a trick to ensure we define the provider functions correctly */
|
||||
static OSSL_provider_gettable_params_fn p_gettable_params;
|
||||
static OSSL_provider_get_params_fn p_get_params;
|
||||
static OSSL_provider_get_reason_strings_fn p_get_reason_strings;
|
||||
|
||||
static const OSSL_PARAM *p_gettable_params(void *_)
|
||||
{
|
||||
@@ -100,9 +101,21 @@ static int p_get_params(void *vprov, OSSL_PARAM params[])
|
||||
return ok;
|
||||
}
|
||||
|
||||
static const OSSL_ITEM *p_get_reason_strings(void *_)
|
||||
{
|
||||
static const OSSL_ITEM reason_strings[] = {
|
||||
{1, "dummy reason string"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
return reason_strings;
|
||||
}
|
||||
|
||||
static const OSSL_DISPATCH p_test_table[] = {
|
||||
{ OSSL_FUNC_PROVIDER_GETTABLE_PARAMS, (void (*)(void))p_gettable_params },
|
||||
{ OSSL_FUNC_PROVIDER_GET_PARAMS, (void (*)(void))p_get_params },
|
||||
{ OSSL_FUNC_PROVIDER_GET_REASON_STRINGS,
|
||||
(void (*)(void))p_get_reason_strings},
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
|
||||
+71
-25
@@ -10,13 +10,13 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <openssl/params.h>
|
||||
#include "internal/param_build.h"
|
||||
#include "openssl/param_build.h"
|
||||
#include "internal/nelem.h"
|
||||
#include "testutil.h"
|
||||
|
||||
static int template_public_test(void)
|
||||
{
|
||||
OSSL_PARAM_BLD bld;
|
||||
OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new();
|
||||
OSSL_PARAM *params = NULL, *p;
|
||||
BIGNUM *bn = NULL, *bn_res = NULL;
|
||||
int i;
|
||||
@@ -28,20 +28,20 @@ static int template_public_test(void)
|
||||
const char *cutf;
|
||||
int res = 0;
|
||||
|
||||
ossl_param_bld_init(&bld);
|
||||
if (!TEST_true(ossl_param_bld_push_int(&bld, "i", -6))
|
||||
|| !TEST_true(ossl_param_bld_push_long(&bld, "l", 42))
|
||||
|| !TEST_true(ossl_param_bld_push_int32(&bld, "i32", 1532))
|
||||
|| !TEST_true(ossl_param_bld_push_int64(&bld, "i64", -9999999))
|
||||
|| !TEST_true(ossl_param_bld_push_double(&bld, "d", 1.61803398875))
|
||||
if (!TEST_ptr(bld)
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_int(bld, "i", -6))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_long(bld, "l", 42))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_int32(bld, "i32", 1532))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_int64(bld, "i64", -9999999))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_double(bld, "d", 1.61803398875))
|
||||
|| !TEST_ptr(bn = BN_new())
|
||||
|| !TEST_true(BN_set_word(bn, 1729))
|
||||
|| !TEST_true(ossl_param_bld_push_BN(&bld, "bignumber", bn))
|
||||
|| !TEST_true(ossl_param_bld_push_utf8_string(&bld, "utf8_s", "foo",
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, "bignumber", bn))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_utf8_string(bld, "utf8_s", "foo",
|
||||
sizeof("foo")))
|
||||
|| !TEST_true(ossl_param_bld_push_utf8_ptr(&bld, "utf8_p", "bar-boom",
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_utf8_ptr(bld, "utf8_p", "bar-boom",
|
||||
0))
|
||||
|| !TEST_ptr(params = ossl_param_bld_to_param(&bld))
|
||||
|| !TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld))
|
||||
/* Check int */
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "i"))
|
||||
|| !TEST_true(OSSL_PARAM_get_int(p, &i))
|
||||
@@ -95,7 +95,8 @@ static int template_public_test(void)
|
||||
goto err;
|
||||
res = 1;
|
||||
err:
|
||||
ossl_param_bld_free(params);
|
||||
OSSL_PARAM_BLD_free_params(params);
|
||||
OSSL_PARAM_BLD_free(bld);
|
||||
OPENSSL_free(utf);
|
||||
BN_free(bn);
|
||||
BN_free(bn_res);
|
||||
@@ -106,7 +107,7 @@ static int template_private_test(void)
|
||||
{
|
||||
static int data1[] = { 2, 3, 5, 7, 11, 15, 17 };
|
||||
static unsigned char data2[] = { 2, 4, 6, 8, 10 };
|
||||
OSSL_PARAM_BLD bld;
|
||||
OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new();
|
||||
OSSL_PARAM *params = NULL, *p;
|
||||
unsigned int i;
|
||||
unsigned long int l;
|
||||
@@ -116,20 +117,20 @@ static int template_private_test(void)
|
||||
BIGNUM *bn = NULL, *bn_res = NULL;
|
||||
int res = 0;
|
||||
|
||||
ossl_param_bld_init(&bld);
|
||||
if (!TEST_true(ossl_param_bld_push_uint(&bld, "i", 6))
|
||||
|| !TEST_true(ossl_param_bld_push_ulong(&bld, "l", 42))
|
||||
|| !TEST_true(ossl_param_bld_push_uint32(&bld, "i32", 1532))
|
||||
|| !TEST_true(ossl_param_bld_push_uint64(&bld, "i64", 9999999))
|
||||
|| !TEST_true(ossl_param_bld_push_size_t(&bld, "st", 65537))
|
||||
if (!TEST_ptr(bld)
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_uint(bld, "i", 6))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_ulong(bld, "l", 42))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_uint32(bld, "i32", 1532))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_uint64(bld, "i64", 9999999))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_size_t(bld, "st", 65537))
|
||||
|| !TEST_ptr(bn = BN_secure_new())
|
||||
|| !TEST_true(BN_set_word(bn, 1729))
|
||||
|| !TEST_true(ossl_param_bld_push_BN(&bld, "bignumber", bn))
|
||||
|| !TEST_true(ossl_param_bld_push_octet_string(&bld, "oct_s", data1,
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_BN(bld, "bignumber", bn))
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_octet_string(bld, "oct_s", data1,
|
||||
sizeof(data1)))
|
||||
|| !TEST_true(ossl_param_bld_push_octet_ptr(&bld, "oct_p", data2,
|
||||
|| !TEST_true(OSSL_PARAM_BLD_push_octet_ptr(bld, "oct_p", data2,
|
||||
sizeof(data2)))
|
||||
|| !TEST_ptr(params = ossl_param_bld_to_param(&bld))
|
||||
|| !TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld))
|
||||
/* Check unsigned int */
|
||||
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "i"))
|
||||
|| !TEST_true(OSSL_PARAM_get_uint(p, &i))
|
||||
@@ -184,15 +185,60 @@ static int template_private_test(void)
|
||||
goto err;
|
||||
res = 1;
|
||||
err:
|
||||
ossl_param_bld_free(params);
|
||||
OSSL_PARAM_BLD_free_params(params);
|
||||
OSSL_PARAM_BLD_free(bld);
|
||||
BN_free(bn);
|
||||
BN_free(bn_res);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int builder_limit_test(void)
|
||||
{
|
||||
const int n = 100;
|
||||
char names[100][3];
|
||||
OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new();
|
||||
OSSL_PARAM *params = NULL;
|
||||
int i, res = 0;
|
||||
|
||||
if (!TEST_ptr(bld))
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
names[i][0] = 'A' + (i / 26) - 1;
|
||||
names[i][0] = 'a' + (i % 26) - 1;
|
||||
names[i][2] = '\0';
|
||||
if (!TEST_true(OSSL_PARAM_BLD_push_int(bld, names[i], 3 * i + 1)))
|
||||
goto err;
|
||||
}
|
||||
if (!TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld)))
|
||||
goto err;
|
||||
/* Count the elements in the params arrary, expecting n */
|
||||
for (i = 0; params[i].key != NULL; i++);
|
||||
if (!TEST_int_eq(i, n))
|
||||
goto err;
|
||||
|
||||
/* Verify that the build, cleared the builder structure */
|
||||
OSSL_PARAM_BLD_free_params(params);
|
||||
params = NULL;
|
||||
|
||||
if (!TEST_true(OSSL_PARAM_BLD_push_int(bld, "g", 2))
|
||||
|| !TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld)))
|
||||
goto err;
|
||||
/* Count the elements in the params arrary, expecting 1 */
|
||||
for (i = 0; params[i].key != NULL; i++);
|
||||
if (!TEST_int_eq(i, 1))
|
||||
goto err;
|
||||
res = 1;
|
||||
err:
|
||||
OSSL_PARAM_BLD_free_params(params);
|
||||
OSSL_PARAM_BLD_free(bld);
|
||||
return res;
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(template_public_test);
|
||||
ADD_TEST(template_private_test);
|
||||
ADD_TEST(builder_limit_test);
|
||||
return 1;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ use platform;
|
||||
|
||||
plan skip_all => "Test only supported in a fips build" if disabled("fips");
|
||||
|
||||
plan tests => 10;
|
||||
plan tests => 12;
|
||||
|
||||
my $infile = bldtop_file('providers', platform->dso('fips'));
|
||||
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
|
||||
@@ -99,3 +99,21 @@ ok(!run(app(['openssl', 'fipsinstall', '-out', 'fips.cnf', '-module', $infile,
|
||||
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
|
||||
'-section_name', 'fips_install', '-corrupt_desc', 'CTR'])),
|
||||
"fipsinstall fails when the DRBG CTR result is corrupted");
|
||||
|
||||
# corrupt a KAS test
|
||||
ok(!run(app(['openssl', 'fipsinstall', '-out', 'fips.conf', '-module', $infile,
|
||||
'-provider_name', 'fips', '-mac_name', 'HMAC',
|
||||
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
|
||||
'-section_name', 'fips_install',
|
||||
'-corrupt_desc', 'DH',
|
||||
'-corrupt_type', 'KAT_KA'])),
|
||||
"fipsinstall fails when the kas result is corrupted");
|
||||
|
||||
# corrupt a Signature test
|
||||
ok(!run(app(['openssl', 'fipsinstall', '-out', 'fips.conf', '-module', $infile,
|
||||
'-provider_name', 'fips', '-mac_name', 'HMAC',
|
||||
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
|
||||
'-section_name', 'fips_install',
|
||||
'-corrupt_desc', 'DSA',
|
||||
'-corrupt_type', 'KAT_Signature'])),
|
||||
"fipsinstall fails when the signature result is corrupted");
|
||||
@@ -15,3 +15,5 @@ setup("test_rand");
|
||||
|
||||
ok(run(test(["drbgtest"])));
|
||||
ok(run(test(["drbg_cavs_test"])));
|
||||
# commented out due to long running time
|
||||
#ok(run(test(["drbg_extra_test"])));
|
||||
@@ -14,7 +14,7 @@ use File::Spec::Functions qw/catfile/;
|
||||
use File::Copy;
|
||||
use File::Compare qw/compare_text/;
|
||||
use File::Basename;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file bldtop_dir/;
|
||||
|
||||
setup("test_enc");
|
||||
|
||||
@@ -26,6 +26,8 @@ my $testsrc = srctop_file("test","recipes",basename($0));
|
||||
my $test = catfile(".", "p");
|
||||
|
||||
my $cmd = "openssl";
|
||||
my $provpath = bldtop_dir("providers");
|
||||
my @prov = ("-provider_path", $provpath, "-provider", "default", "-provider", "legacy");
|
||||
|
||||
my $ciphersstatus = undef;
|
||||
my @ciphers =
|
||||
@@ -59,8 +61,8 @@ plan tests => 2 + (scalar @ciphers)*2;
|
||||
@d = ( "enc", @{$variant{$t}}, "-d" );
|
||||
}
|
||||
|
||||
ok(run(app([$cmd, @e, "-in", $test, "-out", $cipherfile]))
|
||||
&& run(app([$cmd, @d, "-in", $cipherfile, "-out", $clearfile]))
|
||||
ok(run(app([$cmd, @e, @prov, "-in", $test, "-out", $cipherfile]))
|
||||
&& run(app([$cmd, @d, @prov, "-in", $cipherfile, "-out", $clearfile]))
|
||||
&& compare_text($test,$clearfile) == 0, $t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ use File::Spec::Functions qw/catfile/;
|
||||
use File::Copy;
|
||||
use File::Compare qw/compare_text/;
|
||||
use File::Basename;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file bldtop_dir/;
|
||||
|
||||
setup("test_evp_more");
|
||||
|
||||
@@ -25,6 +25,8 @@ my $cipherlist = undef;
|
||||
my $plaintext = catfile(".", "testdatafile");
|
||||
my $fail = "";
|
||||
my $cmd = "openssl";
|
||||
my $provpath = bldtop_dir("providers");
|
||||
my @prov = ("-provider_path", $provpath, "-provider", "default", "-provider", "legacy");
|
||||
|
||||
my $ciphersstatus = undef;
|
||||
my @ciphers =
|
||||
@@ -49,9 +51,9 @@ SKIP: {
|
||||
my $clearfile = "$plaintext.$ciphername.clear";
|
||||
my @common = ( $cmd, "enc", "$cipher", "-k", "test" );
|
||||
|
||||
ok(run(app([@common, "-e", "-in", $plaintext, "-out", $cipherfile]))
|
||||
ok(run(app([@common, @prov, "-e", "-in", $plaintext, "-out", $cipherfile]))
|
||||
&& compare_text($plaintext, $cipherfile) != 0
|
||||
&& run(app([@common, "-d", "-in", $cipherfile, "-out", $clearfile]))
|
||||
&& run(app([@common, @prov, "-d", "-in", $cipherfile, "-out", $clearfile]))
|
||||
&& compare_text($plaintext, $clearfile) == 0
|
||||
, $ciphername);
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ SKIP: {
|
||||
'-in', srctop_file('test', 'certs', 'sm2.pem'),
|
||||
'-inkey', srctop_file('test', 'certs', 'sm2.key'),
|
||||
'-out', 'sm2.sig', '-rawin',
|
||||
'-digest', 'sm3', '-pkeyopt', 'sm2_id:someid']))),
|
||||
'-digest', 'sm3', '-pkeyopt', 'distid:someid']))),
|
||||
"Sign a piece of data using SM2");
|
||||
ok_nofips(run(app(([ 'openssl', 'pkeyutl', '-verify', '-certin',
|
||||
'-in', srctop_file('test', 'certs', 'sm2.pem'),
|
||||
'-inkey', srctop_file('test', 'certs', 'sm2.pem'),
|
||||
'-sigfile', 'sm2.sig', '-rawin',
|
||||
'-digest', 'sm3', '-pkeyopt', 'sm2_id:someid']))),
|
||||
'-digest', 'sm3', '-pkeyopt', 'distid:someid']))),
|
||||
"Verify an SM2 signature against a piece of data");
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use OpenSSL::Test;
|
||||
|
||||
setup("test_provider");
|
||||
|
||||
plan tests => 7;
|
||||
plan tests => 9;
|
||||
|
||||
SKIP: {
|
||||
skip "No default provider?", 6
|
||||
@@ -45,3 +45,18 @@ plan tests => 7;
|
||||
}
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip "No null provider?", 1
|
||||
unless ok(run(app([qw(openssl provider null)])),
|
||||
"try running 'openssl provider null'");
|
||||
|
||||
my @cmd = ('openssl', 'provider', '-vvv', 'null');
|
||||
my @lines = ( map { (my $x = $_) =~ s|\R$||; $x }
|
||||
run(app([@cmd]), capture => 1) );
|
||||
|
||||
my $curr = scalar @lines;
|
||||
my $cmp = "$curr == 1";
|
||||
ok(eval $cmp,
|
||||
"'openssl provider $_ default' line count == 1");
|
||||
}
|
||||
|
||||
@@ -191,27 +191,27 @@ subtest "generating SM2 certificate requests" => sub {
|
||||
ok(run(app(["openssl", "req",
|
||||
"-config", srctop_file("test", "test.cnf"),
|
||||
"-new", "-key", srctop_file("test", "certs", "sm2.key"),
|
||||
"-sigopt", "sm2_id:1234567812345678",
|
||||
"-sigopt", "distid:1234567812345678",
|
||||
"-out", "testreq-sm2.pem", "-sm3"])),
|
||||
"Generating SM2 certificate request");
|
||||
|
||||
ok(run(app(["openssl", "req",
|
||||
"-config", srctop_file("test", "test.cnf"),
|
||||
"-verify", "-in", "testreq-sm2.pem", "-noout",
|
||||
"-sm2-id", "1234567812345678", "-sm3"])),
|
||||
"-vfyopt", "distid:1234567812345678", "-sm3"])),
|
||||
"Verifying signature on SM2 certificate request");
|
||||
|
||||
ok(run(app(["openssl", "req",
|
||||
"-config", srctop_file("test", "test.cnf"),
|
||||
"-new", "-key", srctop_file("test", "certs", "sm2.key"),
|
||||
"-sigopt", "sm2_hex_id:DEADBEEF",
|
||||
"-sigopt", "hexdistid:DEADBEEF",
|
||||
"-out", "testreq-sm2.pem", "-sm3"])),
|
||||
"Generating SM2 certificate request with hex id");
|
||||
|
||||
ok(run(app(["openssl", "req",
|
||||
"-config", srctop_file("test", "test.cnf"),
|
||||
"-verify", "-in", "testreq-sm2.pem", "-noout",
|
||||
"-sm2-hex-id", "DEADBEEF", "-sm3"])),
|
||||
"-vfyopt", "hexdistid:DEADBEEF", "-sm3"])),
|
||||
"Verifying signature on SM2 certificate request");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2020 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 warnings;
|
||||
|
||||
use File::Spec;
|
||||
use OpenSSL::Test::Utils;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
||||
|
||||
setup("test_rusext");
|
||||
|
||||
plan tests => 5;
|
||||
|
||||
require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));
|
||||
my $pem = srctop_file("test/certs", "grfc.pem");
|
||||
my $out_msb = "grfc.msb";
|
||||
my $out_utf8 = "grfc.utf8";
|
||||
|
||||
ok(run(app(["openssl", "x509", "-text", "-in", $pem, "-out", $out_msb,
|
||||
"-nameopt", "esc_msb", "-certopt", "no_pubkey"])));
|
||||
is(cmp_text($out_msb, srctop_file('test', 'recipes', '25-test_rusext_data', 'grfc.msb')),
|
||||
0, 'Comparing esc_msb output');
|
||||
ok(run(app(["openssl", "x509", "-text", "-in", $pem, "-out", $out_utf8,
|
||||
"-nameopt", "utf8", "-certopt", "no_pubkey"])));
|
||||
is(cmp_text($out_utf8, srctop_file('test', 'recipes', '25-test_rusext_data', 'grfc.utf8')),
|
||||
0, 'Comparing utf8 output');
|
||||
@@ -0,0 +1,67 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number:
|
||||
0c:8c:40:93:bb:e6:93:bd:43:0b:f5:18:26:03:1d:05
|
||||
Signature Algorithm: GOST R 34.11-94 with GOST R 34.10-2001
|
||||
Issuer: OGRN=1027739334479, INN=007706228218, street=\U0414\U0435\U0440\U0431\U0435\U043D\U0435\U0432\U0441\U043A\U0430\U044F \U043D\U0430\U0431. \U0434. 7 \U0441\U0442\U0440. 15, emailAddress=pki-grfc@grfc.ru, C=RU, ST=77 \U0433. \U041C\U043E\U0441\U043A\U0432\U0430, L=\U041C\U043E\U0441\U043A\U0432\U0430, O=\U0424\U0413\U0423\U041F "\U0413\U0420\U0427\U0426", CN=\U0423\U0426 \U0424\U0413\U0423\U041F "\U0413\U0420\U0427\U0426"
|
||||
Validity
|
||||
Not Before: Mar 12 07:38:26 2013 GMT
|
||||
Not After : Mar 12 07:46:00 2028 GMT
|
||||
Subject: OGRN=1027739334479, INN=007706228218, street=\U0414\U0435\U0440\U0431\U0435\U043D\U0435\U0432\U0441\U043A\U0430\U044F \U043D\U0430\U0431. \U0434. 7 \U0441\U0442\U0440. 15, emailAddress=pki-grfc@grfc.ru, C=RU, ST=77 \U0433. \U041C\U043E\U0441\U043A\U0432\U0430, L=\U041C\U043E\U0441\U043A\U0432\U0430, O=\U0424\U0413\U0423\U041F "\U0413\U0420\U0427\U0426", CN=\U0423\U0426 \U0424\U0413\U0423\U041F "\U0413\U0420\U0427\U0426"
|
||||
X509v3 extensions:
|
||||
Signing Tool of Subject:
|
||||
"КриптоПро CSP" (версия 3.6)
|
||||
Signing Tool of Issuer:
|
||||
signTool : "КриптоПро CSP" (версия 3.6)
|
||||
cATool : "Удостоверяющий центр "КриптоПро УЦ" версии 1.5
|
||||
signToolCert: Сертификат соответствия № СФ/121-1859 от 17.06.2012
|
||||
cAToolCert : Сертификат соответствия № СФ/128-1822 от 01.06.2012
|
||||
X509v3 Key Usage:
|
||||
Digital Signature, Certificate Sign, CRL Sign
|
||||
X509v3 Basic Constraints: critical
|
||||
CA:TRUE
|
||||
X509v3 Subject Key Identifier:
|
||||
6B:00:86:83:89:D2:00:CF:56:B8:6B:E4:E3:36:10:1E:1F:72:AE:C3
|
||||
1.3.6.1.4.1.311.21.1:
|
||||
...
|
||||
X509v3 Certificate Policies:
|
||||
Policy: 1.2.643.100.113.1
|
||||
Policy: 1.2.643.100.113.2
|
||||
Policy: X509v3 Any Policy
|
||||
Signature Algorithm: GOST R 34.11-94 with GOST R 34.10-2001
|
||||
Signature Value:
|
||||
bd:95:dd:5f:3a:2b:74:a5:29:62:20:c2:24:a8:8b:a0:13:1a:
|
||||
21:f5:4a:d6:2e:b1:3f:f5:50:e9:96:a0:a2:c9:79:09:15:a2:
|
||||
41:c0:60:e1:1d:3f:25:8d:88:f4:4c:60:f3:0f:4e:e3:29:6e:
|
||||
b8:6e:01:b4:03:2c:07:8f:27:37
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFGDCCBMegAwIBAgIQDIxAk7vmk71DC/UYJgMdBTAIBgYqhQMCAgMwggEWMRgw
|
||||
FgYFKoUDZAESDTEwMjc3MzkzMzQ0NzkxGjAYBggqhQMDgQMBARIMMDA3NzA2MjI4
|
||||
MjE4MTowOAYDVQQJDDHQlNC10YDQsdC10L3QtdCy0YHQutCw0Y8g0L3QsNCxLiDQ
|
||||
tC4gNyDRgdGC0YAuIDE1MR8wHQYJKoZIhvcNAQkBFhBwa2ktZ3JmY0BncmZjLnJ1
|
||||
MQswCQYDVQQGEwJSVTEcMBoGA1UECAwTNzcg0LMuINCc0L7RgdC60LLQsDEVMBMG
|
||||
A1UEBwwM0JzQvtGB0LrQstCwMRwwGgYDVQQKDBPQpNCT0KPQnyAi0JPQoNCn0KYi
|
||||
MSEwHwYDVQQDDBjQo9CmINCk0JPQo9CfICLQk9Cg0KfQpiIwHhcNMTMwMzEyMDcz
|
||||
ODI2WhcNMjgwMzEyMDc0NjAwWjCCARYxGDAWBgUqhQNkARINMTAyNzczOTMzNDQ3
|
||||
OTEaMBgGCCqFAwOBAwEBEgwwMDc3MDYyMjgyMTgxOjA4BgNVBAkMMdCU0LXRgNCx
|
||||
0LXQvdC10LLRgdC60LDRjyDQvdCw0LEuINC0LiA3INGB0YLRgC4gMTUxHzAdBgkq
|
||||
hkiG9w0BCQEWEHBraS1ncmZjQGdyZmMucnUxCzAJBgNVBAYTAlJVMRwwGgYDVQQI
|
||||
DBM3NyDQsy4g0JzQvtGB0LrQstCwMRUwEwYDVQQHDAzQnNC+0YHQutCy0LAxHDAa
|
||||
BgNVBAoME9Ck0JPQo9CfICLQk9Cg0KfQpiIxITAfBgNVBAMMGNCj0KYg0KTQk9Cj
|
||||
0J8gItCT0KDQp9CmIjBjMBwGBiqFAwICEzASBgcqhQMCAiMBBgcqhQMCAh4BA0MA
|
||||
BECWU7YnkJgff0sdJ+i50FXAYZlpcSz8wO/2AnfCzGC+PMj/NGOKMMWcv8I9eN7W
|
||||
eEXwIuRc96StDM8zJigQGd/1o4IB6TCCAeUwNgYFKoUDZG8ELQwrItCa0YDQuNC/
|
||||
0YLQvtCf0YDQviBDU1AiICjQstC10YDRgdC40Y8gMy42KTCCATMGBSqFA2RwBIIB
|
||||
KDCCASQMKyLQmtGA0LjQv9GC0L7Qn9GA0L4gQ1NQIiAo0LLQtdGA0YHQuNGPIDMu
|
||||
NikMUyLQo9C00L7RgdGC0L7QstC10YDRj9GO0YnQuNC5INGG0LXQvdGC0YAgItCa
|
||||
0YDQuNC/0YLQvtCf0YDQviDQo9CmIiDQstC10YDRgdC40LggMS41DE/QodC10YDR
|
||||
gtC40YTQuNC60LDRgiDRgdC+0L7RgtCy0LXRgtGB0YLQstC40Y8g4oSWINCh0KQv
|
||||
MTIxLTE4NTkg0L7RgiAxNy4wNi4yMDEyDE/QodC10YDRgtC40YTQuNC60LDRgiDR
|
||||
gdC+0L7RgtCy0LXRgtGB0YLQstC40Y8g4oSWINCh0KQvMTI4LTE4MjIg0L7RgiAw
|
||||
MS4wNi4yMDEyMAsGA1UdDwQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW
|
||||
BBRrAIaDidIAz1a4a+TjNhAeH3KuwzAQBgkrBgEEAYI3FQEEAwIBADAlBgNVHSAE
|
||||
HjAcMAgGBiqFA2RxATAIBgYqhQNkcQIwBgYEVR0gADAIBgYqhQMCAgMDQQC9ld1f
|
||||
Oit0pSliIMIkqIugExoh9UrWLrE/9VDplqCiyXkJFaJBwGDhHT8ljYj0TGDzD07j
|
||||
KW64bgG0AywHjyc3
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,67 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number:
|
||||
0c:8c:40:93:bb:e6:93:bd:43:0b:f5:18:26:03:1d:05
|
||||
Signature Algorithm: GOST R 34.11-94 with GOST R 34.10-2001
|
||||
Issuer: OGRN=1027739334479, INN=007706228218, street=Дербеневская наб. д. 7 стр. 15, emailAddress=pki-grfc@grfc.ru, C=RU, ST=77 г. Москва, L=Москва, O=ФГУП "ГРЧЦ", CN=УЦ ФГУП "ГРЧЦ"
|
||||
Validity
|
||||
Not Before: Mar 12 07:38:26 2013 GMT
|
||||
Not After : Mar 12 07:46:00 2028 GMT
|
||||
Subject: OGRN=1027739334479, INN=007706228218, street=Дербеневская наб. д. 7 стр. 15, emailAddress=pki-grfc@grfc.ru, C=RU, ST=77 г. Москва, L=Москва, O=ФГУП "ГРЧЦ", CN=УЦ ФГУП "ГРЧЦ"
|
||||
X509v3 extensions:
|
||||
Signing Tool of Subject:
|
||||
"КриптоПро CSP" (версия 3.6)
|
||||
Signing Tool of Issuer:
|
||||
signTool : "КриптоПро CSP" (версия 3.6)
|
||||
cATool : "Удостоверяющий центр "КриптоПро УЦ" версии 1.5
|
||||
signToolCert: Сертификат соответствия № СФ/121-1859 от 17.06.2012
|
||||
cAToolCert : Сертификат соответствия № СФ/128-1822 от 01.06.2012
|
||||
X509v3 Key Usage:
|
||||
Digital Signature, Certificate Sign, CRL Sign
|
||||
X509v3 Basic Constraints: critical
|
||||
CA:TRUE
|
||||
X509v3 Subject Key Identifier:
|
||||
6B:00:86:83:89:D2:00:CF:56:B8:6B:E4:E3:36:10:1E:1F:72:AE:C3
|
||||
1.3.6.1.4.1.311.21.1:
|
||||
...
|
||||
X509v3 Certificate Policies:
|
||||
Policy: 1.2.643.100.113.1
|
||||
Policy: 1.2.643.100.113.2
|
||||
Policy: X509v3 Any Policy
|
||||
Signature Algorithm: GOST R 34.11-94 with GOST R 34.10-2001
|
||||
Signature Value:
|
||||
bd:95:dd:5f:3a:2b:74:a5:29:62:20:c2:24:a8:8b:a0:13:1a:
|
||||
21:f5:4a:d6:2e:b1:3f:f5:50:e9:96:a0:a2:c9:79:09:15:a2:
|
||||
41:c0:60:e1:1d:3f:25:8d:88:f4:4c:60:f3:0f:4e:e3:29:6e:
|
||||
b8:6e:01:b4:03:2c:07:8f:27:37
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFGDCCBMegAwIBAgIQDIxAk7vmk71DC/UYJgMdBTAIBgYqhQMCAgMwggEWMRgw
|
||||
FgYFKoUDZAESDTEwMjc3MzkzMzQ0NzkxGjAYBggqhQMDgQMBARIMMDA3NzA2MjI4
|
||||
MjE4MTowOAYDVQQJDDHQlNC10YDQsdC10L3QtdCy0YHQutCw0Y8g0L3QsNCxLiDQ
|
||||
tC4gNyDRgdGC0YAuIDE1MR8wHQYJKoZIhvcNAQkBFhBwa2ktZ3JmY0BncmZjLnJ1
|
||||
MQswCQYDVQQGEwJSVTEcMBoGA1UECAwTNzcg0LMuINCc0L7RgdC60LLQsDEVMBMG
|
||||
A1UEBwwM0JzQvtGB0LrQstCwMRwwGgYDVQQKDBPQpNCT0KPQnyAi0JPQoNCn0KYi
|
||||
MSEwHwYDVQQDDBjQo9CmINCk0JPQo9CfICLQk9Cg0KfQpiIwHhcNMTMwMzEyMDcz
|
||||
ODI2WhcNMjgwMzEyMDc0NjAwWjCCARYxGDAWBgUqhQNkARINMTAyNzczOTMzNDQ3
|
||||
OTEaMBgGCCqFAwOBAwEBEgwwMDc3MDYyMjgyMTgxOjA4BgNVBAkMMdCU0LXRgNCx
|
||||
0LXQvdC10LLRgdC60LDRjyDQvdCw0LEuINC0LiA3INGB0YLRgC4gMTUxHzAdBgkq
|
||||
hkiG9w0BCQEWEHBraS1ncmZjQGdyZmMucnUxCzAJBgNVBAYTAlJVMRwwGgYDVQQI
|
||||
DBM3NyDQsy4g0JzQvtGB0LrQstCwMRUwEwYDVQQHDAzQnNC+0YHQutCy0LAxHDAa
|
||||
BgNVBAoME9Ck0JPQo9CfICLQk9Cg0KfQpiIxITAfBgNVBAMMGNCj0KYg0KTQk9Cj
|
||||
0J8gItCT0KDQp9CmIjBjMBwGBiqFAwICEzASBgcqhQMCAiMBBgcqhQMCAh4BA0MA
|
||||
BECWU7YnkJgff0sdJ+i50FXAYZlpcSz8wO/2AnfCzGC+PMj/NGOKMMWcv8I9eN7W
|
||||
eEXwIuRc96StDM8zJigQGd/1o4IB6TCCAeUwNgYFKoUDZG8ELQwrItCa0YDQuNC/
|
||||
0YLQvtCf0YDQviBDU1AiICjQstC10YDRgdC40Y8gMy42KTCCATMGBSqFA2RwBIIB
|
||||
KDCCASQMKyLQmtGA0LjQv9GC0L7Qn9GA0L4gQ1NQIiAo0LLQtdGA0YHQuNGPIDMu
|
||||
NikMUyLQo9C00L7RgdGC0L7QstC10YDRj9GO0YnQuNC5INGG0LXQvdGC0YAgItCa
|
||||
0YDQuNC/0YLQvtCf0YDQviDQo9CmIiDQstC10YDRgdC40LggMS41DE/QodC10YDR
|
||||
gtC40YTQuNC60LDRgiDRgdC+0L7RgtCy0LXRgtGB0YLQstC40Y8g4oSWINCh0KQv
|
||||
MTIxLTE4NTkg0L7RgiAxNy4wNi4yMDEyDE/QodC10YDRgtC40YTQuNC60LDRgiDR
|
||||
gdC+0L7RgtCy0LXRgtGB0YLQstC40Y8g4oSWINCh0KQvMTI4LTE4MjIg0L7RgiAw
|
||||
MS4wNi4yMDEyMAsGA1UdDwQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW
|
||||
BBRrAIaDidIAz1a4a+TjNhAeH3KuwzAQBgkrBgEEAYI3FQEEAwIBADAlBgNVHSAE
|
||||
HjAcMAgGBiqFA2RxATAIBgYqhQNkcQIwBgYEVR0gADAIBgYqhQMCAgMDQQC9ld1f
|
||||
Oit0pSliIMIkqIugExoh9UrWLrE/9VDplqCiyXkJFaJBwGDhHT8ljYj0TGDzD07j
|
||||
KW64bgG0AywHjyc3
|
||||
-----END CERTIFICATE-----
|
||||
@@ -27,7 +27,7 @@ sub verify {
|
||||
run(app([@args]));
|
||||
}
|
||||
|
||||
plan tests => 137;
|
||||
plan tests => 139;
|
||||
|
||||
# Canonical success
|
||||
ok(verify("ee-cert", "sslserver", ["root-cert"], ["ca-cert"]),
|
||||
@@ -222,6 +222,10 @@ ok(verify("ee-client", "sslclient", [qw(ee+clientAuth)], [], "-partial_chain"),
|
||||
"accept direct match with client trust");
|
||||
ok(!verify("ee-client", "sslclient", [qw(ee-clientAuth)], [], "-partial_chain"),
|
||||
"reject direct match with client mistrust");
|
||||
ok(verify("ee-pathlen", "sslserver", [qw(root-cert)], [qw(ca-cert)]),
|
||||
"accept non-ca with pathlen:0 by default");
|
||||
ok(!verify("ee-pathlen", "sslserver", [qw(root-cert)], [qw(ca-cert)], "-x509_strict"),
|
||||
"reject non-ca with pathlen:0 with strict flag");
|
||||
|
||||
# Proxy certificates
|
||||
ok(!verify("pc1-cert", "sslclient", [qw(root-cert)], [qw(ee-client ca-cert)]),
|
||||
@@ -378,10 +382,8 @@ SKIP: {
|
||||
skip "SM2 is not supported by this OpenSSL build", 2
|
||||
if disabled("sm2");
|
||||
|
||||
# Test '-sm2-id' and '-sm2-hex-id' option
|
||||
ok_nofips(verify("sm2", "any", ["sm2-ca-cert"], [], "-sm2-id", "1234567812345678"),
|
||||
ok_nofips(verify("sm2", "any", ["sm2-ca-cert"], [], "-vfyopt", "distid:1234567812345678"),
|
||||
"SM2 ID test");
|
||||
ok_nofips(verify("sm2", "any", ["sm2-ca-cert"], [], "-sm2-hex-id",
|
||||
"31323334353637383132333435363738"),
|
||||
ok_nofips(verify("sm2", "any", ["sm2-ca-cert"], [], "-vfyopt", "hexdistid:31323334353637383132333435363738"),
|
||||
"SM2 hex ID test");
|
||||
}
|
||||
@@ -31,9 +31,9 @@ my @configs = ( $defaultcnf );
|
||||
# Only add the FIPS config if the FIPS module has been built
|
||||
push @configs, 'fips.cnf' unless $no_fips;
|
||||
|
||||
my @files = qw( evpciph.txt evpdigest.txt evppkey.txt);
|
||||
my @files = qw( evpciph.txt evpdigest.txt evppkey.txt evppkey_ecc.txt);
|
||||
my @defltfiles = qw( evpencod.txt evpkdf.txt evppkey_kdf.txt evpmac.txt
|
||||
evppbe.txt evppkey_ecc.txt evpcase.txt evpccmcavs.txt );
|
||||
evppbe.txt evpcase.txt evpccmcavs.txt );
|
||||
my @ideafiles = qw( evpciph_idea.txt );
|
||||
push @defltfiles, @ideafiles unless disabled("idea");
|
||||
|
||||
|
||||
@@ -624,6 +624,11 @@ Key = 89BCD952A8C8AB371AF48AC7D07085D5EFF702E6D62CDC23
|
||||
Input = FA620C1BBE97319E9A0CF0492121F7A20EB08A6A709DCBD00AAF38E4F99E754E
|
||||
Output = 8F49A1B7D6AA2258
|
||||
|
||||
MAC = CMAC by EVP_PKEY
|
||||
Algorithm = DES-EDE3-CBC
|
||||
Key = 89BCD952A8C8AB371AF48AC7D07085D5EFF702E6D62CDC23
|
||||
Input = FA620C1BBE97319E9A0CF0492121F7A20EB08A6A709DCBD00AAF38E4F99E754E
|
||||
Output = 8F49A1B7D6AA2258
|
||||
|
||||
Title = GMAC Tests (from NIST)
|
||||
|
||||
|
||||
@@ -312,12 +312,14 @@ Result = VERIFY_ERROR
|
||||
# DigestInfo-wrapped MDC-2 signature
|
||||
Verify = RSA-2048
|
||||
Availablein = default
|
||||
Availablein = legacy
|
||||
Ctrl = digest:MDC2
|
||||
Input = "0123456789ABCDEF"
|
||||
Output = 3a46e5e80635d3b5586187b44b08fd02ca0bd36a637a8afeb46a1c1eb18d05b3196e00edf85378109015bcd3d0cfcefc2919c5b8e3ac42884b360188b1395ed34df7d2749f36b91c320d290311d78b36f390481eff42ace0275385c05176d022e4b625cf0ed85082d4b25da9e8a86011f6ac1cb8d8b812cc2bbd6c240caa8445aa74f8e971c935dbf3447df0411eb9e5cdee0851d1e0fea7041916c77efc09dc54e8dd4b7ba8f8d85ef43d4f12abde99886f4ebd5f021fc1b476cc23dc6a94fbbe77c954eee496fb6b4b5c534daa4e819143ce8de511a8bcb65759750c17edaca6fb31ac271c1ca3a27705f780ae86c67009e76fcba9067dde3556ff59c44111
|
||||
|
||||
VerifyRecover = RSA-2048
|
||||
Availablein = default
|
||||
Availablein = legacy
|
||||
Ctrl = digest:MDC2
|
||||
Input = 3a46e5e80635d3b5586187b44b08fd02ca0bd36a637a8afeb46a1c1eb18d05b3196e00edf85378109015bcd3d0cfcefc2919c5b8e3ac42884b360188b1395ed34df7d2749f36b91c320d290311d78b36f390481eff42ace0275385c05176d022e4b625cf0ed85082d4b25da9e8a86011f6ac1cb8d8b812cc2bbd6c240caa8445aa74f8e971c935dbf3447df0411eb9e5cdee0851d1e0fea7041916c77efc09dc54e8dd4b7ba8f8d85ef43d4f12abde99886f4ebd5f021fc1b476cc23dc6a94fbbe77c954eee496fb6b4b5c534daa4e819143ce8de511a8bcb65759750c17edaca6fb31ac271c1ca3a27705f780ae86c67009e76fcba9067dde3556ff59c44111
|
||||
Output = "0123456789ABCDEF"
|
||||
@@ -325,12 +327,14 @@ Output = "0123456789ABCDEF"
|
||||
# Legacy OCTET STRING MDC-2 signature
|
||||
Verify = RSA-2048
|
||||
Availablein = default
|
||||
Availablein = legacy
|
||||
Ctrl = digest:MDC2
|
||||
Input = "0123456789ABCDEF"
|
||||
Output = 6cde46bbfc6a3b772c3d884640709be9f2fb70fcf199c14eaff7811369ea99733f984a9c48cd372578fa37cedeef24c93286d6d64f438df051e625ab2e125a7d9974a76240873e43efc3acbcbdccc2ee63769cdbf983b334ccb982273315c222b3bbdc3e928ac8a141a7412f1f794cfcabcc069a2ae4975d7bb68bea145d789634c9e0b02d324b5efd599c9bf2b1d32d077aba59aa0ad4a82cbbb90eaa9214e4f57104cf049c4139e2ddecf6edf219cd986f4d79cf25128c58667562c9d22be0291430d6cc7dad977d56e08315fcec133ea95d8db550f89735b4d5f233eaff0c86fce2b99f3f508e920f882c31f3e13f8775a3c8fa585c4f4c69eca89f648b7e
|
||||
|
||||
VerifyRecover = RSA-2048
|
||||
Availablein = default
|
||||
Availablein = legacy
|
||||
Ctrl = digest:MDC2
|
||||
Input = 6cde46bbfc6a3b772c3d884640709be9f2fb70fcf199c14eaff7811369ea99733f984a9c48cd372578fa37cedeef24c93286d6d64f438df051e625ab2e125a7d9974a76240873e43efc3acbcbdccc2ee63769cdbf983b334ccb982273315c222b3bbdc3e928ac8a141a7412f1f794cfcabcc069a2ae4975d7bb68bea145d789634c9e0b02d324b5efd599c9bf2b1d32d077aba59aa0ad4a82cbbb90eaa9214e4f57104cf049c4139e2ddecf6edf219cd986f4d79cf25128c58667562c9d22be0291430d6cc7dad977d56e08315fcec133ea95d8db550f89735b4d5f233eaff0c86fce2b99f3f508e920f882c31f3e13f8775a3c8fa585c4f4c69eca89f648b7e
|
||||
Output = "0123456789ABCDEF"
|
||||
@@ -338,6 +342,7 @@ Output = "0123456789ABCDEF"
|
||||
# Legacy OCTET STRING MDC-2 signature, digest mismatch
|
||||
Verify = RSA-2048
|
||||
Availablein = default
|
||||
Availablein = legacy
|
||||
Ctrl = digest:MDC2
|
||||
Input = "0000000000000000"
|
||||
Output = 6cde46bbfc6a3b772c3d884640709be9f2fb70fcf199c14eaff7811369ea99733f984a9c48cd372578fa37cedeef24c93286d6d64f438df051e625ab2e125a7d9974a76240873e43efc3acbcbdccc2ee63769cdbf983b334ccb982273315c222b3bbdc3e928ac8a141a7412f1f794cfcabcc069a2ae4975d7bb68bea145d789634c9e0b02d324b5efd599c9bf2b1d32d077aba59aa0ad4a82cbbb90eaa9214e4f57104cf049c4139e2ddecf6edf219cd986f4d79cf25128c58667562c9d22be0291430d6cc7dad977d56e08315fcec133ea95d8db550f89735b4d5f233eaff0c86fce2b99f3f508e920f882c31f3e13f8775a3c8fa585c4f4c69eca89f648b7e
|
||||
@@ -346,6 +351,7 @@ Result = VERIFY_ERROR
|
||||
# Legacy OCTET STRING MDC-2 signature, wrong input digest length
|
||||
Verify = RSA-2048
|
||||
Availablein = default
|
||||
Availablein = legacy
|
||||
Ctrl = digest:MDC2
|
||||
Input = "0123456789ABCDE"
|
||||
Output = 6cde46bbfc6a3b772c3d884640709be9f2fb70fcf199c14eaff7811369ea99733f984a9c48cd372578fa37cedeef24c93286d6d64f438df051e625ab2e125a7d9974a76240873e43efc3acbcbdccc2ee63769cdbf983b334ccb982273315c222b3bbdc3e928ac8a141a7412f1f794cfcabcc069a2ae4975d7bb68bea145d789634c9e0b02d324b5efd599c9bf2b1d32d077aba59aa0ad4a82cbbb90eaa9214e4f57104cf049c4139e2ddecf6edf219cd986f4d79cf25128c58667562c9d22be0291430d6cc7dad977d56e08315fcec133ea95d8db550f89735b4d5f233eaff0c86fce2b99f3f508e920f882c31f3e13f8775a3c8fa585c4f4c69eca89f648b7e
|
||||
@@ -354,6 +360,7 @@ Result = VERIFY_ERROR
|
||||
# Legacy OCTET STRING MDC-2 signature, wrong signature digest length
|
||||
Verify = RSA-2048
|
||||
Availablein = default
|
||||
Availablein = legacy
|
||||
Ctrl = digest:MDC2
|
||||
Input = "0123456789ABCDEF"
|
||||
Output = 08da512483ece70be57f28a75271612800ae30ffbadc62609bc88b80d497a1fc13c300fdfcab6dc80cf55373c10adcc249ae80479b87fa3e391a2cd4a74babd1c22a4976812d544dcd6729b161bbc48fd067cf635b05f9edaddaeb6f67f2117d6b54a23c5e6f08a246abfe0356a67d7f3929306515e6d9962f8ce205120ecdcd2d4e3783cd0b4a1f0196a1b13924d0d3649233312695c3c336ae04e0b1efddabcc878b57622db60f6f747a1124c38426dacf1425c92d304c2bb1052f987c1dd73e4cc4b20d23396d4f05f52f98cf5065c3fb7dc319425f1f6f1878b87f57afbd24fbff98909494581aadd04d80a639b85ce8684ea58409d8dbbbaacf256bb5c4
|
||||
@@ -361,6 +368,7 @@ Result = VERIFY_ERROR
|
||||
|
||||
VerifyRecover = RSA-2048
|
||||
Availablein = default
|
||||
Availablein = legacy
|
||||
Ctrl = digest:MDC2
|
||||
Input = 08da512483ece70be57f28a75271612800ae30ffbadc62609bc88b80d497a1fc13c300fdfcab6dc80cf55373c10adcc249ae80479b87fa3e391a2cd4a74babd1c22a4976812d544dcd6729b161bbc48fd067cf635b05f9edaddaeb6f67f2117d6b54a23c5e6f08a246abfe0356a67d7f3929306515e6d9962f8ce205120ecdcd2d4e3783cd0b4a1f0196a1b13924d0d3649233312695c3c336ae04e0b1efddabcc878b57622db60f6f747a1124c38426dacf1425c92d304c2bb1052f987c1dd73e4cc4b20d23396d4f05f52f98cf5065c3fb7dc319425f1f6f1878b87f57afbd24fbff98909494581aadd04d80a639b85ce8684ea58409d8dbbbaacf256bb5c4
|
||||
Result = KEYOP_ERROR
|
||||
@@ -368,6 +376,7 @@ Result = KEYOP_ERROR
|
||||
# Legacy OCTET STRING MDC-2 signature, wrong input and signature digest length
|
||||
Verify = RSA-2048
|
||||
Availablein = default
|
||||
Availablein = legacy
|
||||
Ctrl = digest:MDC2
|
||||
Input = "0123456789ABCDE"
|
||||
Output = 08da512483ece70be57f28a75271612800ae30ffbadc62609bc88b80d497a1fc13c300fdfcab6dc80cf55373c10adcc249ae80479b87fa3e391a2cd4a74babd1c22a4976812d544dcd6729b161bbc48fd067cf635b05f9edaddaeb6f67f2117d6b54a23c5e6f08a246abfe0356a67d7f3929306515e6d9962f8ce205120ecdcd2d4e3783cd0b4a1f0196a1b13924d0d3649233312695c3c336ae04e0b1efddabcc878b57622db60f6f747a1124c38426dacf1425c92d304c2bb1052f987c1dd73e4cc4b20d23396d4f05f52f98cf5065c3fb7dc319425f1f6f1878b87f57afbd24fbff98909494581aadd04d80a639b85ce8684ea58409d8dbbbaacf256bb5c4
|
||||
@@ -635,7 +644,7 @@ Result = KEYOP_INIT_ERROR
|
||||
Reason = invalid salt length
|
||||
|
||||
|
||||
Title = EC tests
|
||||
Title = ECDSA tests
|
||||
|
||||
Verify = P-256
|
||||
Availablein = default
|
||||
@@ -18563,7 +18572,7 @@ KeyGen = rsaEncryption
|
||||
Availablein = default
|
||||
Ctrl = rsa_keygen_bits:128
|
||||
KeyName = tmprsa
|
||||
Result = PKEY_CTRL_INVALID
|
||||
Result = KEYGEN_GENERATE_ERROR
|
||||
Reason = key size too small
|
||||
|
||||
# RSA-PSS with restrictions, should succeed.
|
||||
|
||||
@@ -121,7 +121,7 @@ foreach my $setup (@setups) {
|
||||
|
||||
foreach my $alg (@types) {
|
||||
foreach my $testcase (@testdata) {
|
||||
$ENV{OPENSSL_CONF} = $testcase->{config};
|
||||
$ENV{OPENSSL_CONF} = "";
|
||||
foreach my $test (@{$testcase->{tests}}) {
|
||||
my @testproviders =
|
||||
@{ $test->{providers} // $testcase->{providers} };
|
||||
@@ -137,6 +137,7 @@ foreach my $alg (@types) {
|
||||
"running evp_fetch_prov_test with $alg$testprovstr$testmsg";
|
||||
|
||||
ok(run(test(["evp_fetch_prov_test", "-type", "$alg",
|
||||
"-config", "$testcase->{config}",
|
||||
@testargs, @testproviders])),
|
||||
$message);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MC4CAQAwBQYDK2VwBCIEIJ1hsZ3v/VpguoRK9JLsLMREScVpezJpGXA7rAMcrn9g
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -0,0 +1,9 @@
|
||||
ED25519 Private-Key:
|
||||
priv:
|
||||
9d:61:b1:9d:ef:fd:5a:60:ba:84:4a:f4:92:ec:2c:
|
||||
c4:44:49:c5:69:7b:32:69:19:70:3b:ac:03:1c:ae:
|
||||
7f:60
|
||||
pub:
|
||||
d7:5a:98:01:82:b1:0a:b7:d5:4b:fe:d3:c9:64:07:
|
||||
3a:0e:e1:72:f3:da:a6:23:25:af:02:1a:68:f7:07:
|
||||
51:1a
|
||||
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MCowBQYDK2VwAyEA11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo=
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -0,0 +1,5 @@
|
||||
ED25519 Public-Key:
|
||||
pub:
|
||||
d7:5a:98:01:82:b1:0a:b7:d5:4b:fe:d3:c9:64:07:
|
||||
3a:0e:e1:72:f3:da:a6:23:25:af:02:1a:68:f7:07:
|
||||
51:1a
|
||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MEcCAQAwBQYDK2VxBDsEOWyCpWLLgI0Q1jK+ichRPr9skp803fqMn2PJlg7240ij
|
||||
UoyKP8wvBE45o/xblEkvjwMudUmiAJj5Ww==
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -0,0 +1,11 @@
|
||||
ED448 Private-Key:
|
||||
priv:
|
||||
6c:82:a5:62:cb:80:8d:10:d6:32:be:89:c8:51:3e:
|
||||
bf:6c:92:9f:34:dd:fa:8c:9f:63:c9:96:0e:f6:e3:
|
||||
48:a3:52:8c:8a:3f:cc:2f:04:4e:39:a3:fc:5b:94:
|
||||
49:2f:8f:03:2e:75:49:a2:00:98:f9:5b
|
||||
pub:
|
||||
5f:d7:44:9b:59:b4:61:fd:2c:e7:87:ec:61:6a:d4:
|
||||
6a:1d:a1:34:24:85:a7:0e:1f:8a:0e:a7:5d:80:e9:
|
||||
67:78:ed:f1:24:76:9b:46:c7:06:1b:d6:78:3d:f1:
|
||||
e5:0f:6c:d1:fa:1a:be:af:e8:25:61:80
|
||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MEMwBQYDK2VxAzoAX9dEm1m0Yf0s54fsYWrUah2hNCSFpw4fig6nXYDpZ3jt8SR2
|
||||
m0bHBhvWeD3x5Q9s0foavq/oJWGA
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -0,0 +1,6 @@
|
||||
ED448 Public-Key:
|
||||
pub:
|
||||
5f:d7:44:9b:59:b4:61:fd:2c:e7:87:ec:61:6a:d4:
|
||||
6a:1d:a1:34:24:85:a7:0e:1f:8a:0e:a7:5d:80:e9:
|
||||
67:78:ed:f1:24:76:9b:46:c7:06:1b:d6:78:3d:f1:
|
||||
e5:0f:6c:d1:fa:1a:be:af:e8:25:61:80
|
||||
@@ -0,0 +1,27 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright Nokia 2007-2019
|
||||
# Copyright Siemens AG 2015-2019
|
||||
#
|
||||
# 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 qw/:DEFAULT data_file/;
|
||||
use OpenSSL::Test::Utils;
|
||||
|
||||
setup("test_cmp_client");
|
||||
|
||||
plan skip_all => "This test is not supported in a no-cmp build"
|
||||
if disabled("cmp");
|
||||
|
||||
plan tests => 1;
|
||||
|
||||
ok(run(test(["cmp_client_test",
|
||||
data_file("server.key"),
|
||||
data_file("server.crt"),
|
||||
data_file("client.key"),
|
||||
data_file("client.crt"),
|
||||
data_file("client.csr")])));
|
||||
@@ -0,0 +1,13 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIB6DCCAUkCCQD6PZPVVOpOKTAKBggqhkjOPQQDAjA4MQswCQYDVQQGEwJERTET
|
||||
MBEGA1UECgwKU2llbWVucyBBRzEUMBIGA1UEAwwLdGVzdCBjbGllbnQwHhcNMTkw
|
||||
NzI2MTE1OTQyWhcNMTkwODI1MTE1OTQyWjA4MQswCQYDVQQGEwJERTETMBEGA1UE
|
||||
CgwKU2llbWVucyBBRzEUMBIGA1UEAwwLdGVzdCBjbGllbnQwgZswEAYHKoZIzj0C
|
||||
AQYFK4EEACMDgYYABAHClvNEi0aAVuM3CrR5Pwj3TFKHRXfd04MCSs/p9bzMFlMT
|
||||
l6SGCGbFh9ZbU+J2jXYGBtTSSs4O/27lqzXCS8DjQAHMrFq69i5VuUmGXe7jQcfY
|
||||
iyKIb+3It0GstBa0hDssxWvBUJADMd+p6R0pA/XjCG0ZqkkHwdzCxEby/oCZPp1g
|
||||
3jAKBggqhkjOPQQDAgOBjAAwgYgCQgEJiQwLbHH6E9dLpy+BsZ3m+nfwSvPulS/n
|
||||
DMm6ZRi57iItAey9eywxpsKV7DKT+SPjjlAt+l083Smz42Gwpdt+cAJCAXQ2NHqm
|
||||
hPYo8Qk5a+Y15PYqm5g5qZ1b5E2FtRHNK8EJzSMrQEzDiI3jO0sgcvzr7kwOsZ7X
|
||||
Z8y+DTE4HOoYo6oo
|
||||
-----END CERTIFICATE-----
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
-----BEGIN EC PRIVATE KEY-----
|
||||
MIHcAgEBBEIAyT6geQkerhMGSj1ZG0ZhFa1Q5kYEBtnEE/bs5Gdm9L3v0OukExzm
|
||||
Nx1XJATGBnCyOM5IzPw1TWXT+BNhSxJYtvOgBwYFK4EEACOhgYkDgYYABAHClvNE
|
||||
i0aAVuM3CrR5Pwj3TFKHRXfd04MCSs/p9bzMFlMTl6SGCGbFh9ZbU+J2jXYGBtTS
|
||||
Ss4O/27lqzXCS8DjQAHMrFq69i5VuUmGXe7jQcfYiyKIb+3It0GstBa0hDssxWvB
|
||||
UJADMd+p6R0pA/XjCG0ZqkkHwdzCxEby/oCZPp1g3g==
|
||||
-----END EC PRIVATE KEY-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICpTCCAY2gAwIBAgIBATANBgkqhkiG9w0BAQUFADAWMRQwEgYDVQQKDAtvcGVu
|
||||
c3NsX2NtcDAeFw0xNzEyMjAxMzA0MDBaFw0xODEyMjAxMzA0MDBaMBYxFDASBgNV
|
||||
BAoMC29wZW5zc2xfY21wMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
|
||||
4ckRrH0UWmIJFj99kBqvCipGjJRAaPkdvWjdDQLglTpI3eZAJHnq0ypW/PZccrWj
|
||||
o7mxuvAStEYWF+5Jx6ZFmAsC1K0NNebSAZQoLWYZqiOzkfVVpLicMnItNFElfCoh
|
||||
BzPCYmF5UlC5yp9PSUEfNwPJqDIRMtw+IlVUV3AJw9TJ3uuWq/vWW9r96/gBKKdd
|
||||
mj/q2gGT8RC6LxEaolTbhfPbHaA1DFpv1WQFb3oAV3Wq14SOZf9bH1olBVsmBMsU
|
||||
shFEw5MXVrNCv2moM4HtITMyjvZe7eIwHzSzf6dvQjERG6GvZ/i5KOhaqgJCnRKd
|
||||
HHzijz9cLec5p9NSOuC1OwIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQDGUXpFCBkV
|
||||
WgPrBfZyBwt6VCjWB/e67q4IdcKMfDa4hwSquah1AyXHI0PlC/qitnoSx2+7f7pY
|
||||
TEOay/3eEPUl1J5tdPF2Vg56Dw8jdhSkMwO7bXKDEE3R6o6jaa4ECgxwQtdGHmNU
|
||||
A41PgKX76yEXku803ptO39/UR7i7Ye3MbyAmWE+PvixJYUbxd3fqz5fsaJqTCzAy
|
||||
AT9hrr4uu8J7m3LYaYXo4LVL4jw5UsP5bIYtpmmEBfy9GhpUqH5/LzBNij7y3ziE
|
||||
T59wHkzawAQDHsBPuCe07DFtlzqWWvaih0TQAw9MZ2tbyK9jt7P80Rqt9CwpM/i9
|
||||
jQYqSl/ix5hn
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEA4ckRrH0UWmIJFj99kBqvCipGjJRAaPkdvWjdDQLglTpI3eZA
|
||||
JHnq0ypW/PZccrWjo7mxuvAStEYWF+5Jx6ZFmAsC1K0NNebSAZQoLWYZqiOzkfVV
|
||||
pLicMnItNFElfCohBzPCYmF5UlC5yp9PSUEfNwPJqDIRMtw+IlVUV3AJw9TJ3uuW
|
||||
q/vWW9r96/gBKKddmj/q2gGT8RC6LxEaolTbhfPbHaA1DFpv1WQFb3oAV3Wq14SO
|
||||
Zf9bH1olBVsmBMsUshFEw5MXVrNCv2moM4HtITMyjvZe7eIwHzSzf6dvQjERG6Gv
|
||||
Z/i5KOhaqgJCnRKdHHzijz9cLec5p9NSOuC1OwIDAQABAoIBAGiYVO+rIfqc38jG
|
||||
sMxJED2NSBFnvE7k2LoeEgktBA0daxQgziYXtIkOXC3jkwAw1RXLuGH5RTDuJt3/
|
||||
LX6nsCW3NCCB6lTGERNaJyKg4dLHpzA+juY3/2P/MKHD1bGncpV7jNk2fpV7gBY1
|
||||
pu0wld1Oi+S3DPCaxs3w6Zl39Y4Z7oSNf6DRO5lGN3Asc8TSVjIOWpAl8LIg+P2B
|
||||
ZvFeHRANVXaV9YmF2uEi7iMgH4vGrK2svsmM9VThVO4ArGcTRTvGYn7aw3/H4Pt+
|
||||
lYuhERdpkKBT0tCgIpO5IJXMl4/5RSDTtcBwiJcReN5IHUAItBIPSHcMflNSKG/I
|
||||
aQf4u0ECgYEA8+PAyzn096Y2UrKzE75yuadCveLjsUWx2NN5ZMohQru99F4k7Pab
|
||||
/Te4qOe5zlxHAPK3LRwvbwUWo5mLfs45wFrSgZoRlYcCuL+JaX0y2oXMMF9E+UkY
|
||||
tljMt/HpLo1SfSjN2Sae4LVhC7rWJ43LtyRepptzBPGqd26eLPGAMr8CgYEA7P8u
|
||||
RGkMOrMzEKAb0A9smrzq2xW88T1VejqEt6R8mUcNt8PFHMgjuzVU4zDysrlb7G/0
|
||||
VSkQWnJxBh1yNGc1Av7YgwicIgApr4ty0hZhLcnKX2VrNw+L/sSe/cnwVAc6RtPK
|
||||
RR6xQubuLlrCGcbYXmyn5Jv+nlY0S3uCyDFHqIUCgYAwtpLxhJf7RwWeqva9wNJl
|
||||
ZpUcHE9iPwtwxXx/tyfBjoI4Zv11HyS1BQYrJm2kXCYKeHBB4FlREXEeKDMGluZO
|
||||
F1XocP+GIDtY71jg6xLXNtY76yt5pzH6ae4p53WtyKhrO1UyRFaDh3bkwuK3b8j6
|
||||
wZbuLCpjGGn2BPAvBeWXPQKBgEewKN6op/pZmmi9Bay5/bAQ1TnQKYcPdnuyl9K0
|
||||
/ruespeTsFw0bhqC11qhw8gsKZIri0z3TusNEwM2hQU08uQlEnkQcaoXQoTHOcQy
|
||||
4NJo575Tf0r4ePBnqXA7VWcViJtEFTszPYtvLzz2VyBU9b4aP+73AN4EVW0/vx+v
|
||||
SG3BAoGBAMzESFA2TXwUFmozK5zowIszc995Xqpi7mXKk77WESOpoS1dQ1wF1dSg
|
||||
XOwxzFoYovLxcc1K9lqOrod8BV+qGuEfc/PIJ2aiXjvEDeZYX2eWaANNmj4OSLoJ
|
||||
MNYj9tZxbq56slD7snf7AgUBnwKz0Pj6H6UsbE3gdJqZWCDyw/bB
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -0,0 +1,26 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright Nokia 2007-2020
|
||||
# Copyright Siemens AG 2015-2020
|
||||
#
|
||||
# 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 qw/:DEFAULT data_file/;
|
||||
use OpenSSL::Test::Utils;
|
||||
|
||||
setup("test_cmp_server");
|
||||
|
||||
plan skip_all => "This test is not supported in a no-cmp build"
|
||||
if disabled("cmp");
|
||||
|
||||
plan skip_all => "This test is not supported in a no-ec build"
|
||||
if disabled("ec");
|
||||
|
||||
plan tests => 1;
|
||||
|
||||
ok(run(test(["cmp_server_test",
|
||||
data_file("CR_protected_PBM_1234.der")])));
|
||||
Binary file not shown.
@@ -59,8 +59,8 @@ SKIP: {
|
||||
srctop_file("test", "CAss.cnf"),
|
||||
"-in", srctop_file("test", "certs", "sm2-csr.pem"),
|
||||
"-out", "sm2-test.crt",
|
||||
"-sigopt", "sm2_id:1234567812345678",
|
||||
"-sm2-id", "1234567812345678",
|
||||
"-sigopt", "distid:1234567812345678",
|
||||
"-vfyopt", "distid:1234567812345678",
|
||||
"-md", "sm3",
|
||||
"-cert", srctop_file("test", "certs", "sm2-root.crt"),
|
||||
"-keyfile", srctop_file("test", "certs", "sm2-root.key")]))),
|
||||
|
||||
@@ -13,7 +13,7 @@ use warnings;
|
||||
use POSIX;
|
||||
use File::Spec::Functions qw/catfile/;
|
||||
use File::Compare qw/compare_text/;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_dir srctop_file/;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_dir srctop_file bldtop_dir/;
|
||||
use OpenSSL::Test::Utils;
|
||||
|
||||
setup("test_cms");
|
||||
@@ -21,6 +21,9 @@ setup("test_cms");
|
||||
plan skip_all => "CMS is not supported by this OpenSSL build"
|
||||
if disabled("cms");
|
||||
|
||||
my $provpath = bldtop_dir("providers");
|
||||
my @prov = ("-provider_path", $provpath, "-provider", "default", "-provider", "legacy");
|
||||
|
||||
my $datadir = srctop_dir("test", "recipes", "80-test_cms_data");
|
||||
my $smdir = srctop_dir("test", "smime-certs");
|
||||
my $smcont = srctop_file("test", "smcont.txt");
|
||||
@@ -311,10 +314,11 @@ my @smime_cms_tests = (
|
||||
],
|
||||
|
||||
[ "encrypted content test streaming PEM format, 128 bit RC2 key",
|
||||
[ "{cmd1}", "-EncryptedData_encrypt", "-in", $smcont, "-outform", "PEM",
|
||||
[ "{cmd1}", @prov, "-EncryptedData_encrypt",
|
||||
"-in", $smcont, "-outform", "PEM",
|
||||
"-rc2", "-secretkey", "000102030405060708090A0B0C0D0E0F",
|
||||
"-stream", "-out", "{output}.cms" ],
|
||||
[ "{cmd2}", "-EncryptedData_decrypt", "-in", "{output}.cms",
|
||||
[ "{cmd2}", @prov, "-EncryptedData_decrypt", "-in", "{output}.cms",
|
||||
"-inform", "PEM",
|
||||
"-secretkey", "000102030405060708090A0B0C0D0E0F",
|
||||
"-out", "{output}.txt" ],
|
||||
@@ -322,10 +326,11 @@ my @smime_cms_tests = (
|
||||
],
|
||||
|
||||
[ "encrypted content test streaming PEM format, 40 bit RC2 key",
|
||||
[ "{cmd1}", "-EncryptedData_encrypt", "-in", $smcont, "-outform", "PEM",
|
||||
[ "{cmd1}", @prov, "-EncryptedData_encrypt",
|
||||
"-in", $smcont, "-outform", "PEM",
|
||||
"-rc2", "-secretkey", "0001020304",
|
||||
"-stream", "-out", "{output}.cms" ],
|
||||
[ "{cmd2}", "-EncryptedData_decrypt", "-in", "{output}.cms",
|
||||
[ "{cmd2}", @prov, "-EncryptedData_decrypt", "-in", "{output}.cms",
|
||||
"-inform", "PEM",
|
||||
"-secretkey", "0001020304", "-out", "{output}.txt" ],
|
||||
\&final_compare
|
||||
|
||||
@@ -8,14 +8,46 @@
|
||||
|
||||
|
||||
use OpenSSL::Test::Utils;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_dir/;
|
||||
use OpenSSL::Test qw/:DEFAULT srctop_file srctop_dir bldtop_file bldtop_dir/;
|
||||
|
||||
BEGIN {
|
||||
setup("test_sslprovider");
|
||||
}
|
||||
|
||||
use lib srctop_dir('Configurations');
|
||||
use lib bldtop_dir('.');
|
||||
use platform;
|
||||
|
||||
plan skip_all => "No TLS/SSL protocols are supported by this OpenSSL build"
|
||||
if alldisabled(grep { $_ ne "ssl3" } available_protocols("tls"));
|
||||
|
||||
plan tests => 1;
|
||||
plan tests => 3;
|
||||
|
||||
ok(run(test(["sslprovidertest", srctop_dir("test", "certs")])),
|
||||
$ENV{OPENSSL_MODULES} = bldtop_dir("providers");
|
||||
$ENV{OPENSSL_CONF_INCLUDE} = bldtop_dir("providers");
|
||||
|
||||
SKIP: {
|
||||
skip "Skipping FIPS installation", 1
|
||||
if disabled("fips");
|
||||
|
||||
ok(run(app(['openssl', 'fipsinstall',
|
||||
'-out', bldtop_file('providers', 'fipsinstall.cnf'),
|
||||
'-module', bldtop_file('providers', platform->dso('fips')),
|
||||
'-provider_name', 'fips', '-mac_name', 'HMAC',
|
||||
'-macopt', 'digest:SHA256', '-macopt', 'hexkey:00',
|
||||
'-section_name', 'fips_sect'])),
|
||||
"fipsinstall");
|
||||
}
|
||||
|
||||
ok(run(test(["sslprovidertest", srctop_dir("test", "certs"), "default",
|
||||
srctop_file("test", "default.cnf")])),
|
||||
"running sslprovidertest");
|
||||
|
||||
SKIP: {
|
||||
skip "Skipping FIPS provider test", 1
|
||||
if disabled("fips");
|
||||
|
||||
ok(run(test(["sslprovidertest", srctop_dir("test", "certs"), "fips",
|
||||
srctop_file("test", "fips.cnf")])),
|
||||
"running sslprovidertest");
|
||||
}
|
||||
@@ -21,7 +21,7 @@ plan skip_all => "krb5 not available"
|
||||
|
||||
plan tests => 1;
|
||||
|
||||
$ENV{OPENSSL_MODULES} = abs_path($ENV{OPENSSL_MODULES});
|
||||
$ENV{OPENSSL_MODULES} = abs_path(bldtop_dir("providers"));
|
||||
$ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "default-and-legacy.cnf"));
|
||||
|
||||
ok(run(cmd([data_file("krb5.sh")])), "running krb5 tests");
|
||||
@@ -37,17 +37,18 @@ static size_t fake_rand_size = 0;
|
||||
|
||||
static int get_faked_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (fake_rand_bytes == NULL)
|
||||
return saved_rand->bytes(buf, num);
|
||||
|
||||
if (!TEST_size_t_le(fake_rand_bytes_offset + num, fake_rand_size))
|
||||
if (!TEST_size_t_gt(fake_rand_size, 0))
|
||||
return 0;
|
||||
|
||||
for (i = 0; i != num; ++i)
|
||||
buf[i] = fake_rand_bytes[fake_rand_bytes_offset + i];
|
||||
fake_rand_bytes_offset += num;
|
||||
while (num-- > 0) {
|
||||
if (fake_rand_bytes_offset >= fake_rand_size)
|
||||
fake_rand_bytes_offset = 0;
|
||||
*buf++ = fake_rand_bytes[fake_rand_bytes_offset++];
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -180,8 +181,7 @@ static int test_sm2_crypt(const EC_GROUP *group,
|
||||
|
||||
start_fake_rand(k_hex);
|
||||
if (!TEST_true(sm2_encrypt(key, digest, (const uint8_t *)message, msg_len,
|
||||
ctext, &ctext_len))
|
||||
|| !TEST_size_t_eq(fake_rand_bytes_offset, fake_rand_size)) {
|
||||
ctext, &ctext_len))) {
|
||||
restore_rand();
|
||||
goto done;
|
||||
}
|
||||
@@ -301,8 +301,7 @@ static int test_sm2_sign(const EC_GROUP *group,
|
||||
start_fake_rand(k_hex);
|
||||
sig = sm2_do_sign(key, EVP_sm3(), (const uint8_t *)userid, strlen(userid),
|
||||
(const uint8_t *)message, msg_len);
|
||||
if (!TEST_ptr(sig)
|
||||
|| !TEST_size_t_eq(fake_rand_bytes_offset, fake_rand_size)) {
|
||||
if (!TEST_ptr(sig)) {
|
||||
restore_rand();
|
||||
goto done;
|
||||
}
|
||||
|
||||
+118
-6
@@ -651,6 +651,117 @@ end:
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Very focused test to exercise a single case in the server-side state
|
||||
* machine, when the ChangeCipherState message needs to actually change
|
||||
* from one cipher to a different cipher (i.e., not changing from null
|
||||
* encryption to real encryption).
|
||||
*/
|
||||
static int test_ccs_change_cipher(void)
|
||||
{
|
||||
SSL_CTX *cctx = NULL, *sctx = NULL;
|
||||
SSL *clientssl = NULL, *serverssl = NULL;
|
||||
SSL_SESSION *sess = NULL, *sesspre, *sesspost;
|
||||
int testresult = 0;
|
||||
int i;
|
||||
unsigned char buf;
|
||||
size_t readbytes;
|
||||
|
||||
/*
|
||||
* Create a conection so we can resume and potentially (but not) use
|
||||
* a different cipher in the second connection.
|
||||
*/
|
||||
if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(),
|
||||
TLS_client_method(),
|
||||
TLS1_VERSION, TLS1_2_VERSION,
|
||||
&sctx, &cctx, cert, privkey))
|
||||
|| !TEST_true(SSL_CTX_set_options(sctx, SSL_OP_NO_TICKET))
|
||||
|| !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
|
||||
NULL, NULL))
|
||||
|| !TEST_true(SSL_set_cipher_list(clientssl, "AES128-GCM-SHA256"))
|
||||
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
|
||||
SSL_ERROR_NONE))
|
||||
|| !TEST_ptr(sesspre = SSL_get0_session(serverssl))
|
||||
|| !TEST_ptr(sess = SSL_get1_session(clientssl)))
|
||||
goto end;
|
||||
|
||||
shutdown_ssl_connection(serverssl, clientssl);
|
||||
serverssl = clientssl = NULL;
|
||||
|
||||
/* Resume, preferring a different cipher. Our server will force the
|
||||
* same cipher to be used as the initial handshake. */
|
||||
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
|
||||
NULL, NULL))
|
||||
|| !TEST_true(SSL_set_session(clientssl, sess))
|
||||
|| !TEST_true(SSL_set_cipher_list(clientssl, "AES256-GCM-SHA384:AES128-GCM-SHA256"))
|
||||
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
|
||||
SSL_ERROR_NONE))
|
||||
|| !TEST_true(SSL_session_reused(clientssl))
|
||||
|| !TEST_true(SSL_session_reused(serverssl))
|
||||
|| !TEST_ptr(sesspost = SSL_get0_session(serverssl))
|
||||
|| !TEST_ptr_eq(sesspre, sesspost)
|
||||
|| !TEST_int_eq(TLS1_CK_RSA_WITH_AES_128_GCM_SHA256,
|
||||
SSL_CIPHER_get_id(SSL_get_current_cipher(clientssl))))
|
||||
goto end;
|
||||
shutdown_ssl_connection(serverssl, clientssl);
|
||||
serverssl = clientssl = NULL;
|
||||
|
||||
/*
|
||||
* Now create a fresh connection and try to renegotiate a different
|
||||
* cipher on it.
|
||||
*/
|
||||
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
|
||||
NULL, NULL))
|
||||
|| !TEST_true(SSL_set_cipher_list(clientssl, "AES128-GCM-SHA256"))
|
||||
|| !TEST_true(create_ssl_connection(serverssl, clientssl,
|
||||
SSL_ERROR_NONE))
|
||||
|| !TEST_ptr(sesspre = SSL_get0_session(serverssl))
|
||||
|| !TEST_true(SSL_set_cipher_list(clientssl, "AES256-GCM-SHA384"))
|
||||
|| !TEST_true(SSL_renegotiate(clientssl))
|
||||
|| !TEST_true(SSL_renegotiate_pending(clientssl)))
|
||||
goto end;
|
||||
/* Actually drive the renegotiation. */
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (SSL_read_ex(clientssl, &buf, sizeof(buf), &readbytes) > 0) {
|
||||
if (!TEST_ulong_eq(readbytes, 0))
|
||||
goto end;
|
||||
} else if (!TEST_int_eq(SSL_get_error(clientssl, 0),
|
||||
SSL_ERROR_WANT_READ)) {
|
||||
goto end;
|
||||
}
|
||||
if (SSL_read_ex(serverssl, &buf, sizeof(buf), &readbytes) > 0) {
|
||||
if (!TEST_ulong_eq(readbytes, 0))
|
||||
goto end;
|
||||
} else if (!TEST_int_eq(SSL_get_error(serverssl, 0),
|
||||
SSL_ERROR_WANT_READ)) {
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
/* sesspre and sesspost should be different since the cipher changed. */
|
||||
if (!TEST_false(SSL_renegotiate_pending(clientssl))
|
||||
|| !TEST_false(SSL_session_reused(clientssl))
|
||||
|| !TEST_false(SSL_session_reused(serverssl))
|
||||
|| !TEST_ptr(sesspost = SSL_get0_session(serverssl))
|
||||
|| !TEST_ptr_ne(sesspre, sesspost)
|
||||
|| !TEST_int_eq(TLS1_CK_RSA_WITH_AES_256_GCM_SHA384,
|
||||
SSL_CIPHER_get_id(SSL_get_current_cipher(clientssl))))
|
||||
goto end;
|
||||
|
||||
shutdown_ssl_connection(serverssl, clientssl);
|
||||
serverssl = clientssl = NULL;
|
||||
|
||||
testresult = 1;
|
||||
|
||||
end:
|
||||
SSL_free(serverssl);
|
||||
SSL_free(clientssl);
|
||||
SSL_CTX_free(sctx);
|
||||
SSL_CTX_free(cctx);
|
||||
SSL_SESSION_free(sess);
|
||||
|
||||
return testresult;
|
||||
}
|
||||
|
||||
static int execute_test_large_message(const SSL_METHOD *smeth,
|
||||
const SSL_METHOD *cmeth,
|
||||
int min_version, int max_version,
|
||||
@@ -1167,7 +1278,7 @@ static int ocsp_server_cb(SSL *s, void *arg)
|
||||
return SSL_TLSEXT_ERR_ALERT_FATAL;
|
||||
|
||||
id = sk_OCSP_RESPID_value(ids, 0);
|
||||
if (id == NULL || !OCSP_RESPID_match(id, ocspcert))
|
||||
if (id == NULL || !OCSP_RESPID_match_ex(id, ocspcert, NULL, NULL))
|
||||
return SSL_TLSEXT_ERR_ALERT_FATAL;
|
||||
} else if (*argi != 1) {
|
||||
return SSL_TLSEXT_ERR_ALERT_FATAL;
|
||||
@@ -1295,7 +1406,7 @@ static int test_tlsext_status_type(void)
|
||||
|| !TEST_ptr(ids = sk_OCSP_RESPID_new_null())
|
||||
|| !TEST_ptr(ocspcert = PEM_read_bio_X509(certbio,
|
||||
NULL, NULL, NULL))
|
||||
|| !TEST_true(OCSP_RESPID_set_by_key(id, ocspcert))
|
||||
|| !TEST_true(OCSP_RESPID_set_by_key_ex(id, ocspcert, NULL, NULL))
|
||||
|| !TEST_true(sk_OCSP_RESPID_push(ids, id)))
|
||||
goto end;
|
||||
id = NULL;
|
||||
@@ -5422,8 +5533,8 @@ static int create_new_vfile(char *userid, char *password, const char *filename)
|
||||
if (!TEST_ptr(dummy) || !TEST_ptr(row))
|
||||
goto end;
|
||||
|
||||
gNid = SRP_create_verifier(userid, password, &row[DB_srpsalt],
|
||||
&row[DB_srpverifier], NULL, NULL);
|
||||
gNid = SRP_create_verifier_ex(userid, password, &row[DB_srpsalt],
|
||||
&row[DB_srpverifier], NULL, NULL, NULL, NULL);
|
||||
if (!TEST_ptr(gNid))
|
||||
goto end;
|
||||
|
||||
@@ -5479,8 +5590,8 @@ static int create_new_vbase(char *userid, char *password)
|
||||
if (!TEST_ptr(lgN))
|
||||
goto end;
|
||||
|
||||
if (!TEST_true(SRP_create_verifier_BN(userid, password, &salt, &verifier,
|
||||
lgN->N, lgN->g)))
|
||||
if (!TEST_true(SRP_create_verifier_BN_ex(userid, password, &salt, &verifier,
|
||||
lgN->N, lgN->g, NULL, NULL)))
|
||||
goto end;
|
||||
|
||||
user_pwd = OPENSSL_zalloc(sizeof(*user_pwd));
|
||||
@@ -7214,6 +7325,7 @@ int setup_tests(void)
|
||||
#ifndef OPENSSL_NO_TLS1_2
|
||||
ADD_TEST(test_client_hello_cb);
|
||||
ADD_TEST(test_no_ems);
|
||||
ADD_TEST(test_ccs_change_cipher);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1_3
|
||||
ADD_ALL_TESTS(test_early_data_read_write, 3);
|
||||
|
||||
+60
-39
@@ -7,6 +7,7 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <openssl/provider.h>
|
||||
|
||||
#include "ssltestlib.h"
|
||||
@@ -14,11 +15,10 @@
|
||||
|
||||
static char *cert = NULL;
|
||||
static char *privkey = NULL;
|
||||
static char *modulename = NULL;
|
||||
static char *configfile = NULL;
|
||||
|
||||
/* TODO(3.0): Re-enable this code. See comment in setup_tests() */
|
||||
#if 0
|
||||
OSSL_PROVIDER *defctxlegacy = NULL;
|
||||
#endif
|
||||
static OSSL_PROVIDER *defctxlegacy = NULL;
|
||||
|
||||
static int test_different_libctx(void)
|
||||
{
|
||||
@@ -26,13 +26,29 @@ static int test_different_libctx(void)
|
||||
SSL *clientssl = NULL, *serverssl = NULL;
|
||||
int testresult = 0;
|
||||
OPENSSL_CTX *libctx = OPENSSL_CTX_new();
|
||||
OSSL_PROVIDER *prov = NULL;
|
||||
|
||||
/* TODO(3.0): Re-enable this code. See comment in setup_tests() */
|
||||
#if 0
|
||||
/* Verify that the default provider in the default libctx is not available */
|
||||
if (!TEST_false(OSSL_PROVIDER_available(NULL, "default")))
|
||||
/*
|
||||
* Verify that the default and fips providers in the default libctx are not
|
||||
* available
|
||||
*/
|
||||
if (!TEST_false(OSSL_PROVIDER_available(NULL, "default"))
|
||||
|| !TEST_false(OSSL_PROVIDER_available(NULL, "fips")))
|
||||
goto end;
|
||||
#endif
|
||||
|
||||
if (!TEST_true(OPENSSL_CTX_load_config(libctx, configfile)))
|
||||
goto end;
|
||||
|
||||
prov = OSSL_PROVIDER_load(libctx, modulename);
|
||||
if (!TEST_ptr(prov)
|
||||
/* Check we have the provider available */
|
||||
|| !TEST_true(OSSL_PROVIDER_available(libctx, modulename)))
|
||||
goto end;
|
||||
/* Check the default provider is not available */
|
||||
if (strcmp(modulename, "default") != 0
|
||||
&& !TEST_false(OSSL_PROVIDER_available(libctx, "default")))
|
||||
goto end;
|
||||
TEST_note("%s provider loaded", modulename);
|
||||
|
||||
cctx = SSL_CTX_new_with_libctx(libctx, NULL, TLS_client_method());
|
||||
if (!TEST_ptr(cctx))
|
||||
@@ -41,11 +57,21 @@ static int test_different_libctx(void)
|
||||
if (!TEST_ptr(sctx))
|
||||
goto end;
|
||||
|
||||
/*
|
||||
* TODO(3.0): Make this work in TLSv1.3. Currently we can only do RSA key
|
||||
* exchange, because we don't have key gen/param gen for EC yet - which
|
||||
* implies TLSv1.2 only
|
||||
*/
|
||||
if (!TEST_true(create_ssl_ctx_pair(NULL,
|
||||
NULL,
|
||||
TLS1_VERSION,
|
||||
0,
|
||||
&sctx, NULL, cert, privkey)))
|
||||
TLS1_2_VERSION,
|
||||
&sctx, &cctx, cert, privkey)))
|
||||
goto end;
|
||||
|
||||
/* Ensure we use a FIPS compatible ciphersuite and sigalg */
|
||||
if (!TEST_true(SSL_CTX_set_cipher_list(cctx, "AES128-SHA256"))
|
||||
|| !TEST_true(SSL_CTX_set1_sigalgs_list(cctx, "RSA+SHA256")))
|
||||
goto end;
|
||||
|
||||
if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
|
||||
@@ -56,15 +82,13 @@ static int test_different_libctx(void)
|
||||
if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
|
||||
goto end;
|
||||
|
||||
/* TODO(3.0): Re-enable this code. See comment in setup_tests() */
|
||||
#if 0
|
||||
/*
|
||||
* Verify that the default provider in the default libctx is still not
|
||||
* available
|
||||
* Verify that the default and fips providers in the default libctx are
|
||||
* still not available
|
||||
*/
|
||||
if (!TEST_false(OSSL_PROVIDER_available(NULL, "default")))
|
||||
if (!TEST_false(OSSL_PROVIDER_available(NULL, "default"))
|
||||
|| !TEST_false(OSSL_PROVIDER_available(NULL, "fips")))
|
||||
goto end;
|
||||
#endif
|
||||
|
||||
testresult = 1;
|
||||
|
||||
@@ -74,6 +98,7 @@ static int test_different_libctx(void)
|
||||
SSL_CTX_free(sctx);
|
||||
SSL_CTX_free(cctx);
|
||||
|
||||
OSSL_PROVIDER_unload(prov);
|
||||
OPENSSL_CTX_free(libctx);
|
||||
|
||||
return testresult;
|
||||
@@ -82,26 +107,15 @@ static int test_different_libctx(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
char *certsdir = NULL;
|
||||
/*
|
||||
* TODO(3.0): Re-enable this code when key generation is provider aware. At
|
||||
* the moment the below causes the tests to fail because libssl attempts to
|
||||
* generate a key for the key_share, which ultimately invokes RAND_bytes().
|
||||
* However, because key generation is not yet provider aware it just uses
|
||||
* the default library context - and hence fails.
|
||||
*/
|
||||
#if 0
|
||||
/*
|
||||
* For tests in this file we want to ensure the default ctx does not have
|
||||
* the default provider loaded into the default ctx. So we load "legacy" to
|
||||
* prevent default from being auto-loaded. This tests that there is no
|
||||
* "leakage", i.e. when using SSL_CTX_new_with_libctx() we expect only the
|
||||
* specific libctx to be used - nothing should fall back to the default
|
||||
* libctx
|
||||
*/
|
||||
defctxlegacy = OSSL_PROVIDER_load(NULL, "legacy");
|
||||
#endif
|
||||
|
||||
if (!TEST_ptr(certsdir = test_get_argument(0)))
|
||||
if (!test_skip_common_options()) {
|
||||
TEST_error("Error parsing test options\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!TEST_ptr(certsdir = test_get_argument(0))
|
||||
|| !TEST_ptr(modulename = test_get_argument(1))
|
||||
|| !TEST_ptr(configfile = test_get_argument(2)))
|
||||
return 0;
|
||||
|
||||
cert = test_mk_file_path(certsdir, "servercert.pem");
|
||||
@@ -114,6 +128,16 @@ int setup_tests(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* For tests in this file we want to ensure the default ctx does not have
|
||||
* the default provider loaded into the default ctx. So we load "legacy" to
|
||||
* prevent default from being auto-loaded. This tests that there is no
|
||||
* "leakage", i.e. when using SSL_CTX_new_with_libctx() we expect only the
|
||||
* specific libctx to be used - nothing should fall back to the default
|
||||
* libctx
|
||||
*/
|
||||
defctxlegacy = OSSL_PROVIDER_load(NULL, "legacy");
|
||||
|
||||
ADD_TEST(test_different_libctx);
|
||||
|
||||
return 1;
|
||||
@@ -121,8 +145,5 @@ int setup_tests(void)
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
/* TODO(3.0): Re-enable this code. See comment in setup_tests() */
|
||||
#if 0
|
||||
OSSL_PROVIDER_unload(defctxlegacy);
|
||||
#endif
|
||||
}
|
||||
+8
-1
@@ -915,11 +915,14 @@ int create_ssl_objects(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an SSL connection, but does not ready any post-handshake
|
||||
* Create an SSL connection, but does not read any post-handshake
|
||||
* NewSessionTicket messages.
|
||||
* If |read| is set and we're using DTLS then we will attempt to SSL_read on
|
||||
* the connection once we've completed one half of it, to ensure any retransmits
|
||||
* get triggered.
|
||||
* We stop the connection attempt (and return a failure value) if either peer
|
||||
* has SSL_get_error() return the value in the |want| parameter. The connection
|
||||
* attempt could be restarted by a subsequent call to this function.
|
||||
*/
|
||||
int create_bare_ssl_connection(SSL *serverssl, SSL *clientssl, int want,
|
||||
int read)
|
||||
@@ -938,6 +941,8 @@ int create_bare_ssl_connection(SSL *serverssl, SSL *clientssl, int want,
|
||||
|
||||
if (!clienterr && retc <= 0 && err != SSL_ERROR_WANT_READ) {
|
||||
TEST_info("SSL_connect() failed %d, %d", retc, err);
|
||||
if (want != SSL_ERROR_SSL)
|
||||
TEST_openssl_errors();
|
||||
clienterr = 1;
|
||||
}
|
||||
if (want != SSL_ERROR_NONE && err == want)
|
||||
@@ -954,6 +959,8 @@ int create_bare_ssl_connection(SSL *serverssl, SSL *clientssl, int want,
|
||||
&& err != SSL_ERROR_WANT_READ
|
||||
&& err != SSL_ERROR_WANT_X509_LOOKUP) {
|
||||
TEST_info("SSL_accept() failed %d, %d", rets, err);
|
||||
if (want != SSL_ERROR_SSL)
|
||||
TEST_openssl_errors();
|
||||
servererr = 1;
|
||||
}
|
||||
if (want != SSL_ERROR_NONE && err == want)
|
||||
|
||||
+14
-18
@@ -179,15 +179,13 @@ static int test_store_ctx(void)
|
||||
|
||||
OPT_TEST_DECLARE_USAGE("roots.pem untrusted.pem bad.pem\n")
|
||||
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
static int test_sm2_id(void)
|
||||
static int test_distinguishing_id(void)
|
||||
{
|
||||
/* we only need an X509 structure, no matter if it's a real SM2 cert */
|
||||
X509 *x = NULL;
|
||||
BIO *bio = NULL;
|
||||
int ret = 0;
|
||||
ASN1_OCTET_STRING *v = NULL, *v2 = NULL;
|
||||
char *sm2id = "this is an ID";
|
||||
char *distid = "this is an ID";
|
||||
|
||||
bio = BIO_new_file(bad_f, "r");
|
||||
if (bio == NULL)
|
||||
@@ -201,14 +199,15 @@ static int test_sm2_id(void)
|
||||
if (v == NULL)
|
||||
goto err;
|
||||
|
||||
if (!ASN1_OCTET_STRING_set(v, (unsigned char *)sm2id, (int)strlen(sm2id))) {
|
||||
if (!ASN1_OCTET_STRING_set(v, (unsigned char *)distid,
|
||||
(int)strlen(distid))) {
|
||||
ASN1_OCTET_STRING_free(v);
|
||||
goto err;
|
||||
}
|
||||
|
||||
X509_set0_sm2_id(x, v);
|
||||
X509_set0_distinguishing_id(x, v);
|
||||
|
||||
v2 = X509_get0_sm2_id(x);
|
||||
v2 = X509_get0_distinguishing_id(x);
|
||||
if (!TEST_ptr(v2)
|
||||
|| !TEST_int_eq(ASN1_OCTET_STRING_cmp(v, v2), 0))
|
||||
goto err;
|
||||
@@ -220,14 +219,13 @@ static int test_sm2_id(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_req_sm2_id(void)
|
||||
static int test_req_distinguishing_id(void)
|
||||
{
|
||||
/* we only need an X509_REQ structure, no matter if it's a real SM2 cert */
|
||||
X509_REQ *x = NULL;
|
||||
BIO *bio = NULL;
|
||||
int ret = 0;
|
||||
ASN1_OCTET_STRING *v = NULL, *v2 = NULL;
|
||||
char *sm2id = "this is an ID";
|
||||
char *distid = "this is an ID";
|
||||
|
||||
bio = BIO_new_file(req_f, "r");
|
||||
if (bio == NULL)
|
||||
@@ -241,14 +239,15 @@ static int test_req_sm2_id(void)
|
||||
if (v == NULL)
|
||||
goto err;
|
||||
|
||||
if (!ASN1_OCTET_STRING_set(v, (unsigned char *)sm2id, (int)strlen(sm2id))) {
|
||||
if (!ASN1_OCTET_STRING_set(v, (unsigned char *)distid,
|
||||
(int)strlen(distid))) {
|
||||
ASN1_OCTET_STRING_free(v);
|
||||
goto err;
|
||||
}
|
||||
|
||||
X509_REQ_set0_sm2_id(x, v);
|
||||
X509_REQ_set0_distinguishing_id(x, v);
|
||||
|
||||
v2 = X509_REQ_get0_sm2_id(x);
|
||||
v2 = X509_REQ_get0_distinguishing_id(x);
|
||||
if (!TEST_ptr(v2)
|
||||
|| !TEST_int_eq(ASN1_OCTET_STRING_cmp(v, v2), 0))
|
||||
goto err;
|
||||
@@ -259,7 +258,6 @@ static int test_req_sm2_id(void)
|
||||
BIO_free(bio);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
@@ -276,9 +274,7 @@ int setup_tests(void)
|
||||
|
||||
ADD_TEST(test_alt_chains_cert_forgery);
|
||||
ADD_TEST(test_store_ctx);
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
ADD_TEST(test_sm2_id);
|
||||
ADD_TEST(test_req_sm2_id);
|
||||
#endif
|
||||
ADD_TEST(test_distinguishing_id);
|
||||
ADD_TEST(test_req_distinguishing_id);
|
||||
return 1;
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/rand.h>
|
||||
#include "internal/packet.h"
|
||||
#include "testutil.h"
|
||||
|
||||
@@ -21,6 +22,9 @@ static const unsigned char empty[] = { 0x00 };
|
||||
static const unsigned char alloc[] = { 0x02, 0xfe, 0xff };
|
||||
static const unsigned char submem[] = { 0x03, 0x02, 0xfe, 0xff };
|
||||
static const unsigned char fixed[] = { 0xff, 0xff, 0xff };
|
||||
static const unsigned char simpleder[] = {
|
||||
0xfc, 0x04, 0x00, 0x01, 0x02, 0x03, 0xff, 0xfe, 0xfd
|
||||
};
|
||||
|
||||
static BUF_MEM *buf;
|
||||
|
||||
@@ -349,6 +353,68 @@ static int test_WPACKET_memcpy(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int test_WPACKET_init_der(void)
|
||||
{
|
||||
WPACKET pkt;
|
||||
unsigned char sbuf[1024];
|
||||
unsigned char testdata[] = { 0x00, 0x01, 0x02, 0x03 };
|
||||
unsigned char testdata2[259] = { 0x82, 0x01, 0x00 };
|
||||
size_t written[2];
|
||||
int i;
|
||||
|
||||
/* Test initialising for writing DER */
|
||||
if (!TEST_true(WPACKET_init_der(&pkt, sbuf, sizeof(sbuf)))
|
||||
|| !TEST_true(WPACKET_put_bytes_u24(&pkt, 0xfffefd))
|
||||
/* Test writing data in a length prefixed sub-packet */
|
||||
|| !TEST_true(WPACKET_start_sub_packet(&pkt))
|
||||
|| !TEST_true(WPACKET_memcpy(&pkt, testdata, sizeof(testdata)))
|
||||
|| !TEST_true(WPACKET_close(&pkt))
|
||||
|| !TEST_true(WPACKET_put_bytes_u8(&pkt, 0xfc))
|
||||
|| !TEST_true(WPACKET_finish(&pkt))
|
||||
|| !TEST_true(WPACKET_get_total_written(&pkt, &written[0]))
|
||||
|| !TEST_mem_eq(WPACKET_get_curr(&pkt), written[0], simpleder,
|
||||
sizeof(simpleder)))
|
||||
return cleanup(&pkt);
|
||||
|
||||
/* Generate random packet data for test */
|
||||
if (!TEST_true(RAND_bytes(&testdata2[3], sizeof(testdata2) - 3)))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Test with a sub-packet that has 2 length bytes. We do 2 passes - first
|
||||
* with a NULL buffer, just to calculate lengths, and a second pass with a
|
||||
* real buffer to actually generate a packet
|
||||
*/
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (i == 0) {
|
||||
if (!TEST_true(WPACKET_init_null_der(&pkt)))
|
||||
return 0;
|
||||
} else {
|
||||
if (!TEST_true(WPACKET_init_der(&pkt, sbuf, sizeof(sbuf))))
|
||||
return 0;
|
||||
}
|
||||
if (!TEST_true(WPACKET_start_sub_packet(&pkt))
|
||||
|| !TEST_true(WPACKET_memcpy(&pkt, &testdata2[3],
|
||||
sizeof(testdata2) - 3))
|
||||
|| !TEST_true(WPACKET_close(&pkt))
|
||||
|| !TEST_true(WPACKET_finish(&pkt))
|
||||
|| !TEST_true(WPACKET_get_total_written(&pkt, &written[i])))
|
||||
return cleanup(&pkt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that the size calculated in the first pass equals the size of the
|
||||
* packet actually generated in the second pass. Also check the generated
|
||||
* packet looks as we expect it to.
|
||||
*/
|
||||
if (!TEST_size_t_eq(written[0], written[1])
|
||||
|| !TEST_mem_eq(WPACKET_get_curr(&pkt), written[1], testdata2,
|
||||
sizeof(testdata2)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (!TEST_ptr(buf = BUF_MEM_new()))
|
||||
@@ -360,6 +426,7 @@ int setup_tests(void)
|
||||
ADD_TEST(test_WPACKET_set_flags);
|
||||
ADD_TEST(test_WPACKET_allocate_bytes);
|
||||
ADD_TEST(test_WPACKET_memcpy);
|
||||
ADD_TEST(test_WPACKET_init_der);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user