Following a successful run of the NTS-KE protocol wherein Protocol ID 0 (NTPv4) is selected as a Next Protocol, two AEAD keys
SHALL be extracted: a client-to-server (C2S) key and a server-to-client (S2C) key. These keys
SHALL be computed with the HKDF defined in Section
7.5 of [
RFC 8446] using the following inputs:
-
The [RFC 5705] SHALL be "EXPORTER-network-time-security".
-
The [RFC 5705] SHALL consist of the following five octets:
-
The first two octets SHALL be zero (the Protocol ID for NTPv4).
-
The next two octets SHALL be the Numeric Identifier of the negotiated AEAD algorithm in network byte order.
-
The final octet SHALL be 0x00 for the C2S key and 0x01 for the S2C key.
Implementations wishing to derive additional keys for private or experimental use
MUST NOT do so by extending the above-specified syntax for per-association context values. Instead, they
SHOULD use their own disambiguating label string. Note that [
RFC 5705] provides that disambiguating label strings beginning with "EXPERIMENTAL"
MAY be used without IANA registration.
In general, an NTS-protected NTPv4 packet consists of the following:
-
The usual 48-octet NTP header, which is authenticated but not encrypted.
-
Some extension fields, which are authenticated but not encrypted.
-
An extension field that contains AEAD output (i.e., an authentication tag and possible ciphertext). The corresponding plaintext, if non-empty, consists of some extension fields that benefit from both encryption and authentication.
-
Possibly, some additional extension fields that are neither encrypted nor authenticated. In general, these are discarded by the receiver.
Always included among the authenticated or authenticated-and-encrypted extension fields are a cookie extension field and a unique identifier extension field, as described in
Section 5.7. The purpose of the cookie extension field is to enable the server to offload storage of session state onto the client. The purpose of the unique identifier extension field is to protect the client from replay attacks.
The Unique Identifier extension field provides the client with a cryptographically strong means of detecting replayed packets. It has a Field Type of 0x0104. When the extension field is included in a client packet (mode 3), its body
SHALL consist of a string of octets generated by a [
RFC 4086]. The string
MUST be at least 32 octets long. When the extension field is included in a server packet (mode 4), its body
SHALL contain the same octet string as was provided in the client packet to which the server is responding. All server packets generated by NTS-implementing servers in response to client packets containing this extension field
MUST also contain this field with the same content as in the client's request. The field's use in modes other than client-server is not defined.
This extension field
MAY also be used standalone, without NTS, in which case it provides the client with a means of detecting spoofed packets from off-path attackers. Historically, NTP's origin timestamp field has played both these roles, but this is suboptimal for cryptographic purposes because it is only 64 bits long, and depending on implementation details, most of those bits may be predictable. In contrast, the Unique Identifier extension field enables a degree of unpredictability and collision resistance more consistent with cryptographic best practice.
The NTS Cookie extension field has a Field Type of 0x0204. Its purpose is to carry information that enables the server to recompute keys and other session state without having to store any per-client state. The contents of its body
SHALL be implementation-defined, and clients
MUST NOT attempt to interpret them. See
Section 6 for a suggested construction. The NTS Cookie extension field
MUST NOT be included in NTP packets whose mode is other than 3 (client) or 4 (server).
The NTS Cookie Placeholder extension field has a Field Type of 0x0304. When this extension field is included in a client packet (mode 3), it communicates to the server that the client wishes it to send additional cookies in its response. This extension field
MUST NOT be included in NTP packets whose mode is other than 3.
Whenever an NTS Cookie Placeholder extension field is present, it
MUST be accompanied by an NTS Cookie extension field. The body length of the NTS Cookie Placeholder extension field
MUST be the same as the body length of the NTS Cookie extension field. This length requirement serves to ensure that the response will not be larger than the request, in order to improve timekeeping precision and prevent DDoS amplification. The contents of the NTS Cookie Placeholder extension field's body
SHOULD be all zeros and, aside from checking its length,
MUST be ignored by the server.
The NTS Authenticator and Encrypted Extension Fields extension field is the central cryptographic element of an NTS-protected NTP packet. Its Field Type is 0x0404. It
SHALL be formatted according to
Figure 4 and include the following fields:
-
Nonce Length:
-
Two octets in network byte order, giving the length of the Nonce field, excluding any padding, interpreted as an unsigned integer.
-
Ciphertext Length:
-
Two octets in network byte order, giving the length of the Ciphertext field, excluding any padding, interpreted as an unsigned integer.
-
Nonce:
-
A nonce as required by the negotiated AEAD algorithm. The end of the field is zero-padded to a word (four octets) boundary.
-
Ciphertext:
-
The output of the negotiated AEAD algorithm. The structure of this field is determined by the negotiated algorithm, but it typically contains an authentication tag in addition to the actual ciphertext. The end of the field is zero-padded to a word (four octets) boundary.
-
Additional Padding:
-
Clients that use a nonce length shorter than the maximum allowed by the negotiated AEAD algorithm may be required to include additional zero-padding. The necessary length of this field is specified below.
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Nonce Length | Ciphertext Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
. .
. Nonce, including up to 3 octets padding .
. .
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
. .
. Ciphertext, including up to 3 octets padding .
. .
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
. .
. Additional Padding .
. .
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The Ciphertext field
SHALL be formed by providing the following inputs to the negotiated AEAD algorithm:
-
K:
-
For packets sent from the client to the server, the C2S key SHALL be used. For packets sent from the server to the client, the S2C key SHALL be used.
-
A:
-
The associated data SHALL consist of the portion of the NTP packet beginning from the start of the NTP header and ending at the end of the last extension field that precedes the NTS Authenticator and Encrypted Extension Fields extension field.
-
P:
-
The plaintext SHALL consist of all (if any) NTP extension fields to be encrypted; if multiple extension fields are present, they SHALL be joined by concatenation. Each such field SHALL be formatted in accordance with [RFC 7822], except that, contrary to the RFC 7822 requirement that fields have a minimum length of 16 or 28 octets, encrypted extension fields MAY be arbitrarily short (but still MUST be a multiple of 4 octets in length).
-
N:
-
The nonce SHALL be formed however required by the negotiated AEAD algorithm.
The purpose of the Additional Padding field is to ensure that servers can always choose a nonce whose length is adequate to ensure its uniqueness, even if the client chooses a shorter one, and still ensure that the overall length of the server's response packet does not exceed the length of the request. For mode 4 (server) packets, no Additional Padding field is ever required. For mode 3 (client) packets, the length of the Additional Padding field
SHALL be computed as follows. Let 'N_LEN' be the padded length of the Nonce field. Let 'N_MAX' be, as specified by [
RFC 5116], the maximum permitted nonce length for the negotiated AEAD algorithm. Let 'N_REQ' be the lesser of 16 and N_MAX, rounded up to the nearest multiple of 4. If N_LEN is greater than or equal to N_REQ, then no Additional Padding field is required. Otherwise, the Additional Padding field
SHALL be at least N_REQ - N_LEN octets in length. Servers
MUST enforce this requirement by discarding any packet that does not conform to it.
Senders are always free to include more Additional Padding than mandated by the above paragraph. Theoretically, it could be necessary to do so in order to bring the extension field to the minimum length required by [
RFC 7822]. This should never happen in practice because any reasonable AEAD algorithm will have a nonce and an authenticator long enough to bring the extension field to its required length already. Nonetheless, implementers are advised to explicitly handle this case and ensure that the extension field they emit is of legal length.
The NTS Authenticator and Encrypted Extension Fields extension field
MUST NOT be included in NTP packets whose mode is other than 3 (client) or 4 (server).
A client sending an NTS-protected request
SHALL include the following extension fields as displayed in
Figure 5:
-
Exactly one Unique Identifier extension field that MUST be authenticated, MUST NOT be encrypted, and whose contents MUST be the output of a [RFC 4086].
-
Exactly one NTS Cookie extension field that MUST be authenticated and MUST NOT be encrypted. The cookie MUST be one which has been previously provided to the client, either from the key establishment server during the NTS-KE handshake or from the NTP server in response to a previous NTS-protected NTP request.
-
Exactly one NTS Authenticator and Encrypted Extension Fields extension field, generated using an AEAD algorithm and C2S key established through NTS-KE.
To protect the client's privacy, the client
SHOULD avoid reusing a cookie. If the client does not have any cookies that it has not already sent, it
SHOULD initiate a rerun of the NTS-KE protocol. The client
MAY reuse cookies in order to prioritize resilience over unlinkability. Which of the two that should be prioritized in any particular case is dependent on the application and the user's preference.
Section 9.1 describes the privacy considerations of this in further detail.
The client
MAY include one or more NTS Cookie Placeholder extension fields that
MUST be authenticated and
MAY be encrypted. The number of NTS Cookie Placeholder extension fields that the client includes
SHOULD be such that if the client includes N placeholders and the server sends back N+1 cookies, the number of unused cookies stored by the client will come to eight. The client
SHOULD NOT include more than seven NTS Cookie Placeholder extension fields in a request. When both the client and server adhere to all cookie-management guidance provided in this memo, the number of placeholder extension fields will equal the number of dropped packets since the last successful volley.
In rare circumstances, it may be necessary to include fewer NTS Cookie Placeholder extensions than recommended above in order to prevent datagram fragmentation. When cookies adhere to the format recommended in
Section 6 and the AEAD in use is the mandatory-to-implement AEAD_AES_SIV_CMAC_256, senders can include a cookie and seven placeholders and still have packet size fall comfortably below 1280 octets if no non-NTS-related extensions are used; 1280 octets is the minimum prescribed MTU for IPv6 and is generally safe for avoiding IPv4 fragmentation. Nonetheless, senders
SHOULD include fewer cookies and placeholders than otherwise indicated if doing so is necessary to prevent fragmentation.
+---------------------------------------+
| - Verify time request message. |
| - Generate time response message. |
| - Included NTPv4 extension fields: |
| o Unique Identifier EF |
| o NTS Authentication and |
| Encrypted Extension Fields EF |
| - NTS Cookie EF |
| - <NTS Cookie EF> |
| - Transmit time request packet. |
+-----------------+---------------------+
|
|
Server -----------+---------------+-----+----------------------->
^ \
/ \
Time request / \ Time response
(mode 3) / \ (mode 4)
/ \
/ V
Client -----+---------------------------------+----------------->
| |
| |
| |
+-----------+-----------------------+ +-----+------------------+
|- Generate time request message. | |- Verify time response |
| - Include NTPv4 Extension fields: | | message. |
| o Unique Identifier EF | |- Extract cookie(s). |
| o NTS Cookie EF | |- Time synchronization |
| o <NTS Cookie Placeholder EF> | | processing. |
| | +------------------------+
|- Generate AEAD tag of NTP message.|
|- Add NTS Authentication and |
| Encrypted Extension Fields EF. |
|- Transmit time request packet. |
+-----------------------------------+
The client
MAY include additional (non-NTS-related) extension fields that
MAY appear prior to the NTS Authenticator and Encrypted Extension Fields extension fields (therefore authenticated but not encrypted), within it (therefore encrypted and authenticated), or after it (therefore neither encrypted nor authenticated). The server
MUST discard any unauthenticated extension fields. Future specifications of extension fields
MAY provide exceptions to this rule.
Upon receiving an NTS-protected request, the server
SHALL (through some implementation-defined mechanism) use the cookie to recover the AEAD algorithm, C2S key, and S2C key associated with the request, and then use the C2S key to authenticate the packet and decrypt the ciphertext. If the cookie is valid and authentication and decryption succeed, the server
SHALL include the following extension fields in its response:
-
Exactly one Unique Identifier extension field that MUST be authenticated, MUST NOT be encrypted, and whose contents SHALL echo those provided by the client.
-
Exactly one NTS Authenticator and Encrypted Extension Fields extension field, generated using the AEAD algorithm and S2C key recovered from the cookie provided by the client.
-
One or more NTS Cookie extension fields that MUST be authenticated and encrypted. The number of NTS Cookie extension fields included SHOULD be equal to, and MUST NOT exceed, one plus the number of valid NTS Cookie Placeholder extension fields included in the request. The cookies returned in those fields MUST be valid for use with the NTP server that sent them. They MAY be valid for other NTP servers as well, but there is no way for the server to indicate this.
We emphasize the contrast that NTS Cookie extension fields
MUST NOT be encrypted when sent from client to server but
MUST be encrypted when sent from server to client. The former is necessary in order for the server to be able to recover the C2S and S2C keys, while the latter is necessary to satisfy the unlinkability goals discussed in
Section 9.1. We emphasize also that "encrypted" means encapsulated within the NTS Authenticator and Encrypted Extensions extension field. While the body of an NTS Cookie extension field will generally consist of some sort of AEAD output (regardless of whether the recommendations of
Section 6 are precisely followed), this is not sufficient to make the extension field "encrypted".
The server
MAY include additional (non-NTS-related) extension fields that
MAY appear prior to the NTS Authenticator and Encrypted Extension Fields extension field (therefore authenticated but not encrypted), within it (therefore encrypted and authenticated), or after it (therefore neither encrypted nor authenticated). The client
MUST discard any unauthenticated extension fields. Future specifications of extension fields
MAY provide exceptions to this rule.
Upon receiving an NTS-protected response, the client
MUST verify that the Unique Identifier matches that of an outstanding request, and that the packet is authentic under the S2C key associated with that request. If either of these checks fails, the packet
MUST be discarded without further processing. In particular, the client
MUST discard unprotected responses to NTS-protected requests.
If the server is unable to validate the cookie or authenticate the request, it
SHOULD respond with a Kiss-o'-Death (KoD) packet (see Section
7.4 of [
RFC 5905]) with kiss code "NTSN", meaning "NTS NAK" (NTS negative-acknowledgment). It
MUST NOT include any NTS Cookie or NTS Authenticator and Encrypted Extension Fields extension fields.
If the NTP server has previously responded with authentic NTS-protected NTP packets, the client
MUST verify that any KoD packets received from the server contain the Unique Identifier extension field and that the Unique Identifier matches that of an outstanding request. If this check fails, the packet
MUST be discarded without further processing. If this check passes, the client
MUST comply with Section
7.4 of [
RFC 5905] where required.
A client
MAY automatically rerun the NTS-KE protocol upon forced disassociation from an NTP server. In that case, it
MUST avoid quickly looping between the NTS-KE and NTP servers by rate limiting the retries. Requirements for retry intervals in NTS-KE are described in
Section 4.2.
Upon reception of the NTS NAK kiss code, the client
SHOULD wait until the next poll for a valid NTS-protected response, and if none is received, initiate a fresh NTS-KE handshake to try to renegotiate new cookies, AEAD keys, and parameters. If the NTS-KE handshake succeeds, the client
MUST discard all old cookies and parameters and use the new ones instead. As long as the NTS-KE handshake has not succeeded, the client
SHOULD continue polling the NTP server using the cookies and parameters it has.
To allow for NTP session restart when the NTS-KE server is unavailable and to reduce NTS-KE server load, the client
SHOULD keep at least one unused but recent cookie, AEAD keys, negotiated AEAD algorithm, and other necessary parameters in persistent storage. This way, the client is able to resume the NTP session without performing renewed NTS-KE negotiation.