From c97a0bb0bfbe8521674625810f2d3acd3c00d74d Mon Sep 17 00:00:00 2001 From: Pauli Date: Thu, 5 Jun 2025 09:50:59 +1000 Subject: [PATCH] rand: produce correct return from EVP_RAND_nonce MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Tom Cosgrove Reviewed-by: Saša Nedvědický Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27766) (cherry picked from commit a2b9120d15073ab596452fc361d01bb26ee13773) --- crypto/evp/evp_rand.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crypto/evp/evp_rand.c b/crypto/evp/evp_rand.c index 50334042a9c..ac0c01f2ae1 100644 --- a/crypto/evp/evp_rand.c +++ b/crypto/evp/evp_rand.c @@ -646,10 +646,8 @@ static int evp_rand_nonce_locked(EVP_RAND_CTX *ctx, unsigned char *out, { unsigned int str = evp_rand_strength_locked(ctx); - if (ctx->meth->nonce == NULL) - return 0; - if (ctx->meth->nonce(ctx->algctx, out, str, outlen, outlen)) - return 1; + if (ctx->meth->nonce != NULL) + return ctx->meth->nonce(ctx->algctx, out, str, outlen, outlen) > 0; return evp_rand_generate_locked(ctx, out, outlen, str, 0, NULL, 0); } -- 2.47.2