TEST: Adapt test/evp_pkey_provided_test.c to check the key size
authorRichard Levitte <levitte@openssl.org>
Wed, 8 Jan 2020 02:50:33 +0000 (03:50 +0100)
committerRichard Levitte <levitte@openssl.org>
Fri, 17 Jan 2020 08:04:04 +0000 (09:04 +0100)
This is for the case where we build keys from user data

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10778)

test/evp_pkey_provided_test.c

index 029a8e425a044081d03b92f51e7fef22b277612b..8101585d950ed759a17dcce0b819cb2cee5331e8 100644 (file)
@@ -126,7 +126,10 @@ static int test_fromdata_rsa(void)
         goto err;
 
     if (!TEST_true(EVP_PKEY_key_fromdata_init(ctx))
-        || !TEST_true(EVP_PKEY_fromdata(ctx, &pk, fromdata_params)))
+        || !TEST_true(EVP_PKEY_fromdata(ctx, &pk, 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))
         goto err;
 
     ret = test_print_key_using_pem(pk)
@@ -176,7 +179,10 @@ static int test_fromdata_dh(void)
         goto err;
 
     if (!TEST_true(EVP_PKEY_key_fromdata_init(ctx))
-        || !TEST_true(EVP_PKEY_fromdata(ctx, &pk, fromdata_params)))
+        || !TEST_true(EVP_PKEY_fromdata(ctx, &pk, fromdata_params))
+        || !TEST_int_eq(EVP_PKEY_bits(pk), 32)
+        || !TEST_int_eq(EVP_PKEY_security_bits(pk), 0) /* Missing Q */
+        || !TEST_int_eq(EVP_PKEY_size(pk), 4))
         goto err;
 
     ret = test_print_key_using_pem(pk)