Internet-Draft TOTP Offline Time and Viewed Records November 2026
Rigopoulos Expires 3 June 2027 [Page]
Workgroup:
Independent Submission
Internet-Draft:
draft-rigopoulos-totp-offline-audit-00
Updates:
6238 (if approved)
Published:
Intended Status:
Experimental
Expires:
Author:
E. A. Rigopoulos
YPS Services LLC

TOTP with an Offline Time Source and a Prover-Side Viewed Record

Abstract

This document updates RFC 6238. It specifies two optional, backwards-compatible mechanisms for the Time-Based One-Time Password (TOTP) algorithm. It specifies an Offline Time Source profile in which the prover derives Unix time from a local clock that has no network dependency, together with a declared maximum drift rate and a method for measuring that rate against a trusted reference. It also specifies an append-only viewed record written on the prover when a TOTP value is displayed or copied, and optional verifier behaviour that uses that record to reject or flag an OTP accepted at a time-step the device never recorded as viewed. The TOTP value itself is computed exactly as in RFC 6238. A viewed record detects unviewed or wrong-step OTPs; it does not prevent acceptance unless the verifier checks the record. This document is Experimental.

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on 3 June 2027.

▲

Table of Contents

1. Introduction

This document specifies an update to [RFC6238], which defines TOTP as an extension of the HMAC-based One-Time Password (HOTP) algorithm in [RFC4226]. The moving factor in RFC 6238 is a time-step counter

T = floor((Current Unix time - T0) / X)

with a default time-step size X of 30 seconds and a default origin T0 of 0 (the Unix epoch). Requirement R1 in Section 3 of [RFC6238] says the prover and the verifier MUST know or be able to derive the current Unix time. It does not say how that time is obtained, and it does not require or forbid a network time source.

Section 5.2 of [RFC6238] observes that a validation system does not know the client's exact timestamp when an OTP was generated. It says a verifier SHOULD set a policy for an acceptable delay window, RECOMMENDS that at most one time-step is allowed as the network delay, and requires that, after a successful validation, the verifier MUST NOT accept the same OTP again. Section 6 RECOMMENDS a limit on clock drift and a resynchronisation procedure. Neither section specifies a clock implementation, and neither defines a record on the prover of when a code was displayed or copied.

In common deployment a verifier accepts the previous, current, and next step (a "+/- 1" window). Under that policy, three different codes can be valid at once and a given code remains acceptable for 90 seconds. The one-time-use rule in Section 5.2 applies only at that verifier and only after it has already accepted that OTP. It does not block a different adjacent-step code, and it cannot show whether a code in the window was ever viewed on the device.

This document specifies the following additions to [RFC6238]:

The TOTP calculation is unchanged. Provers and verifiers that implement only [RFC6238] remain interoperable with implementations of this document. This document is Experimental because the time-source profile, the record format, and the optional verifier check need implementation and operational experience, including privacy and deployment practice, before any later revision is considered.

2. Conventions and Definitions

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

3. Terminology

Prover
The token or application that computes a TOTP value, as in [RFC6238].
Verifier
The validation system that accepts or rejects a TOTP value.
Time-step T
The integer moving factor defined in Section 4.2 of [RFC6238].
D_max
The maximum allowed fractional frequency error of a local clock, in parts per million (ppm), declared by an implementation of the Offline Time Source profile.
Viewed record
An append-only entry written by the prover when a TOTP value for a given T is displayed or copied to the user.
Audit mode
Optional verifier behaviour that accepts TOTP values as in [RFC6238] and later compares them with viewed records, flagging mismatches.
Enforce mode
Optional verifier behaviour that, at validation time, requires a viewed record for the accepted time-step and rejects the OTP if no such record is provided.

4. Offline Time Source

An implementation that claims the Offline Time Source profile defined here MUST derive the "Current Unix time" used in Section 4.2 of [RFC6238] from a local clock, with no network protocol required to compute T or the TOTP value. The profile does not change X, T0, the hash function, the digit count, or the truncation of [RFC6238].

This document does not specify a particular clock part or product. Any local real-time clock, including a temperature-compensated crystal oscillator or a similar time source, may be used if it meets the declared D_max and the measurement method in Section 4.3.

4.1. Maximum Drift Rate

An implementation of this profile MUST declare a maximum drift rate D_max in ppm. D_max is a bound on the absolute fractional frequency error of the local clock relative to a trusted reference after the clock has been set. Under a constant-rate model, the time in days for the accumulated offset to reach a threshold of S seconds is

t_days = S / (|D_max| * 10^-6) / 86400

Implementations SHOULD NOT declare a D_max greater than 20 ppm. A tighter class (for example 2 ppm) MAY be declared if the measurement method supports it. The values 2 ppm and 20 ppm are model classes for illustration and default policy; they are not measurements of any particular device.

At 20 ppm, the model reaches a 15-second offset in 8.681 days and a 30-second offset (one default time-step) in 17.361 days. At 2 ppm those intervals are 86.806 days and 173.611 days. Any nonzero offset of at most one time-step already requires a verifier window of +/- 1 if the prover's current code is to be accepted at every phase of the step. The moment the offset exceeds X seconds, a window of +/- 2 is required. Implementations SHOULD set or compare the local clock against a trusted reference often enough that the expected offset remains at most one time-step, given the declared D_max.

4.2. Setting and Resynchronisation

When the local clock is first set, and whenever the measured offset exceeds a configured threshold, the clock MUST be set from a trusted reference. That threshold SHOULD be no greater than one time-step X. The trusted reference MAY be a network time protocol, a satellite time source, or another local reference of known quality. Use of a network protocol to set the clock does not remove the requirement that ordinary TOTP generation under this profile proceed without a network dependency.

If the accumulated offset is larger than the verifier's accepted window, automatic resynchronisation as described in Section 6 of [RFC6238] may not be sufficient. In that case an additional authentication measure SHOULD be used before the clock is set, as already recommended in that section.

4.3. Measurement Method

An implementation that claims a D_max MUST be able to demonstrate it by the following method, or by a method of equal or greater rigour.

  1. Set the local clock from a trusted reference and record the device Unix time and the reference Unix time.
  2. Once per day, for at least 14 consecutive days (28 days is RECOMMENDED), record both Unix times again. The reference SHOULD be NTP or a satellite time source.
  3. Compute the daily offset (device seconds minus reference seconds), the maximum absolute offset, and a least-squares estimate of rate in ppm over the interval.
  4. The claim holds if the estimated rate and the projected offset remain within D_max and within one time-step over the intended service interval.

This method is a laboratory or operational check of a clock class. It is not a substitute for a published measurement of a specific shipped device.

5. The Viewed Record

When a TOTP value is displayed or copied, a prover that implements viewed records MUST append a record for the corresponding time-step T. Records MUST be append-only: an implementation MUST NOT alter or delete an earlier record except as part of a documented, integrity-preserving rotation or expiry policy. The plaintext OTP MUST NOT be stored in the record; a truncated keyed digest is stored instead.

5.1. Record Fields

Each record contains at least the following fields:

v
Format version. This document defines version 1.
seq
A monotonic sequence number. The first record on a prover MUST use seq = 1. Each later record MUST use a seq greater than all earlier records on that prover.
T
The time-step counter of the viewed TOTP value, as in [RFC6238].
viewed
The local time of the view, as an RFC 3339 UTC timestamp with a "Z" suffix and second precision (for example, 1970-01-01T00:00:59Z).
digits
The TOTP digit count (typically 6 or 8).
alg
The TOTP hash algorithm: "SHA1", "SHA256", or "SHA512".
digest
Lowercase hexadecimal encoding of the leftmost 8 octets of the viewed-code MAC defined below.
mac
RECOMMENDED when a record is exported or sent to a verifier. Lowercase hexadecimal encoding of the leftmost 16 octets of the covering MAC defined below.

The viewed-code digest is:

HMAC-SHA-256(K,
    "TOTP-VIEWED" || 0x00 || uint64be(T) || ASCII(code))

where K is the shared TOTP secret, uint64be(T) is T as an 8-octet big-endian unsigned integer, and ASCII(code) is the exact decimal digit string of the viewed OTP, including leading zeros. The ASCII label is the 11-octet string %x54.4F.54.50.2D.56.49.45.57.45.44.

The covering MAC, when present, is:

HMAC-SHA-256(K,
    "TOTP-VIEWED-MAC" || 0x00 || uint64be(seq) ||
    uint64be(T) || ASCII(viewed) || uint8(digits) ||
    ASCII(alg) || digest_octets)

The ASCII label is the 15-octet string %x54.4F.54.50.2D.56.49.45.57.45.44.2D.4D.41.43. digest_octets is the 8-octet value encoded by the digest field, not its hexadecimal representation. The mac field MUST NOT be included in its own input.

An optional account or issuer label MAY be stored locally; implementations that export records SHOULD consider the privacy implications in Section 12.

5.2. JSON Representation

A log MAY be represented as a JSON [RFC8259] array of objects. The following example is the first Appendix B test time (Unix time 59) with the 8-digit SHA-1 TOTP of [RFC6238]:

{
  "v": 1,
  "seq": 1,
  "T": 1,
  "viewed": "1970-01-01T00:00:59Z",
  "digits": 8,
  "alg": "SHA1",
  "digest": "6cd61375889ffa0b",
  "mac": "44e256b21a8a649325bc0e411e049f45"
}

5.3. CBOR Representation

The same record MAY be represented in CBOR [RFC8949]. In diagnostic notation:

{
  "v": 1,
  "seq": 1,
  "T": 1,
  "viewed": "1970-01-01T00:00:59Z",
  "digits": 8,
  "alg": "SHA1",
  "digest": h'6CD61375889FFA0B',
  "mac":    h'44E256B21A8A649325BC0E411E049F45'
}

Interoperable exchange SHOULD use the JSON representation unless both sides have agreed to CBOR. This document does not register a media type (see Section 13).

6. Verifier Check

Support for viewed records on the verifier is OPTIONAL. A verifier that does not implement this section MUST continue to validate TOTP values as specified in [RFC6238]. When this section is implemented, two modes are defined.

6.1. Audit Mode

In audit mode the verifier validates the OTP as in [RFC6238], including the Section 5.2 rule that the same OTP MUST NOT be accepted a second time after success. Independently, it obtains viewed records (at the time of validation, or later) and MUST flag an accepted OTP whose accepted time-step has no matching viewed record on the prover, or whose accepted time-step differs from the step or steps recorded as viewed for that authentication attempt.

Audit mode detects unviewed or wrong-step acceptances after the fact. It does not, by itself, prevent acceptance.

6.2. Enforce Mode

In enforce mode the verifier, at validation time, additionally requires one or more viewed records covering the accepted time-step. If it accepts an OTP at step S (including a match in a delay or resynchronisation window), and no viewed record with T = S is presented and authenticated, it MUST reject the OTP.

Under a common +/- 1 window, a user who viewed only step T can still submit the current-step code. Codes for T-1 and T+1, which would otherwise be acceptable as different OTPs, are rejected unless they too were recorded as viewed. This narrows the effective window for unviewed neighbour steps without changing how the TOTP value is computed. It does not detect a copy of a code that was recorded as viewed (for example a shoulder-surf of the displayed OTP).

6.3. Obtaining Records

How records are carried to the verifier is out of scope of the TOTP calculation. An implementation MAY send records together with the OTP, export them later for audit, or compare them on a local management path. When records are sent, the mac field SHOULD be present, and the verifier MUST recompute the digest and the mac using the shared secret before relying on the record. A record with an invalid mac MUST be ignored for enforcement and MUST be flagged in audit mode.

7. Interoperability with RFC 6238

For the same secret K, origin T0, time-step X, hash algorithm, digit count, and Unix time, an implementation of this document MUST produce the same TOTP value as [RFC6238]. The Offline Time Source profile and the viewed record do not alter that value.

A prover that implements this document can be validated by a verifier that implements only [RFC6238]. A verifier that implements this document can validate a prover that implements only [RFC6238], provided it does not require enforce mode. Enforce mode is therefore an explicit, mutually agreed policy, not a silent change to TOTP.

8. Test Vectors

The following vectors use the Appendix B test token of [RFC6238]: the ASCII shared secret "12345678901234567890", X = 30, T0 = 0, and HMAC-SHA-1. The 8-digit TOTP values MUST match Table 1 of that RFC. The 6-digit values are the same truncated integer reduced modulo 10^6, included because six-digit codes are widely deployed. The digest and mac fields were generated offline from the constructions in Section 5.1. The "viewed" timestamp is the UTC instant equal to the listed Unix time, as if the code were viewed at the moment it was generated. Sequence numbers run from 1 to 6 in table order.

Table 1 lists the TOTP values. Table 2 lists the viewed records for the 8-digit codes. Table 3 lists the digest and mac for the corresponding 6-digit codes, using the same seq, T, and viewed timestamp, with digits = 6.

Table 1: TOTP values for the Appendix B times (HMAC-SHA-1)
Unix time UTC T (hex) TOTP (8) TOTP (6)
59 1970-01-01T00:00:59Z 0000000000000001 94287082 287082
1111111109 2005-03-18T01:58:29Z 00000000023523EC 07081804 081804
1111111111 2005-03-18T01:58:31Z 00000000023523ED 14050471 050471
1234567890 2009-02-13T23:31:30Z 000000000273EF07 89005924 005924
2000000000 2033-05-18T03:33:20Z 0000000003F940AA 69279037 279037
20000000000 2603-10-11T11:33:20Z 0000000027BC86AA 65353130 353130
Table 2: Viewed records for the 8-digit codes (alg = SHA1, digits = 8)
seq T digest mac
1 1 6cd61375889ffa0b 44e256b21a8a649325bc0e411e049f45
2 37037036 edbcdf5108fb06f7 260c2e3d63510828b3714e034c9d383a
3 37037037 473efb3fb6e79bec c1ddec49506f8e556386f0cff4d7ba46
4 41152263 7da5aebe378d6144 dc673ac6fc03c3ceee2058b029a6a2c5
5 66666666 b20352a510905140 e3c595af1a3906af6511edbdf0574fde
6 666666666 ecbac0e7cbf5f3ec e19efccee63a8278db61ff4c08b7570c
Table 3: Digest and mac for the 6-digit codes (alg = SHA1, digits = 6)
seq T digest mac
1 1 40fdf812c2d8d342 100b1728be424e2f42a8005fff2b3035
2 37037036 e85015ba83d941d4 459e24a8f390cd8352482e4c1ea395f6
3 37037037 49631a5028eda401 7335e0efb752ac3c6caf9ecbb52c864a
4 41152263 37577bdb0a361084 194204acbbcb0ef8b4b3add75b1a9e68
5 66666666 14be20c848413dc4 4dcffc240108b425f856c794dd11d9d6
6 666666666 a88648e1600b3dce 4b636bbe283295ded27b896100e1ec59

9. Measured Results

The figures in this section come from a reproducible model and simulation run offline (networking disabled) on 30 November 2026, with seed 20261130 and 200000 Monte Carlo trials. They are labelled as exact arithmetic, a constant-rate clock model, or a simulation with stated assumptions. They are not measurements of a particular product or of a carrier network. The run also confirmed that all six SHA-1 8-digit Appendix B test values of [RFC6238] matched.

Exact acceptance-window arithmetic, with X = 30 seconds:

Constant-rate isolated clock model (exact), time to a 15-second and 30-second offset:

Relative drift between an offline issuer or verifier and an offline device is |r_device - r_verifier| ppm. An NTP-synced server is modelled as 0 ppm against true time. If both offline clocks drift at 2 ppm in the same direction, the relative rate is 0 and they do not force a wider window. If they drift at 2 ppm in opposite directions, the relative rate is 4 ppm and they reach a 15-second offset in 43.403 days, which is sooner than a 2 ppm device against an NTP-synced server (86.806 days). An offline issuer is therefore more accurate only when the two clocks are closely matched.

A network-sync simulation assumed a daily healthy residual of Normal(0, 0.020 s) and, independently, bad jumps as a Poisson process with a mean of 2 events per year, each Uniform(15, 90) seconds in magnitude and random in sign, over 2000 traces of 50 years. No healthy-only trace exceeded 15 seconds. With jumps, the median time to the first offset of 15 seconds or more was 121 days (mean 177.81; analytic mean wait for the first jump is 182.62 days). These assumptions are not measured carrier data.

Replay simulations used a +/- 1 window and the following delay assumptions, which are not measured user behaviour: the view falls uniformly in the current step; the typist submits after Uniform(2, 12) s; a fast attacker submits after Uniform(0.5, 5) s; a slower attacker after Uniform(5, 25) s.

The measurable improvement is therefore detection of unviewed or wrong-step OTPs, and prevention only when the verifier implements enforce mode. The record does not, by itself, prevent acceptance, and it does not identify a copy of a code that was viewed.

10. Implementation Status

This section is to be removed before publishing as an RFC.

This section records the status of known implementations of the mechanism defined in this document at the time of posting, following [RFC7942]. It is to be removed before publication as an RFC.

Organization:
YPS Services LLC
Implementation:
Last Viewed, security software. A public RFC 6238 test panel that computes codes locally without a network is available at https://lastviewed.ypsservices.com/.
Coverage:
RFC 6238 code generation with the Appendix B test key. The viewed record defined in this document is in development.
Licensing:
Proprietary.
Contact:
ea.rigopoulos@ypsservices.com

Last Viewed is a trademark of YPS Services LLC.

11. Security Considerations

The security of the TOTP value remains that of [RFC6238] and [RFC4226]. This section considers only the additions in this document.

The viewed record detects; it does not prevent, unless the verifier implements enforce mode and actually receives an authentic record at validation time. Audit mode is a retrospective control. A deployment that only stores records on the prover, and never compares them, does not change the attack surface of [RFC6238].

A shoulder-surf or other copy of an OTP that the prover did record as viewed is not distinguishable, from the record alone, from the user's own use of that OTP. The Section 5.2 rule in [RFC6238] remains the control that stops the same OTP being accepted twice at that verifier after a first success.

Record tampering: an attacker who can append or alter records without K cannot forge a valid digest or mac. An attacker who has K can forge records and TOTP values; protection of K is therefore essential and is out of scope of this document, as it is of [RFC6238]. Implementations SHOULD treat a record with a missing or invalid mac as unauthenticated. Sequence numbers detect gaps but do not, by themselves, prove that a missing view did not occur on a different device that shares K.

Clock tampering: an attacker who can set the prover's local clock can shift T and the viewed timestamp. The Offline Time Source profile reduces dependence on a network time protocol and on sudden network time jumps, but it does not prevent physical or software attacks on the local clock. Setting the clock SHOULD require an additional authentication measure when the offset is large, as in Section 6 of [RFC6238]. Verifiers SHOULD NOT widen the acceptance window beyond what Section 5.2 of [RFC6238] recommends without understanding the added exposure (more simultaneously valid codes and a longer acceptance period for each code).

Shared-secret storage, provisioning, and the design of any particular hardware token are out of scope. Keys SHOULD still be generated and protected as recommended in [RFC6238].

12. Privacy Considerations

A viewed record is a log of authentication activity: it shows that a particular account's OTP was displayed or copied at a particular local time. Implementations SHOULD keep records on the prover by default, export them only with user or administrator action, and retain them only as long as needed for the agreed audit or enforce policy. Account labels and other identifiers SHOULD be omitted from exported records unless required. Verifiers that receive records SHOULD apply the same retention limits as for other authentication logs. See also [RFC6973].

13. IANA Considerations

This document has no IANA actions.

14. References

14.1. Normative References

[RFC2119]
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/info/rfc2119>.
[RFC4226]
M'Raihi, D., Bellare, M., Hoornaert, F., Naccache, D., and O. Ranen, "HOTP: An HMAC-Based One-Time Password Algorithm", RFC 4226, DOI 10.17487/RFC4226, , <https://www.rfc-editor.org/info/rfc4226>.
[RFC6238]
M'Raihi, D., Machani, S., Pei, M., and J. Rydell, "TOTP: Time-Based One-Time Password Algorithm", RFC 6238, DOI 10.17487/RFC6238, , <https://www.rfc-editor.org/info/rfc6238>.
[RFC8174]
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, , <https://www.rfc-editor.org/info/rfc8174>.

14.2. Informative References

[RFC6973]
Cooper, A., Tschofenig, H., Aboba, B., Peterson, J., Morris, J., Hansen, M., and R. Smith, "Privacy Considerations for Internet Protocols", RFC 6973, DOI 10.17487/RFC6973, , <https://www.rfc-editor.org/info/rfc6973>.
[RFC7942]
Sheffer, Y. and A. Farrel, "Improving Awareness of Running Code: The Implementation Status Section", BCP 205, RFC 7942, DOI 10.17487/RFC7942, , <https://www.rfc-editor.org/info/rfc7942>.
[RFC8259]
Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, , <https://www.rfc-editor.org/info/rfc8259>.
[RFC8949]
Bormann, C. and P. Hoffman, "Concise Binary Object Representation (CBOR)", STD 94, RFC 8949, DOI 10.17487/RFC8949, , <https://www.rfc-editor.org/info/rfc8949>.

Acknowledgements

This document builds on [RFC6238] by D. M'Raihi, S. Machani, M. Pei, and J. Rydell, and on [RFC4226] by D. M'Raihi, M. Bellare, F. Hoornaert, D. Naccache, and O. Ranen. Errors of interpretation remain the author's.

Author's Address

E. A. Rigopoulos
YPS Services LLC