Visual RFC.
ALL RFCs / RFC 6238
Read the RFC ↗
RFC 6238 / TIME-BASED ONE-TIME PASSWORDS

Turn time into a moving counter

01

A 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.

RFC 6238 · § 4.2EXAMPLE
3 / 3
Turn time into a moving counterUnix time 59 divided by the agreed30-second step floors to counter1; time 60 floors to counter2. The final state separately encodes counter1 as exactly eight big-endian bytes, ending in01. Time and counter are distinct from the secret key and the HMAC message is binary, not ASCII. Data-flow arrows indicate local computation, not a prover sending time to a server.Public time becomes a binary counterCounter T = 1eight-byte big-endian00 00 00 00 00 00 00 01Binary bytes · not ASCII "1"Support counter arithmetic beyond 32 bits
03
Encode counter 1 in big-endian bytes.

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 ↗

Protocol participantThreat or exceptionProtocol controlSimplified drawings · precise section references
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.

KEY POINT

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.
DETAILS

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 ↗

All chapters in RFC 6238

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 ↗