diff options
Diffstat (limited to 'test/evp_extra_test.c')
-rw-r--r-- | test/evp_extra_test.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index 1141d52666..72a6305d89 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -900,6 +900,8 @@ static int test_EC_priv_pub(void) BIGNUM *priv = NULL; int ret = 0; unsigned char *encoded = NULL; + size_t len = 0; + unsigned char buffer[128]; /* * Setup the parameters for our pkey object. For our purposes they don't @@ -1019,6 +1021,26 @@ static int test_EC_priv_pub(void) goto err; } + /* Positive and negative testcase for EVP_PKEY_get_octet_string_param */ + if (!TEST_int_eq(EVP_PKEY_get_octet_string_param(params_and_pub, + OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, + buffer, sizeof(buffer), &len), 1) + || !TEST_int_eq(len, 65)) + goto err; + + len = 0; + if (!TEST_int_eq(EVP_PKEY_get_octet_string_param(params_and_pub, + OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, + NULL, 0, &len), 1) + || !TEST_int_eq(len, 65)) + goto err; + + /* too-short buffer len*/ + if (!TEST_int_eq(EVP_PKEY_get_octet_string_param(params_and_pub, + OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, + buffer, 10, &len), 0)) + goto err; + ret = 1; err: OSSL_PARAM_free(params); |