]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add testcases for EVP_PKEY_get1_encoded_public_key
authorTomas Mraz <tomas@openssl.org>
Thu, 28 Jul 2022 12:13:06 +0000 (14:13 +0200)
committerTomas Mraz <tomas@openssl.org>
Thu, 18 Aug 2022 08:20:03 +0000 (10:20 +0200)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18902)

test/evp_extra_test.c

index dfcd317773019ea898fea2f4ebef21a0383b51d4..23f92f26f058a58f839252c37ec7da19663610c3 100644 (file)
@@ -897,6 +897,7 @@ static int test_EC_priv_pub(void)
     EVP_PKEY *params_and_keypair = NULL;
     BIGNUM *priv = NULL;
     int ret = 0;
+    unsigned char *encoded = NULL;
 
     /*
      * Setup the parameters for our pkey object. For our purposes they don't
@@ -1005,6 +1006,17 @@ static int test_EC_priv_pub(void)
         || !TEST_int_gt(EVP_PKEY_eq(params_and_keypair, params_and_priv), 0))
         goto err;
 
+    /* Positive and negative testcase for EVP_PKEY_get1_encoded_public_key */
+    if (!TEST_int_gt(EVP_PKEY_get1_encoded_public_key(params_and_pub, &encoded), 0))
+        goto err;
+    OPENSSL_free(encoded);
+    encoded = NULL;
+    if (!TEST_int_eq(EVP_PKEY_get1_encoded_public_key(just_params, &encoded), 0)) {
+        OPENSSL_free(encoded);
+        encoded = NULL;
+        goto err;
+    }
+
     ret = 1;
  err:
     OSSL_PARAM_free(params);