1.\" $OpenBSD: moduli.5,v 1.16 2011/11/28 08:46:27 eric Exp $ 2.\" 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. 16.\" 17.\" $FreeBSD$ 18.\" 19.Dd July 19, 2012 20.Dt MODULI 5 21.Os 22.Sh NAME 23.Nm moduli 24.Nd Diffie-Hellman moduli 25.Sh DESCRIPTION 26The 27.Pa /etc/ssh/moduli 28file contains prime numbers and generators for use by 29.Xr sshd 8 30in the Diffie-Hellman Group Exchange key exchange method. 31.Pp 32New moduli may be generated with 33.Xr ssh-keygen 1 34using a two-step process. 35An initial 36.Em candidate generation 37pass, using 38.Ic ssh-keygen -G , 39calculates numbers that are likely to be useful. 40A second 41.Em primality testing 42pass, using 43.Ic ssh-keygen -T , 44provides a high degree of assurance that the numbers are prime and are 45safe for use in Diffie-Hellman operations by 46.Xr sshd 8 . 47This 48.Nm 49format is used as the output from each pass. 50.Pp 51The file consists of newline-separated records, one per modulus, 52containing seven space-separated fields. 53These fields are as follows: 54.Bl -tag -width Description -offset indent 55.It timestamp 56The time that the modulus was last processed as YYYYMMDDHHMMSS. 57.It type 58Decimal number specifying the internal structure of the prime modulus. 59Supported types are: 60.Pp 61.Bl -tag -width 0x00 -compact 62.It 0 63Unknown, not tested. 64.It 2 65"Safe" prime; (p-1)/2 is also prime. 66.It 4 67Sophie Germain; 2p+1 is also prime. 68.El 69.Pp 70Moduli candidates initially produced by 71.Xr ssh-keygen 1 72are Sophie Germain primes (type 4). 73Further primality testing with 74.Xr ssh-keygen 1 75produces safe prime moduli (type 2) that are ready for use in 76.Xr sshd 8 . 77Other types are not used by OpenSSH. 78.It tests 79Decimal number indicating the type of primality tests that the number 80has been subjected to represented as a bitmask of the following values: 81.Pp 82.Bl -tag -width 0x00 -compact 83.It 0x00 84Not tested. 85.It 0x01 86Composite number \(en not prime. 87.It 0x02 88Sieve of Eratosthenes. 89.It 0x04 90Probabilistic Miller-Rabin primality tests. 91.El 92.Pp 93The 94.Xr ssh-keygen 1 95moduli candidate generation uses the Sieve of Eratosthenes (flag 0x02). 96Subsequent 97.Xr ssh-keygen 1 98primality tests are Miller-Rabin tests (flag 0x04). 99.It trials 100Decimal number indicating the number of primality trials 101that have been performed on the modulus. 102.It size 103Decimal number indicating the size of the prime in bits. 104.It generator 105The recommended generator for use with this modulus (hexadecimal). 106.It modulus 107The modulus itself in hexadecimal. 108.El 109.Pp 110When performing Diffie-Hellman Group Exchange, 111.Xr sshd 8 112first estimates the size of the modulus required to produce enough 113Diffie-Hellman output to sufficiently key the selected symmetric cipher. 114.Xr sshd 8 115then randomly selects a modulus from 116.Fa /etc/ssh/moduli 117that best meets the size requirement. 118.Sh SEE ALSO 119.Xr ssh-keygen 1 , 120.Xr sshd 8 121.Rs 122.%R RFC 4419 123.%T "Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer Protocol" 124.%D 2006 125.Re 126