Change:
Remove 1.3 references (based on Hannes's PR ); Protect CID; Initial sketch for explicit marking of CID records using ad hoc CTs.
I also do not understand that
Sorry, you're right. It needs to be in the MAC, but not the key derivation
I don't think we need to include the CID in the MAC since the CID is just the key name. In regular DTLS the 5 tuple is the key name and we don't include it in the MAC calculation either. If someone fakes a packet and places a wrong CID in there then they MAC will just fail since either (a) the wrong key will be looked up or (b) no key is found at all. In either case there is no issue.

Discussion:
Abstract <del> This document specifies the "Connection ID" concept for the Datagram Transport Layer Security (DTLS) protocol, version 1.2 and version 1.3. </del> <ins> This document specifies the Connection ID construct for the Datagram Transport Layer Security (DTLS) protocol.  I-D.ietf-tls-dtls13 specifies the Connection ID for DTLS version 1.3. </ins> A Connection ID is an identifier carried in the record layer header that gives the recipient additional information for selecting the

updated once the key lifetime expires. In the current version of DTLS, the IP address and port of the peer <del> is used to identify the DTLS association.  Unfortunately, in some </del> <ins> are used to identify the DTLS association.  Unfortunately, in some </ins> cases, such as NAT rebinding, these values are insufficient.  This is <del> a particular issue in the Internet of Things when the device needs to enter extended sleep periods to increase the battery lifetime and is therefore subject to rebinding.  This leads to connection failure, with the resulting cost of a new handshake. </del> <ins> a particular issue in the Internet of Things when devices enter extended sleep periods to increase their battery lifetime.  The NAT rebinding leads to connection failure, with the resulting cost of a new handshake. </ins> This document defines an extension to DTLS to add a connection ID to <del> each DTLS record.  The presence of the connection ID is negotiated via a DTLS extension.  It also defines a DTLS 1.3 post-handshake message to change connection ids. </del> <ins> the DTLS record layer.  The presence of the connection ID is negotiated via a DTLS extension. </ins> 2.

"OPTIONAL" in this document are to be interpreted as described in RFC 2119 RFC2119. <del> The reader is assumed to be familiar with the DTLS specifications since this document defines an extension to DTLS 1.2 and DTLS 1.3. </del> <ins> The reader is assumed to be familiar with DTLS RFC6347. </ins> 3.

The extension type is specified as follows. The extension_data field of this extension, when included in the <del> ClientHello, MUST contain the CID structure, which contains the CID </del> <ins> ClientHello, MUST contain the CID structure, which carries the CID </ins> which the client wishes the server to use when sending messages towards it.  A zero-length value indicates that the client is prepared to send with a connection ID but does not wish the server to

same). A server which is willing to use CIDs will respond with its own <del> "connection_id" extension, containing the CID which it wishes the client to use when sending messages towards it.  A zero-length value indicates that the server will send with the client's CID but does not wish the client to use a CID (or again, alternately, to use a zero-length CID). </del> <ins> "connection_id" extension, containing the CID it wishes the client to use when sending messages towards it.  A zero-length value indicates that the server will send with the client's CID but does not wish the client to use a CID (or again, alternately, to use a zero-length CID). </ins> When a session is resumed, the "connection_id" extension is negotiated afresh, not retained from previous connections in the

Previous design ideas for using cryptographically generated session ids, either using hash chains or public key encryption, were dismissed due to their inefficient designs.  Note that a client <del> always has the chance to fall-back to a full handshake or more precisely to a handshake that uses session resumption (DTLS 1.2 language) or to a PSK-based handshake using the ticket-based approach. </del> <ins> always has the chance to fall back to a full handshake or more precisely to a handshake that uses session resumption. </ins> Because each party sends in the extension_data the value that it will receive as a connection identifier in encrypted records, it is

time constant.  Note that such implementations must still be able to send other length connection identifiers to other parties. <del> In DTLS 1.2, connection ids are exchanged at the beginning of the DTLS session only.  There is no dedicated "connection id update" message that allows new connection ids to be established mid-session, because DTLS 1.2 in general does not allow post-handshake messages that do not themselves begin other handshakes.  In DTLS 1.3, which does allow such messages, we use post-handshake message to update the connection ID post-handshake-messages and to request new IDs. DTLS 1.2 peers switch to the new record layer format when encryption is enabled.  The same is true for DTLS 1.3 but since the DTLS 1.3 enables encryption early in the handshake phase the connection ID will be enabled earlier.  For this reason, the connection ID needs to go in the DTLS 1.3 ServerHello. </del> <ins> In DTLS, connection ids are exchanged at the beginning of the DTLS session only.  There is no dedicated "connection id update" message that allows new connection ids to be established mid-session, because DTLS in general does not allow TLS 1.3-style post-handshake messages that do not themselves begin other handshakes.  DTLS peers switch to the new record layer format when encryption is enabled. </ins> 4. <del> In DTLS 1.3, if the client and server have negotiated the "connection_id" extension, either side can send a new connection ID which it wishes the other side to use in a NewConnectionId message: Indicates the CID which the sender wishes the peer to use. </del> <ins> This extension is applicable for use with DTLS and dtls-record12 illustrates the record format. </ins> <del> Indicates whether the new CID should be used immediately or is a spare.  If usage is set to "cid_immediate", then the new CID MUST be used immediately for all future records.  If it is set to "cid_spare", then either CID MAY be used, as described in sec- cons. If the client and server have negotiated the "connection_id" extension, either side can request a new CID using the RequestConnectionId message. </del> <ins> Note that for both record formats, it is not possible to parse the records without knowing how long the Connection ID is. </ins> <del> Endpoints SHOULD respond to RequestConnectionId by sending a NewConnectionId with usage "cid_spare" as soon as possible.  Note that an endpoint MAY ignore requests which it considers excessive (though they MUST be ACKed as usual). </del> <ins> In order to allow a receiver to determine whether a record has CID or not, connections which have negotiated this extension use new record types for all protected records. new-cid-content-types shows the record types to use: </ins> 5. <del> This extension is applicable for use with DTLS 1.2 and DTLS 1.3. This extension can be used with the optimized DTLS 1.3 record layer format. dtls-record12 and dtls-record13 illustrate the record formats of DTLS 1.2 and DTLS 1.3, respectively. Besides the "cid" field, all other fields are defined in the DTLS 1.2 and DTLS 1.3 specifications. Note that for both record formats, it is not possible to parse the records without knowing if the connection ID is in use and how long it is. </del> <ins> The CID value, when present, is included in the MAC calculation for the DTLS record.  It is created as follows: </ins> 6. <del> Below is an example exchange for DTLS 1.3 using a single connection id in each direction. Below is an example exchange for DTLS 1.2 using a connection id used uni-directionally from the client to the server. </del> <ins> dtls-example2 shows an example exchange where a connection id used uni-directionally from the client to the server in DTLS 1.2. </ins> 7.

contain arbitrary values; implementations concerned about this SHOULD refuse to use connection ids. <del> An on-path adversary, who is able to observe the DTLS 1.2 protocol </del> <ins> An on-path adversary, who is able to observe the DTLS protocol </ins> exchanges between the DTLS client and the DTLS server, is able to link the observed payloads to all subsequent payloads carrying the <del> same connection id pair (for bi-directional communication).  In DTLS 1.3, it is possible to provide new encrypted connection IDs, though of course those IDs are immediately used on the wire.  Without multi- homing and mobility the use of the connection id is not different to the use of the 5-tuple. </del> <ins> same connection id pair (for bi-directional communication).  Without multi-homing or mobility, the use of the connection id is not different to the use of the 5-tuple. </ins> With multi-homing, an adversary is able to correlate the communication interaction over the two paths, which adds further privacy concerns.  In order to prevent this, implementations SHOULD attempt to use fresh connection IDs whenever they change local addresses or ports (though this is not always possible to detect). <del> In DTLS 1.3, The RequestConnectionId message can be used to ask for new IDs in order to ensure that you have a pool of suitable IDs. This document does not change the security properties of DTLS 1.2 RFC6347 and DTLS 1.3 I-D.ietf-tls-dtls13.  It merely provides a more robust mechanism for associating an incoming packet with a stored security context. </del> <ins> This document does not change the security properties of DTLS RFC6347.  It merely provides a more robust mechanism for associating an incoming packet with a stored security context. </ins> [[OPEN ISSUE: Sequence numbers leak connection IDs.  We need to update the document to address this.  One possibility would be the

"ExtensionType Values" registry, defined in RFC5246, for connection_id(TBD) defined in this document. <del> IANA is requested to allocate two values in the "TLS Handshake Type" registry, defined in RFC5246, for request_connection_id (TBD), and new_connection_id (TBD), as defined in this document. </del> <ins> IANA is requested to allocate the following new values in the "TLS ContentType Registry": alert_with_cid(25) handshake_with_cid(26) application_data_with_cid(27) heartbeat_with_cid(28) </ins>