idnits 2.17.1 draft-ietf-lake-edhoc-06.txt: -(2416): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(2560): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- == There are 5 instances of lines with non-ascii characters in the document. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** There are 2 instances of too long lines in the document, the longest one being 3 characters in excess of 72. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (21 April 2021) is 1100 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '6' on line 1656 -- Looks like a reference, but probably isn't: '5' on line 1656 -- Looks like a reference, but probably isn't: '9' on line 1652 -- Looks like a reference, but probably isn't: '8' on line 1656 -- Looks like a reference, but probably isn't: '7' on line 1656 ** Downref: Normative reference to an Informational RFC: RFC 5869 ** Downref: Normative reference to an Informational RFC: RFC 6090 ** Downref: Normative reference to an Informational RFC: RFC 6979 ** Downref: Normative reference to an Informational RFC: RFC 7748 ** Downref: Normative reference to an Informational RFC: RFC 8376 == Outdated reference: A later version (-15) exists of draft-ietf-cose-rfc8152bis-struct-14 -- Possible downref: Normative reference to a draft: ref. 'I-D.ietf-cose-rfc8152bis-struct' ** Downref: Normative reference to an Informational draft: draft-ietf-cose-rfc8152bis-algs (ref. 'I-D.ietf-cose-rfc8152bis-algs') == Outdated reference: A later version (-09) exists of draft-ietf-cose-x509-08 == Outdated reference: A later version (-14) exists of draft-ietf-core-echo-request-tag-11 ** Downref: Normative reference to an Informational draft: draft-ietf-lake-reqs (ref. 'I-D.ietf-lake-reqs') == Outdated reference: A later version (-28) exists of draft-ietf-core-resource-directory-26 == Outdated reference: A later version (-07) exists of draft-ietf-lwig-security-protocol-comparison-05 == Outdated reference: A later version (-43) exists of draft-ietf-tls-dtls13-40 == Outdated reference: A later version (-05) exists of draft-selander-ace-ake-authz-02 == Outdated reference: A later version (-11) exists of draft-ietf-core-oscore-edhoc-00 == Outdated reference: A later version (-08) exists of draft-mattsson-cose-cbor-cert-compress-06 == Outdated reference: A later version (-04) exists of draft-mattsson-cfrg-det-sigs-with-noise-02 Summary: 8 errors (**), 0 flaws (~~), 12 warnings (==), 7 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group G. Selander 3 Internet-Draft J. Mattsson 4 Intended status: Standards Track F. Palombini 5 Expires: 23 October 2021 Ericsson AB 6 21 April 2021 8 Ephemeral Diffie-Hellman Over COSE (EDHOC) 9 draft-ietf-lake-edhoc-06 11 Abstract 13 This document specifies Ephemeral Diffie-Hellman Over COSE (EDHOC), a 14 very compact and lightweight authenticated Diffie-Hellman key 15 exchange with ephemeral keys. EDHOC provides mutual authentication, 16 perfect forward secrecy, and identity protection. EDHOC is intended 17 for usage in constrained scenarios and a main use case is to 18 establish an OSCORE security context. By reusing COSE for 19 cryptography, CBOR for encoding, and CoAP for transport, the 20 additional code size can be kept very low. 22 Status of This Memo 24 This Internet-Draft is submitted in full conformance with the 25 provisions of BCP 78 and BCP 79. 27 Internet-Drafts are working documents of the Internet Engineering 28 Task Force (IETF). Note that other groups may also distribute 29 working documents as Internet-Drafts. The list of current Internet- 30 Drafts is at https://datatracker.ietf.org/drafts/current/. 32 Internet-Drafts are draft documents valid for a maximum of six months 33 and may be updated, replaced, or obsoleted by other documents at any 34 time. It is inappropriate to use Internet-Drafts as reference 35 material or to cite them other than as "work in progress." 37 This Internet-Draft will expire on 23 October 2021. 39 Copyright Notice 41 Copyright (c) 2021 IETF Trust and the persons identified as the 42 document authors. All rights reserved. 44 This document is subject to BCP 78 and the IETF Trust's Legal 45 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 46 license-info) in effect on the date of publication of this document. 47 Please review these documents carefully, as they describe your rights 48 and restrictions with respect to this document. Code Components 49 extracted from this document must include Simplified BSD License text 50 as described in Section 4.e of the Trust Legal Provisions and are 51 provided without warranty as described in the Simplified BSD License. 53 Table of Contents 55 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 56 1.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . 4 57 1.2. Use of EDHOC . . . . . . . . . . . . . . . . . . . . . . 5 58 1.3. Message Size Examples . . . . . . . . . . . . . . . . . . 6 59 1.4. Document Structure . . . . . . . . . . . . . . . . . . . 6 60 1.5. Terminology and Requirements Language . . . . . . . . . . 6 61 2. EDHOC Outline . . . . . . . . . . . . . . . . . . . . . . . . 7 62 3. Protocol Elements . . . . . . . . . . . . . . . . . . . . . . 9 63 3.1. General . . . . . . . . . . . . . . . . . . . . . . . . . 9 64 3.2. Method and Correlation . . . . . . . . . . . . . . . . . 10 65 3.2.1. Method . . . . . . . . . . . . . . . . . . . . . . . 10 66 3.2.2. Connection Identifiers . . . . . . . . . . . . . . . 10 67 3.2.3. Transport . . . . . . . . . . . . . . . . . . . . . . 11 68 3.2.4. Message Correlation . . . . . . . . . . . . . . . . . 11 69 3.3. Authentication Parameters . . . . . . . . . . . . . . . . 11 70 3.3.1. Authentication Keys . . . . . . . . . . . . . . . . . 12 71 3.3.2. Identities . . . . . . . . . . . . . . . . . . . . . 12 72 3.3.3. Authentication Credentials . . . . . . . . . . . . . 13 73 3.3.4. Identification of Credentials . . . . . . . . . . . . 14 74 3.4. Cipher Suites . . . . . . . . . . . . . . . . . . . . . . 16 75 3.5. Ephemeral Public Keys . . . . . . . . . . . . . . . . . . 17 76 3.6. Auxiliary Data . . . . . . . . . . . . . . . . . . . . . 18 77 3.7. Applicability Statement . . . . . . . . . . . . . . . . . 18 78 4. Key Derivation . . . . . . . . . . . . . . . . . . . . . . . 20 79 4.1. EDHOC-Exporter Interface . . . . . . . . . . . . . . . . 22 80 5. Message Formatting and Processing . . . . . . . . . . . . . . 22 81 5.1. Encoding of bstr_identifier . . . . . . . . . . . . . . . 23 82 5.2. Message Processing Outline . . . . . . . . . . . . . . . 23 83 5.3. EDHOC Message 1 . . . . . . . . . . . . . . . . . . . . . 24 84 5.3.1. Formatting of Message 1 . . . . . . . . . . . . . . . 24 85 5.3.2. Initiator Processing of Message 1 . . . . . . . . . . 25 86 5.3.3. Responder Processing of Message 1 . . . . . . . . . . 26 87 5.4. EDHOC Message 2 . . . . . . . . . . . . . . . . . . . . . 26 88 5.4.1. Formatting of Message 2 . . . . . . . . . . . . . . . 27 89 5.4.2. Responder Processing of Message 2 . . . . . . . . . . 27 90 5.4.3. Initiator Processing of Message 2 . . . . . . . . . . 29 91 5.5. EDHOC Message 3 . . . . . . . . . . . . . . . . . . . . . 29 92 5.5.1. Formatting of Message 3 . . . . . . . . . . . . . . . 30 93 5.5.2. Initiator Processing of Message 3 . . . . . . . . . . 30 94 5.5.3. Responder Processing of Message 3 . . . . . . . . . . 32 95 6. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 33 96 6.1. Success . . . . . . . . . . . . . . . . . . . . . . . . . 34 97 6.2. Unspecified . . . . . . . . . . . . . . . . . . . . . . . 34 98 6.3. Wrong Selected Cipher Suite . . . . . . . . . . . . . . . 35 99 6.3.1. Cipher Suite Negotiation . . . . . . . . . . . . . . 35 100 6.3.2. Examples . . . . . . . . . . . . . . . . . . . . . . 35 101 7. Transferring EDHOC and Deriving an OSCORE Context . . . . . . 37 102 7.1. EDHOC Message 4 . . . . . . . . . . . . . . . . . . . . . 37 103 7.1.1. Formatting of Message 4 . . . . . . . . . . . . . . . 37 104 7.1.2. Responder Processing of Message 4 . . . . . . . . . . 38 105 7.1.3. Initiator Processing of Message 4 . . . . . . . . . . 38 106 7.2. Transferring EDHOC in CoAP . . . . . . . . . . . . . . . 39 107 7.2.1. Deriving an OSCORE Context from EDHOC . . . . . . . . 41 108 7.2.2. Error Messages with CoAP Transport . . . . . . . . . 42 109 8. Security Considerations . . . . . . . . . . . . . . . . . . . 42 110 8.1. Security Properties . . . . . . . . . . . . . . . . . . . 42 111 8.2. Cryptographic Considerations . . . . . . . . . . . . . . 44 112 8.3. Cipher Suites and Cryptographic Algorithms . . . . . . . 45 113 8.4. Unprotected Data . . . . . . . . . . . . . . . . . . . . 46 114 8.5. Denial-of-Service . . . . . . . . . . . . . . . . . . . . 46 115 8.6. Implementation Considerations . . . . . . . . . . . . . . 46 116 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 48 117 9.1. EDHOC Cipher Suites Registry . . . . . . . . . . . . . . 48 118 9.2. EDHOC Method Type Registry . . . . . . . . . . . . . . . 49 119 9.3. EDHOC Error Codes Registry . . . . . . . . . . . . . . . 50 120 9.4. The Well-Known URI Registry . . . . . . . . . . . . . . . 50 121 9.5. Media Types Registry . . . . . . . . . . . . . . . . . . 50 122 9.6. CoAP Content-Formats Registry . . . . . . . . . . . . . . 51 123 9.7. Expert Review Instructions . . . . . . . . . . . . . . . 51 124 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 52 125 10.1. Normative References . . . . . . . . . . . . . . . . . . 52 126 10.2. Informative References . . . . . . . . . . . . . . . . . 54 127 Appendix A. Use of CBOR, CDDL and COSE in EDHOC . . . . . . . . 56 128 A.1. CBOR and CDDL . . . . . . . . . . . . . . . . . . . . . . 57 129 A.2. CDDL Definitions . . . . . . . . . . . . . . . . . . . . 57 130 A.3. COSE . . . . . . . . . . . . . . . . . . . . . . . . . . 59 131 Appendix B. Test Vectors . . . . . . . . . . . . . . . . . . . . 59 132 B.1. Test Vectors for EDHOC Authenticated with Signature Keys 133 (x5t) . . . . . . . . . . . . . . . . . . . . . . . . . . 60 134 B.1.1. Message_1 . . . . . . . . . . . . . . . . . . . . . . 60 135 B.1.2. Message_2 . . . . . . . . . . . . . . . . . . . . . . 61 136 B.1.3. Message_3 . . . . . . . . . . . . . . . . . . . . . . 69 137 B.1.4. OSCORE Security Context Derivation . . . . . . . . . 75 138 B.2. Test Vectors for EDHOC Authenticated with Static 139 Diffie-Hellman Keys . . . . . . . . . . . . . . . . . . . 77 140 B.2.1. Message_1 . . . . . . . . . . . . . . . . . . . . . . 78 141 B.2.2. Message_2 . . . . . . . . . . . . . . . . . . . . . . 79 142 B.2.3. Message_3 . . . . . . . . . . . . . . . . . . . . . . 85 143 B.2.4. OSCORE Security Context Derivation . . . . . . . . . 90 144 Appendix C. Applicability Template . . . . . . . . . . . . . . . 92 145 Appendix D. EDHOC Message Deduplication . . . . . . . . . . . . 93 146 Appendix E. Change Log . . . . . . . . . . . . . . . . . . . . . 94 147 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 96 148 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 97 150 1. Introduction 152 1.1. Motivation 154 Many Internet of Things (IoT) deployments require technologies which 155 are highly performant in constrained environments [RFC7228]. IoT 156 devices may be constrained in various ways, including memory, 157 storage, processing capacity, and power. The connectivity for these 158 settings may also exhibit constraints such as unreliable and lossy 159 channels, highly restricted bandwidth, and dynamic topology. The 160 IETF has acknowledged this problem by standardizing a range of 161 lightweight protocols and enablers designed for the IoT, including 162 the Constrained Application Protocol (CoAP, [RFC7252]), Concise 163 Binary Object Representation (CBOR, [RFC8949]), and Static Context 164 Header Compression (SCHC, [RFC8724]). 166 The need for special protocols targeting constrained IoT deployments 167 extends also to the security domain [I-D.ietf-lake-reqs]. Important 168 characteristics in constrained environments are the number of round 169 trips and protocol message sizes, which if kept low can contribute to 170 good performance by enabling transport over a small number of radio 171 frames, reducing latency due to fragmentation or duty cycles, etc. 172 Another important criteria is code size, which may be prohibitive for 173 certain deployments due to device capabilities or network load during 174 firmware update. Some IoT deployments also need to support a variety 175 of underlying transport technologies, potentially even with a single 176 connection. 178 Some security solutions for such settings exist already. CBOR Object 179 Signing and Encryption (COSE, [I-D.ietf-cose-rfc8152bis-struct]) 180 specifies basic application-layer security services efficiently 181 encoded in CBOR. Another example is Object Security for Constrained 182 RESTful Environments (OSCORE, [RFC8613]) which is a lightweight 183 communication security extension to CoAP using CBOR and COSE. In 184 order to establish good quality cryptographic keys for security 185 protocols such as COSE and OSCORE, the two endpoints may run an 186 authenticated Diffie-Hellman key exchange protocol, from which shared 187 secret key material can be derived. Such a key exchange protocol 188 should also be lightweight; to prevent bad performance in case of 189 repeated use, e.g., due to device rebooting or frequent rekeying for 190 security reasons; or to avoid latencies in a network formation 191 setting with many devices authenticating at the same time. 193 This document specifies Ephemeral Diffie-Hellman Over COSE (EDHOC), a 194 lightweight authenticated key exchange protocol providing good 195 security properties including perfect forward secrecy, identity 196 protection, and cipher suite negotiation. Authentication can be 197 based on raw public keys (RPK) or public key certificates, and 198 requires the application to provide input on how to verify that 199 endpoints are trusted. This specification focuses on referencing 200 instead of transporting credentials to reduce message overhead. 202 EDHOC makes use of known protocol constructions, such as SIGMA 203 [SIGMA] and Extract-and-Expand [RFC5869]. COSE also provides crypto 204 agility and enables the use of future algorithms targeting IoT. 206 1.2. Use of EDHOC 208 EDHOC is designed for highly constrained settings making it 209 especially suitable for low-power wide area networks [RFC8376] such 210 as Cellular IoT, 6TiSCH, and LoRaWAN. A main objective for EDHOC is 211 to be a lightweight authenticated key exchange for OSCORE, i.e. to 212 provide authentication and session key establishment for IoT use 213 cases such as those built on CoAP [RFC7252]. CoAP is a specialized 214 web transfer protocol for use with constrained nodes and networks, 215 providing a request/response interaction model between application 216 endpoints. As such, EDHOC is targeting a large variety of use cases 217 involving 'things' with embedded microcontrollers, sensors, and 218 actuators. 220 A typical setting is when one of the endpoints is constrained or in a 221 constrained network, and the other endpoint is a node on the Internet 222 (such as a mobile phone) or at the edge of the constrained network 223 (such as a gateway). Thing-to-thing interactions over constrained 224 networks are also relevant since both endpoints would then benefit 225 from the lightweight properties of the protocol. EDHOC could e.g. be 226 run when a device connects for the first time, or to establish fresh 227 keys which are not revealed by a later compromise of the long-term 228 keys. Further security properties are described in Section 8.1. 230 EDHOC enables the reuse of the same lightweight primitives as OSCORE: 231 CBOR for encoding, COSE for cryptography, and CoAP for transport. By 232 reusing existing libraries the additional code size can be kept very 233 low. Note that, while CBOR and COSE primitives are built into the 234 protocol messages, EDHOC is not bound to a particular transport. 235 However, it is recommended to transfer EDHOC messages in CoAP 236 payloads as is detailed in Section 7.2. 238 1.3. Message Size Examples 240 Compared to the DTLS 1.3 handshake [I-D.ietf-tls-dtls13] with ECDHE 241 and connection ID, the number of bytes in EDHOC + CoAP can be less 242 than 1/6 when RPK authentication is used, see 243 [I-D.ietf-lwig-security-protocol-comparison]. Figure 1 shows two 244 examples of message sizes for EDHOC with different kinds of 245 authentication keys and different COSE header parameters for 246 identification: static Diffie-Hellman keys identified by 'kid' 247 [I-D.ietf-cose-rfc8152bis-struct], and X.509 signature certificates 248 identified by a hash value using 'x5t' [I-D.ietf-cose-x509]. 250 ================================= 251 kid x5t 252 --------------------------------- 253 message_1 37 37 254 message_2 46 117 255 message_3 20 91 256 --------------------------------- 257 Total 103 245 258 ================================= 260 Figure 1: Example of message sizes in bytes. 262 1.4. Document Structure 264 The remainder of the document is organized as follows: Section 2 265 outlines EDHOC authenticated with digital signatures, Section 3 266 describes the protocol elements of EDHOC, including message flow, and 267 formatting of the ephemeral public keys, Section 4 describes the key 268 derivation, Section 5 specifies EDHOC with authentication based on 269 signature keys or static Diffie-Hellman keys, Section 6 specifies the 270 EDHOC error message, and Section 7 describes how EDHOC can be 271 transferred in CoAP and used to establish an OSCORE security context. 273 1.5. Terminology and Requirements Language 275 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 276 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 277 "OPTIONAL" in this document are to be interpreted as described in BCP 278 14 [RFC2119] [RFC8174] when, and only when, they appear in all 279 capitals, as shown here. 281 Readers are expected to be familiar with the terms and concepts 282 described in CBOR [RFC8949], CBOR Sequences [RFC8742], COSE 283 structures and process [I-D.ietf-cose-rfc8152bis-struct], COSE 284 algorithms [I-D.ietf-cose-rfc8152bis-algs], and CDDL [RFC8610]. The 285 Concise Data Definition Language (CDDL) is used to express CBOR data 286 structures [RFC8949]. Examples of CBOR and CDDL are provided in 287 Appendix A.1. When referring to CBOR, this specification always 288 refer to Deterministically Encoded CBOR as specified in Sections 289 4.2.1 and 4.2.2 of [RFC8949]. 291 The single output from authenticated encryption (including the 292 authentication tag) is called 'ciphertext', following [RFC5116]. 294 2. EDHOC Outline 296 EDHOC specifies different authentication methods of the Diffie- 297 Hellman key exchange: digital signatures and static Diffie-Hellman 298 keys. This section outlines the digital signature based method. 299 Further details of protocol elements and other authentication methods 300 are provided in the remainder of this document. 302 SIGMA (SIGn-and-MAc) is a family of theoretical protocols with a 303 large number of variants [SIGMA]. Like IKEv2 [RFC7296] and (D)TLS 304 1.3 [RFC8446], EDHOC authenticated with digital signatures is built 305 on a variant of the SIGMA protocol which provides identity protection 306 of the initiator (SIGMA-I), and like IKEv2 [RFC7296], EDHOC 307 implements the SIGMA-I variant as MAC-then-Sign. The SIGMA-I 308 protocol using an authenticated encryption algorithm is shown in 309 Figure 2. 311 Initiator Responder 312 | G_X | 313 +-------------------------------------------------------->| 314 | | 315 | G_Y, AEAD( K_2; ID_CRED_R, Sig(R; CRED_R, G_X, G_Y) ) | 316 |<--------------------------------------------------------+ 317 | | 318 | AEAD( K_3; ID_CRED_I, Sig(I; CRED_I, G_Y, G_X) ) | 319 +-------------------------------------------------------->| 320 | | 322 Figure 2: Authenticated encryption variant of the SIGMA-I protocol. 324 The parties exchanging messages are called Initiator (I) and 325 Responder (R). They exchange ephemeral public keys, compute a shared 326 secret, and derive symmetric application keys used to protect 327 application data. 329 * G_X and G_Y are the ECDH ephemeral public keys of I and R, 330 respectively. 332 * CRED_I and CRED_R are the credentials containing the public 333 authentication keys of I and R, respectively. 335 * ID_CRED_I and ID_CRED_R are credential identifiers enabling the 336 recipient party to retrieve the credential of I and R, 337 respectively. 339 * Sig(I; . ) and Sig(R; . ) denote signatures made with the private 340 authentication key of I and R, respectively. 342 * AEAD(K; . ) denotes authenticated encryption with additional data 343 using a key K derived from the shared secret. 345 In order to create a "full-fledged" protocol some additional protocol 346 elements are needed. EDHOC adds: 348 * Explicit connection identifiers C_I, C_R chosen by I and R, 349 respectively, enabling the recipient to find the protocol state. 351 * Transcript hashes (hashes of message data) TH_2, TH_3, TH_4 used 352 for key derivation and as additional authenticated data. 354 * Computationally independent keys derived from the ECDH shared 355 secret and used for authenticated encryption of different 356 messages. 358 * An optional fourth message giving explicit key confirmation to I 359 in deployments where no protected application data is sent from R 360 to I. 362 * A key material exporter and a key update function enabling 363 frequent forward secrecy. 365 * Verification of a common preferred cipher suite: 367 - The Initiator lists supported cipher suites in order of 368 preference 370 - The Responder verifies that the selected cipher suite is the 371 first supported cipher suite (or else rejects and states 372 supported cipher suites). 374 * Method types and error handling. 376 * Transport of opaque auxiliary data. 378 EDHOC is designed to encrypt and integrity protect as much 379 information as possible, and all symmetric keys are derived using as 380 much previous information as possible. EDHOC is furthermore designed 381 to be as compact and lightweight as possible, in terms of message 382 sizes, processing, and the ability to reuse already existing CBOR, 383 COSE, and CoAP libraries. 385 To simplify for implementors, the use of CBOR and COSE in EDHOC is 386 summarized in Appendix A and test vectors including CBOR diagnostic 387 notation are given in Appendix B. 389 3. Protocol Elements 391 3.1. General 393 An EDHOC message flow consists of three mandatory messages 394 (message_1, message_2, message_3) between Initiator and Responder, an 395 optional fourth message (message_4), plus an EDHOC error message. 396 EDHOC messages are CBOR Sequences [RFC8742], see Figure 3. The 397 protocol elements in the figure are introduced in the following 398 sections. Message formatting and processing is specified in 399 Section 5 and Section 6. An implementation may support only 400 Initiator or only Responder. 402 Application data is protected using the agreed application algorithms 403 (AEAD, hash) in the selected cipher suite (see Section 3.4) and the 404 application can make use of the established connection identifiers 405 C_1, C_I, and C_R (see Section 3.2.4). EDHOC may be used with the 406 media type application/edhoc defined in Section 9. 408 The Initiator can derive symmetric application keys after creating 409 EDHOC message_3, see Section 4.1. Application protected data can 410 therefore be sent in parallel or together with EDHOC message_3. 412 Initiator Responder 413 | C_1, METHOD_CORR, SUITES_I, G_X, C_I, AD_1 | 414 +------------------------------------------------------------------>| 415 | message_1 | 416 | | 417 | C_I, G_Y, C_R, Enc(ID_CRED_R, Signature_or_MAC_2, AD_2) | 418 |<------------------------------------------------------------------+ 419 | message_2 | 420 | | 421 | C_R, AEAD(K_3ae; ID_CRED_I, Signature_or_MAC_3, AD_3) | 422 +------------------------------------------------------------------>| 423 | message_3 | 425 Figure 3: EDHOC Message Flow 427 3.2. Method and Correlation 429 The data item METHOD_CORR in message_1 (see Section 5.3.1), is an 430 integer specifying the method and the correlation properties of the 431 transport, which are described in this section. 433 3.2.1. Method 435 EDHOC supports authentication with signature or static Diffie-Hellman 436 keys, as defined in the four authentication methods: 0, 1, 2, and 3, 437 see Figure 4. (Method 0 corresponds to the case outlined in 438 Section 2 where both Initiator and Responder authenticate with 439 signature keys.) 441 An implementation may support only a single method. The Initiator 442 and the Responder need to have agreed on a single method to be used 443 for EDHOC, see Section 3.7. 445 +-------+-------------------+-------------------+-------------------+ 446 | Value | Initiator | Responder | Reference | 447 +-------+-------------------+-------------------+-------------------+ 448 | 0 | Signature Key | Signature Key | [[this document]] | 449 | 1 | Signature Key | Static DH Key | [[this document]] | 450 | 2 | Static DH Key | Signature Key | [[this document]] | 451 | 3 | Static DH Key | Static DH Key | [[this document]] | 452 +-------+-------------------+-------------------+-------------------+ 454 Figure 4: Method Types 456 3.2.2. Connection Identifiers 458 EDHOC includes optional connection identifiers (C_1, C_I, C_R). The 459 connection identifiers C_1, C_I, and C_R do not have any 460 cryptographic purpose in EDHOC. They contain information 461 facilitating retrieval of the protocol state and may therefore be 462 very short. C_1 is always set to "null", while C_I and C_R are 463 chosen by I and R, respectively. One byte connection identifiers are 464 realistic in many scenarios as most constrained devices only have a 465 few connections. In cases where a node only has one connection, the 466 identifiers may even be the empty byte string. 468 The connection identifier MAY be used with an application protocol 469 (e.g. OSCORE) for which EDHOC establishes keys, in which case the 470 connection identifiers SHALL adhere to the requirements for that 471 protocol. Each party choses a connection identifier it desires the 472 other party to use in outgoing messages. (For OSCORE this results in 473 the endpoint selecting its Recipient ID, see Section 3.1 of 474 [RFC8613]). 476 3.2.3. Transport 478 Cryptographically, EDHOC does not put requirements on the lower 479 layers. EDHOC is not bound to a particular transport layer, and can 480 be used in environments without IP. The transport is responsible to 481 handle message loss, reordering, message duplication, fragmentation, 482 and denial of service protection, where necessary. 484 The Initiator and the Responder need to have agreed on a transport to 485 be used for EDHOC, see Section 3.7. It is recommended to transport 486 EDHOC in CoAP payloads, see Section 7. 488 3.2.4. Message Correlation 490 If the whole transport path provides a mechanism for correlating 491 messages received with messages previously sent, then some of the 492 connection identifiers may be omitted. There are four cases: 494 * corr = 0, the transport does not provide a correlation mechanism. 496 * corr = 1, the transport provides a correlation mechanism that 497 enables the Responder to correlate message_2 and message_1 as well 498 as message_4 and message_3. 500 * corr = 2, the transport provides a correlation mechanism that 501 enables the Initiator to correlate message_3 and message_2. 503 * corr = 3, the transport provides a correlation mechanism that 504 enables both parties to correlate all three messages. 506 For example, if the key exchange is transported over CoAP, the CoAP 507 Token can be used to correlate messages, see Section 7.2. 509 3.3. Authentication Parameters 510 3.3.1. Authentication Keys 512 The authentication key MUST be a signature key or static Diffie- 513 Hellman key. The Initiator and the Responder MAY use different types 514 of authentication keys, e.g. one uses a signature key and the other 515 uses a static Diffie-Hellman key. When using a signature key, the 516 authentication is provided by a signature. When using a static 517 Diffie-Hellman key the authentication is provided by a Message 518 Authentication Code (MAC) computed from an ephemeral-static ECDH 519 shared secret which enables significant reductions in message sizes. 520 The MAC is implemented with an AEAD algorithm. When using static 521 Diffie-Hellman keys the Initiator's and Responder's private 522 authentication keys are called I and R, respectively, and the public 523 authentication keys are called G_I and G_R, respectively. 525 * Only the Responder SHALL have access to the Responder's private 526 authentication key. 528 * Only the Initiator SHALL have access to the Initiator's private 529 authentication key. 531 3.3.2. Identities 533 EDHOC assumes the existence of mechanisms (certification authority, 534 trusted third party, manual distribution, etc.) for specifying and 535 distributing authentication keys and identities. Policies are set 536 based on the identity of the other party, and parties typically only 537 allow connections from a specific identity or a small restricted set 538 of identities. For example, in the case of a device connecting to a 539 network, the network may only allow connections from devices which 540 authenticate with certificates having a particular range of serial 541 numbers in the subject field and signed by a particular CA. On the 542 other side, the device may only be allowed to connect to a network 543 which authenticates with a particular public key (information of 544 which may be provisioned, e.g., out of band or in the Auxiliary Data, 545 see Section 3.6). 547 The EDHOC implementation must be able to receive and enforce 548 information from the application about what is the intended endpoint, 549 and in particular whether it is a specific identity or a set of 550 identities. 552 * When a Public Key Infrastructure (PKI) is used, the trust anchor 553 is a Certification Authority (CA) certificate, and the identity is 554 the subject whose unique name (e.g. a domain name, NAI, or EUI) is 555 included in the endpoint's certificate. Before running EDHOC each 556 party needs at least one CA public key certificate, or just the 557 public key, and a specific identity or set of identities it is 558 allowed to communicate with. Only validated public-key 559 certificates with an allowed subject name, as specified by the 560 application, are to be accepted. EDHOC provides proof that the 561 other party possesses the private authentication key corresponding 562 to the public authentication key in its certificate. The 563 certification path provides proof that the subject of the 564 certificate owns the public key in the certificate. 566 * When public keys are used but not with a PKI (RPK, self-signed 567 certificate), the trust anchor is the public authentication key of 568 the other party. In this case, the identity is typically directly 569 associated to the public authentication key of the other party. 570 For example, the name of the subject may be a canonical 571 representation of the public key. Alternatively, if identities 572 can be expressed in the form of unique subject names assigned to 573 public keys, then a binding to identity can be achieved by 574 including both public key and associated subject name in the 575 protocol message computation: CRED_I or CRED_R may be a self- 576 signed certificate or COSE_Key containing the public 577 authentication key and the subject name, see Section 3.3.3. 578 Before running EDHOC, each endpoint needs a specific public 579 authentication key/unique associated subject name, or a set of 580 public authentication keys/unique associated subject names, which 581 it is allowed to communicate with. EDHOC provides proof that the 582 other party possesses the private authentication key corresponding 583 to the public authentication key. 585 3.3.3. Authentication Credentials 587 The authentication credentials, CRED_I and CRED_R, contain the public 588 authentication key of the Initiator and the Responder, respectively. 589 The Initiator and the Responder MAY use different types of 590 credentials, e.g. one uses an RPK and the other uses a public key 591 certificate. 593 The credentials CRED_I and CRED_R are signed or MAC:ed (depending on 594 method) by the Initiator and the Responder, respectively, see 595 Section 5.5 and Section 5.4. 597 When the credential is a certificate, CRED_x is an end-entity 598 certificate (i.e. not the certificate chain) encoded as a CBOR bstr. 599 In X.509 certificates, signature keys typically have key usage 600 "digitalSignature" and Diffie-Hellman keys typically have key usage 601 "keyAgreement". 603 To prevent misbinding attacks in systems where an attacker can 604 register public keys without proving knowledge of the private key, 605 SIGMA [SIGMA] enforces a MAC to be calculated over the "Identity", 606 which in case of a X.509 certificate would be the 'subject' and 607 'subjectAltName' fields. EDHOC follows SIGMA by calculating a MAC 608 over the whole certificate. While the SIGMA paper only focuses on 609 the identity, the same principle is true for any information such as 610 policies connected to the public key. 612 When the credential is a COSE_Key, CRED_x is a CBOR map only 613 containing specific fields from the COSE_Key identifying the public 614 key, and optionally the "Identity". CRED_x needs to be defined such 615 that it is identical when generated by Initiator or Responder. The 616 parameters SHALL be encoded in bytewise lexicographic order of their 617 deterministic encodings as specified in Section 4.2.1 of [RFC8949]. 619 If the parties have agreed on an identity besides the public key, the 620 identity is included in the CBOR map with the label "subject name", 621 otherwise the subject name is the empty text string. The public key 622 parameters depend on key type. 624 * For COSE_Keys of type OKP the CBOR map SHALL, except for subject 625 name, only include the parameters 1 (kty), -1 (crv), and -2 626 (x-coordinate). 628 * For COSE_Keys of type EC2 the CBOR map SHALL, except for subject 629 name, only include the parameters 1 (kty), -1 (crv), -2 630 (x-coordinate), and -3 (y-coordinate). 632 An example of CRED_x when the RPK contains an X25519 static Diffie- 633 Hellman key and the parties have agreed on an EUI-64 identity is 634 shown below: 636 CRED_x = { 637 1: 1, 638 -1: 4, 639 -2: h'b1a3e89460e88d3a8d54211dc95f0b90 640 3ff205eb71912d6db8f4af980d2db83a', 641 "subject name" : "42-50-31-FF-EF-37-32-39" 642 } 644 3.3.4. Identification of Credentials 646 ID_CRED_I and ID_CRED_R are identifiers of the public authentication 647 keys of the Initiator and the Responder, respectively. ID_CRED_I and 648 ID_CRED_R do not have any cryptographic purpose in EDHOC. 650 * ID_CRED_R is intended to facilitate for the Initiator to retrieve 651 the Responder's public authentication key. 653 * ID_CRED_I is intended to facilitate for the Responder to retrieve 654 the Initiator's public authentication key. 656 The identifiers ID_CRED_I and ID_CRED_R are COSE header_maps, i.e. 657 CBOR maps containing Common COSE Header Parameters, see Section 3.1 658 of [I-D.ietf-cose-rfc8152bis-struct]). In the following we give some 659 examples of COSE header_maps. 661 Raw public keys are most optimally stored as COSE_Key objects and 662 identified with a 'kid' parameter: 664 * ID_CRED_x = { 4 : kid_x }, where kid_x : bstr, for x = I or R. 666 Public key certificates can be identified in different ways. Header 667 parameters for identifying C509 certificates and X.509 certificates 668 are defined in [I-D.mattsson-cose-cbor-cert-compress] and 669 [I-D.ietf-cose-x509], for example: 671 * by a hash value with the 'c5t' or 'x5t' parameters; 673 - ID_CRED_x = { 34 : COSE_CertHash }, for x = I or R, 675 - ID_CRED_x = { TDB3 : COSE_CertHash }, for x = I or R, 677 * by a URI with the 'c5u' or 'x5u' parameters; 679 - ID_CRED_x = { 35 : uri }, for x = I or R, 681 - ID_CRED_x = { TBD4 : uri }, for x = I or R, 683 * ID_CRED_x MAY contain the actual credential used for 684 authentication, CRED_x. For example, a certificate chain can be 685 transported in ID_CRED_x with COSE header parameter c5c or 686 x5chain, defined in [I-D.mattsson-cose-cbor-cert-compress] and 687 [I-D.ietf-cose-x509]. 689 It is RECOMMENDED that ID_CRED_x uniquely identify the public 690 authentication key as the recipient may otherwise have to try several 691 keys. ID_CRED_I and ID_CRED_R are transported in the 'ciphertext', 692 see Section 5.5 and Section 5.4. 694 When ID_CRED_x does not contain the actual credential it may be very 695 short. One byte credential identifiers are realistic in many 696 scenarios as most constrained devices only have a few keys. In cases 697 where a node only has one key, the identifier may even be the empty 698 byte string. 700 3.4. Cipher Suites 702 An EDHOC cipher suite consists of an ordered set of COSE code points 703 from the "COSE Algorithms" and "COSE Elliptic Curves" registries: 705 * EDHOC AEAD algorithm 707 * EDHOC hash algorithm 709 * EDHOC ECDH curve 711 * EDHOC signature algorithm 713 * EDHOC signature algorithm curve 715 * Application AEAD algorithm 717 * Application hash algorithm 719 Each cipher suite is identified with a pre-defined int label. 721 EDHOC can be used with all algorithms and curves defined for COSE. 722 Implementation can either use one of the pre-defined cipher suites 723 (Section 9.1) or use any combination of COSE algorithms to define 724 their own private cipher suite. Private cipher suites can be 725 identified with any of the four values -24, -23, -22, -21. 727 The following cipher suites are for constrained IoT where message 728 overhead is a very important factor: 730 0. ( 10, -16, 4, -8, 6, 10, -16 ) 731 (AES-CCM-16-64-128, SHA-256, X25519, EdDSA, Ed25519, 732 AES-CCM-16-64-128, SHA-256) 734 1. ( 30, -16, 4, -8, 6, 10, -16 ) 735 (AES-CCM-16-128-128, SHA-256, X25519, EdDSA, Ed25519, 736 AES-CCM-16-64-128, SHA-256) 738 2. ( 10, -16, 1, -7, 1, 10, -16 ) 739 (AES-CCM-16-64-128, SHA-256, P-256, ES256, P-256, 740 AES-CCM-16-64-128, SHA-256) 742 3. ( 30, -16, 1, -7, 1, 10, -16 ) 743 (AES-CCM-16-128-128, SHA-256, P-256, ES256, P-256, 744 AES-CCM-16-64-128, SHA-256) 746 The following cipher suite is for general non-constrained 747 applications. It uses very high performance algorithms that also are 748 widely supported: 750 4. ( 1, -16, 4, -7, 1, 1, -16 ) 751 (A128GCM, SHA-256, X25519, ES256, P-256, 752 A128GCM, SHA-256) 754 The following cipher suite is for high security application such as 755 government use and financial applications. It is compatible with the 756 CNSA suite [CNSA]. 758 5. ( 3, -43, 2, -35, 2, 3, -43 ) 759 (A256GCM, SHA-384, P-384, ES384, P-384, 760 A256GCM, SHA-384) 762 The different methods use the same cipher suites, but some algorithms 763 are not used in some methods. The EDHOC signature algorithm and the 764 EDHOC signature algorithm curve are not used in methods without 765 signature authentication. 767 The Initiator needs to have a list of cipher suites it supports in 768 order of preference. The Responder needs to have a list of cipher 769 suites it supports. SUITES_I is a CBOR array containing cipher 770 suites that the Initiator supports. SUITES_I is formatted and 771 processed as detailed in Section 5.3.1 to secure the cipher suite 772 negotiation. Examples of cipher suite negotiation are given in 773 Section 6.3.2. 775 3.5. Ephemeral Public Keys 777 The ECDH ephemeral public keys are formatted as a COSE_Key of type 778 EC2 or OKP according to Sections 7.1 and 7.2 of 779 [I-D.ietf-cose-rfc8152bis-algs], but only the 'x' parameter is 780 included G_X and G_Y. For Elliptic Curve Keys of type EC2, compact 781 representation as per [RFC6090] MAY be used also in the COSE_Key. If 782 the COSE implementation requires an 'y' parameter, any of the 783 possible values of the y-coordinate can be used, see Appendix C of 784 [RFC6090]. COSE always use compact output for Elliptic Curve Keys of 785 type EC2. 787 3.6. Auxiliary Data 789 In order to reduce round trips and number of messages, and in some 790 cases also streamline processing, certain security applications may 791 be integrated into EDHOC by transporting auxiliary data together with 792 the messages. One example is the transport of third-party 793 authorization information protected outside of EDHOC 794 [I-D.selander-ace-ake-authz]. Another example is the embedding of a 795 certificate enrolment request or a newly issued certificate. 797 EDHOC allows opaque auxiliary data (AD) to be sent in the EDHOC 798 messages. Unprotected Auxiliary Data (AD_1, AD_2) may be sent in 799 message_1 and message_2, respectively. Protected Auxiliary Data 800 (AD_3) may be sent in message_3. 802 Since data carried in AD_1 and AD_2 may not be protected, and the 803 content of AD_3 is available to both the Initiator and the Responder, 804 special considerations need to be made such that the availability of 805 the data a) does not violate security and privacy requirements of the 806 service which uses this data, and b) does not violate the security 807 properties of EDHOC. 809 3.7. Applicability Statement 811 EDHOC requires certain parameters to be agreed upon between Initiator 812 and Responder. Some parameters can be agreed through the protocol 813 execution (specifically cipher suite negotiation, see Section 3.4) 814 but other parameters may need to be known out-of-band (e.g., which 815 authentication method is used, see Section 3.2.1). 817 The purpose of the applicability statement is describe the intended 818 use of EDHOC to allow for the relevant processing and verifications 819 to be made, including things like: 821 1. How the endpoint detects that an EDHOC message is received. This 822 includes how EDHOC messages are transported, for example in the 823 payload of a CoAP message with a certain Uri-Path or Content- 824 Format; see Section 7.2. 826 2. Method and correlation of underlying transport messages 827 (METHOD_CORR; see Section 3.2.1 and Section 3.2.4). This gives 828 information about the optional connection identifier fields. 830 3. How message_1 is identified, in particular if the optional 831 initial C_1 = "null" of message_1 is present; see Section 5.3.1 833 4. Authentication credentials (CRED_I, CRED_R; see Section 3.3.3). 835 5. Type used to identify authentication credentials (ID_CRED_I, 836 ID_CRED_R; see Section 3.3.4). 838 6. Use and type of Auxiliary Data (AD_1, AD_2, AD_3; see 839 Section 3.6). 841 7. Identifier used as identity of endpoint; see Section 3.3.2. 843 8. If message_4 shall be sent/expected, and if not, how to ensure a 844 protected application message is sent from the Responder to the 845 Initiator; see Section 7.1. 847 The applicability statement may also contain information about 848 supported cipher suites. The procedure for selecting and verifying 849 cipher suite is still performed as specified by the protocol, but it 850 may become simplified by this knowledge. 852 An example of an applicability statement is shown in Appendix C. 854 For some parameters, like METHOD_CORR, ID_CRED_x, type of AD_x, the 855 receiver is able to verify compliance with applicability statement, 856 and if it needs to fail because of incompliance, to infer the reason 857 why the protocol failed. 859 For other parameters, like CRED_x in the case that it is not 860 transported, it may not be possible to verify that incompliance with 861 applicability statement was the reason for failure: Integrity 862 verification in message_2 or message_3 may fail not only because of 863 wrong authentication credential. For example, in case the Initiator 864 uses public key certificate by reference (i.e. not transported within 865 the protocol) then both endpoints need to use an identical data 866 structure as CRED_I or else the integrity verification will fail. 868 Note that it is not necessary for the endpoints to specify a single 869 transport for the EDHOC messages. For example, a mix of CoAP and 870 HTTP may be used along the path, and this may still allow correlation 871 between messages. 873 The applicability statement may be dependent on the identity of the 874 other endpoint, but this applies only to the later phases of the 875 protocol when identities are known. (Initiator does not know 876 identity of Responder before having verified message_2, and Responder 877 does not know identity of Initiator before having verified 878 message_3.) 880 Other conditions may be part of the applicability statement, such as 881 target application or use (if there is more than one application/use) 882 to the extent that EDHOC can distinguish between them. In case 883 multiple applicability statements are used, the receiver needs to be 884 able to determine which is applicable for a given protocol instance, 885 for example based on URI or Auxiliary Data type. 887 4. Key Derivation 889 EDHOC uses Extract-and-Expand [RFC5869] with the EDHOC hash algorithm 890 in the selected cipher suite to derive keys used in EDHOC and in the 891 application. Extract is used to derive fixed-length uniformly 892 pseudorandom keys (PRK) from ECDH shared secrets. Expand is used to 893 derive additional output keying material (OKM) from the PRKs. The 894 PRKs are derived using Extract. 896 PRK = Extract( salt, IKM ) 898 If the EDHOC hash algorithm is SHA-2, then Extract( salt, IKM ) = 899 HKDF-Extract( salt, IKM ) [RFC5869]. If the EDHOC hash algorithm is 900 SHAKE128, then Extract( salt, IKM ) = KMAC128( salt, IKM, 256, "" ). 901 If the EDHOC hash algorithm is SHAKE256, then Extract( salt, IKM ) = 902 KMAC256( salt, IKM, 512, "" ). 904 PRK_2e is used to derive a keystream to encrypt message_2. PRK_3e2m 905 is used to derive keys and IVs to produce a MAC in message_2 and to 906 encrypt message_3. PRK_4x3m is used to derive keys and IVs to 907 produce a MAC in message_3 and to derive application specific data. 909 PRK_2e is derived with the following input: 911 * The salt SHALL be the empty byte string. Note that [RFC5869] 912 specifies that if the salt is not provided, it is set to a string 913 of zeros (see Section 2.2 of [RFC5869]). For implementation 914 purposes, not providing the salt is the same as setting the salt 915 to the empty byte string. 917 * The input keying material (IKM) SHALL be the ECDH shared secret 918 G_XY (calculated from G_X and Y or G_Y and X) as defined in 919 Section 6.3.1 of [I-D.ietf-cose-rfc8152bis-algs]. 921 Example: Assuming the use of SHA-256 the extract phase of HKDF 922 produces PRK_2e as follows: 924 PRK_2e = HMAC-SHA-256( salt, G_XY ) 926 where salt = 0x (the empty byte string). 928 The pseudorandom keys PRK_3e2m and PRK_4x3m are defined as follow: 930 * If the Responder authenticates with a static Diffie-Hellman key, 931 then PRK_3e2m = Extract( PRK_2e, G_RX ), where G_RX is the ECDH 932 shared secret calculated from G_R and X, or G_X and R, else 933 PRK_3e2m = PRK_2e. 935 * If the Initiator authenticates with a static Diffie-Hellman key, 936 then PRK_4x3m = Extract( PRK_3e2m, G_IY ), where G_IY is the ECDH 937 shared secret calculated from G_I and Y, or G_Y and I, else 938 PRK_4x3m = PRK_3e2m. 940 Example: Assuming the use of curve25519, the ECDH shared secrets 941 G_XY, G_RX, and G_IY are the outputs of the X25519 function 942 [RFC7748]: 944 G_XY = X25519( Y, G_X ) = X25519( X, G_Y ) 946 The keys and IVs used in EDHOC are derived from PRK using Expand 947 [RFC5869] where the EDHOC-KDF is instantiated with the EDHOC AEAD 948 algorithm in the selected cipher suite. 950 OKM = EDHOC-KDF( PRK, transcript_hash, label, length ) 951 = Expand( PRK, info, length ) 953 where info is the CBOR encoding of 955 info = [ 956 edhoc_aead_id : int / tstr, 957 transcript_hash : bstr, 958 label : tstr, 959 length : uint 960 ] 962 where 964 * edhoc_aead_id is an int or tstr containing the algorithm 965 identifier of the EDHOC AEAD algorithm in the selected cipher 966 suite encoded as defined in [I-D.ietf-cose-rfc8152bis-algs]. Note 967 that a single fixed edhoc_aead_id is used in all invocations of 968 EDHOC-KDF, including the derivation of KEYSTREAM_2 and invocations 969 of the EDHOC-Exporter. 971 * transcript_hash is a bstr set to one of the transcript hashes 972 TH_2, TH_3, or TH_4 as defined in Sections 5.4.1, 5.5.1, and 4.1. 974 * label is a tstr set to the name of the derived key or IV, i.e. 975 "K_2m", "IV_2m", "KEYSTREAM_2", "K_3m", "IV_3m", "K_3ae", or 976 "IV_3ae". 978 * length is the length of output keying material (OKM) in bytes 980 If the EDHOC hash algorithm is SHA-2, then Expand( PRK, info, length 981 ) = HKDF-Expand( PRK, info, length ) [RFC5869]. If the EDHOC hash 982 algorithm is SHAKE128, then Expand( PRK, info, length ) = KMAC128( 983 PRK, info, L, "" ). If the EDHOC hash algorithm is SHAKE256, then 984 Expand( PRK, info, length ) = KMAC256( PRK, info, L, "" ). 986 KEYSTREAM_2 are derived using the transcript hash TH_2 and the 987 pseudorandom key PRK_2e. K_2m and IV_2m are derived using the 988 transcript hash TH_2 and the pseudorandom key PRK_3e2m. K_3ae and 989 IV_3ae are derived using the transcript hash TH_3 and the 990 pseudorandom key PRK_3e2m. K_3m and IV_3m are derived using the 991 transcript hash TH_3 and the pseudorandom key PRK_4x3m. IVs are only 992 used if the EDHOC AEAD algorithm uses IVs. 994 4.1. EDHOC-Exporter Interface 996 Application keys and other application specific data can be derived 997 using the EDHOC-Exporter interface defined as: 999 EDHOC-Exporter(label, length) 1000 = EDHOC-KDF(PRK_4x3m, TH_4, label, length) 1002 where label is a tstr defined by the application and length is a uint 1003 defined by the application. The label SHALL be different for each 1004 different exporter value. The transcript hash TH_4 is a CBOR encoded 1005 bstr and the input to the hash function is a CBOR Sequence. 1007 TH_4 = H( TH_3, CIPHERTEXT_3 ) 1009 where H() is the hash function in the selected cipher suite. Example 1010 use of the EDHOC-Exporter is given in Sections 7.2.1. 1012 To provide forward secrecy in an even more efficient way than re- 1013 running EDHOC, EDHOC provides the function EDHOC-KeyUpdate. When 1014 EDHOC-KeyUpdate is called the old PRK_4x3m is deleted and the new 1015 PRk_4x3m is calculated as a "hash" of the old key using the Extract 1016 function as illustrated by the following pseudocode: 1018 EDHOC-KeyUpdate( nonce ): 1019 PRK_4x3m = Extract( nonce, PRK_4x3m ) 1021 5. Message Formatting and Processing 1023 This section specifies formatting of the messages and processing 1024 steps. Error messages are specified in Section 6. 1026 An EDHOC message is encoded as a sequence of CBOR data (CBOR 1027 Sequence, [RFC8742]). Additional optimizations are made to reduce 1028 message overhead. 1030 While EDHOC uses the COSE_Key, COSE_Sign1, and COSE_Encrypt0 1031 structures, only a subset of the parameters is included in the EDHOC 1032 messages. The unprotected COSE header in COSE_Sign1, and 1033 COSE_Encrypt0 (not included in the EDHOC message) MAY contain 1034 parameters (e.g. 'alg'). 1036 5.1. Encoding of bstr_identifier 1038 Byte strings are encoded in CBOR as two or more bytes, whereas 1039 integers in the interval -24 to 23 are encoded in CBOR as one byte. 1041 bstr_identifier is a special encoding of byte strings, used 1042 throughout the protocol to enable the encoding of the shortest byte 1043 strings as integers that only require one byte of CBOR encoding. 1045 The bstr_identifier encoding is defined as follows: Byte strings in 1046 the interval h'00' to h'2f' are encoded as the corresponding integer 1047 minus 24, which are all represented by one byte CBOR ints. Other 1048 byte strings are encoded as CBOR byte strings. 1050 For example, the byte string h'59e9' encoded as a bstr_identifier is 1051 equal to h'59e9', while the byte string h'2a' is encoded as the 1052 integer 18. 1054 The CDDL definition of the bstr_identifier is given below: 1056 bstr_identifier = bstr / int 1058 Note that, despite what could be interpreted by the CDDL definition 1059 only, bstr_identifier once decoded are always byte strings. 1061 5.2. Message Processing Outline 1063 This section outlines the message processing of EDHOC. 1065 For each protocol instance, the endpoints are assumed to keep an 1066 associated protocol state containing connection identifiers, keys, 1067 etc. used for subsequent processing of protocol related data. The 1068 protocol state is assumed to be associated to an applicability 1069 statement (Section 3.7) which provides the context for how messages 1070 are transported, identified and processed. 1072 EDHOC messages SHALL be processed according to the current protocol 1073 state. The following steps are expected to be performed at reception 1074 of an EDHOC message: 1076 1. Detect that an EDHOC message has been received, for example by 1077 means of port number, URI, or media type (Section 3.7). 1079 2. Retrieve the protocol state, e.g. using the received connection 1080 identifier (Section 3.2.2) or with the help of message 1081 correlation provided by the transport protocol (Section 3.2.4). 1082 If there is no protocol state, in the case of message_1, a new 1083 protocol state is created. An initial C_1 = "null" byte in 1084 message_1 (Section 5.3.1) can be used to distinguish message_1 1085 from other messages. The Responder endpoint needs to make use of 1086 available Denial-of-Service mitigation (Section 8.5). 1088 3. If the message received is an error message then process 1089 according to Section 6, else process as the expected next message 1090 according to the protocol state. 1092 If the processing fails, then the protocol is discontinued, an error 1093 message sent, and the protocol state erased. Further details are 1094 provided in the following subsections. 1096 Different instances of the same message MUST NOT be processed in one 1097 protocol instance. Note that processing will fail if the same 1098 message appears a second time for EDHOC processing because the state 1099 of the protocol has moved on and now expects something else. This 1100 assumes that message duplication due to re-transmissions is handled 1101 by the transport protocol, see Section 3.2.3. The case when the 1102 transport does not support message deduplication is addressed in 1103 Appendix D. 1105 5.3. EDHOC Message 1 1107 5.3.1. Formatting of Message 1 1109 message_1 SHALL be a CBOR Sequence (see Appendix A.1) as defined 1110 below 1111 message_1 = ( 1112 ? C_1 : null, 1113 METHOD_CORR : int, 1114 SUITES_I : [ selected : suite, supported : 2* suite ] / suite, 1115 G_X : bstr, 1116 C_I : bstr_identifier, 1117 ? AD_1 : bstr, 1118 ) 1120 suite = int 1122 where: 1124 * C_1 - an initial CBOR simple value "null" (= 0xf6) MAY be used to 1125 distinguish message_1 from other messages. 1127 * METHOD_CORR = 4 * method + corr, where method = 0, 1, 2, or 3 (see 1128 Figure 4) and the correlation parameter corr is chosen based on 1129 the transport and determines which connection identifiers that are 1130 omitted (see Section 3.2.4). 1132 * SUITES_I - cipher suites which the Initiator supports in order of 1133 (decreasing) preference. The list of supported cipher suites can 1134 be truncated at the end, as is detailed in the processing steps 1135 below and Section 6.3. One of the supported cipher suites is 1136 selected. The selected suite is the first suite in the SUITES_I 1137 CBOR array. If a single supported cipher suite is conveyed then 1138 that cipher suite is selected and SUITES_I is encoded as an int 1139 instead of an array. 1141 * G_X - the ephemeral public key of the Initiator 1143 * C_I - variable length connection identifier, encoded as a 1144 bstr_identifier (see Section 5.1). 1146 * AD_1 - bstr containing unprotected opaque auxiliary data 1148 5.3.2. Initiator Processing of Message 1 1150 The Initiator SHALL compose message_1 as follows: 1152 * The supported cipher suites and the order of preference MUST NOT 1153 be changed based on previous error messages. However, the list 1154 SUITES_I sent to the Responder MAY be truncated such that cipher 1155 suites which are the least preferred are omitted. The amount of 1156 truncation MAY be changed between sessions, e.g. based on previous 1157 error messages (see next bullet), but all cipher suites which are 1158 more preferred than the least preferred cipher suite in the list 1159 MUST be included in the list. 1161 * The Initiator MUST select its most preferred cipher suite, 1162 conditioned on what it can assume to be supported by the 1163 Responder. If the Initiator previously received from the 1164 Responder an error message with error code 1 (see Section 6.3) 1165 indicating cipher suites supported by the Responder which also are 1166 supported by the Initiator, then the Initiator SHOULD select the 1167 most preferred cipher suite of those (note that error messages are 1168 not authenticated and may be forged). 1170 * Generate an ephemeral ECDH key pair as specified in Section 5 of 1171 [SP-800-56A] using the curve in the selected cipher suite and 1172 format it as a COSE_Key. Let G_X be the 'x' parameter of the 1173 COSE_Key. 1175 * Choose a connection identifier C_I and store it for the length of 1176 the protocol. 1178 * Encode message_1 as a sequence of CBOR encoded data items as 1179 specified in Section 5.3.1 1181 5.3.3. Responder Processing of Message 1 1183 The Responder SHALL process message_1 as follows: 1185 * Decode message_1 (see Appendix A.1). 1187 * Verify that the selected cipher suite is supported and that no 1188 prior cipher suite in SUITES_I is supported. 1190 * Pass AD_1 to the security application. 1192 If any verification step fails, the Responder MUST send an EDHOC 1193 error message back, formatted as defined in Section 6, and the 1194 protocol MUST be discontinued. 1196 5.4. EDHOC Message 2 1197 5.4.1. Formatting of Message 2 1199 message_2 and data_2 SHALL be CBOR Sequences (see Appendix A.1) as 1200 defined below 1202 message_2 = ( 1203 data_2, 1204 CIPHERTEXT_2 : bstr, 1205 ) 1207 data_2 = ( 1208 ? C_I : bstr_identifier, 1209 G_Y : bstr, 1210 C_R : bstr_identifier, 1211 ) 1213 where: 1215 * G_Y - the ephemeral public key of the Responder 1217 * C_R - variable length connection identifier, encoded as a 1218 bstr_identifier (see Section 5.1). 1220 5.4.2. Responder Processing of Message 2 1222 The Responder SHALL compose message_2 as follows: 1224 * If corr (METHOD_CORR mod 4) equals 1 or 3, C_I is omitted, 1225 otherwise C_I is not omitted. 1227 * Generate an ephemeral ECDH key pair as specified in Section 5 of 1228 [SP-800-56A] using the curve in the selected cipher suite and 1229 format it as a COSE_Key. Let G_Y be the 'x' parameter of the 1230 COSE_Key. 1232 * Choose a connection identifier C_R and store it for the length of 1233 the protocol. 1235 * Compute the transcript hash TH_2 = H(message_1, data_2) where H() 1236 is the hash function in the selected cipher suite. The transcript 1237 hash TH_2 is a CBOR encoded bstr and the input to the hash 1238 function is a CBOR Sequence. 1240 * Compute an inner COSE_Encrypt0 as defined in Section 5.3 of 1241 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1242 in the selected cipher suite, K_2m, IV_2m, and the following 1243 parameters: 1245 - protected = << ID_CRED_R >> 1247 o ID_CRED_R - identifier to facilitate retrieval of CRED_R, 1248 see Section 3.3.4 1250 - external_aad = << TH_2, CRED_R, ? AD_2 >> 1252 o CRED_R - bstr containing the credential of the Responder, 1253 see Section 3.3.4. 1255 o AD_2 = bstr containing opaque unprotected auxiliary data 1257 - plaintext = h'' 1259 COSE constructs the input to the AEAD [RFC5116] as follows: 1261 - Key K = EDHOC-KDF( PRK_3e2m, TH_2, "K_2m", length ) 1263 - Nonce N = EDHOC-KDF( PRK_3e2m, TH_2, "IV_2m", length ) 1265 - Plaintext P = 0x (the empty string) 1267 - Associated data A = 1269 [ "Encrypt0", << ID_CRED_R >>, << TH_2, CRED_R, ? AD_2 >> ] 1271 MAC_2 is the 'ciphertext' of the inner COSE_Encrypt0. 1273 * If the Responder authenticates with a static Diffie-Hellman key 1274 (method equals 1 or 3), then Signature_or_MAC_2 is MAC_2. If the 1275 Responder authenticates with a signature key (method equals 0 or 1276 2), then Signature_or_MAC_2 is the 'signature' of a COSE_Sign1 1277 object as defined in Section 4.4 of 1278 [I-D.ietf-cose-rfc8152bis-struct] using the signature algorithm in 1279 the selected cipher suite, the private authentication key of the 1280 Responder, and the following parameters: 1282 - protected = << ID_CRED_R >> 1284 - external_aad = << TH_2, CRED_R, ? AD_2 >> 1286 - payload = MAC_2 1288 COSE constructs the input to the Signature Algorithm as: 1290 - The key is the private authentication key of the Responder. 1292 - The message M to be signed = 1294 [ "Signature1", << ID_CRED_R >>, << TH_2, CRED_R, ? AD_2 >>, 1295 MAC_2 ] 1297 * CIPHERTEXT_2 is encrypted by using the Expand function as a binary 1298 additive stream cipher. 1300 - plaintext = ( ID_CRED_R / bstr_identifier, Signature_or_MAC_2, 1301 ? AD_2 ) 1303 o Note that if ID_CRED_R contains a single 'kid' parameter, 1304 i.e., ID_CRED_R = { 4 : kid_R }, only the byte string kid_R 1305 is conveyed in the plaintext encoded as a bstr_identifier, 1306 see Section 3.3.4 and Section 5.1. 1308 - CIPHERTEXT_2 = plaintext XOR KEYSTREAM_2 1310 * Encode message_2 as a sequence of CBOR encoded data items as 1311 specified in Section 5.4.1. 1313 5.4.3. Initiator Processing of Message 2 1315 The Initiator SHALL process message_2 as follows: 1317 * Decode message_2 (see Appendix A.1). 1319 * Retrieve the protocol state using the connection identifier C_I 1320 and/or other external information such as the CoAP Token and the 1321 5-tuple. 1323 * Decrypt CIPHERTEXT_2, see Section 5.4.2. 1325 * Verify that the identity of the Responder is an allowed identity 1326 for this connection, see Section 3.3. 1328 * Verify Signature_or_MAC_2 using the algorithm in the selected 1329 cipher suite. The verification process depends on the method, see 1330 Section 5.4.2. 1332 * Pass AD_2 to the security application. 1334 If any verification step fails, the Initiator MUST send an EDHOC 1335 error message back, formatted as defined in Section 6, and the 1336 protocol MUST be discontinued. 1338 5.5. EDHOC Message 3 1339 5.5.1. Formatting of Message 3 1341 message_3 and data_3 SHALL be CBOR Sequences (see Appendix A.1) as 1342 defined below 1344 message_3 = ( 1345 data_3, 1346 CIPHERTEXT_3 : bstr, 1347 ) 1349 data_3 = ( 1350 ? C_R : bstr_identifier, 1351 ) 1353 5.5.2. Initiator Processing of Message 3 1355 The Initiator SHALL compose message_3 as follows: 1357 * If corr (METHOD_CORR mod 4) equals 2 or 3, C_R is omitted, 1358 otherwise C_R is not omitted. 1360 * Compute the transcript hash TH_3 = H(TH_2 , CIPHERTEXT_2, data_3) 1361 where H() is the hash function in the selected cipher suite. The 1362 transcript hash TH_3 is a CBOR encoded bstr and the input to the 1363 hash function is a CBOR Sequence. 1365 * Compute an inner COSE_Encrypt0 as defined in Section 5.3 of 1366 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1367 in the selected cipher suite, K_3m, IV_3m, and the following 1368 parameters: 1370 - protected = << ID_CRED_I >> 1372 o ID_CRED_I - identifier to facilitate retrieval of CRED_I, 1373 see Section 3.3.4 1375 - external_aad = << TH_3, CRED_I, ? AD_3 >> 1377 o CRED_I - bstr containing the credential of the Initiator, 1378 see Section 3.3.4. 1380 o AD_3 = bstr containing opaque protected auxiliary data 1382 - plaintext = h'' 1384 COSE constructs the input to the AEAD [RFC5116] as follows: 1386 - Key K = EDHOC-KDF( PRK_4x3m, TH_3, "K_3m", length ) 1387 - Nonce N = EDHOC-KDF( PRK_4x3m, TH_3, "IV_3m", length ) 1389 - Plaintext P = 0x (the empty string) 1391 - Associated data A = 1393 [ "Encrypt0", << ID_CRED_I >>, << TH_3, CRED_I, ? AD_3 >> ] 1395 MAC_3 is the 'ciphertext' of the inner COSE_Encrypt0. 1397 * If the Initiator authenticates with a static Diffie-Hellman key 1398 (method equals 2 or 3), then Signature_or_MAC_3 is MAC_3. If the 1399 Initiator authenticates with a signature key (method equals 0 or 1400 1), then Signature_or_MAC_3 is the 'signature' of a COSE_Sign1 1401 object as defined in Section 4.4 of 1402 [I-D.ietf-cose-rfc8152bis-struct] using the signature algorithm in 1403 the selected cipher suite, the private authentication key of the 1404 Initiator, and the following parameters: 1406 - protected = << ID_CRED_I >> 1408 - external_aad = << TH_3, CRED_I, ? AD_3 >> 1410 - payload = MAC_3 1412 COSE constructs the input to the Signature Algorithm as: 1414 - The key is the private authentication key of the Initiator. 1416 - The message M to be signed = 1418 [ "Signature1", << ID_CRED_I >>, << TH_3, CRED_I, ? AD_3 >>, 1419 MAC_3 ] 1421 * Compute an outer COSE_Encrypt0 as defined in Section 5.3 of 1422 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1423 in the selected cipher suite, K_3ae, IV_3ae, and the following 1424 parameters. The protected header SHALL be empty. 1426 - external_aad = TH_3 1428 - plaintext = ( ID_CRED_I / bstr_identifier, Signature_or_MAC_3, 1429 ? AD_3 ) 1431 o Note that if ID_CRED_I contains a single 'kid' parameter, 1432 i.e., ID_CRED_I = { 4 : kid_I }, only the byte string kid_I 1433 is conveyed in the plaintext encoded as a bstr_identifier, 1434 see Section 3.3.4 and Section 5.1. 1436 COSE constructs the input to the AEAD [RFC5116] as follows: 1438 - Key K = EDHOC-KDF( PRK_3e2m, TH_3, "K_3ae", length ) 1440 - Nonce N = EDHOC-KDF( PRK_3e2m, TH_3, "IV_3ae", length ) 1442 - Plaintext P = ( ID_CRED_I / bstr_identifier, 1443 Signature_or_MAC_3, ? AD_3 ) 1445 - Associated data A = [ "Encrypt0", h'', TH_3 ] 1447 CIPHERTEXT_3 is the 'ciphertext' of the outer COSE_Encrypt0. 1449 * Encode message_3 as a sequence of CBOR encoded data items as 1450 specified in Section 5.5.1. 1452 Pass the connection identifiers (C_I, C_R) and the application 1453 algorithms in the selected cipher suite to the application. The 1454 application can now derive application keys using the EDHOC-Exporter 1455 interface. 1457 After sending message_3, the Initiator is assured that no other party 1458 than the Responder can compute the key PRK_4x3m (implicit key 1459 authentication). The Initiator does however not know that the 1460 Responder has actually computed the key PRK_4x3m. While the 1461 Initiator can securely send protected application data, the Initiator 1462 SHOULD NOT permanently store the keying material PRK_4x3m and TH_4 1463 until the Initiator is assured that the Responder has actually 1464 computed the key PRK_4x3m (explicit key confirmation). Explicit key 1465 confirmation is e.g. assured when the Initiator has verified an 1466 OSCORE message or message_4 from the Responder. 1468 5.5.3. Responder Processing of Message 3 1470 The Responder SHALL process message_3 as follows: 1472 * Decode message_3 (see Appendix A.1). 1474 * Retrieve the protocol state using the connection identifier C_R 1475 and/or other external information such as the CoAP Token and the 1476 5-tuple. 1478 * Decrypt and verify the outer COSE_Encrypt0 as defined in 1479 Section 5.3 of [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC 1480 AEAD algorithm in the selected cipher suite, K_3ae, and IV_3ae. 1482 * Verify that the identity of the Initiator is an allowed identity 1483 for this connection, see Section 3.3. 1485 * Verify Signature_or_MAC_3 using the algorithm in the selected 1486 cipher suite. The verification process depends on the method, see 1487 Section 5.5.2. 1489 * Pass AD_3, the connection identifiers (C_I, C_R), and the 1490 application algorithms in the selected cipher suite to the 1491 security application. The application can now derive application 1492 keys using the EDHOC-Exporter interface. 1494 If any verification step fails, the Responder MUST send an EDHOC 1495 error message back, formatted as defined in Section 6, and the 1496 protocol MUST be discontinued. 1498 After verifying message_3, the Responder is assured that the 1499 Initiator has calculated the key PRK_4x3m (explicit key confirmation) 1500 and that no other party than the Responder can compute the key. The 1501 Responder can securely send protected application data and store the 1502 keying material PRK_4x3m and TH_4. 1504 6. Error Handling 1506 This section defines the format for error messages. 1508 An EDHOC error message can be sent by either endpoint as a reply to 1509 any non-error EDHOC message. How errors at the EDHOC layer are 1510 transported depends on lower layers, which need to enable error 1511 messages to be sent and processed as intended. 1513 All error messages in EDHOC are fatal. After sending an error 1514 message, the sender MUST discontinue the protocol. The receiver 1515 SHOULD treat an error message as an indication that the other party 1516 likely has discontinued the protocol. But as the error message is 1517 not authenticated, a received error messages might also have been 1518 sent by an attacker and the receiver MAY therefore try to continue 1519 the protocol. 1521 error SHALL be a CBOR Sequence (see Appendix A.1) as defined below 1523 error = ( 1524 ? C_x : bstr_identifier, 1525 ERR_CODE : int, 1526 ERR_INFO : any 1527 ) 1529 Figure 5: EDHOC Error Message 1531 where: 1533 * C_x - (optional) variable length connection identifier, encoded as 1534 a bstr_identifier (see Section 5.1). If error is sent by the 1535 Responder and corr (METHOD_CORR mod 4) equals 0 or 2 then C_x is 1536 set to C_I, else if error is sent by the Initiator and corr 1537 (METHOD_CORR mod 4) equals 0 or 1 then C_x is set to C_R, else C_x 1538 is omitted. 1540 * ERR_CODE - error code encoded as an integer. 1542 * ERR_INFO - error information. Content and encoding depend on 1543 error code. 1545 The remainder of this section specifies the currently defined error 1546 codes, see Figure 6. Error codes 1, 0 and -1 MUST be supported. 1547 Additional error codes and corresponding error information may be 1548 specified. 1550 +----------+---------------+----------------------------------------+ 1551 | ERR_CODE | ERR_INFO Type | Description | 1552 +==========+===============+========================================+ 1553 | -1 | TBD | Success | 1554 +----------+---------------+----------------------------------------+ 1555 | 0 | tstr | Unspecified | 1556 +----------+---------------+----------------------------------------+ 1557 | 1 | SUITES_R | Wrong selected cipher suite | 1558 +----------+---------------+----------------------------------------+ 1560 Figure 6: Error Codes and Error Information 1562 6.1. Success 1564 TBD 1566 6.2. Unspecified 1568 Error code 0 is used for unspecified errors and contain a diagnostic 1569 message. 1571 For error messages with ERR_CODE == 0, ERR_INFO MUST be a text string 1572 containing a human-readable diagnostic message written in English. 1573 The diagnostic text message is mainly intended for software engineers 1574 that during debugging need to interpret it in the context of the 1575 EDHOC specification. The diagnostic message SHOULD be provided to 1576 the calling application where it SHOULD be logged. 1578 6.3. Wrong Selected Cipher Suite 1580 Error code 1 MUST only be used in a response to message_1 in case the 1581 cipher suite selected by the Initiator is not supported by the 1582 Responder, or if the Responder supports a cipher suite more preferred 1583 by the Initiator than the selected cipher suite, see Section 5.3.3. 1585 ERR_INFO is of type SUITES_R: 1587 SUITES_R : [ supported : 2* suite ] / suite 1589 If the Responder does not support the selected cipher suite, then 1590 SUITES_R MUST include one or more supported cipher suites. If the 1591 Responder does not support the selected cipher suite, but supports 1592 another cipher suite in SUITES_I, then SUITES_R MUST include the 1593 first supported cipher suite in SUITES_I. 1595 6.3.1. Cipher Suite Negotiation 1597 After receiving SUITES_R, the Initiator can determine which cipher 1598 suite to select for the next EDHOC run with the Responder. 1600 If the Initiator intends to contact the Responder in the future, the 1601 Initiator SHOULD remember which selected cipher suite to use until 1602 the next message_1 has been sent, otherwise the Initiator and 1603 Responder will likely run into an infinite loop. After a successful 1604 run of EDHOC, the Initiator MAY remember the selected cipher suite to 1605 use in future EDHOC runs. Note that if the Initiator or Responder is 1606 updated with new cipher suite policies, any cached information may be 1607 outdated. 1609 6.3.2. Examples 1611 Assume that the Initiator supports the five cipher suites 5, 6, 7, 8, 1612 and 9 in decreasing order of preference. Figures 7 and 8 show 1613 examples of how the Initiator can truncate SUITES_I and how SUITES_R 1614 is used by Responders to give the Initiator information about the 1615 cipher suites that the Responder supports. 1617 In the first example (Figure 7), the Responder supports cipher suite 1618 6 but not the initially selected cipher suite 5. 1620 Initiator Responder 1621 | METHOD_CORR, SUITES_I = 5, G_X, C_I, AD_1 | 1622 +------------------------------------------------------------------>| 1623 | message_1 | 1624 | | 1625 | C_I, DIAG_MSG, SUITES_R = 6 | 1626 |<------------------------------------------------------------------+ 1627 | error | 1628 | | 1629 | METHOD_CORR, SUITES_I = [6, 5, 6], G_X, C_I, AD_1 | 1630 +------------------------------------------------------------------>| 1631 | message_1 | 1633 Figure 7: Example of Responder supporting suite 6 but not suite 5. 1635 In the second example (Figure 8), the Responder supports cipher 1636 suites 8 and 9 but not the more preferred (by the Initiator) cipher 1637 suites 5, 6 or 7. To illustrate the negotiation mechanics we let the 1638 Initiator first make a guess that the Responder supports suite 6 but 1639 not suite 5. Since the Responder supports neither 5 nor 6, it 1640 responds with an error and SUITES_R, after which the Initiator 1641 selects its most preferred supported suite. The order of cipher 1642 suites in SUITES_R does not matter. (If the Responder had supported 1643 suite 5, it would include it in SUITES_R of the response, and it 1644 would in that case have become the selected suite in the second 1645 message_1.) 1647 Initiator Responder 1648 | METHOD_CORR, SUITES_I = [6, 5, 6], G_X, C_I, AD_1 | 1649 +------------------------------------------------------------------>| 1650 | message_1 | 1651 | | 1652 | C_I, DIAG_MSG, SUITES_R = [9, 8] | 1653 |<------------------------------------------------------------------+ 1654 | error | 1655 | | 1656 | METHOD_CORR, SUITES_I = [8, 5, 6, 7, 8], G_X, C_I, AD_1 | 1657 +------------------------------------------------------------------>| 1658 | message_1 | 1660 Figure 8: Example of Responder supporting suites 8 and 9 but not 1661 5, 6 or 7. 1663 Note that the Initiator's list of supported cipher suites and order 1664 of preference is fixed (see Section 5.3.1 and Section 5.3.2). 1665 Furthermore, the Responder shall only accept message_1 if the 1666 selected cipher suite is the first cipher suite in SUITES_I that the 1667 Responder supports (see Section 5.3.3). Following this procedure 1668 ensures that the selected cipher suite is the most preferred (by the 1669 Initiator) cipher suite supported by both parties. 1671 If the selected cipher suite is not the first cipher suite which the 1672 Responder supports in SUITES_I received in message_1, then Responder 1673 MUST discontinue the protocol, see Section 5.3.3. If SUITES_I in 1674 message_1 is manipulated then the integrity verification of message_2 1675 containing the transcript hash TH_2 = H( message_1, data_2 ) will 1676 fail and the Initiator will discontinue the protocol. 1678 7. Transferring EDHOC and Deriving an OSCORE Context 1680 7.1. EDHOC Message 4 1682 This section specifies message_4 which is OPTIONAL to support. Key 1683 confirmation is normally provided by sending an application message 1684 from the Responder to the Initiator protected with a key derived with 1685 the EDHOC-Exporter, e.g., using OSCORE (see Section 7.2.1). In 1686 deployments where no protected application message is sent from the 1687 Responder to the Initiator, the Responder MUST send message_4. Two 1688 examples of such deployments: 1690 1. When EDHOC is only used for authentication and no application 1691 data is sent. 1693 2. When application data is only sent from the Initiator to the 1694 Responder. 1696 Further considerations are provided in Section 3.7. 1698 7.1.1. Formatting of Message 4 1700 message_4 and data_4 SHALL be CBOR Sequences (see Appendix A.1) as 1701 defined below 1703 message_4 = ( 1704 data_4, 1705 MAC_4 : bstr, 1706 ) 1708 data_4 = ( 1709 ? C_I : bstr_identifier, 1710 ) 1712 7.1.2. Responder Processing of Message 4 1714 The Responder SHALL compose message_4 as follows: 1716 * If corr (METHOD_CORR mod 4) equals 1 or 3, C_I is omitted, 1717 otherwise C_I is not omitted. 1719 * Compute an inner COSE_Encrypt0 as defined in Section 5.3 of 1720 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1721 in the selected cipher suite, and the following parameters: 1723 - protected = h'' 1725 - external_aad = << TH_4 >> 1727 - plaintext = h'' 1729 COSE constructs the input to the AEAD [RFC5116] as follows: 1731 - Key K = EDHOC-Exporter( "EDHOC_message_4_Key", length ) 1733 - Nonce N = EDHOC-Exporter( "EDHOC_message_4_Nonce", length ) 1735 - Plaintext P = 0x (the empty string) 1737 - Associated data A = 1739 [ "Encrypt0", h'', << TH_4 >> ] 1741 MAC_4 is the 'ciphertext' of the COSE_Encrypt0. 1743 * Encode message_4 as a sequence of CBOR encoded data items as 1744 specified in Section 7.1.1. 1746 7.1.3. Initiator Processing of Message 4 1748 The Initiator SHALL process message_4 as follows: 1750 * Decode message_4 (see Appendix A.1). 1752 * Retrieve the protocol state using the connection identifier C_I 1753 and/or other external information such as the CoAP Token and the 1754 5-tuple. 1756 * Verify MAC_4 as defined in Section 5.3 of 1757 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1758 in the selected cipher suite, and the parameters defined in 1759 Section 7.1.2. 1761 If any verification step fails the Initiator MUST send an EDHOC error 1762 message back, formatted as defined in Section 6, and the protocol 1763 MUST be discontinued. 1765 7.2. Transferring EDHOC in CoAP 1767 It is recommended to transport EDHOC as an exchange of CoAP [RFC7252] 1768 messages. CoAP is a reliable transport that can preserve packet 1769 ordering and handle message duplication. CoAP can also perform 1770 fragmentation and protect against denial of service attacks. It is 1771 recommended to carry the EDHOC messages in Confirmable messages, 1772 especially if fragmentation is used. 1774 By default, the CoAP client is the Initiator and the CoAP server is 1775 the Responder, but the roles SHOULD be chosen to protect the most 1776 sensitive identity, see Section 8. By default, EDHOC is transferred 1777 in POST requests and 2.04 (Changed) responses to the Uri-Path: 1778 "/.well-known/edhoc", but an application may define its own path that 1779 can be discovered e.g. using resource directory 1780 [I-D.ietf-core-resource-directory]. 1782 By default, the message flow is as follows: EDHOC message_1 is sent 1783 in the payload of a POST request from the client to the server's 1784 resource for EDHOC. EDHOC message_2 or the EDHOC error message is 1785 sent from the server to the client in the payload of a 2.04 (Changed) 1786 response. EDHOC message_3 or the EDHOC error message is sent from 1787 the client to the server's resource in the payload of a POST request. 1788 If needed, an EDHOC error message is sent from the server to the 1789 client in the payload of a 2.04 (Changed) response. Alternatively, 1790 if EDHOC message_4 is used, it is sent from the server to the client 1791 in the payload of a 2.04 (Changed) response analogously to message_2. 1793 An example of a successful EDHOC exchange using CoAP is shown in 1794 Figure 9. In this case the CoAP Token enables the Initiator to 1795 correlate message_1 and message_2 so the correlation parameter corr = 1796 1. 1798 Client Server 1799 | | 1800 +--------->| Header: POST (Code=0.02) 1801 | POST | Uri-Path: "/.well-known/edhoc" 1802 | | Content-Format: application/edhoc 1803 | | Payload: EDHOC message_1 1804 | | 1805 |<---------+ Header: 2.04 Changed 1806 | 2.04 | Content-Format: application/edhoc 1807 | | Payload: EDHOC message_2 1808 | | 1809 +--------->| Header: POST (Code=0.02) 1810 | POST | Uri-Path: "/.well-known/edhoc" 1811 | | Content-Format: application/edhoc 1812 | | Payload: EDHOC message_3 1813 | | 1814 |<---------+ Header: 2.04 Changed 1815 | 2.04 | 1816 | | 1818 Figure 9: Transferring EDHOC in CoAP when the Initiator is CoAP 1819 Client 1821 The exchange in Figure 9 protects the client identity against active 1822 attackers and the server identity against passive attackers. An 1823 alternative exchange that protects the server identity against active 1824 attackers and the client identity against passive attackers is shown 1825 in Figure 10. In this case the CoAP Token enables the Responder to 1826 correlate message_2 and message_3 so the correlation parameter corr = 1827 2. If EDHOC message_4 is used, it is transported with CoAP in the 1828 payload of a POST request with a 2.04 (Changed) response. 1830 Client Server 1831 | | 1832 +--------->| Header: POST (Code=0.02) 1833 | POST | Uri-Path: "/.well-known/edhoc" 1834 | | 1835 |<---------+ Header: 2.04 Changed 1836 | 2.04 | Content-Format: application/edhoc 1837 | | Payload: EDHOC message_1 1838 | | 1839 +--------->| Header: POST (Code=0.02) 1840 | POST | Uri-Path: "/.well-known/edhoc" 1841 | | Content-Format: application/edhoc 1842 | | Payload: EDHOC message_2 1843 | | 1844 |<---------+ Header: 2.04 Changed 1845 | 2.04 | Content-Format: application/edhoc 1846 | | Payload: EDHOC message_3 1847 | | 1849 Figure 10: Transferring EDHOC in CoAP when the Initiator is CoAP 1850 Server 1852 To protect against denial-of-service attacks, the CoAP server MAY 1853 respond to the first POST request with a 4.01 (Unauthorized) 1854 containing an Echo option [I-D.ietf-core-echo-request-tag]. This 1855 forces the initiator to demonstrate its reachability at its apparent 1856 network address. If message fragmentation is needed, the EDHOC 1857 messages may be fragmented using the CoAP Block-Wise Transfer 1858 mechanism [RFC7959]. 1860 7.2.1. Deriving an OSCORE Context from EDHOC 1862 When EDHOC is used to derive parameters for OSCORE [RFC8613], the 1863 parties make sure that the EDHOC connection identifiers are unique, 1864 i.e. C_R MUST NOT be equal to C_I. The CoAP client and server MUST 1865 be able to retrieve the OSCORE protocol state using its chosen 1866 connection identifier and optionally other information such as the 1867 5-tuple. In case that the CoAP client is the Initiator and the CoAP 1868 server is the Responder: 1870 * The client's OSCORE Sender ID is C_R and the server's OSCORE 1871 Sender ID is C_I, as defined in this document 1873 * The AEAD Algorithm and the hash algorithm are the application AEAD 1874 and hash algorithms in the selected cipher suite. 1876 * The Master Secret and Master Salt are derived as follows. By 1877 default key_length is the key length (in bytes) of the application 1878 AEAD Algorithm and salt_length is 8 bytes. The Initiator and 1879 Responder MAY agree out-of-band on a longer key_length than the 1880 default and a different salt_length. 1882 Master Secret = EDHOC-Exporter( "OSCORE Master Secret", key_length ) 1883 Master Salt = EDHOC-Exporter( "OSCORE Master Salt", salt_length ) 1885 7.2.2. Error Messages with CoAP Transport 1887 EDHOC does not restrict how error messages are transported with CoAP, 1888 as long as the appropriate error message can to be transported in 1889 response to a message that failed (see Section 6). In case of 1890 combining EDHOC and OSCORE as specified in 1891 [I-D.ietf-core-oscore-edhoc], an error message following a combined 1892 EDHOC message_3/OSCORE request MUST be sent with a CoAP error code 1893 and SHALL contain the ERR_INFO as payload (see Section 6). 1895 8. Security Considerations 1897 8.1. Security Properties 1899 EDHOC inherits its security properties from the theoretical SIGMA-I 1900 protocol [SIGMA]. Using the terminology from [SIGMA], EDHOC provides 1901 perfect forward secrecy, mutual authentication with aliveness, 1902 consistency, and peer awareness. As described in [SIGMA], peer 1903 awareness is provided to the Responder, but not to the Initiator. 1905 EDHOC protects the credential identifier of the Initiator against 1906 active attacks and the credential identifier of the Responder against 1907 passive attacks. The roles should be assigned to protect the most 1908 sensitive identity/identifier, typically that which is not possible 1909 to infer from routing information in the lower layers. 1911 Compared to [SIGMA], EDHOC adds an explicit method type and expands 1912 the message authentication coverage to additional elements such as 1913 algorithms, auxiliary data, and previous messages. This protects 1914 against an attacker replaying messages or injecting messages from 1915 another session. 1917 EDHOC also adds negotiation of connection identifiers and downgrade 1918 protected negotiation of cryptographic parameters, i.e. an attacker 1919 cannot affect the negotiated parameters. A single session of EDHOC 1920 does not include negotiation of cipher suites, but it enables the 1921 Responder to verify that the selected cipher suite is the most 1922 preferred cipher suite by the Initiator which is supported by both 1923 the Initiator and the Responder. 1925 As required by [RFC7258], IETF protocols need to mitigate pervasive 1926 monitoring when possible. One way to mitigate pervasive monitoring 1927 is to use a key exchange that provides perfect forward secrecy. 1928 EDHOC therefore only supports methods with perfect forward secrecy. 1929 To limit the effect of breaches, it is important to limit the use of 1930 symmetrical group keys for bootstrapping. EDHOC therefore strives to 1931 make the additional cost of using raw public keys and self-signed 1932 certificates as small as possible. Raw public keys and self-signed 1933 certificates are not a replacement for a public key infrastructure, 1934 but SHOULD be used instead of symmetrical group keys for 1935 bootstrapping. 1937 Compromise of the long-term keys (private signature or static DH 1938 keys) does not compromise the security of completed EDHOC exchanges. 1939 Compromising the private authentication keys of one party lets an 1940 active attacker impersonate that compromised party in EDHOC exchanges 1941 with other parties, but does not let the attacker impersonate other 1942 parties in EDHOC exchanges with the compromised party. Compromise of 1943 the long-term keys does not enable a passive attacker to compromise 1944 future session keys. Compromise of the HDKF input parameters (ECDH 1945 shared secret) leads to compromise of all session keys derived from 1946 that compromised shared secret. Compromise of one session key does 1947 not compromise other session keys. Compromise of PRK_4x3m leads to 1948 compromise of all exported keying material derived after the last 1949 invocation of the EDHOC-KeyUpdate function. 1951 EDHOC provides a minimum of 64-bit security against online brute 1952 force attacks and a minimum of 128-bit security against offline brute 1953 force attacks. This is in line with IPsec, TLS, and COSE. To break 1954 64-bit security against online brute force an attacker would on 1955 average have to send 4.3 billion messages per second for 68 years, 1956 which is infeasible in constrained IoT radio technologies. 1958 After sending message_3, the Initiator is assured that no other party 1959 than the Responder can compute the key PRK_4x3m (implicit key 1960 authentication). The Initiator does however not know that the 1961 Responder has actually computed the key PRK_4x3m. While the 1962 Initiator can securely send protected application data, the Initiator 1963 SHOULD NOT permanently store the keying material PRK_4x3m and TH_4 1964 until the Initiator is assured that the Responder has actually 1965 computed the key PRK_4x3m (explicit key confirmation). Explicit key 1966 confirmation is e.g. assured when the Initiator has verified an 1967 OSCORE message or message_4 from the Responder. After verifying 1968 message_3, the Responder is assured that the Initiator has calculated 1969 the key PRK_4x3m (explicit key confirmation) and that no other party 1970 than the Responder can compute the key. The Responder can securely 1971 send protected application data and store the keying material 1972 PRK_4x3m and TH_4. 1974 Key compromise impersonation (KCI): In EDHOC authenticated with 1975 signature keys, EDHOC provides KCI protection against an attacker 1976 having access to the long term key or the ephemeral secret key. With 1977 static Diffie-Hellman key authentication, KCI protection would be 1978 provided against an attacker having access to the long-term Diffie- 1979 Hellman key, but not to an attacker having access to the ephemeral 1980 secret key. Note that the term KCI has typically been used for 1981 compromise of long-term keys, and that an attacker with access to the 1982 ephemeral secret key can only attack that specific protocol run. 1984 Repudiation: In EDHOC authenticated with signature keys, the 1985 Initiator could theoretically prove that the Responder performed a 1986 run of the protocol by presenting the private ephemeral key, and vice 1987 versa. Note that storing the private ephemeral keys violates the 1988 protocol requirements. With static Diffie-Hellman key 1989 authentication, both parties can always deny having participated in 1990 the protocol. 1992 Two earlier versions of EDHOC have been formally analyzed [Norrman20] 1993 [Bruni18] and the specification has been updated based on the 1994 analysis. 1996 8.2. Cryptographic Considerations 1998 The security of the SIGMA protocol requires the MAC to be bound to 1999 the identity of the signer. Hence the message authenticating 2000 functionality of the authenticated encryption in EDHOC is critical: 2001 authenticated encryption MUST NOT be replaced by plain encryption 2002 only, even if authentication is provided at another level or through 2003 a different mechanism. EDHOC implements SIGMA-I using a MAC-then- 2004 Sign approach. 2006 To reduce message overhead EDHOC does not use explicit nonces and 2007 instead rely on the ephemeral public keys to provide randomness to 2008 each session. A good amount of randomness is important for the key 2009 generation, to provide liveness, and to protect against interleaving 2010 attacks. For this reason, the ephemeral keys MUST NOT be reused, and 2011 both parties SHALL generate fresh random ephemeral key pairs. 2013 As discussed the [SIGMA], the encryption of message_2 does only need 2014 to protect against passive attacker as active attackers can always 2015 get the Responders identity by sending their own message_1. EDHOC 2016 uses the Expand function (typically HKDF-Expand) as a binary additive 2017 stream cipher. HKDF-Expand provides better confidentiality than AES- 2018 CTR but is not often used as it is slow on long messages, and most 2019 applications require both IND-CCA confidentiality as well as 2020 integrity protection. For the encryption of message_2, any speed 2021 difference is negligible, IND-CCA does not increase security, and 2022 integrity is provided by the inner MAC (and signature depending on 2023 method). 2025 The data rates in many IoT deployments are very limited. Given that 2026 the application keys are protected as well as the long-term 2027 authentication keys they can often be used for years or even decades 2028 before the cryptographic limits are reached. If the application keys 2029 established through EDHOC need to be renewed, the communicating 2030 parties can derive application keys with other labels or run EDHOC 2031 again. 2033 8.3. Cipher Suites and Cryptographic Algorithms 2035 For many constrained IoT devices it is problematic to support more 2036 than one cipher suite. Existing devices can be expected to support 2037 either ECDSA or EdDSA. To enable as much interoperability as we can 2038 reasonably achieve, less constrained devices SHOULD implement both 2039 cipher suite 0 (AES-CCM-16-64-128, SHA-256, X25519, EdDSA, Ed25519, 2040 AES-CCM-16-64-128, SHA-256) and cipher suite 2 (AES-CCM-16-64-128, 2041 SHA-256, P-256, ES256, P-256, AES-CCM-16-64-128, SHA-256). 2042 Constrained endpoints SHOULD implement cipher suite 0 or cipher suite 2043 2. Implementations only need to implement the algorithms needed for 2044 their supported methods. 2046 When using private cipher suite or registering new cipher suites, the 2047 choice of key length used in the different algorithms needs to be 2048 harmonized, so that a sufficient security level is maintained for 2049 certificates, EDHOC, and the protection of application data. The 2050 Initiator and the Responder should enforce a minimum security level. 2052 The hash algorithms SHA-1 and SHA-256/64 (256-bit Hash truncated to 2053 64-bits) SHALL NOT be supported for use in EDHOC except for 2054 certificate identification with x5u and c5u. Note that secp256k1 is 2055 only defined for use with ECDSA and not for ECDH. 2057 8.4. Unprotected Data 2059 The Initiator and the Responder must make sure that unprotected data 2060 and metadata do not reveal any sensitive information. This also 2061 applies for encrypted data sent to an unauthenticated party. In 2062 particular, it applies to AD_1, ID_CRED_R, AD_2, and ERR_MSG. Using 2063 the same AD_1 in several EDHOC sessions allows passive eavesdroppers 2064 to correlate the different sessions. Another consideration is that 2065 the list of supported cipher suites may potentially be used to 2066 identify the application. 2068 The Initiator and the Responder must also make sure that 2069 unauthenticated data does not trigger any harmful actions. In 2070 particular, this applies to AD_1 and ERR_MSG. 2072 8.5. Denial-of-Service 2074 EDHOC itself does not provide countermeasures against Denial-of- 2075 Service attacks. By sending a number of new or replayed message_1 an 2076 attacker may cause the Responder to allocate state, perform 2077 cryptographic operations, and amplify messages. To mitigate such 2078 attacks, an implementation SHOULD rely on lower layer mechanisms such 2079 as the Echo option in CoAP [I-D.ietf-core-echo-request-tag] that 2080 forces the initiator to demonstrate reachability at its apparent 2081 network address. 2083 8.6. Implementation Considerations 2085 The availability of a secure random number generator is essential for 2086 the security of EDHOC. If no true random number generator is 2087 available, a truly random seed MUST be provided from an external 2088 source and used with a cryptographically secure pseudorandom number 2089 generator. As each pseudorandom number must only be used once, an 2090 implementation need to get a new truly random seed after reboot, or 2091 continuously store state in nonvolatile memory, see ([RFC8613], 2092 Appendix B.1.1) for issues and solution approaches for writing to 2093 nonvolatile memory. Intentionally or unintentionally weak or 2094 predictable pseudorandom number generators can be abused or exploited 2095 for malicious purposes. [RFC8937] describes a way for security 2096 protocol implementations to augment their (pseudo)random number 2097 generators using a long-term private keys and a deterministic 2098 signature function. This improves randomness from broken or 2099 otherwise subverted random number generators. The same idea can be 2100 used with other secrets and functions such as a Diffie-Hellman 2101 function or a symmetric secret and a PRF like HMAC or KMAC. It is 2102 RECOMMENDED to not trust a single source of randomness and to not put 2103 unaugmented random numbers on the wire. 2105 If ECDSA is supported, "deterministic ECDSA" as specified in 2106 [RFC6979] MAY be used. Pure deterministic elliptic-curve signatures 2107 such as deterministic ECDSA and EdDSA have gained popularity over 2108 randomized ECDSA as their security do not depend on a source of high- 2109 quality randomness. Recent research has however found that 2110 implementations of these signature algorithms may be vulnerable to 2111 certain side-channel and fault injection attacks due to their 2112 determinism. See e.g. Section 1 of 2113 [I-D.mattsson-cfrg-det-sigs-with-noise] for a list of attack papers. 2114 As suggested in Section 6.1.2 of [I-D.ietf-cose-rfc8152bis-algs] this 2115 can be addressed by combining randomness and determinism. 2117 The referenced processing instructions in [SP-800-56A] must be 2118 complied with, including deleting the intermediate computed values 2119 along with any ephemeral ECDH secrets after the key derivation is 2120 completed. The ECDH shared secrets, keys, and IVs MUST be secret. 2121 Implementations should provide countermeasures to side-channel 2122 attacks such as timing attacks. Depending on the selected curve, the 2123 parties should perform various validations of each other's public 2124 keys, see e.g. Section 5 of [SP-800-56A]. 2126 The Initiator and the Responder are responsible for verifying the 2127 integrity of certificates. The selection of trusted CAs should be 2128 done very carefully and certificate revocation should be supported. 2129 The private authentication keys MUST be kept secret. 2131 The Initiator and the Responder are allowed to select the connection 2132 identifiers C_I and C_R, respectively, for the other party to use in 2133 the ongoing EDHOC protocol as well as in a subsequent application 2134 protocol (e.g. OSCORE [RFC8613]). The choice of connection 2135 identifier is not security critical in EDHOC but intended to simplify 2136 the retrieval of the right security context in combination with using 2137 short identifiers. If the wrong connection identifier of the other 2138 party is used in a protocol message it will result in the receiving 2139 party not being able to retrieve a security context (which will 2140 terminate the protocol) or retrieve the wrong security context (which 2141 also terminates the protocol as the message cannot be verified). 2143 The Responder MUST finish the verification step of message_3 before 2144 passing AD_3 to the application. 2146 If two nodes unintentionally initiate two simultaneous EDHOC message 2147 exchanges with each other even if they only want to complete a single 2148 EDHOC message exchange, they MAY terminate the exchange with the 2149 lexicographically smallest G_X. If the two G_X values are equal, the 2150 received message_1 MUST be discarded to mitigate reflection attacks. 2151 Note that in the case of two simultaneous EDHOC exchanges where the 2152 nodes only complete one and where the nodes have different preferred 2153 cipher suites, an attacker can affect which of the two nodes' 2154 preferred cipher suites will be used by blocking the other exchange. 2156 If supported by the device, it is RECOMMENDED that at least the long- 2157 term private keys is stored in a Trusted Execution Environment (TEE) 2158 and that sensitive operations using these keys are performed inside 2159 the TEE. To achieve even higher security it is RECOMMENDED that 2160 additional operations such as ephemeral key generation, all 2161 computations of shared secrets, and storage of the PRK keys can be 2162 done inside the TEE. The TEE can also be used to protect the EDHOC 2163 and application protocol (e.g. OSCORE) implementation using some 2164 form of "secure boot", memory protection etc. The use of a TEE 2165 enforces that code within that environment cannot be tampered with, 2166 and that any data used by such code cannot be read or tampered with 2167 by code outside that environment. 2169 9. IANA Considerations 2171 9.1. EDHOC Cipher Suites Registry 2173 IANA has created a new registry titled "EDHOC Cipher Suites" under 2174 the new heading "EDHOC". The registration procedure is "Expert 2175 Review". The columns of the registry are Value, Array, Description, 2176 and Reference, where Value is an integer and the other columns are 2177 text strings. The initial contents of the registry are: 2179 Value: -24 2180 Algorithms: N/A 2181 Desc: Reserved for Private Use 2182 Reference: [[this document]] 2184 Value: -23 2185 Algorithms: N/A 2186 Desc: Reserved for Private Use 2187 Reference: [[this document]] 2189 Value: -22 2190 Algorithms: N/A 2191 Desc: Reserved for Private Use 2192 Reference: [[this document]] 2193 Value: -21 2194 Algorithms: N/A 2195 Desc: Reserved for Private Use 2196 Reference: [[this document]] 2198 Value: 0 2199 Array: 10, 5, 4, -8, 6, 10, 5 2200 Desc: AES-CCM-16-64-128, SHA-256, X25519, EdDSA, Ed25519, 2201 AES-CCM-16-64-128, SHA-256 2202 Reference: [[this document]] 2204 Value: 1 2205 Array: 30, 5, 4, -8, 6, 10, 5 2206 Desc: AES-CCM-16-128-128, SHA-256, X25519, EdDSA, Ed25519, 2207 AES-CCM-16-64-128, SHA-256 2208 Reference: [[this document]] 2210 Value: 2 2211 Array: 10, 5, 1, -7, 1, 10, 5 2212 Desc: AES-CCM-16-64-128, SHA-256, P-256, ES256, P-256, 2213 AES-CCM-16-64-128, SHA-256 2214 Reference: [[this document]] 2216 Value: 3 2217 Array: 30, 5, 1, -7, 1, 10, 5 2218 Desc: AES-CCM-16-128-128, SHA-256, P-256, ES256, P-256, 2219 AES-CCM-16-64-128, SHA-256 2220 Reference: [[this document]] 2222 Value: 4 2223 Array: 1, -16, 4, -7, 1, 1, -16 2224 Desc: A128GCM, SHA-256, X25519, ES256, P-256, 2225 A128GCM, SHA-256 2226 Reference: [[this document]] 2228 Value: 5 2229 Array: 3, -43, 2, -35, 2, 3, -43 2230 Desc: A256GCM, SHA-384, P-384, ES384, P-384, 2231 A256GCM, SHA-384 2232 Reference: [[this document]] 2234 9.2. EDHOC Method Type Registry 2236 IANA has created a new registry entitled "EDHOC Method Type" under 2237 the new heading "EDHOC". The registration procedure is "Expert 2238 Review". The columns of the registry are Value, Description, and 2239 Reference, where Value is an integer and the other columns are text 2240 strings. The initial contents of the registry is shown in Figure 4. 2242 9.3. EDHOC Error Codes Registry 2244 IANA has created a new registry entitled "EDHOC Error Codes" under 2245 the new heading "EDHOC". The registration procedure is 2246 "Specification Required". The columns of the registry are ERR_CODE, 2247 ERR_INFO Type and Description, where ERR_CODE is an integer, ERR_INFO 2248 is a CDDL defined type, and Description is a text string. The 2249 initial contents of the registry is shown in Figure 6. 2251 9.4. The Well-Known URI Registry 2253 IANA has added the well-known URI 'edhoc' to the Well-Known URIs 2254 registry. 2256 * URI suffix: edhoc 2258 * Change controller: IETF 2260 * Specification document(s): [[this document]] 2262 * Related information: None 2264 9.5. Media Types Registry 2266 IANA has added the media type 'application/edhoc' to the Media Types 2267 registry. 2269 * Type name: application 2271 * Subtype name: edhoc 2273 * Required parameters: N/A 2275 * Optional parameters: N/A 2277 * Encoding considerations: binary 2279 * Security considerations: See Section 7 of this document. 2281 * Interoperability considerations: N/A 2283 * Published specification: [[this document]] (this document) 2285 * Applications that use this media type: To be identified 2287 * Fragment identifier considerations: N/A 2289 * Additional information: 2291 - Magic number(s): N/A 2293 - File extension(s): N/A 2295 - Macintosh file type code(s): N/A 2297 * Person & email address to contact for further information: See 2298 "Authors' Addresses" section. 2300 * Intended usage: COMMON 2302 * Restrictions on usage: N/A 2304 * Author: See "Authors' Addresses" section. 2306 * Change Controller: IESG 2308 9.6. CoAP Content-Formats Registry 2310 IANA has added the media type 'application/edhoc' to the CoAP 2311 Content-Formats registry. 2313 * Media Type: application/edhoc 2315 * Encoding: 2317 * ID: TBD42 2319 * Reference: [[this document]] 2321 9.7. Expert Review Instructions 2323 The IANA Registries established in this document is defined as 2324 "Expert Review". This section gives some general guidelines for what 2325 the experts should be looking for, but they are being designated as 2326 experts for a reason so they should be given substantial latitude. 2328 Expert reviewers should take into consideration the following points: 2330 * Clarity and correctness of registrations. Experts are expected to 2331 check the clarity of purpose and use of the requested entries. 2332 Expert needs to make sure the values of algorithms are taken from 2333 the right registry, when that's required. Expert should consider 2334 requesting an opinion on the correctness of registered parameters 2335 from relevant IETF working groups. Encodings that do not meet 2336 these objective of clarity and completeness should not be 2337 registered. 2339 * Experts should take into account the expected usage of fields when 2340 approving point assignment. The length of the encoded value 2341 should be weighed against how many code points of that length are 2342 left, the size of device it will be used on, and the number of 2343 code points left that encode to that size. 2345 * Specifications are recommended. When specifications are not 2346 provided, the description provided needs to have sufficient 2347 information to verify the points above. 2349 10. References 2351 10.1. Normative References 2353 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2354 Requirement Levels", BCP 14, RFC 2119, 2355 DOI 10.17487/RFC2119, March 1997, 2356 . 2358 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 2359 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 2360 . 2362 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 2363 Key Derivation Function (HKDF)", RFC 5869, 2364 DOI 10.17487/RFC5869, May 2010, 2365 . 2367 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 2368 Curve Cryptography Algorithms", RFC 6090, 2369 DOI 10.17487/RFC6090, February 2011, 2370 . 2372 [RFC6979] Pornin, T., "Deterministic Usage of the Digital Signature 2373 Algorithm (DSA) and Elliptic Curve Digital Signature 2374 Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, August 2375 2013, . 2377 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 2378 Application Protocol (CoAP)", RFC 7252, 2379 DOI 10.17487/RFC7252, June 2014, 2380 . 2382 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 2383 for Security", RFC 7748, DOI 10.17487/RFC7748, January 2384 2016, . 2386 [RFC8949] Bormann, C. and P. Hoffman, "Concise Binary Object 2387 Representation (CBOR)", STD 94, RFC 8949, 2388 DOI 10.17487/RFC8949, December 2020, 2389 . 2391 [RFC7959] Bormann, C. and Z. Shelby, Ed., "Block-Wise Transfers in 2392 the Constrained Application Protocol (CoAP)", RFC 7959, 2393 DOI 10.17487/RFC7959, August 2016, 2394 . 2396 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2397 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2398 May 2017, . 2400 [RFC8376] Farrell, S., Ed., "Low-Power Wide Area Network (LPWAN) 2401 Overview", RFC 8376, DOI 10.17487/RFC8376, May 2018, 2402 . 2404 [RFC8610] Birkholz, H., Vigano, C., and C. Bormann, "Concise Data 2405 Definition Language (CDDL): A Notational Convention to 2406 Express Concise Binary Object Representation (CBOR) and 2407 JSON Data Structures", RFC 8610, DOI 10.17487/RFC8610, 2408 June 2019, . 2410 [RFC8613] Selander, G., Mattsson, J., Palombini, F., and L. Seitz, 2411 "Object Security for Constrained RESTful Environments 2412 (OSCORE)", RFC 8613, DOI 10.17487/RFC8613, July 2019, 2413 . 2415 [RFC8724] Minaburo, A., Toutain, L., Gomez, C., Barthel, D., and JC. 2416 Zúñiga, "SCHC: Generic Framework for Static Context Header 2417 Compression and Fragmentation", RFC 8724, 2418 DOI 10.17487/RFC8724, April 2020, 2419 . 2421 [RFC8742] Bormann, C., "Concise Binary Object Representation (CBOR) 2422 Sequences", RFC 8742, DOI 10.17487/RFC8742, February 2020, 2423 . 2425 [I-D.ietf-cose-rfc8152bis-struct] 2426 Schaad, J., "CBOR Object Signing and Encryption (COSE): 2427 Structures and Process", Work in Progress, Internet-Draft, 2428 draft-ietf-cose-rfc8152bis-struct-14, 24 September 2020, 2429 . 2432 [I-D.ietf-cose-rfc8152bis-algs] 2433 Schaad, J., "CBOR Object Signing and Encryption (COSE): 2434 Initial Algorithms", Work in Progress, Internet-Draft, 2435 draft-ietf-cose-rfc8152bis-algs-12, 24 September 2020, 2436 . 2439 [I-D.ietf-cose-x509] 2440 Schaad, J., "CBOR Object Signing and Encryption (COSE): 2441 Header parameters for carrying and referencing X.509 2442 certificates", Work in Progress, Internet-Draft, draft- 2443 ietf-cose-x509-08, 14 December 2020, . 2446 [I-D.ietf-core-echo-request-tag] 2447 Amsuess, C., Mattsson, J., and G. Selander, "CoAP: Echo, 2448 Request-Tag, and Token Processing", Work in Progress, 2449 Internet-Draft, draft-ietf-core-echo-request-tag-11, 2 2450 November 2020, . 2453 [I-D.ietf-lake-reqs] 2454 Vucinic, M., Selander, G., Mattsson, J., and D. Garcia- 2455 Carillo, "Requirements for a Lightweight AKE for OSCORE", 2456 Work in Progress, Internet-Draft, draft-ietf-lake-reqs-04, 2457 8 June 2020, . 2460 10.2. Informative References 2462 [RFC7228] Bormann, C., Ersue, M., and A. Keranen, "Terminology for 2463 Constrained-Node Networks", RFC 7228, 2464 DOI 10.17487/RFC7228, May 2014, 2465 . 2467 [RFC7258] Farrell, S. and H. Tschofenig, "Pervasive Monitoring Is an 2468 Attack", BCP 188, RFC 7258, DOI 10.17487/RFC7258, May 2469 2014, . 2471 [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T. 2472 Kivinen, "Internet Key Exchange Protocol Version 2 2473 (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October 2474 2014, . 2476 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 2477 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 2478 . 2480 [RFC8937] Cremers, C., Garratt, L., Smyshlyaev, S., Sullivan, N., 2481 and C. Wood, "Randomness Improvements for Security 2482 Protocols", RFC 8937, DOI 10.17487/RFC8937, October 2020, 2483 . 2485 [I-D.ietf-core-resource-directory] 2486 Amsuess, C., Shelby, Z., Koster, M., Bormann, C., and P. 2487 Stok, "CoRE Resource Directory", Work in Progress, 2488 Internet-Draft, draft-ietf-core-resource-directory-26, 2 2489 November 2020, . 2492 [I-D.ietf-lwig-security-protocol-comparison] 2493 Mattsson, J., Palombini, F., and M. Vucinic, "Comparison 2494 of CoAP Security Protocols", Work in Progress, Internet- 2495 Draft, draft-ietf-lwig-security-protocol-comparison-05, 2 2496 November 2020, . 2499 [I-D.ietf-tls-dtls13] 2500 Rescorla, E., Tschofenig, H., and N. Modadugu, "The 2501 Datagram Transport Layer Security (DTLS) Protocol Version 2502 1.3", Work in Progress, Internet-Draft, draft-ietf-tls- 2503 dtls13-40, 20 January 2021, . 2506 [I-D.selander-ace-ake-authz] 2507 Selander, G., Mattsson, J., Vucinic, M., Richardson, M., 2508 and A. Schellenbaum, "Lightweight Authorization for 2509 Authenticated Key Exchange.", Work in Progress, Internet- 2510 Draft, draft-selander-ace-ake-authz-02, 2 November 2020, 2511 . 2514 [I-D.ietf-core-oscore-edhoc] 2515 Palombini, F., Tiloca, M., Hoeglund, R., Hristozov, S., 2516 and G. Selander, "Combining EDHOC and OSCORE", Work in 2517 Progress, Internet-Draft, draft-ietf-core-oscore-edhoc-00, 2518 1 April 2021, . 2521 [I-D.mattsson-cose-cbor-cert-compress] 2522 Raza, S., Hoglund, J., Selander, G., Mattsson, J., and M. 2523 Furuhed, "CBOR Encoding of X.509 Certificates (CBOR 2524 Certificates)", Work in Progress, Internet-Draft, draft- 2525 mattsson-cose-cbor-cert-compress-06, 19 January 2021, 2526 . 2529 [I-D.mattsson-cfrg-det-sigs-with-noise] 2530 Mattsson, J., Thormarker, E., and S. Ruohomaa, 2531 "Deterministic ECDSA and EdDSA Signatures with Additional 2532 Randomness", Work in Progress, Internet-Draft, draft- 2533 mattsson-cfrg-det-sigs-with-noise-02, 11 March 2020, 2534 . 2537 [SP-800-56A] 2538 Barker, E., Chen, L., Roginsky, A., Vassilev, A., and R. 2539 Davis, "Recommendation for Pair-Wise Key-Establishment 2540 Schemes Using Discrete Logarithm Cryptography", 2541 NIST Special Publication 800-56A Revision 3, April 2018, 2542 . 2544 [SIGMA] Krawczyk, H., "SIGMA - The 'SIGn-and-MAc' Approach to 2545 Authenticated Diffie-Hellman and Its Use in the IKE- 2546 Protocols (Long version)", June 2003, 2547 . 2549 [CNSA] (Placeholder), ., "Commercial National Security Algorithm 2550 Suite", August 2015, 2551 . 2554 [Norrman20] 2555 Norrman, K., Sundararajan, V., and A. Bruni, "Formal 2556 Analysis of EDHOC Key Establishment for Constrained IoT 2557 Devices", September 2020, 2558 . 2560 [Bruni18] Bruni, A., Sahl Jørgensen, T., Grønbech Petersen, T., and 2561 C. Schürmann, "Formal Verification of Ephemeral Diffie- 2562 Hellman Over COSE (EDHOC)", November 2018, 2563 . 2567 [CborMe] Bormann, C., "CBOR Playground", May 2018, 2568 . 2570 Appendix A. Use of CBOR, CDDL and COSE in EDHOC 2572 This Appendix is intended to simplify for implementors not familiar 2573 with CBOR [RFC8949], CDDL [RFC8610], COSE 2574 [I-D.ietf-cose-rfc8152bis-struct], and HKDF [RFC5869]. 2576 A.1. CBOR and CDDL 2578 The Concise Binary Object Representation (CBOR) [RFC8949] is a data 2579 format designed for small code size and small message size. CBOR 2580 builds on the JSON data model but extends it by e.g. encoding binary 2581 data directly without base64 conversion. In addition to the binary 2582 CBOR encoding, CBOR also has a diagnostic notation that is readable 2583 and editable by humans. The Concise Data Definition Language (CDDL) 2584 [RFC8610] provides a way to express structures for protocol messages 2585 and APIs that use CBOR. [RFC8610] also extends the diagnostic 2586 notation. 2588 CBOR data items are encoded to or decoded from byte strings using a 2589 type-length-value encoding scheme, where the three highest order bits 2590 of the initial byte contain information about the major type. CBOR 2591 supports several different types of data items, in addition to 2592 integers (int, uint), simple values (e.g. null), byte strings (bstr), 2593 and text strings (tstr), CBOR also supports arrays [] of data items, 2594 maps {} of pairs of data items, and sequences [RFC8742] of data 2595 items. Some examples are given below. For a complete specification 2596 and more examples, see [RFC8949] and [RFC8610]. We recommend 2597 implementors to get used to CBOR by using the CBOR playground 2598 [CborMe]. 2600 Diagnostic Encoded Type 2601 ------------------------------------------------------------------ 2602 1 0x01 unsigned integer 2603 24 0x1818 unsigned integer 2604 -24 0x37 negative integer 2605 -25 0x3818 negative integer 2606 null 0xf6 simple value 2607 h'12cd' 0x4212cd byte string 2608 '12cd' 0x4431326364 byte string 2609 "12cd" 0x6431326364 text string 2610 { 4 : h'cd' } 0xa10441cd map 2611 << 1, 2, null >> 0x430102f6 byte string 2612 [ 1, 2, null ] 0x830102f6 array 2613 ( 1, 2, null ) 0x0102f6 sequence 2614 1, 2, null 0x0102f6 sequence 2615 ------------------------------------------------------------------ 2617 A.2. CDDL Definitions 2619 This sections compiles the CDDL definitions for ease of reference. 2621 bstr_identifier = bstr / int 2623 suite = int 2625 SUITES_R : [ supported : 2* suite ] / suite 2627 message_1 = ( 2628 ? C_1 : null, 2629 METHOD_CORR : int, 2630 SUITES_I : [ selected : suite, supported : 2* suite ] / suite, 2631 G_X : bstr, 2632 C_I : bstr_identifier, 2633 ? AD_1 : bstr, 2634 ) 2636 message_2 = ( 2637 data_2, 2638 CIPHERTEXT_2 : bstr, 2639 ) 2641 data_2 = ( 2642 ? C_I : bstr_identifier, 2643 G_Y : bstr, 2644 C_R : bstr_identifier, 2645 ) 2647 message_3 = ( 2648 data_3, 2649 CIPHERTEXT_3 : bstr, 2650 ) 2652 data_3 = ( 2653 ? C_R : bstr_identifier, 2654 ) 2656 message_4 = ( 2657 data_4, 2658 MAC_4 : bstr, 2659 ) 2661 data_4 = ( 2662 ? C_I : bstr_identifier, 2663 ) 2665 error = ( 2666 ? C_x : bstr_identifier, 2667 ERR_CODE : int, 2668 ERR_INFO : any 2670 ) 2672 info = [ 2673 edhoc_aead_id : int / tstr, 2674 transcript_hash : bstr, 2675 label : tstr, 2676 length : uint 2677 ] 2679 A.3. COSE 2681 CBOR Object Signing and Encryption (COSE) 2682 [I-D.ietf-cose-rfc8152bis-struct] describes how to create and process 2683 signatures, message authentication codes, and encryption using CBOR. 2684 COSE builds on JOSE, but is adapted to allow more efficient 2685 processing in constrained devices. EDHOC makes use of COSE_Key, 2686 COSE_Encrypt0, and COSE_Sign1 objects. 2688 Appendix B. Test Vectors 2690 This appendix provides detailed test vectors compatible with versions 2691 -05 and -06 of this specification, to ease implementation and ensure 2692 interoperability. In addition to hexadecimal, all CBOR data items 2693 and sequences are given in CBOR diagnostic notation. The test 2694 vectors use the default mapping to CoAP where the Initiator acts as 2695 CoAP client (this means that corr = 1). 2697 A more extensive test vector suite covering more combinations of 2698 authentication method used between Initiator and Responder and 2699 related code to generate them can be found at https://github.com/ 2700 lake-wg/edhoc/tree/master/test-vectors-05. 2702 NOTE 1. In the previous and current test vectors the same name is 2703 used for certain byte strings and their CBOR bstr encodings. For 2704 example the transcript hash TH_2 is used to denote both the output of 2705 the hash function and the input into the key derivation function, 2706 whereas the latter is a CBOR bstr encoding of the former. Some 2707 attempts are made to clarify that in this Appendix (e.g. using "CBOR 2708 encoded"/"CBOR unencoded"). 2710 NOTE 2. If not clear from the context, remember that CBOR sequences 2711 and CBOR arrays assume CBOR encoded data items as elements. 2713 B.1. Test Vectors for EDHOC Authenticated with Signature Keys (x5t) 2715 EDHOC with signature authentication and X.509 certificates is used. 2716 In this test vector, the hash value 'x5t' is used to identify the 2717 certificate. The optional C_1 in message_1 is omitted. No auxiliary 2718 data is sent in the message exchange. 2720 method (Signature Authentication) 2721 0 2723 CoAP is used as transport and the Initiator acts as CoAP client: 2725 corr (the Initiator can correlate message_1 and message_2) 2726 1 2728 From there, METHOD_CORR has the following value: 2730 METHOD_CORR (4 * method + corr) (int) 2731 1 2733 The Initiator indicates only one cipher suite in the (potentially 2734 truncated) list of cipher suites. 2736 Supported Cipher Suites (1 byte) 2737 00 2739 The Initiator selected the indicated cipher suite. 2741 Selected Cipher Suite (int) 2742 0 2744 Cipher suite 0 is supported by both the Initiator and the Responder, 2745 see Section 3.4. 2747 B.1.1. Message_1 2749 The Initiator generates its ephemeral key pair. 2751 X (Initiator's ephemeral private key) (32 bytes) 2752 8f 78 1a 09 53 72 f8 5b 6d 9f 61 09 ae 42 26 11 73 4d 7d bf a0 06 9a 2d 2753 f2 93 5b b2 e0 53 bf 35 2755 G_X (Initiator's ephemeral public key, CBOR unencoded) (32 bytes) 2756 89 8f f7 9a 02 06 7a 16 ea 1e cc b9 0f a5 22 46 f5 aa 4d d6 ec 07 6b ba 2757 02 59 d9 04 b7 ec 8b 0c 2759 The Initiator chooses a connection identifier C_I: 2761 Connection identifier chosen by Initiator (1 byte) 2762 09 2764 Note that since C_I is a byte string in the interval h'00' to h'2f', 2765 it is encoded as the corresponding integer subtracted by 24 (see 2766 bstr_identifier in Section 5.1). Thus 0x09 = 09, 9 - 24 = -15, and 2767 -15 in CBOR encoding is equal to 0x2e. 2769 C_I (1 byte) 2770 2e 2772 Since no auxiliary data is sent: 2774 AD_1 (0 bytes) 2776 The list of supported cipher suites needs to contain the selected 2777 cipher suite. The initiator truncates the list of supported cipher 2778 suites to one cipher suite only. In this case there is only one 2779 supported cipher suite indicated, 00. 2781 Because one single selected cipher suite is conveyed, it is encoded 2782 as an int instead of an array: 2784 SUITES_I (int) 2785 0 2787 message_1 is constructed as the CBOR Sequence of the data items above 2788 encoded as CBOR. In CBOR diagnostic notation: 2790 message_1 = 2791 ( 2792 1, 2793 0, 2794 h'898FF79A02067A16EA1ECCB90FA52246F5AA4DD6EC076BBA0259D904B7EC8B0C', 2795 -15 2796 ) 2798 Which as a CBOR encoded data item is: 2800 message_1 (CBOR Sequence) (37 bytes) 2801 01 00 58 20 89 8f f7 9a 02 06 7a 16 ea 1e cc b9 0f a5 22 46 f5 aa 4d d6 2802 ec 07 6b ba 02 59 d9 04 b7 ec 8b 0c 2e 2804 B.1.2. Message_2 2806 Since METHOD_CORR mod 4 equals 1, C_I is omitted from data_2. 2808 The Responder generates the following ephemeral key pair. 2810 Y (Responder's ephemeral private key) (32 bytes) 2811 fd 8c d8 77 c9 ea 38 6e 6a f3 4f f7 e6 06 c4 b6 4c a8 31 c8 ba 33 13 4f 2812 d4 cd 71 67 ca ba ec da 2814 G_Y (Responder's ephemeral public key, CBOR unencoded) (32 bytes) 2815 71 a3 d5 99 c2 1d a1 89 02 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 19 52 2816 81 75 4c 5e bc af 30 1e 2818 From G_X and Y or from G_Y and X the ECDH shared secret is computed: 2820 G_XY (ECDH shared secret) (32 bytes) 2821 2b b7 fa 6e 13 5b c3 35 d0 22 d6 34 cb fb 14 b3 f5 82 f3 e2 e3 af b2 b3 2822 15 04 91 49 5c 61 78 2b 2824 The key and nonce for calculating the 'ciphertext' are calculated as 2825 follows, as specified in Section 4. 2827 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 2829 PRK_2e = HMAC-SHA-256(salt, G_XY) 2831 Salt is the empty byte string. 2833 salt (0 bytes) 2835 From there, PRK_2e is computed: 2837 PRK_2e (32 bytes) 2838 ec 62 92 a0 67 f1 37 fc 7f 59 62 9d 22 6f bf c4 e0 68 89 49 f6 62 a9 7f 2839 d8 2f be b7 99 71 39 4a 2841 The Responder's sign/verify key pair is the following: 2843 SK_R (Responder's private authentication key) (32 bytes) 2844 df 69 27 4d 71 32 96 e2 46 30 63 65 37 2b 46 83 ce d5 38 1b fc ad cd 44 2845 0a 24 c3 91 d2 fe db 94 2847 PK_R (Responder's public authentication key) (32 bytes) 2848 db d9 dc 8c d0 3f b7 c3 91 35 11 46 2b b2 38 16 47 7c 6b d8 d6 6e f5 a1 2849 a0 70 ac 85 4e d7 3f d2 2851 Since neither the Initiator nor the Responder authenticates with a 2852 static Diffie-Hellman key, PRK_3e2m = PRK_2e 2854 PRK_3e2m (32 bytes) 2855 ec 62 92 a0 67 f1 37 fc 7f 59 62 9d 22 6f bf c4 e0 68 89 49 f6 62 a9 7f 2856 d8 2f be b7 99 71 39 4a 2857 The Responder chooses a connection identifier C_R. 2859 Connection identifier chosen by Responder (1 byte) 2860 00 2862 Note that since C_R is a byte string in the interval h'00' to h'2f', 2863 it is encoded as the corresponding integer subtracted by 24 (see 2864 bstr_identifier in Section 5.1). Thus 0x00 = 0, 0 - 24 = -24, and 2865 -24 in CBOR encoding is equal to 0x37. 2867 C_R (1 byte) 2868 37 2870 Data_2 is constructed as the CBOR Sequence of G_Y and C_R, encoded as 2871 CBOR byte strings. The CBOR diagnostic notation is: 2873 data_2 = 2874 ( 2875 h'71a3d599c21da18902a1aea810b2b6382ccd8d5f9bf0195281754c5ebcaf301e', 2876 -24 2877 ) 2879 Which as a CBOR encoded data item is: 2881 data_2 (CBOR Sequence) (35 bytes) 2882 58 20 71 a3 d5 99 c2 1d a1 89 02 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 2883 19 52 81 75 4c 5e bc af 30 1e 37 2885 From data_2 and message_1, compute the input to the transcript hash 2886 TH_2 = H( message_1, data_2 ), as a CBOR Sequence of these 2 data 2887 items. 2889 Input to calculate TH_2 (CBOR Sequence) (72 bytes) 2890 01 00 58 20 89 8f f7 9a 02 06 7a 16 ea 1e cc b9 0f a5 22 46 f5 aa 4d d6 2891 ec 07 6b ba 02 59 d9 04 b7 ec 8b 0c 2e 58 20 71 a3 d5 99 c2 1d a1 89 02 2892 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 19 52 81 75 4c 5e bc af 30 1e 37 2894 And from there, compute the transcript hash TH_2 = SHA-256( 2895 message_1, data_2 ) 2897 TH_2 (CBOR unencoded) (32 bytes) 2898 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 d3 76 d2 c2 2899 c1 53 c1 7f 8e 96 29 ff 2901 The Responder's subject name is the empty string: 2903 Responder's subject name (text string) 2904 "" 2905 In this version of the test vectors CRED_R is not a DER encoded X.509 2906 certificate, but a string of random bytes. 2908 CRED_R (CBOR unencoded) (100 bytes) 2909 c7 88 37 00 16 b8 96 5b db 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 6e 86 2910 44 2b 87 ec 3f f2 45 b7 0a 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e c9 d6 2911 b0 53 4b 71 c2 b4 9e 4b f9 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 38 1e 2912 98 db 71 41 08 41 5e 5c 50 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 71 be 2913 5c 22 5e b2 2915 CRED_R is defined to be the CBOR bstr containing the credential of 2916 the Responder. 2918 CRED_R (102 bytes) 2919 58 64 c7 88 37 00 16 b8 96 5b db 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 2920 6e 86 44 2b 87 ec 3f f2 45 b7 0a 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e 2921 c9 d6 b0 53 4b 71 c2 b4 9e 4b f9 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 2922 38 1e 98 db 71 41 08 41 5e 5c 50 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 2923 71 be 5c 22 5e b2 2925 And because certificates are identified by a hash value with the 2926 'x5t' parameter, ID_CRED_R is the following: 2928 ID_CRED_R = { 34 : COSE_CertHash }. In this example, the hash 2929 algorithm used is SHA-2 256-bit with hash truncated to 64-bits (value 2930 -15). The hash value is calculated over the CBOR unencoded CRED_R. 2931 The CBOR diagnostic notation is: 2933 ID_CRED_R = 2934 { 2935 34: [-15, h'6844078A53F312F5'] 2936 } 2938 which when encoded as a CBOR map becomes: 2940 ID_CRED_R (14 bytes) 2941 a1 18 22 82 2e 48 68 44 07 8a 53 f3 12 f5 2943 Since no auxiliary data is sent: 2945 AD_2 (0 bytes) 2947 The plaintext is defined as the empty string: 2949 P_2m (0 bytes) 2950 The Enc_structure is defined as follows: [ "Encrypt0", 2951 << ID_CRED_R >>, << TH_2, CRED_R >> ], indicating that ID_CRED_R is 2952 encoded as a CBOR byte string, and that the concatenation of the CBOR 2953 byte strings TH_2 and CRED_R is wrapped as a CBOR bstr. The CBOR 2954 diagnostic notation is the following: 2956 A_2m = 2957 [ 2958 "Encrypt0", 2959 h'A11822822E486844078A53F312F5', 2960 h'5820864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF 2961 5864C788370016B8965BDB2074BFF82E5A20E09BEC21F8406E86442B87EC3FF245B70A 2962 47624DC9CDC6824B2A4C52E95EC9D6B0534B71C2B49E4BF9031500CEE6869979C297BB 2963 5A8B381E98DB714108415E5C50DB78974C271579B01633A3EF6271BE5C225EB2' 2964 ] 2966 Which encodes to the following byte string to be used as Additional 2967 Authenticated Data: 2969 A_2m (CBOR-encoded) (163 bytes) 2970 83 68 45 6e 63 72 79 70 74 30 4e a1 18 22 82 2e 48 68 44 07 8a 53 f3 12 2971 f5 58 88 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 2972 72 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 58 64 c7 88 37 00 16 b8 96 5b db 2973 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 6e 86 44 2b 87 ec 3f f2 45 b7 0a 2974 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e c9 d6 b0 53 4b 71 c2 b4 9e 4b f9 2975 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 38 1e 98 db 71 41 08 41 5e 5c 50 2976 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 71 be 5c 22 5e b2 2978 info for K_2m is defined as follows in CBOR diagnostic notation: 2980 info for K_2m = 2981 [ 2982 10, 2983 h'864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF', 2984 "K_2m", 2985 16 2986 ] 2988 Which as a CBOR encoded data item is: 2990 info for K_2m (CBOR-encoded) (42 bytes) 2991 84 0a 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 2992 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 64 4b 5f 32 6d 10 2994 From these parameters, K_2m is computed. Key K_2m is the output of 2995 HKDF-Expand(PRK_3e2m, info, L), where L is the length of K_2m, so 16 2996 bytes. 2998 K_2m (16 bytes) 2999 80 cc a7 49 ab 58 f5 69 ca 35 da ee 05 be d1 94 3001 info for IV_2m is defined as follows, in CBOR diagnostic notation (10 3002 is the COSE algorithm no. of the AEAD algorithm in the selected 3003 cipher suite 0): 3005 info for IV_2m = 3006 [ 3007 10, 3008 h'864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF', 3009 "IV_2m", 3010 13 3011 ] 3013 Which as a CBOR encoded data item is: 3015 info for IV_2m (CBOR-encoded) (43 bytes) 3016 84 0a 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 3017 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 65 49 56 5f 32 6d 0d 3019 From these parameters, IV_2m is computed. IV_2m is the output of 3020 HKDF-Expand(PRK_3e2m, info, L), where L is the length of IV_2m, so 13 3021 bytes. 3023 IV_2m (13 bytes) 3024 c8 1e 1a 95 cc 93 b3 36 69 6e d5 02 55 3026 Finally, COSE_Encrypt0 is computed from the parameters above. 3028 * protected header = CBOR-encoded ID_CRED_R 3030 * external_aad = A_2m 3032 * empty plaintext = P_2m 3034 MAC_2 (CBOR unencoded) (8 bytes) 3035 fa bb a4 7e 56 71 a1 82 3037 To compute the Signature_or_MAC_2, the key is the private 3038 authentication key of the Responder and the message M_2 to be signed 3039 = [ "Signature1", << ID_CRED_R >>, << TH_2, CRED_R, ? AD_2 >>, MAC_2 3040 ]. ID_CRED_R is encoded as a CBOR byte string, the concatenation of 3041 the CBOR byte strings TH_2 and CRED_R is wrapped as a CBOR bstr, and 3042 MAC_2 is encoded as a CBOR bstr. 3044 M_2 = 3045 [ 3046 "Signature1", 3047 h'A11822822E486844078A53F312F5', 3048 h'5820864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629F 3049 F5864C788370016B8965BDB2074BFF82E5A20E09BEC21F8406E86442B87EC3FF245B7 3050 0A47624DC9CDC6824B2A4C52E95EC9D6B0534B71C2B49E4BF9031500CEE6869979C29 3051 7BB5A8B381E98DB714108415E5C50DB78974C271579B01633A3EF6271BE5C225EB2', 3052 h'FABBA47E5671A182' 3053 ] 3055 Which as a CBOR encoded data item is: 3057 M_2 (174 bytes) 3058 84 6a 53 69 67 6e 61 74 75 72 65 31 4e a1 18 22 82 2e 48 68 44 07 8a 53 3059 f3 12 f5 58 88 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a 3060 ce 99 72 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 58 64 c7 88 37 00 16 b8 96 3061 5b db 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 6e 86 44 2b 87 ec 3f f2 45 3062 b7 0a 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e c9 d6 b0 53 4b 71 c2 b4 9e 3063 4b f9 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 38 1e 98 db 71 41 08 41 5e 3064 5c 50 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 71 be 5c 22 5e b2 48 fa bb 3065 a4 7e 56 71 a1 82 3067 Since the method = 0, Signature_or_MAC_2 is a signature. The 3068 algorithm with selected cipher suite 0 is Ed25519 and the output is 3069 64 bytes. 3071 Signature_or_MAC_2 (CBOR unencoded) (64 bytes) 3072 1f 17 00 6a 98 48 c9 77 cb bd ca a7 57 b6 fd 46 82 c8 17 39 e1 5c 99 37 3073 c2 1c f5 e9 a0 e6 03 9f 54 fd 2a 6c 3a 11 18 f2 b9 d8 eb cd 48 23 48 b9 3074 9c 3e d7 ed 1b d9 80 6c 93 c8 90 68 e8 36 b4 0f 3076 CIPHERTEXT_2 is the ciphertext resulting from XOR between plaintext 3077 and KEYSTREAM_2 which is derived from TH_2 and the pseudorandom key 3078 PRK_2e. 3080 * plaintext = CBOR Sequence of the items ID_CRED_R and 3081 Signature_or_MAC_2 encoded as CBOR byte strings, in this order 3082 (AD_2 is empty). 3084 The plaintext is the following: 3086 P_2e (CBOR Sequence) (80 bytes) 3087 a1 18 22 82 2e 48 68 44 07 8a 53 f3 12 f5 58 40 1f 17 00 6a 98 48 c9 77 3088 cb bd ca a7 57 b6 fd 46 82 c8 17 39 e1 5c 99 37 c2 1c f5 e9 a0 e6 03 9f 3089 54 fd 2a 6c 3a 11 18 f2 b9 d8 eb cd 48 23 48 b9 9c 3e d7 ed 1b d9 80 6c 3090 93 c8 90 68 e8 36 b4 0f 3091 KEYSTREAM_2 = HKDF-Expand( PRK_2e, info, length ), where length is 3092 the length of the plaintext, so 80. 3094 info for KEYSTREAM_2 = 3095 [ 3096 10, 3097 h'864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF', 3098 "KEYSTREAM_2", 3099 80 3100 ] 3102 Which as a CBOR encoded data item is: 3104 info for KEYSTREAM_2 (CBOR-encoded) (50 bytes) 3105 84 0a 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 3106 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 6b 4b 45 59 53 54 52 45 41 4d 5f 32 3107 18 50 3109 From there, KEYSTREAM_2 is computed: 3111 KEYSTREAM_2 (80 bytes) 3112 ae ea 8e af 50 cf c6 70 09 da e8 2d 8d 85 b0 e7 60 91 bf 0f 07 0b 79 53 3113 6c 83 23 dc 3d 9d 61 13 10 35 94 63 f4 4b 12 4b ea b3 a1 9d 09 93 82 d7 3114 30 80 17 f4 92 62 06 e4 f5 44 9b 9f c9 24 bc b6 bd 78 ec 45 0a 66 83 fb 3115 8a 2f 5f 92 4f c4 40 4f 3117 Using the parameters above, the ciphertext CIPHERTEXT_2 can be 3118 computed: 3120 CIPHERTEXT_2 (CBOR unencoded) (80 bytes) 3121 0f f2 ac 2d 7e 87 ae 34 0e 50 bb de 9f 70 e8 a7 7f 86 bf 65 9f 43 b0 24 3122 a7 3e e9 7b 6a 2b 9c 55 92 fd 83 5a 15 17 8b 7c 28 af 54 74 a9 75 81 48 3123 64 7d 3d 98 a8 73 1e 16 4c 9c 70 52 81 07 f4 0f 21 46 3b a8 11 bf 03 97 3124 19 e7 cf fa a7 f2 f4 40 3126 message_2 is the CBOR Sequence of data_2 and CIPHERTEXT_2, in this 3127 order: 3129 message_2 = 3130 ( 3131 data_2, 3132 h'0FF2AC2D7E87AE340E50BBDE9F70E8A77F86BF659F43B024A73EE97B6A2B9C5592FD 3133 835A15178B7C28AF5474A9758148647D3D98A8731E164C9C70528107F40F21463BA811 3134 BF039719E7CFFAA7F2F440' 3135 ) 3137 Which as a CBOR encoded data item is: 3139 message_2 (CBOR Sequence) (117 bytes) 3140 58 20 71 a3 d5 99 c2 1d a1 89 02 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 3141 19 52 81 75 4c 5e bc af 30 1e 37 58 50 0f f2 ac 2d 7e 87 ae 34 0e 50 bb 3142 de 9f 70 e8 a7 7f 86 bf 65 9f 43 b0 24 a7 3e e9 7b 6a 2b 9c 55 92 fd 83 3143 5a 15 17 8b 7c 28 af 54 74 a9 75 81 48 64 7d 3d 98 a8 73 1e 16 4c 9c 70 3144 52 81 07 f4 0f 21 46 3b a8 11 bf 03 97 19 e7 cf fa a7 f2 f4 40 3146 B.1.3. Message_3 3148 Since corr equals 1, C_R is not omitted from data_3. 3150 The Initiator's sign/verify key pair is the following: 3152 SK_I (Initiator's private authentication key) (32 bytes) 3153 2f fc e7 a0 b2 b8 25 d3 97 d0 cb 54 f7 46 e3 da 3f 27 59 6e e0 6b 53 71 3154 48 1d c0 e0 12 bc 34 d7 3156 PK_I (Responder's public authentication key) (32 bytes) 3157 38 e5 d5 45 63 c2 b6 a4 ba 26 f3 01 5f 61 bb 70 6e 5c 2e fd b5 56 d2 e1 3158 69 0b 97 fc 3c 6d e1 49 3160 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 3162 PRK_4x3m = HMAC-SHA-256 (PRK_3e2m, G_IY) 3164 PRK_4x3m (32 bytes) 3165 ec 62 92 a0 67 f1 37 fc 7f 59 62 9d 22 6f bf c4 e0 68 89 49 f6 62 a9 7f 3166 d8 2f be b7 99 71 39 4a 3168 data 3 is equal to C_R. 3170 data_3 (CBOR Sequence) (1 byte) 3171 37 3173 From data_3, CIPHERTEXT_2, and TH_2, compute the input to the 3174 transcript hash TH_3 = H(TH_2 , CIPHERTEXT_2, data_3), as a CBOR 3175 Sequence of these 3 data items. 3177 Input to calculate TH_3 (CBOR Sequence) (117 bytes) 3178 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 d3 76 3179 d2 c2 c1 53 c1 7f 8e 96 29 ff 58 50 0f f2 ac 2d 7e 87 ae 34 0e 50 bb de 3180 9f 70 e8 a7 7f 86 bf 65 9f 43 b0 24 a7 3e e9 7b 6a 2b 9c 55 92 fd 83 5a 3181 15 17 8b 7c 28 af 54 74 a9 75 81 48 64 7d 3d 98 a8 73 1e 16 4c 9c 70 52 3182 81 07 f4 0f 21 46 3b a8 11 bf 03 97 19 e7 cf fa a7 f2 f4 40 37 3184 And from there, compute the transcript hash TH_3 = SHA-256(TH_2 , 3185 CIPHERTEXT_2, data_3) 3187 TH_3 (CBOR unencoded) (32 bytes) 3188 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 65 0c 30 70 3189 b6 f5 1e 68 e2 ae bb 60 3191 The Initiator's subject name is the empty string: 3193 Initiator's subject name (text string) 3194 "" 3196 In this version of the test vectors CRED_I is not a DER encoded X.509 3197 certificate, but a string of random bytes. 3199 CRED_I (CBOR unencoded) (101 bytes) 3200 54 13 20 4c 3e bc 34 28 a6 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 7e c6 3201 56 1e 52 43 3a a5 5e 71 f1 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 76 60 3202 88 09 84 49 cb 84 8f fc 79 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 67 5e 3203 8f 6c 77 a4 a2 c3 01 95 60 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 48 65 3204 02 ff 7b dd a6 3206 CRED_I is defined to be the CBOR bstr containing the credential of 3207 the Initiator. 3209 CRED_I (103 bytes) 3210 58 65 54 13 20 4c 3e bc 34 28 a6 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 3211 7e c6 56 1e 52 43 3a a5 5e 71 f1 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 3212 76 60 88 09 84 49 cb 84 8f fc 79 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 3213 67 5e 8f 6c 77 a4 a2 c3 01 95 60 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 3214 48 65 02 ff 7b dd a6 3216 And because certificates are identified by a hash value with the 3217 'x5t' parameter, ID_CRED_I is the following: 3219 ID_CRED_I = { 34 : COSE_CertHash }. In this example, the hash 3220 algorithm used is SHA-2 256-bit with hash truncated to 64-bits (value 3221 -15). The hash value is calculated over the CBOR unencoded CRED_I. 3223 ID_CRED_I = 3224 { 3225 34: [-15, h'705D5845F36FC6A6'] 3226 } 3228 which when encoded as a CBOR map becomes: 3230 ID_CRED_I (14 bytes) 3231 a1 18 22 82 2e 48 70 5d 58 45 f3 6f c6 a6 3233 Since no auxiliary data is exchanged: 3235 AD_3 (0 bytes) 3237 The plaintext of the COSE_Encrypt is the empty string: 3239 P_3m (0 bytes) 3241 The associated data is the following: [ "Encrypt0", << ID_CRED_I >>, 3242 << TH_3, CRED_I, ? AD_3 >> ]. 3244 A_3m (CBOR-encoded) (164 bytes) 3245 83 68 45 6e 63 72 79 70 74 30 4e a1 18 22 82 2e 48 70 5d 58 45 f3 6f c6 3246 a6 58 89 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 3247 0f 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 58 65 54 13 20 4c 3e bc 34 28 a6 3248 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 7e c6 56 1e 52 43 3a a5 5e 71 f1 3249 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 76 60 88 09 84 49 cb 84 8f fc 79 3250 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 67 5e 8f 6c 77 a4 a2 c3 01 95 60 3251 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 48 65 02 ff 7b dd a6 3253 Info for K_3m is computed as follows: 3255 info for K_3m = 3256 [ 3257 10, 3258 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3259 "K_3m", 3260 16 3261 ] 3263 Which as a CBOR encoded data item is: 3265 info for K_3m (CBOR-encoded) (42 bytes) 3266 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3267 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 64 4b 5f 33 6d 10 3269 From these parameters, K_3m is computed. Key K_3m is the output of 3270 HKDF-Expand(PRK_4x3m, info, L), where L is the length of K_2m, so 16 3271 bytes. 3273 K_3m (16 bytes) 3274 83 a9 c3 88 02 91 2e 7f 8f 0d 2b 84 14 d1 e5 2c 3276 Nonce IV_3m is the output of HKDF-Expand(PRK_4x3m, info, L), where L 3277 = 13 bytes. 3279 Info for IV_3m is defined as follows: 3281 info for IV_3m = 3282 [ 3283 10, 3284 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3285 "IV_3m", 3286 13 3287 ] 3289 Which as a CBOR encoded data item is: 3291 info for IV_3m (CBOR-encoded) (43 bytes) 3292 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3293 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 65 49 56 5f 33 6d 0d 3295 From these parameters, IV_3m is computed: 3297 IV_3m (13 bytes) 3298 9c 83 9c 0e e8 36 42 50 5a 8e 1c 9f b2 3300 MAC_3 is the 'ciphertext' of the COSE_Encrypt0: 3302 MAC_3 (CBOR unencoded) (8 bytes) 3303 2f a1 e3 9e ae 7d 5f 8d 3305 Since the method = 0, Signature_or_MAC_3 is a signature. The 3306 algorithm with selected cipher suite 0 is Ed25519. 3308 * The message M_3 to be signed = [ "Signature1", << ID_CRED_I >>, 3309 << TH_3, CRED_I >>, MAC_3 ], i.e. ID_CRED_I encoded as CBOR bstr, 3310 the concatenation of the CBOR byte strings TH_3 and CRED_I wrapped 3311 as a CBOR bstr, and MAC_3 encoded as a CBOR bstr. 3313 * The signing key is the private authentication key of the 3314 Initiator. 3316 M_3 = 3317 [ 3318 "Signature1", 3319 h'A11822822E48705D5845F36FC6A6', 3320 h'5820F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB6 3321 058655413204C3EBC3428A6CF57E24C9DEF59651770449BCE7EC6561E52433AA55E71 3322 F1FA34B22A9CA4A1E12924EAE1D1766088098449CB848FFC795F88AFC49CBE8AFDD1B 3323 A009F21675E8F6C77A4A2C30195601F6F0A0852978BD43D28207D44486502FF7BDD 3324 A6', 3325 h'2FA1E39EAE7D5F8D'] 3327 Which as a CBOR encoded data item is: 3329 M_3 (175 bytes) 3330 84 6a 53 69 67 6e 61 74 75 72 65 31 4e a1 18 22 82 2e 48 70 5d 58 45 f3 3331 6f c6 a6 58 89 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 3332 9c 7c 0f 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 58 65 54 13 20 4c 3e bc 34 3333 28 a6 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 7e c6 56 1e 52 43 3a a5 5e 3334 71 f1 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 76 60 88 09 84 49 cb 84 8f 3335 fc 79 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 67 5e 8f 6c 77 a4 a2 c3 01 3336 95 60 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 48 65 02 ff 7b dd a6 48 2f 3337 a1 e3 9e ae 7d 5f 8d 3339 From there, the 64 byte signature can be computed: 3341 Signature_or_MAC_3 (CBOR unencoded) (64 bytes) 3342 ab 9f 7b bd eb c4 eb f8 a3 d3 04 17 9b cc a3 9d 9c 8a 76 73 65 76 fb 3c 3343 32 d2 fa c7 e2 59 34 e5 33 dc c7 02 2e 4d 68 61 c8 f5 fe cb e9 2d 17 4e 3344 b2 be af 0a 59 a4 15 84 37 2f 43 2e 6b f4 7b 04 3346 Finally, the outer COSE_Encrypt0 is computed. 3348 The plaintext is the CBOR Sequence of the items ID_CRED_I and the 3349 CBOR encoded Signature_or_MAC_3, in this order (AD_3 is empty). 3351 P_3ae (CBOR Sequence) (80 bytes) 3352 a1 18 22 82 2e 48 70 5d 58 45 f3 6f c6 a6 58 40 ab 9f 7b bd eb c4 eb f8 3353 a3 d3 04 17 9b cc a3 9d 9c 8a 76 73 65 76 fb 3c 32 d2 fa c7 e2 59 34 e5 3354 33 dc c7 02 2e 4d 68 61 c8 f5 fe cb e9 2d 17 4e b2 be af 0a 59 a4 15 84 3355 37 2f 43 2e 6b f4 7b 04 3357 The Associated data A is the following: Associated data A = [ 3358 "Encrypt0", h'', TH_3 ] 3360 A_3ae (CBOR-encoded) (45 bytes) 3361 83 68 45 6e 63 72 79 70 74 30 40 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 3362 29 c1 52 ab 3a ea 9c 7c 0f 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 3364 Key K_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 3366 info is defined as follows: 3368 info for K_3ae = 3369 [ 3370 10, 3371 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3372 "K_3ae", 3373 16 3374 ] 3376 Which as a CBOR encoded data item is: 3378 info for K_3ae (CBOR-encoded) (43 bytes) 3379 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3380 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 65 4b 5f 33 61 65 10 3382 L is the length of K_3ae, so 16 bytes. 3384 From these parameters, K_3ae is computed: 3386 K_3ae (16 bytes) 3387 b8 79 9f e3 d1 50 4f d8 eb 22 c4 72 62 cd bb 05 3389 Nonce IV_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 3391 info is defined as follows: 3393 info for IV_3ae = 3394 [ 3395 10, 3396 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3397 "IV_3ae", 3398 13 3399 ] 3401 Which as a CBOR encoded data item is: 3403 info for IV_3ae (CBOR-encoded) (44 bytes) 3404 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3405 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 66 49 56 5f 33 61 65 0d 3407 L is the length of IV_3ae, so 13 bytes. 3409 From these parameters, IV_3ae is computed: 3411 IV_3ae (13 bytes) 3412 74 c7 de 41 b8 4a 5b b7 19 0a 85 98 dc 3414 Using the parameters above, the 'ciphertext' CIPHERTEXT_3 can be 3415 computed: 3417 CIPHERTEXT_3 (CBOR unencoded) (88 bytes) 3418 f5 f6 de bd 82 14 05 1c d5 83 c8 40 96 c4 80 1d eb f3 5b 15 36 3d d1 6e 3419 bd 85 30 df dc fb 34 fc d2 eb 6c ad 1d ac 66 a4 79 fb 38 de aa f1 d3 0a 3420 7e 68 17 a2 2a b0 4f 3d 5b 1e 97 2a 0d 13 ea 86 c6 6b 60 51 4c 96 57 ea 3421 89 c5 7b 04 01 ed c5 aa 8b bc ab 81 3c c5 d6 e7 3423 From the parameter above, message_3 is computed, as the CBOR Sequence 3424 of the following CBOR encoded data items: (C_R, CIPHERTEXT_3). 3426 message_3 = 3427 ( 3428 -24, 3429 h'F5F6DEBD8214051CD583C84096C4801DEBF35B15363DD16EBD8530DFDCFB34FCD2EB 3430 6CAD1DAC66A479FB38DEAAF1D30A7E6817A22AB04F3D5B1E972A0D13EA86C66B60514C 3431 9657EA89C57B0401EDC5AA8BBCAB813CC5D6E7' 3432 ) 3434 Which encodes to the following byte string: 3436 message_3 (CBOR Sequence) (91 bytes) 3437 37 58 58 f5 f6 de bd 82 14 05 1c d5 83 c8 40 96 c4 80 1d eb f3 5b 15 36 3438 3d d1 6e bd 85 30 df dc fb 34 fc d2 eb 6c ad 1d ac 66 a4 79 fb 38 de aa 3439 f1 d3 0a 7e 68 17 a2 2a b0 4f 3d 5b 1e 97 2a 0d 13 ea 86 c6 6b 60 51 4c 3440 96 57 ea 89 c5 7b 04 01 ed c5 aa 8b bc ab 81 3c c5 d6 e7 3442 B.1.4. OSCORE Security Context Derivation 3444 From here, the Initiator and the Responder can derive an OSCORE 3445 Security Context, using the EDHOC-Exporter interface. 3447 From TH_3 and CIPHERTEXT_3, compute the input to the transcript hash 3448 TH_4 = H( TH_3, CIPHERTEXT_3 ), as a CBOR Sequence of these 2 data 3449 items. 3451 Input to calculate TH_4 (CBOR Sequence) (124 bytes) 3452 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 65 0c 3453 30 70 b6 f5 1e 68 e2 ae bb 60 58 58 f5 f6 de bd 82 14 05 1c d5 83 c8 40 3454 96 c4 80 1d eb f3 5b 15 36 3d d1 6e bd 85 30 df dc fb 34 fc d2 eb 6c ad 3455 1d ac 66 a4 79 fb 38 de aa f1 d3 0a 7e 68 17 a2 2a b0 4f 3d 5b 1e 97 2a 3456 0d 13 ea 86 c6 6b 60 51 4c 96 57 ea 89 c5 7b 04 01 ed c5 aa 8b bc ab 81 3457 3c c5 d6 e7 3459 And from there, compute the transcript hash TH_4 = SHA-256(TH_3 , 3460 CIPHERTEXT_4) 3462 TH_4 (CBOR unencoded) (32 bytes) 3463 3b 69 a6 7f ec 7e 73 6c c1 a9 52 6c da 00 02 d4 09 f5 b9 ea 0a 2b e9 60 3464 51 a6 e3 0d 93 05 fd 51 3466 The Master Secret and Master Salt are derived as follows: 3468 Master Secret = EDHOC-Exporter( "OSCORE Master Secret", 16 ) = EDHOC- 3469 KDF(PRK_4x3m, TH_4, "OSCORE Master Secret", 16) = HKDF-Expand( 3470 PRK_4x3m, info_ms, 16 ) 3471 Master Salt = EDHOC-Exporter( "OSCORE Master Salt", 8 ) = EDHOC- 3472 KDF(PRK_4x3m, TH_4, "OSCORE Master Salt", 8) = HKDF-Expand( PRK_4x3m, 3473 info_salt, 8 ) 3475 info_ms for OSCORE Master Secret is defined as follows: 3477 info_ms = [ 3478 10, 3479 h'3B69A67FEC7E736CC1A9526CDA0002D409F5B9EA0A2BE96051A6E30D9305FD51', 3480 "OSCORE Master Secret", 3481 16 3482 ] 3484 Which as a CBOR encoded data item is: 3486 info_ms for OSCORE Master Secret (CBOR-encoded) (58 bytes) 3487 84 0a 58 20 3b 69 a6 7f ec 7e 73 6c c1 a9 52 6c da 00 02 d4 09 f5 b9 ea 3488 0a 2b e9 60 51 a6 e3 0d 93 05 fd 51 74 4f 53 43 4f 52 45 20 4d 61 73 74 3489 65 72 20 53 65 63 72 65 74 10 3491 info_salt for OSCORE Master Salt is defined as follows: 3493 info_salt = [ 3494 10, 3495 h'3B69A67FEC7E736CC1A9526CDA0002D409F5B9EA0A2BE96051A6E30D9305FD51', 3496 "OSCORE Master Salt", 3497 8 3498 ] 3500 Which as a CBOR encoded data item is: 3502 info for OSCORE Master Salt (CBOR-encoded) (56 Bytes) 3503 84 0a 58 20 3b 69 a6 7f ec 7e 73 6c c1 a9 52 6c da 00 02 d4 09 f5 b9 ea 3504 0a 2b e9 60 51 a6 e3 0d 93 05 fd 51 72 4f 53 43 4f 52 45 20 4d 61 73 74 3505 65 72 20 53 61 6c 74 08 3507 From these parameters, OSCORE Master Secret and OSCORE Master Salt 3508 are computed: 3510 OSCORE Master Secret (16 bytes) 3511 96 aa 88 ce 86 5e ba 1f fa f3 89 64 13 2c c4 42 3513 OSCORE Master Salt (8 bytes) 3514 5e c3 ee 41 7c fb ba e9 3516 The client's OSCORE Sender ID is C_R and the server's OSCORE Sender 3517 ID is C_I. 3519 Client's OSCORE Sender ID (1 byte) 3520 00 3522 Server's OSCORE Sender ID (1 byte) 3523 09 3525 The AEAD Algorithm and the hash algorithm are the application AEAD 3526 and hash algorithms in the selected cipher suite. 3528 OSCORE AEAD Algorithm (int) 3529 10 3531 OSCORE Hash Algorithm (int) 3532 -16 3534 B.2. Test Vectors for EDHOC Authenticated with Static Diffie-Hellman 3535 Keys 3537 EDHOC with static Diffie-Hellman keys and raw public keys is used. 3538 In this test vector, a key identifier is used to identify the raw 3539 public key. The optional C_1 in message_1 is omitted. No auxiliary 3540 data is sent in the message exchange. 3542 method (Static DH Based Authentication) 3543 3 3545 CoAP is used as transport and the Initiator acts as CoAP client: 3547 corr (the Initiator can correlate message_1 and message_2) 3548 1 3550 From there, METHOD_CORR has the following value: 3552 METHOD_CORR (4 * method + corr) (int) 3553 13 3555 The Initiator indicates only one cipher suite in the (potentially 3556 truncated) list of cipher suites. 3558 Supported Cipher Suites (1 byte) 3559 00 3561 The Initiator selected the indicated cipher suite. 3563 Selected Cipher Suite (int) 3564 0 3565 Cipher suite 0 is supported by both the Initiator and the Responder, 3566 see Section 3.4. 3568 B.2.1. Message_1 3570 The Initiator generates its ephemeral key pair. 3572 X (Initiator's ephemeral private key) (32 bytes) 3573 ae 11 a0 db 86 3c 02 27 e5 39 92 fe b8 f5 92 4c 50 d0 a7 ba 6e ea b4 ad 3574 1f f2 45 72 f4 f5 7c fa 3576 G_X (Initiator's ephemeral public key, CBOR unencoded) (32 bytes) 3577 8d 3e f5 6d 1b 75 0a 43 51 d6 8a c2 50 a0 e8 83 79 0e fc 80 a5 38 a4 44 3578 ee 9e 2b 57 e2 44 1a 7c 3580 The Initiator chooses a connection identifier C_I: 3582 Connection identifier chosen by Initiator (1 byte) 3583 16 3585 Note that since C_I is a byte string in the interval h'00' to h'2f', 3586 it is encoded as the corresponding integer - 24 (see bstr_identifier 3587 in Section 5.1), i.e. 0x16 = 22, 22 - 24 = -2, and -2 in CBOR 3588 encoding is equal to 0x21. 3590 C_I (1 byte) 3591 21 3593 Since no auxiliary data is sent: 3595 AD_1 (0 bytes) 3597 Since the list of supported cipher suites needs to contain the 3598 selected cipher suite, the initiator truncates the list of supported 3599 cipher suites to one cipher suite only, 00. 3601 Because one single selected cipher suite is conveyed, it is encoded 3602 as an int instead of an array: 3604 SUITES_I (int) 3605 0 3607 message_1 is constructed as the CBOR Sequence of the data items above 3608 encoded as CBOR. In CBOR diagnostic notation: 3610 message_1 = 3611 ( 3612 13, 3613 0, 3614 h'8D3EF56D1B750A4351D68AC250A0E883790EFC80A538A444EE9E2B57E2441A7C', 3615 -2 3616 ) 3618 Which as a CBOR encoded data item is: 3620 message_1 (CBOR Sequence) (37 bytes) 3621 0d 00 58 20 8d 3e f5 6d 1b 75 0a 43 51 d6 8a c2 50 a0 e8 83 79 0e fc 80 3622 a5 38 a4 44 ee 9e 2b 57 e2 44 1a 7c 21 3624 B.2.2. Message_2 3626 Since METHOD_CORR mod 4 equals 1, C_I is omitted from data_2. 3628 The Responder generates the following ephemeral key pair. 3630 Y (Responder's ephemeral private key) (32 bytes) 3631 c6 46 cd dc 58 12 6e 18 10 5f 01 ce 35 05 6e 5e bc 35 f4 d4 cc 51 07 49 3632 a3 a5 e0 69 c1 16 16 9a 3634 G_Y (Responder's ephemeral public key, CBOR unencoded) (32 bytes) 3635 52 fb a0 bd c8 d9 53 dd 86 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db fc 33 3636 01 04 70 69 45 1b af 35 3638 From G_X and Y or from G_Y and X the ECDH shared secret is computed: 3640 G_XY (ECDH shared secret) (32 bytes) 3641 de fc 2f 35 69 10 9b 3d 1f a4 a7 3d c5 e2 fe b9 e1 15 0d 90 c2 5e e2 f0 3642 66 c2 d8 85 f4 f8 ac 4e 3644 The key and nonce for calculating the 'ciphertext' are calculated as 3645 follows, as specified in Section 4. 3647 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 3649 PRK_2e = HMAC-SHA-256(salt, G_XY) 3651 Salt is the empty byte string. 3653 salt (0 bytes) 3655 From there, PRK_2e is computed: 3657 PRK_2e (32 bytes) 3658 93 9f cb 05 6d 2e 41 4f 1b ec 61 04 61 99 c2 c7 63 d2 7f 0c 3d 15 fa 16 3659 71 fa 13 4e 0d c5 a0 4d 3661 The Responder's static Diffie-Hellman key pair is the following: 3663 R (Responder's private authentication key) (32 bytes) 3664 bb 50 1a ac 67 b9 a9 5f 97 e0 ed ed 6b 82 a6 62 93 4f bb fc 7a d1 b7 4c 3665 1f ca d6 6a 07 94 22 d0 3667 G_R (Responder's public authentication key) (32 bytes) 3668 a3 ff 26 35 95 be b3 77 d1 a0 ce 1d 04 da d2 d4 09 66 ac 6b cb 62 20 51 3669 b8 46 59 18 4d 5d 9a 32 3671 Since the Responder authenticates with a static Diffie-Hellman key, 3672 PRK_3e2m = HKDF-Extract( PRK_2e, G_RX ), where G_RX is the ECDH 3673 shared secret calculated from G_R and X, or G_X and R. 3675 From the Responder's authentication key and the Initiator's ephemeral 3676 key (see Appendix B.2.1), the ECDH shared secret G_RX is calculated. 3678 G_RX (ECDH shared secret) (32 bytes) 3679 21 c7 ef f4 fb 69 fa 4b 67 97 d0 58 84 31 5d 84 11 a3 fd a5 4f 6d ad a6 3680 1d 4f cd 85 e7 90 66 68 3682 PRK_3e2m (32 bytes) 3683 75 07 7c 69 1e 35 01 2d 48 bc 24 c8 4f 2b ab 89 f5 2f ac 03 fe dd 81 3e 3684 43 8c 93 b1 0b 39 93 07 3686 The Responder chooses a connection identifier C_R. 3688 Connection identifier chosen by Responder (1 byte) 3689 00 3691 Note that since C_R is a byte string in the interval h'00' to h'2f', 3692 it is encoded as the corresponding integer - 24 (see bstr_identifier 3693 in Section 5.1), i.e. 0x00 = 0, 0 - 24 = -24, and -24 in CBOR 3694 encoding is equal to 0x37. 3696 C_R (1 byte) 3697 37 3699 Data_2 is constructed as the CBOR Sequence of G_Y and C_R. 3701 data_2 = 3702 ( 3703 h'52FBA0BDC8D953DD86CE1AB2FD7C05A4658C7C30AFDBFC3301047069451BAF35', 3704 -24 3705 ) 3707 Which as a CBOR encoded data item is: 3709 data_2 (CBOR Sequence) (35 bytes) 3710 58 20 52 fb a0 bd c8 d9 53 dd 86 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db 3711 fc 33 01 04 70 69 45 1b af 35 37 3713 From data_2 and message_1, compute the input to the transcript hash 3714 TH_2 = H( message_1, data_2 ), as a CBOR Sequence of these 2 data 3715 items. 3717 Input to calculate TH_2 (CBOR Sequence) (72 bytes) 3718 0d 00 58 20 8d 3e f5 6d 1b 75 0a 43 51 d6 8a c2 50 a0 e8 83 79 0e fc 80 3719 a5 38 a4 44 ee 9e 2b 57 e2 44 1a 7c 21 58 20 52 fb a0 bd c8 d9 53 dd 86 3720 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db fc 33 01 04 70 69 45 1b af 35 37 3722 And from there, compute the transcript hash TH_2 = SHA-256( 3723 message_1, data_2 ) 3725 TH_2 (CBOR unencoded) (32 bytes) 3726 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 36 d0 cf 8c 3727 73 a6 e8 a7 c3 62 1e 26 3729 The Responder's subject name is the empty string: 3731 Responder's subject name (text string) 3732 "" 3734 ID_CRED_R is the following: 3736 ID_CRED_R = 3737 { 3738 4: h'05' 3739 } 3741 ID_CRED_R (4 bytes) 3742 a1 04 41 05 3744 CRED_R is the following COSE_Key: 3746 { 3747 1: 1, 3748 -1: 4, 3749 -2: h'A3FF263595BEB377D1A0CE1D04DAD2D40966AC6BCB622051B84659184D5D9A32, 3750 "subject name": "" 3751 } 3753 Which encodes to the following byte string: 3755 CRED_R (54 bytes) 3756 a4 01 01 20 04 21 58 20 a3 ff 26 35 95 be b3 77 d1 a0 ce 1d 04 da d2 d4 3757 09 66 ac 6b cb 62 20 51 b8 46 59 18 4d 5d 9a 32 6c 73 75 62 6a 65 63 74 3758 20 6e 61 6d 65 60 3760 Since no auxiliary data is sent: 3762 AD_2 (0 bytes) 3764 The plaintext is defined as the empty string: 3766 P_2m (0 bytes) 3768 The Enc_structure is defined as follows: [ "Encrypt0", 3769 << ID_CRED_R >>, << TH_2, CRED_R >> ], so ID_CRED_R is encoded as a 3770 CBOR bstr, and the concatenation of the CBOR byte strings TH_2 and 3771 CRED_R is wrapped in a CBOR bstr. 3773 A_2m = 3774 [ 3775 "Encrypt0", 3776 h'A1044105', 3777 h'5820DECFD64A3667640A0233B04AA8AA91F68956B8A536D0CF8C73A6E8A7C3621E2 3778 6A401012004215820A3FF263595BEB377D1A0CE1D04DAD2D40966AC6BCB622051B846 3779 59184D5D9A326C7375626A656374206E616D6560' 3780 ] 3782 Which encodes to the following byte string to be used as Additional 3783 Authenticated Data: 3785 A_2m (CBOR-encoded) (105 bytes) 3786 83 68 45 6e 63 72 79 70 74 30 44 a1 04 41 05 58 58 58 20 de cf d6 4a 36 3787 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 36 d0 cf 8c 73 a6 e8 a7 c3 3788 62 1e 26 a4 01 01 20 04 21 58 20 a3 ff 26 35 95 be b3 77 d1 a0 ce 1d 04 3789 da d2 d4 09 66 ac 6b cb 62 20 51 b8 46 59 18 4d 5d 9a 32 6c 73 75 62 6a 3790 65 63 74 20 6e 61 6d 65 60 3792 info for K_2m is defined as follows: 3794 info for K_2m = 3795 [ 3796 10, 3797 h'DECFD64A3667640A0233B04AA8AA91F68956B8A536D0CF8C73A6E8A7C3621E26', 3798 "K_2m", 3799 16 3800 ] 3802 Which as a CBOR encoded data item is: 3804 info for K_2m (CBOR-encoded) (42 bytes) 3805 84 0a 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 3806 36 d0 cf 8c 73 a6 e8 a7 c3 62 1e 26 64 4b 5f 32 6d 10 3808 From these parameters, K_2m is computed. Key K_2m is the output of 3809 HKDF-Expand(PRK_3e2m, info, L), where L is the length of K_2m, so 16 3810 bytes. 3812 K_2m (16 bytes) 3813 4e cd ef ba d8 06 81 8b 62 51 b9 d7 86 78 bc 76 3815 info for IV_2m is defined as follows: 3817 info for IV_2m = 3818 [ 3819 10, 3820 h'A51C76463E8AE58FD3B8DC5EDE1E27143CC92D223EACD9E5FF6E3FAC876658A5', 3821 "IV_2m", 3822 13 3823 ] 3825 Which as a CBOR encoded data item is: 3827 info for IV_2m (CBOR-encoded) (43 bytes) 3828 84 0a 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 3829 36 d0 cf 8c 73 a6 e8 a7 c3 62 1e 26 65 49 56 5f 32 6d 0d 3831 From these parameters, IV_2m is computed. IV_2m is the output of 3832 HKDF-Expand(PRK_3e2m, info, L), where L is the length of IV_2m, so 13 3833 bytes. 3835 IV_2m (13 bytes) 3836 e9 b8 e4 b1 bd 02 f4 9a 82 0d d3 53 4f 3838 Finally, COSE_Encrypt0 is computed from the parameters above. 3840 * protected header = CBOR-encoded ID_CRED_R 3841 * external_aad = A_2m 3843 * empty plaintext = P_2m 3845 MAC_2 is the 'ciphertext' of the COSE_Encrypt0 with empty plaintext. 3846 In case of cipher suite 0 the AEAD is AES-CCM truncated to 8 bytes: 3848 MAC_2 (CBOR unencoded) (8 bytes) 3849 42 e7 99 78 43 1e 6b 8f 3851 Since method = 2, Signature_or_MAC_2 is MAC_2: 3853 Signature_or_MAC_2 (CBOR unencoded) (8 bytes) 3854 42 e7 99 78 43 1e 6b 8f 3856 CIPHERTEXT_2 is the ciphertext resulting from XOR between plaintext 3857 and KEYSTREAM_2 which is derived from TH_2 and the pseudorandom key 3858 PRK_2e. 3860 The plaintext is the CBOR Sequence of the items ID_CRED_R and the 3861 CBOR encoded Signature_or_MAC_2, in this order (AD_2 is empty). 3863 Note that since ID_CRED_R contains a single 'kid' parameter, i.e., 3864 ID_CRED_R = { 4 : kid_R }, only the byte string kid_R is conveyed in 3865 the plaintext encoded as a bstr_identifier. kid_R is encoded as the 3866 corresponding integer - 24 (see bstr_identifier in Section 5.1), i.e. 3867 0x05 = 5, 5 - 24 = -19, and -19 in CBOR encoding is equal to 0x32. 3869 The plaintext is the following: 3871 P_2e (CBOR Sequence) (10 bytes) 3872 32 48 42 e7 99 78 43 1e 6b 8f 3874 KEYSTREAM_2 = HKDF-Expand( PRK_2e, info, length ), where length is 3875 the length of the plaintext, so 10. 3877 info for KEYSTREAM_2 = 3878 [ 3879 10, 3880 h'DECFD64A3667640A0233B04AA8AA91F68956B8A536D0CF8C73A6E8A7C3621E26', 3881 "KEYSTREAM_2", 3882 10 3883 ] 3885 Which as a CBOR encoded data item is: 3887 info for KEYSTREAM_2 (CBOR-encoded) (49 bytes) 3888 84 0a 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 3889 36 d0 cf 8c 73 a6 e8 a7 c3 62 1e 26 6b 4b 45 59 53 54 52 45 41 4d 5f 32 3890 0a 3892 From there, KEYSTREAM_2 is computed: 3894 KEYSTREAM_2 (10 bytes) 3895 91 b9 ff ba 9b f5 5a d1 57 16 3897 Using the parameters above, the ciphertext CIPHERTEXT_2 can be 3898 computed: 3900 CIPHERTEXT_2 (CBOR unencoded) (10 bytes) 3901 a3 f1 bd 5d 02 8d 19 cf 3c 99 3903 message_2 is the CBOR Sequence of data_2 and CIPHERTEXT_2, in this 3904 order: 3906 message_2 = 3907 ( 3908 data_2, 3909 h'A3F1BD5D028D19CF3C99' 3910 ) 3912 Which as a CBOR encoded data item is: 3914 message_2 (CBOR Sequence) (46 bytes) 3915 58 20 52 fb a0 bd c8 d9 53 dd 86 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db 3916 fc 33 01 04 70 69 45 1b af 35 37 4a a3 f1 bd 5d 02 8d 19 cf 3c 99 3918 B.2.3. Message_3 3920 Since corr equals 1, C_R is not omitted from data_3. 3922 The Initiator's static Diffie-Hellman key pair is the following: 3924 I (Initiator's private authentication key) (32 bytes) 3925 2b be a6 55 c2 33 71 c3 29 cf bd 3b 1f 02 c6 c0 62 03 38 37 b8 b5 90 99 3926 a4 43 6f 66 60 81 b0 8e 3928 G_I (Initiator's public authentication key, CBOR unencoded) (32 bytes) 3929 2c 44 0c c1 21 f8 d7 f2 4c 3b 0e 41 ae da fe 9c aa 4f 4e 7a bb 83 5e c3 3930 0f 1d e8 8a db 96 ff 71 3932 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 3934 From the Initiator's authentication key and the Responder's ephemeral 3935 key (see Appendix B.2.2), the ECDH shared secret G_IY is calculated. 3937 G_IY (ECDH shared secret) (32 bytes) 3938 cb ff 8c d3 4a 81 df ec 4c b6 5d 9a 57 2e bd 09 64 45 0c 78 56 3d a4 98 3939 1d 80 d3 6c 8b 1a 75 2a 3941 PRK_4x3m = HMAC-SHA-256 (PRK_3e2m, G_IY). 3943 PRK_4x3m (32 bytes) 3944 02 56 2f 1f 01 78 5c 0a a5 f5 94 64 0c 49 cb f6 9f 72 2e 9e 6c 57 83 7d 3945 8e 15 79 ec 45 fe 64 7a 3947 data 3 is equal to C_R. 3949 data_3 (CBOR Sequence) (1 byte) 3950 37 3952 From data_3, CIPHERTEXT_2, and TH_2, compute the input to the 3953 transcript hash TH_3 = H(TH_2 , CIPHERTEXT_2, data_3), as a CBOR 3954 Sequence of these 3 data items. 3956 Input to calculate TH_3 (CBOR Sequence) (46 bytes) 3957 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 36 d0 3958 cf 8c 73 a6 e8 a7 c3 62 1e 26 4a a3 f1 bd 5d 02 8d 19 cf 3c 99 37 3960 And from there, compute the transcript hash TH_3 = SHA-256(TH_2 , 3961 CIPHERTEXT_2, data_3) 3963 TH_3 (CBOR unencoded) (32 bytes) 3964 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 d7 cb 8b 84 3965 db 03 ff a5 83 a3 5f cb 3967 The initiator's subject name is the empty string: 3969 Initiator's subject name (text string) 3970 "" 3972 And its credential is: 3974 ID_CRED_I = 3975 { 3976 4: h'23' 3977 } 3979 ID_CRED_I (4 bytes) 3980 a1 04 41 23 3981 CRED_I is the following COSE_Key: 3983 { 3984 1: 1, 3985 -1: 4, 3986 -2: h'2C440CC121F8D7F24C3B0E41AEDAFE9CAA4F4E7ABB835EC30F1DE88ADB96FF71', 3987 "subject name": "" 3988 } 3990 Which encodes to the following byte string: 3992 CRED_I (54 bytes) 3993 a4 01 01 20 04 21 58 20 2c 44 0c c1 21 f8 d7 f2 4c 3b 0e 41 ae da fe 9c 3994 aa 4f 4e 7a bb 83 5e c3 0f 1d e8 8a db 96 ff 71 6c 73 75 62 6a 65 63 74 3995 20 6e 61 6d 65 60 3997 Since no auxiliary data is exchanged: 3999 AD_3 (0 bytes) 4001 The plaintext of the COSE_Encrypt is the empty string: 4003 P_3m (0 bytes) 4005 The associated data is the following: [ "Encrypt0", << ID_CRED_I >>, 4006 << TH_3, CRED_I, ? AD_3 >> ]. 4008 A_3m (CBOR-encoded) (105 bytes) 4009 83 68 45 6e 63 72 79 70 74 30 44 a1 04 41 23 58 58 58 20 b6 cd 80 4f c4 4010 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 d7 cb 8b 84 db 03 ff a5 83 4011 a3 5f cb a4 01 01 20 04 21 58 20 2c 44 0c c1 21 f8 d7 f2 4c 3b 0e 41 ae 4012 da fe 9c aa 4f 4e 7a bb 83 5e c3 0f 1d e8 8a db 96 ff 71 6c 73 75 62 6a 4013 65 63 74 20 6e 61 6d 65 60 4015 Info for K_3m is computed as follows: 4017 info for K_3m = 4018 [ 4019 10, 4020 h'B6CD804FC4B9D7CAC502ABD77CDA74E41CB01182D7CB8B84DB03FFA583A35FCB', 4021 "K_3m", 4022 16 4023 ] 4025 Which as a CBOR encoded data item is: 4027 info for K_3m (CBOR-encoded) (42 bytes) 4028 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 4029 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 64 4b 5f 33 6d 10 4031 From these parameters, K_3m is computed. Key K_3m is the output of 4032 HKDF-Expand(PRK_4x3m, info, L), where L is the length of K_2m, so 16 4033 bytes. 4035 K_3m (16 bytes) 4036 02 c7 e7 93 89 9d 90 d1 28 28 10 26 96 94 c9 58 4038 Nonce IV_3m is the output of HKDF-Expand(PRK_4x3m, info, L), where L 4039 = 13 bytes. 4041 Info for IV_3m is defined as follows: 4043 info for IV_3m = 4044 [ 4045 10, 4046 h'B6CD804FC4B9D7CAC502ABD77CDA74E41CB01182D7CB8B84DB03FFA583A35FCB', 4047 "IV_3m", 4048 13 4049 ] 4051 Which as a CBOR encoded data item is: 4053 info for IV_3m (CBOR-encoded) (43 bytes) 4054 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 4055 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 65 49 56 5f 33 6d 0d 4057 From these parameters, IV_3m is computed: 4059 IV_3m (13 bytes) 4060 0d a7 cc 3a 6f 9a b2 48 52 ce 8b 37 a6 4062 MAC_3 is the 'ciphertext' of the COSE_Encrypt0 with empty plaintext. 4063 In case of cipher suite 0 the AEAD is AES-CCM truncated to 8 bytes: 4065 MAC_3 (CBOR unencoded) (8 bytes) 4066 ee 59 8e a6 61 17 dc c3 4068 Since method = 3, Signature_or_MAC_3 is MAC_3: 4070 Signature_or_MAC_3 (CBOR unencoded) (8 bytes) 4071 ee 59 8e a6 61 17 dc c3 4073 Finally, the outer COSE_Encrypt0 is computed. 4075 The plaintext is the CBOR Sequence of the items ID_CRED_I and the 4076 CBOR encoded Signature_or_MAC_3, in this order (AD_3 is empty). 4078 Note that since ID_CRED_I contains a single 'kid' parameter, i.e., 4079 ID_CRED_I = { 4 : kid_I }, only the byte string kid_I is conveyed in 4080 the plaintext encoded as a bstr_identifier. kid_I is encoded as the 4081 corresponding integer - 24 (see bstr_identifier in Section 5.1), i.e. 4082 0x23 = 35, 35 - 24 = 11, and 11 in CBOR encoding is equal to 0x0b. 4084 P_3ae (CBOR Sequence) (10 bytes) 4085 0b 48 ee 59 8e a6 61 17 dc c3 4087 The Associated data A is the following: Associated data A = [ 4088 "Encrypt0", h'', TH_3 ] 4090 A_3ae (CBOR-encoded) (45 bytes) 4091 83 68 45 6e 63 72 79 70 74 30 40 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab 4092 d7 7c da 74 e4 1c b0 11 82 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 4094 Key K_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 4096 info is defined as follows: 4098 info for K_3ae = 4099 [ 4100 10, 4101 h'B6CD804FC4B9D7CAC502ABD77CDA74E41CB01182D7CB8B84DB03FFA583A35FCB', 4102 "K_3ae", 4103 16 4104 ] 4106 Which as a CBOR encoded data item is: 4108 info for K_3ae (CBOR-encoded) (43 bytes) 4109 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 4110 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 65 4b 5f 33 61 65 10 4112 L is the length of K_3ae, so 16 bytes. 4114 From these parameters, K_3ae is computed: 4116 K_3ae (16 bytes) 4117 6b a4 c8 83 1d e3 ae 23 e9 8e f7 35 08 d0 95 86 4119 Nonce IV_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 4121 info is defined as follows: 4123 info for IV_3ae = 4124 [ 4125 10, 4126 h'97D8AD42334833EB25B960A5EB0704505F89671A0168AA1115FAF92D9E67EF04', 4127 "IV_3ae", 4128 13 4129 ] 4131 Which as a CBOR encoded data item is: 4133 info for IV_3ae (CBOR-encoded) (44 bytes) 4134 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 4135 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 66 49 56 5f 33 61 65 0d 4137 L is the length of IV_3ae, so 13 bytes. 4139 From these parameters, IV_3ae is computed: 4141 IV_3ae (13 bytes) 4142 6c 6d 0f e1 1e 9a 1a f3 7b 87 84 55 10 4144 Using the parameters above, the 'ciphertext' CIPHERTEXT_3 can be 4145 computed: 4147 CIPHERTEXT_3 (CBOR unencoded) (18 bytes) 4148 d5 53 5f 31 47 e8 5f 1c fa cd 9e 78 ab f9 e0 a8 1b bf 4150 From the parameter above, message_3 is computed, as the CBOR Sequence 4151 of the following items: (C_R, CIPHERTEXT_3). 4153 message_3 = 4154 ( 4155 -24, 4156 h'D5535F3147E85F1CFACD9E78ABF9E0A81BBF' 4157 ) 4159 Which encodes to the following byte string: 4161 message_3 (CBOR Sequence) (20 bytes) 4162 37 52 d5 53 5f 31 47 e8 5f 1c fa cd 9e 78 ab f9 e0 a8 1b bf 4164 B.2.4. OSCORE Security Context Derivation 4166 From here, the Initiator and the Responder can derive an OSCORE 4167 Security Context, using the EDHOC-Exporter interface. 4169 From TH_3 and CIPHERTEXT_3, compute the input to the transcript hash 4170 TH_4 = H( TH_3, CIPHERTEXT_3 ), as a CBOR Sequence of these 2 data 4171 items. 4173 Input to calculate TH_4 (CBOR Sequence) (53 bytes) 4174 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 d7 cb 4175 8b 84 db 03 ff a5 83 a3 5f cb 52 d5 53 5f 31 47 e8 5f 1c fa cd 9e 78 ab 4176 f9 e0 a8 1b bf 4178 And from there, compute the transcript hash TH_4 = SHA-256(TH_3 , 4179 CIPHERTEXT_4) 4181 TH_4 (CBOR unencoded) (32 bytes) 4182 7c cf de dc 2c 10 ca 03 56 e9 57 b9 f6 a5 92 e0 fa 74 db 2a b5 4f 59 24 4183 40 96 f9 a2 ac 56 d2 07 4185 The Master Secret and Master Salt are derived as follows: 4187 Master Secret = EDHOC-Exporter( "OSCORE Master Secret", 16 ) = EDHOC- 4188 KDF(PRK_4x3m, TH_4, "OSCORE Master Secret", 16) = HKDF-Expand( 4189 PRK_4x3m, info_ms, 16 ) 4191 Master Salt = EDHOC-Exporter( "OSCORE Master Salt", 8 ) = EDHOC- 4192 KDF(PRK_4x3m, TH_4, "OSCORE Master Salt", 8) = HKDF-Expand( PRK_4x3m, 4193 info_salt, 8 ) 4195 info_ms for OSCORE Master Secret is defined as follows: 4197 info_ms = [ 4198 10, 4199 h'7CCFDEDC2C10CA0356E957B9F6A592E0FA74DB2AB54F59244096F9A2AC56D207', 4200 "OSCORE Master Secret", 4201 16 4202 ] 4204 Which as a CBOR encoded data item is: 4206 info_ms for OSCORE Master Secret (CBOR-encoded) (58 bytes) 4207 84 0a 58 20 7c cf de dc 2c 10 ca 03 56 e9 57 b9 f6 a5 92 e0 fa 74 db 2a 4208 b5 4f 59 24 40 96 f9 a2 ac 56 d2 07 74 4f 53 43 4f 52 45 20 4d 61 73 74 4209 65 72 20 53 65 63 72 65 74 10 4211 info_salt for OSCORE Master Salt is defined as follows: 4213 info_salt = [ 4214 10, 4215 h'7CCFDEDC2C10CA0356E957B9F6A592E0FA74DB2AB54F59244096F9A2AC56D207', 4216 "OSCORE Master Salt", 4217 8 4218 ] 4220 Which as a CBOR encoded data item is: 4222 info for OSCORE Master Salt (CBOR-encoded) (56 Bytes) 4223 84 0a 58 20 7c cf de dc 2c 10 ca 03 56 e9 57 b9 f6 a5 92 e0 fa 74 db 2a 4224 b5 4f 59 24 40 96 f9 a2 ac 56 d2 07 72 4f 53 43 4f 52 45 20 4d 61 73 74 4225 65 72 20 53 61 6c 74 08 4227 From these parameters, OSCORE Master Secret and OSCORE Master Salt 4228 are computed: 4230 OSCORE Master Secret (16 bytes) 4231 c3 4a 50 6d 0e bf bd 17 03 04 86 13 5f 9c b3 50 4233 OSCORE Master Salt (8 bytes) 4234 c2 24 34 9d 9b 34 ca 8c 4236 The client's OSCORE Sender ID is C_R and the server's OSCORE Sender 4237 ID is C_I. 4239 Client's OSCORE Sender ID (1 byte) 4240 00 4242 Server's OSCORE Sender ID (1 byte) 4243 16 4245 The AEAD Algorithm and the hash algorithm are the application AEAD 4246 and hash algorithms in the selected cipher suite. 4248 OSCORE AEAD Algorithm (int) 4249 10 4251 OSCORE Hash Algorithm (int) 4252 -16 4254 Appendix C. Applicability Template 4256 This appendix contains an example of an applicability statement, see 4257 Section 3.7. 4259 For use of EDHOC in the XX protocol, the following assumptions are 4260 made on the parameters: 4262 * METHOD_CORR = 5 4264 - method = 1 (I uses signature key, R uses static DH key.) 4266 - corr = 1 (CoAP Token or other transport data enables 4267 correlation between message_1 and message_2.) 4269 * EDHOC requests are expected by the server at /app1-edh, no 4270 Content-Format needed. 4272 * C_1 = "null" is present to identify message_1 4274 * CRED_I is an 802.1AR IDevID encoded as a C509 Certificate of type 4275 0 [I-D.mattsson-cose-cbor-cert-compress]. 4277 - R acquires CRED_I out-of-band, indicated in AD_1 4279 - ID_CRED_I = {4: h''} is a kid with value empty byte string 4281 * CRED_R is a COSE_Key of type OKP as specified in Section 3.3.4. 4283 - The CBOR map has parameters 1 (kty), -1 (crv), and -2 4284 (x-coordinate). 4286 * ID_CRED_R = CRED_R 4288 * AD_1 contains Auxiliary Data of type A (TBD) 4290 * AD_2 contains Auxiliary Data of type B (TBD) 4292 * No use of message_4: the application sends protected messages from 4293 R to I. 4295 * Auxiliary Data is processed as specified in 4296 [I-D.selander-ace-ake-authz]. 4298 Appendix D. EDHOC Message Deduplication 4300 EDHOC by default assumes that message duplication is handled by the 4301 transport, in this section exemplified with CoAP. 4303 Deduplication of CoAP messages is described in Section 4.5 of 4304 [RFC7252]. This handles the case when the same Confirmable (CON) 4305 message is received multiple times due to missing acknowledgement on 4306 CoAP messaging layer. The recommended processing in [RFC7252] is 4307 that the duplicate message is acknowledged (ACK), but the received 4308 message is only processed once by the CoAP stack. 4310 Message deduplication is resource demanding and therefore not 4311 supported in all CoAP implementations. Since EDHOC is targeting 4312 constrained environments, it is desirable that EDHOC can optionally 4313 support transport layers which does not handle message duplication. 4314 Special care is needed to avoid issues with duplicate messages, see 4315 Section 5.2. 4317 The guiding principle here is similar to the deduplication processing 4318 on CoAP messaging layer: a received duplicate EDHOC message SHALL NOT 4319 result in a response consisting of another instance of the next EDHOC 4320 message. The result MAY be that a duplicate EDHOC response is sent, 4321 provided it is still relevant with respect the current protocol 4322 state. In any case, the received message MUST NOT be processed more 4323 than once by the same EDHOC instance. This is called "EDHOC message 4324 deduplication". 4326 An EDHOC implementation MAY store the previously sent EDHOC message 4327 to be able to resend it. An EDHOC implementation MAY keep the 4328 protocol state to be able to recreate the previously sent EDHOC 4329 message and resend it. The previous message or protocol state MUST 4330 NOT be kept longer than what is required for retransmission, for 4331 example, in the case of CoAP transport, no longer than the 4332 EXCHANGE_LIFETIME (see Section 4.8.2 of [RFC7252]). 4334 Note that the requirements in Section 5.2 still apply because 4335 duplicate messages are not processed by the EDHOC state machine: 4337 * EDHOC messages SHALL be processed according to the current 4338 protocol state. 4340 * Different instances of the same message MUST NOT be processed in 4341 one protocol instance. 4343 Appendix E. Change Log 4345 Main changes: 4347 * From -05 to -06: 4349 - New section 5.2 "Message Processing Outline" 4351 - Optional inital byte C_1 = null in message_1 4353 - New format of error messages, table of error codes, IANA 4354 registry 4356 - Change of recommendation transport of error in CoAP 4357 - Merge of content in 3.7 and appendix C into new section 3.7 4358 "Applicability Statement" 4360 - Requiring use of deterministic CBOR 4362 - New section on message deduplication 4364 - New appendix containin all CDDL definitions 4366 - New appendix with change log 4368 - Removed section "Other Documents Referncing EDHOC" 4370 - Clarifications based on review comments 4372 * From -04 to -05: 4374 - EDHOC-Rekey-FS -> EDHOC-KeyUpdate 4376 - Clarification of cipher suite negotiation 4378 - Updated security considerations 4380 - Updated test vectors 4382 - Updated applicability statement template 4384 * From -03 to -04: 4386 - Restructure of section 1 4388 - Added references to C509 Certificates 4390 - Change in CIPHERTEXT_2 -> plaintext XOR KEYSTREAM_2 (test 4391 vector not updated) 4393 - "K_2e", "IV_2e" -> KEYSTREAM_2 4395 - Specified optional message 4 4397 - EDHOC-Exporter-FS -> EDHOC-Rekey-FS 4399 - Less constrained devices SHOULD implement both suite 0 and 2 4401 - Clarification of error message 4403 - Added exporter interface test vector 4405 * From -02 to -03: 4407 - Rearrangements of section 3 and beginning of section 4 4409 - Key derivation new section 4 4411 - Cipher suites 4 and 5 added 4413 - EDHOC-EXPORTER-FS - generate a new PRK_4x3m from an old one 4415 - Change in CIPHERTEXT_2 -> COSE_Encrypt0 without tag (no change 4416 to test vector) 4418 - Clarification of error message 4420 - New appendix C applicability statement 4422 * From -01 to -02: 4424 - New section 1.2 Use of EDHOC 4426 - Clarification of identities 4428 - New section 4.3 clarifying bstr_identifier 4430 - Updated security considerations 4432 - Updated text on cipher suite negotiation and key confirmation 4434 - Test vector for static DH 4436 * From -00 to -01: 4438 - Removed PSK method 4440 - Removed references to certificate by value 4442 Acknowledgments 4444 The authors want to thank Alessandro Bruni, Karthikeyan Bhargavan, 4445 Timothy Claeys, Martin Disch, Theis Groenbech Petersen, Dan Harkins, 4446 Klaus Hartke, Russ Housley, Stefan Hristozov, Alexandros Krontiris, 4447 Ilari Liusvaara, Karl Norrman, Salvador Perez, Eric Rescorla, Michael 4448 Richardson, Thorvald Sahl Joergensen, Jim Schaad, Carsten Schuermann, 4449 Ludwig Seitz, Stanislav Smyshlyaev, Valery Smyslov, Peter van der 4450 Stok, Rene Struik, Vaishnavi Sundararajan, Erik Thormarker, Marco 4451 Tiloca, Michel Veillette, and Malisa Vucinic for reviewing and 4452 commenting on intermediate versions of the draft. We are especially 4453 indebted to Jim Schaad for his continuous reviewing and 4454 implementation of different versions of the draft. 4456 Work on this document has in part been supported by the H2020 project 4457 SIFIS-Home (grant agreement 952652). 4459 Authors' Addresses 4461 Göran Selander 4462 Ericsson AB 4464 Email: goran.selander@ericsson.com 4466 John Preuß Mattsson 4467 Ericsson AB 4469 Email: john.mattsson@ericsson.com 4471 Francesca Palombini 4472 Ericsson AB 4474 Email: francesca.palombini@ericsson.com