From: Tomas Mraz Date: Thu, 28 Jul 2022 12:13:06 +0000 (+0200) Subject: Add testcases for EVP_PKEY_get1_encoded_public_key X-Git-Tag: openssl-3.2.0-alpha1~2268 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a1596f4e3d710c163279a20e6b844d371886e73;p=thirdparty%2Fopenssl.git Add testcases for EVP_PKEY_get1_encoded_public_key Reviewed-by: Paul Dale Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/18902) --- diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index dfcd3177730..23f92f26f05 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -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);