Visual RFC.
ALL RFCs / RFC 4226
Read the RFC ↗
RFC 4226 / Counter-based one-time passwords

Keep token and server counters distinct

01

A token makes a new code after a button press. The server calculates its own expected value using its copy of the secret and counter.

RFC 4226 · § 7.2EXAMPLE
4 / 4
Keep token and server counters distinctToken last-generated counter 1; server next-expected counter 2. Successful match consumes1; next expected2 while token last-generated remains1. No claim of complete login.A press advances the token; a match advances the serverHOTP tokenValidatorLast generated: 1Next expected: 2Same K, stored separatelyMatched counter 1 consumedServer next 2 · token last 1Other factor and permission still separateAppendix D public test key · no real login
04
Consume the matched counter

The server advances beyond the accepted counter. This is the OTP validation outcome; other factors and application authorization remain separate.

Source for this drawing: RFC 4226 · Read RFC section 7.2 ↗

Protocol participantThreat or exceptionProtocol controlSimplified drawings · precise section references
New to this? Start hereA quick picture + helpful background

A seal answers a specific question.

A certificate or signature supports particular checks about a key or message. It does not automatically prove that every claim or sender is trustworthy.

Helpful first, if these ideas are unfamiliar

These pictures are analogies to help you learn. The linked RFC explains the actual rules.

Related RFCs and changes

“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.

KEY POINT

Validation compares independently calculated values; it does not ask the token for the answer.

  • HOTP means HMAC-Based One-Time Password. HMAC is a keyed message authentication code: a calculation that combines a secret key with input bytes. Here the changing input is an increasing counter, not a clock. The token and validation server share a unique secret K for that token (§§4–5.2).
  • The moving factor C is an eight-byte counter that MUST be synchronized. A new code request increments the token counter before calculating the next value (§7.2, verified editorial erratum 5723). The server increments only after successful authentication (§7.4).
  • Explicit example convention: the token last generated counter 0; the server next expects counter 1. A press advances the token to 1 and displays287082 from Appendix D. The server computes HOTP(K,1) itself and compares the received digits. Verified technical erratum 4994 corrects §7.2 to say calculated by the server.
  • On success at counter 1, the server next expects2; the token last generated remains1 until another request. The same consumed counter is no longer eligible. Six-digit outputs can collide at different counters: this is counter consumption, not a promise that the displayed number can never recur.
  • Counters and codes are examples, not enrollment defaults. The public ASCII secret in Appendix D is test data and MUST NOT be used as a real secret. Protocol P MUST support two-factor authentication; possession of a code alone is not the whole login (§7.1).
DETAILS

Offline public test values and selected rules; not a login service, secure token implementation or deployment recommendation.

Read the RFC section ↗

All chapters in RFC 4226

Drawing view

Scroll the drawing to see every part. Playback controls stay above it.

RFC 9700 / CHAPTERS

Chapters

For full details, tables, algorithms, and exceptions, read the original RFC.

RFC status and corrections ↗