Code
The cryptography of computers: hashes, AES and HMAC, RSA’s weak keys, Diffie–Hellman, certificates, one-time passwords, Shor and Grover, ML-KEM, BB84, Shamir’s shares, time locks, passwords.
RSA
Builds an RSA key step by step from two primes (n = pq, φ(n), d = e⁻¹ mod φ(n)) and encrypts as m^e mod n, without the padding of PKCS #1 (RFC 8017). The Attack tab breaks weak keys as Boneh's survey (1999) sets out: factoring, Wiener's small d, a shared prime, Håstad's broadcast, a common modulus, a message too small. Rivest, Shamir and Adleman published RSA in 1978.
Terms
History, how it works, how it was checked, limits
History
Rivest, Shamir and Adleman published RSA in 1978: a public exponent e and a modulus n = pq encrypt, and only the holder of p and q can compute the private exponent d. Real use pads a message (PKCS #1, RFC 8017). Boneh’s “Twenty Years of Attacks on the RSA Cryptosystem” (1999) gathered the ways weak keys fall.
How it works
Keys starts from two primes, 61 and 53 or a random pair, and shows n = pq, φ(n), e (typed, or the first of 65537, 257, 17, 7, 5 and 3 coprime to φ) and d = e⁻¹ mod φ(n) with the extended Euclidean algorithm’s divisions; it encrypts a number below n as m^e mod n, or a text a code point at a time. The Attack tab takes public values: Factor n tries trial division, Fermat’s method, Pollard’s p − 1 and rho in a worker; the others are Wiener’s convergents of e/n, the gcd of moduli in pairs, Håstad’s Chinese remainders, a common modulus and an exact root of c, each with a constructed example. Where Fermat’s method or rho split n, the result draws how: the square on a less the square on b laid out as (a − b)(a + b), or rho’s walk seen modulo the factor found, a tail into a loop.
How it was checked
The shared number theory is pinned: Miller–Rabin on 2^127 − 1 and 561, inverses, roots, Chinese remainders, continued fractions and each factoring method on a small case. p = 61, q = 53 and e = 17 give d = 2753, division by division. Wiener’s textbook example, n = 90,581 and e = 17,993, gives d = 5. Squares and three primes are factored completely; the other attacks succeed on keys built in the tests. Factoring’s two examples are tested: the close primes split at Fermat’s first try; the other resists the other methods, falls to rho and reads “Pollard”, its walk checked against a table of every term. The other examples have no test.
The tests hold 38 checks of this tool; 1 rests on outside material:
- A print’s own example Wiener: n 90581, e 17993 → d 5, p 239, q 379
Limits
Keys is textbook RSA without padding, on small primes; text mode is a simple substitution that frequency analysis breaks. With n = p², a multiple of p does not come back. The attacks break only weak keys; Wiener needs d below about n^¼ / 3. Only Fermat’s method and rho are drawn; the ρ is not to scale, and b’s square is enlarged where too small to see.
- R. L. Rivest, A. Shamir and L. Adleman, “A Method for Obtaining Digital Signatures and Public-Key Cryptosystems”, Communications of the ACM 21 (2), 1978, pp. 120–126
- RFC 8017, PKCS #1: RSA Cryptography Specifications Version 2.2 (2016)
- Dan Boneh, “Twenty Years of Attacks on the RSA Cryptosystem”, Notices of the AMS 46 (2), 1999, pp. 203–213