aboutsummaryrefslogtreecommitdiff
path: root/test/evp_pkey_provided_test.c
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-03-11 13:31:13 +0100
committerTomas Mraz <tomas@openssl.org>2021-03-17 14:57:47 +0100
commit9a4854405869158bd87ee90345b933815882a24d (patch)
tree3bad42c70a66232ac69c0d9e2adcc41ed7b27c17 /test/evp_pkey_provided_test.c
parente08993eab65cdc67a3f2078e99f366c155eed49d (diff)
downloadopenssl-9a4854405869158bd87ee90345b933815882a24d.zip
openssl-9a4854405869158bd87ee90345b933815882a24d.tar.gz
openssl-9a4854405869158bd87ee90345b933815882a24d.tar.bz2
Make EVP_PKEY_missing_parameters work properly on provided RSA keys
This requires changing semantics of the keymgmt_has() function a little in the sense that it now returns 1 if the selection has no meaning for the key type. It was already doing so for ECX keys for example. The keymgmt_validate function semantics is changed similarly to allow passing validation on the same selection that the key returns 1 for. Fixes #14509 Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14511)
Diffstat (limited to 'test/evp_pkey_provided_test.c')
-rw-r--r--test/evp_pkey_provided_test.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/evp_pkey_provided_test.c b/test/evp_pkey_provided_test.c
index 18b62d4..c89bb36 100644
--- a/test/evp_pkey_provided_test.c
+++ b/test/evp_pkey_provided_test.c
@@ -344,7 +344,8 @@ static int test_fromdata_rsa(void)
fromdata_params))
|| !TEST_int_eq(EVP_PKEY_bits(pk), 32)
|| !TEST_int_eq(EVP_PKEY_security_bits(pk), 8)
- || !TEST_int_eq(EVP_PKEY_size(pk), 4))
+ || !TEST_int_eq(EVP_PKEY_size(pk), 4)
+ || !TEST_false(EVP_PKEY_missing_parameters(pk)))
goto err;
if (!TEST_ptr(key_ctx = EVP_PKEY_CTX_new_from_pkey(NULL, pk, "")))
@@ -509,7 +510,8 @@ static int test_fromdata_dh_named_group(void)
fromdata_params))
|| !TEST_int_eq(EVP_PKEY_bits(pk), 2048)
|| !TEST_int_eq(EVP_PKEY_security_bits(pk), 112)
- || !TEST_int_eq(EVP_PKEY_size(pk), 256))
+ || !TEST_int_eq(EVP_PKEY_size(pk), 256)
+ || !TEST_false(EVP_PKEY_missing_parameters(pk)))
goto err;
if (!TEST_true(EVP_PKEY_get_utf8_string_param(pk, OSSL_PKEY_PARAM_GROUP_NAME,
@@ -654,7 +656,8 @@ static int test_fromdata_dh_fips186_4(void)
fromdata_params))
|| !TEST_int_eq(EVP_PKEY_bits(pk), 2048)
|| !TEST_int_eq(EVP_PKEY_security_bits(pk), 112)
- || !TEST_int_eq(EVP_PKEY_size(pk), 256))
+ || !TEST_int_eq(EVP_PKEY_size(pk), 256)
+ || !TEST_false(EVP_PKEY_missing_parameters(pk)))
goto err;
if (!TEST_true(EVP_PKEY_get_utf8_string_param(pk, OSSL_PKEY_PARAM_GROUP_NAME,
@@ -926,7 +929,8 @@ static int test_fromdata_ecx(int tst)
fromdata_params))
|| !TEST_int_eq(EVP_PKEY_bits(pk), bits)
|| !TEST_int_eq(EVP_PKEY_security_bits(pk), security_bits)
- || !TEST_int_eq(EVP_PKEY_size(pk), size))
+ || !TEST_int_eq(EVP_PKEY_size(pk), size)
+ || !TEST_false(EVP_PKEY_missing_parameters(pk)))
goto err;
if (!TEST_ptr(ctx2 = EVP_PKEY_CTX_new_from_pkey(NULL, pk, NULL)))
@@ -1039,7 +1043,8 @@ static int test_fromdata_ec(void)
fromdata_params))
|| !TEST_int_eq(EVP_PKEY_bits(pk), 256)
|| !TEST_int_eq(EVP_PKEY_security_bits(pk), 128)
- || !TEST_int_eq(EVP_PKEY_size(pk), 2 + 35 * 2))
+ || !TEST_int_eq(EVP_PKEY_size(pk), 2 + 35 * 2)
+ || !TEST_false(EVP_PKEY_missing_parameters(pk)))
goto err;
if (!TEST_ptr(copy_pk = EVP_PKEY_new())
@@ -1298,7 +1303,8 @@ static int test_fromdata_dsa_fips186_4(void)
fromdata_params))
|| !TEST_int_eq(EVP_PKEY_bits(pk), 2048)
|| !TEST_int_eq(EVP_PKEY_security_bits(pk), 112)
- || !TEST_int_eq(EVP_PKEY_size(pk), 2 + 2 * (3 + sizeof(q_data))))
+ || !TEST_int_eq(EVP_PKEY_size(pk), 2 + 2 * (3 + sizeof(q_data)))
+ || !TEST_false(EVP_PKEY_missing_parameters(pk)))
goto err;
if (!TEST_false(EVP_PKEY_get_utf8_string_param(pk, OSSL_PKEY_PARAM_GROUP_NAME,