How passwords are stored: salt and many rounds
A well-built site does not keep your password itself. My reading: it keeps a value derived from the password, mixed with a random salt and run through many rounds of work.
The short version
RFC 8018 defines PBKDF2. It takes a password, a salt and an iteration count, and produces a derived key. The salt is extra data mixed in; it may be random and should be at least eight octets (64 bits). The iteration count c is how many rounds the work repeats, and the RFC says it raises the security strength of a password by log2(c) bits, so each guess costs more.
Step by step
- Pick a random salt, at least eight octets long.
- Feed the password, the salt and the iteration count c into PBKDF2.
- Get back a derived key of the length you asked for.
- Store that value, not the password (my reading; the RFC does not say this).
- At login the site usually repeats the derivation with the stored salt and compares the results (common practice, not in the RFC).
Why it matters
The RFC says the salt makes a large set of keys possible for one password. My reading: two accounts with the same password need not end up with the same stored value. Pick the iteration count from current guidance, not from this post.
Sources
- RFC 8018: PKCS #5 Password-Based Cryptography Specification v2.1 — PBKDF2 inputs (5.2), salt purpose, random salt and the eight-octet minimum (4.1), iteration count adds log2(c) bits (4.2)