Skip to content

Commit 8c08c8b

Browse files
committed
Add a test for creating ECX private keys that are too short
We expect attempting to create such short keys to fail Reviewed-by: Tomas Mraz <[email protected]> Reviewed-by: Paul Dale <[email protected]> (Merged from openssl#17041)
1 parent 50938ae commit 8c08c8b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/evp_extra_test.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4231,6 +4231,28 @@ static int test_cipher_with_engine(void)
42314231
# endif /* OPENSSL_NO_DYNAMIC_ENGINE */
42324232
#endif /* OPENSSL_NO_DEPRECATED_3_0 */
42334233

4234+
static int ecxnids[] = {
4235+
NID_X25519,
4236+
NID_X448,
4237+
NID_ED25519,
4238+
NID_ED448
4239+
};
4240+
4241+
/* Test that creating ECX keys with a short private key fails as expected */
4242+
static int test_ecx_short_keys(int tst)
4243+
{
4244+
unsigned char ecxkeydata = 1;
4245+
EVP_PKEY *pkey;
4246+
4247+
4248+
pkey = EVP_PKEY_new_raw_private_key(ecxnids[tst], NULL, &ecxkeydata, 1);
4249+
if (!TEST_ptr_null(pkey)) {
4250+
EVP_PKEY_free(pkey);
4251+
return 0;
4252+
}
4253+
return 1;
4254+
}
4255+
42344256
typedef enum OPTION_choice {
42354257
OPT_ERR = -1,
42364258
OPT_EOF = 0,
@@ -4374,6 +4396,8 @@ int setup_tests(void)
43744396
# endif
43754397
#endif
43764398

4399+
ADD_ALL_TESTS(test_ecx_short_keys, OSSL_NELEM(ecxnids));
4400+
43774401
return 1;
43784402
}
43794403

0 commit comments

Comments
 (0)