MODULI(5)

πŸ“¦ version 10.2p1, in epel 10, epel 9, fedora 43, fedora 44

✨ MODULI β€” bestie edition ✨

okay so this is the File Formats Manual page for MODULI(5), and it's literally about Diffie-Hellman moduli. yes really. stay with me, it's more fun than it sounds πŸ’…


🌸 NAME 🌸

moduli β€” Diffie-Hellman moduli. that's it, that's the name, short and iconic πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

the file /etc/gsissh/moduli is holding a whole collection of prime numbers and generators, and it exists so that sshd(8) can use them in the Diffie-Hellman Group Exchange key exchange method. it's giving backstage crew for your crypto, no cap πŸ”βœ¨

new moduli can be generated with ssh-keygen(1) and it's a two-step process, because of course it is:

  1. an initial candidate generation pass, using ssh-keygen -M generate, calculates numbers that are likely to be useful. lowkey just vibes-checking numbers at this stage.
  2. a second primality testing pass, using ssh-keygen -M screen, gives a high degree of assurance that the numbers are prime and are safe for use in Diffie-Hellman operations by sshd(8). this is the vibe check that actually matters fr fr.

and this moduli format? it's used as the output from each pass. both of them. periodt.

the file is made of newline-separated records, one per modulus, and each record has seven space-separated fields. seven! here's the whole lineup 🫢

  • timestamp β€” the time that the modulus was last processed, formatted as YYYYMMDDHHMMSS. it's a little timestamp receipt bestie.
  • type β€” a decimal number specifying the internal structure of the prime modulus. supported types are:
    • 0 β€” unknown, not tested.
    • 2 β€” "safe" prime; (p-1)/2 is also prime.
    • 4 β€” Sophie Germain; 2p+1 is also prime.

moduli candidates initially produced by ssh-keygen(1) are Sophie Germain primes (type 4). further primality testing with ssh-keygen(1) produces safe prime moduli (type 2) that are ready for use in sshd(8). other types are not used by OpenSSH, so don't come for them πŸ’€

  • tests β€” a decimal number indicating the type of primality tests that the number has been subjected to, represented as a bitmask of these values:
    • 0x00 β€” not tested.
    • 0x01 β€” composite number – not prime.
    • 0x02 β€” Sieve of Eratosthenes.
    • 0x04 β€” probabilistic Miller-Rabin primality tests.

the ssh-keygen(1) moduli candidate generation uses the Sieve of Eratosthenes (flag 0x02). subsequent ssh-keygen(1) primality tests are Miller-Rabin tests (flag 0x04). those are the two flags doing all the work, iykyk 🌈

  • trials β€” a decimal number indicating the number of primality trials that have been performed on the modulus.
  • size β€” a decimal number indicating the size of the prime in bits.
  • generator β€” the recommended generator for use with this modulus (hexadecimal).
  • modulus β€” the modulus itself in hexadecimal.

and here's the fun part, the actual ✨ plot ✨ β€” when performing Diffie-Hellman Group Exchange, sshd(8) first estimates the size of the modulus required to produce enough Diffie-Hellman output to sufficiently key the selected symmetric cipher. then sshd(8) randomly selects a modulus from /etc/gsissh/moduli that best meets the size requirement. so it's shopping in the moduli closet and picking the fit that matches πŸ”₯πŸ‘‘


πŸ‘‘ SEE ALSO πŸ‘‘

ssh-keygen(1), sshd(8)


⭐ STANDARDS ⭐

M. Friedl, N. Provos, and W. Simpson, Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer Protocol, RFC 4419, March 2006.


πŸ’– that's the whole page bestie, go forth and understand your moduli πŸ’–

Debian Β· April 16, 2022 Β· MODULI(5) β€” mwah, love u, see u in the group chat πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from