Public-key login lab
See how logging in with a key works: make a toy RSA key pair, sign server challenges, watch replay attacks fail and crack keys that are too small.
How to use
- Make a key pair: type two primes p and q and a public exponent e, or press Pick primes. The lab shows the public key (n and e) and works out the private key d.
- Log in with it: Sign up sends only the public key to the server. Each Log in gets a new random challenge from the server; your device answers with challenged mod n, and the server checks that answere mod n gives the challenge back. The table lists everything that crossed the network.
- Try the two attacks: replaying a recorded answer fails because the next challenge is different, and a signature made with another key does not check out.
- Shared secret shows Diffie-Hellman: two people agree on a number that an eavesdropper who saw every message cannot work out.
- Break a small key factors n. Once n is split into p and q, the private key follows at once, which is why real keys are huge.
Keyboard and touch
| Enter | In a box: make the keys, exchange or factor |
| Tab | Move between the tabs, boxes and buttons |
Tips
- The classic textbook pair p = 61, q = 53, e = 17 gives n = 3233 and d = 2753. Encrypting 65 gives 2790, and decrypting 2790 gives 65 again.
- With a password, a copy of what you sent (or a stolen password list) lets someone in. With a key login the server holds nothing worth stealing and every answer works only once.
- Pick primes with 3 digits and attack the key: it falls in a moment. Twelve-digit primes take noticeably longer, and real keys use primes of about 300 digits.
- e must share no factor with (p - 1)(q - 1). If it does, the lab says so; 65537 is the usual choice.
About this tool
This is the idea behind SSH keys, security keys and passkeys: proof of a secret without sending it. The lab uses textbook RSA: n = p × q, d is the inverse of e modulo (p - 1)(q - 1), a signature is cd mod n and the check is se mod n. Primes are tested with the Miller-Rabin test using the first 13 primes as bases, which is exact for every number below 3.3 × 1024. Small keys are factored with Pollard's rho method.
Teaching sizes only. Real systems use keys of 2048 bits or more, hash and pad what they sign (for example RSA-PSS), and many use elliptic curves (ECDSA, Ed25519) instead of RSA; passkeys add origin checks so a fake site cannot use the answer. Never protect anything with keys from this page. Everything runs in your browser and nothing is sent anywhere.