From 2ffbd76c6260bb6eab3771629c841bdacb69e36c Mon Sep 17 00:00:00 2001 From: olszomal Date: Tue, 4 Aug 2026 11:36:20 +0200 Subject: [PATCH] Check the OSSL_PARAM type before reading the RSA-PSS salt length Previously, string parameters were passed to OSSL_PARAM_get_int() first, leaving a spurious "incompatible type" error in the OpenSSL error queue even when string parsing succeeded. --- src/provider.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/provider.c b/src/provider.c index 412a50c4..8ecb96da 100644 --- a/src/provider.c +++ b/src/provider.c @@ -1660,11 +1660,16 @@ static int signature_set_ctx_params(void *ctx, const OSSL_PARAM params[]) p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_PSS_SALTLEN); if (p != NULL) { int saltlen = 0; - const char *s = NULL; - if (OSSL_PARAM_get_int(p, &saltlen)) { - /* got int directly */ - } else if (OSSL_PARAM_get_utf8_string_ptr(p, &s) && s != NULL) { + if (p->data_type == OSSL_PARAM_INTEGER) { + if (!OSSL_PARAM_get_int(p, &saltlen)) + return 0; + } else if (p->data_type == OSSL_PARAM_UTF8_STRING) { + const char *s = NULL; + + if (OSSL_PARAM_get_utf8_string_ptr(p, &s) || s == NULL) + return 0; + if (OPENSSL_strcasecmp(s, "digest") == 0) saltlen = RSA_PSS_SALTLEN_DIGEST; /* -1 */ else if (OPENSSL_strcasecmp(s, "auto") == 0)