]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
rand: produce correct return from EVP_RAND_nonce
authorPauli <ppzgs1@gmail.com>
Wed, 4 Jun 2025 23:50:59 +0000 (09:50 +1000)
committerTomas Mraz <tomas@openssl.org>
Mon, 9 Jun 2025 08:24:08 +0000 (10:24 +0200)
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27766)

crypto/evp/evp_rand.c

index 50334042a9cca11c445aba13568343817432ffac..ac0c01f2ae1ec278332bff343ff66a24602065a0 100644 (file)
@@ -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);
 }