blob: ef0de08506b17cc339904ad951d747435e6cb081 [file] [log] [blame]
Damien Miller0120c412012-11-07 08:36:00 +11001.\" $OpenBSD: moduli.5,v 1.17 2012/09/26 17:34:38 jmc Exp $
Damien Miller60dcc622008-06-26 15:59:32 +10002.\"
3.\" Copyright (c) 2008 Damien Miller <djm@mindrot.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Damien Miller0120c412012-11-07 08:36:00 +110016.Dd $Mdocdate: September 26 2012 $
Damien Miller60dcc622008-06-26 15:59:32 +100017.Dt MODULI 5
18.Os
19.Sh NAME
20.Nm moduli
Darren Tuckerf2794742011-08-07 23:10:11 +100021.Nd Diffie-Hellman moduli
Damien Miller60dcc622008-06-26 15:59:32 +100022.Sh DESCRIPTION
23The
24.Pa /etc/moduli
Darren Tucker578451d2011-08-07 23:09:20 +100025file contains prime numbers and generators for use by
Damien Miller60dcc622008-06-26 15:59:32 +100026.Xr sshd 8
27in the Diffie-Hellman Group Exchange key exchange method.
28.Pp
29New moduli may be generated with
30.Xr ssh-keygen 1
31using a two-step process.
32An initial
33.Em candidate generation
Darren Tucker578451d2011-08-07 23:09:20 +100034pass, using
Damien Miller60dcc622008-06-26 15:59:32 +100035.Ic ssh-keygen -G ,
36calculates numbers that are likely to be useful.
37A second
38.Em primality testing
39pass, using
Darren Tucker578451d2011-08-07 23:09:20 +100040.Ic ssh-keygen -T ,
Damien Miller60dcc622008-06-26 15:59:32 +100041provides a high degree of assurance that the numbers are prime and are
Darren Tuckerf2794742011-08-07 23:10:11 +100042safe for use in Diffie-Hellman operations by
Damien Miller60dcc622008-06-26 15:59:32 +100043.Xr sshd 8 .
44This
45.Nm
46format is used as the output from each pass.
47.Pp
48The file consists of newline-separated records, one per modulus,
Darren Tucker578451d2011-08-07 23:09:20 +100049containing seven space-separated fields.
Damien Miller60dcc622008-06-26 15:59:32 +100050These fields are as follows:
Damien Miller60dcc622008-06-26 15:59:32 +100051.Bl -tag -width Description -offset indent
52.It timestamp
53The time that the modulus was last processed as YYYYMMDDHHMMSS.
54.It type
55Decimal number specifying the internal structure of the prime modulus.
56Supported types are:
57.Pp
58.Bl -tag -width 0x00 -compact
59.It 0
Darren Tucker578451d2011-08-07 23:09:20 +100060Unknown, not tested.
Damien Miller60dcc622008-06-26 15:59:32 +100061.It 2
62"Safe" prime; (p-1)/2 is also prime.
63.It 4
Damien Millerd5c3d4c2012-11-07 08:35:38 +110064Sophie Germain; 2p+1 is also prime.
Damien Miller60dcc622008-06-26 15:59:32 +100065.El
66.Pp
67Moduli candidates initially produced by
68.Xr ssh-keygen 1
69are Sophie Germain primes (type 4).
Darren Tucker578451d2011-08-07 23:09:20 +100070Further primality testing with
Damien Miller60dcc622008-06-26 15:59:32 +100071.Xr ssh-keygen 1
72produces safe prime moduli (type 2) that are ready for use in
73.Xr sshd 8 .
74Other types are not used by OpenSSH.
75.It tests
76Decimal number indicating the type of primality tests that the number
77has been subjected to represented as a bitmask of the following values:
78.Pp
79.Bl -tag -width 0x00 -compact
80.It 0x00
Darren Tucker578451d2011-08-07 23:09:20 +100081Not tested.
Damien Miller60dcc622008-06-26 15:59:32 +100082.It 0x01
Darren Tucker578451d2011-08-07 23:09:20 +100083Composite number \(en not prime.
Damien Miller60dcc622008-06-26 15:59:32 +100084.It 0x02
Darren Tucker578451d2011-08-07 23:09:20 +100085Sieve of Eratosthenes.
Damien Miller60dcc622008-06-26 15:59:32 +100086.It 0x04
Darren Tucker91e6b572011-08-07 23:10:56 +100087Probabilistic Miller-Rabin primality tests.
Damien Miller60dcc622008-06-26 15:59:32 +100088.El
89.Pp
90The
91.Xr ssh-keygen 1
92moduli candidate generation uses the Sieve of Eratosthenes (flag 0x02).
93Subsequent
94.Xr ssh-keygen 1
95primality tests are Miller-Rabin tests (flag 0x04).
96.It trials
Darren Tucker578451d2011-08-07 23:09:20 +100097Decimal number indicating the number of primality trials
98that have been performed on the modulus.
Damien Miller60dcc622008-06-26 15:59:32 +100099.It size
100Decimal number indicating the size of the prime in bits.
101.It generator
102The recommended generator for use with this modulus (hexadecimal).
103.It modulus
104The modulus itself in hexadecimal.
105.El
106.Pp
Darren Tuckerf2794742011-08-07 23:10:11 +1000107When performing Diffie-Hellman Group Exchange,
Damien Miller60dcc622008-06-26 15:59:32 +1000108.Xr sshd 8
109first estimates the size of the modulus required to produce enough
Darren Tuckerf2794742011-08-07 23:10:11 +1000110Diffie-Hellman output to sufficiently key the selected symmetric cipher.
Damien Miller60dcc622008-06-26 15:59:32 +1000111.Xr sshd 8
112then randomly selects a modulus from
113.Fa /etc/moduli
114that best meets the size requirement.
Damien Miller60dcc622008-06-26 15:59:32 +1000115.Sh SEE ALSO
116.Xr ssh-keygen 1 ,
Darren Tucker578451d2011-08-07 23:09:20 +1000117.Xr sshd 8
Damien Miller0120c412012-11-07 08:36:00 +1100118.Sh STANDARDS
Damien Miller60dcc622008-06-26 15:59:32 +1000119.Rs
Damien Miller0120c412012-11-07 08:36:00 +1100120.%A M. Friedl
121.%A N. Provos
122.%A W. Simpson
123.%D March 2006
Damien Miller60dcc622008-06-26 15:59:32 +1000124.%R RFC 4419
Damien Miller0120c412012-11-07 08:36:00 +1100125.%T Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer Protocol
Damien Miller60dcc622008-06-26 15:59:32 +1000126.%D 2006
127.Re