A one-time code replaces a long-term password during authentication. It is derived from a uniformly random symmetric key and additional data, then accepted only once or within a narrow validity period. Reusing it would defeat its purpose: exposure should not grant unlimited account access. section 11.2.3
Two common schemes differ in the extra value combined with the shared key:
- HOTP uses a counter, requiring client and server state to remain synchronized. section 11.2.3
- TOTP uses the current time and is widely used because it avoids maintaining a shared counter state. section 11.2.3
- Mobile authenticator applications and security keys commonly generate these codes. section 11.2.3
TOTP sign-in
During registration, a service shares a symmetric key with an authenticator application, often through a QR code. Later, the application generates a six-digit code; the service independently computes the expected value with HMAC and the current time, then compares the values in constant time. section 11.2.3


