idnits 2.17.1 draft-ietf-lake-edhoc-08.txt: 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: ---------------------------------------------------------------------------- No issues found here. 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 2 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 (July 12, 2021) is 1017 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 1773 -- Looks like a reference, but probably isn't: '5' on line 1773 -- Looks like a reference, but probably isn't: '9' on line 1769 -- Looks like a reference, but probably isn't: '8' on line 1773 -- Looks like a reference, but probably isn't: '7' on line 1773 == Outdated reference: A later version (-14) exists of draft-ietf-core-echo-request-tag-12 ** Downref: Normative reference to an Informational draft: draft-ietf-cose-rfc8152bis-algs (ref. 'I-D.ietf-cose-rfc8152bis-algs') -- Possible downref: Normative reference to a draft: ref. 'I-D.ietf-cose-rfc8152bis-struct' == Outdated reference: A later version (-09) exists of draft-ietf-cose-x509-08 ** Downref: Normative reference to an Informational draft: draft-ietf-lake-reqs (ref. 'I-D.ietf-lake-reqs') == Outdated reference: A later version (-09) exists of draft-ietf-rats-uccs-00 ** 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 (-11) exists of draft-ietf-core-oscore-edhoc-00 == Outdated reference: A later version (-09) exists of draft-ietf-cose-cbor-encoded-cert-00 == Outdated reference: A later version (-07) exists of draft-ietf-lwig-security-protocol-comparison-05 == Outdated reference: A later version (-04) exists of draft-mattsson-cfrg-det-sigs-with-noise-02 == Outdated reference: A later version (-05) exists of draft-selander-ace-ake-authz-02 Summary: 8 errors (**), 0 flaws (~~), 9 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: January 13, 2022 Ericsson AB 6 July 12, 2021 8 Ephemeral Diffie-Hellman Over COSE (EDHOC) 9 draft-ietf-lake-edhoc-08 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 January 13, 2022. 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 46 (https://trustee.ietf.org/license-info) in effect on the date of 47 publication of this document. Please review these documents 48 carefully, as they describe your rights and restrictions with respect 49 to this document. Code Components extracted from this document must 50 include Simplified BSD License text as described in Section 4.e of 51 the Trust Legal Provisions and are provided without warranty as 52 described in the Simplified BSD License. 54 Table of Contents 56 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 57 1.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . 3 58 1.2. Use of EDHOC . . . . . . . . . . . . . . . . . . . . . . 4 59 1.3. Message Size Examples . . . . . . . . . . . . . . . . . . 5 60 1.4. Document Structure . . . . . . . . . . . . . . . . . . . 6 61 1.5. Terminology and Requirements Language . . . . . . . . . . 6 62 2. EDHOC Outline . . . . . . . . . . . . . . . . . . . . . . . . 6 63 3. Protocol Elements . . . . . . . . . . . . . . . . . . . . . . 8 64 3.1. General . . . . . . . . . . . . . . . . . . . . . . . . . 8 65 3.2. Method . . . . . . . . . . . . . . . . . . . . . . . . . 9 66 3.3. Connection Identifiers . . . . . . . . . . . . . . . . . 9 67 3.4. Transport . . . . . . . . . . . . . . . . . . . . . . . . 11 68 3.5. Authentication Parameters . . . . . . . . . . . . . . . . 11 69 3.6. Cipher Suites . . . . . . . . . . . . . . . . . . . . . . 16 70 3.7. Ephemeral Public Keys . . . . . . . . . . . . . . . . . . 18 71 3.8. External Authorization Data . . . . . . . . . . . . . . . 18 72 3.9. Applicability Statement . . . . . . . . . . . . . . . . . 19 73 4. Key Derivation . . . . . . . . . . . . . . . . . . . . . . . 21 74 4.1. EDHOC-Exporter Interface . . . . . . . . . . . . . . . . 23 75 5. Message Formatting and Processing . . . . . . . . . . . . . . 24 76 5.1. Message Processing Outline . . . . . . . . . . . . . . . 24 77 5.2. EDHOC Message 1 . . . . . . . . . . . . . . . . . . . . . 25 78 5.3. EDHOC Message 2 . . . . . . . . . . . . . . . . . . . . . 27 79 5.4. EDHOC Message 3 . . . . . . . . . . . . . . . . . . . . . 30 80 5.5. EDHOC Message 4 . . . . . . . . . . . . . . . . . . . . . 33 81 6. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 35 82 6.1. Success . . . . . . . . . . . . . . . . . . . . . . . . . 36 83 6.2. Unspecified . . . . . . . . . . . . . . . . . . . . . . . 36 84 6.3. Wrong Selected Cipher Suite . . . . . . . . . . . . . . . 36 85 7. Security Considerations . . . . . . . . . . . . . . . . . . . 38 86 7.1. Security Properties . . . . . . . . . . . . . . . . . . . 38 87 7.2. Cryptographic Considerations . . . . . . . . . . . . . . 40 88 7.3. Cipher Suites and Cryptographic Algorithms . . . . . . . 41 89 7.4. Unprotected Data . . . . . . . . . . . . . . . . . . . . 42 90 7.5. Denial-of-Service . . . . . . . . . . . . . . . . . . . . 42 91 7.6. Implementation Considerations . . . . . . . . . . . . . . 43 92 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 44 93 8.1. EDHOC Exporter Label . . . . . . . . . . . . . . . . . . 44 94 8.2. EDHOC Cipher Suites Registry . . . . . . . . . . . . . . 45 95 8.3. EDHOC Method Type Registry . . . . . . . . . . . . . . . 47 96 8.4. EDHOC Error Codes Registry . . . . . . . . . . . . . . . 47 97 8.5. COSE Header Parameters Registry . . . . . . . . . . . . . 47 98 8.6. COSE Header Parameters Registry . . . . . . . . . . . . . 47 99 8.7. COSE Key Common Parameters Registry . . . . . . . . . . . 48 100 8.8. The Well-Known URI Registry . . . . . . . . . . . . . . . 48 101 8.9. Media Types Registry . . . . . . . . . . . . . . . . . . 48 102 8.10. CoAP Content-Formats Registry . . . . . . . . . . . . . . 49 103 8.11. EDHOC External Authorization Data . . . . . . . . . . . . 49 104 8.12. Expert Review Instructions . . . . . . . . . . . . . . . 50 105 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 50 106 9.1. Normative References . . . . . . . . . . . . . . . . . . 50 107 9.2. Informative References . . . . . . . . . . . . . . . . . 53 108 Appendix A. Use with OSCORE and Transfer over CoAP . . . . . . . 55 109 A.1. Selecting EDHOC Connection Identifier . . . . . . . . . . 55 110 A.2. Deriving the OSCORE Security Context . . . . . . . . . . 56 111 A.3. Transferring EDHOC over CoAP . . . . . . . . . . . . . . 57 112 Appendix B. Compact Representation . . . . . . . . . . . . . . . 60 113 Appendix C. Use of CBOR, CDDL and COSE in EDHOC . . . . . . . . 60 114 C.1. CBOR and CDDL . . . . . . . . . . . . . . . . . . . . . . 60 115 C.2. CDDL Definitions . . . . . . . . . . . . . . . . . . . . 61 116 C.3. COSE . . . . . . . . . . . . . . . . . . . . . . . . . . 62 117 Appendix D. Test Vectors . . . . . . . . . . . . . . . . . . . . 63 118 D.1. Test Vectors for EDHOC Authenticated with Signature Keys 119 (x5t) . . . . . . . . . . . . . . . . . . . . . . . . . . 63 120 D.2. Test Vectors for EDHOC Authenticated with Static Diffie- 121 Hellman Keys . . . . . . . . . . . . . . . . . . . . . . 81 122 Appendix E. Applicability Template . . . . . . . . . . . . . . . 96 123 Appendix F. EDHOC Message Deduplication . . . . . . . . . . . . 96 124 Appendix G. Transports Not Natively Providing Correlation . . . 97 125 Appendix H. Change Log . . . . . . . . . . . . . . . . . . . . . 98 126 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 101 127 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 101 129 1. Introduction 131 1.1. Motivation 133 Many Internet of Things (IoT) deployments require technologies which 134 are highly performant in constrained environments [RFC7228]. IoT 135 devices may be constrained in various ways, including memory, 136 storage, processing capacity, and power. The connectivity for these 137 settings may also exhibit constraints such as unreliable and lossy 138 channels, highly restricted bandwidth, and dynamic topology. The 139 IETF has acknowledged this problem by standardizing a range of 140 lightweight protocols and enablers designed for the IoT, including 141 the Constrained Application Protocol (CoAP, [RFC7252]), Concise 142 Binary Object Representation (CBOR, [RFC8949]), and Static Context 143 Header Compression (SCHC, [RFC8724]). 145 The need for special protocols targeting constrained IoT deployments 146 extends also to the security domain [I-D.ietf-lake-reqs]. Important 147 characteristics in constrained environments are the number of round 148 trips and protocol message sizes, which if kept low can contribute to 149 good performance by enabling transport over a small number of radio 150 frames, reducing latency due to fragmentation or duty cycles, etc. 151 Another important criteria is code size, which may be prohibitive for 152 certain deployments due to device capabilities or network load during 153 firmware update. Some IoT deployments also need to support a variety 154 of underlying transport technologies, potentially even with a single 155 connection. 157 Some security solutions for such settings exist already. CBOR Object 158 Signing and Encryption (COSE, [I-D.ietf-cose-rfc8152bis-struct]) 159 specifies basic application-layer security services efficiently 160 encoded in CBOR. Another example is Object Security for Constrained 161 RESTful Environments (OSCORE, [RFC8613]) which is a lightweight 162 communication security extension to CoAP using CBOR and COSE. In 163 order to establish good quality cryptographic keys for security 164 protocols such as COSE and OSCORE, the two endpoints may run an 165 authenticated Diffie-Hellman key exchange protocol, from which shared 166 secret key material can be derived. Such a key exchange protocol 167 should also be lightweight; to prevent bad performance in case of 168 repeated use, e.g., due to device rebooting or frequent rekeying for 169 security reasons; or to avoid latencies in a network formation 170 setting with many devices authenticating at the same time. 172 This document specifies Ephemeral Diffie-Hellman Over COSE (EDHOC), a 173 lightweight authenticated key exchange protocol providing good 174 security properties including perfect forward secrecy, identity 175 protection, and cipher suite negotiation. Authentication can be 176 based on raw public keys (RPK) or public key certificates, and 177 requires the application to provide input on how to verify that 178 endpoints are trusted. This specification focuses on referencing 179 instead of transporting credentials to reduce message overhead. 181 EDHOC makes use of known protocol constructions, such as SIGMA 182 [SIGMA] and Extract-and-Expand [RFC5869]. COSE also provides crypto 183 agility and enables the use of future algorithms targeting IoT. 185 1.2. Use of EDHOC 187 EDHOC is designed for highly constrained settings making it 188 especially suitable for low-power wide area networks [RFC8376] such 189 as Cellular IoT, 6TiSCH, and LoRaWAN. A main objective for EDHOC is 190 to be a lightweight authenticated key exchange for OSCORE, i.e. to 191 provide authentication and session key establishment for IoT use 192 cases such as those built on CoAP [RFC7252]. CoAP is a specialized 193 web transfer protocol for use with constrained nodes and networks, 194 providing a request/response interaction model between application 195 endpoints. As such, EDHOC is targeting a large variety of use cases 196 involving 'things' with embedded microcontrollers, sensors, and 197 actuators. 199 A typical setting is when one of the endpoints is constrained or in a 200 constrained network, and the other endpoint is a node on the Internet 201 (such as a mobile phone) or at the edge of the constrained network 202 (such as a gateway). Thing-to-thing interactions over constrained 203 networks are also relevant since both endpoints would then benefit 204 from the lightweight properties of the protocol. EDHOC could e.g. be 205 run when a device connects for the first time, or to establish fresh 206 keys which are not revealed by a later compromise of the long-term 207 keys. Further security properties are described in Section 7.1. 209 EDHOC enables the reuse of the same lightweight primitives as OSCORE: 210 CBOR for encoding, COSE for cryptography, and CoAP for transport. By 211 reusing existing libraries the additional code size can be kept very 212 low. Note that, while CBOR and COSE primitives are built into the 213 protocol messages, EDHOC is not bound to a particular transport. 214 However, it is recommended to transfer EDHOC messages in CoAP 215 payloads as is detailed in Appendix A.3. 217 1.3. Message Size Examples 219 Compared to the DTLS 1.3 handshake [I-D.ietf-tls-dtls13] with ECDHE 220 and connection ID, the number of bytes in EDHOC + CoAP can be less 221 than 1/6 when RPK authentication is used, see 222 [I-D.ietf-lwig-security-protocol-comparison]. Figure 1 shows two 223 examples of message sizes for EDHOC with different kinds of 224 authentication keys and different COSE header parameters for 225 identification: static Diffie-Hellman keys identified by 'kid' 226 [I-D.ietf-cose-rfc8152bis-struct], and X.509 signature certificates 227 identified by a hash value using 'x5t' [I-D.ietf-cose-x509]. 229 ================================= 230 kid x5t 231 --------------------------------- 232 message_1 37 37 233 message_2 45 116 234 message_3 20 91 235 --------------------------------- 236 Total 103 245 237 ================================= 239 Figure 1: Example of message sizes in bytes. 241 1.4. Document Structure 243 The remainder of the document is organized as follows: Section 2 244 outlines EDHOC authenticated with digital signatures, Section 3 245 describes the protocol elements of EDHOC, including message flow, and 246 formatting of the ephemeral public keys, Section 4 describes the key 247 derivation, Section 5 specifies EDHOC with authentication based on 248 signature keys or static Diffie-Hellman keys, Section 6 specifies the 249 EDHOC error message, and Appendix A describes how EDHOC can be 250 transferred in CoAP and used to establish an OSCORE security context. 252 1.5. Terminology and Requirements Language 254 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 255 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 256 "OPTIONAL" in this document are to be interpreted as described in BCP 257 14 [RFC2119] [RFC8174] when, and only when, they appear in all 258 capitals, as shown here. 260 Readers are expected to be familiar with the terms and concepts 261 described in CBOR [RFC8949], CBOR Sequences [RFC8742], COSE 262 structures and process [I-D.ietf-cose-rfc8152bis-struct], COSE 263 algorithms [I-D.ietf-cose-rfc8152bis-algs], and CDDL [RFC8610]. The 264 Concise Data Definition Language (CDDL) is used to express CBOR data 265 structures [RFC8949]. Examples of CBOR and CDDL are provided in 266 Appendix C.1. When referring to CBOR, this specification always 267 refer to Deterministically Encoded CBOR as specified in Sections 268 4.2.1 and 4.2.2 of [RFC8949]. 270 The single output from authenticated encryption (including the 271 authentication tag) is called 'ciphertext', following [RFC5116]. 273 2. EDHOC Outline 275 EDHOC specifies different authentication methods of the Diffie- 276 Hellman key exchange: digital signatures and static Diffie-Hellman 277 keys. This section outlines the digital signature based method. 278 Further details of protocol elements and other authentication methods 279 are provided in the remainder of this document. 281 SIGMA (SIGn-and-MAc) is a family of theoretical protocols with a 282 large number of variants [SIGMA]. Like IKEv2 [RFC7296] and (D)TLS 283 1.3 [RFC8446], EDHOC authenticated with digital signatures is built 284 on a variant of the SIGMA protocol which provides identity protection 285 of the initiator (SIGMA-I), and like IKEv2 [RFC7296], EDHOC 286 implements the SIGMA-I variant as MAC-then-Sign. The SIGMA-I 287 protocol using an authenticated encryption algorithm is shown in 288 Figure 2. 290 Initiator Responder 291 | G_X | 292 +-------------------------------------------------------->| 293 | | 294 | G_Y, AEAD( K_2; ID_CRED_R, Sig(R; CRED_R, G_X, G_Y) ) | 295 |<--------------------------------------------------------+ 296 | | 297 | AEAD( K_3; ID_CRED_I, Sig(I; CRED_I, G_Y, G_X) ) | 298 +-------------------------------------------------------->| 299 | | 301 Figure 2: Authenticated encryption variant of the SIGMA-I protocol. 303 The parties exchanging messages are called Initiator (I) and 304 Responder (R). They exchange ephemeral public keys, compute a shared 305 secret, and derive symmetric application keys used to protect 306 application data. 308 o G_X and G_Y are the ECDH ephemeral public keys of I and R, 309 respectively. 311 o CRED_I and CRED_R are the credentials containing the public 312 authentication keys of I and R, respectively. 314 o ID_CRED_I and ID_CRED_R are credential identifiers enabling the 315 recipient party to retrieve the credential of I and R, 316 respectively. 318 o Sig(I; . ) and Sig(R; . ) denote signatures made with the private 319 authentication key of I and R, respectively. 321 o AEAD(K; . ) denotes authenticated encryption with additional data 322 using a key K derived from the shared secret. 324 In order to create a "full-fledged" protocol some additional protocol 325 elements are needed. EDHOC adds: 327 o Transcript hashes (hashes of message data) TH_2, TH_3, TH_4 used 328 for key derivation and as additional authenticated data. 330 o Computationally independent keys derived from the ECDH shared 331 secret and used for authenticated encryption of different 332 messages. 334 o An optional fourth message giving explicit key confirmation to I 335 in deployments where no protected application data is sent from R 336 to I. 338 o A key material exporter and a key update function enabling 339 frequent forward secrecy. 341 o Verification of a common preferred cipher suite: 343 * The Initiator lists supported cipher suites in order of 344 preference 346 * The Responder verifies that the selected cipher suite is the 347 first supported cipher suite (or else rejects and states 348 supported cipher suites). 350 o Method types and error handling. 352 o Selection of connection identifiers C_I and C_R which may be used 353 to identify established keys or protocol state. 355 o Transport of external authorization data. 357 EDHOC is designed to encrypt and integrity protect as much 358 information as possible, and all symmetric keys are derived using as 359 much previous information as possible. EDHOC is furthermore designed 360 to be as compact and lightweight as possible, in terms of message 361 sizes, processing, and the ability to reuse already existing CBOR, 362 COSE, and CoAP libraries. 364 To simplify for implementors, the use of CBOR and COSE in EDHOC is 365 summarized in Appendix C and test vectors including CBOR diagnostic 366 notation are given in Appendix D. 368 3. Protocol Elements 370 3.1. General 372 An EDHOC message flow consists of three mandatory messages 373 (message_1, message_2, message_3) between Initiator and Responder, an 374 optional fourth message (message_4), plus an EDHOC error message. 375 EDHOC messages are CBOR Sequences [RFC8742], see Figure 3. The 376 protocol elements in the figure are introduced in the following 377 sections. Message formatting and processing is specified in 378 Section 5 and Section 6. An implementation may support only 379 Initiator or only Responder. 381 Application data is protected using the agreed application algorithms 382 (AEAD, hash) in the selected cipher suite (see Section 3.6) and the 383 application can make use of the established connection identifiers 384 C_I and C_R (see Section 3.3). EDHOC may be used with the media type 385 application/edhoc defined in Section 8. 387 The Initiator can derive symmetric application keys after creating 388 EDHOC message_3, see Section 4.1. Application protected data can 389 therefore be sent in parallel or together with EDHOC message_3. 391 Initiator Responder 392 | METHOD, SUITES_I, G_X, C_I, EAD_1 | 393 +------------------------------------------------------------------>| 394 | message_1 | 395 | | 396 | G_Y, C_R, Enc(ID_CRED_R, Signature_or_MAC_2, EAD_2) | 397 |<------------------------------------------------------------------+ 398 | message_2 | 399 | | 400 | AEAD(K_3ae; ID_CRED_I, Signature_or_MAC_3, EAD_3) | 401 +------------------------------------------------------------------>| 402 | message_3 | 404 Figure 3: EDHOC Message Flow 406 3.2. Method 408 The data item METHOD in message_1 (see Section 5.2.1), is an integer 409 specifying the authentication method. EDHOC supports authentication 410 with signature or static Diffie-Hellman keys, as defined in the four 411 authentication methods: 0, 1, 2, and 3, see Figure 4. (Method 0 412 corresponds to the case outlined in Section 2 where both Initiator 413 and Responder authenticate with signature keys.) 415 An implementation may support only a single method. The Initiator 416 and the Responder need to have agreed on a single method to be used 417 for EDHOC, see Section 3.9. 419 +-------+-------------------+-------------------+-------------------+ 420 | Value | Initiator | Responder | Reference | 421 +-------+-------------------+-------------------+-------------------+ 422 | 0 | Signature Key | Signature Key | [[this document]] | 423 | 1 | Signature Key | Static DH Key | [[this document]] | 424 | 2 | Static DH Key | Signature Key | [[this document]] | 425 | 3 | Static DH Key | Static DH Key | [[this document]] | 426 +-------+-------------------+-------------------+-------------------+ 428 Figure 4: Method Types 430 3.3. Connection Identifiers 432 EDHOC includes the selection of connection identifiers (C_I, C_R) 433 identifying a connection for which keys are agreed. Connection 434 identifiers may be used in the ongoing EDHOC protocol (see 435 Section 3.3.2) or in a subsequent application protocol, e.g., OSCORE 436 (see Section 3.3.3). The connection identifiers do not have any 437 cryptographic purpose in EDHOC. 439 Connection identifiers in EDHOC are byte strings or integers, encoded 440 in CBOR. One byte connection identifiers (the integers -24 to 23 and 441 the empty bytestring h'') are realistic in many scenarios as most 442 constrained devices only have a few connections. 444 3.3.1. Selection of Connection Identifiers 446 C_I and C_R are chosen by I and R, respectively. The Initiator 447 selects C_I and sends it in message_1 for the Responder to use as a 448 reference to the connection in communications with the Initiator. 449 The Responder selects C_R and sends in message_2 for the Initiator to 450 use as a reference to the connection in communications with the 451 Responder. 453 If connection identifiers are used by an application protocol for 454 which EDHOC establishes keys then the selected connection identifiers 455 SHALL adhere to the requirements for that protocol, see Section 3.3.3 456 for an example. 458 3.3.2. Use of Connection Identifiers in EDHOC 460 Connection identifiers may be used to correlate EDHOC messages and 461 facilitate the retrieval of protocol state during EDHOC protocol 462 execution. EDHOC transports that do not inherently provide 463 correlation across all messages of an exchange can send connection 464 identifiers along with EDHOC messages to gain that required 465 capability, see Section 3.4. For an example when CoAP is used as 466 transport, see Appendix A.3. 468 3.3.3. Use of Connection Identifiers in OSCORE 470 For OSCORE, the choice of a connection identifier results in the 471 endpoint selecting its Recipient ID, see Section 3.1 of [RFC8613]), 472 for which certain uniqueness requirements apply, see Section 3.3 of 473 [RFC8613]). Therefore the Initiator and the Responder MUST NOT 474 select connection identifiers such that it results in same OSCORE 475 Recipient ID. Since the Recipient ID is a byte string and a EDHOC 476 connection identifier is either a CBOR byte string or a CBOR integer, 477 care must be taken when selecting the connection identifiers and 478 converting them to Recipient IDs. A mapping from EDHOC connection 479 identifier to OSCORE Recipient ID is specified in Appendix A.1. 481 3.4. Transport 483 Cryptographically, EDHOC does not put requirements on the lower 484 layers. EDHOC is not bound to a particular transport layer, and can 485 even be used in environments without IP. The transport is 486 responsible, where necessary, to handle: 488 o message loss, 490 o message reordering, 492 o message duplication, 494 o fragmentation, 496 o demultiplex EDHOC messages from other types of messages, and 498 o denial of service protection. 500 Besides these common transport oriented properties, EDHOC transport 501 additionally needs to support the correlation between EDHOC messages, 502 including an indication of a message being message_1. The 503 correlation may reuse existing mechanisms in the transport protocol. 504 For example, the CoAP Token may be used to correlate EDHOC messages 505 in a CoAP response and an associated CoAP request. In the absense of 506 correlation between a message received and a message previously sent 507 inherent to the transport, the EDHOC connection identifiers may be 508 added, e.g. by prepending the appropriate connection identifier (when 509 available from the EDHOC protocol) to the EDHOC message. Transport 510 of EDHOC in CoAP payloads is described in Appendix A.3, which also 511 shows how to use connection identifiers and message_1 indication with 512 CoAP. 514 The Initiator and the Responder need to have agreed on a transport to 515 be used for EDHOC, see Section 3.9. 517 3.5. Authentication Parameters 519 3.5.1. Authentication Keys 521 The authentication key MUST be a signature key or static Diffie- 522 Hellman key. The Initiator and the Responder MAY use different types 523 of authentication keys, e.g. one uses a signature key and the other 524 uses a static Diffie-Hellman key. When using a signature key, the 525 authentication is provided by a signature. When using a static 526 Diffie-Hellman key the authentication is provided by a Message 527 Authentication Code (MAC) computed from an ephemeral-static ECDH 528 shared secret which enables significant reductions in message sizes. 530 The MAC is implemented with an AEAD algorithm. When using static 531 Diffie-Hellman keys the Initiator's and Responder's private 532 authentication keys are called I and R, respectively, and the public 533 authentication keys are called G_I and G_R, respectively. The 534 authentication key algorithm needs to specified with enough 535 parameters to make it completely determined. Note that for most 536 signature algorithms, the signature is determined by the signature 537 algorithm and the authentication key algorithm together. For 538 example, the curve used in the signature is typically determined by 539 the authentication key parameters. 541 o Only the Responder SHALL have access to the Responder's private 542 authentication key. 544 o Only the Initiator SHALL have access to the Initiator's private 545 authentication key. 547 3.5.2. Identities 549 EDHOC assumes the existence of mechanisms (certification authority, 550 trusted third party, manual distribution, etc.) for specifying and 551 distributing authentication keys and identities. Policies are set 552 based on the identity of the other party, and parties typically only 553 allow connections from a specific identity or a small restricted set 554 of identities. For example, in the case of a device connecting to a 555 network, the network may only allow connections from devices which 556 authenticate with certificates having a particular range of serial 557 numbers in the subject field and signed by a particular CA. On the 558 other side, the device may only be allowed to connect to a network 559 which authenticates with a particular public key (information of 560 which may be provisioned, e.g., out of band or in the external 561 authorization data, see Section 3.8). 563 The EDHOC implementation must be able to receive and enforce 564 information from the application about what is the intended endpoint, 565 and in particular whether it is a specific identity or a set of 566 identities. 568 o When a Public Key Infrastructure (PKI) is used, the trust anchor 569 is a Certification Authority (CA) certificate, and the identity is 570 the subject whose unique name (e.g. a domain name, NAI, or EUI) is 571 included in the endpoint's certificate. Before running EDHOC each 572 party needs at least one CA public key certificate, or just the 573 public key, and a specific identity or set of identities it is 574 allowed to communicate with. Only validated public-key 575 certificates with an allowed subject name, as specified by the 576 application, are to be accepted. EDHOC provides proof that the 577 other party possesses the private authentication key corresponding 578 to the public authentication key in its certificate. The 579 certification path provides proof that the subject of the 580 certificate owns the public key in the certificate. 582 o When public keys are used but not with a PKI (RPK, self-signed 583 certificate), the trust anchor is the public authentication key of 584 the other party. In this case, the identity is typically directly 585 associated to the public authentication key of the other party. 586 For example, the name of the subject may be a canonical 587 representation of the public key. Alternatively, if identities 588 can be expressed in the form of unique subject names assigned to 589 public keys, then a binding to identity can be achieved by 590 including both public key and associated subject name in the 591 protocol message computation: CRED_I or CRED_R may be a self- 592 signed certificate or COSE_Key containing the public 593 authentication key and the subject name, see Section 3.5.3. 594 Before running EDHOC, each endpoint needs a specific public 595 authentication key/unique associated subject name, or a set of 596 public authentication keys/unique associated subject names, which 597 it is allowed to communicate with. EDHOC provides proof that the 598 other party possesses the private authentication key corresponding 599 to the public authentication key. 601 3.5.3. Authentication Credentials 603 The authentication credentials, CRED_I and CRED_R, contain the public 604 authentication key of the Initiator and the Responder, respectively. 605 The Initiator and the Responder MAY use different types of 606 credentials, e.g. one uses an RPK and the other uses a public key 607 certificate. 609 The credentials CRED_I and CRED_R are signed or MAC:ed (depending on 610 method) by the Initiator and the Responder, respectively, see 611 Section 5.4 and Section 5.3. 613 When the credential is a certificate, CRED_x is an end-entity 614 certificate (i.e. not the certificate chain) encoded as a CBOR bstr. 615 In X.509 certificates, signature keys typically have key usage 616 "digitalSignature" and Diffie-Hellman keys typically have key usage 617 "keyAgreement". 619 To prevent misbinding attacks in systems where an attacker can 620 register public keys without proving knowledge of the private key, 621 SIGMA [SIGMA] enforces a MAC to be calculated over the "Identity", 622 which in case of a X.509 certificate would be the 'subject' and 623 'subjectAltName' fields. EDHOC follows SIGMA by calculating a MAC 624 over the whole certificate. While the SIGMA paper only focuses on 625 the identity, the same principle is true for any information such as 626 policies connected to the public key. 628 When the credential is a COSE_Key, CRED_x is a CBOR map only 629 containing specific fields from the COSE_Key identifying the public 630 key, and optionally the "Identity". CRED_x needs to be defined such 631 that it is identical when generated by Initiator or Responder. The 632 parameters SHALL be encoded in bytewise lexicographic order of their 633 deterministic encodings as specified in Section 4.2.1 of [RFC8949]. 635 If the parties have agreed on an identity besides the public key, the 636 identity is included in the CBOR map with the label "subject name", 637 otherwise the subject name is the empty text string. The public key 638 parameters depend on key type. 640 o For COSE_Keys of type OKP the CBOR map SHALL, except for subject 641 name, only include the parameters 1 (kty), -1 (crv), and -2 642 (x-coordinate). 644 o For COSE_Keys of type EC2 the CBOR map SHALL, except for subject 645 name, only include the parameters 1 (kty), -1 (crv), -2 646 (x-coordinate), and -3 (y-coordinate). 648 An example of CRED_x when the RPK contains an X25519 static Diffie- 649 Hellman key and the parties have agreed on an EUI-64 identity is 650 shown below: 652 CRED_x = { 653 1: 1, 654 -1: 4, 655 -2: h'b1a3e89460e88d3a8d54211dc95f0b90 656 3ff205eb71912d6db8f4af980d2db83a', 657 "subject name" : "42-50-31-FF-EF-37-32-39" 658 } 660 3.5.4. Identification of Credentials 662 ID_CRED_I and ID_CRED_R are used to identify and optionally transport 663 the public authentication keys of the Initiator and the Responder, 664 respectively. ID_CRED_I and ID_CRED_R do not have any cryptographic 665 purpose in EDHOC. 667 o ID_CRED_R is intended to facilitate for the Initiator to retrieve 668 the Responder's public authentication key. 670 o ID_CRED_I is intended to facilitate for the Responder to retrieve 671 the Initiator's public authentication key. 673 The identifiers ID_CRED_I and ID_CRED_R are COSE header_maps, i.e. 674 CBOR maps containing Common COSE Header Parameters, see Section 3.1 675 of [I-D.ietf-cose-rfc8152bis-struct]). In the following we give some 676 examples of COSE header_maps. 678 Raw public keys are most optimally stored as COSE_Key objects and 679 identified with a 'kid2' parameter (see Section 8.6 and Section 8.7): 681 o ID_CRED_x = { 4 : kid_x }, where kid_x : bstr / int, for x = I or 682 R. 684 Note that the integers -24 to 23 and the empty bytestring h'' are 685 encoded as one byte. 687 Public key certificates can be identified in different ways. Header 688 parameters for identifying C509 certificates and X.509 certificates 689 are defined in [I-D.ietf-cose-cbor-encoded-cert] and 690 [I-D.ietf-cose-x509], for example: 692 o by a hash value with the 'c5t' or 'x5t' parameters; 694 * ID_CRED_x = { 34 : COSE_CertHash }, for x = I or R, 696 * ID_CRED_x = { TDB3 : COSE_CertHash }, for x = I or R, 698 o by a URI with the 'c5u' or 'x5u' parameters; 700 * ID_CRED_x = { 35 : uri }, for x = I or R, 702 * ID_CRED_x = { TBD4 : uri }, for x = I or R, 704 o ID_CRED_x MAY contain the actual credential used for 705 authentication, CRED_x. For example, a certificate chain can be 706 transported in ID_CRED_x with COSE header parameter c5c or 707 x5chain, defined in [I-D.ietf-cose-cbor-encoded-cert] and 708 [I-D.ietf-cose-x509]. 710 It is RECOMMENDED that ID_CRED_x uniquely identify the public 711 authentication key as the recipient may otherwise have to try several 712 keys. ID_CRED_I and ID_CRED_R are transported in the 'ciphertext', 713 see Section 5.4 and Section 5.3. 715 When ID_CRED_x does not contain the actual credential it may be very 716 short. One byte credential identifiers are realistic in many 717 scenarios as most constrained devices only have a few keys. In cases 718 where a node only has one key, the identifier may even be the empty 719 byte string. 721 3.6. Cipher Suites 723 An EDHOC cipher suite consists of an ordered set of algorithms from 724 the "COSE Algorithms" and "COSE Elliptic Curves" registries. 725 Algorithms need to be specified with enough parameters to make them 726 completely determined. Currently, none of the algorithms require 727 parameters. EDHOC is only specified for use with key exchange 728 algorithms of type ECDH curves. Use with other types of key exchange 729 algorithms would likely require a specification updating EDHOC. Note 730 that for most signature algorithms, the signature is determined by 731 the signature algorithm and the authentication key algorithm 732 together, see Section 3.5.1. 734 o EDHOC AEAD algorithm 736 o EDHOC hash algorithm 738 o EDHOC key exchange algorithm (ECDH curve) 740 o EDHOC signature algorithm 742 o Application AEAD algorithm 744 o Application hash algorithm 746 Each cipher suite is identified with a pre-defined int label. 748 EDHOC can be used with all algorithms and curves defined for COSE. 749 Implementation can either use one of the pre-defined cipher suites 750 (Section 8.2) or use any combination of COSE algorithms and 751 parameters to define their own private cipher suite. Private cipher 752 suites can be identified with any of the four values -24, -23, -22, 753 -21. 755 The following CCM cipher suites are for constrained IoT where message 756 overhead is a very important factor. Cipher suites 1 and 3 use a 757 larger tag length (128-bit) in the EDHOC AEAD algorithm than the 758 Application AEAD algorithm (64-bit): 760 0. ( 10, -16, 4, -8, 10, -16 ) 761 (AES-CCM-16-64-128, SHA-256, X25519, EdDSA, 762 AES-CCM-16-64-128, SHA-256) 764 1. ( 30, -16, 4, -8, 10, -16 ) 765 (AES-CCM-16-128-128, SHA-256, X25519, EdDSA, 766 AES-CCM-16-64-128, SHA-256) 768 2. ( 10, -16, 1, -7, 10, -16 ) 769 (AES-CCM-16-64-128, SHA-256, P-256, ES256, 770 AES-CCM-16-64-128, SHA-256) 772 3. ( 30, -16, 1, -7, 10, -16 ) 773 (AES-CCM-16-128-128, SHA-256, P-256, ES256, 774 AES-CCM-16-64-128, SHA-256) 776 The following ChaCha20 cipher suites are for less constrained 777 applications and only use 128-bit tag lengths. 779 4. ( 24, -16, 4, -8, 24, -16 ) 780 (ChaCha20/Poly1305, SHA-256, X25519, EdDSA, 781 ChaCha20/Poly1305, SHA-256) 783 5. ( 24, -16, 1, -7, 24, -16 ) 784 (ChaCha20/Poly1305, SHA-256, P-256, ES256, 785 ChaCha20/Poly1305, SHA-256) 787 The following GCM cipher suite is for general non-constrained 788 applications. It uses high performance algorithms that are widely 789 supported: 791 6. ( 1, -16, 4, -7, 1, -16 ) 792 (A128GCM, SHA-256, X25519, ES256, 793 A128GCM, SHA-256) 795 The following two cipher suites are for high security application 796 such as government use and financial applications. The two cipher 797 suites do not share any algorithms. The first of the two cipher 798 suites is compatible with the CNSA suite [CNSA]. 800 24. ( 3, -43, 2, -35, 3, -43 ) 801 (A256GCM, SHA-384, P-384, ES384, 802 A256GCM, SHA-384) 804 25. ( 24, -45, 5, -8, 24, -45 ) 805 (ChaCha20/Poly1305, SHAKE256, X448, EdDSA, 806 ChaCha20/Poly1305, SHAKE256) 808 The different methods use the same cipher suites, but some algorithms 809 are not used in some methods. The EDHOC signature algorithm is not 810 used in methods without signature authentication. 812 The Initiator needs to have a list of cipher suites it supports in 813 order of preference. The Responder needs to have a list of cipher 814 suites it supports. SUITES_I is a CBOR array containing cipher 815 suites that the Initiator supports. SUITES_I is formatted and 816 processed as detailed in Section 5.2.1 to secure the cipher suite 817 negotiation. Examples of cipher suite negotiation are given in 818 Section 6.3.2. 820 3.7. Ephemeral Public Keys 822 EDHOC always uses compact representation of elliptic curve points, 823 see Appendix B. In COSE compact representation is achieved by 824 formatting the ECDH ephemeral public keys as COSE_Keys of type EC2 or 825 OKP according to Sections 7.1 and 7.2 of 826 [I-D.ietf-cose-rfc8152bis-algs], but only including the 'x' parameter 827 in G_X and G_Y. For Elliptic Curve Keys of type EC2, compact 828 representation MAY be used also in the COSE_Key. If the COSE 829 implementation requires an 'y' parameter, the value y = false SHALL 830 be used. COSE always use compact output for Elliptic Curve Keys of 831 type EC2. 833 3.8. External Authorization Data 835 In order to reduce round trips and number of messages or to simplify 836 processing, external security applications may be integrated into 837 EDHOC by transporting authorization related data together with the 838 messages. One example is the transport third-party identity and 839 authorization information protected out of scope of EDHOC 840 [I-D.selander-ace-ake-authz]. Another example is the embedding of a 841 certificate enrolment request or a newly issued certificate. 843 EDHOC allows opaque external authorization data (EAD) to be sent in 844 the EDHOC messages. External authorization data sent in message_1 845 (EAD_1) or message_2 (EAD_2) must be considered unprotected by EDHOC, 846 see Section 7.4. External authorization data sent in message_3 847 (EAD_3) or message_4 (EAD_4) is protected between Initiator and 848 Responder. 850 External authorization data is a CBOR sequence (see Appendix C.1) as 851 defined below: 853 EAD = ( 854 type : int, 855 1* ext_authz_data : any, 856 ) 858 where type is an int and is followed by one or more ext_authz_data 859 depending on type as defined in a separate specification. 861 The EAD fields of EDHOC are not intended for generic application 862 data. Since data carried in EAD_1 and EAD_2 fields may not be 863 protected, special considerations need to be made such that a) it 864 does not violate security, privacy etc. requirements of the service 865 which uses this data, and b) it does not violate the security 866 properties of EDHOC. Security applications making use of the EAD 867 fields must perform the necessary security analysis. 869 3.9. Applicability Statement 871 EDHOC requires certain parameters to be agreed upon between Initiator 872 and Responder. Some parameters can be agreed through the protocol 873 execution (specifically cipher suite negotiation, see Section 3.6) 874 but other parameters may need to be known out-of-band (e.g., which 875 authentication method is used, see Section 3.2). 877 The purpose of the applicability statement is describe the intended 878 use of EDHOC to allow for the relevant processing and verifications 879 to be made, including things like: 881 1. How the endpoint detects that an EDHOC message is received. This 882 includes how EDHOC messages are transported, for example in the 883 payload of a CoAP message with a certain Uri-Path or Content- 884 Format; see Appendix A.3. * The method of transporting EDHOC 885 messages may also describe data carried along with the messages 886 that are needed for the transport to satisfy the requirements of 887 Section 3.4, e.g., connection identifiers used with certain 888 messages, see Appendix A.3. 890 2. Authentication method (METHOD; see Section 3.2). 892 3. Profile for authentication credentials (CRED_I, CRED_R; see 893 Section 3.5.3), e.g., profile for certificate or COSE_key, 894 including supported authentication key algorithms (subject public 895 key algorithm in X.509 certificate). 897 4. Type used to identify authentication credentials (ID_CRED_I, 898 ID_CRED_R; see Section 3.5.4). 900 5. Use and type of external authorization data (EAD_1, EAD_2, EAD_3, 901 EAD_4; see Section 3.8). 903 6. Identifier used as identity of endpoint; see Section 3.5.2. 905 7. If message_4 shall be sent/expected, and if not, how to ensure a 906 protected application message is sent from the Responder to the 907 Initiator; see Section 5.5. 909 The applicability statement may also contain information about 910 supported cipher suites. The procedure for selecting and verifying 911 cipher suite is still performed as specified by the protocol, but it 912 may become simplified by this knowledge. 914 An example of an applicability statement is shown in Appendix E. 916 For some parameters, like METHOD, ID_CRED_x, type of EAD, the 917 receiver is able to verify compliance with applicability statement, 918 and if it needs to fail because of incompliance, to infer the reason 919 why the protocol failed. 921 For other parameters, like CRED_x in the case that it is not 922 transported, it may not be possible to verify that incompliance with 923 applicability statement was the reason for failure: Integrity 924 verification in message_2 or message_3 may fail not only because of 925 wrong authentication credential. For example, in case the Initiator 926 uses public key certificate by reference (i.e. not transported within 927 the protocol) then both endpoints need to use an identical data 928 structure as CRED_I or else the integrity verification will fail. 930 Note that it is not necessary for the endpoints to specify a single 931 transport for the EDHOC messages. For example, a mix of CoAP and 932 HTTP may be used along the path, and this may still allow correlation 933 between messages. 935 The applicability statement may be dependent on the identity of the 936 other endpoint, but this applies only to the later phases of the 937 protocol when identities are known. (Initiator does not know 938 identity of Responder before having verified message_2, and Responder 939 does not know identity of Initiator before having verified 940 message_3.) 942 Other conditions may be part of the applicability statement, such as 943 target application or use (if there is more than one application/use) 944 to the extent that EDHOC can distinguish between them. In case 945 multiple applicability statements are used, the receiver needs to be 946 able to determine which is applicable for a given session, for 947 example based on URI or external authorization data type. 949 4. Key Derivation 951 EDHOC uses Extract-and-Expand [RFC5869] with the EDHOC hash algorithm 952 in the selected cipher suite to derive keys used in EDHOC and in the 953 application. Extract is used to derive fixed-length uniformly 954 pseudorandom keys (PRK) from ECDH shared secrets. Expand is used to 955 derive additional output keying material (OKM) from the PRKs. The 956 PRKs are derived using Extract. 958 PRK = Extract( salt, IKM ) 960 If the EDHOC hash algorithm is SHA-2, then Extract( salt, IKM ) = 961 HKDF-Extract( salt, IKM ) [RFC5869]. If the EDHOC hash algorithm is 962 SHAKE128, then Extract( salt, IKM ) = KMAC128( salt, IKM, 256, "" ). 963 If the EDHOC hash algorithm is SHAKE256, then Extract( salt, IKM ) = 964 KMAC256( salt, IKM, 512, "" ). 966 PRK_2e is used to derive a keystream to encrypt message_2. PRK_3e2m 967 is used to derive keys and IVs to produce a MAC in message_2 and to 968 encrypt message_3. PRK_4x3m is used to derive keys and IVs to 969 produce a MAC in message_3 and to derive application specific data. 971 PRK_2e is derived with the following input: 973 o The salt SHALL be the empty byte string. Note that [RFC5869] 974 specifies that if the salt is not provided, it is set to a string 975 of zeros (see Section 2.2 of [RFC5869]). For implementation 976 purposes, not providing the salt is the same as setting the salt 977 to the empty byte string. 979 o The input keying material (IKM) SHALL be the ECDH shared secret 980 G_XY (calculated from G_X and Y or G_Y and X) as defined in 981 Section 6.3.1 of [I-D.ietf-cose-rfc8152bis-algs]. 983 Example: Assuming the use of SHA-256 the extract phase of HKDF 984 produces PRK_2e as follows: 986 PRK_2e = HMAC-SHA-256( salt, G_XY ) 988 where salt = 0x (the empty byte string). 990 The pseudorandom keys PRK_3e2m and PRK_4x3m are defined as follow: 992 o If the Responder authenticates with a static Diffie-Hellman key, 993 then PRK_3e2m = Extract( PRK_2e, G_RX ), where G_RX is the ECDH 994 shared secret calculated from G_R and X, or G_X and R, else 995 PRK_3e2m = PRK_2e. 997 o If the Initiator authenticates with a static Diffie-Hellman key, 998 then PRK_4x3m = Extract( PRK_3e2m, G_IY ), where G_IY is the ECDH 999 shared secret calculated from G_I and Y, or G_Y and I, else 1000 PRK_4x3m = PRK_3e2m. 1002 Example: Assuming the use of curve25519, the ECDH shared secrets 1003 G_XY, G_RX, and G_IY are the outputs of the X25519 function 1004 [RFC7748]: 1006 G_XY = X25519( Y, G_X ) = X25519( X, G_Y ) 1008 The keys and IVs used in EDHOC are derived from PRKs using Expand 1009 [RFC5869] where the EDHOC-KDF is instantiated with the EDHOC AEAD 1010 algorithm in the selected cipher suite. 1012 OKM = EDHOC-KDF( PRK, transcript_hash, label, length ) 1013 = Expand( PRK, info, length ) 1015 where info is the CBOR encoding of 1017 info = [ 1018 edhoc_aead_id : int / tstr, 1019 transcript_hash : bstr, 1020 label : tstr, 1021 length : uint 1022 ] 1024 where 1026 o edhoc_aead_id is an int or tstr containing the algorithm 1027 identifier of the EDHOC AEAD algorithm in the selected cipher 1028 suite encoded as defined in [I-D.ietf-cose-rfc8152bis-algs]. Note 1029 that a single fixed edhoc_aead_id is used in all invocations of 1030 EDHOC-KDF, including the derivation of KEYSTREAM_2 and invocations 1031 of the EDHOC-Exporter. 1033 o transcript_hash is a bstr set to one of the transcript hashes 1034 TH_2, TH_3, or TH_4 as defined in Sections 5.3.1, 5.4.1, and 4.1. 1036 o label is a tstr set to the name of the derived key or IV, i.e. 1037 "K_2m", "IV_2m", "KEYSTREAM_2", "K_3m", "IV_3m", "K_3ae", or 1038 "IV_3ae". 1040 o length is the length of output keying material (OKM) in bytes 1042 If the EDHOC hash algorithm is SHA-2, then Expand( PRK, info, length 1043 ) = HKDF-Expand( PRK, info, length ) [RFC5869]. If the EDHOC hash 1044 algorithm is SHAKE128, then Expand( PRK, info, length ) = KMAC128( 1045 PRK, info, L, "" ). If the EDHOC hash algorithm is SHAKE256, then 1046 Expand( PRK, info, length ) = KMAC256( PRK, info, L, "" ). 1048 KEYSTREAM_2 are derived using the transcript hash TH_2 and the 1049 pseudorandom key PRK_2e. K_2m and IV_2m are derived using the 1050 transcript hash TH_2 and the pseudorandom key PRK_3e2m. K_3ae and 1051 IV_3ae are derived using the transcript hash TH_3 and the 1052 pseudorandom key PRK_3e2m. K_3m and IV_3m are derived using the 1053 transcript hash TH_3 and the pseudorandom key PRK_4x3m. IVs are only 1054 used if the EDHOC AEAD algorithm uses IVs. 1056 4.1. EDHOC-Exporter Interface 1058 Application keys and other application specific data can be derived 1059 using the EDHOC-Exporter interface defined as: 1061 EDHOC-Exporter(label, context, length) 1062 = EDHOC-KDF(PRK_4x3m, TH_4, label_context, length) 1064 label_context is a CBOR sequence: 1066 label_context = ( 1067 label : tstr, 1068 context : bstr, 1069 ) 1071 where label is a registered tstr from the EDHOC Exporter Label 1072 registry (Section 8.1), context is a bstr defined by the application, 1073 and length is a uint defined by the application. The (label, 1074 context) pair must be unique, i.e. a (label, context) MUST NOT be 1075 used for two different purposes. However an application can re- 1076 derive the same key several times as long as it is done in a secure 1077 way. For example, in most encryption algorithms the same (key, 1078 nonce) pair must not be reused. 1080 The transcript hash TH_4 is a CBOR encoded bstr and the input to the 1081 hash function is a CBOR Sequence. 1083 TH_4 = H( TH_3, CIPHERTEXT_3 ) 1085 where H() is the hash function in the selected cipher suite. 1086 Examples of use of the EDHOC-Exporter are given in Section 5.5.2 and 1087 Appendix A. 1089 To provide forward secrecy in an even more efficient way than re- 1090 running EDHOC, EDHOC provides the function EDHOC-KeyUpdate. When 1091 EDHOC-KeyUpdate is called the old PRK_4x3m is deleted and the new 1092 PRK_4x3m is calculated as a "hash" of the old key using the Extract 1093 function as illustrated by the following pseudocode: 1095 EDHOC-KeyUpdate( nonce ): 1096 PRK_4x3m = Extract( nonce, PRK_4x3m ) 1098 5. Message Formatting and Processing 1100 This section specifies formatting of the messages and processing 1101 steps. Error messages are specified in Section 6. 1103 An EDHOC message is encoded as a sequence of CBOR data (CBOR 1104 Sequence, [RFC8742]). Additional optimizations are made to reduce 1105 message overhead. 1107 While EDHOC uses the COSE_Key, COSE_Sign1, and COSE_Encrypt0 1108 structures, only a subset of the parameters is included in the EDHOC 1109 messages. The unprotected COSE header in COSE_Sign1, and 1110 COSE_Encrypt0 (not included in the EDHOC message) MAY contain 1111 parameters (e.g. 'alg'). 1113 5.1. Message Processing Outline 1115 This section outlines the message processing of EDHOC. 1117 For each session, the endpoints are assumed to keep an associated 1118 protocol state containing identifiers, keys, etc. used for subsequent 1119 processing of protocol related data. The protocol state is assumed 1120 to be associated to an applicability statement (Section 3.9) which 1121 provides the context for how messages are transported, identified and 1122 processed. 1124 EDHOC messages SHALL be processed according to the current protocol 1125 state. The following steps are expected to be performed at reception 1126 of an EDHOC message: 1128 1. Detect that an EDHOC message has been received, for example by 1129 means of port number, URI, or media type (Section 3.9). 1131 2. Retrieve the protocol state according to the message correlation 1132 provided by the transport, see Section 3.4. If there is no 1133 protocol state, in the case of message_1, a new protocol state is 1134 created. The Responder endpoint needs to make use of available 1135 Denial-of-Service mitigation (Section 7.5). 1137 3. If the message received is an error message then process 1138 according to Section 6, else process as the expected next message 1139 according to the protocol state. 1141 If the processing fails, then the protocol is discontinued, an error 1142 message sent, and the protocol state erased. Further details are 1143 provided in the following subsections. 1145 Different instances of the same message MUST NOT be processed in one 1146 session. Note that processing will fail if the same message appears 1147 a second time for EDHOC processing because the state of the protocol 1148 has moved on and now expects something else. This assumes that 1149 message duplication due to re-transmissions is handled by the 1150 transport protocol, see Section 3.4. The case when the transport 1151 does not support message deduplication is addressed in Appendix F. 1153 5.2. EDHOC Message 1 1155 5.2.1. Formatting of Message 1 1157 message_1 SHALL be a CBOR Sequence (see Appendix C.1) as defined 1158 below 1160 message_1 = ( 1161 METHOD : int, 1162 SUITES_I : [ selected : suite, supported : 2* suite ] / suite, 1163 G_X : bstr, 1164 C_I : bstr / int, 1165 ? EAD ; EAD_1 1166 ) 1168 suite = int 1170 where: 1172 o METHOD = 0, 1, 2, or 3 (see Figure 4). 1174 o SUITES_I - cipher suites which the Initiator supports in order of 1175 (decreasing) preference. The list of supported cipher suites can 1176 be truncated at the end, as is detailed in the processing steps 1177 below and Section 6.3. One of the supported cipher suites is 1178 selected. The selected suite is the first suite in the SUITES_I 1179 CBOR array. If a single supported cipher suite is conveyed then 1180 that cipher suite is selected and SUITES_I is encoded as an int 1181 instead of an array. 1183 o G_X - the ephemeral public key of the Initiator 1185 o C_I - variable length connection identifier 1187 o EAD_1 - unprotected external authorization data, see Section 3.8. 1189 5.2.2. Initiator Processing of Message 1 1191 The Initiator SHALL compose message_1 as follows: 1193 o The supported cipher suites and the order of preference MUST NOT 1194 be changed based on previous error messages. However, the list 1195 SUITES_I sent to the Responder MAY be truncated such that cipher 1196 suites which are the least preferred are omitted. The amount of 1197 truncation MAY be changed between sessions, e.g. based on previous 1198 error messages (see next bullet), but all cipher suites which are 1199 more preferred than the least preferred cipher suite in the list 1200 MUST be included in the list. 1202 o The Initiator MUST select its most preferred cipher suite, 1203 conditioned on what it can assume to be supported by the 1204 Responder. If the Initiator previously received from the 1205 Responder an error message with error code 2 (see Section 6.3) 1206 indicating cipher suites supported by the Responder which also are 1207 supported by the Initiator, then the Initiator SHOULD select the 1208 most preferred cipher suite of those (note that error messages are 1209 not authenticated and may be forged). 1211 o Generate an ephemeral ECDH key pair using the curve in the 1212 selected cipher suite and format it as a COSE_Key. Let G_X be the 1213 'x' parameter of the COSE_Key. 1215 o Choose a connection identifier C_I and store it for the length of 1216 the protocol. 1218 o Encode message_1 as a sequence of CBOR encoded data items as 1219 specified in Section 5.2.1 1221 5.2.3. Responder Processing of Message 1 1223 The Responder SHALL process message_1 as follows: 1225 o Decode message_1 (see Appendix C.1). 1227 o Verify that the selected cipher suite is supported and that no 1228 prior cipher suite in SUITES_I is supported. 1230 o Pass EAD_1 to the security application. 1232 If any processing step fails, the Responder SHOULD send an EDHOC 1233 error message back, formatted as defined in Section 6, and the 1234 session MUST be discontinued. Sending error messages is essential 1235 for debugging but MAY e.g. be skipped due to denial of service 1236 reasons, see Section 7. 1238 5.3. EDHOC Message 2 1240 5.3.1. Formatting of Message 2 1242 message_2 and data_2 SHALL be CBOR Sequences (see Appendix C.1) as 1243 defined below 1245 message_2 = ( 1246 data_2, 1247 CIPHERTEXT_2 : bstr, 1248 ) 1250 data_2 = ( 1251 G_Y : bstr, 1252 C_R : bstr / int, 1253 ) 1255 where: 1257 o G_Y - the ephemeral public key of the Responder 1259 o C_R - variable length connection identifier 1261 5.3.2. Responder Processing of Message 2 1263 The Responder SHALL compose message_2 as follows: 1265 o Generate an ephemeral ECDH key pair using the curve in the 1266 selected cipher suite and format it as a COSE_Key. Let G_Y be the 1267 'x' parameter of the COSE_Key. 1269 o Choose a connection identifier C_R and store it for the length of 1270 the protocol. 1272 o Compute the transcript hash TH_2 = H( H(message_1), data_2 ) where 1273 H() is the hash function in the selected cipher suite. The 1274 transcript hash TH_2 is a CBOR encoded bstr and the input to the 1275 hash function is a CBOR Sequence. Note that H(message_1) can be 1276 computed and cached already in the processing of message_1. 1278 o Compute an inner COSE_Encrypt0 as defined in Section 5.3 of 1279 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1280 in the selected cipher suite, K_2m, IV_2m, and the following 1281 parameters: 1283 * protected = << ID_CRED_R >> 1284 + ID_CRED_R - identifier to facilitate retrieval of CRED_R, 1285 see Section 3.5.4 1287 * external_aad = << TH_2, CRED_R, ? EAD_2 >> 1289 + CRED_R - bstr containing the credential of the Responder, 1290 see Section 3.5.4 1292 + EAD_2 = unprotected external authorization data, see 1293 Section 3.8 1295 * plaintext = h'' 1297 COSE constructs the input to the AEAD [RFC5116] as follows: 1299 * Key K = EDHOC-KDF( PRK_3e2m, TH_2, "K_2m", length ) 1301 * Nonce N = EDHOC-KDF( PRK_3e2m, TH_2, "IV_2m", length ) 1303 * Plaintext P = 0x (the empty string) 1305 * Associated data A = 1307 [ "Encrypt0", << ID_CRED_R >>, << TH_2, CRED_R, ? EAD_2 >> ] 1309 MAC_2 is the 'ciphertext' of the inner COSE_Encrypt0. 1311 o If the Responder authenticates with a static Diffie-Hellman key 1312 (method equals 1 or 3), then Signature_or_MAC_2 is MAC_2. If the 1313 Responder authenticates with a signature key (method equals 0 or 1314 2), then Signature_or_MAC_2 is the 'signature' of a COSE_Sign1 1315 object as defined in Section 4.4 of 1316 [I-D.ietf-cose-rfc8152bis-struct] using the signature algorithm in 1317 the selected cipher suite, the private authentication key of the 1318 Responder, and the following parameters: 1320 * protected = << ID_CRED_R >> 1322 * external_aad = << TH_2, CRED_R, ? EAD_2 >> 1324 * payload = MAC_2 1326 COSE constructs the input to the Signature Algorithm as: 1328 * The key is the private authentication key of the Responder. 1330 * The message M to be signed = 1332 [ "Signature1", << ID_CRED_R >>, << TH_2, CRED_R, ? EAD_2 >>, 1333 MAC_2 ] 1335 o CIPHERTEXT_2 is encrypted by using the Expand function as a binary 1336 additive stream cipher. 1338 * plaintext = ( ID_CRED_R / bstr / int, Signature_or_MAC_2, ? 1339 EAD_2 ) 1341 + Note that if ID_CRED_R contains a single 'kid2' parameter, 1342 i.e., ID_CRED_R = { 4 : kid_R }, only the byte string or 1343 integer kid_R is conveyed in the plaintext encoded as a bstr 1344 / int. 1346 * CIPHERTEXT_2 = plaintext XOR KEYSTREAM_2 1348 o Encode message_2 as a sequence of CBOR encoded data items as 1349 specified in Section 5.3.1. 1351 5.3.3. Initiator Processing of Message 2 1353 The Initiator SHALL process message_2 as follows: 1355 o Decode message_2 (see Appendix C.1). 1357 o Retrieve the protocol state using the message correlation provided 1358 by the transport (e.g., the CoAP Token and the 5-tuple as a 1359 client, or the prepended C_I as a server). 1361 o Decrypt CIPHERTEXT_2, see Section 5.3.2. 1363 o Pass EAD_2 to the security application. 1365 o Verify that the identity of the Responder is an allowed identity 1366 for this connection, see Section 3.5. 1368 o Verify Signature_or_MAC_2 using the algorithm in the selected 1369 cipher suite. The verification process depends on the method, see 1370 Section 5.3.2. 1372 If any processing step fails, the Initiator SHOULD send an EDHOC 1373 error message back, formatted as defined in Section 6. Sending error 1374 messages is essential for debugging but MAY e.g.be skipped if a 1375 session cannot be found or due to denial of service reasons, see 1376 Section 7. If an error message is sent, the session MUST be 1377 discontinued. 1379 5.4. EDHOC Message 3 1381 5.4.1. Formatting of Message 3 1383 message_3 SHALL be a CBOR Sequence (see Appendix C.1) as defined 1384 below 1386 message_3 = ( 1387 CIPHERTEXT_3 : bstr, 1388 ) 1390 5.4.2. Initiator Processing of Message 3 1392 The Initiator SHALL compose message_3 as follows: 1394 o Compute the transcript hash TH_3 = H(TH_2, CIPHERTEXT_2) where H() 1395 is the hash function in the selected cipher suite. The transcript 1396 hash TH_3 is a CBOR encoded bstr and the input to the hash 1397 function is a CBOR Sequence. Note that H(TH_2, CIPHERTEXT_2) can 1398 be computed and cached already in the processing of message_2. 1400 o Compute an inner COSE_Encrypt0 as defined in Section 5.3 of 1401 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1402 in the selected cipher suite, K_3m, IV_3m, and the following 1403 parameters: 1405 * protected = << ID_CRED_I >> 1407 + ID_CRED_I - identifier to facilitate retrieval of CRED_I, 1408 see Section 3.5.4 1410 * external_aad = << TH_3, CRED_I, ? EAD_3 >> 1412 + CRED_I - bstr containing the credential of the Initiator, 1413 see Section 3.5.4. 1415 + EAD_3 = protected external authorization data, see 1416 Section 3.8 1418 * plaintext = h'' 1420 COSE constructs the input to the AEAD [RFC5116] as follows: 1422 * Key K = EDHOC-KDF( PRK_4x3m, TH_3, "K_3m", length ) 1424 * Nonce N = EDHOC-KDF( PRK_4x3m, TH_3, "IV_3m", length ) 1426 * Plaintext P = 0x (the empty string) 1427 * Associated data A = 1429 [ "Encrypt0", << ID_CRED_I >>, << TH_3, CRED_I, ? EAD_3 >> ] 1431 MAC_3 is the 'ciphertext' of the inner COSE_Encrypt0. 1433 o If the Initiator authenticates with a static Diffie-Hellman key 1434 (method equals 2 or 3), then Signature_or_MAC_3 is MAC_3. If the 1435 Initiator authenticates with a signature key (method equals 0 or 1436 1), then Signature_or_MAC_3 is the 'signature' of a COSE_Sign1 1437 object as defined in Section 4.4 of 1438 [I-D.ietf-cose-rfc8152bis-struct] using the signature algorithm in 1439 the selected cipher suite, the private authentication key of the 1440 Initiator, and the following parameters: 1442 * protected = << ID_CRED_I >> 1444 * external_aad = << TH_3, CRED_I, ? EAD_3 >> 1446 * payload = MAC_3 1448 COSE constructs the input to the Signature Algorithm as: 1450 * The key is the private authentication key of the Initiator. 1452 * The message M to be signed = 1454 [ "Signature1", << ID_CRED_I >>, << TH_3, CRED_I, ? EAD_3 >>, 1455 MAC_3 ] 1457 o Compute an outer COSE_Encrypt0 as defined in Section 5.3 of 1458 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1459 in the selected cipher suite, K_3ae, IV_3ae, and the following 1460 parameters. The protected header SHALL be empty. 1462 * external_aad = TH_3 1464 * plaintext = ( ID_CRED_I / bstr / int, Signature_or_MAC_3, ? 1465 EAD_3 ) 1467 + Note that if ID_CRED_I contains a single 'kid2' parameter, 1468 i.e., ID_CRED_I = { 4 : kid_I }, only the byte string or 1469 integer kid_I is conveyed in the plaintext encoded as a bstr 1470 or int. 1472 COSE constructs the input to the AEAD [RFC5116] as follows: 1474 * Key K = EDHOC-KDF( PRK_3e2m, TH_3, "K_3ae", length ) 1475 * Nonce N = EDHOC-KDF( PRK_3e2m, TH_3, "IV_3ae", length ) 1477 * Plaintext P = ( ID_CRED_I / bstr / int, Signature_or_MAC_3, ? 1478 EAD_3 ) 1480 * Associated data A = [ "Encrypt0", h'', TH_3 ] 1482 CIPHERTEXT_3 is the 'ciphertext' of the outer COSE_Encrypt0. 1484 o Encode message_3 as a sequence of CBOR encoded data items as 1485 specified in Section 5.4.1. 1487 Pass the connection identifiers (C_I, C_R) and the application 1488 algorithms in the selected cipher suite to the application. The 1489 application can now derive application keys using the EDHOC-Exporter 1490 interface. 1492 After sending message_3, the Initiator is assured that no other party 1493 than the Responder can compute the key PRK_4x3m (implicit key 1494 authentication). The Initiator can securely derive application keys 1495 and send protected application data. However, the Initiator does not 1496 know that the Responder has actually computed the key PRK_4x3m and 1497 therefore the Initiator SHOULD NOT permanently store the keying 1498 material PRK_4x3m and TH_4, or derived application keys, until the 1499 Initiator is assured that the Responder has actually computed the key 1500 PRK_4x3m (explicit key confirmation). This is similar to waiting for 1501 acknowledgement (ACK) in a transport protocol. Explicit key 1502 confirmation is e.g. assured when the Initiator has verified an 1503 OSCORE message or message_4 from the Responder. 1505 5.4.3. Responder Processing of Message 3 1507 The Responder SHALL process message_3 as follows: 1509 o Decode message_3 (see Appendix C.1). 1511 o Retrieve the protocol state using the message correlation provided 1512 by the transport (e.g., the CoAP Token and the 5-tuple as a 1513 client, or the prepended C_R as a server). 1515 o Decrypt and verify the outer COSE_Encrypt0 as defined in 1516 Section 5.3 of [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC 1517 AEAD algorithm in the selected cipher suite, K_3ae, and IV_3ae. 1519 o Pass EAD_3 to the security application. 1521 o Verify that the identity of the Initiator is an allowed identity 1522 for this connection, see Section 3.5. 1524 o Verify Signature_or_MAC_3 using the algorithm in the selected 1525 cipher suite. The verification process depends on the method, see 1526 Section 5.4.2. 1528 o Pass the connection identifiers (C_I, C_R), and the application 1529 algorithms in the selected cipher suite to the security 1530 application. The application can now derive application keys 1531 using the EDHOC-Exporter interface. 1533 If any processing step fails, the Responder SHOULD send an EDHOC 1534 error message back, formatted as defined in Section 6. Sending error 1535 messages is essential for debugging but MAY e.g.be skipped if a 1536 session cannot be found or due to denial of service reasons, see 1537 Section 7. If an error message is sent, the session MUST be 1538 discontinued. 1540 After verifying message_3, the Responder is assured that the 1541 Initiator has calculated the key PRK_4x3m (explicit key confirmation) 1542 and that no other party than the Responder can compute the key. The 1543 Responder can securely send protected application data and store the 1544 keying material PRK_4x3m and TH_4. 1546 5.5. EDHOC Message 4 1548 This section specifies message_4 which is OPTIONAL to support. Key 1549 confirmation is normally provided by sending an application message 1550 from the Responder to the Initiator protected with a key derived with 1551 the EDHOC-Exporter, e.g., using OSCORE (see Appendix A). In 1552 deployments where no protected application message is sent from the 1553 Responder to the Initiator, the Responder MUST send message_4. Two 1554 examples of such deployments: 1556 1. When EDHOC is only used for authentication and no application 1557 data is sent. 1559 2. When application data is only sent from the Initiator to the 1560 Responder. 1562 Further considerations are provided in Section 3.9. 1564 5.5.1. Formatting of Message 4 1566 message_4 SHALL be a CBOR Sequence (see Appendix C.1) as defined 1567 below 1569 message_4 = ( 1570 CIPHERTEXT_4 : bstr, 1571 ) 1573 5.5.2. Responder Processing of Message 4 1575 The Responder SHALL compose message_4 as follows: 1577 o Compute a COSE_Encrypt0 as defined in Section 5.3 of 1578 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1579 in the selected cipher suite, and the following parameters. The 1580 protected header SHALL be empty. 1582 * protected = h'' 1584 * external_aad = TH_4 1586 * plaintext = ( ? EAD_4 ) 1588 where EAD_4 is protected external authorization data, see 1589 Section 3.8. COSE constructs the input to the AEAD [RFC5116] as 1590 follows: 1592 * Key K = EDHOC-Exporter( "EDHOC_message_4_Key", h'', length ) 1594 * Nonce N = EDHOC-Exporter( "EDHOC_message_4_Nonce", h'', length 1595 ) 1597 * Plaintext P = ( ? EAD_4 ) 1599 * Associated data A = [ "Encrypt0", h'', TH_4 ] 1601 CIPHERTEXT_4 is the 'ciphertext' of the COSE_Encrypt0. 1603 o Encode message_4 as a sequence of CBOR encoded data items as 1604 specified in Section 5.5.1. 1606 5.5.3. Initiator Processing of Message 4 1608 The Initiator SHALL process message_4 as follows: 1610 o Decode message_4 (see Appendix C.1). 1612 o Retrieve the protocol state using the message correlation provided 1613 by the transport (e.g., the CoAP Token and the 5-tuple as a 1614 client, or the prepended C_I as a server). 1616 o Decrypt and verify the outer COSE_Encrypt0 as defined in 1617 Section 5.3 of [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC 1618 AEAD algorithm in the selected cipher suite, and the parameters 1619 defined in Section 5.5.2. 1621 o Pass EAD_4 to the security application. 1623 If any verification step fails the Initiator MUST send an EDHOC error 1624 message back, formatted as defined in Section 6, and the session MUST 1625 be discontinued. 1627 6. Error Handling 1629 This section defines the format for error messages. 1631 An EDHOC error message can be sent by either endpoint as a reply to 1632 any non-error EDHOC message. How errors at the EDHOC layer are 1633 transported depends on lower layers, which need to enable error 1634 messages to be sent and processed as intended. 1636 Errors in EDHOC are fatal. After sending an error message, the 1637 sender MUST discontinue the protocol. The receiver SHOULD treat an 1638 error message as an indication that the other party likely has 1639 discontinued the protocol. But as the error message is not 1640 authenticated, a received error message might also have been sent by 1641 an attacker and the receiver MAY therefore try to continue the 1642 protocol. 1644 error SHALL be a CBOR Sequence (see Appendix C.1) as defined below 1646 error = ( 1647 ERR_CODE : int, 1648 ERR_INFO : any 1649 ) 1651 Figure 5: EDHOC Error Message 1653 where: 1655 o ERR_CODE - error code encoded as an integer. The value 0 is used 1656 for success, all other values (negative or positive) indicate 1657 errors. 1659 o ERR_INFO - error information. Content and encoding depend on 1660 error code. 1662 The remainder of this section specifies the currently defined error 1663 codes, see Figure 6. Error codes 1 and 2 MUST be supported. 1664 Additional error codes and corresponding error information may be 1665 specified. 1667 +----------+---------------+----------------------------------------+ 1668 | ERR_CODE | ERR_INFO Type | Description | 1669 +==========+===============+========================================+ 1670 | 0 | any | Success | 1671 +----------+---------------+----------------------------------------+ 1672 | 1 | tstr | Unspecified | 1673 +----------+---------------+----------------------------------------+ 1674 | 2 | SUITES_R | Wrong selected cipher suite | 1675 +----------+---------------+----------------------------------------+ 1677 Figure 6: Error Codes and Error Information 1679 6.1. Success 1681 Error code 0 MAY be used internally in an application to indicate 1682 success, e.g. in log files. ERR_INFO can contain any type of CBOR 1683 item. Error code 0 MUST NOT be used as part of the EDHOC message 1684 exchange flow. 1686 6.2. Unspecified 1688 Error code 1 is used for errors that do not have a specific error 1689 code defined. ERR_INFO MUST be a text string containing a human- 1690 readable diagnostic message written in English. The diagnostic text 1691 message is mainly intended for software engineers that during 1692 debugging need to interpret it in the context of the EDHOC 1693 specification. The diagnostic message SHOULD be provided to the 1694 calling application where it SHOULD be logged. 1696 6.3. Wrong Selected Cipher Suite 1698 Error code 2 MUST only be used in a response to message_1 in case the 1699 cipher suite selected by the Initiator is not supported by the 1700 Responder, or if the Responder supports a cipher suite more preferred 1701 by the Initiator than the selected cipher suite, see Section 5.2.3. 1702 ERR_INFO is of type SUITES_R: 1704 SUITES_R : [ supported : 2* suite ] / suite 1706 If the Responder does not support the selected cipher suite, then 1707 SUITES_R MUST include one or more supported cipher suites. If the 1708 Responder does not support the selected cipher suite, but supports 1709 another cipher suite in SUITES_I, then SUITES_R MUST include the 1710 first supported cipher suite in SUITES_I. 1712 6.3.1. Cipher Suite Negotiation 1714 After receiving SUITES_R, the Initiator can determine which cipher 1715 suite to select for the next EDHOC run with the Responder. 1717 If the Initiator intends to contact the Responder in the future, the 1718 Initiator SHOULD remember which selected cipher suite to use until 1719 the next message_1 has been sent, otherwise the Initiator and 1720 Responder will likely run into an infinite loop. After a successful 1721 run of EDHOC, the Initiator MAY remember the selected cipher suite to 1722 use in future EDHOC runs. Note that if the Initiator or Responder is 1723 updated with new cipher suite policies, any cached information may be 1724 outdated. 1726 6.3.2. Examples 1728 Assume that the Initiator supports the five cipher suites 5, 6, 7, 8, 1729 and 9 in decreasing order of preference. Figures 7 and 8 show 1730 examples of how the Initiator can truncate SUITES_I and how SUITES_R 1731 is used by Responders to give the Initiator information about the 1732 cipher suites that the Responder supports. 1734 In the first example (Figure 7), the Responder supports cipher suite 1735 6 but not the initially selected cipher suite 5. 1737 Initiator Responder 1738 | METHOD, SUITES_I = 5, G_X, C_I, EAD_1 | 1739 +------------------------------------------------------------------>| 1740 | message_1 | 1741 | | 1742 | DIAG_MSG, SUITES_R = 6 | 1743 |<------------------------------------------------------------------+ 1744 | error | 1745 | | 1746 | METHOD, SUITES_I = [6, 5, 6], G_X, C_I, EAD_1 | 1747 +------------------------------------------------------------------>| 1748 | message_1 | 1750 Figure 7: Example of Responder supporting suite 6 but not suite 5. 1752 In the second example (Figure 8), the Responder supports cipher 1753 suites 8 and 9 but not the more preferred (by the Initiator) cipher 1754 suites 5, 6 or 7. To illustrate the negotiation mechanics we let the 1755 Initiator first make a guess that the Responder supports suite 6 but 1756 not suite 5. Since the Responder supports neither 5 nor 6, it 1757 responds with an error and SUITES_R, after which the Initiator 1758 selects its most preferred supported suite. The order of cipher 1759 suites in SUITES_R does not matter. (If the Responder had supported 1760 suite 5, it would include it in SUITES_R of the response, and it 1761 would in that case have become the selected suite in the second 1762 message_1.) 1764 Initiator Responder 1765 | METHOD, SUITES_I = [6, 5, 6], G_X, C_I, EAD_1 | 1766 +------------------------------------------------------------------>| 1767 | message_1 | 1768 | | 1769 | DIAG_MSG, SUITES_R = [9, 8] | 1770 |<------------------------------------------------------------------+ 1771 | error | 1772 | | 1773 | METHOD, SUITES_I = [8, 5, 6, 7, 8], G_X, C_I, EAD_1 | 1774 +------------------------------------------------------------------>| 1775 | message_1 | 1777 Figure 8: Example of Responder supporting suites 8 and 9 but not 5, 6 1778 or 7. 1780 Note that the Initiator's list of supported cipher suites and order 1781 of preference is fixed (see Section 5.2.1 and Section 5.2.2). 1782 Furthermore, the Responder shall only accept message_1 if the 1783 selected cipher suite is the first cipher suite in SUITES_I that the 1784 Responder supports (see Section 5.2.3). Following this procedure 1785 ensures that the selected cipher suite is the most preferred (by the 1786 Initiator) cipher suite supported by both parties. 1788 If the selected cipher suite is not the first cipher suite which the 1789 Responder supports in SUITES_I received in message_1, then Responder 1790 MUST discontinue the protocol, see Section 5.2.3. If SUITES_I in 1791 message_1 is manipulated then the integrity verification of message_2 1792 containing the transcript hash TH_2 will fail and the Initiator will 1793 discontinue the protocol. 1795 7. Security Considerations 1797 7.1. Security Properties 1799 EDHOC inherits its security properties from the theoretical SIGMA-I 1800 protocol [SIGMA]. Using the terminology from [SIGMA], EDHOC provides 1801 perfect forward secrecy, mutual authentication with aliveness, 1802 consistency, and peer awareness. As described in [SIGMA], peer 1803 awareness is provided to the Responder, but not to the Initiator. 1805 EDHOC protects the credential identifier of the Initiator against 1806 active attacks and the credential identifier of the Responder against 1807 passive attacks. The roles should be assigned to protect the most 1808 sensitive identity/identifier, typically that which is not possible 1809 to infer from routing information in the lower layers. 1811 Compared to [SIGMA], EDHOC adds an explicit method type and expands 1812 the message authentication coverage to additional elements such as 1813 algorithms, external authorization data, and previous messages. This 1814 protects against an attacker replaying messages or injecting messages 1815 from another session. 1817 EDHOC also adds selection of connection identifiers and downgrade 1818 protected negotiation of cryptographic parameters, i.e. an attacker 1819 cannot affect the negotiated parameters. A single session of EDHOC 1820 does not include negotiation of cipher suites, but it enables the 1821 Responder to verify that the selected cipher suite is the most 1822 preferred cipher suite by the Initiator which is supported by both 1823 the Initiator and the Responder. 1825 As required by [RFC7258], IETF protocols need to mitigate pervasive 1826 monitoring when possible. One way to mitigate pervasive monitoring 1827 is to use a key exchange that provides perfect forward secrecy. 1828 EDHOC therefore only supports methods with perfect forward secrecy. 1829 To limit the effect of breaches, it is important to limit the use of 1830 symmetrical group keys for bootstrapping. EDHOC therefore strives to 1831 make the additional cost of using raw public keys and self-signed 1832 certificates as small as possible. Raw public keys and self-signed 1833 certificates are not a replacement for a public key infrastructure, 1834 but SHOULD be used instead of symmetrical group keys for 1835 bootstrapping. 1837 Compromise of the long-term keys (private signature or static DH 1838 keys) does not compromise the security of completed EDHOC exchanges. 1839 Compromising the private authentication keys of one party lets an 1840 active attacker impersonate that compromised party in EDHOC exchanges 1841 with other parties, but does not let the attacker impersonate other 1842 parties in EDHOC exchanges with the compromised party. Compromise of 1843 the long-term keys does not enable a passive attacker to compromise 1844 future session keys. Compromise of the HDKF input parameters (ECDH 1845 shared secret) leads to compromise of all session keys derived from 1846 that compromised shared secret. Compromise of one session key does 1847 not compromise other session keys. Compromise of PRK_4x3m leads to 1848 compromise of all exported keying material derived after the last 1849 invocation of the EDHOC-KeyUpdate function. 1851 EDHOC provides a minimum of 64-bit security against online brute 1852 force attacks and a minimum of 128-bit security against offline brute 1853 force attacks. This is in line with IPsec, TLS, and COSE. To break 1854 64-bit security against online brute force an attacker would on 1855 average have to send 4.3 billion messages per second for 68 years, 1856 which is infeasible in constrained IoT radio technologies. 1858 After sending message_3, the Initiator is assured that no other party 1859 than the Responder can compute the key PRK_4x3m (implicit key 1860 authentication). The Initiator does however not know that the 1861 Responder has actually computed the key PRK_4x3m. While the 1862 Initiator can securely send protected application data, the Initiator 1863 SHOULD NOT permanently store the keying material PRK_4x3m and TH_4 1864 until the Initiator is assured that the Responder has actually 1865 computed the key PRK_4x3m (explicit key confirmation). Explicit key 1866 confirmation is e.g. assured when the Initiator has verified an 1867 OSCORE message or message_4 from the Responder. After verifying 1868 message_3, the Responder is assured that the Initiator has calculated 1869 the key PRK_4x3m (explicit key confirmation) and that no other party 1870 than the Responder can compute the key. The Responder can securely 1871 send protected application data and store the keying material 1872 PRK_4x3m and TH_4. 1874 Key compromise impersonation (KCI): In EDHOC authenticated with 1875 signature keys, EDHOC provides KCI protection against an attacker 1876 having access to the long term key or the ephemeral secret key. With 1877 static Diffie-Hellman key authentication, KCI protection would be 1878 provided against an attacker having access to the long-term Diffie- 1879 Hellman key, but not to an attacker having access to the ephemeral 1880 secret key. Note that the term KCI has typically been used for 1881 compromise of long-term keys, and that an attacker with access to the 1882 ephemeral secret key can only attack that specific protocol run. 1884 Repudiation: In EDHOC authenticated with signature keys, the 1885 Initiator could theoretically prove that the Responder performed a 1886 run of the protocol by presenting the private ephemeral key, and vice 1887 versa. Note that storing the private ephemeral keys violates the 1888 protocol requirements. With static Diffie-Hellman key 1889 authentication, both parties can always deny having participated in 1890 the protocol. 1892 Two earlier versions of EDHOC have been formally analyzed [Norrman20] 1893 [Bruni18] and the specification has been updated based on the 1894 analysis. 1896 7.2. Cryptographic Considerations 1898 The security of the SIGMA protocol requires the MAC to be bound to 1899 the identity of the signer. Hence the message authenticating 1900 functionality of the authenticated encryption in EDHOC is critical: 1901 authenticated encryption MUST NOT be replaced by plain encryption 1902 only, even if authentication is provided at another level or through 1903 a different mechanism. EDHOC implements SIGMA-I using a MAC-then- 1904 Sign approach. 1906 To reduce message overhead EDHOC does not use explicit nonces and 1907 instead rely on the ephemeral public keys to provide randomness to 1908 each session. A good amount of randomness is important for the key 1909 generation, to provide liveness, and to protect against interleaving 1910 attacks. For this reason, the ephemeral keys MUST NOT be reused, and 1911 both parties SHALL generate fresh random ephemeral key pairs. 1913 As discussed the [SIGMA], the encryption of message_2 does only need 1914 to protect against passive attacker as active attackers can always 1915 get the Responders identity by sending their own message_1. EDHOC 1916 uses the Expand function (typically HKDF-Expand) as a binary additive 1917 stream cipher. HKDF-Expand provides better confidentiality than AES- 1918 CTR but is not often used as it is slow on long messages, and most 1919 applications require both IND-CCA confidentiality as well as 1920 integrity protection. For the encryption of message_2, any speed 1921 difference is negligible, IND-CCA does not increase security, and 1922 integrity is provided by the inner MAC (and signature depending on 1923 method). 1925 The data rates in many IoT deployments are very limited. Given that 1926 the application keys are protected as well as the long-term 1927 authentication keys they can often be used for years or even decades 1928 before the cryptographic limits are reached. If the application keys 1929 established through EDHOC need to be renewed, the communicating 1930 parties can derive application keys with other labels or run EDHOC 1931 again. 1933 Requirement for how to securely generate, validate, and process the 1934 ephermeral public keys depend on the elliptic curve. For X25519 and 1935 X448, the requirements are defined in [RFC7748]. For secp256r1, 1936 secp384r1, and secp521r1, the requirements are defined in Section 5 1937 of [SP-800-56A]. For secp256r1, secp384r1, and secp521r1, at least 1938 partial public-key validation MUST be done. 1940 7.3. Cipher Suites and Cryptographic Algorithms 1942 For many constrained IoT devices it is problematic to support more 1943 than one cipher suite. Existing devices can be expected to support 1944 either ECDSA or EdDSA. To enable as much interoperability as we can 1945 reasonably achieve, less constrained devices SHOULD implement both 1946 cipher suite 0 (AES-CCM-16-64-128, SHA-256, X25519, EdDSA, AES-CCM- 1947 16-64-128, SHA-256) and cipher suite 2 (AES-CCM-16-64-128, SHA-256, 1948 P-256, ES256, AES-CCM-16-64-128, SHA-256). Constrained endpoints 1949 SHOULD implement cipher suite 0 or cipher suite 2. Implementations 1950 only need to implement the algorithms needed for their supported 1951 methods. 1953 When using private cipher suite or registering new cipher suites, the 1954 choice of key length used in the different algorithms needs to be 1955 harmonized, so that a sufficient security level is maintained for 1956 certificates, EDHOC, and the protection of application data. The 1957 Initiator and the Responder should enforce a minimum security level. 1959 The hash algorithms SHA-1 and SHA-256/64 (256-bit Hash truncated to 1960 64-bits) SHALL NOT be supported for use in EDHOC except for 1961 certificate identification with x5u and c5u. Note that secp256k1 is 1962 only defined for use with ECDSA and not for ECDH. 1964 7.4. Unprotected Data 1966 The Initiator and the Responder must make sure that unprotected data 1967 and metadata do not reveal any sensitive information. This also 1968 applies for encrypted data sent to an unauthenticated party. In 1969 particular, it applies to EAD_1, ID_CRED_R, EAD_2, and error 1970 messages. Using the same EAD_1 in several EDHOC sessions allows 1971 passive eavesdroppers to correlate the different sessions. Another 1972 consideration is that the list of supported cipher suites may 1973 potentially be used to identify the application. 1975 The Initiator and the Responder must also make sure that 1976 unauthenticated data does not trigger any harmful actions. In 1977 particular, this applies to EAD_1 and error messages. 1979 7.5. Denial-of-Service 1981 EDHOC itself does not provide countermeasures against Denial-of- 1982 Service attacks. By sending a number of new or replayed message_1 an 1983 attacker may cause the Responder to allocate state, perform 1984 cryptographic operations, and amplify messages. To mitigate such 1985 attacks, an implementation SHOULD rely on lower layer mechanisms such 1986 as the Echo option in CoAP [I-D.ietf-core-echo-request-tag] that 1987 forces the initiator to demonstrate reachability at its apparent 1988 network address. 1990 An attacker can also send faked message_2, message_3, message_4, or 1991 error in an attempt to trick the receiving party to send an error 1992 message and discontinue the session. EDHOC implementations MAY 1993 evaluate if a received message is likely to have be forged by and 1994 attacker and ignore it without sending an error message or 1995 discontinuing the session. 1997 7.6. Implementation Considerations 1999 The availability of a secure random number generator is essential for 2000 the security of EDHOC. If no true random number generator is 2001 available, a truly random seed MUST be provided from an external 2002 source and used with a cryptographically secure pseudorandom number 2003 generator. As each pseudorandom number must only be used once, an 2004 implementation need to get a new truly random seed after reboot, or 2005 continuously store state in nonvolatile memory, see ([RFC8613], 2006 Appendix B.1.1) for issues and solution approaches for writing to 2007 nonvolatile memory. Intentionally or unintentionally weak or 2008 predictable pseudorandom number generators can be abused or exploited 2009 for malicious purposes. [RFC8937] describes a way for security 2010 protocol implementations to augment their (pseudo)random number 2011 generators using a long-term private keys and a deterministic 2012 signature function. This improves randomness from broken or 2013 otherwise subverted random number generators. The same idea can be 2014 used with other secrets and functions such as a Diffie-Hellman 2015 function or a symmetric secret and a PRF like HMAC or KMAC. It is 2016 RECOMMENDED to not trust a single source of randomness and to not put 2017 unaugmented random numbers on the wire. 2019 If ECDSA is supported, "deterministic ECDSA" as specified in 2020 [RFC6979] MAY be used. Pure deterministic elliptic-curve signatures 2021 such as deterministic ECDSA and EdDSA have gained popularity over 2022 randomized ECDSA as their security do not depend on a source of high- 2023 quality randomness. Recent research has however found that 2024 implementations of these signature algorithms may be vulnerable to 2025 certain side-channel and fault injection attacks due to their 2026 determinism. See e.g. Section 1 of 2027 [I-D.mattsson-cfrg-det-sigs-with-noise] for a list of attack papers. 2028 As suggested in Section 6.1.2 of [I-D.ietf-cose-rfc8152bis-algs] this 2029 can be addressed by combining randomness and determinism. 2031 All private keys, symmetric keys, and IVs MUST be secret. 2032 Implementations should provide countermeasures to side-channel 2033 attacks such as timing attacks. Intermediate computed values such as 2034 ephemeral ECDH keys and ECDH shared secrets MUST be deleted after key 2035 derivation is completed. 2037 The Initiator and the Responder are responsible for verifying the 2038 integrity of certificates. The selection of trusted CAs should be 2039 done very carefully and certificate revocation should be supported. 2040 The private authentication keys MUST be kept secret. 2042 The Initiator and the Responder are allowed to select the connection 2043 identifiers C_I and C_R, respectively, for the other party to use in 2044 the ongoing EDHOC protocol as well as in a subsequent application 2045 protocol (e.g. OSCORE [RFC8613]). The choice of connection 2046 identifier is not security critical in EDHOC but intended to simplify 2047 the retrieval of the right security context in combination with using 2048 short identifiers. If the wrong connection identifier of the other 2049 party is used in a protocol message it will result in the receiving 2050 party not being able to retrieve a security context (which will 2051 terminate the protocol) or retrieve the wrong security context (which 2052 also terminates the protocol as the message cannot be verified). 2054 If two nodes unintentionally initiate two simultaneous EDHOC message 2055 exchanges with each other even if they only want to complete a single 2056 EDHOC message exchange, they MAY terminate the exchange with the 2057 lexicographically smallest G_X. If the two G_X values are equal, the 2058 received message_1 MUST be discarded to mitigate reflection attacks. 2059 Note that in the case of two simultaneous EDHOC exchanges where the 2060 nodes only complete one and where the nodes have different preferred 2061 cipher suites, an attacker can affect which of the two nodes' 2062 preferred cipher suites will be used by blocking the other exchange. 2064 If supported by the device, it is RECOMMENDED that at least the long- 2065 term private keys are stored in a Trusted Execution Environment (TEE) 2066 and that sensitive operations using these keys are performed inside 2067 the TEE. To achieve even higher security it is RECOMMENDED that in 2068 additional operations such as ephemeral key generation, all 2069 computations of shared secrets, and storage of the pseudorandom keys 2070 (PRK) can be done inside the TEE. The use of a TEE enforces that 2071 code within that environment cannot be tampered with, and that any 2072 data used by such code cannot be read or tampered with by code 2073 outside that environment. Note that non-EDHOC code inside the TEE 2074 might still be able to read EDHOC data and tamper with EDHOC code, to 2075 protect against such attacks EDHOC needs to be in its own zone. To 2076 provide better protection against some forms of physical attacks, 2077 sensitive EDHOC data should be stored inside the SoC or encrypted and 2078 integrity protected when sent on a data bus (e.g. between the CPU and 2079 RAM or Flash). Secure boot can be used to increase the security of 2080 code and data in the Rich Execution Environment (REE) by validating 2081 the REE image. 2083 8. IANA Considerations 2085 8.1. EDHOC Exporter Label 2087 IANA has created a new registry titled "EDHOC Exporter Label" under 2088 the new heading "EDHOC". The registration procedure is "Expert 2089 Review". The columns of the registry are Label, Description, and 2090 Reference. All columns are text strings. The initial contents of 2091 the registry are: 2093 Label: EDHOC_message_4_Key 2094 Description: Key used to protect EDHOC message_4 2095 Reference: [[this document]] 2097 Label: EDHOC_message_4_Nonce 2098 Description: Nonce used to protect EDHOC message_4 2099 Reference: [[this document]] 2101 Label: OSCORE Master Secret 2102 Description: Derived OSCORE Master Secret 2103 Reference: [[this document]] 2105 Label: OSCORE Master Salt 2106 Description: Derived OSCORE Master Salt 2107 Reference: [[this document]] 2109 8.2. EDHOC Cipher Suites Registry 2111 IANA has created a new registry titled "EDHOC Cipher Suites" under 2112 the new heading "EDHOC". The registration procedure is "Expert 2113 Review". The columns of the registry are Value, Array, Description, 2114 and Reference, where Value is an integer and the other columns are 2115 text strings. The initial contents of the registry are: 2117 Value: -24 2118 Algorithms: N/A 2119 Desc: Reserved for Private Use 2120 Reference: [[this document]] 2122 Value: -23 2123 Algorithms: N/A 2124 Desc: Reserved for Private Use 2125 Reference: [[this document]] 2127 Value: -22 2128 Algorithms: N/A 2129 Desc: Reserved for Private Use 2130 Reference: [[this document]] 2132 Value: -21 2133 Algorithms: N/A 2134 Desc: Reserved for Private Use 2135 Reference: [[this document]] 2136 Value: 0 2137 Array: 10, -16, 4, -8, 10, -16 2138 Desc: AES-CCM-16-64-128, SHA-256, X25519, EdDSA, 2139 AES-CCM-16-64-128, SHA-256 2140 Reference: [[this document]] 2142 Value: 1 2143 Array: 30, -16, 4, -8, 10, -16 2144 Desc: AES-CCM-16-128-128, SHA-256, X25519, EdDSA, 2145 AES-CCM-16-64-128, SHA-256 2146 Reference: [[this document]] 2148 Value: 2 2149 Array: 10, -16, 1, -7, 10, -16 2150 Desc: AES-CCM-16-64-128, SHA-256, P-256, ES256, 2151 AES-CCM-16-64-128, SHA-256 2152 Reference: [[this document]] 2154 Value: 3 2155 Array: 30, -16, 1, -7, 10, -16 2156 Desc: AES-CCM-16-128-128, SHA-256, P-256, ES256, 2157 AES-CCM-16-64-128, SHA-256 2158 Reference: [[this document]] 2160 Value: 4 2161 Array: 24, -16, 4, -8, 24, -16 2162 Desc: ChaCha20/Poly1305, SHA-256, X25519, EdDSA, 2163 ChaCha20/Poly1305, SHA-256 2164 Reference: [[this document]] 2166 Value: 5 2167 Array: 24, -16, 1, -7, 24, -16 2168 Desc: ChaCha20/Poly1305, SHA-256, P-256, ES256, 2169 ChaCha20/Poly1305, SHA-256 2170 Reference: [[this document]] 2172 Value: 6 2173 Array: 1, -16, 4, -7, 1, -16 2174 Desc: A128GCM, SHA-256, X25519, ES256, 2175 A128GCM, SHA-256 2176 Reference: [[this document]] 2178 Value: 24 2179 Array: 3, -43, 2, -35, 3, -43 2180 Desc: A256GCM, SHA-384, P-384, ES384, 2181 A256GCM, SHA-384 2182 Reference: [[this document]] 2183 Value: 25 2184 Array: 24, -45, 5, -8, 24, -45 2185 Desc: ChaCha20/Poly1305, SHAKE256, X448, EdDSA, 2186 ChaCha20/Poly1305, SHAKE256 2187 Reference: [[this document]] 2189 8.3. EDHOC Method Type Registry 2191 IANA has created a new registry entitled "EDHOC Method Type" under 2192 the new heading "EDHOC". The registration procedure is "Expert 2193 Review". The columns of the registry are Value, Description, and 2194 Reference, where Value is an integer and the other columns are text 2195 strings. The initial contents of the registry is shown in Figure 4. 2197 8.4. EDHOC Error Codes Registry 2199 IANA has created a new registry entitled "EDHOC Error Codes" under 2200 the new heading "EDHOC". The registration procedure is 2201 "Specification Required". The columns of the registry are ERR_CODE, 2202 ERR_INFO Type and Description, where ERR_CODE is an integer, ERR_INFO 2203 is a CDDL defined type, and Description is a text string. The 2204 initial contents of the registry is shown in Figure 6. 2206 8.5. COSE Header Parameters Registry 2208 This document registers the following entries in the "COSE Header 2209 Parameters" registry under the "CBOR Object Signing and Encryption 2210 (COSE)" heading. The value of the 'cwt' header parameter is a CWT 2211 [RFC8392] or an unprotected CWT Claims Set [I-D.ietf-rats-uccs]. 2213 +-----------+-------+----------------+------------------------------+ 2214 | Name | Label | Value Type | Description | 2215 +===========+=======+================+==============================+ 2216 | cwt | TBD1 | COSE_Messages | A CBOR Web Token (CWT) or an | 2217 | | | / map | unprotected CWT Claims Set | 2218 +-----------+-------+----------------+------------------------------+ 2220 8.6. COSE Header Parameters Registry 2222 IANA has added the COSE header parameter 'kid2' to the COSE Header 2223 Parameters registry. The kid2 parameter may point to a COSE key 2224 common parameter 'kid' or 'kid2'. The kid2 parameter can be used to 2225 identify a key stored in a "raw" COSE_Key, in a CWT, or in a 2226 certificate. The Value Reference for this item is empty and omitted 2227 from the table below. 2229 +------+-------+------------+----------------+-------------------+ 2230 | Name | Label | Value Type | Description | Reference | 2231 +------+-------+------------+----------------+-------------------+ 2232 | kid2 | TBD | bstr / int | Key identifier | [[This document]] | 2233 +------+-------+------------+----------------+-------------------+ 2235 8.7. COSE Key Common Parameters Registry 2237 IANA has added the COSE key common parameter 'kid2' to the COSE Key 2238 Common Parameters registry. The Value Reference for this item is 2239 empty and omitted from the table below. 2241 +------+-------+------------+----------------+-------------------+ 2242 | Name | Label | Value Type | Description | Reference | 2243 +------+-------+------------+----------------+-------------------+ 2244 | kid2 | TBD | bstr / int | Key identifi- | [[This document]] | 2245 | | | | cation value - | | 2246 | | | | match to kid2 | | 2247 | | | | in message | | 2248 +------+-------+------------+----------------+-------------------+ 2250 8.8. The Well-Known URI Registry 2252 IANA has added the well-known URI 'edhoc' to the Well-Known URIs 2253 registry. 2255 o URI suffix: edhoc 2257 o Change controller: IETF 2259 o Specification document(s): [[this document]] 2261 o Related information: None 2263 8.9. Media Types Registry 2265 IANA has added the media type 'application/edhoc' to the Media Types 2266 registry. 2268 o Type name: application 2270 o Subtype name: edhoc 2272 o Required parameters: N/A 2274 o Optional parameters: N/A 2276 o Encoding considerations: binary 2277 o Security considerations: See Section 7 of this document. 2279 o Interoperability considerations: N/A 2281 o Published specification: [[this document]] (this document) 2283 o Applications that use this media type: To be identified 2285 o Fragment identifier considerations: N/A 2287 o Additional information: 2289 * Magic number(s): N/A 2291 * File extension(s): N/A 2293 * Macintosh file type code(s): N/A 2295 o Person & email address to contact for further information: See 2296 "Authors' Addresses" section. 2298 o Intended usage: COMMON 2300 o Restrictions on usage: N/A 2302 o Author: See "Authors' Addresses" section. 2304 o Change Controller: IESG 2306 8.10. CoAP Content-Formats Registry 2308 IANA has added the media type 'application/edhoc' to the CoAP 2309 Content-Formats registry. 2311 o Media Type: application/edhoc 2313 o Encoding: 2315 o ID: TBD42 2317 o Reference: [[this document]] 2319 8.11. EDHOC External Authorization Data 2321 IANA has created a new registry entitled "EDHOC External 2322 Authorization Data" under the new heading "EDHOC". The registration 2323 procedure is "Expert Review". The columns of the registry are Value, 2324 Description, and Reference, where Value is an integer and the other 2325 columns are text strings. 2327 8.12. Expert Review Instructions 2329 The IANA Registries established in this document is defined as 2330 "Expert Review". This section gives some general guidelines for what 2331 the experts should be looking for, but they are being designated as 2332 experts for a reason so they should be given substantial latitude. 2334 Expert reviewers should take into consideration the following points: 2336 o Clarity and correctness of registrations. Experts are expected to 2337 check the clarity of purpose and use of the requested entries. 2338 Expert needs to make sure the values of algorithms are taken from 2339 the right registry, when that's required. Expert should consider 2340 requesting an opinion on the correctness of registered parameters 2341 from relevant IETF working groups. Encodings that do not meet 2342 these objective of clarity and completeness should not be 2343 registered. 2345 o Experts should take into account the expected usage of fields when 2346 approving point assignment. The length of the encoded value 2347 should be weighed against how many code points of that length are 2348 left, the size of device it will be used on, and the number of 2349 code points left that encode to that size. 2351 o Specifications are recommended. When specifications are not 2352 provided, the description provided needs to have sufficient 2353 information to verify the points above. 2355 9. References 2357 9.1. Normative References 2359 [I-D.ietf-core-echo-request-tag] 2360 Amsuess, C., Mattsson, J. P., and G. Selander, "CoAP: 2361 Echo, Request-Tag, and Token Processing", draft-ietf-core- 2362 echo-request-tag-12 (work in progress), February 2021. 2364 [I-D.ietf-cose-rfc8152bis-algs] 2365 Schaad, J., "CBOR Object Signing and Encryption (COSE): 2366 Initial Algorithms", draft-ietf-cose-rfc8152bis-algs-12 2367 (work in progress), September 2020. 2369 [I-D.ietf-cose-rfc8152bis-struct] 2370 Schaad, J., "CBOR Object Signing and Encryption (COSE): 2371 Structures and Process", draft-ietf-cose-rfc8152bis- 2372 struct-15 (work in progress), February 2021. 2374 [I-D.ietf-cose-x509] 2375 Schaad, J., "CBOR Object Signing and Encryption (COSE): 2376 Header parameters for carrying and referencing X.509 2377 certificates", draft-ietf-cose-x509-08 (work in progress), 2378 December 2020. 2380 [I-D.ietf-lake-reqs] 2381 Vucinic, M., Selander, G., Mattsson, J. P., and D. Garcia- 2382 Carrillo, "Requirements for a Lightweight AKE for OSCORE", 2383 draft-ietf-lake-reqs-04 (work in progress), June 2020. 2385 [I-D.ietf-rats-uccs] 2386 Birkholz, H., O'Donoghue, J., Cam-Winget, N., and C. 2387 Bormann, "A CBOR Tag for Unprotected CWT Claims Sets", 2388 draft-ietf-rats-uccs-00 (work in progress), May 2021. 2390 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2391 Requirement Levels", BCP 14, RFC 2119, 2392 DOI 10.17487/RFC2119, March 1997, 2393 . 2395 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 2396 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 2397 . 2399 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 2400 Key Derivation Function (HKDF)", RFC 5869, 2401 DOI 10.17487/RFC5869, May 2010, 2402 . 2404 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 2405 Curve Cryptography Algorithms", RFC 6090, 2406 DOI 10.17487/RFC6090, February 2011, 2407 . 2409 [RFC6979] Pornin, T., "Deterministic Usage of the Digital Signature 2410 Algorithm (DSA) and Elliptic Curve Digital Signature 2411 Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, August 2412 2013, . 2414 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 2415 Application Protocol (CoAP)", RFC 7252, 2416 DOI 10.17487/RFC7252, June 2014, 2417 . 2419 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 2420 for Security", RFC 7748, DOI 10.17487/RFC7748, January 2421 2016, . 2423 [RFC7959] Bormann, C. and Z. Shelby, Ed., "Block-Wise Transfers in 2424 the Constrained Application Protocol (CoAP)", RFC 7959, 2425 DOI 10.17487/RFC7959, August 2016, 2426 . 2428 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2429 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2430 May 2017, . 2432 [RFC8376] Farrell, S., Ed., "Low-Power Wide Area Network (LPWAN) 2433 Overview", RFC 8376, DOI 10.17487/RFC8376, May 2018, 2434 . 2436 [RFC8392] Jones, M., Wahlstroem, E., Erdtman, S., and H. Tschofenig, 2437 "CBOR Web Token (CWT)", RFC 8392, DOI 10.17487/RFC8392, 2438 May 2018, . 2440 [RFC8610] Birkholz, H., Vigano, C., and C. Bormann, "Concise Data 2441 Definition Language (CDDL): A Notational Convention to 2442 Express Concise Binary Object Representation (CBOR) and 2443 JSON Data Structures", RFC 8610, DOI 10.17487/RFC8610, 2444 June 2019, . 2446 [RFC8613] Selander, G., Mattsson, J., Palombini, F., and L. Seitz, 2447 "Object Security for Constrained RESTful Environments 2448 (OSCORE)", RFC 8613, DOI 10.17487/RFC8613, July 2019, 2449 . 2451 [RFC8724] Minaburo, A., Toutain, L., Gomez, C., Barthel, D., and JC. 2452 Zuniga, "SCHC: Generic Framework for Static Context Header 2453 Compression and Fragmentation", RFC 8724, 2454 DOI 10.17487/RFC8724, April 2020, 2455 . 2457 [RFC8742] Bormann, C., "Concise Binary Object Representation (CBOR) 2458 Sequences", RFC 8742, DOI 10.17487/RFC8742, February 2020, 2459 . 2461 [RFC8949] Bormann, C. and P. Hoffman, "Concise Binary Object 2462 Representation (CBOR)", STD 94, RFC 8949, 2463 DOI 10.17487/RFC8949, December 2020, 2464 . 2466 9.2. Informative References 2468 [Bruni18] Bruni, A., Sahl Joergensen, T., Groenbech Petersen, T., 2469 and C. Schuermann, "Formal Verification of Ephemeral 2470 Diffie-Hellman Over COSE (EDHOC)", November 2018, 2471 . 2475 [CborMe] Bormann, C., "CBOR Playground", May 2018, 2476 . 2478 [CNSA] (Placeholder), ., "Commercial National Security Algorithm 2479 Suite", August 2015, 2480 . 2483 [I-D.ietf-core-oscore-edhoc] 2484 Palombini, F., Tiloca, M., Hoeglund, R., Hristozov, S., 2485 and G. Selander, "Combining EDHOC and OSCORE", draft-ietf- 2486 core-oscore-edhoc-00 (work in progress), April 2021. 2488 [I-D.ietf-core-resource-directory] 2489 Amsuess, C., Shelby, Z., Koster, M., Bormann, C., and P. 2490 V. D. Stok, "CoRE Resource Directory", draft-ietf-core- 2491 resource-directory-28 (work in progress), March 2021. 2493 [I-D.ietf-cose-cbor-encoded-cert] 2494 Raza, S., Hoeglund, J., Selander, G., Mattsson, J. P., and 2495 M. Furuhed, "CBOR Encoded X.509 Certificates (C509 2496 Certificates)", draft-ietf-cose-cbor-encoded-cert-00 (work 2497 in progress), April 2021. 2499 [I-D.ietf-lwig-security-protocol-comparison] 2500 Mattsson, J. P., Palombini, F., and M. Vucinic, 2501 "Comparison of CoAP Security Protocols", draft-ietf-lwig- 2502 security-protocol-comparison-05 (work in progress), 2503 November 2020. 2505 [I-D.ietf-tls-dtls13] 2506 Rescorla, E., Tschofenig, H., and N. Modadugu, "The 2507 Datagram Transport Layer Security (DTLS) Protocol Version 2508 1.3", draft-ietf-tls-dtls13-43 (work in progress), April 2509 2021. 2511 [I-D.mattsson-cfrg-det-sigs-with-noise] 2512 Mattsson, J. P., Thormarker, E., and S. Ruohomaa, 2513 "Deterministic ECDSA and EdDSA Signatures with Additional 2514 Randomness", draft-mattsson-cfrg-det-sigs-with-noise-02 2515 (work in progress), March 2020. 2517 [I-D.selander-ace-ake-authz] 2518 Selander, G., Mattsson, J. P., Vucinic, M., Richardson, 2519 M., and A. Schellenbaum, "Lightweight Authorization for 2520 Authenticated Key Exchange.", draft-selander-ace-ake- 2521 authz-02 (work in progress), November 2020. 2523 [Norrman20] 2524 Norrman, K., Sundararajan, V., and A. Bruni, "Formal 2525 Analysis of EDHOC Key Establishment for Constrained IoT 2526 Devices", September 2020, 2527 . 2529 [RFC7228] Bormann, C., Ersue, M., and A. Keranen, "Terminology for 2530 Constrained-Node Networks", RFC 7228, 2531 DOI 10.17487/RFC7228, May 2014, 2532 . 2534 [RFC7258] Farrell, S. and H. Tschofenig, "Pervasive Monitoring Is an 2535 Attack", BCP 188, RFC 7258, DOI 10.17487/RFC7258, May 2536 2014, . 2538 [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T. 2539 Kivinen, "Internet Key Exchange Protocol Version 2 2540 (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October 2541 2014, . 2543 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 2544 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 2545 . 2547 [RFC8937] Cremers, C., Garratt, L., Smyshlyaev, S., Sullivan, N., 2548 and C. Wood, "Randomness Improvements for Security 2549 Protocols", RFC 8937, DOI 10.17487/RFC8937, October 2020, 2550 . 2552 [SECG] "Standards for Efficient Cryptography 1 (SEC 1)", May 2553 2009, . 2555 [SIGMA] Krawczyk, H., "SIGMA - The 'SIGn-and-MAc' Approach to 2556 Authenticated Diffie-Hellman and Its Use in the IKE- 2557 Protocols (Long version)", June 2003, 2558 . 2560 [SP-800-56A] 2561 Barker, E., Chen, L., Roginsky, A., Vassilev, A., and R. 2562 Davis, "Recommendation for Pair-Wise Key-Establishment 2563 Schemes Using Discrete Logarithm Cryptography", 2564 NIST Special Publication 800-56A Revision 3, April 2018, 2565 . 2567 Appendix A. Use with OSCORE and Transfer over CoAP 2569 This sppendix describes how to select EDHOC connection identifiers 2570 and derive an OSCORE security context when OSCORE is used with EDHOC, 2571 and how to transfer EDHOC messages over CoAP. 2573 A.1. Selecting EDHOC Connection Identifier 2575 This section specifies a rule for converting from EDHOC connection 2576 identifier to OSCORE Sender/Recipient ID. (An identifier is Sender 2577 ID or Recipient ID depending on from which endpoint is the point of 2578 view, see Section 3.1 of [RFC8613].) 2580 o If the EDHOC connection identifier is numeric, i.e. encoded as a 2581 CBOR integer on the wire, it is converted to a (naturally byte- 2582 string shaped) OSCORE Sender/Recipient ID equal to its CBOR 2583 encoded form. 2585 For example, a numeric C_R equal to 10 (0x0A in CBOR encoding) is 2586 converted to a (typically client) Sender ID equal to 0x0A, while a 2587 numeric C_I equal to -12 (0x2B in CBOR encoding) is converted to a 2588 (typically client) Sender ID equal to 0x2B. 2590 o If the EDHOC connection identifier is byte-valued, hence encoded 2591 as a CBOR byte string on the wire, it is converted to an OSCORE 2592 Sender/Recipient ID equal to the byte string. 2594 For example, a byte-string valued C_R equal to 0xFF (0x41FF in CBOR 2595 encoding) is converted to a (typically client) Sender ID equal to 2596 0xFF. 2598 Two EDHOC connection identifiers are called "equivalent" if and only 2599 if, by applying the conversion above, they both result in the same 2600 OSCORE Sender/Recipient ID. For example, the two EDHOC connection 2601 identifiers with CBOR encoding 0x0A (numeric) and 0x410A (byte- 2602 valued) are equivalent since they both result in the same OSCORE 2603 Sender/Recipient ID 0x0A. 2605 When EDHOC is used to establish an OSCORE security context, the 2606 connection identifiers C_I and C_R MUST NOT be equivalent. 2607 Furthermore, in case of multiple OSCORE security contexts with 2608 potentially different endpoints, to facilitate retrieval of the 2609 correct OSCORE security context, an endpoint SHOULD select an EDHOC 2610 connection identifier that when converted to OSCORE Recipient ID does 2611 not coincide with its other Recipient IDs. 2613 A.2. Deriving the OSCORE Security Context 2615 This section specifies how to use EDHOC output to derive the OSCORE 2616 security context. 2618 After successful processing of EDHOC message_3, Client and Server 2619 derive Security Context parameters for OSCORE as follows (see 2620 Section 3.2 of [RFC8613]): 2622 o The Master Secret and Master Salt are derived by using the EDHOC- 2623 Exporter interface, see Section 4.1. 2625 The EDHOC Exporter Labels for deriving the OSCORE Master Secret and 2626 the OSCORE Master Salt, are "OSCORE Master Secret" and "OSCORE Master 2627 Salt", respectively. 2629 The context parameter is h'' (0x40), the empty CBOR byte string. 2631 By default, key_length is the key length (in bytes) of the 2632 application AEAD Algorithm of the selected cipher suite for the EDHOC 2633 session. Also by default, salt_length has value 8. The Initiator 2634 and Responder MAY agree out-of-band on a longer key_length than the 2635 default and on a different salt_length. 2637 Master Secret = EDHOC-Exporter( "OSCORE Master Secret", h'', key_length ) 2638 Master Salt = EDHOC-Exporter( "OSCORE Master Salt", h'', salt_length ) 2640 o The AEAD Algorithm is the application AEAD algorithm of the 2641 selected cipher suite for the EDHOC session. 2643 o The HKDF Algorithm is the one based on the application hash 2644 algorithm of the selected cipher suite for the EDHOC session. For 2645 example, if SHA-256 is the application hash algorithm of the 2646 selected ciphersuite, HKDF SHA-256 is used as HKDF Algorithm in 2647 the OSCORE Security Context. 2649 o In case the Client is Initiator and the Server is Responder, the 2650 Client's OSCORE Sender ID and the Server's OSCORE Sender ID are 2651 determined from the EDHOC connection identifiers C_R and C_I for 2652 the EDHOC session, respectively, by applying the conversion in 2653 Appendix A.1. The reverse applies in case the Client is the 2654 Responder and the Server is the Initiator. 2656 Client and Server use the parameters above to establish an OSCORE 2657 Security Context, as per Section 3.2.1 of [RFC8613]. 2659 From then on, Client and Server retrieve the OSCORE protocol state 2660 using the Recipient ID, and optionally other transport information 2661 such as the 5-tuple. 2663 A.3. Transferring EDHOC over CoAP 2665 This section specifies one instance for how EDHOC can be transferred 2666 as an exchange of CoAP [RFC7252] messages. CoAP is a reliable 2667 transport that can preserve packet ordering and handle message 2668 duplication. CoAP can also perform fragmentation and protect against 2669 denial of service attacks. According to this specification, EDHOC 2670 messages are carried in Confirmable messages, which is beneficial 2671 especially if fragmentation is used. 2673 By default, the CoAP client is the Initiator and the CoAP server is 2674 the Responder, but the roles SHOULD be chosen to protect the most 2675 sensitive identity, see Section 7. According to this specification, 2676 EDHOC is transferred in POST requests and 2.04 (Changed) responses to 2677 the Uri-Path: "/.well-known/edhoc". An application may define its 2678 own path that can be discovered, e.g., using resource directory 2679 [I-D.ietf-core-resource-directory]. 2681 By default, the message flow is as follows: EDHOC message_1 is sent 2682 in the payload of a POST request from the client to the server's 2683 resource for EDHOC. EDHOC message_2 or the EDHOC error message is 2684 sent from the server to the client in the payload of a 2.04 (Changed) 2685 response. EDHOC message_3 or the EDHOC error message is sent from 2686 the client to the server's resource in the payload of a POST request. 2687 If needed, an EDHOC error message is sent from the server to the 2688 client in the payload of a 2.04 (Changed) response. Alternatively, 2689 if EDHOC message_4 is used, it is sent from the server to the client 2690 in the payload of a 2.04 (Changed) response analogously to message_2. 2692 In order to correlate a message received from a client to a message 2693 previously sent by the server, messages sent by the client are 2694 prepended with the CBOR serialization of the connection identifier 2695 which the server has chosen. This applies independently of if the 2696 CoAP server is Responder or Initiator. For the default case when the 2697 server is Responder, the prepended connection identifier is C_R, and 2698 C_I if the server is Initiator. If message_1 is sent to the server, 2699 the CBOR simple value "null" (0xf6) is sent in its place (given that 2700 the server has not selected C_R yet). 2702 These identifiers are encoded in CBOR and thus self-delimiting. They 2703 are sent in front of the actual EDHOC message, and only the part of 2704 the body following the identifier is used for EDHOC processing. 2706 Consequently, the application/edhoc media type does not apply to 2707 these messages; their media type is unnamed. 2709 An example of a successful EDHOC exchange using CoAP is shown in 2710 Figure 9. In this case the CoAP Token enables correlation on the 2711 Initiator side, and the prepended C_R enables correlation on the 2712 Responder (server) side. 2714 Client Server 2715 | | 2716 +--------->| Header: POST (Code=0.02) 2717 | POST | Uri-Path: "/.well-known/edhoc" 2718 | | Payload: null, EDHOC message_1 2719 | | 2720 |<---------+ Header: 2.04 Changed 2721 | 2.04 | Content-Format: application/edhoc 2722 | | Payload: EDHOC message_2 2723 | | 2724 +--------->| Header: POST (Code=0.02) 2725 | POST | Uri-Path: "/.well-known/edhoc" 2726 | | Payload: C_R, EDHOC message_3 2727 | | 2728 |<---------+ Header: 2.04 Changed 2729 | 2.04 | 2730 | | 2732 Figure 9: Transferring EDHOC in CoAP when the Initiator is CoAP 2733 Client 2735 The exchange in Figure 9 protects the client identity against active 2736 attackers and the server identity against passive attackers. 2738 An alternative exchange that protects the server identity against 2739 active attackers and the client identity against passive attackers is 2740 shown in Figure 10. In this case the CoAP Token enables the 2741 Responder to correlate message_2 and message_3, and the prepended C_I 2742 enables correlation on the Initiator (server) side. If EDHOC 2743 message_4 is used, C_I is prepended, and it is transported with CoAP 2744 in the payload of a POST request with a 2.04 (Changed) response. 2746 Client Server 2747 | | 2748 +--------->| Header: POST (Code=0.02) 2749 | POST | Uri-Path: "/.well-known/edhoc" 2750 | | 2751 |<---------+ Header: 2.04 Changed 2752 | 2.04 | Content-Format: application/edhoc 2753 | | Payload: EDHOC message_1 2754 | | 2755 +--------->| Header: POST (Code=0.02) 2756 | POST | Uri-Path: "/.well-known/edhoc" 2757 | | Payload: C_I, EDHOC message_2 2758 | | 2759 |<---------+ Header: 2.04 Changed 2760 | 2.04 | Content-Format: application/edhoc 2761 | | Payload: EDHOC message_3 2762 | | 2764 Figure 10: Transferring EDHOC in CoAP when the Initiator is CoAP 2765 Server 2767 To protect against denial-of-service attacks, the CoAP server MAY 2768 respond to the first POST request with a 4.01 (Unauthorized) 2769 containing an Echo option [I-D.ietf-core-echo-request-tag]. This 2770 forces the initiator to demonstrate its reachability at its apparent 2771 network address. If message fragmentation is needed, the EDHOC 2772 messages may be fragmented using the CoAP Block-Wise Transfer 2773 mechanism [RFC7959]. EDHOC does not restrict how error messages are 2774 transported with CoAP, as long as the appropriate error message can 2775 to be transported in response to a message that failed (see 2776 Section 6). 2778 A.3.1. Transferring EDHOC and OSCORE over CoAP 2780 A method for combining EDHOC and OSCORE protocols in two round-trips 2781 is specified in [I-D.ietf-core-oscore-edhoc]. 2783 When using EDHOC over CoAP for establishing an OSCORE Security 2784 Context, EDHOC error messages sent as CoAP responses MUST be error 2785 responses, i.e., they MUST specify a CoAP error response code. In 2786 particular, it is RECOMMENDED that such error responses have response 2787 code either 4.00 (Bad Request) in case of client error (e.g., due to 2788 a malformed EDHOC message), or 5.00 (Internal Server Error) in case 2789 of server error (e.g., due to failure in deriving EDHOC key 2790 material). 2792 Appendix B. Compact Representation 2794 As described in Section 4.2 of [RFC6090] the x-coordinate of an 2795 elliptic curve public key is a suitable representative for the entire 2796 point whenever scalar multiplication is used as a one-way function. 2797 One example is ECDH with compact output, where only the x-coordinate 2798 of the computed value is used as the shared secret. 2800 This section defines a format for compact representation based on the 2801 Elliptic-Curve-Point-to-Octet-String Conversion defined in 2802 Section 2.3.3 of [SECG]. Using the notation from [SECG], the output 2803 is an octet string of length ceil( (log2 q) / 8 ). See [SECG] for a 2804 definition of q, M, X, xp, and ~yp. The steps in Section 2.3.3 of 2805 [SECG] are replaced by: 2807 1. Convert the field element xp to an octet string X of length ceil( 2808 (log2 q) / 8 ) octets using the conversion routine specified in 2809 Section 2.3.5 of [SECG]. 2811 2. Output M = X 2813 The encoding of the point at infinity is not supported. Compact 2814 representation does not change any requirements on validation. If a 2815 y-coordinate is required for validation or compatibily with APIs the 2816 value ~yp SHALL be set to zero. For such use, the compact 2817 representation can be transformed into the SECG point compressed 2818 format by prepending it with the single byte 0x02 (i.e. M = 0x02 || 2819 X). 2821 Using compact representation have some security benefits. An 2822 implementation does not need to check that the point is not the point 2823 at infinity (the identity element). Similarly, as not even the sign 2824 of the y-coordinate is encoded, compact representation trivially 2825 avoids so called "benign malleability" attacks where an attacker 2826 changes the sign, see [SECG]. 2828 Appendix C. Use of CBOR, CDDL and COSE in EDHOC 2830 This Appendix is intended to simplify for implementors not familiar 2831 with CBOR [RFC8949], CDDL [RFC8610], COSE 2832 [I-D.ietf-cose-rfc8152bis-struct], and HKDF [RFC5869]. 2834 C.1. CBOR and CDDL 2836 The Concise Binary Object Representation (CBOR) [RFC8949] is a data 2837 format designed for small code size and small message size. CBOR 2838 builds on the JSON data model but extends it by e.g. encoding binary 2839 data directly without base64 conversion. In addition to the binary 2840 CBOR encoding, CBOR also has a diagnostic notation that is readable 2841 and editable by humans. The Concise Data Definition Language (CDDL) 2842 [RFC8610] provides a way to express structures for protocol messages 2843 and APIs that use CBOR. [RFC8610] also extends the diagnostic 2844 notation. 2846 CBOR data items are encoded to or decoded from byte strings using a 2847 type-length-value encoding scheme, where the three highest order bits 2848 of the initial byte contain information about the major type. CBOR 2849 supports several different types of data items, in addition to 2850 integers (int, uint), simple values (e.g. null), byte strings (bstr), 2851 and text strings (tstr), CBOR also supports arrays [] of data items, 2852 maps {} of pairs of data items, and sequences [RFC8742] of data 2853 items. Some examples are given below. For a complete specification 2854 and more examples, see [RFC8949] and [RFC8610]. We recommend 2855 implementors to get used to CBOR by using the CBOR playground 2856 [CborMe]. 2858 Diagnostic Encoded Type 2859 ------------------------------------------------------------------ 2860 1 0x01 unsigned integer 2861 24 0x1818 unsigned integer 2862 -24 0x37 negative integer 2863 -25 0x3818 negative integer 2864 null 0xf6 simple value 2865 h'12cd' 0x4212cd byte string 2866 '12cd' 0x4431326364 byte string 2867 "12cd" 0x6431326364 text string 2868 { 4 : h'cd' } 0xa10441cd map 2869 << 1, 2, null >> 0x430102f6 byte string 2870 [ 1, 2, null ] 0x830102f6 array 2871 ( 1, 2, null ) 0x0102f6 sequence 2872 1, 2, null 0x0102f6 sequence 2873 ------------------------------------------------------------------ 2875 C.2. CDDL Definitions 2877 This sections compiles the CDDL definitions for ease of reference. 2879 suite = int 2881 SUITES_R : [ supported : 2* suite ] / suite 2883 message_1 = ( 2884 METHOD : int, 2885 SUITES_I : [ selected : suite, supported : 2* suite ] / suite, 2886 G_X : bstr, 2887 C_I : bstr / int, 2888 ? EAD ; EAD_1 2889 ) 2891 message_2 = ( 2892 data_2, 2893 CIPHERTEXT_2 : bstr, 2894 ) 2896 data_2 = ( 2897 G_Y : bstr, 2898 C_R : bstr / int, 2899 ) 2901 message_3 = ( 2902 CIPHERTEXT_3 : bstr, 2903 ) 2905 message_4 = ( 2906 CIPHERTEXT_4 : bstr, 2907 ) 2909 error = ( 2910 ERR_CODE : int, 2911 ERR_INFO : any 2912 ) 2914 info = [ 2915 edhoc_aead_id : int / tstr, 2916 transcript_hash : bstr, 2917 label : tstr, 2918 length : uint 2919 ] 2921 C.3. COSE 2923 CBOR Object Signing and Encryption (COSE) 2924 [I-D.ietf-cose-rfc8152bis-struct] describes how to create and process 2925 signatures, message authentication codes, and encryption using CBOR. 2926 COSE builds on JOSE, but is adapted to allow more efficient 2927 processing in constrained devices. EDHOC makes use of COSE_Key, 2928 COSE_Encrypt0, and COSE_Sign1 objects. 2930 Appendix D. Test Vectors 2932 NOTE 0. These test vectors are compatible with versions -05 and -06 2933 of the specification. 2935 This appendix provides detailed test vectors to ease implementation 2936 and ensure interoperability. In addition to hexadecimal, all CBOR 2937 data items and sequences are given in CBOR diagnostic notation. The 2938 test vectors use the default mapping to CoAP where the Initiator acts 2939 as CoAP client (this means that corr = 1). 2941 A more extensive test vector suite covering more combinations of 2942 authentication method used between Initiator and Responder and 2943 related code to generate them can be found at https://github.com/ 2944 lake-wg/edhoc/tree/master/test-vectors-05. 2946 NOTE 1. In the previous and current test vectors the same name is 2947 used for certain byte strings and their CBOR bstr encodings. For 2948 example the transcript hash TH_2 is used to denote both the output of 2949 the hash function and the input into the key derivation function, 2950 whereas the latter is a CBOR bstr encoding of the former. Some 2951 attempts are made to clarify that in this Appendix (e.g. using "CBOR 2952 encoded"/"CBOR unencoded"). 2954 NOTE 2. If not clear from the context, remember that CBOR sequences 2955 and CBOR arrays assume CBOR encoded data items as elements. 2957 D.1. Test Vectors for EDHOC Authenticated with Signature Keys (x5t) 2959 EDHOC with signature authentication and X.509 certificates is used. 2960 In this test vector, the hash value 'x5t' is used to identify the 2961 certificate. The optional C_1 in message_1 is omitted. No external 2962 authorization data is sent in the message exchange. 2964 method (Signature Authentication) 2965 0 2967 CoAP is used as transport and the Initiator acts as CoAP client: 2969 corr (the Initiator can correlate message_1 and message_2) 2970 1 2972 From there, METHOD_CORR has the following value: 2974 METHOD_CORR (4 * method + corr) (int) 2975 1 2977 The Initiator indicates only one cipher suite in the (potentially 2978 truncated) list of cipher suites. 2980 Supported Cipher Suites (1 byte) 2981 00 2983 The Initiator selected the indicated cipher suite. 2985 Selected Cipher Suite (int) 2986 0 2988 Cipher suite 0 is supported by both the Initiator and the Responder, 2989 see Section 3.6. 2991 D.1.1. Message_1 2993 The Initiator generates its ephemeral key pair. 2995 X (Initiator's ephemeral private key) (32 bytes) 2996 8f 78 1a 09 53 72 f8 5b 6d 9f 61 09 ae 42 26 11 73 4d 7d bf a0 06 9a 2d 2997 f2 93 5b b2 e0 53 bf 35 2999 G_X (Initiator's ephemeral public key, CBOR unencoded) (32 bytes) 3000 89 8f f7 9a 02 06 7a 16 ea 1e cc b9 0f a5 22 46 f5 aa 4d d6 ec 07 6b ba 3001 02 59 d9 04 b7 ec 8b 0c 3003 The Initiator chooses a connection identifier C_I: 3005 Connection identifier chosen by Initiator (1 byte) 3006 09 3008 Note that since C_I is a byte string in the interval h'00' to h'2f', 3009 it is encoded as the corresponding integer subtracted by 24. Thus 3010 0x09 = 09, 9 - 24 = -15, and -15 in CBOR encoding is equal to 0x2e. 3012 C_I (1 byte) 3013 2e 3015 Since no external authorization data is sent: 3017 EAD_1 (0 bytes) 3019 The list of supported cipher suites needs to contain the selected 3020 cipher suite. The initiator truncates the list of supported cipher 3021 suites to one cipher suite only. In this case there is only one 3022 supported cipher suite indicated, 00. 3024 Because one single selected cipher suite is conveyed, it is encoded 3025 as an int instead of an array: 3027 SUITES_I (int) 3028 0 3030 message_1 is constructed as the CBOR Sequence of the data items above 3031 encoded as CBOR. In CBOR diagnostic notation: 3033 message_1 = 3034 ( 3035 1, 3036 0, 3037 h'898FF79A02067A16EA1ECCB90FA52246F5AA4DD6EC076BBA0259D904B7EC8B0C', 3038 -15 3039 ) 3041 Which as a CBOR encoded data item is: 3043 message_1 (CBOR Sequence) (37 bytes) 3044 01 00 58 20 89 8f f7 9a 02 06 7a 16 ea 1e cc b9 0f a5 22 46 f5 aa 4d d6 3045 ec 07 6b ba 02 59 d9 04 b7 ec 8b 0c 2e 3047 D.1.2. Message_2 3049 Since METHOD_CORR mod 4 equals 1, C_I is omitted from data_2. 3051 The Responder generates the following ephemeral key pair. 3053 Y (Responder's ephemeral private key) (32 bytes) 3054 fd 8c d8 77 c9 ea 38 6e 6a f3 4f f7 e6 06 c4 b6 4c a8 31 c8 ba 33 13 4f 3055 d4 cd 71 67 ca ba ec da 3057 G_Y (Responder's ephemeral public key, CBOR unencoded) (32 bytes) 3058 71 a3 d5 99 c2 1d a1 89 02 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 19 52 3059 81 75 4c 5e bc af 30 1e 3061 From G_X and Y or from G_Y and X the ECDH shared secret is computed: 3063 G_XY (ECDH shared secret) (32 bytes) 3064 2b b7 fa 6e 13 5b c3 35 d0 22 d6 34 cb fb 14 b3 f5 82 f3 e2 e3 af b2 b3 3065 15 04 91 49 5c 61 78 2b 3067 The key and nonce for calculating the 'ciphertext' are calculated as 3068 follows, as specified in Section 4. 3070 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 3072 PRK_2e = HMAC-SHA-256(salt, G_XY) 3074 Salt is the empty byte string. 3076 salt (0 bytes) 3078 From there, PRK_2e is computed: 3080 PRK_2e (32 bytes) 3081 ec 62 92 a0 67 f1 37 fc 7f 59 62 9d 22 6f bf c4 e0 68 89 49 f6 62 a9 7f 3082 d8 2f be b7 99 71 39 4a 3084 The Responder's sign/verify key pair is the following: 3086 SK_R (Responder's private authentication key) (32 bytes) 3087 df 69 27 4d 71 32 96 e2 46 30 63 65 37 2b 46 83 ce d5 38 1b fc ad cd 44 3088 0a 24 c3 91 d2 fe db 94 3090 PK_R (Responder's public authentication key) (32 bytes) 3091 db d9 dc 8c d0 3f b7 c3 91 35 11 46 2b b2 38 16 47 7c 6b d8 d6 6e f5 a1 3092 a0 70 ac 85 4e d7 3f d2 3094 Since neither the Initiator nor the Responder authenticates with a 3095 static Diffie-Hellman key, PRK_3e2m = PRK_2e 3097 PRK_3e2m (32 bytes) 3098 ec 62 92 a0 67 f1 37 fc 7f 59 62 9d 22 6f bf c4 e0 68 89 49 f6 62 a9 7f 3099 d8 2f be b7 99 71 39 4a 3101 The Responder chooses a connection identifier C_R. 3103 Connection identifier chosen by Responder (1 byte) 3104 00 3106 Note that since C_R is a byte string in the interval h'00' to h'2f', 3107 it is encoded as the corresponding integer subtracted by 24. Thus 3108 0x00 = 0, 0 - 24 = -24, and -24 in CBOR encoding is equal to 0x37. 3110 C_R (1 byte) 3111 37 3113 Data_2 is constructed as the CBOR Sequence of G_Y and C_R, encoded as 3114 CBOR byte strings. The CBOR diagnostic notation is: 3116 data_2 = 3117 ( 3118 h'71a3d599c21da18902a1aea810b2b6382ccd8d5f9bf0195281754c5ebcaf301e', 3119 -24 3120 ) 3122 Which as a CBOR encoded data item is: 3124 data_2 (CBOR Sequence) (35 bytes) 3125 58 20 71 a3 d5 99 c2 1d a1 89 02 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 3126 19 52 81 75 4c 5e bc af 30 1e 37 3128 From data_2 and message_1, compute the input to the transcript hash 3129 TH_2 = H( H(message_1), data_2 ), as a CBOR Sequence of these 2 data 3130 items. 3132 Input to calculate TH_2 (CBOR Sequence) (72 bytes) 3133 01 00 58 20 89 8f f7 9a 02 06 7a 16 ea 1e cc b9 0f a5 22 46 f5 aa 4d d6 3134 ec 07 6b ba 02 59 d9 04 b7 ec 8b 0c 2e 58 20 71 a3 d5 99 c2 1d a1 89 02 3135 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 19 52 81 75 4c 5e bc af 30 1e 37 3137 And from there, compute the transcript hash TH_2 = SHA-256( 3138 H(message_1), data_2 ) 3140 TH_2 (CBOR unencoded) (32 bytes) 3141 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 d3 76 d2 c2 3142 c1 53 c1 7f 8e 96 29 ff 3144 The Responder's subject name is the empty string: 3146 Responder's subject name (text string) 3147 "" 3149 In this version of the test vectors CRED_R is not a DER encoded X.509 3150 certificate, but a string of random bytes. 3152 CRED_R (CBOR unencoded) (100 bytes) 3153 c7 88 37 00 16 b8 96 5b db 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 6e 86 3154 44 2b 87 ec 3f f2 45 b7 0a 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e c9 d6 3155 b0 53 4b 71 c2 b4 9e 4b f9 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 38 1e 3156 98 db 71 41 08 41 5e 5c 50 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 71 be 3157 5c 22 5e b2 3159 CRED_R is defined to be the CBOR bstr containing the credential of 3160 the Responder. 3162 CRED_R (102 bytes) 3163 58 64 c7 88 37 00 16 b8 96 5b db 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 3164 6e 86 44 2b 87 ec 3f f2 45 b7 0a 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e 3165 c9 d6 b0 53 4b 71 c2 b4 9e 4b f9 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 3166 38 1e 98 db 71 41 08 41 5e 5c 50 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 3167 71 be 5c 22 5e b2 3169 And because certificates are identified by a hash value with the 3170 'x5t' parameter, ID_CRED_R is the following: 3172 ID_CRED_R = { 34 : COSE_CertHash }. In this example, the hash 3173 algorithm used is SHA-2 256-bit with hash truncated to 64-bits (value 3174 -15). The hash value is calculated over the CBOR unencoded CRED_R. 3175 The CBOR diagnostic notation is: 3177 ID_CRED_R = 3178 { 3179 34: [-15, h'6844078A53F312F5'] 3180 } 3182 which when encoded as a CBOR map becomes: 3184 ID_CRED_R (14 bytes) 3185 a1 18 22 82 2e 48 68 44 07 8a 53 f3 12 f5 3187 Since no external authorization data is sent: 3189 EAD_2 (0 bytes) 3191 The plaintext is defined as the empty string: 3193 P_2m (0 bytes) 3195 The Enc_structure is defined as follows: [ "Encrypt0", 3196 << ID_CRED_R >>, << TH_2, CRED_R >> ], indicating that ID_CRED_R is 3197 encoded as a CBOR byte string, and that the concatenation of the CBOR 3198 byte strings TH_2 and CRED_R is wrapped as a CBOR bstr. The CBOR 3199 diagnostic notation is the following: 3201 A_2m = 3202 [ 3203 "Encrypt0", 3204 h'A11822822E486844078A53F312F5', 3205 h'5820864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF 3206 5864C788370016B8965BDB2074BFF82E5A20E09BEC21F8406E86442B87EC3FF245B70A 3207 47624DC9CDC6824B2A4C52E95EC9D6B0534B71C2B49E4BF9031500CEE6869979C297BB 3208 5A8B381E98DB714108415E5C50DB78974C271579B01633A3EF6271BE5C225EB2' 3209 ] 3210 Which encodes to the following byte string to be used as Additional 3211 Authenticated Data: 3213 A_2m (CBOR-encoded) (163 bytes) 3214 83 68 45 6e 63 72 79 70 74 30 4e a1 18 22 82 2e 48 68 44 07 8a 53 f3 12 3215 f5 58 88 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 3216 72 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 58 64 c7 88 37 00 16 b8 96 5b db 3217 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 6e 86 44 2b 87 ec 3f f2 45 b7 0a 3218 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e c9 d6 b0 53 4b 71 c2 b4 9e 4b f9 3219 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 38 1e 98 db 71 41 08 41 5e 5c 50 3220 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 71 be 5c 22 5e b2 3222 info for K_2m is defined as follows in CBOR diagnostic notation: 3224 info for K_2m = 3225 [ 3226 10, 3227 h'864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF', 3228 "K_2m", 3229 16 3230 ] 3232 Which as a CBOR encoded data item is: 3234 info for K_2m (CBOR-encoded) (42 bytes) 3235 84 0a 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 3236 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 64 4b 5f 32 6d 10 3238 From these parameters, K_2m is computed. Key K_2m is the output of 3239 HKDF-Expand(PRK_3e2m, info, L), where L is the length of K_2m, so 16 3240 bytes. 3242 K_2m (16 bytes) 3243 80 cc a7 49 ab 58 f5 69 ca 35 da ee 05 be d1 94 3245 info for IV_2m is defined as follows, in CBOR diagnostic notation (10 3246 is the COSE algorithm no. of the AEAD algorithm in the selected 3247 cipher suite 0): 3249 info for IV_2m = 3250 [ 3251 10, 3252 h'864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF', 3253 "IV_2m", 3254 13 3255 ] 3257 Which as a CBOR encoded data item is: 3259 info for IV_2m (CBOR-encoded) (43 bytes) 3260 84 0a 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 3261 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 65 49 56 5f 32 6d 0d 3263 From these parameters, IV_2m is computed. IV_2m is the output of 3264 HKDF-Expand(PRK_3e2m, info, L), where L is the length of IV_2m, so 13 3265 bytes. 3267 IV_2m (13 bytes) 3268 c8 1e 1a 95 cc 93 b3 36 69 6e d5 02 55 3270 Finally, COSE_Encrypt0 is computed from the parameters above. 3272 o protected header = CBOR-encoded ID_CRED_R 3274 o external_aad = A_2m 3276 o empty plaintext = P_2m 3278 MAC_2 (CBOR unencoded) (8 bytes) 3279 fa bb a4 7e 56 71 a1 82 3281 To compute the Signature_or_MAC_2, the key is the private 3282 authentication key of the Responder and the message M_2 to be signed 3283 = [ "Signature1", << ID_CRED_R >>, << TH_2, CRED_R, ? EAD_2 >>, MAC_2 3284 ]. ID_CRED_R is encoded as a CBOR byte string, the concatenation of 3285 the CBOR byte strings TH_2 and CRED_R is wrapped as a CBOR bstr, and 3286 MAC_2 is encoded as a CBOR bstr. 3288 M_2 = 3289 [ 3290 "Signature1", 3291 h'A11822822E486844078A53F312F5', 3292 h'5820864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629F 3293 F5864C788370016B8965BDB2074BFF82E5A20E09BEC21F8406E86442B87EC3FF245B7 3294 0A47624DC9CDC6824B2A4C52E95EC9D6B0534B71C2B49E4BF9031500CEE6869979C29 3295 7BB5A8B381E98DB714108415E5C50DB78974C271579B01633A3EF6271BE5C225EB2', 3296 h'FABBA47E5671A182' 3297 ] 3299 Which as a CBOR encoded data item is: 3301 M_2 (174 bytes) 3302 84 6a 53 69 67 6e 61 74 75 72 65 31 4e a1 18 22 82 2e 48 68 44 07 8a 53 3303 f3 12 f5 58 88 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a 3304 ce 99 72 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 58 64 c7 88 37 00 16 b8 96 3305 5b db 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 6e 86 44 2b 87 ec 3f f2 45 3306 b7 0a 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e c9 d6 b0 53 4b 71 c2 b4 9e 3307 4b f9 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 38 1e 98 db 71 41 08 41 5e 3308 5c 50 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 71 be 5c 22 5e b2 48 fa bb 3309 a4 7e 56 71 a1 82 3311 Since the method = 0, Signature_or_MAC_2 is a signature. The 3312 algorithm with selected cipher suite 0 is Ed25519 and the output is 3313 64 bytes. 3315 Signature_or_MAC_2 (CBOR unencoded) (64 bytes) 3316 1f 17 00 6a 98 48 c9 77 cb bd ca a7 57 b6 fd 46 82 c8 17 39 e1 5c 99 37 3317 c2 1c f5 e9 a0 e6 03 9f 54 fd 2a 6c 3a 11 18 f2 b9 d8 eb cd 48 23 48 b9 3318 9c 3e d7 ed 1b d9 80 6c 93 c8 90 68 e8 36 b4 0f 3320 CIPHERTEXT_2 is the ciphertext resulting from XOR between plaintext 3321 and KEYSTREAM_2 which is derived from TH_2 and the pseudorandom key 3322 PRK_2e. 3324 o plaintext = CBOR Sequence of the items ID_CRED_R and 3325 Signature_or_MAC_2 encoded as CBOR byte strings, in this order 3326 (EAD_2 is empty). 3328 The plaintext is the following: 3330 P_2e (CBOR Sequence) (80 bytes) 3331 a1 18 22 82 2e 48 68 44 07 8a 53 f3 12 f5 58 40 1f 17 00 6a 98 48 c9 77 3332 cb bd ca a7 57 b6 fd 46 82 c8 17 39 e1 5c 99 37 c2 1c f5 e9 a0 e6 03 9f 3333 54 fd 2a 6c 3a 11 18 f2 b9 d8 eb cd 48 23 48 b9 9c 3e d7 ed 1b d9 80 6c 3334 93 c8 90 68 e8 36 b4 0f 3336 KEYSTREAM_2 = HKDF-Expand( PRK_2e, info, length ), where length is 3337 the length of the plaintext, so 80. 3339 info for KEYSTREAM_2 = 3340 [ 3341 10, 3342 h'864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF', 3343 "KEYSTREAM_2", 3344 80 3345 ] 3347 Which as a CBOR encoded data item is: 3349 info for KEYSTREAM_2 (CBOR-encoded) (50 bytes) 3350 84 0a 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 3351 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 6b 4b 45 59 53 54 52 45 41 4d 5f 32 3352 18 50 3354 From there, KEYSTREAM_2 is computed: 3356 KEYSTREAM_2 (80 bytes) 3357 ae ea 8e af 50 cf c6 70 09 da e8 2d 8d 85 b0 e7 60 91 bf 0f 07 0b 79 53 3358 6c 83 23 dc 3d 9d 61 13 10 35 94 63 f4 4b 12 4b ea b3 a1 9d 09 93 82 d7 3359 30 80 17 f4 92 62 06 e4 f5 44 9b 9f c9 24 bc b6 bd 78 ec 45 0a 66 83 fb 3360 8a 2f 5f 92 4f c4 40 4f 3362 Using the parameters above, the ciphertext CIPHERTEXT_2 can be 3363 computed: 3365 CIPHERTEXT_2 (CBOR unencoded) (80 bytes) 3366 0f f2 ac 2d 7e 87 ae 34 0e 50 bb de 9f 70 e8 a7 7f 86 bf 65 9f 43 b0 24 3367 a7 3e e9 7b 6a 2b 9c 55 92 fd 83 5a 15 17 8b 7c 28 af 54 74 a9 75 81 48 3368 64 7d 3d 98 a8 73 1e 16 4c 9c 70 52 81 07 f4 0f 21 46 3b a8 11 bf 03 97 3369 19 e7 cf fa a7 f2 f4 40 3371 message_2 is the CBOR Sequence of data_2 and CIPHERTEXT_2, in this 3372 order: 3374 message_2 = 3375 ( 3376 data_2, 3377 h'0FF2AC2D7E87AE340E50BBDE9F70E8A77F86BF659F43B024A73EE97B6A2B9C5592FD 3378 835A15178B7C28AF5474A9758148647D3D98A8731E164C9C70528107F40F21463BA811 3379 BF039719E7CFFAA7F2F440' 3380 ) 3382 Which as a CBOR encoded data item is: 3384 message_2 (CBOR Sequence) (117 bytes) 3385 58 20 71 a3 d5 99 c2 1d a1 89 02 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 3386 19 52 81 75 4c 5e bc af 30 1e 37 58 50 0f f2 ac 2d 7e 87 ae 34 0e 50 bb 3387 de 9f 70 e8 a7 7f 86 bf 65 9f 43 b0 24 a7 3e e9 7b 6a 2b 9c 55 92 fd 83 3388 5a 15 17 8b 7c 28 af 54 74 a9 75 81 48 64 7d 3d 98 a8 73 1e 16 4c 9c 70 3389 52 81 07 f4 0f 21 46 3b a8 11 bf 03 97 19 e7 cf fa a7 f2 f4 40 3391 D.1.3. Message_3 3393 Since corr equals 1, C_R is not omitted from data_3. 3395 The Initiator's sign/verify key pair is the following: 3397 SK_I (Initiator's private authentication key) (32 bytes) 3398 2f fc e7 a0 b2 b8 25 d3 97 d0 cb 54 f7 46 e3 da 3f 27 59 6e e0 6b 53 71 3399 48 1d c0 e0 12 bc 34 d7 3401 PK_I (Responder's public authentication key) (32 bytes) 3402 38 e5 d5 45 63 c2 b6 a4 ba 26 f3 01 5f 61 bb 70 6e 5c 2e fd b5 56 d2 e1 3403 69 0b 97 fc 3c 6d e1 49 3405 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 3407 PRK_4x3m = HMAC-SHA-256 (PRK_3e2m, G_IY) 3409 PRK_4x3m (32 bytes) 3410 ec 62 92 a0 67 f1 37 fc 7f 59 62 9d 22 6f bf c4 e0 68 89 49 f6 62 a9 7f 3411 d8 2f be b7 99 71 39 4a 3413 data 3 is equal to C_R. 3415 data_3 (CBOR Sequence) (1 byte) 3416 37 3418 From data_3, CIPHERTEXT_2, and TH_2, compute the input to the 3419 transcript hash TH_3 = H( H(TH_2 , CIPHERTEXT_2), data_3), as a CBOR 3420 Sequence of 2 data items. 3422 Input to calculate TH_3 (CBOR Sequence) (117 bytes) 3423 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 d3 76 3424 d2 c2 c1 53 c1 7f 8e 96 29 ff 58 50 0f f2 ac 2d 7e 87 ae 34 0e 50 bb de 3425 9f 70 e8 a7 7f 86 bf 65 9f 43 b0 24 a7 3e e9 7b 6a 2b 9c 55 92 fd 83 5a 3426 15 17 8b 7c 28 af 54 74 a9 75 81 48 64 7d 3d 98 a8 73 1e 16 4c 9c 70 52 3427 81 07 f4 0f 21 46 3b a8 11 bf 03 97 19 e7 cf fa a7 f2 f4 40 37 3429 And from there, compute the transcript hash TH_3 = SHA-256( H(TH_2 , 3430 CIPHERTEXT_2), data_3) 3432 TH_3 (CBOR unencoded) (32 bytes) 3433 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 65 0c 30 70 3434 b6 f5 1e 68 e2 ae bb 60 3436 The Initiator's subject name is the empty string: 3438 Initiator's subject name (text string) 3439 "" 3441 In this version of the test vectors CRED_I is not a DER encoded X.509 3442 certificate, but a string of random bytes. 3444 CRED_I (CBOR unencoded) (101 bytes) 3445 54 13 20 4c 3e bc 34 28 a6 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 7e c6 3446 56 1e 52 43 3a a5 5e 71 f1 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 76 60 3447 88 09 84 49 cb 84 8f fc 79 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 67 5e 3448 8f 6c 77 a4 a2 c3 01 95 60 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 48 65 3449 02 ff 7b dd a6 3451 CRED_I is defined to be the CBOR bstr containing the credential of 3452 the Initiator. 3454 CRED_I (103 bytes) 3455 58 65 54 13 20 4c 3e bc 34 28 a6 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 3456 7e c6 56 1e 52 43 3a a5 5e 71 f1 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 3457 76 60 88 09 84 49 cb 84 8f fc 79 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 3458 67 5e 8f 6c 77 a4 a2 c3 01 95 60 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 3459 48 65 02 ff 7b dd a6 3461 And because certificates are identified by a hash value with the 3462 'x5t' parameter, ID_CRED_I is the following: 3464 ID_CRED_I = { 34 : COSE_CertHash }. In this example, the hash 3465 algorithm used is SHA-2 256-bit with hash truncated to 64-bits (value 3466 -15). The hash value is calculated over the CBOR unencoded CRED_I. 3468 ID_CRED_I = 3469 { 3470 34: [-15, h'705D5845F36FC6A6'] 3471 } 3473 which when encoded as a CBOR map becomes: 3475 ID_CRED_I (14 bytes) 3476 a1 18 22 82 2e 48 70 5d 58 45 f3 6f c6 a6 3478 Since no external authorization data is exchanged: 3480 EAD_3 (0 bytes) 3482 The plaintext of the COSE_Encrypt is the empty string: 3484 P_3m (0 bytes) 3486 The associated data is the following: [ "Encrypt0", << ID_CRED_I >>, 3487 << TH_3, CRED_I, ? EAD_3 >> ]. 3489 A_3m (CBOR-encoded) (164 bytes) 3490 83 68 45 6e 63 72 79 70 74 30 4e a1 18 22 82 2e 48 70 5d 58 45 f3 6f c6 3491 a6 58 89 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 3492 0f 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 58 65 54 13 20 4c 3e bc 34 28 a6 3493 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 7e c6 56 1e 52 43 3a a5 5e 71 f1 3494 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 76 60 88 09 84 49 cb 84 8f fc 79 3495 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 67 5e 8f 6c 77 a4 a2 c3 01 95 60 3496 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 48 65 02 ff 7b dd a6 3498 Info for K_3m is computed as follows: 3500 info for K_3m = 3501 [ 3502 10, 3503 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3504 "K_3m", 3505 16 3506 ] 3508 Which as a CBOR encoded data item is: 3510 info for K_3m (CBOR-encoded) (42 bytes) 3511 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3512 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 64 4b 5f 33 6d 10 3514 From these parameters, K_3m is computed. Key K_3m is the output of 3515 HKDF-Expand(PRK_4x3m, info, L), where L is the length of K_2m, so 16 3516 bytes. 3518 K_3m (16 bytes) 3519 83 a9 c3 88 02 91 2e 7f 8f 0d 2b 84 14 d1 e5 2c 3521 Nonce IV_3m is the output of HKDF-Expand(PRK_4x3m, info, L), where L 3522 = 13 bytes. 3524 Info for IV_3m is defined as follows: 3526 info for IV_3m = 3527 [ 3528 10, 3529 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3530 "IV_3m", 3531 13 3532 ] 3534 Which as a CBOR encoded data item is: 3536 info for IV_3m (CBOR-encoded) (43 bytes) 3537 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3538 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 65 49 56 5f 33 6d 0d 3540 From these parameters, IV_3m is computed: 3542 IV_3m (13 bytes) 3543 9c 83 9c 0e e8 36 42 50 5a 8e 1c 9f b2 3545 MAC_3 is the 'ciphertext' of the COSE_Encrypt0: 3547 MAC_3 (CBOR unencoded) (8 bytes) 3548 2f a1 e3 9e ae 7d 5f 8d 3550 Since the method = 0, Signature_or_MAC_3 is a signature. The 3551 algorithm with selected cipher suite 0 is Ed25519. 3553 o The message M_3 to be signed = [ "Signature1", << ID_CRED_I >>, 3554 << TH_3, CRED_I >>, MAC_3 ], i.e. ID_CRED_I encoded as CBOR bstr, 3555 the concatenation of the CBOR byte strings TH_3 and CRED_I wrapped 3556 as a CBOR bstr, and MAC_3 encoded as a CBOR bstr. 3558 o The signing key is the private authentication key of the 3559 Initiator. 3561 M_3 = 3562 [ 3563 "Signature1", 3564 h'A11822822E48705D5845F36FC6A6', 3565 h'5820F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB6 3566 058655413204C3EBC3428A6CF57E24C9DEF59651770449BCE7EC6561E52433AA55E71 3567 F1FA34B22A9CA4A1E12924EAE1D1766088098449CB848FFC795F88AFC49CBE8AFDD1B 3568 A009F21675E8F6C77A4A2C30195601F6F0A0852978BD43D28207D44486502FF7BDD 3569 A6', 3570 h'2FA1E39EAE7D5F8D'] 3572 Which as a CBOR encoded data item is: 3574 M_3 (175 bytes) 3575 84 6a 53 69 67 6e 61 74 75 72 65 31 4e a1 18 22 82 2e 48 70 5d 58 45 f3 3576 6f c6 a6 58 89 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 3577 9c 7c 0f 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 58 65 54 13 20 4c 3e bc 34 3578 28 a6 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 7e c6 56 1e 52 43 3a a5 5e 3579 71 f1 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 76 60 88 09 84 49 cb 84 8f 3580 fc 79 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 67 5e 8f 6c 77 a4 a2 c3 01 3581 95 60 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 48 65 02 ff 7b dd a6 48 2f 3582 a1 e3 9e ae 7d 5f 8d 3583 From there, the 64 byte signature can be computed: 3585 Signature_or_MAC_3 (CBOR unencoded) (64 bytes) 3586 ab 9f 7b bd eb c4 eb f8 a3 d3 04 17 9b cc a3 9d 9c 8a 76 73 65 76 fb 3c 3587 32 d2 fa c7 e2 59 34 e5 33 dc c7 02 2e 4d 68 61 c8 f5 fe cb e9 2d 17 4e 3588 b2 be af 0a 59 a4 15 84 37 2f 43 2e 6b f4 7b 04 3590 Finally, the outer COSE_Encrypt0 is computed. 3592 The plaintext is the CBOR Sequence of the items ID_CRED_I and the 3593 CBOR encoded Signature_or_MAC_3, in this order (EAD_3 is empty). 3595 P_3ae (CBOR Sequence) (80 bytes) 3596 a1 18 22 82 2e 48 70 5d 58 45 f3 6f c6 a6 58 40 ab 9f 7b bd eb c4 eb f8 3597 a3 d3 04 17 9b cc a3 9d 9c 8a 76 73 65 76 fb 3c 32 d2 fa c7 e2 59 34 e5 3598 33 dc c7 02 2e 4d 68 61 c8 f5 fe cb e9 2d 17 4e b2 be af 0a 59 a4 15 84 3599 37 2f 43 2e 6b f4 7b 04 3601 The Associated data A is the following: Associated data A = [ 3602 "Encrypt0", h'', TH_3 ] 3604 A_3ae (CBOR-encoded) (45 bytes) 3605 83 68 45 6e 63 72 79 70 74 30 40 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 3606 29 c1 52 ab 3a ea 9c 7c 0f 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 3608 Key K_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 3610 info is defined as follows: 3612 info for K_3ae = 3613 [ 3614 10, 3615 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3616 "K_3ae", 3617 16 3618 ] 3620 Which as a CBOR encoded data item is: 3622 info for K_3ae (CBOR-encoded) (43 bytes) 3623 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3624 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 65 4b 5f 33 61 65 10 3626 L is the length of K_3ae, so 16 bytes. 3628 From these parameters, K_3ae is computed: 3630 K_3ae (16 bytes) 3631 b8 79 9f e3 d1 50 4f d8 eb 22 c4 72 62 cd bb 05 3633 Nonce IV_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 3635 info is defined as follows: 3637 info for IV_3ae = 3638 [ 3639 10, 3640 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3641 "IV_3ae", 3642 13 3643 ] 3645 Which as a CBOR encoded data item is: 3647 info for IV_3ae (CBOR-encoded) (44 bytes) 3648 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3649 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 66 49 56 5f 33 61 65 0d 3651 L is the length of IV_3ae, so 13 bytes. 3653 From these parameters, IV_3ae is computed: 3655 IV_3ae (13 bytes) 3656 74 c7 de 41 b8 4a 5b b7 19 0a 85 98 dc 3658 Using the parameters above, the 'ciphertext' CIPHERTEXT_3 can be 3659 computed: 3661 CIPHERTEXT_3 (CBOR unencoded) (88 bytes) 3662 f5 f6 de bd 82 14 05 1c d5 83 c8 40 96 c4 80 1d eb f3 5b 15 36 3d d1 6e 3663 bd 85 30 df dc fb 34 fc d2 eb 6c ad 1d ac 66 a4 79 fb 38 de aa f1 d3 0a 3664 7e 68 17 a2 2a b0 4f 3d 5b 1e 97 2a 0d 13 ea 86 c6 6b 60 51 4c 96 57 ea 3665 89 c5 7b 04 01 ed c5 aa 8b bc ab 81 3c c5 d6 e7 3667 From the parameter above, message_3 is computed, as the CBOR Sequence 3668 of the following CBOR encoded data items: (C_R, CIPHERTEXT_3). 3670 message_3 = 3671 ( 3672 -24, 3673 h'F5F6DEBD8214051CD583C84096C4801DEBF35B15363DD16EBD8530DFDCFB34FCD2EB 3674 6CAD1DAC66A479FB38DEAAF1D30A7E6817A22AB04F3D5B1E972A0D13EA86C66B60514C 3675 9657EA89C57B0401EDC5AA8BBCAB813CC5D6E7' 3676 ) 3677 Which encodes to the following byte string: 3679 message_3 (CBOR Sequence) (91 bytes) 3680 37 58 58 f5 f6 de bd 82 14 05 1c d5 83 c8 40 96 c4 80 1d eb f3 5b 15 36 3681 3d d1 6e bd 85 30 df dc fb 34 fc d2 eb 6c ad 1d ac 66 a4 79 fb 38 de aa 3682 f1 d3 0a 7e 68 17 a2 2a b0 4f 3d 5b 1e 97 2a 0d 13 ea 86 c6 6b 60 51 4c 3683 96 57 ea 89 c5 7b 04 01 ed c5 aa 8b bc ab 81 3c c5 d6 e7 3685 D.1.4. OSCORE Security Context Derivation 3687 From here, the Initiator and the Responder can derive an OSCORE 3688 Security Context, using the EDHOC-Exporter interface. 3690 From TH_3 and CIPHERTEXT_3, compute the input to the transcript hash 3691 TH_4 = H( TH_3, CIPHERTEXT_3 ), as a CBOR Sequence of these 2 data 3692 items. 3694 Input to calculate TH_4 (CBOR Sequence) (124 bytes) 3695 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 65 0c 3696 30 70 b6 f5 1e 68 e2 ae bb 60 58 58 f5 f6 de bd 82 14 05 1c d5 83 c8 40 3697 96 c4 80 1d eb f3 5b 15 36 3d d1 6e bd 85 30 df dc fb 34 fc d2 eb 6c ad 3698 1d ac 66 a4 79 fb 38 de aa f1 d3 0a 7e 68 17 a2 2a b0 4f 3d 5b 1e 97 2a 3699 0d 13 ea 86 c6 6b 60 51 4c 96 57 ea 89 c5 7b 04 01 ed c5 aa 8b bc ab 81 3700 3c c5 d6 e7 3702 And from there, compute the transcript hash TH_4 = SHA-256(TH_3 , 3703 CIPHERTEXT_4) 3705 TH_4 (CBOR unencoded) (32 bytes) 3706 3b 69 a6 7f ec 7e 73 6c c1 a9 52 6c da 00 02 d4 09 f5 b9 ea 0a 2b e9 60 3707 51 a6 e3 0d 93 05 fd 51 3709 The Master Secret and Master Salt are derived as follows: 3711 Master Secret = EDHOC-Exporter( "OSCORE Master Secret", 16 ) = EDHOC- 3712 KDF(PRK_4x3m, TH_4, "OSCORE Master Secret", 16) = HKDF-Expand( 3713 PRK_4x3m, info_ms, 16 ) 3715 Master Salt = EDHOC-Exporter( "OSCORE Master Salt", 8 ) = EDHOC- 3716 KDF(PRK_4x3m, TH_4, "OSCORE Master Salt", 8) = HKDF-Expand( PRK_4x3m, 3717 info_salt, 8 ) 3719 info_ms for OSCORE Master Secret is defined as follows: 3721 info_ms = [ 3722 10, 3723 h'3B69A67FEC7E736CC1A9526CDA0002D409F5B9EA0A2BE96051A6E30D9305FD51', 3724 "OSCORE Master Secret", 3725 16 3726 ] 3728 Which as a CBOR encoded data item is: 3730 info_ms for OSCORE Master Secret (CBOR-encoded) (58 bytes) 3731 84 0a 58 20 3b 69 a6 7f ec 7e 73 6c c1 a9 52 6c da 00 02 d4 09 f5 b9 ea 3732 0a 2b e9 60 51 a6 e3 0d 93 05 fd 51 74 4f 53 43 4f 52 45 20 4d 61 73 74 3733 65 72 20 53 65 63 72 65 74 10 3735 info_salt for OSCORE Master Salt is defined as follows: 3737 info_salt = [ 3738 10, 3739 h'3B69A67FEC7E736CC1A9526CDA0002D409F5B9EA0A2BE96051A6E30D9305FD51', 3740 "OSCORE Master Salt", 3741 8 3742 ] 3744 Which as a CBOR encoded data item is: 3746 info for OSCORE Master Salt (CBOR-encoded) (56 Bytes) 3747 84 0a 58 20 3b 69 a6 7f ec 7e 73 6c c1 a9 52 6c da 00 02 d4 09 f5 b9 ea 3748 0a 2b e9 60 51 a6 e3 0d 93 05 fd 51 72 4f 53 43 4f 52 45 20 4d 61 73 74 3749 65 72 20 53 61 6c 74 08 3751 From these parameters, OSCORE Master Secret and OSCORE Master Salt 3752 are computed: 3754 OSCORE Master Secret (16 bytes) 3755 96 aa 88 ce 86 5e ba 1f fa f3 89 64 13 2c c4 42 3757 OSCORE Master Salt (8 bytes) 3758 5e c3 ee 41 7c fb ba e9 3760 The client's OSCORE Sender ID is C_R and the server's OSCORE Sender 3761 ID is C_I. 3763 Client's OSCORE Sender ID (1 byte) 3764 00 3766 Server's OSCORE Sender ID (1 byte) 3767 09 3768 The AEAD Algorithm and the hash algorithm are the application AEAD 3769 and hash algorithms in the selected cipher suite. 3771 OSCORE AEAD Algorithm (int) 3772 10 3774 OSCORE Hash Algorithm (int) 3775 -16 3777 D.2. Test Vectors for EDHOC Authenticated with Static Diffie-Hellman 3778 Keys 3780 EDHOC with static Diffie-Hellman keys and raw public keys is used. 3781 In this test vector, a key identifier is used to identify the raw 3782 public key. The optional C_1 in message_1 is omitted. No external 3783 authorization data is sent in the message exchange. 3785 method (Static DH Based Authentication) 3786 3 3788 CoAP is used as transport and the Initiator acts as CoAP client: 3790 corr (the Initiator can correlate message_1 and message_2) 3791 1 3793 From there, METHOD_CORR has the following value: 3795 METHOD_CORR (4 * method + corr) (int) 3796 13 3798 The Initiator indicates only one cipher suite in the (potentially 3799 truncated) list of cipher suites. 3801 Supported Cipher Suites (1 byte) 3802 00 3804 The Initiator selected the indicated cipher suite. 3806 Selected Cipher Suite (int) 3807 0 3809 Cipher suite 0 is supported by both the Initiator and the Responder, 3810 see Section 3.6. 3812 D.2.1. Message_1 3814 The Initiator generates its ephemeral key pair. 3816 X (Initiator's ephemeral private key) (32 bytes) 3817 ae 11 a0 db 86 3c 02 27 e5 39 92 fe b8 f5 92 4c 50 d0 a7 ba 6e ea b4 ad 3818 1f f2 45 72 f4 f5 7c fa 3820 G_X (Initiator's ephemeral public key, CBOR unencoded) (32 bytes) 3821 8d 3e f5 6d 1b 75 0a 43 51 d6 8a c2 50 a0 e8 83 79 0e fc 80 a5 38 a4 44 3822 ee 9e 2b 57 e2 44 1a 7c 3824 The Initiator chooses a connection identifier C_I: 3826 Connection identifier chosen by Initiator (1 byte) 3827 16 3829 Note that since C_I is a byte string in the interval h'00' to h'2f', 3830 it is encoded as the corresponding integer - 24, i.e. 0x16 = 22, 22 - 3831 24 = -2, and -2 in CBOR encoding is equal to 0x21. 3833 C_I (1 byte) 3834 21 3836 Since no external authorization data is sent: 3838 EAD_1 (0 bytes) 3840 Since the list of supported cipher suites needs to contain the 3841 selected cipher suite, the initiator truncates the list of supported 3842 cipher suites to one cipher suite only, 00. 3844 Because one single selected cipher suite is conveyed, it is encoded 3845 as an int instead of an array: 3847 SUITES_I (int) 3848 0 3850 message_1 is constructed as the CBOR Sequence of the data items above 3851 encoded as CBOR. In CBOR diagnostic notation: 3853 message_1 = 3854 ( 3855 13, 3856 0, 3857 h'8D3EF56D1B750A4351D68AC250A0E883790EFC80A538A444EE9E2B57E2441A7C', 3858 -2 3859 ) 3860 Which as a CBOR encoded data item is: 3862 message_1 (CBOR Sequence) (37 bytes) 3863 0d 00 58 20 8d 3e f5 6d 1b 75 0a 43 51 d6 8a c2 50 a0 e8 83 79 0e fc 80 3864 a5 38 a4 44 ee 9e 2b 57 e2 44 1a 7c 21 3866 D.2.2. Message_2 3868 Since METHOD_CORR mod 4 equals 1, C_I is omitted from data_2. 3870 The Responder generates the following ephemeral key pair. 3872 Y (Responder's ephemeral private key) (32 bytes) 3873 c6 46 cd dc 58 12 6e 18 10 5f 01 ce 35 05 6e 5e bc 35 f4 d4 cc 51 07 49 3874 a3 a5 e0 69 c1 16 16 9a 3876 G_Y (Responder's ephemeral public key, CBOR unencoded) (32 bytes) 3877 52 fb a0 bd c8 d9 53 dd 86 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db fc 33 3878 01 04 70 69 45 1b af 35 3880 From G_X and Y or from G_Y and X the ECDH shared secret is computed: 3882 G_XY (ECDH shared secret) (32 bytes) 3883 de fc 2f 35 69 10 9b 3d 1f a4 a7 3d c5 e2 fe b9 e1 15 0d 90 c2 5e e2 f0 3884 66 c2 d8 85 f4 f8 ac 4e 3886 The key and nonce for calculating the 'ciphertext' are calculated as 3887 follows, as specified in Section 4. 3889 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 3891 PRK_2e = HMAC-SHA-256(salt, G_XY) 3893 Salt is the empty byte string. 3895 salt (0 bytes) 3897 From there, PRK_2e is computed: 3899 PRK_2e (32 bytes) 3900 93 9f cb 05 6d 2e 41 4f 1b ec 61 04 61 99 c2 c7 63 d2 7f 0c 3d 15 fa 16 3901 71 fa 13 4e 0d c5 a0 4d 3903 The Responder's static Diffie-Hellman key pair is the following: 3905 R (Responder's private authentication key) (32 bytes) 3906 bb 50 1a ac 67 b9 a9 5f 97 e0 ed ed 6b 82 a6 62 93 4f bb fc 7a d1 b7 4c 3907 1f ca d6 6a 07 94 22 d0 3908 G_R (Responder's public authentication key) (32 bytes) 3909 a3 ff 26 35 95 be b3 77 d1 a0 ce 1d 04 da d2 d4 09 66 ac 6b cb 62 20 51 3910 b8 46 59 18 4d 5d 9a 32 3912 Since the Responder authenticates with a static Diffie-Hellman key, 3913 PRK_3e2m = HKDF-Extract( PRK_2e, G_RX ), where G_RX is the ECDH 3914 shared secret calculated from G_R and X, or G_X and R. 3916 From the Responder's authentication key and the Initiator's ephemeral 3917 key (see Appendix D.2.1), the ECDH shared secret G_RX is calculated. 3919 G_RX (ECDH shared secret) (32 bytes) 3920 21 c7 ef f4 fb 69 fa 4b 67 97 d0 58 84 31 5d 84 11 a3 fd a5 4f 6d ad a6 3921 1d 4f cd 85 e7 90 66 68 3923 PRK_3e2m (32 bytes) 3924 75 07 7c 69 1e 35 01 2d 48 bc 24 c8 4f 2b ab 89 f5 2f ac 03 fe dd 81 3e 3925 43 8c 93 b1 0b 39 93 07 3927 The Responder chooses a connection identifier C_R. 3929 Connection identifier chosen by Responder (1 byte) 3930 00 3932 Note that since C_R is a byte string in the interval h'00' to h'2f', 3933 it is encoded as the corresponding integer - 24, i.e. 0x00 = 0, 0 - 3934 24 = -24, and -24 in CBOR encoding is equal to 0x37. 3936 C_R (1 byte) 3937 37 3939 Data_2 is constructed as the CBOR Sequence of G_Y and C_R. 3941 data_2 = 3942 ( 3943 h'52FBA0BDC8D953DD86CE1AB2FD7C05A4658C7C30AFDBFC3301047069451BAF35', 3944 -24 3945 ) 3947 Which as a CBOR encoded data item is: 3949 data_2 (CBOR Sequence) (35 bytes) 3950 58 20 52 fb a0 bd c8 d9 53 dd 86 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db 3951 fc 33 01 04 70 69 45 1b af 35 37 3953 From data_2 and message_1, compute the input to the transcript hash 3954 TH_2 = H( H(message_1), data_2 ), as a CBOR Sequence of these 2 data 3955 items. 3957 Input to calculate TH_2 (CBOR Sequence) (72 bytes) 3958 0d 00 58 20 8d 3e f5 6d 1b 75 0a 43 51 d6 8a c2 50 a0 e8 83 79 0e fc 80 3959 a5 38 a4 44 ee 9e 2b 57 e2 44 1a 7c 21 58 20 52 fb a0 bd c8 d9 53 dd 86 3960 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db fc 33 01 04 70 69 45 1b af 35 37 3962 And from there, compute the transcript hash TH_2 = SHA-256( 3963 H(message_1), data_2 ) 3965 TH_2 (CBOR unencoded) (32 bytes) 3966 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 36 d0 cf 8c 3967 73 a6 e8 a7 c3 62 1e 26 3969 The Responder's subject name is the empty string: 3971 Responder's subject name (text string) 3972 "" 3974 ID_CRED_R is the following: 3976 ID_CRED_R = 3977 { 3978 4: h'05' 3979 } 3981 ID_CRED_R (4 bytes) 3982 a1 04 41 05 3984 CRED_R is the following COSE_Key: 3986 { 3987 1: 1, 3988 -1: 4, 3989 -2: h'A3FF263595BEB377D1A0CE1D04DAD2D40966AC6BCB622051B84659184D5D9A32, 3990 "subject name": "" 3991 } 3993 Which encodes to the following byte string: 3995 CRED_R (54 bytes) 3996 a4 01 01 20 04 21 58 20 a3 ff 26 35 95 be b3 77 d1 a0 ce 1d 04 da d2 d4 3997 09 66 ac 6b cb 62 20 51 b8 46 59 18 4d 5d 9a 32 6c 73 75 62 6a 65 63 74 3998 20 6e 61 6d 65 60 4000 Since no external authorization data is sent: 4002 EAD_2 (0 bytes) 4004 The plaintext is defined as the empty string: 4006 P_2m (0 bytes) 4008 The Enc_structure is defined as follows: [ "Encrypt0", 4009 << ID_CRED_R >>, << TH_2, CRED_R >> ], so ID_CRED_R is encoded as a 4010 CBOR bstr, and the concatenation of the CBOR byte strings TH_2 and 4011 CRED_R is wrapped in a CBOR bstr. 4013 A_2m = 4014 [ 4015 "Encrypt0", 4016 h'A1044105', 4017 h'5820DECFD64A3667640A0233B04AA8AA91F68956B8A536D0CF8C73A6E8A7C3621E2 4018 6A401012004215820A3FF263595BEB377D1A0CE1D04DAD2D40966AC6BCB622051B846 4019 59184D5D9A326C7375626A656374206E616D6560' 4020 ] 4022 Which encodes to the following byte string to be used as Additional 4023 Authenticated Data: 4025 A_2m (CBOR-encoded) (105 bytes) 4026 83 68 45 6e 63 72 79 70 74 30 44 a1 04 41 05 58 58 58 20 de cf d6 4a 36 4027 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 36 d0 cf 8c 73 a6 e8 a7 c3 4028 62 1e 26 a4 01 01 20 04 21 58 20 a3 ff 26 35 95 be b3 77 d1 a0 ce 1d 04 4029 da d2 d4 09 66 ac 6b cb 62 20 51 b8 46 59 18 4d 5d 9a 32 6c 73 75 62 6a 4030 65 63 74 20 6e 61 6d 65 60 4032 info for K_2m is defined as follows: 4034 info for K_2m = 4035 [ 4036 10, 4037 h'DECFD64A3667640A0233B04AA8AA91F68956B8A536D0CF8C73A6E8A7C3621E26', 4038 "K_2m", 4039 16 4040 ] 4042 Which as a CBOR encoded data item is: 4044 info for K_2m (CBOR-encoded) (42 bytes) 4045 84 0a 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 4046 36 d0 cf 8c 73 a6 e8 a7 c3 62 1e 26 64 4b 5f 32 6d 10 4048 From these parameters, K_2m is computed. Key K_2m is the output of 4049 HKDF-Expand(PRK_3e2m, info, L), where L is the length of K_2m, so 16 4050 bytes. 4052 K_2m (16 bytes) 4053 4e cd ef ba d8 06 81 8b 62 51 b9 d7 86 78 bc 76 4054 info for IV_2m is defined as follows: 4056 info for IV_2m = 4057 [ 4058 10, 4059 h'A51C76463E8AE58FD3B8DC5EDE1E27143CC92D223EACD9E5FF6E3FAC876658A5', 4060 "IV_2m", 4061 13 4062 ] 4064 Which as a CBOR encoded data item is: 4066 info for IV_2m (CBOR-encoded) (43 bytes) 4067 84 0a 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 4068 36 d0 cf 8c 73 a6 e8 a7 c3 62 1e 26 65 49 56 5f 32 6d 0d 4070 From these parameters, IV_2m is computed. IV_2m is the output of 4071 HKDF-Expand(PRK_3e2m, info, L), where L is the length of IV_2m, so 13 4072 bytes. 4074 IV_2m (13 bytes) 4075 e9 b8 e4 b1 bd 02 f4 9a 82 0d d3 53 4f 4077 Finally, COSE_Encrypt0 is computed from the parameters above. 4079 o protected header = CBOR-encoded ID_CRED_R 4081 o external_aad = A_2m 4083 o empty plaintext = P_2m 4085 MAC_2 is the 'ciphertext' of the COSE_Encrypt0 with empty plaintext. 4086 In case of cipher suite 0 the AEAD is AES-CCM truncated to 8 bytes: 4088 MAC_2 (CBOR unencoded) (8 bytes) 4089 42 e7 99 78 43 1e 6b 8f 4091 Since method = 2, Signature_or_MAC_2 is MAC_2: 4093 Signature_or_MAC_2 (CBOR unencoded) (8 bytes) 4094 42 e7 99 78 43 1e 6b 8f 4096 CIPHERTEXT_2 is the ciphertext resulting from XOR between plaintext 4097 and KEYSTREAM_2 which is derived from TH_2 and the pseudorandom key 4098 PRK_2e. 4100 The plaintext is the CBOR Sequence of the items ID_CRED_R and the 4101 CBOR encoded Signature_or_MAC_2, in this order (EAD_2 is empty). 4103 Note that since ID_CRED_R contains a single 'kid' parameter, i.e., 4104 ID_CRED_R = { 4 : kid_R }, only the byte string kid_R is conveyed in 4105 the plaintext encoded as a bstr_identifier. kid_R is encoded as the 4106 corresponding integer - 24, i.e. 0x05 = 5, 5 - 24 = -19, and -19 in 4107 CBOR encoding is equal to 0x32. 4109 The plaintext is the following: 4111 P_2e (CBOR Sequence) (10 bytes) 4112 32 48 42 e7 99 78 43 1e 6b 8f 4114 KEYSTREAM_2 = HKDF-Expand( PRK_2e, info, length ), where length is 4115 the length of the plaintext, so 10. 4117 info for KEYSTREAM_2 = 4118 [ 4119 10, 4120 h'DECFD64A3667640A0233B04AA8AA91F68956B8A536D0CF8C73A6E8A7C3621E26', 4121 "KEYSTREAM_2", 4122 10 4123 ] 4125 Which as a CBOR encoded data item is: 4127 info for KEYSTREAM_2 (CBOR-encoded) (49 bytes) 4128 84 0a 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 4129 36 d0 cf 8c 73 a6 e8 a7 c3 62 1e 26 6b 4b 45 59 53 54 52 45 41 4d 5f 32 4130 0a 4132 From there, KEYSTREAM_2 is computed: 4134 KEYSTREAM_2 (10 bytes) 4135 91 b9 ff ba 9b f5 5a d1 57 16 4137 Using the parameters above, the ciphertext CIPHERTEXT_2 can be 4138 computed: 4140 CIPHERTEXT_2 (CBOR unencoded) (10 bytes) 4141 a3 f1 bd 5d 02 8d 19 cf 3c 99 4143 message_2 is the CBOR Sequence of data_2 and CIPHERTEXT_2, in this 4144 order: 4146 message_2 = 4147 ( 4148 data_2, 4149 h'A3F1BD5D028D19CF3C99' 4150 ) 4151 Which as a CBOR encoded data item is: 4153 message_2 (CBOR Sequence) (46 bytes) 4154 58 20 52 fb a0 bd c8 d9 53 dd 86 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db 4155 fc 33 01 04 70 69 45 1b af 35 37 4a a3 f1 bd 5d 02 8d 19 cf 3c 99 4157 D.2.3. Message_3 4159 Since corr equals 1, C_R is not omitted from data_3. 4161 The Initiator's static Diffie-Hellman key pair is the following: 4163 I (Initiator's private authentication key) (32 bytes) 4164 2b be a6 55 c2 33 71 c3 29 cf bd 3b 1f 02 c6 c0 62 03 38 37 b8 b5 90 99 4165 a4 43 6f 66 60 81 b0 8e 4167 G_I (Initiator's public authentication key, CBOR unencoded) (32 bytes) 4168 2c 44 0c c1 21 f8 d7 f2 4c 3b 0e 41 ae da fe 9c aa 4f 4e 7a bb 83 5e c3 4169 0f 1d e8 8a db 96 ff 71 4171 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 4173 From the Initiator's authentication key and the Responder's ephemeral 4174 key (see Appendix D.2.2), the ECDH shared secret G_IY is calculated. 4176 G_IY (ECDH shared secret) (32 bytes) 4177 cb ff 8c d3 4a 81 df ec 4c b6 5d 9a 57 2e bd 09 64 45 0c 78 56 3d a4 98 4178 1d 80 d3 6c 8b 1a 75 2a 4180 PRK_4x3m = HMAC-SHA-256 (PRK_3e2m, G_IY). 4182 PRK_4x3m (32 bytes) 4183 02 56 2f 1f 01 78 5c 0a a5 f5 94 64 0c 49 cb f6 9f 72 2e 9e 6c 57 83 7d 4184 8e 15 79 ec 45 fe 64 7a 4186 data 3 is equal to C_R. 4188 data_3 (CBOR Sequence) (1 byte) 4189 37 4191 From data_3, CIPHERTEXT_2, and TH_2, compute the input to the 4192 transcript hash TH_3 = H( H(TH_2 , CIPHERTEXT_2), data_3), as a CBOR 4193 Sequence of these 2 data items. 4195 Input to calculate TH_3 (CBOR Sequence) (46 bytes) 4196 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 36 d0 4197 cf 8c 73 a6 e8 a7 c3 62 1e 26 4a a3 f1 bd 5d 02 8d 19 cf 3c 99 37 4198 And from there, compute the transcript hash TH_3 = SHA-256( H(TH_2 , 4199 CIPHERTEXT_2), data_3) 4201 TH_3 (CBOR unencoded) (32 bytes) 4202 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 d7 cb 8b 84 4203 db 03 ff a5 83 a3 5f cb 4205 The initiator's subject name is the empty string: 4207 Initiator's subject name (text string) 4208 "" 4210 And its credential is: 4212 ID_CRED_I = 4213 { 4214 4: h'23' 4215 } 4217 ID_CRED_I (4 bytes) 4218 a1 04 41 23 4220 CRED_I is the following COSE_Key: 4222 { 4223 1:1, 4224 -1:4, 4225 -2:h'2C440CC121F8D7F24C3B0E41AEDAFE9CAA4F4E7ABB835EC30F1DE88ADB96FF71', 4226 "subject name":"" 4227 } 4229 Which encodes to the following byte string: 4231 CRED_I (54 bytes) 4232 a4 01 01 20 04 21 58 20 2c 44 0c c1 21 f8 d7 f2 4c 3b 0e 41 ae da fe 9c 4233 aa 4f 4e 7a bb 83 5e c3 0f 1d e8 8a db 96 ff 71 6c 73 75 62 6a 65 63 74 4234 20 6e 61 6d 65 60 4236 Since no external authorization data is exchanged: 4238 EAD_3 (0 bytes) 4240 The plaintext of the COSE_Encrypt is the empty string: 4242 P_3m (0 bytes) 4244 The associated data is the following: [ "Encrypt0", << ID_CRED_I >>, 4245 << TH_3, CRED_I, ? EAD_3 >> ]. 4247 A_3m (CBOR-encoded) (105 bytes) 4248 83 68 45 6e 63 72 79 70 74 30 44 a1 04 41 23 58 58 58 20 b6 cd 80 4f c4 4249 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 d7 cb 8b 84 db 03 ff a5 83 4250 a3 5f cb a4 01 01 20 04 21 58 20 2c 44 0c c1 21 f8 d7 f2 4c 3b 0e 41 ae 4251 da fe 9c aa 4f 4e 7a bb 83 5e c3 0f 1d e8 8a db 96 ff 71 6c 73 75 62 6a 4252 65 63 74 20 6e 61 6d 65 60 4254 Info for K_3m is computed as follows: 4256 info for K_3m = 4257 [ 4258 10, 4259 h'B6CD804FC4B9D7CAC502ABD77CDA74E41CB01182D7CB8B84DB03FFA583A35FCB', 4260 "K_3m", 4261 16 4262 ] 4264 Which as a CBOR encoded data item is: 4266 info for K_3m (CBOR-encoded) (42 bytes) 4267 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 4268 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 64 4b 5f 33 6d 10 4270 From these parameters, K_3m is computed. Key K_3m is the output of 4271 HKDF-Expand(PRK_4x3m, info, L), where L is the length of K_2m, so 16 4272 bytes. 4274 K_3m (16 bytes) 4275 02 c7 e7 93 89 9d 90 d1 28 28 10 26 96 94 c9 58 4277 Nonce IV_3m is the output of HKDF-Expand(PRK_4x3m, info, L), where L 4278 = 13 bytes. 4280 Info for IV_3m is defined as follows: 4282 info for IV_3m = 4283 [ 4284 10, 4285 h'B6CD804FC4B9D7CAC502ABD77CDA74E41CB01182D7CB8B84DB03FFA583A35FCB', 4286 "IV_3m", 4287 13 4288 ] 4290 Which as a CBOR encoded data item is: 4292 info for IV_3m (CBOR-encoded) (43 bytes) 4293 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 4294 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 65 49 56 5f 33 6d 0d 4295 From these parameters, IV_3m is computed: 4297 IV_3m (13 bytes) 4298 0d a7 cc 3a 6f 9a b2 48 52 ce 8b 37 a6 4300 MAC_3 is the 'ciphertext' of the COSE_Encrypt0 with empty plaintext. 4301 In case of cipher suite 0 the AEAD is AES-CCM truncated to 8 bytes: 4303 MAC_3 (CBOR unencoded) (8 bytes) 4304 ee 59 8e a6 61 17 dc c3 4306 Since method = 3, Signature_or_MAC_3 is MAC_3: 4308 Signature_or_MAC_3 (CBOR unencoded) (8 bytes) 4309 ee 59 8e a6 61 17 dc c3 4311 Finally, the outer COSE_Encrypt0 is computed. 4313 The plaintext is the CBOR Sequence of the items ID_CRED_I and the 4314 CBOR encoded Signature_or_MAC_3, in this order (EAD_3 is empty). 4316 Note that since ID_CRED_I contains a single 'kid' parameter, i.e., 4317 ID_CRED_I = { 4 : kid_I }, only the byte string kid_I is conveyed in 4318 the plaintext encoded as a bstr_identifier. kid_I is encoded as the 4319 corresponding integer - 24, i.e. 0x23 = 35, 35 - 24 = 11, and 11 in 4320 CBOR encoding is equal to 0x0b. 4322 P_3ae (CBOR Sequence) (10 bytes) 4323 0b 48 ee 59 8e a6 61 17 dc c3 4325 The Associated data A is the following: Associated data A = [ 4326 "Encrypt0", h'', TH_3 ] 4328 A_3ae (CBOR-encoded) (45 bytes) 4329 83 68 45 6e 63 72 79 70 74 30 40 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab 4330 d7 7c da 74 e4 1c b0 11 82 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 4332 Key K_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 4334 info is defined as follows: 4336 info for K_3ae = 4337 [ 4338 10, 4339 h'B6CD804FC4B9D7CAC502ABD77CDA74E41CB01182D7CB8B84DB03FFA583A35FCB', 4340 "K_3ae", 4341 16 4342 ] 4343 Which as a CBOR encoded data item is: 4345 info for K_3ae (CBOR-encoded) (43 bytes) 4346 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 4347 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 65 4b 5f 33 61 65 10 4349 L is the length of K_3ae, so 16 bytes. 4351 From these parameters, K_3ae is computed: 4353 K_3ae (16 bytes) 4354 6b a4 c8 83 1d e3 ae 23 e9 8e f7 35 08 d0 95 86 4356 Nonce IV_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 4358 info is defined as follows: 4360 info for IV_3ae = 4361 [ 4362 10, 4363 h'97D8AD42334833EB25B960A5EB0704505F89671A0168AA1115FAF92D9E67EF04', 4364 "IV_3ae", 4365 13 4366 ] 4368 Which as a CBOR encoded data item is: 4370 info for IV_3ae (CBOR-encoded) (44 bytes) 4371 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 4372 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 66 49 56 5f 33 61 65 0d 4374 L is the length of IV_3ae, so 13 bytes. 4376 From these parameters, IV_3ae is computed: 4378 IV_3ae (13 bytes) 4379 6c 6d 0f e1 1e 9a 1a f3 7b 87 84 55 10 4381 Using the parameters above, the 'ciphertext' CIPHERTEXT_3 can be 4382 computed: 4384 CIPHERTEXT_3 (CBOR unencoded) (18 bytes) 4385 d5 53 5f 31 47 e8 5f 1c fa cd 9e 78 ab f9 e0 a8 1b bf 4387 From the parameter above, message_3 is computed, as the CBOR Sequence 4388 of the following items: (C_R, CIPHERTEXT_3). 4390 message_3 = 4391 ( 4392 -24, 4393 h'D5535F3147E85F1CFACD9E78ABF9E0A81BBF' 4394 ) 4396 Which encodes to the following byte string: 4398 message_3 (CBOR Sequence) (20 bytes) 4399 37 52 d5 53 5f 31 47 e8 5f 1c fa cd 9e 78 ab f9 e0 a8 1b bf 4401 D.2.4. OSCORE Security Context Derivation 4403 From here, the Initiator and the Responder can derive an OSCORE 4404 Security Context, using the EDHOC-Exporter interface. 4406 From TH_3 and CIPHERTEXT_3, compute the input to the transcript hash 4407 TH_4 = H( TH_3, CIPHERTEXT_3 ), as a CBOR Sequence of these 2 data 4408 items. 4410 Input to calculate TH_4 (CBOR Sequence) (53 bytes) 4411 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 d7 cb 4412 8b 84 db 03 ff a5 83 a3 5f cb 52 d5 53 5f 31 47 e8 5f 1c fa cd 9e 78 ab 4413 f9 e0 a8 1b bf 4415 And from there, compute the transcript hash TH_4 = SHA-256(TH_3 , 4416 CIPHERTEXT_4) 4418 TH_4 (CBOR unencoded) (32 bytes) 4419 7c cf de dc 2c 10 ca 03 56 e9 57 b9 f6 a5 92 e0 fa 74 db 2a b5 4f 59 24 4420 40 96 f9 a2 ac 56 d2 07 4422 The Master Secret and Master Salt are derived as follows: 4424 Master Secret = EDHOC-Exporter( "OSCORE Master Secret", 16 ) = EDHOC- 4425 KDF(PRK_4x3m, TH_4, "OSCORE Master Secret", 16) = HKDF-Expand( 4426 PRK_4x3m, info_ms, 16 ) 4428 Master Salt = EDHOC-Exporter( "OSCORE Master Salt", 8 ) = EDHOC- 4429 KDF(PRK_4x3m, TH_4, "OSCORE Master Salt", 8) = HKDF-Expand( PRK_4x3m, 4430 info_salt, 8 ) 4432 info_ms for OSCORE Master Secret is defined as follows: 4434 info_ms = [ 4435 10, 4436 h'7CCFDEDC2C10CA0356E957B9F6A592E0FA74DB2AB54F59244096F9A2AC56D207', 4437 "OSCORE Master Secret", 4438 16 4439 ] 4441 Which as a CBOR encoded data item is: 4443 info_ms for OSCORE Master Secret (CBOR-encoded) (58 bytes) 4444 84 0a 58 20 7c cf de dc 2c 10 ca 03 56 e9 57 b9 f6 a5 92 e0 fa 74 db 2a 4445 b5 4f 59 24 40 96 f9 a2 ac 56 d2 07 74 4f 53 43 4f 52 45 20 4d 61 73 74 4446 65 72 20 53 65 63 72 65 74 10 4448 info_salt for OSCORE Master Salt is defined as follows: 4450 info_salt = [ 4451 10, 4452 h'7CCFDEDC2C10CA0356E957B9F6A592E0FA74DB2AB54F59244096F9A2AC56D207', 4453 "OSCORE Master Salt", 4454 8 4455 ] 4457 Which as a CBOR encoded data item is: 4459 info for OSCORE Master Salt (CBOR-encoded) (56 Bytes) 4460 84 0a 58 20 7c cf de dc 2c 10 ca 03 56 e9 57 b9 f6 a5 92 e0 fa 74 db 2a 4461 b5 4f 59 24 40 96 f9 a2 ac 56 d2 07 72 4f 53 43 4f 52 45 20 4d 61 73 74 4462 65 72 20 53 61 6c 74 08 4464 From these parameters, OSCORE Master Secret and OSCORE Master Salt 4465 are computed: 4467 OSCORE Master Secret (16 bytes) 4468 c3 4a 50 6d 0e bf bd 17 03 04 86 13 5f 9c b3 50 4470 OSCORE Master Salt (8 bytes) 4471 c2 24 34 9d 9b 34 ca 8c 4473 The client's OSCORE Sender ID is C_R and the server's OSCORE Sender 4474 ID is C_I. 4476 Client's OSCORE Sender ID (1 byte) 4477 00 4479 Server's OSCORE Sender ID (1 byte) 4480 16 4481 The AEAD Algorithm and the hash algorithm are the application AEAD 4482 and hash algorithms in the selected cipher suite. 4484 OSCORE AEAD Algorithm (int) 4485 10 4487 OSCORE Hash Algorithm (int) 4488 -16 4490 Appendix E. Applicability Template 4492 This appendix contains an example of an applicability statement, see 4493 Section 3.9. 4495 For use of EDHOC in the XX protocol, the following assumptions are 4496 made on the parameters: 4498 o METHOD = 1 (I uses signature key, R uses static DH key.) 4500 o EDHOC requests are expected by the server at /app1-edh, no 4501 Content-Format needed. 4503 o CRED_I is an 802.1AR IDevID encoded as a C509 Certificate of type 4504 0 [I-D.ietf-cose-cbor-encoded-cert]. 4506 * R acquires CRED_I out-of-band, indicated in EAD_1 4508 * ID_CRED_I = {4: h''} is a kid with value empty byte string 4510 o CRED_R is a COSE_Key of type OKP as specified in Section 3.5.4. 4512 * The CBOR map has parameters 1 (kty), -1 (crv), and -2 4513 (x-coordinate). 4515 o ID_CRED_R = CRED_R 4517 o No use of message_4: the application sends protected messages from 4518 R to I. 4520 o External authorization data is defined and processed as specified 4521 in [I-D.selander-ace-ake-authz]. 4523 Appendix F. EDHOC Message Deduplication 4525 EDHOC by default assumes that message duplication is handled by the 4526 transport, in this section exemplified with CoAP. 4528 Deduplication of CoAP messages is described in Section 4.5 of 4529 [RFC7252]. This handles the case when the same Confirmable (CON) 4530 message is received multiple times due to missing acknowledgement on 4531 CoAP messaging layer. The recommended processing in [RFC7252] is 4532 that the duplicate message is acknowledged (ACK), but the received 4533 message is only processed once by the CoAP stack. 4535 Message deduplication is resource demanding and therefore not 4536 supported in all CoAP implementations. Since EDHOC is targeting 4537 constrained environments, it is desirable that EDHOC can optionally 4538 support transport layers which does not handle message duplication. 4539 Special care is needed to avoid issues with duplicate messages, see 4540 Section 5.1. 4542 The guiding principle here is similar to the deduplication processing 4543 on CoAP messaging layer: a received duplicate EDHOC message SHALL NOT 4544 result in a response consisting of another instance of the next EDHOC 4545 message. The result MAY be that a duplicate EDHOC response is sent, 4546 provided it is still relevant with respect the current protocol 4547 state. In any case, the received message MUST NOT be processed more 4548 than once in the same EDHOC session. This is called "EDHOC message 4549 deduplication". 4551 An EDHOC implementation MAY store the previously sent EDHOC message 4552 to be able to resend it. An EDHOC implementation MAY keep the 4553 protocol state to be able to recreate the previously sent EDHOC 4554 message and resend it. The previous message or protocol state MUST 4555 NOT be kept longer than what is required for retransmission, for 4556 example, in the case of CoAP transport, no longer than the 4557 EXCHANGE_LIFETIME (see Section 4.8.2 of [RFC7252]). 4559 Note that the requirements in Section 5.1 still apply because 4560 duplicate messages are not processed by the EDHOC state machine: 4562 o EDHOC messages SHALL be processed according to the current 4563 protocol state. 4565 o Different instances of the same message MUST NOT be processed in 4566 one session. 4568 Appendix G. Transports Not Natively Providing Correlation 4570 Protocols that do not natively provide full correlation between a 4571 series of messages can send the C_I and C_R identifiers along as 4572 needed. 4574 The transport over CoAP (Appendix A.3) can serve as a blueprint for 4575 other server-client protocols: The client prepends the C_x which the 4576 server selected (or, for message 1, a sentinel null value which is 4577 not a valid C_x) to any request message it sends. The server does 4578 not send any such indicator, as responses are matched to request by 4579 the client-server protocol design. 4581 Protocols that do not provide any correlation at all can prescribe 4582 prepending of the peer's chosen C_x to all messages. 4584 Appendix H. Change Log 4586 Main changes: 4588 o From -07 to -08: 4590 * Prepended C_x moved from the EDHOC protocol itself to the 4591 transport mapping 4593 * METHOD_CORR renamed to METHOD, corr removed 4595 * Removed bstr_identifier and use bstr / int instead; C_x can now 4596 be int without any implied bstr semantics 4598 * Defined COSE header parameter 'kid2' with value type bstr / int 4599 for use with ID_CRED_x 4601 * Updated message sizes 4603 * New cipher suites with AES-GCM and ChaCha20 / Poly1305 4605 * Changed from one- to two-byte identifier of CNSA compliant 4606 suite 4608 * Separate sections on transport and connection id with further 4609 sub-structure 4611 * Moved back key derivation for OSCORE from draft-ietf-core- 4612 oscore-edhoc 4614 * OSCORE and CoAP specific processing moved to new appendix 4616 * Message 4 section moved to message processing section 4618 o From -06 to -07: 4620 * Changed transcript hash definition for TH_2 and TH_3 4622 * Removed "EDHOC signature algorithm curve" from cipher suite 4623 * New IANA registry "EDHOC Exporter Label" 4625 * New application defined parameter "context" in EDHOC-Exporter 4627 * Changed normative language for failure from MUST to SHOULD send 4628 error 4630 * Made error codes non-negative and 0 for success 4632 * Added detail on success error code 4634 * Aligned terminology "protocol instance" -> "session" 4636 * New appendix on compact EC point representation 4638 * Added detail on use of ephemeral public keys 4640 * Moved key derivation for OSCORE to draft-ietf-core-oscore-edhoc 4642 * Additional security considerations 4644 * Renamed "Auxililary Data" as "External Authorization Data" 4646 * Added encrypted EAD_4 to message_4 4648 o From -05 to -06: 4650 * New section 5.2 "Message Processing Outline" 4652 * Optional inital byte C_1 = null in message_1 4654 * New format of error messages, table of error codes, IANA 4655 registry 4657 * Change of recommendation transport of error in CoAP 4659 * Merge of content in 3.7 and appendix C into new section 3.7 4660 "Applicability Statement" 4662 * Requiring use of deterministic CBOR 4664 * New section on message deduplication 4666 * New appendix containin all CDDL definitions 4668 * New appendix with change log 4670 * Removed section "Other Documents Referencing EDHOC" 4671 * Clarifications based on review comments 4673 o From -04 to -05: 4675 * EDHOC-Rekey-FS -> EDHOC-KeyUpdate 4677 * Clarification of cipher suite negotiation 4679 * Updated security considerations 4681 * Updated test vectors 4683 * Updated applicability statement template 4685 o From -03 to -04: 4687 * Restructure of section 1 4689 * Added references to C509 Certificates 4691 * Change in CIPHERTEXT_2 -> plaintext XOR KEYSTREAM_2 (test 4692 vector not updated) 4694 * "K_2e", "IV_2e" -> KEYSTREAM_2 4696 * Specified optional message 4 4698 * EDHOC-Exporter-FS -> EDHOC-Rekey-FS 4700 * Less constrained devices SHOULD implement both suite 0 and 2 4702 * Clarification of error message 4704 * Added exporter interface test vector 4706 o From -02 to -03: 4708 * Rearrangements of section 3 and beginning of section 4 4710 * Key derivation new section 4 4712 * Cipher suites 4 and 5 added 4714 * EDHOC-EXPORTER-FS - generate a new PRK_4x3m from an old one 4716 * Change in CIPHERTEXT_2 -> COSE_Encrypt0 without tag (no change 4717 to test vector) 4719 * Clarification of error message 4721 * New appendix C applicability statement 4723 o From -01 to -02: 4725 * New section 1.2 Use of EDHOC 4727 * Clarification of identities 4729 * New section 4.3 clarifying bstr_identifier 4731 * Updated security considerations 4733 * Updated text on cipher suite negotiation and key confirmation 4735 * Test vector for static DH 4737 o From -00 to -01: 4739 * Removed PSK method 4741 * Removed references to certificate by value 4743 Acknowledgments 4745 The authors want to thank Christian Amsuess, Alessandro Bruni, 4746 Karthikeyan Bhargavan, Timothy Claeys, Martin Disch, Theis Groenbech 4747 Petersen, Dan Harkins, Klaus Hartke, Russ Housley, Stefan Hristozov, 4748 Alexandros Krontiris, Ilari Liusvaara, Karl Norrman, Salvador Perez, 4749 Eric Rescorla, Michael Richardson, Thorvald Sahl Joergensen, Jim 4750 Schaad, Carsten Schuermann, Ludwig Seitz, Stanislav Smyshlyaev, 4751 Valery Smyslov, Peter van der Stok, Rene Struik, Vaishnavi 4752 Sundararajan, Erik Thormarker, Marco Tiloca, Michel Veillette, and 4753 Malisa Vucinic for reviewing and commenting on intermediate versions 4754 of the draft. We are especially indebted to Jim Schaad for his 4755 continuous reviewing and implementation of different versions of the 4756 draft. 4758 Work on this document has in part been supported by the H2020 project 4759 SIFIS-Home (grant agreement 952652). 4761 Authors' Addresses 4763 Goeran Selander 4764 Ericsson AB 4766 Email: goran.selander@ericsson.com 4767 John Preuss Mattsson 4768 Ericsson AB 4770 Email: john.mattsson@ericsson.com 4772 Francesca Palombini 4773 Ericsson AB 4775 Email: francesca.palombini@ericsson.com