<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">

<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc strict="yes"?>
<?rfc toc="yes"?>
<?rfc tocdepth="3"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>

<rfc category="info" docName="draft-ietf-ntp-roughtime-07" ipr="trust200902">
  <front>
    <title>Roughtime</title>

    <author fullname="Aanchal Malhotra" initials="A." surname="Malhotra">
      <organization>Boston University</organization>
      <address>
        <postal>
          <street>111 Cummington Mall</street>
          <city>Boston</city>
          <region>MA</region>
          <code>02215</code>
          <country>USA</country>
        </postal>
        <email>aanchal4@bu.edu</email>
      </address>
    </author>

    <author fullname="Adam Langley" initials="A." surname="Langley">
      <organization>Google</organization>
      <address>
      <email>agl@google.com</email>
      </address>
    </author>

    <author fullname="Watson Ladd" initials="W." surname="Ladd">
      <organization> Sealance, Inc.</organization>
      <address>
        <email>watsonbladd@gmail.com</email>
      </address>
    </author>

   <author fullname="Marcus Dansarie" initials="M." surname="Dansarie">
      <address>
        <email>marcus@dansarie.se</email>
        <uri>https://orcid.org/0000-0001-9246-0263</uri>
      </address>
    </author>
    <date year="2022" month="September" day="26"/>

    <area>General</area>

    <workgroup>Internet Engineering Task Force</workgroup>

    <keyword>roughtime</keyword>

    <keyword>time synchronization</keyword>

    <abstract>
      <t>
        This document specifies Roughtime - a protocol that aims to achieve
        rough time synchronization while detecting servers that provide
        inaccurate time and providing cryptographic proof of their malfeasance.
      </t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>
        Time synchronization is essential to Internet security as many security
        protocols and other applications require synchronization
        <xref target="RFC7384"/> <xref target="MCBG"/>. Unfortunately widely
        deployed protocols such as the Network Time Protocol (NTP)
        <xref target="RFC5905"/> lack essential security features, and even
        newer protocols like Network Time Security (NTS)
        <xref target="RFC8915"/> lack mechanisms to ensure that the servers
        behave correctly. Authenticating time servers prevents network
        adversaries from modifying time packets, but an authenticated time
        server still has full control over the contents of the time packet and
        may transmit incorrect time. The Roughtime protocol provides
        cryptographic proof of malfeasance, enabling clients to detect and prove
        to a third party a server's attempts to influence the time a client
        computes.
      </t>
      <table anchor="existing_approaches">
        <name>Security Properties of current protocols.</name>
        <tbody>
          <tr>
            <th>Protocol</th>
            <th>Authenticated Server</th>
            <th>Server Malfeasance Evidence</th>
          </tr>
          <tr><td>NTP, Chronos</td> <td>N</td>   <td>N</td></tr>
          <tr><td>NTP-MAC</td>      <td>Y*</td>  <td>N</td></tr>
          <tr><td>NTP-Autokey</td>  <td>Y**</td> <td>N</td></tr>
          <tr><td>NTS</td>          <td>Y</td>   <td>N</td></tr>
          <tr><td>Roughtime</td>    <td>Y</td>   <td>Y</td></tr>
        </tbody>
      </table>
      <t>
        Y* For security issues with symmetric-key based NTP-MAC authentication,
        please refer to <xref target="RFC8573">RFC 8573</xref>.
      </t>
      <t>
        Y** For security issues with Autokey Public Key Authentication, refer to
        <xref target="Autokey"/>.
      </t>
      <t>
        <list style="symbols">
          <t>
            If a server's timestamps do not fit into the time context
            of other servers' responses, then a Roughtime client can
            cryptographically prove this misbehavior to third
            parties. This helps detect dishonest or malfunctioning
            servers.
          </t>
          <t>
            A Roughtime client can roughly detect (with no absolute
            guarantee) a delay attack <xref target="DelayAttacks"/>
            but can not cryptographically prove this to a third
            party. However such attacks expand the round trip time
            between request and response.
          </t>
          <t>
            Note that delay attacks cannot be detected/stopped by any protocol.
            Delay attacks can not, however, undermine the security guarantees
            provided by Roughtime.
          </t>
          <t>
            Although delay attacks cannot be prevented, they can be
            limited to a predetermined upper bound. This can be done
            by defining a maximal tolerable Round Trip Time (RTT)
            value, MAX-RTT, that a Roughtime client is willing to
            accept. A Roughtime client can measure the RTT of every
            request-response handshake and compare it to MAX-RTT. If
            the RTT exceeds MAX-RTT, the corresponding measurement is
            discarded.  When this approach is used, the maximal time
            error that can be caused by a delay attack is
            MAX-RTT/2. It should be noted that this approach assumes
            that the nature of the system is known to the client,
            including reasonable upper bounds on the RTT value.
          </t>
        </list>
      </t>
    </section>

    <section title="Requirements Language">
      <t>
        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&nbsp;14 <xref target="RFC2119"></xref>
        <xref target="RFC8174"></xref> when, and only when, they appear in all
        capitals, as shown here.
      </t>
    </section>

    <section title="Protocol Overview" anchor="protocol-overview">
      <t>
        Roughtime is a protocol for rough time synchronization that
        enables clients to provide cryptographic proof of server
        malfeasance. It does so by having responses from servers
        include a signature over a value derived from a nonce in the
        client request. This provides cryptographic proof that the
        timestamp was issued after the server received the client's
        request. The derived value included in the server's response
        is the root of a Merkle tree which includes the hash of the
        client's nonce as the value of one of its leaf nodes. This
        enables the server to amortize the relatively costly signing
        operation over a number of client requests.
      </t>
      <t>
        Single server mode: At its most basic level, Roughtime is a one round
        protocol in which a completely fresh client requests the current time
        and the server sends a signed response. The response includes a
        timestamp and a radius used to indicate the server's certainty about the
        reported time. For example, a radius of 1,000,000 microseconds means the
        server is absolutely confident that the true time is within one second
        of the reported time.
      </t>
      <t>
        The server proves freshness of its response as follows. The client's
        request contains a nonce which the server incorporates into its signed
        response. The client can verify the server's signatures and - provided
        that the nonce has sufficient entropy - this proves that the signed
        response could only have been generated after the nonce.
      </t>
    </section>

    <section title="The Guarantee">
      <t>
        A Roughtime server guarantees that a response to a query sent
        at t<sub>1</sub>, received at t<sub>2</sub>, and with timestamp
        t<sub>3</sub> has been created between the transmission of the query and
        its reception. If t<sub>3</sub> is not within that interval, a server
        inconsistency may be detected and used to impeach the server. The
        propagation of such a guarantee and its use of type synchronization is
        discussed in <xref target="ntp-integration"/>. No delay attacker may
        affect this: they may only expand the interval between t<sub>1</sub> and
        t<sub>2</sub>, or of course stop the measurement in the first place.
      </t>
    </section>

    <section title="Message Format">
      <t>
        Roughtime messages are maps consisting of one or more (tag, value)
        pairs. They start with a header, which contains the number of pairs, the
        tags, and value offsets. The header is followed by a message values
        section which contains the values associated with the tags in the
        header. Messages MUST be formatted according to
        <xref target="fig-roughtime-message"/> as described in the following
        sections.
      </t>
      <t>
        Messages MAY be recursive, i.e. the value of a tag can itself be a
        Roughtime message.
      </t>
      <figure anchor="fig-roughtime-message">
        <name>Roughtime Message Format</name>
        <artwork><![CDATA[
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   Number of pairs (uint32)                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                     N-1 offsets (uint32)                      .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                        N tags (uint32)                        .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                            Values                             .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+]]>
        </artwork>
      </figure>

      <section title="Data Types" anchor="format">
        <section title="int32">
          <t>
            An int32 is a 32 bit signed integer. It is serialized least
            significant byte first in sign-magnitude representation with the
            sign bit in the most significant bit. The negative zero value
            (0x80000000) MUST NOT be used and any message with it is
            syntactically invalid and MUST be ignored.
          </t>
        </section>
        <section title="uint32">
          <t>
            A uint32 is a 32 bit unsigned integer. It is serialized with the
            least significant byte first.
          </t>
        </section>

        <section title="uint64">
          <t>
            A uint64 is a 64 bit unsigned integer. It is serialized with the
            least significant byte first.
          </t>
        </section>

        <section title="Tag" anchor="tag">
          <t>
            Tags are used to identify values in Roughtime messages. A tag is a
            uint32 but may also be listed in this document as a sequence of up
            to four ASCII characters <xref target="RFC0020"/>. ASCII strings
            shorter than four characters can be unambiguously converted to tags
            by padding them with zero bytes. For example, the ASCII string
            "NONC" would correspond to the tag 0x434e4f4e and "PAD" would
            correspond to 0x00444150.
          </t>
        </section>

        <section title="Timestamp">
          <t>
            A timestamp is a uint64 interpreted in the following way. The most
            significant 3 bytes contain the integer part of a Modified Julian
            Date (MJD). The least significant 5 bytes is a count of the number
            of Coordinated Universal Time (UTC) <xref target="ITU-R_TF.460-6"/>
            microseconds since midnight on that day.
          </t>
          <t>
            The MJD is the number of UTC days since 17 November 1858
            <xref target="ITU-R_TF.457-2"/>. It is useful to note that 1 January
            1970 is 40,587 days after 17 November 1858.
          </t>
          <t>
            Note that, unlike NTP, this representation does not use the full
            number of bits in the fractional part and that days with leap
            seconds will have more or fewer than the nominal 86,400,000,000
            microseconds.
          </t>
        </section>
      </section>

      <section title="Header">
        <t>
          All Roughtime messages start with a header. The first four bytes of
          the header is the uint32 number of tags N, and hence of (tag, value)
          pairs. The following 4*(N-1) bytes are offsets, each a uint32. The
          last 4*N bytes in the header are tags.
        </t>
        <t>
          Offsets refer to the positions of the values in the message values
          section. All offsets MUST be multiples of four and placed in
          increasing order. The first post-header byte is at offset 0. The
          offset array is considered to have a not explicitly encoded value of 0
          as its zeroth entry. The value associated with the ith tag begins at
          offset[i] and ends at offset[i+1]-1, with the exception of the last
          value which ends at the end of the message. Values MAY have zero
          length.
        </t>
        <t>
          Tags MUST be listed in the same order as the offsets of their values
          and MUST also be sorted in ascending order by numeric value. A tag
          MUST NOT appear more than once in a header.
        </t>
      </section>
    </section>

    <section title="Protocol Details">
      <t>
        As described in <xref target="protocol-overview"/>, clients
        initiate time synchronization by sending requests containing
        a nonce to servers who send signed time responses in
        return. Roughtime packets can be sent between clients and
        servers either as UDP datagrams or via TCP streams. Servers
        SHOULD support the UDP transport mode, while TCP transport is
        OPTIONAL.
      </t>
      <t>
        A Roughtime packet MUST be formatted according to
        <xref target="fig-roughtime-packet-format" /> and as described here.
        The first field is a uint64 with the value 0x4d49544847554f52
        ("ROUGHTIM" in ASCII). The second field is a uint32 and contains the
        length of the third field. The third and last field contains a
        Roughtime message as specified in <xref target="format"/>.
      </t>
      <figure anchor="fig-roughtime-packet-format">
        <name>Roughtime Packet Format</name>
        <artwork><![CDATA[
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                  0x4d49544847554f52 (uint64)                  |
|                        ("ROUGHTIM")                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Message length (uint32)                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                      Roughtime message                        .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+]]>
        </artwork>
      </figure>
      <t>
        Roughtime request and response packets MUST be transmitted in a single
        datagram when the UDP transport mode is used. Setting the packet's don't
        fragment bit <xref target="RFC0791" /> is OPTIONAL in IPv4 networks.
      </t>
      <t>
        Multiple requests and responses can be exchanged over an established TCP
        connection. Clients MAY send multiple requests at once and servers MAY
        send responses out of order. The connection SHOULD be closed by the
        client when it has no more requests to send and has received all
        expected responses. Either side SHOULD close the connection in response
        to synchronization, format, implementation-defined timeouts, or other
        errors.
      </t>
      <t>
        All requests and responses MUST contain the VER tag. It contains a list
        of one or more uint32 version numbers. The version of Roughtime
        specified by this memo has version number 1.
      </t>
      <t>
        NOTE TO RFC EDITOR: remove this paragraph before publication. For
        testing drafts of this memo, a version number of 0x80000000 plus the
        draft number is used.
      </t>

      <section title="Requests">
        <t>
          A request MUST contain the tags VER and NONC. Tags other than NONC and
          VER SHOULD be ignored by the server. A future version of this protocol
          may mandate additional tags in the message and assign them semantic
          meaning.
        </t>
        <t>
          The size of the request message SHOULD be at least 1024 bytes when
          the UDP transport mode is used. To attain this size the PAD tag
          SHOULD be added to the message. Its value SHOULD be all zeros.
          Responding to requests shorter than 1024 bytes is OPTIONAL and
          servers MUST NOT send responses larger than the requests they are
          replying to.
        </t>
        <section title="VER">
          <t>
            In a request, the VER tag contains a list of versions. The VER tag
            MUST include at least one Roughtime version supported by the client.
            The client MUST ensure that the version numbers and tags included in
            the request are not incompatible with each other or the packet
            contents.
          </t>
        </section>
        <section title="NONC">
          <t>
            The value of the NONC tag is a 32 byte nonce. It SHOULD be generated
            in a manner indistinguishable from random. BCP&nbsp;106 contains
            specific guidelines regarding this <xref target="RFC4086" />.
          </t>
        </section>
      </section>

      <section title="Responses">
        <t>
          A response MUST contain the tags SIG, VER, NONC, PATH, SREP, CERT, and
          INDX.
        </t>
        <section title="SIG">
          <t>
            In general, a SIG tag value is a 64 byte Ed25519 signature
            <xref target="RFC8032"/> over a concatenation of a signature context
            ASCII string and the entire value of a tag. All context strings
            MUST include a terminating zero byte.
          </t>
          <t>
            The SIG tag in the root of a response MUST be a signature over the
            SREP value using the public key contained in CERT. The context
            string MUST be "RoughTime v1 response signature".
          </t>
        </section>
        <section title="VER">
          <t>
            In a response, the VER tag MUST contain a single version number. It
            SHOULD be one of the version numbers supplied by the client in its
            request. The server MUST ensure that the version number corresponds
            with the rest of the packet contents.
          </t>
        </section>
        <section title="NONC">
          <t>
            The NONC tag MUST contain the nonce of the message being responded
            to.
          </t>
        </section>
        <section title="PATH">
          <t>
            The PATH tag value MUST be a multiple of 32 bytes long and
            represent a path of 32 byte hash values in the Merkle tree used to
            generate the ROOT value as described in
            <xref target="merkle-tree"/>. In the case where a response is
            prepared for a single request and the Merkle tree contains only the
            root node, the size of PATH MUST be zero.
          </t>
        </section>
        <section title="SREP">
          <t>
            The SREP tag contains a time response. Its value MUST be a
            Roughtime message with the tags ROOT, MIDP, and RADI. If the server
            has updated UT1, TAI, or leap second information, it MAY include any
            of the tags DUT1, DTAI, and LEAP in the contents of the SREP tag.
            The absence of any of those tags indicates that the server does not
            hold such information.
          </t>
          <t>
            The ROOT tag MUST contain a 32 byte value of a Merkle tree root as
            described in <xref target="merkle-tree"/>.
          </t>
          <t>
            The MIDP tag value MUST be timestamp of the moment of processing.
          </t>
          <t>
            The RADI tag value MUST be a uint32 representing the server's
            estimate of the accuracy of MIDP in microseconds. Servers MUST
            ensure that the true time is within (MIDP-RADI, MIDP+RADI) at the
            time they transmit the response message.
          </t>
          <t>
            The DUT1 tag value MUST be an int32 indicating the predicted
            difference between UT1 and UTC (UT1 - UTC) in microseconds at the
            time indicated by MIDP, as given by the International Earth Rotation
            and Reference Systems Service (IERS).
          </t>
          <t>
            The DTAI tag value MUST be an int32 indicating the current
            difference between International Atomic Time (TAI) and UTC
            (TAI - UTC) in seconds as published in the International Bureau of
            Weights and Measures' (BIPM) Circular T.
          </t>
          <t>
            The LEAP tag MUST contain one or more int32 values, each
            representing a past or future leap second event. Positive values
            represent the addition of a second and negative values represent the
            removal of a second. The absolute value represents the MJD of the
            day that begins immediately after the leap second event. The leap
            second events MUST be sorted in reverse chronological order and the
            first item MUST be the last (past or future) leap second event that
            the server knows about.
         </t>
         <t>
           By way of illustration, there was a leap second 31 December 2016
           23:59:60. This event would be represented by a LEAP tag containing
           the int32 value 57754. The positive sign represents that there was an
           additional second inserted, the numeric value indicates 1 January
           2017, the day that began at midnight following the addition.
         </t>
        </section>
        <section title="CERT">
          <t>
            The CERT tag contains a public-key certificate signed with the
            server's long-term key. Its value is a Roughtime message with the
            tags DELE and SIG, where SIG is a signature over the DELE value. The
            context string used to generate SIG MUST be "RoughTime v1 delegation
            signature".
          </t>
          <t>
            The DELE tag contains a delegated public-key certificate used by the
            server to sign the SREP tag. Its value is a Roughtime message with
            the tags MINT, MAXT, and PUBK. The purpose of the DELE tag is to
            enable separation of a long-term public key from keys on devices
            exposed to the public Internet.
          </t>
          <t>
            The MINT tag is the minimum timestamp for which the key in PUBK is
            trusted to sign responses. MIDP MUST be more than or equal to MINT for
            a response to be considered valid.
          </t>
          <t>
            The MAXT tag is the maximum timestamp for which the key in PUBK is
            trusted to sign responses. MIDP MUST be less than or equal to MAXT for
            a response to be considered valid.
          </t>
          <t>
            The PUBK tag contains a temporary 32 byte Ed25519 public key which is
            used to sign the SREP tag.
          </t>
        </section>
        <section title="INDX">
          <t>
            The INDX tag value is a uint32 determining the position of NONC in the
            Merkle tree used to generate the ROOT value as described in
            <xref target="merkle-tree"/>.
          </t>
        </section>
      </section>

      <section title="The Merkle Tree" anchor="merkle-tree">
        <t>
          A Merkle tree is a binary tree where the value of each non-leaf node
          is a hash value derived from its two children. The root of the tree is
          thus dependent on all leaf nodes.
        </t>
        <t>
          In Roughtime, each leaf node in the Merkle tree represents the nonce
          in one request. Leaf nodes are indexed left to right, beginning with
          zero.
        </t>
        <t>
          The values of all nodes are calculated from the leaf nodes and up
          towards the root node using the output of the SHA-512/256 hash
          algorithm <xref target="SHS"/>. For leaf nodes, the byte 0x00 is
          prepended to the nonce before applying the hash function. For all
          other nodes, the byte 0x01 is concatenated with first the left and
          then the right child node value before applying the hash function.
        </t>
        <t>
          The value of the Merkle tree's root node is included in the ROOT tag
          of the response.
        </t>
        <t>
          The index of a request's nonce node is included in the INDX tag of the
          response.
        </t>
        <t>
          The values of all sibling nodes in the path between a
          request's nonce node and the root node is stored in the PATH
          tag so that the client can reconstruct and validate the
          value in the ROOT tag using its nonce. These values are each
          32 bytes and are stored one after the other with no
          additional padding or structure.  The order in which they
          are stored is described in <xref target="root-check"/>
        </t>
      </section>

      <section title="Validity of Response">
        <t>
          A client MUST check the following properties when it receives a
          response.

          <list style="symbols">
            <t>
              The signature in CERT was made with the long-term key of the
              server.
            </t>
            <t>
              The DELE timestamps and the MIDP value are consistent.
            </t>
            <t>
              The value of NONC in the response is identical to the value of
              NONC in the request.
            </t>
            <t>
              The INDX and PATH values prove NONC was included in the Merkle
              tree with value ROOT using the algorithm in
              <xref target="root-check"/>.
            </t>
            <t>
              The signature of SREP in SIG validates with the public key in
              DELE.
            </t>
          </list>

          A response that passes these checks is said to be valid. Validity of a
          response does not prove the time is correct, but merely that the
          server signed it, and thus promises that it began to compute the
          signature at a time in the interval (MIDP-RADI, MIDP+RADI).
        </t>

        <section title="Root Value Calculation Algorithm"
            anchor="root-check">
          <t>
            When validating the response, the client independently computes the
            hash of the Merkle tree from the values in the tags PATH, INDX, and
            NONC. The bits of INDX are ordered from least to most significant in
            this algorithm. In the following examples, || denotes concatenation.
          </t>
          <t>
            At initialization, hash is set to SHA-512/256(0x00 || nonc).
          </t>
          <t>
            If no more entries remain in PATH the current hash is the hash of
            the Merkle tree, i.e. the value of ROOT. All remaining bits of INDX
            must be zero at this point.
          </t>
          <t>
            Otherwise, let node be the next 32 bytes in PATH. If the current bit
            in INDX is 0 then hash = SHA-512/256(0x01 || node || hash), else
            hash = SHA-512/256(0x01 || hash || node).
          </t>
          <t>
            <xref target="fig-roughtime-calc-root"/> presents pseudocode for the
            root value calculation algorithm.
          </t>
          <figure anchor="fig-roughtime-calc-root">
            <name>Pseudocode for the Roughtime root value calculation algorithm.</name>
            <sourcecode><![CDATA[
function calc_root(path, indx, nonc):
    if len(path) > 32:
        throw error
    hash = sha512-256(0x00 || nonc)
    while len(path) > 0:
        if indx & 1 == 0:
            hash = sha512-256(0x01 || hash || path[0])
        else:
            hash = sha512-256(0x01 || path[0] || hash)
        path = path[1:]
        indx >>= 1
    if indx != 0:
        throw error
    return hash]]>
            </sourcecode>
          </figure>
        </section>
      </section>
    </section>
    <section title = "Integration Into NTP" anchor="ntp-integration">
      <t>
        We assume that there is a bound PHI on the frequency error in the clock
        on the machine. Given a measurement taken at a local time t, we know the
        true time is in (t-delta-sigma, t-delta+sigma). After d seconds have
        elapsed we know the true time is within (t-delta-sigma-d*PHI,
        t-delta+sigma+d*PHI). A simple and effective way to mix with NTP or PTP
        discipline of the clock is to trim the observed intervals in NTP to fit
        entirely within this window or reject measurements that fall to far
        outside. This assumes time has not been stepped.  If the NTP process
        decides to step the time, it MUST use Roughtime to ensure the new
        truetime estimate that will be stepped to is consistent with the true
        time.
      </t>
      <t>
        Should this window become too large, another Roughtime measurement is
        called for. The definition of "too large" is implementation defined.
      </t>
      <t>
        Implementations MAY use other, more sophisticated means of adjusting the
        clock respecting Roughtime information. Other applications such as X.509
        verification may wish to
      </t>
    </section>

    <section title="Grease">
      <t>
        Servers MAY send back a fraction of responses that are syntactically
        invalid or contain invalid signatures as well as incorrect times.
        Clients MUST properly reject such responses. Servers MUST NOT send back
        responses with incorrect times and valid signatures. Either signature
        MAY be invalid for this application.
      </t>
    </section>

    <section title="Roughtime Servers">
      <t>
        NOTE TO RFC EDITOR: remove this section before publication.
      </t>
      <t>
        The below list contains a list of servers with their public keys in
        Base64 format. These servers may implement older versions of this
        specification.
        <figure>
          <artwork>
address:       roughtime.cloudflare.com
port:          2002
long-term key: gD63hSj3ScS+wuOeGrubXlq35N1c5Lby/S+T7MNTjxo=

address:       roughtime.dnov.se
port:          2002
long-term key: hlKAFAeU+xDZ1+9eVgrXel+m3sRiSlzoqCsqL9WoRB0=

address:       roughtime.int08h.com
port:          2002
long-term key: AW5uAoTSTDfG5NfY1bTh08GUnOqlRb+HVhbJ3ODJvsE=

address:       roughtime.se
port:          2002
long-term key: S3AzfZJ5CjSdkJ21ZJGbxqdYP/SoE8fXKY0+aicsehI=

address:       time.0xt.ca
port:          2002
long-term key: iBVjxg/1j7y1+kQUTBYdTabxCppesU/07D4PMDJk2WA=
          </artwork>
        </figure>
      </t>
    </section>
    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>
         Thomas Peterson corrected multiple nits. Peter L&ouml;thberg,
         Tal Mizrahi, Ragnar Sundblad, Kristof Teichel, and the other members of
         the NTP working group contributed comments and suggestions.
      </t>
    </section>

    <section anchor="IANA" title="IANA Considerations">
      <section title="Service Name and Transport Protocol Port Number Registry">
        <t>
          IANA is requested to allocate the following entry in the
          <xref target="RFC6335">Service Name and Transport Protocol
          Port Number Registry</xref>:
          <list>
            <t>Service Name: Roughtime</t>
            <t>Transport Protocol: tcp,udp</t>
            <t>Assignee: IESG &lt;iesg@ietf.org&gt;</t>
            <t>Contact: IETF Chair &lt;chair@ietf.org&gt;</t>
            <t>Description: Roughtime time synchronization</t>
            <t>Reference: [[this memo]]</t>
            <t>Port Number: [[TBD1]], selected by IANA from the User Port
              range</t>
          </list>
        </t>
      </section>
      <section title="Roughtime Version Registry">
        <t>
          IANA is requested to create a new registry entitled &quot;Roughtime
          Version Registry&quot;. Entries shall have the following fields:
          <list>
            <t>Version ID (REQUIRED): a 32-bit unsigned integer</t>
            <t>Version name (REQUIRED): A short text string naming the version
              being identified.</t>
            <t>Reference (REQUIRED): A reference to a relevant specification
              document.</t>
          </list>
          The policy for allocation of new entries SHOULD be: IETF Review.
        </t>
        <t>
          The initial contents of this registry shall be as follows:
        </t>
        <table>
          <name>Roughtime version assignments.</name>
          <tbody>
            <tr>
              <th>Version ID</th>
              <th>Version name</th>
              <th>Reference</th>
            </tr>

            <tr>
              <td>0x0</td>
              <td>Reserved</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x1</td>
              <td>Roughtime version 1</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x2-0x7fffffff</td>
              <td>Unassigned</td>
              <td></td>
            </tr>

            <tr>
              <td>0x80000000-0xffffffff</td>
              <td>Reserved for Private or Experimental use</td>
              <td>[[this memo]]</td>
            </tr>
          </tbody>
        </table>
      </section>

      <section title="Roughtime Tag Registry">
        <t>
          IANA is requested to create a new registry entitled
          &quot;Roughtime Tag Registry&quot;. Entries SHALL have
          the following fields:
          <list>
            <t>
              Tag (REQUIRED): A 32-bit unsigned integer in hexadecimal format.
            </t>
            <t>
              ASCII Representation (OPTIONAL): The ASCII representation of the
              tag in accordance with <xref target="tag"/> of this memo, if
              applicable.
            </t>
            <t>
              Reference (REQUIRED): A reference to a relevant specification
              document.
            </t>
          </list>
          The policy for allocation of new entries in this registry
          SHOULD be: Specification Required.
        </t>
        <t>
          The initial contents of this registry SHALL be as follows:
        </t>
        <table>
          <name>Roughtime tags.</name>
          <tbody>
            <tr>
              <th>Tag</th>
              <th>ASCII Representation</th>
              <th>Reference</th>
            </tr>

            <tr>
              <td>0x00444150</td>
              <td>PAD</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x00474953</td>
              <td>SIG</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x00524556</td>
              <td>VER</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x31545544</td>
              <td>DUT1</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x434e4f4e</td>
              <td>NONC</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x454c4544</td>
              <td>DELE</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x48544150</td>
              <td>PATH</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x49415444</td>
              <td>DTAI</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x49444152</td>
              <td>RADI</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x4b425550</td>
              <td>PUBK</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x5041454c</td>
              <td>LEAP</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x5044494d</td>
              <td>MIDP</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x50455253</td>
              <td>SREP</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x544e494d</td>
              <td>MINT</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x544f4f52</td>
              <td>ROOT</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x54524543</td>
              <td>CERT</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x5458414d</td>
              <td>MAXT</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x58444e49</td>
              <td>INDX</td>
              <td>[[this memo]]</td>
            </tr>

            <tr>
              <td>0x80000000-0xffffffff</td>
              <td>Reserved for Private or Experimental use</td>
              <td>[[this memo]]</td>
            </tr>
          </tbody>
        </table>
      </section>
    </section>

    <section title="Security Considerations">
      <t>
        Since the only supported signature scheme, Ed25519, is not quantum
        resistant, the Roughtime version described in this memo will not survive
        the advent of quantum computers.
      </t>
      <t>
        Maintaining a list of trusted servers and adjudicating violations of the
        rules by servers is not discussed in this document and is essential for
        security. Roughtime clients MUST regularly update their view of which
        servers are trustworthy in order to benefit from the detection of
        misbehavior.
      </t>
      <t>
        Validating timestamps made on different dates requires knowledge of leap
        seconds in order to calculate time intervals correctly.
      </t>
      <t>
        Servers carry out a significant amount of computation in response to
        clients, and thus may experience vulnerability to denial of service
        attacks.
      </t>
      <t>
        This protocol does not provide any confidentiality. Given the nature of
        timestamps such impact is minor. <xref target="sec-privacy"/> discusses
        the use of nonces generated from user-provided data.
      </t>
      <t>
        The compromise of a PUBK's private key, even past MAXT, is a problem as
        the private key can be used to sign invalid times that are in the range
        MINT to MAXT, and thus violate the good behavior guarantee of the
        server.
      </t>
      <t>
        Servers MUST NOT send UDP response packets larger than the request
        packets sent by clients, in order to prevent amplification attacks.
      </t>
    </section>

    <section title="Privacy Considerations" anchor="sec-privacy">
      <t>
        This protocol is designed to obscure all client identifiers. Servers
        necessarily have persistent long-term identities essential to enforcing
        correct behavior.
      </t>
      <t>
        Nonces are transmitted in the clear. For that reason, generating nonces
        in a nonrandom manner can cause leaks of private data or enable tracking
        of clients as they move between networks. Particular attention must be
        given when nonces are generated by hashing user-provided data. This may,
        for example, happen in timestamping applications. In such cases, the
        data SHOULD be blinded by concatenating it with a securely generated
        random string before the hash function is applied.
      </t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <reference anchor="ITU-R_TF.457-2">
        <front>
          <title>
            Use of the Modified Julian Date by the Standard-Frequency
            and Time-Signal Services
          </title>
          <author>
            <organization>
              ITU-R
            </organization>
          </author>
          <date year="1997" month="October"/>
        </front>
        <seriesInfo name="ITU-R Recommendation" value="TF.457-2"/>
      </reference>

      <reference anchor = "SHS">
        <front>
          <title>Secure Hash Standard</title>
          <author>
            <organization>
              National Institute of Standards and Technology
            </organization>
          </author>
          <date year="2015" month="August"/>
        </front>
        <seriesInfo name="DOI" value="10.6028/NIST.FIPS.180-4"/>
        <seriesInfo name="FIPS" value="180-4"/>
      </reference>
      <reference anchor="ITU-R_TF.460-6">
        <front>
          <title>
            Standard-Frequency and Time-Signal Emissions
          </title>
          <author>
            <organization>
              ITU-R
            </organization>
          </author>
          <date year="2002" month="February"/>
        </front>
        <seriesInfo name="ITU-R Recommendation" value="TF.460-6"/>
      </reference>

      <?rfc include="reference.RFC.0020.xml"?>
      <?rfc include='reference.RFC.6335.xml'?>
      <?rfc include="reference.RFC.8032.xml"?>
    </references>
    <references title="Informative References">
      <?rfc include="reference.RFC.0768.xml"?>
      <?rfc include='reference.RFC.0791.xml'?>
      <?rfc include="reference.RFC.2119.xml"?>
      <?rfc include="reference.RFC.4086.xml"?>
      <?rfc include="reference.RFC.5905.xml"?>
      <?rfc include="reference.RFC.7384.xml"?>
      <?rfc include="reference.RFC.8174.xml"?>
      <?rfc include="reference.RFC.8573.xml"?>
      <?rfc include="reference.RFC.8915.xml"?>
      <?rfc include="reference.RFC.9293.xml"?>

      <reference anchor="Autokey"
          target="https://zero-entropy.de/autokey_analysis.pdf">
        <front>
          <title>Analysis of the NTP Autokey Procedures</title>
          <author initials="S." surname="Rottger">
            <organization/>
          </author>
          <date year="2012"/>
        </front>
      </reference>

      <reference anchor="DelayAttacks"
          target="https://ieeexplore.ieee.org/document/6336612">
        <front>
          <title>
            A Game Theoretic Analysis of Delay Attacks Against Time
            Synchronization Protocols
          </title>
          <author initials="T." surname="Mizrahi" fullname="Tal Mizrahi">
            <organization/>
          </author>
          <date year="2012"/>
        </front>
        <seriesInfo name="DOI" value="10.1109/ISPCS.2012.6336612"/>
      </reference>

      <reference anchor="MCBG" target="https://eprint.iacr.org/2015/1020">
        <front>
          <title>Attacking the Network Time Protocol</title>
          <author initials="A." surname="Malhotra" fullname="A. Malhotra">
            <organization/>
          </author>
          <author initials="I." surname="Cohen" fullname="I. Cohen">
            <organization/>
          </author>
          <author initials="E." surname="Brakke" fullname="E. Brakke">
            <organization/>
          </author>
          <author initials="S." surname="Goldberg" fullname="S. Goldberg">
            <organization/>
          </author>
          <date year="2015"/>
        </front>
      </reference>
    </references>

    <section title="Terms and Abbreviations">
      <t>
        <list style="hanging">
          <t hangText="ASCII ">American Standard Code for Information
              Interchange</t>
          <t hangText="IANA  ">Internet Assigned Numbers Authority</t>
          <t hangText="MJD   ">Modified Julian Date</t>
          <t hangText="NTP   "><xref target="RFC5905">Network Time Protocol
              </xref></t>
          <t hangText="NTS   "><xref target="RFC8915">
              Network Time Security</xref></t>
          <t hangText="TAI   "><xref target="ITU-R_TF.460-6">International
              Atomic Time (Temps Atomique International)</xref></t>
          <t hangText="TCP   "><xref target="RFC9293">Transmission Control
              Protocol</xref></t>
          <t hangText="UDP   "><xref target="RFC0768">User Datagram Protocol
              </xref></t>
          <t hangText="UT    "><xref target="ITU-R_TF.460-6">Universal Time
              </xref></t>
          <t hangText="UTC   "><xref target="ITU-R_TF.460-6">Coordinated
              Universal Time</xref></t>
        </list>
      </t>
    </section>
  </back>
</rfc>
