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:08:52 +1000 |
commit | 6f87463b62f9b2849510d74ff0fd6a62955ea947 (patch) | |
tree | cfa177be27891c66e98a8fe252b4310ed0b8fb97 /crypto/evp | |
parent | 23750f677ef61b6bea4e81f23f335ad08fc49b51 (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)
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/ctrl_params_translate.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/crypto/evp/ctrl_params_translate.c b/crypto/evp/ctrl_params_translate.c index cfde29dac2..f6a2d1d0f8 100644 --- a/crypto/evp/ctrl_params_translate.c +++ b/crypto/evp/ctrl_params_translate.c @@ -1392,21 +1392,23 @@ static int fix_rsa_pss_saltlen(enum state state, if ((ctx->action_type == SET && state == PRE_PARAMS_TO_CTRL) || (ctx->action_type == GET && state == POST_CTRL_TO_PARAMS)) { size_t i; + int val; for (i = 0; i < OSSL_NELEM(str_value_map); i++) { if (strcmp(ctx->p2, str_value_map[i].ptr) == 0) break; } - if (i == OSSL_NELEM(str_value_map)) { - ctx->p1 = atoi(ctx->p2); - } else if (state == POST_CTRL_TO_PARAMS) { + + val = i == OSSL_NELEM(str_value_map) ? atoi(ctx->p2) + : (int)str_value_map[i].id; + if (state == POST_CTRL_TO_PARAMS) { /* * EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN weirdness explained further * up */ - *(int *)ctx->orig_p2 = str_value_map[i].id; + *(int *)ctx->orig_p2 = val; } else { - ctx->p1 = (int)str_value_map[i].id; + ctx->p1 = val; } ctx->p2 = NULL; } |