summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorTom Cosgrove <tom.cosgrove@arm.com>2021-11-25 15:49:26 +0000
committerPauli <ppzgs1@gmail.com>2021-11-27 17:09:25 +1000
commita852c4e731f400deab23600e01db22ee97ff8ac7 (patch)
treee329eda9b4620f75b90f56c3f3cffc09a4eaf338 /crypto/evp
parent7182ad7925077a825e451d09c59c2181d8533dc6 (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 'crypto/evp')
-rw-r--r--crypto/evp/ctrl_params_translate.c12
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;
}