A prime number is an integer greater than one divisible only by 1 and itself. The first examples are 2, 3, 5, 7, and 11. In Diffie-Hellman (DH), a large prime supplies the modulus for the multiplicative group of integers from 1 through p−1. section 5.2.1
The size and quality of p matter. DH security depends on the discrete logarithm problem, so larger parameters provide more security against known attacks. Cryptographic libraries may use probable primes to accelerate generation, but faulty prime generation has caused serious vulnerabilities, including ROCA in 2017. section 5.2.1 section 5.2.3
Practical DH parameter guidance includes:
- Use a sufficiently large prime; 2,048-bit p is identified as current best practice. section 5.2.3
- Prefer carefully specified groups such as those in RFC 7919 rather than ad hoc or blindly trusted parameters. section 5.2.3
- Remember that even standardized groups can be broken: historical DH parameters in Socat and RFC 5114 caused concern. section 5.2.3
A clock that wraps around
With modulus 5, arithmetic wraps around: 5 becomes 0, 6 becomes 1, 7 becomes 2, and 10 becomes 0. This illustrates the modular arithmetic used with a prime modulus in DH. section 5.2.1
Figure 5.5 The group of integers modulo the prime number 5 can be pictured as a clock that resets to 0 after the number 4. Thus 5 is represented as 0, 6 as 1, 7 as 2, 8 as 3, 9 as 4, 10 as 0, and so on.
Use the clock diagram to visualize how integers wrap around modulo the prime number 5. section 5.2.1




