<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt"?>
<!--
  Internet-Draft: draft-rigopoulos-totp-offline-audit-00
  Category: Experimental (a new optional mechanism that needs
  implementation and operational experience).
  submissionType: independent
  Updates: 6238

  AUTHOR CONTACT: before Datatracker upload, replace the placeholder
  email below with a public address. No author email was published on
  ypsservices.com at the time of writing. The organisation URI is public.
-->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude"
     category="exp"
     docName="draft-rigopoulos-totp-offline-audit-00"
     indexInclude="true"
     ipr="trust200902"
     sortRefs="true"
     submissionType="independent"
     symRefs="true"
     tocDepth="3"
     tocInclude="true"
     updates="6238"
     version="3">
  <front>
    <title abbrev="TOTP Offline Time and Viewed Records">TOTP with an Offline Time Source and a Prover-Side Viewed Record</title>
    <seriesInfo name="Internet-Draft"
                value="draft-rigopoulos-totp-offline-audit-00"/>
    <author fullname="E. A. Rigopoulos" initials="E. A." surname="Rigopoulos">
      <organization>YPS Services LLC</organization>
      <address>
        <email>ea.rigopoulos@ypsservices.com</email>
        <uri>https://ypsservices.com/</uri>
      </address>
    </author>
    <date day="30" month="November" year="2026"/>
    <area>Security</area>
    <workgroup>Independent Submission</workgroup>
    <keyword>TOTP</keyword>
    <keyword>HOTP</keyword>
    <keyword>one-time password</keyword>
    <keyword>offline</keyword>
    <keyword>audit</keyword>
    <abstract>
      <t>
        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.
      </t>
    </abstract>
  </front>
  <middle>
    <section anchor="intro">
      <name>Introduction</name>
      <t>
        This document specifies an update to
        <xref target="RFC6238"/>, which defines TOTP as an extension of
        the HMAC-based One-Time Password (HOTP) algorithm in
        <xref target="RFC4226"/>.  The moving factor in RFC 6238 is a
        time-step counter
      </t>
      <artwork><![CDATA[
T = floor((Current Unix time - T0) / X)
        ]]></artwork>
      <t>
        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
        <xref target="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.
      </t>
      <t>
        Section 5.2 of <xref target="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.
      </t>
      <t>
        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.
      </t>
      <t>
        This document specifies the following additions to
        <xref target="RFC6238"/>:
      </t>
      <ul>
        <li>
          an Offline Time Source profile, in which the prover derives
          Unix time from a local clock with no network dependency, a
          declared maximum drift rate D_max, a resynchronisation
          procedure, and a measurement method;
        </li>
        <li>
          a prover-side viewed record, written when a TOTP value is
          displayed or copied, containing the time-step T, a truncated
          keyed digest of the code (not the plaintext OTP), a local
          viewed timestamp, and a monotonic sequence number;
        </li>
        <li>
          an optional verifier check that uses the record to reject or
          flag an OTP associated with a step the device never recorded
          as viewed, which narrows the effective +/- 1 window for
          unviewed neighbour steps.
        </li>
      </ul>
      <t>
        The TOTP calculation is unchanged.  Provers and verifiers that
        implement only <xref target="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.
      </t>
    </section>

    <section anchor="conventions">
      <name>Conventions and Definitions</name>
      <t>
        The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>",
        "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>",
        "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>",
        "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>",
        "<bcp14>NOT RECOMMENDED</bcp14>", "<bcp14>MAY</bcp14>", and
        "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted
        as described in BCP 14 <xref target="RFC2119"/>
        <xref target="RFC8174"/> when, and only when, they appear in
        all capitals, as shown here.
      </t>
    </section>

    <section anchor="terminology">
      <name>Terminology</name>
      <dl>
        <dt>Prover</dt>
        <dd>
          The token or application that computes a TOTP value, as in
          <xref target="RFC6238"/>.
        </dd>
        <dt>Verifier</dt>
        <dd>
          The validation system that accepts or rejects a TOTP value.
        </dd>
        <dt>Time-step T</dt>
        <dd>
          The integer moving factor defined in Section 4.2 of
          <xref target="RFC6238"/>.
        </dd>
        <dt>D_max</dt>
        <dd>
          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.
        </dd>
        <dt>Viewed record</dt>
        <dd>
          An append-only entry written by the prover when a TOTP value
          for a given T is displayed or copied to the user.
        </dd>
        <dt>Audit mode</dt>
        <dd>
          Optional verifier behaviour that accepts TOTP values as in
          <xref target="RFC6238"/> and later compares them with viewed
          records, flagging mismatches.
        </dd>
        <dt>Enforce mode</dt>
        <dd>
          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.
        </dd>
      </dl>
    </section>

    <section anchor="offline-time">
      <name>Offline Time Source</name>
      <t>
        An implementation that claims the Offline Time Source profile
        defined here <bcp14>MUST</bcp14> derive the "Current Unix time"
        used in Section 4.2 of <xref target="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
        <xref target="RFC6238"/>.
      </t>
      <t>
        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 <xref target="measurement"/>.
      </t>

      <section anchor="dmax">
        <name>Maximum Drift Rate</name>
        <t>
          An implementation of this profile <bcp14>MUST</bcp14> 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>
        <artwork><![CDATA[
t_days = S / (|D_max| * 10^-6) / 86400
        ]]></artwork>
        <t>
          Implementations <bcp14>SHOULD NOT</bcp14> declare a D_max
          greater than 20 ppm.  A tighter class (for example 2 ppm)
          <bcp14>MAY</bcp14> 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.
        </t>
        <t>
          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 <bcp14>SHOULD</bcp14> 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.
        </t>
      </section>

      <section anchor="resync">
        <name>Setting and Resynchronisation</name>
        <t>
          When the local clock is first set, and whenever the measured
          offset exceeds a configured threshold, the clock
          <bcp14>MUST</bcp14> be set from a trusted reference.  That
          threshold <bcp14>SHOULD</bcp14> be no greater than one
          time-step X.  The trusted reference <bcp14>MAY</bcp14> 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.
        </t>
        <t>
          If the accumulated offset is larger than the verifier's
          accepted window, automatic resynchronisation as described in
          Section 6 of <xref target="RFC6238"/> may not be sufficient.
          In that case an additional authentication measure
          <bcp14>SHOULD</bcp14> be used before the clock is set, as
          already recommended in that section.
        </t>
      </section>

      <section anchor="measurement">
        <name>Measurement Method</name>
        <t>
          An implementation that claims a D_max <bcp14>MUST</bcp14>
          be able to demonstrate it by the following method, or by a
          method of equal or greater rigour.
        </t>
        <ol>
          <li>
            Set the local clock from a trusted reference and record the
            device Unix time and the reference Unix time.
          </li>
          <li>
            Once per day, for at least 14 consecutive days (28 days is
            RECOMMENDED), record both Unix times again.  The reference
            <bcp14>SHOULD</bcp14> be NTP or a satellite time source.
          </li>
          <li>
            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.
          </li>
          <li>
            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.
          </li>
        </ol>
        <t>
          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.
        </t>
      </section>
    </section>

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

      <section anchor="record-fields">
        <name>Record Fields</name>
        <t>
          Each record contains at least the following fields:
        </t>
        <dl>
          <dt>v</dt>
          <dd>Format version.  This document defines version 1.</dd>
          <dt>seq</dt>
          <dd>
            A monotonic sequence number.  The first record on a
            prover <bcp14>MUST</bcp14> use seq = 1.  Each later record
            <bcp14>MUST</bcp14> use a seq greater than all earlier
            records on that prover.
          </dd>
          <dt>T</dt>
          <dd>
            The time-step counter of the viewed TOTP value, as in
            <xref target="RFC6238"/>.
          </dd>
          <dt>viewed</dt>
          <dd>
            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).
          </dd>
          <dt>digits</dt>
          <dd>The TOTP digit count (typically 6 or 8).</dd>
          <dt>alg</dt>
          <dd>
            The TOTP hash algorithm: "SHA1", "SHA256", or "SHA512".
          </dd>
          <dt>digest</dt>
          <dd>
            Lowercase hexadecimal encoding of the leftmost 8 octets
            of the viewed-code MAC defined below.
          </dd>
          <dt>mac</dt>
          <dd>
            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.
          </dd>
        </dl>
        <t>
          The viewed-code digest is:
        </t>
        <artwork><![CDATA[
HMAC-SHA-256(K,
    "TOTP-VIEWED" || 0x00 || uint64be(T) || ASCII(code))
        ]]></artwork>
        <t>
          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.
        </t>
        <t>
          The covering MAC, when present, is:
        </t>
        <artwork><![CDATA[
HMAC-SHA-256(K,
    "TOTP-VIEWED-MAC" || 0x00 || uint64be(seq) ||
    uint64be(T) || ASCII(viewed) || uint8(digits) ||
    ASCII(alg) || digest_octets)
        ]]></artwork>
        <t>
          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
          <bcp14>MUST NOT</bcp14> be included in its own input.
        </t>
        <t>
          An optional account or issuer label <bcp14>MAY</bcp14> be
          stored locally; implementations that export records
          <bcp14>SHOULD</bcp14> consider the privacy implications in
          <xref target="privacy"/>.
        </t>
      </section>

      <section anchor="record-json">
        <name>JSON Representation</name>
        <t>
          A log <bcp14>MAY</bcp14> be represented as a JSON
          <xref target="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 <xref target="RFC6238"/>:
        </t>
        <sourcecode type="json"><![CDATA[
{
  "v": 1,
  "seq": 1,
  "T": 1,
  "viewed": "1970-01-01T00:00:59Z",
  "digits": 8,
  "alg": "SHA1",
  "digest": "6cd61375889ffa0b",
  "mac": "44e256b21a8a649325bc0e411e049f45"
}
        ]]></sourcecode>
      </section>

      <section anchor="record-cbor">
        <name>CBOR Representation</name>
        <t>
          The same record <bcp14>MAY</bcp14> be represented in CBOR
          <xref target="RFC8949"/>.  In diagnostic notation:
        </t>
        <artwork><![CDATA[
{
  "v": 1,
  "seq": 1,
  "T": 1,
  "viewed": "1970-01-01T00:00:59Z",
  "digits": 8,
  "alg": "SHA1",
  "digest": h'6CD61375889FFA0B',
  "mac":    h'44E256B21A8A649325BC0E411E049F45'
}
        ]]></artwork>
        <t>
          Interoperable exchange <bcp14>SHOULD</bcp14> use the JSON
          representation unless both sides have agreed to CBOR.  This
          document does not register a media type (see
          <xref target="iana"/>).
        </t>
      </section>
    </section>

    <section anchor="verifier">
      <name>Verifier Check</name>
      <t>
        Support for viewed records on the verifier is
        <bcp14>OPTIONAL</bcp14>.  A verifier that does not implement
        this section <bcp14>MUST</bcp14> continue to validate TOTP
        values as specified in <xref target="RFC6238"/>.  When this
        section is implemented, two modes are defined.
      </t>

      <section anchor="audit-mode">
        <name>Audit Mode</name>
        <t>
          In audit mode the verifier validates the OTP as in
          <xref target="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 <bcp14>MUST</bcp14> 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.
        </t>
        <t>
          Audit mode detects unviewed or wrong-step acceptances after
          the fact.  It does not, by itself, prevent acceptance.
        </t>
      </section>

      <section anchor="enforce-mode">
        <name>Enforce Mode</name>
        <t>
          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
          <bcp14>MUST</bcp14> reject the OTP.
        </t>
        <t>
          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).
        </t>
      </section>

      <section anchor="exchange">
        <name>Obtaining Records</name>
        <t>
          How records are carried to the verifier is out of scope of
          the TOTP calculation.  An implementation <bcp14>MAY</bcp14>
          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 <bcp14>SHOULD</bcp14> be
          present, and the verifier <bcp14>MUST</bcp14> recompute the
          digest and the mac using the shared secret before relying
          on the record.  A record with an invalid mac
          <bcp14>MUST</bcp14> be ignored for enforcement and
          <bcp14>MUST</bcp14> be flagged in audit mode.
        </t>
      </section>
    </section>

    <section anchor="interop">
      <name>Interoperability with RFC 6238</name>
      <t>
        For the same secret K, origin T0, time-step X, hash algorithm,
        digit count, and Unix time, an implementation of this document
        <bcp14>MUST</bcp14> produce the same TOTP value as
        <xref target="RFC6238"/>.  The Offline Time Source profile
        and the viewed record do not alter that value.
      </t>
      <t>
        A prover that implements this document can be validated by a
        verifier that implements only <xref target="RFC6238"/>.  A
        verifier that implements this document can validate a prover
        that implements only <xref target="RFC6238"/>, provided it
        does not require enforce mode.  Enforce mode is therefore an
        explicit, mutually agreed policy, not a silent change to TOTP.
      </t>
    </section>

    <section anchor="vectors">
      <name>Test Vectors</name>
      <t>
        The following vectors use the Appendix B test token of
        <xref target="RFC6238"/>: the ASCII shared secret
        "12345678901234567890", X = 30, T0 = 0, and HMAC-SHA-1.
        The 8-digit TOTP values <bcp14>MUST</bcp14> 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
        <xref target="record-fields"/>.  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.
      </t>
      <t>
        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.
      </t>
      <table anchor="tab-totp">
        <name>TOTP values for the Appendix B times (HMAC-SHA-1)</name>
        <thead>
          <tr>
            <th>Unix time</th>
            <th>UTC</th>
            <th>T (hex)</th>
            <th>TOTP (8)</th>
            <th>TOTP (6)</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>59</td>
            <td>1970-01-01T00:00:59Z</td>
            <td>0000000000000001</td>
            <td>94287082</td>
            <td>287082</td>
          </tr>
          <tr>
            <td>1111111109</td>
            <td>2005-03-18T01:58:29Z</td>
            <td>00000000023523EC</td>
            <td>07081804</td>
            <td>081804</td>
          </tr>
          <tr>
            <td>1111111111</td>
            <td>2005-03-18T01:58:31Z</td>
            <td>00000000023523ED</td>
            <td>14050471</td>
            <td>050471</td>
          </tr>
          <tr>
            <td>1234567890</td>
            <td>2009-02-13T23:31:30Z</td>
            <td>000000000273EF07</td>
            <td>89005924</td>
            <td>005924</td>
          </tr>
          <tr>
            <td>2000000000</td>
            <td>2033-05-18T03:33:20Z</td>
            <td>0000000003F940AA</td>
            <td>69279037</td>
            <td>279037</td>
          </tr>
          <tr>
            <td>20000000000</td>
            <td>2603-10-11T11:33:20Z</td>
            <td>0000000027BC86AA</td>
            <td>65353130</td>
            <td>353130</td>
          </tr>
        </tbody>
      </table>
      <table anchor="tab-rec8">
        <name>Viewed records for the 8-digit codes (alg = SHA1, digits = 8)</name>
        <thead>
          <tr>
            <th>seq</th>
            <th>T</th>
            <th>digest</th>
            <th>mac</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>1</td>
            <td>1</td>
            <td>6cd61375889ffa0b</td>
            <td>44e256b21a8a649325bc0e411e049f45</td>
          </tr>
          <tr>
            <td>2</td>
            <td>37037036</td>
            <td>edbcdf5108fb06f7</td>
            <td>260c2e3d63510828b3714e034c9d383a</td>
          </tr>
          <tr>
            <td>3</td>
            <td>37037037</td>
            <td>473efb3fb6e79bec</td>
            <td>c1ddec49506f8e556386f0cff4d7ba46</td>
          </tr>
          <tr>
            <td>4</td>
            <td>41152263</td>
            <td>7da5aebe378d6144</td>
            <td>dc673ac6fc03c3ceee2058b029a6a2c5</td>
          </tr>
          <tr>
            <td>5</td>
            <td>66666666</td>
            <td>b20352a510905140</td>
            <td>e3c595af1a3906af6511edbdf0574fde</td>
          </tr>
          <tr>
            <td>6</td>
            <td>666666666</td>
            <td>ecbac0e7cbf5f3ec</td>
            <td>e19efccee63a8278db61ff4c08b7570c</td>
          </tr>
        </tbody>
      </table>
      <table anchor="tab-rec6">
        <name>Digest and mac for the 6-digit codes (alg = SHA1, digits = 6)</name>
        <thead>
          <tr>
            <th>seq</th>
            <th>T</th>
            <th>digest</th>
            <th>mac</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>1</td>
            <td>1</td>
            <td>40fdf812c2d8d342</td>
            <td>100b1728be424e2f42a8005fff2b3035</td>
          </tr>
          <tr>
            <td>2</td>
            <td>37037036</td>
            <td>e85015ba83d941d4</td>
            <td>459e24a8f390cd8352482e4c1ea395f6</td>
          </tr>
          <tr>
            <td>3</td>
            <td>37037037</td>
            <td>49631a5028eda401</td>
            <td>7335e0efb752ac3c6caf9ecbb52c864a</td>
          </tr>
          <tr>
            <td>4</td>
            <td>41152263</td>
            <td>37577bdb0a361084</td>
            <td>194204acbbcb0ef8b4b3add75b1a9e68</td>
          </tr>
          <tr>
            <td>5</td>
            <td>66666666</td>
            <td>14be20c848413dc4</td>
            <td>4dcffc240108b425f856c794dd11d9d6</td>
          </tr>
          <tr>
            <td>6</td>
            <td>666666666</td>
            <td>a88648e1600b3dce</td>
            <td>4b636bbe283295ded27b896100e1ec59</td>
          </tr>
        </tbody>
      </table>
    </section>

    <section anchor="measured">
      <name>Measured Results</name>
      <t>
        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 <xref target="RFC6238"/> matched.
      </t>
      <t>
        Exact acceptance-window arithmetic, with X = 30 seconds:
      </t>
      <ul>
        <li>Window 0: 1 code valid at once; a given code is accepted for 30 seconds.</li>
        <li>Window +/- 1: 3 codes valid at once; a given code is accepted for 90 seconds.</li>
        <li>Window +/- 2: 5 codes valid at once; a given code is accepted for 150 seconds.</li>
      </ul>
      <t>
        Constant-rate isolated clock model (exact), time to a 15-second
        and 30-second offset:
      </t>
      <ul>
        <li>0.5 ppm: 347.222 days / 694.444 days.</li>
        <li>2 ppm: 86.806 days / 173.611 days.</li>
        <li>5 ppm: 34.722 days / 69.444 days.</li>
        <li>20 ppm: 8.681 days / 17.361 days.</li>
        <li>50 ppm: 3.472 days / 6.944 days.</li>
      </ul>
      <t>
        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.
      </t>
      <t>
        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.
      </t>
      <t>
        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.
      </t>
      <ul>
        <li>
          Shoulder-surf of the viewed code, fast attacker: accepted
          before the typist in 89.97% of trials.  Detectable from the
          viewed record alone: 0%, because the same step was viewed.
        </li>
        <li>
          The same scenario, slower attacker: 12.23% accepted before
          the typist; still 0% detectable from the record alone.
        </li>
        <li>
          Unviewed adjacent code C_T-1: accepted in 90.80% (fast) and
          49.80% (slow) of trials.  Unviewed adjacent C_T+1, and a
          code never viewed on the device: accepted in 100% of trials.
          In all of those accepted cases, 100% are detectable
          afterwards if the verifier compares the record.
        </li>
      </ul>
      <t>
        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.
      </t>
    </section>

    <section anchor="impl-status" removeInRFC="true">
      <name>Implementation Status</name>
      <t>This section records the status of known implementations of the mechanism defined in this document at the time of posting, following <xref target="RFC7942"/>. It is to be removed before publication as an RFC.</t>
      <dl>
        <dt>Organization:</dt><dd>YPS Services LLC</dd>
        <dt>Implementation:</dt><dd>Last Viewed, security software. A public RFC 6238 test panel that computes codes locally without a network is available at <eref target="https://lastviewed.ypsservices.com/"/>.</dd>
        <dt>Coverage:</dt><dd>RFC 6238 code generation with the Appendix B test key. The viewed record defined in this document is in development.</dd>
        <dt>Licensing:</dt><dd>Proprietary.</dd>
        <dt>Contact:</dt><dd>ea.rigopoulos@ypsservices.com</dd>
      </dl>
      <t>Last Viewed is a trademark of YPS Services LLC.</t>
    </section>
    <section anchor="security">
      <name>Security Considerations</name>
      <t>
        The security of the TOTP value remains that of
        <xref target="RFC6238"/> and <xref target="RFC4226"/>.  This
        section considers only the additions in this document.
      </t>
      <t>
        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 <xref target="RFC6238"/>.
      </t>
      <t>
        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 <xref target="RFC6238"/> remains the control that
        stops the same OTP being accepted twice at that verifier
        after a first success.
      </t>
      <t>
        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 <xref target="RFC6238"/>.  Implementations
        <bcp14>SHOULD</bcp14> 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.
      </t>
      <t>
        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 <bcp14>SHOULD</bcp14> require an additional
        authentication measure when the offset is large, as in
        Section 6 of <xref target="RFC6238"/>.  Verifiers
        <bcp14>SHOULD NOT</bcp14> widen the acceptance window beyond
        what Section 5.2 of <xref target="RFC6238"/> recommends
        without understanding the added exposure (more simultaneously
        valid codes and a longer acceptance period for each code).
      </t>
      <t>
        Shared-secret storage, provisioning, and the design of any
        particular hardware token are out of scope.  Keys
        <bcp14>SHOULD</bcp14> still be generated and protected as
        recommended in <xref target="RFC6238"/>.
      </t>
    </section>

    <section anchor="privacy">
      <name>Privacy Considerations</name>
      <t>
        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
        <bcp14>SHOULD</bcp14> 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
        <bcp14>SHOULD</bcp14> be omitted from exported records unless
        required.  Verifiers that receive records
        <bcp14>SHOULD</bcp14> apply the same retention limits as for
        other authentication logs.  See also
        <xref target="RFC6973"/>.
      </t>
    </section>

    <section anchor="iana">
      <name>IANA Considerations</name>
      <t>
        This document has no IANA actions.
      </t>
    </section>
  </middle>

  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
          <front>
            <title>Key words for use in RFCs to Indicate Requirement Levels</title>
            <author fullname="S. Bradner" initials="S." surname="Bradner"/>
            <date month="March" year="1997"/>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="2119"/>
          <seriesInfo name="DOI" value="10.17487/RFC2119"/>
        </reference>
        <reference anchor="RFC4226" target="https://www.rfc-editor.org/info/rfc4226">
          <front>
            <title>HOTP: An HMAC-Based One-Time Password Algorithm</title>
            <author fullname="D. M'Raihi" initials="D." surname="M'Raihi"/>
            <author fullname="M. Bellare" initials="M." surname="Bellare"/>
            <author fullname="F. Hoornaert" initials="F." surname="Hoornaert"/>
            <author fullname="D. Naccache" initials="D." surname="Naccache"/>
            <author fullname="O. Ranen" initials="O." surname="Ranen"/>
            <date month="December" year="2005"/>
          </front>
          <seriesInfo name="RFC" value="4226"/>
          <seriesInfo name="DOI" value="10.17487/RFC4226"/>
        </reference>
        <reference anchor="RFC6238" target="https://www.rfc-editor.org/info/rfc6238">
          <front>
            <title>TOTP: Time-Based One-Time Password Algorithm</title>
            <author fullname="D. M'Raihi" initials="D." surname="M'Raihi"/>
            <author fullname="S. Machani" initials="S." surname="Machani"/>
            <author fullname="M. Pei" initials="M." surname="Pei"/>
            <author fullname="J. Rydell" initials="J." surname="Rydell"/>
            <date month="May" year="2011"/>
          </front>
          <seriesInfo name="RFC" value="6238"/>
          <seriesInfo name="DOI" value="10.17487/RFC6238"/>
        </reference>
        <reference anchor="RFC8174" target="https://www.rfc-editor.org/info/rfc8174">
          <front>
            <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
            <author fullname="B. Leiba" initials="B." surname="Leiba"/>
            <date month="May" year="2017"/>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="8174"/>
          <seriesInfo name="DOI" value="10.17487/RFC8174"/>
        </reference>
      </references>
      <references>
        <name>Informative References</name>
        <reference anchor="RFC7942" target="https://www.rfc-editor.org/info/rfc7942">
          <front><title>Improving Awareness of Running Code: The Implementation Status Section</title>
            <author initials="Y." surname="Sheffer" fullname="Y. Sheffer"/><author initials="A." surname="Farrel" fullname="A. Farrel"/>
            <date year="2016" month="July"/></front>
          <seriesInfo name="BCP" value="205"/><seriesInfo name="RFC" value="7942"/><seriesInfo name="DOI" value="10.17487/RFC7942"/>
        </reference>
        <reference anchor="RFC6973" target="https://www.rfc-editor.org/info/rfc6973">
          <front>
            <title>Privacy Considerations for Internet Protocols</title>
            <author fullname="A. Cooper" initials="A." surname="Cooper"/>
            <author fullname="H. Tschofenig" initials="H." surname="Tschofenig"/>
            <author fullname="B. Aboba" initials="B." surname="Aboba"/>
            <author fullname="J. Peterson" initials="J." surname="Peterson"/>
            <author fullname="J. Morris" initials="J." surname="Morris"/>
            <author fullname="M. Hansen" initials="M." surname="Hansen"/>
            <author fullname="R. Smith" initials="R." surname="Smith"/>
            <date month="July" year="2013"/>
          </front>
          <seriesInfo name="RFC" value="6973"/>
          <seriesInfo name="DOI" value="10.17487/RFC6973"/>
        </reference>
        <reference anchor="RFC8259" target="https://www.rfc-editor.org/info/rfc8259">
          <front>
            <title>The JavaScript Object Notation (JSON) Data Interchange Format</title>
            <author fullname="T. Bray" initials="T." surname="Bray" role="editor"/>
            <date month="December" year="2017"/>
          </front>
          <seriesInfo name="STD" value="90"/>
          <seriesInfo name="RFC" value="8259"/>
          <seriesInfo name="DOI" value="10.17487/RFC8259"/>
        </reference>
        <reference anchor="RFC8949" target="https://www.rfc-editor.org/info/rfc8949">
          <front>
            <title>Concise Binary Object Representation (CBOR)</title>
            <author fullname="C. Bormann" initials="C." surname="Bormann"/>
            <author fullname="P. Hoffman" initials="P." surname="Hoffman"/>
            <date month="December" year="2020"/>
          </front>
          <seriesInfo name="STD" value="94"/>
          <seriesInfo name="RFC" value="8949"/>
          <seriesInfo name="DOI" value="10.17487/RFC8949"/>
        </reference>
      </references>
    </references>

    <section anchor="ack" numbered="false">
      <name>Acknowledgements</name>
      <t>
        This document builds on <xref target="RFC6238"/> by D. M'Raihi,
        S. Machani, M. Pei, and J. Rydell, and on <xref target="RFC4226"/>
        by D. M'Raihi, M. Bellare, F. Hoornaert, D. Naccache, and
        O. Ranen.  Errors of interpretation remain the author's.
      </t>
    </section>
  </back>
</rfc>
