summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/BN_generate_prime.3
diff options
context:
space:
mode:
authorschwarze <>2019-08-25 19:24:00 +0000
committerschwarze <>2019-08-25 19:24:00 +0000
commit778a6d338bf2610d12d814b4a503d2638cfc8d1d (patch)
treeb5109bcc1c452d104f90693aee6a22d0e945d314 /src/lib/libcrypto/man/BN_generate_prime.3
parent533a7ff91759c413fd387c34db7eef7bfcad50eb (diff)
downloadopenbsd-778a6d338bf2610d12d814b4a503d2638cfc8d1d.tar.gz
openbsd-778a6d338bf2610d12d814b4a503d2638cfc8d1d.tar.bz2
openbsd-778a6d338bf2610d12d814b4a503d2638cfc8d1d.zip
Change generating and checking of primes so that the error rate of
not being prime depends on the intended use based on the size of the input. For larger primes this will result in more rounds of Miller-Rabin. The maximal error rate for primes with more than 1080 bits is lowered to 2^-128. Patch from Kurt Roeckx <kurt@roeckx.be> and Annie Yousar via OpenSSL commit feac7a1c Jul 25 18:55:16 2018 +0200, still under a free license. OK tb@.
Diffstat (limited to 'src/lib/libcrypto/man/BN_generate_prime.3')
-rw-r--r--src/lib/libcrypto/man/BN_generate_prime.328
1 files changed, 20 insertions, 8 deletions
diff --git a/src/lib/libcrypto/man/BN_generate_prime.3 b/src/lib/libcrypto/man/BN_generate_prime.3
index 2369b6f24f..7db27fd627 100644
--- a/src/lib/libcrypto/man/BN_generate_prime.3
+++ b/src/lib/libcrypto/man/BN_generate_prime.3
@@ -1,6 +1,5 @@
1.\" $OpenBSD: BN_generate_prime.3,v 1.17 2019/06/10 14:58:48 schwarze Exp $ 1.\" $OpenBSD: BN_generate_prime.3,v 1.18 2019/08/25 19:24:00 schwarze Exp $
2.\" full merge up to: OpenSSL b3696a55 Sep 2 09:35:50 2017 -0400 2.\" full merge up to: OpenSSL f987a4dd Jun 27 10:12:08 2019 +0200
3.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
4.\" 3.\"
5.\" This file was written by Ulf Moeller <ulf@openssl.org> 4.\" This file was written by Ulf Moeller <ulf@openssl.org>
6.\" Bodo Moeller <bodo@openssl.org>, and Matt Caswell <matt@openssl.org>. 5.\" Bodo Moeller <bodo@openssl.org>, and Matt Caswell <matt@openssl.org>.
@@ -51,7 +50,7 @@
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\" 52.\"
54.Dd $Mdocdate: June 10 2019 $ 53.Dd $Mdocdate: August 25 2019 $
55.Dt BN_GENERATE_PRIME 3 54.Dt BN_GENERATE_PRIME 3
56.Os 55.Os
57.Sh NAME 56.Sh NAME
@@ -156,6 +155,8 @@ Deprecated:
156.Fn BN_generate_prime_ex 155.Fn BN_generate_prime_ex
157generates a pseudo-random prime number of at least bit length 156generates a pseudo-random prime number of at least bit length
158.Fa bits . 157.Fa bits .
158The returned number is probably prime, but there is a very small
159probability of returning a non-prime number.
159If 160If
160.Fa ret 161.Fa ret
161is not 162is not
@@ -212,8 +213,6 @@ If
212is true, it will be a safe prime (i.e. a prime p so that (p-1)/2 213is true, it will be a safe prime (i.e. a prime p so that (p-1)/2
213is also prime). 214is also prime).
214.Pp 215.Pp
215The prime number generation has a negligible error probability.
216.Pp
217.Fn BN_is_prime_ex 216.Fn BN_is_prime_ex
218and 217and
219.Fn BN_is_prime_fasttest_ex 218.Fn BN_is_prime_fasttest_ex
@@ -251,8 +250,21 @@ If
251.Fa nchecks 250.Fa nchecks
252== 251==
253.Dv BN_prime_checks , 252.Dv BN_prime_checks ,
254a number of iterations is used that yields a false positive rate of at 253a number of iterations is used that yields a false positive rate
255most 2^-80 for random input. 254of at most 2\(ha-64 for random input.
255The error rate depends on the size of the prime
256and goes down for bigger primes.
257The rate is 2\(ha-80 starting at 308 bits, 2\(ha-112 at 852 bits,
2582\(ha-128 at 1080 bits, 2\(ha-192 at 3747 bits
259and 2\(ha-256 at 6394 bits.
260.Pp
261When the source of the prime is not random or not trusted, the
262number of checks needs to be much higher to reach the same level
263of assurance: It should equal half of the targeted security level
264in bits (rounded up to the next integer if necessary).
265For instance, to reach the 128 bit security level,
266.Fa nchecks
267should be set to 64.
256.Pp 268.Pp
257If 269If
258.Fa cb 270.Fa cb