]> 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:57:13 +0000 (09:57 +1000)
committerTomas Mraz <tomas@openssl.org>
Mon, 9 Jun 2025 07:56:13 +0000 (09:56 +0200)
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27767)

crypto/evp/evp_rand.c

index c36dbdc56c775367ce50f2a47f0fc0fd989ed2f8..1e97b1359fffb59c929f9982712e96874c1f2468 100644 (file)
@@ -634,10 +634,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);
 }