diff options
author | Matt Caswell <matt@openssl.org> | 2021-11-15 12:24:05 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2021-11-16 13:28:40 +0000 |
commit | 1843930a71f905f1c8f6207e8a693d426e322443 (patch) | |
tree | 19734a11d5b439a886d6bc25176b73461d92470f /test | |
parent | c41df3bd2d35d265103aa033a754dd66a13ec81a (diff) |
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 <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17041)
(cherry picked from commit 8c08c8b37cab0eb66ca74fc65a40af3ccec77c00)
Diffstat (limited to 'test')
-rw-r--r-- | test/evp_extra_test.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index 0db48a7c93..830639b8ab 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -4231,6 +4231,28 @@ static int test_cipher_with_engine(void) # endif /* OPENSSL_NO_DYNAMIC_ENGINE */ #endif /* OPENSSL_NO_DEPRECATED_3_0 */ +static int ecxnids[] = { + NID_X25519, + NID_X448, + NID_ED25519, + NID_ED448 +}; + +/* Test that creating ECX keys with a short private key fails as expected */ +static int test_ecx_short_keys(int tst) +{ + unsigned char ecxkeydata = 1; + EVP_PKEY *pkey; + + + pkey = EVP_PKEY_new_raw_private_key(ecxnids[tst], NULL, &ecxkeydata, 1); + if (!TEST_ptr_null(pkey)) { + EVP_PKEY_free(pkey); + return 0; + } + return 1; +} + typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, @@ -4374,6 +4396,8 @@ int setup_tests(void) # endif #endif + ADD_ALL_TESTS(test_ecx_short_keys, OSSL_NELEM(ecxnids)); + return 1; } |