crypto/bn: fix return value in BN_generate_prime
authorDavid Asraf <dasraf9@gmail.com>
Wed, 23 Jan 2019 11:10:11 +0000 (11:10 +0000)
committerMatt Caswell <matt@openssl.org>
Sun, 27 Jan 2019 12:18:50 +0000 (12:18 +0000)
When the ret parameter is NULL the generated prime
is in rnd variable and not in ret.

CLA: trivial

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8076)

(cherry picked from commit 3d43f9c809e42b960be94f2f4490d6d14e063486)

crypto/bn/bn_depr.c

index 7d89214..46ee0e9 100644 (file)
@@ -40,7 +40,7 @@ BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
         goto err;
 
     /* we have a prime :-) */
-    return ret;
+    return rnd;
  err:
     BN_free(rnd);
     return NULL;