Add a test for EVP_PKEY_*_check functions for "DSA" keys
authorMat Berchtold <mberchtold@gmail.com>
Wed, 22 Apr 2020 00:30:40 +0000 (19:30 -0500)
committerRichard Levitte <levitte@openssl.org>
Fri, 1 May 2020 06:54:29 +0000 (08:54 +0200)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11598)

test/evp_pkey_provided_test.c

index 1ded0d9..2c07ed0 100644 (file)
@@ -1211,6 +1211,25 @@ static int test_fromdata_dsa_fips186_4(void)
 
     return ret;
 }
+
+static int test_check_dsa(void)
+{
+    int ret = 0;
+    EVP_PKEY_CTX *ctx = NULL;
+
+    if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL))
+        || !TEST_false(EVP_PKEY_check(ctx))
+        || !TEST_false(EVP_PKEY_public_check(ctx))
+        || !TEST_false(EVP_PKEY_private_check(ctx))
+        || !TEST_false(EVP_PKEY_pairwise_check(ctx)))
+       goto err;
+
+    ret = 1;
+ err:
+    EVP_PKEY_CTX_free(ctx);
+
+    return ret;
+}
 #endif /* OPENSSL_NO_DSA */
 
 
@@ -1231,6 +1250,7 @@ int setup_tests(void)
     ADD_TEST(test_fromdata_dh_named_group);
 #endif
 #ifndef OPENSSL_NO_DSA
+    ADD_TEST(test_check_dsa);
     ADD_TEST(test_fromdata_dsa_fips186_4);
 #endif
 #ifndef OPENSSL_NO_EC