Turn time into a moving counter
01A prover is the authenticator that generates a code. A verifier is the server checking it. Both turn Unix time, measured in seconds, into the same integer time-step counter T. They do not exchange a timestamp for every calculation.
The HMAC message is00 00 00 00 00 00 00 01. It is not the text "1", not the secret, and not a network packet.
Source for this drawing: RFC 6238 · Read RFC section 4.2 ↗
New to this? Start hereA quick picture + helpful background
A message needs an address.
Think of a packet as a small addressed envelope. Devices pass it onward; transport protocols decide what delivery promises an application gets.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Terms in this drawing
- Unix time
- Seconds since the Unix epoch, independent of a displayed time zone.
- Moving factor
- The integer counter that changes with time rather than with button presses.
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.
T = floor((current Unix time − T0) / X). The prover and verifier MUST use the same time-step X and MUST know or derive current Unix time.
- T = floor((current Unix time − T0) / X). The prover and verifier MUST use the same time-step X and MUST know or derive current Unix time.
- X defaults to 30 seconds and T0 defaults to zero. These are system parameters agreed during provisioning; 30 seconds is not an unconditional MUST.
- At time 59 with T0=0 and X=30, T=1. At time 60, T=2. A code stays constant within a single time step; different counters can still produce a decimal-code collision.
- TOTP(K,T) = HOTP(K,T). Encode T as the eight-byte, high-order-byte-first HOTP counter, not as ASCII digits or a milliseconds timestamp.
- The implementation MUST support T larger than a 32-bit integer when beyond 2038. Do not truncate Unix time or counter arithmetic to a signed 32-bit value.
All arithmetic here uses public test values. Time59 is59 seconds after the Unix epoch, not a modern clock display. X and T0 are fixed before the example. The shared secret is not derived from time. RFC 4226 §5.2 supplies the eight-byte counter representation.
Read the RFC section ↗