diff options
author | Tom Cosgrove <tom.cosgrove@arm.com> | 2021-11-25 15:49:26 +0000 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2021-11-27 17:09:25 +1000 |
commit | a852c4e731f400deab23600e01db22ee97ff8ac7 (patch) | |
tree | e329eda9b4620f75b90f56c3f3cffc09a4eaf338 /test | |
parent | 7182ad7925077a825e451d09c59c2181d8533dc6 (diff) |
Fix EVP_PKEY_CTX_get_rsa_pss_saltlen() not returning a value
When an integer value was specified, it was not being passed back via
the orig_p2 weirdness.
Regression test included.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17136)
(cherry picked from commit 6f87463b62f9b2849510d74ff0fd6a62955ea947)
Diffstat (limited to 'test')
-rw-r--r-- | test/evp_extra_test.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index 8efe051f20..e6582315c0 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -3283,6 +3283,32 @@ static int test_EVP_rsa_pss_with_keygen_bits(void) return ret; } +static int test_EVP_rsa_pss_set_saltlen(void) +{ + int ret = 0; + EVP_PKEY *pkey = NULL; + EVP_PKEY_CTX *pkey_ctx = NULL; + EVP_MD *sha256 = NULL; + EVP_MD_CTX *sha256_ctx = NULL; + int saltlen = 9999; /* buggy EVP_PKEY_CTX_get_rsa_pss_saltlen() didn't update this */ + const int test_value = 32; + + ret = TEST_ptr(pkey = load_example_rsa_key()) + && TEST_ptr(sha256 = EVP_MD_fetch(testctx, "sha256", NULL)) + && TEST_ptr(sha256_ctx = EVP_MD_CTX_new()) + && TEST_true(EVP_DigestSignInit(sha256_ctx, &pkey_ctx, sha256, NULL, pkey)) + && TEST_true(EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING)) + && TEST_true(EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, test_value)) + && TEST_true(EVP_PKEY_CTX_get_rsa_pss_saltlen(pkey_ctx, &saltlen)) + && TEST_int_eq(saltlen, test_value); + + EVP_MD_CTX_free(sha256_ctx); + EVP_PKEY_free(pkey); + EVP_MD_free(sha256); + + return ret; +} + static int success = 1; static void md_names(const char *name, void *vctx) { @@ -4368,6 +4394,7 @@ int setup_tests(void) ADD_ALL_TESTS(test_evp_iv_des, 6); #endif ADD_TEST(test_EVP_rsa_pss_with_keygen_bits); + ADD_TEST(test_EVP_rsa_pss_set_saltlen); #ifndef OPENSSL_NO_EC ADD_ALL_TESTS(test_ecpub, OSSL_NELEM(ecpub_nids)); #endif |