Summary
- RFC 6238, May 2011, extends the counter-based HOTP algorithm “to support the time-based moving factor”: the one-time value is computed from a shared secret and the current time step.
- The parameters are almost insultingly simple — a 30-second step by default, a start time of zero, and a truncated MAC rendered as a short code a human can type.
- The interesting part is §6. Because clocks drift, the validator is told to accept a limited number of steps, and the document does the arithmetic out loud: accepting two steps back means a maximum drift of 89 seconds.
State moved out of the server
HOTP kept a counter per user, incremented on every login and held in lockstep with the token. That is server state — the thing every authentication system spends its life trying to shed, because state is what you have to store, back up, replicate, migrate, and apologise for after a failover.
TOTP replaces the counter with the clock. Both sides can now compute the same value without ever talking. The bill arrives as a new dependency: agreement about what time it is.
The code is a truncation, not an encryption
The one-time value is a MAC over the time step, chopped down to six or eight digits so a human can retype it from a phone screen. Six digits is not a security level; it is a typing convenience. Which means collisions are not a bug but the design: roughly one code in a million is right by accident.
The document knows this. The defence it builds is not a longer code — it is a smaller number of guesses. Rate limiting, not entropy, is what keeps the second factor standing.
The window is the real parameter
Every time step you accept is another moment in which the correct code is knowable. Widen the window and you buy tolerance for cheap crystals and bad timezone handling; you pay for it in replay surface. There is no free setting, only a trade with a number attached.
What makes §6 worth reading today is that the document does the arithmetic in public instead of pretending the problem belongs to somebody else. Two steps back, 89 seconds of maximum drift, three time steps checked per attempt: a security parameter wearing a user-friendliness costume.
What the specification leaves out
Provisioning the shared secret. Rate limiting. Whether a code may be reused inside its own step. How to resynchronise a token that has drifted. All of it is left to profiles, vendors, and whatever the product team decided on a Tuesday.
The algorithm is the smallest part of the system. Everything that makes a second factor actually work lives in documents this one does not contain — which is why two products that both “do TOTP” behave nothing alike the moment a user’s phone is eleven minutes fast.
The restraint is deliberate, and it is the right call: fix only what both sides must agree on in order to compute the same number, and leave everything that depends on local context to whoever has to run it. The same discipline is what keeps any coordination layer thin enough to survive.
Why it won anyway
TOTP needs no server-side counter, no round trip beyond the login itself, no radio in the token, and no vendor’s permission. A shared secret and a clock is the cheapest second factor that can be welded into anything with a display.
That cheapness is why it is everywhere — and why the window is now a policy decision made by a thousand products, each of which chose it for reasons nobody wrote down, rather than a parameter settled once by a specification.
The lesson about removing state
Delete a piece of state from a protocol and it does not vanish. It reappears as an assumption somewhere else. An assumption that can drift needs a tolerance. A tolerance is a hole, and the only question is whether you chose it on purpose.
Which is the whole of RFC 6238 in one line: when you replace state with context, name the context you are trusting, bound the disagreement, and write the bound down. The bound is the security. Everything else is six digits.
Member Briefing
Read the full trend briefing
Members read the full briefing with the source notes behind every finding.
Strategic Circle
A daily briefing in your language, built from changes we have verified.
Join for USD 20/monthCancel anytime.
Members also get the full research library, a daily briefing on the networks they follow and the private forum.






