summaryrefslogtreecommitdiffstats
path: root/test/evp_pkey_provided_test.c
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2022-01-04 11:57:54 +0100
committerTomas Mraz <tomas@openssl.org>2022-01-07 09:51:04 +0100
commitd4d8f163db1d32c98d8f956e6966263a7a22fac1 (patch)
treee475a3b10f3cdb2057093a74e96abd63bd9041e9 /test/evp_pkey_provided_test.c
parent5b03b89f7f925384c2768874c95f1af7053fd16f (diff)
Test importing EC key parameters with a bad curve
Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17411)
Diffstat (limited to 'test/evp_pkey_provided_test.c')
-rw-r--r--test/evp_pkey_provided_test.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/evp_pkey_provided_test.c b/test/evp_pkey_provided_test.c
index 8b5c7b3457..cf4d8e1294 100644
--- a/test/evp_pkey_provided_test.c
+++ b/test/evp_pkey_provided_test.c
@@ -1113,8 +1113,6 @@ err:
return ret;
}
-#define CURVE_NAME 2
-
static int test_fromdata_ec(void)
{
int ret = 0;
@@ -1126,6 +1124,11 @@ static int test_fromdata_ec(void)
OSSL_PARAM *fromdata_params = NULL;
const char *alg = "EC";
const char *curve = "prime256v1";
+ const char bad_curve[] = "nonexistent-curve";
+ OSSL_PARAM nokey_params[2] = {
+ OSSL_PARAM_END,
+ OSSL_PARAM_END
+ };
/* UNCOMPRESSED FORMAT */
static const unsigned char ec_pub_keydata[] = {
POINT_CONVERSION_UNCOMPRESSED,
@@ -1179,6 +1182,16 @@ static int test_fromdata_ec(void)
if (!TEST_ptr(ctx))
goto err;
+ /* try importing parameters with bad curve first */
+ nokey_params[0] =
+ OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME,
+ (char *)bad_curve, sizeof(bad_curve));
+ if (!TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1)
+ || !TEST_int_eq(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEY_PARAMETERS,
+ nokey_params), 0)
+ || !TEST_ptr_null(pk))
+ goto err;
+
if (!TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1)
|| !TEST_int_eq(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR,
fromdata_params), 1))