Commit 6d250710fb for openssl.org
commit 6d250710fb8cfd5c9a41af373c0c1ca85ff836c2
Author: Tomas Mraz <tomas@openssl.foundation>
Date: Tue Jul 28 16:23:01 2026 +0200
Document the behavior of BN_generate_prime() on failure
The ret argument is freed on failure which might be
surprising to callers.
Reported by: Minkyung Park (UNIST)
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
MergeDate: Mon Aug 10 15:09:34 2026
(Merged from https://github.com/openssl/openssl/pull/32099)
diff --git a/doc/man3/BN_generate_prime.pod b/doc/man3/BN_generate_prime.pod
index 005c25fd7c..1a2bb5d7fe 100644
--- a/doc/man3/BN_generate_prime.pod
+++ b/doc/man3/BN_generate_prime.pod
@@ -201,6 +201,8 @@ BN_is_prime_fasttest() and BN_check_prime return 0 if the number is composite,
-1 on error.
BN_generate_prime() returns the prime number on success, B<NULL> otherwise.
+Please note that the B<ret> BIGNUM is freed on failure and must not be
+used or freed by the caller in such case.
BN_GENCB_new returns a pointer to a BN_GENCB structure on success, or B<NULL>
otherwise.