idnits 2.17.1 draft-ietf-lake-edhoc-05.txt: -(2256): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(2406): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- == There are 11 instances of lines with non-ascii characters in the document. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** There are 2 instances of too long lines in the document, the longest one being 3 characters in excess of 72. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (22 February 2021) is 1159 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 1498 -- Looks like a reference, but probably isn't: '5' on line 1498 -- Looks like a reference, but probably isn't: '9' on line 1494 -- Looks like a reference, but probably isn't: '8' on line 1498 -- Looks like a reference, but probably isn't: '7' on line 1498 ** 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 ** Obsolete normative reference: RFC 8152 (Obsoleted by RFC 9052, RFC 9053) ** Downref: Normative reference to an Informational RFC: RFC 8376 == Outdated reference: A later version (-09) exists of draft-ietf-cose-x509-08 == Outdated reference: A later version (-14) exists of draft-ietf-core-echo-request-tag-11 ** Downref: Normative reference to an Informational draft: draft-ietf-lake-reqs (ref. 'I-D.ietf-lake-reqs') == Outdated reference: A later version (-28) exists of draft-ietf-core-resource-directory-26 == Outdated reference: A later version (-07) exists of draft-ietf-lwig-security-protocol-comparison-05 == Outdated reference: A later version (-43) exists of draft-ietf-tls-dtls13-40 == Outdated reference: A later version (-05) exists of draft-selander-ace-ake-authz-02 == Outdated reference: A later version (-02) exists of draft-palombini-core-oscore-edhoc-01 == Outdated reference: A later version (-08) exists of draft-mattsson-cose-cbor-cert-compress-06 == Outdated reference: A later version (-04) exists of draft-mattsson-cfrg-det-sigs-with-noise-02 Summary: 8 errors (**), 0 flaws (~~), 11 warnings (==), 6 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: 26 August 2021 Ericsson AB 6 22 February 2021 8 Ephemeral Diffie-Hellman Over COSE (EDHOC) 9 draft-ietf-lake-edhoc-05 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 26 August 2021. 39 Copyright Notice 41 Copyright (c) 2021 IETF Trust and the persons identified as the 42 document authors. All rights reserved. 44 This document is subject to BCP 78 and the IETF Trust's Legal 45 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 46 license-info) in effect on the date of publication of this document. 47 Please review these documents carefully, as they describe your rights 48 and restrictions with respect to this document. Code Components 49 extracted from this document must include Simplified BSD License text 50 as described in Section 4.e of the Trust Legal Provisions and are 51 provided without warranty as described in the Simplified BSD License. 53 Table of Contents 55 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 56 1.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . 4 57 1.2. Use of EDHOC . . . . . . . . . . . . . . . . . . . . . . 5 58 1.3. Message Size Examples . . . . . . . . . . . . . . . . . . 6 59 1.4. Document Structure . . . . . . . . . . . . . . . . . . . 6 60 1.5. Terminology and Requirements Language . . . . . . . . . . 6 61 2. EDHOC Outline . . . . . . . . . . . . . . . . . . . . . . . . 7 62 3. Protocol Elements . . . . . . . . . . . . . . . . . . . . . . 9 63 3.1. General . . . . . . . . . . . . . . . . . . . . . . . . . 9 64 3.2. Method and Correlation . . . . . . . . . . . . . . . . . 9 65 3.2.1. Method . . . . . . . . . . . . . . . . . . . . . . . 10 66 3.2.2. Connection Identifiers . . . . . . . . . . . . . . . 10 67 3.2.3. Transport . . . . . . . . . . . . . . . . . . . . . . 11 68 3.2.4. Message Correlation . . . . . . . . . . . . . . . . . 11 69 3.3. Authentication Parameters . . . . . . . . . . . . . . . . 11 70 3.3.1. Authentication Keys . . . . . . . . . . . . . . . . . 11 71 3.3.2. Identities . . . . . . . . . . . . . . . . . . . . . 12 72 3.3.3. Authentication Credentials . . . . . . . . . . . . . 13 73 3.3.4. Identification of Credentials . . . . . . . . . . . . 14 74 3.4. Cipher Suites . . . . . . . . . . . . . . . . . . . . . . 15 75 3.5. Ephemeral Public Keys . . . . . . . . . . . . . . . . . . 17 76 3.6. Auxiliary Data . . . . . . . . . . . . . . . . . . . . . 17 77 3.7. Communication of Protocol Features . . . . . . . . . . . 18 78 4. Key Derivation . . . . . . . . . . . . . . . . . . . . . . . 18 79 4.1. EDHOC-Exporter Interface . . . . . . . . . . . . . . . . 20 80 5. Message Formatting and Processing . . . . . . . . . . . . . . 21 81 5.1. Encoding of bstr_identifier . . . . . . . . . . . . . . . 21 82 5.2. EDHOC Message 1 . . . . . . . . . . . . . . . . . . . . . 22 83 5.2.1. Formatting of Message 1 . . . . . . . . . . . . . . . 22 84 5.2.2. Initiator Processing of Message 1 . . . . . . . . . . 23 85 5.2.3. Responder Processing of Message 1 . . . . . . . . . . 23 86 5.3. EDHOC Message 2 . . . . . . . . . . . . . . . . . . . . . 24 87 5.3.1. Formatting of Message 2 . . . . . . . . . . . . . . . 24 88 5.3.2. Responder Processing of Message 2 . . . . . . . . . . 24 89 5.3.3. Initiator Processing of Message 2 . . . . . . . . . . 26 90 5.4. EDHOC Message 3 . . . . . . . . . . . . . . . . . . . . . 27 91 5.4.1. Formatting of Message 3 . . . . . . . . . . . . . . . 27 92 5.4.2. Initiator Processing of Message 3 . . . . . . . . . . 27 93 5.4.3. Responder Processing of Message 3 . . . . . . . . . . 29 94 6. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 30 95 6.1. EDHOC Error Message . . . . . . . . . . . . . . . . . . . 30 96 6.1.1. Example Use of EDHOC Error Message with SUITES_R . . 32 98 7. Transferring EDHOC and Deriving an OSCORE Context . . . . . . 33 99 7.1. EDHOC Message 4 . . . . . . . . . . . . . . . . . . . . . 33 100 7.1.1. Formatting of Message 4 . . . . . . . . . . . . . . . 34 101 7.1.2. Responder Processing of Message 4 . . . . . . . . . . 34 102 7.1.3. Initiator Processing of Message 4 . . . . . . . . . . 35 103 7.2. Transferring EDHOC in CoAP . . . . . . . . . . . . . . . 35 104 7.2.1. Deriving an OSCORE Context from EDHOC . . . . . . . . 37 105 7.2.2. Error Messages . . . . . . . . . . . . . . . . . . . 38 106 8. Security Considerations . . . . . . . . . . . . . . . . . . . 38 107 8.1. Security Properties . . . . . . . . . . . . . . . . . . . 38 108 8.2. Cryptographic Considerations . . . . . . . . . . . . . . 40 109 8.3. Cipher Suites and Cryptographic Algorithms . . . . . . . 41 110 8.4. Unprotected Data . . . . . . . . . . . . . . . . . . . . 41 111 8.5. Denial-of-Service . . . . . . . . . . . . . . . . . . . . 42 112 8.6. Implementation Considerations . . . . . . . . . . . . . . 42 113 8.7. Other Documents Referencing EDHOC . . . . . . . . . . . . 44 114 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 44 115 9.1. EDHOC Cipher Suites Registry . . . . . . . . . . . . . . 44 116 9.2. EDHOC Method Type Registry . . . . . . . . . . . . . . . 45 117 9.3. The Well-Known URI Registry . . . . . . . . . . . . . . . 45 118 9.4. Media Types Registry . . . . . . . . . . . . . . . . . . 46 119 9.5. CoAP Content-Formats Registry . . . . . . . . . . . . . . 47 120 9.6. Expert Review Instructions . . . . . . . . . . . . . . . 47 121 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 47 122 10.1. Normative References . . . . . . . . . . . . . . . . . . 47 123 10.2. Informative References . . . . . . . . . . . . . . . . . 50 124 Appendix A. Use of CBOR, CDDL and COSE in EDHOC . . . . . . . . 53 125 A.1. CBOR and CDDL . . . . . . . . . . . . . . . . . . . . . . 53 126 A.2. COSE . . . . . . . . . . . . . . . . . . . . . . . . . . 54 127 Appendix B. Test Vectors . . . . . . . . . . . . . . . . . . . . 54 128 B.1. Test Vectors for EDHOC Authenticated with Signature Keys 129 (x5t) . . . . . . . . . . . . . . . . . . . . . . . . . . 55 130 B.1.1. Message_1 . . . . . . . . . . . . . . . . . . . . . . 55 131 B.1.2. Message_2 . . . . . . . . . . . . . . . . . . . . . . 57 132 B.1.3. Message_3 . . . . . . . . . . . . . . . . . . . . . . 64 133 B.1.4. OSCORE Security Context Derivation . . . . . . . . . 70 134 B.2. Test Vectors for EDHOC Authenticated with Static 135 Diffie-Hellman Keys . . . . . . . . . . . . . . . . . . . 72 136 B.2.1. Message_1 . . . . . . . . . . . . . . . . . . . . . . 73 137 B.2.2. Message_2 . . . . . . . . . . . . . . . . . . . . . . 74 138 B.2.3. Message_3 . . . . . . . . . . . . . . . . . . . . . . 80 139 B.2.4. OSCORE Security Context Derivation . . . . . . . . . 85 140 Appendix C. Applicability Statement . . . . . . . . . . . . . . 87 141 C.1. Template: Use of EDHOC in the XX Protocol . . . . . . . . 89 142 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 90 143 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 90 145 1. Introduction 147 1.1. Motivation 149 Many Internet of Things (IoT) deployments require technologies which 150 are highly performant in constrained environments [RFC7228]. IoT 151 devices may be constrained in various ways, including memory, 152 storage, processing capacity, and power. The connectivity for these 153 settings may also exhibit constraints such as unreliable and lossy 154 channels, highly restricted bandwidth, and dynamic topology. The 155 IETF has acknowledged this problem by standardizing a range of 156 lightweight protocols and enablers designed for the IoT, including 157 the Constrained Application Protocol (CoAP, [RFC7252]), Concise 158 Binary Object Representation (CBOR, [RFC8949]), and Static Context 159 Header Compression (SCHC, [RFC8724]). 161 The need for special protocols targeting constrained IoT deployments 162 extends also to the security domain [I-D.ietf-lake-reqs]. Important 163 characteristics in constrained environments are the number of round 164 trips and protocol message sizes, which if kept low can contribute to 165 good performance by enabling transport over a small number of radio 166 frames, reducing latency due to fragmentation or duty cycles, etc. 167 Another important criteria is code size, which may be prohibitive for 168 certain deployments due to device capabilities or network load during 169 firmware update. Some IoT deployments also need to support a variety 170 of underlying transport technologies, potentially even with a single 171 connection. 173 Some security solutions for such settings exist already. CBOR Object 174 Signing and Encryption (COSE) [RFC8152] specifies basic application- 175 layer security services efficiently encoded in CBOR. Another example 176 is Object Security for Constrained RESTful Environments (OSCORE) 177 [RFC8613] which is a lightweight communication security extension to 178 CoAP using CBOR and COSE. In order to establish good quality 179 cryptographic keys for security protocols such as COSE and OSCORE, 180 the two endpoints may run an authenticated key exchange protocol, 181 from which shared secret key material can be derived. Such a key 182 exchange protocol should also be lightweight; to prevent bad 183 performance in case of repeated use, e.g., due to device rebooting or 184 frequent rekeying for security reasons; or to avoid latencies in a 185 network formation setting with many devices authenticating at the 186 same time. 188 This document specifies Ephemeral Diffie-Hellman Over COSE (EDHOC), a 189 lightweight authenticated key exchange protocol providing good 190 security properties including perfect forward secrecy, identity 191 protection, and cipher suite negotation. Authentication can be based 192 on raw public keys (RPK) or public key certificates, and requires the 193 application to provide input on how to verify that endpoints are 194 trusted. This specificaton focuses on referencing instead of 195 transporting credentials to reduce message overhead. 197 EDHOC makes use of known protocol constructions, such as SIGMA 198 [SIGMA] and Extract-and-Expand [RFC5869]. COSE also provides crypto 199 agility and enables the use of future algorithms targeting IoT. 201 1.2. Use of EDHOC 203 EDHOC is designed for highly constrained settings making it 204 especially suitable for low-power wide area networks [RFC8376] such 205 as Cellular IoT, 6TiSCH, and LoRaWAN. A main objective for EDHOC is 206 to be a lightweight AKE for OSCORE, i.e. to provide authentication 207 and session key establishment for IoT use cases such as those built 208 on CoAP [RFC7252]. CoAP is a specialized web transfer protocol for 209 use with constrained nodes and networks, providing a request/response 210 interaction model between application endpoints. As such, EDHOC is 211 targeting a large variety of use cases involving 'things' with 212 embedded microcontrollers, sensors, and actuators. 214 A typical setting is when one of the endpoints is constrained or in a 215 constrained network, and the other endpoint is a node on the Internet 216 (such as a mobile phone) or at the edge of the constrained network 217 (such as a gateway). Thing-to-thing interactions over constrained 218 networks are also relevant since both endpoints would then benefit 219 from the lightweight properties of the protocol. EDHOC could e.g. be 220 run when a device/device(s) connect(s) for the first time, or to 221 establish fresh keys which are not revealed by a later compromise of 222 the long-term keys. Further security properties are described in 223 Section 8.1. 225 EDHOC builds on the same lightweight primitives as OSCORE: CBOR for 226 encoding, COSE for cryptography, and CoAP for transport. By reusing 227 existing libraries the additional code size can be kept very low. 228 EDHOC is not bound to a particular transport, but it is recommended 229 to transfer EDHOC messages in CoAP payloads. 231 1.3. Message Size Examples 233 Compared to the DTLS 1.3 handshake [I-D.ietf-tls-dtls13] with ECDHE 234 and connection ID, the number of bytes in EDHOC + CoAP can be less 235 than 1/6 when RPK authentication is used, see 236 [I-D.ietf-lwig-security-protocol-comparison]. Figure 1 shows two 237 examples of message sizes for EDHOC with different kinds of 238 authentication keys and different COSE header parameters for 239 identification: static Diffie-Hellman keys identified by 'kid' 240 [RFC8152], and X.509 signature certificates identified by a hash 241 value using 'x5t' [I-D.ietf-cose-x509]. 243 ================================= 244 kid x5t 245 --------------------------------- 246 message_1 37 37 247 message_2 46 117 248 message_3 20 91 249 --------------------------------- 250 Total 103 245 251 ================================= 253 Figure 1: Example of message sizes in bytes. 255 1.4. Document Structure 257 The remainder of the document is organized as follows: Section 2 258 outlines EDHOC authenticated with digital signatures, Section 3 259 describes the protocol elements of EDHOC, including message flow, and 260 formatting of the ephemeral public keys, Section 4 describes the key 261 derivation, Section 5 specifies EDHOC with authentication based on 262 signature keys or static Diffie-Hellman keys, Section 6 specifies the 263 EDHOC error message, and Section 7 describes how EDHOC can be 264 transferred in CoAP and used to establish an OSCORE security context. 266 1.5. Terminology and Requirements Language 268 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 269 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 270 "OPTIONAL" in this document are to be interpreted as described in BCP 271 14 [RFC2119] [RFC8174] when, and only when, they appear in all 272 capitals, as shown here. 274 Readers are expected to be familiar with the terms and concepts 275 described in CBOR [RFC8949], CBOR Sequences [RFC8742], COSE 276 [RFC8152], and CDDL [RFC8610]. The Concise Data Definition Language 277 (CDDL) is used to express CBOR data structures [RFC8949]. Examples 278 of CBOR and CDDL are provided in Appendix A.1. 280 The single output from authenticated encryption (including the 281 authentication tag) is called 'ciphertext', following [RFC5116]. 283 2. EDHOC Outline 285 EDHOC specifies different authentication methods of the Diffie- 286 Hellman key exchange: digital signatures and static Diffie-Hellman 287 keys. This section outlines the digital signature based method. 288 Further details of protocol elements and other authentication methods 289 are provided in the remainder of this document. 291 SIGMA (SIGn-and-MAc) is a family of theoretical protocols with a 292 large number of variants [SIGMA]. Like IKEv2 [RFC7296] and (D)TLS 293 1.3 [RFC8446], EDHOC authenticated with digital signatures is built 294 on a variant of the SIGMA protocol which provide identity protection 295 of the initiator (SIGMA-I), and like IKEv2 [RFC7296], EDHOC 296 implements the SIGMA-I variant as MAC-then-Sign. The SIGMA-I 297 protocol using an authenticated encryption algorithm is shown in 298 Figure 2. 300 Initiator Responder 301 | G_X | 302 +-------------------------------------------------------->| 303 | | 304 | G_Y, AEAD( K_2; ID_CRED_R, Sig(R; CRED_R, G_X, G_Y) ) | 305 |<--------------------------------------------------------+ 306 | | 307 | AEAD( K_3; ID_CRED_I, Sig(I; CRED_I, G_Y, G_X) ) | 308 +-------------------------------------------------------->| 309 | | 311 Figure 2: Authenticated encryption variant of the SIGMA-I protocol. 313 The parties exchanging messages are called Initiator (I) and 314 Responder (R). They exchange ephemeral public keys, compute the 315 shared secret, and derive symmetric application keys. 317 * G_X and G_Y are the ECDH ephemeral public keys of I and R, 318 respectively. 320 * CRED_I and CRED_R are the credentials containing the public 321 authentication keys of I and R, respectively. 323 * ID_CRED_I and ID_CRED_R are data enabling the recipient party to 324 retrieve the credential of I and R, respectively. 326 * Sig(I; . ) and S(R; . ) denote signatures made with the private 327 authentication key of I and R, respectively. 329 * AEAD(K; . ) denotes authenticated encryption with additional data 330 using a key K derived from the shared secret. 332 In order to create a "full-fledged" protocol some additional protocol 333 elements are needed. EDHOC adds: 335 * Explicit connection identifiers C_I, C_R chosen by I and R, 336 respectively, enabling the recipient to find the protocol state. 338 * Transcript hashes (hashes of message data) TH_2, TH_3, TH_4 used 339 for key derivation and as additional authenticated data. 341 * Computationally independent keys derived from the ECDH shared 342 secret and used for authenticated encryption of different 343 messages. 345 * An optional fourth flight giving explicit key confirmation to I in 346 deployments where no application data is sent from R to I. 348 * A key material exporter and a key update function enabling 349 frequent forward secrecy. 351 * Verification of a common preferred cipher suite: 353 - The Initiator lists supported cipher suites in order of 354 preference 356 - The Responder verifies that the selected cipher suite is the 357 first supported cipher suite 359 * Method types and error handling. 361 * Transport of opaque auxiliary data. 363 EDHOC is designed to encrypt and integrity protect as much 364 information as possible, and all symmetric keys are derived using as 365 much previous information as possible. EDHOC is furthermore designed 366 to be as compact and lightweight as possible, in terms of message 367 sizes, processing, and the ability to reuse already existing CBOR, 368 COSE, and CoAP libraries. 370 To simplify for implementors, the use of CBOR and COSE in EDHOC is 371 summarized in Appendix A and test vectors including CBOR diagnostic 372 notation are given in Appendix B. 374 3. Protocol Elements 376 3.1. General 378 An EDHOC message flow consists of three mandatory messages 379 (message_1, message_2, message_3) between Initiator and Responder, an 380 optional fourth message (message_4), plus an EDHOC error message. 381 EDHOC messages are CBOR Sequences [RFC8742], see Figure 3. The 382 protocol elements in the figure are introduced in the following 383 sections. Message formatting and processing is specified in 384 Section 5 and Section 6. An implementation may support only 385 Initiator or only Responder. 387 Application data is protected using the agreed application algorithms 388 (AEAD, hash) in the selected cipher suite (see Section 3.4) and the 389 application can make use of the established connection identifiers 390 C_I and C_R (see Section 3.2.4). EDHOC may be used with the media 391 type application/edhoc defined in Section 9. 393 The Initiator can derive symmetric application keys after creating 394 EDHOC message_3, see Section 4.1. Application protected data can 395 therefore be sent in parallel or toghether with EDHOC message_3. 397 Initiator Responder 398 | METHOD_CORR, SUITES_I, G_X, C_I, AD_1 | 399 +------------------------------------------------------------------>| 400 | message_1 | 401 | | 402 | C_I, G_Y, C_R, Enc(ID_CRED_R, Signature_or_MAC_2, AD_2) | 403 |<------------------------------------------------------------------+ 404 | message_2 | 405 | | 406 | C_R, AEAD(K_3ae; ID_CRED_I, Signature_or_MAC_3, AD_3) | 407 +------------------------------------------------------------------>| 408 | message_3 | 410 Figure 3: EDHOC Message Flow 412 3.2. Method and Correlation 414 The data item METHOD_CORR in message_1 (see Section 5.2.1), is an 415 integer specifying the method and the correlation properties of the 416 transport, which are described in this section. 418 3.2.1. Method 420 EDHOC supports authentication with signature or static Diffie-Hellman 421 keys, as defined in the four authentication methods: 0, 1, 2, and 3, 422 see Figure 4. (Method 0 corresponds to the case outlined in 423 Section 2 where both Initiator and Responder authenticate with 424 signature keys.) 426 An implementation may support only a single method. The Initiator 427 and the Responder need to have agreed on a single method to be used 428 for EDHOC, see Appendix C. 430 +-------+-------------------+-------------------+-------------------+ 431 | Value | Initiator | Responder | Reference | 432 +-------+-------------------+-------------------+-------------------+ 433 | 0 | Signature Key | Signature Key | [[this document]] | 434 | 1 | Signature Key | Static DH Key | [[this document]] | 435 | 2 | Static DH Key | Signature Key | [[this document]] | 436 | 3 | Static DH Key | Static DH Key | [[this document]] | 437 +-------+-------------------+-------------------+-------------------+ 439 Figure 4: Method Types 441 3.2.2. Connection Identifiers 443 EDHOC includes connection identifiers (C_I, C_R) to correlate 444 messages. The connection identifiers C_I and C_R do not have any 445 cryptographic purpose in EDHOC. They contain information 446 facilitating retrieval of the protocol state and may therefore be 447 very short. One byte connection identifiers are realistic in many 448 scenarios as most constrained devices only have a few connections. 449 In cases where a node only has one connection, the identifiers may 450 even be the empty byte string. 452 The connection identifier MAY be used with an application protocol 453 (e.g. OSCORE) for which EDHOC establishes keys, in which case the 454 connection identifiers SHALL adhere to the requirements for that 455 protocol. Each party choses a connection identifier it desires the 456 other party to use in outgoing messages. (For OSCORE this results in 457 the endpoint selecting its Recipient ID, see Section 3.1 of 458 [RFC8613]). 460 3.2.3. Transport 462 Cryptographically, EDHOC does not put requirements on the lower 463 layers. EDHOC is not bound to a particular transport layer, and can 464 be used in environments without IP. The transport is responsible to 465 handle message loss, reordering, message duplication, fragmentation, 466 and denial of service protection, where necessary. 468 The Initiator and the Responder need to have agreed on a transport to 469 be used for EDHOC, see Appendix C. It is recommended to transport 470 EDHOC in CoAP payloads, see Section 7. 472 3.2.4. Message Correlation 474 If the transport provides a mechanism for correlating messages, some 475 of the connection identifiers may be omitted. There are four cases: 477 * corr = 0, the transport does not provide a correlation mechanism. 479 * corr = 1, the transport provides a correlation mechanism that 480 enables the Responder to correlate message_2 and message_1. 482 * corr = 2, the transport provides a correlation mechanism that 483 enables the Initiator to correlate message_3 and message_2. 485 * corr = 3, the transport provides a correlation mechanism that 486 enables both parties to correlate all three messages. 488 For example, if the key exchange is transported over CoAP, the CoAP 489 Token can be used to correlate messages, see Section 7.2. 491 3.3. Authentication Parameters 493 3.3.1. Authentication Keys 495 The authentication key MUST be a signature key or static Diffie- 496 Hellman key. The Initiator and the Responder MAY use different types 497 of authentication keys, e.g. one uses a signature key and the other 498 uses a static Diffie-Hellman key. When using a signature key, the 499 authentication is provided by a signature. When using a static 500 Diffie-Hellman key the authentication is provided by a Message 501 Authentication Code (MAC) computed from an ephemeral-static ECDH 502 shared secret which enables significant reductions in message sizes. 503 The MAC is implemented with an AEAD algorithm. When using static 504 Diffie-Hellman keys the Initiator's and Responder's private 505 authentication keys are called I and R, respectively, and the public 506 authentication keys are called G_I and G_R, respectively. 508 * Only the Responder SHALL have access to the Responder's private 509 authentication key. 511 * Only the Initiator SHALL have access to the Initiator's private 512 authentication key. 514 3.3.2. Identities 516 EDHOC assumes the existence of mechanisms (certification authority, 517 trusted third party, manual distribution, etc.) for specifying and 518 distributing authentication keys and identities. Policies are set 519 based on the identity of the other party, and parties typically only 520 allow connections from a specific identity or a small restricted set 521 of identities. For example, in the case of a device connecting to a 522 network, the network may only allow connections from devices which 523 authenticate with certificates having a particular range of serial 524 numbers in the subject field and signed by a particular CA. On the 525 other side, the device may only be allowed to connect to a network 526 which authenticate with a particular public key (information of which 527 may be provisioned, e.g., out of band or in the Auxiliary Data, see 528 Section 3.6). 530 The EDHOC implementation must be able to receive and enforce 531 information from the application about what is the intended peer 532 endpoint, and in particular whether it is a specific identity or a 533 set of identities. 535 * When a Public Key Infrastructure (PKI) is used, the trust anchor 536 is a Certification Authority (CA) certificate, and the identity is 537 the subject whose unique name (e.g. a domain name, NAI, or EUI) is 538 included in the endpoint's certificate. Before running EDHOC each 539 party needs at least one CA public key certificate, or just the 540 public key, and a specific identity or set of identities it is 541 allowed to communicate with. Only validated public-key 542 certificates with an allowed subject name, as specified by the 543 application, are to be accepted. EDHOC provides proof that the 544 other party possesses the private authentication key corresponding 545 to the public authentication key in its certificate. The 546 certification path provides proof that the subject of the 547 certificate owns the public key in the certificate. 549 * When public keys are used but not with a PKI (RPK, self-signed 550 certificate), the trust anchor is the public authentication key of 551 the other party. In this case, the identity is typically directly 552 associated to the public authentication key of the other party. 553 For example, the name of the subject may be a canonical 554 representation of the public key. Alternatively, if identities 555 can be expressed in the form of unique subject names assigned to 556 public keys, then a binding to identity can be achieved by 557 including both public key and associated subject name in the 558 protocol message computation: CRED_I or CRED_R may be a self- 559 signed certificate or COSE_Key containing the public 560 authentication key and the subject name, see Section 3.3.3. 561 Before running EDHOC, each endpoint needs a specific public 562 authentication key/unique associated subject name, or a set of 563 public authentication keys/unique associated subject names, which 564 it is allowed to communicate with. EDHOC provides proof that the 565 other party possesses the private authentication key corresponding 566 to the public authentication key. 568 3.3.3. Authentication Credentials 570 The authentication credentials, CRED_I and CRED_R, contain the public 571 authentication key of the Initiator and the Responder, respectively. 572 The Initiator and the Responder MAY use different types of 573 credentials, e.g. one uses an RPK and the other uses a public key 574 certificate. 576 The credentials CRED_I and CRED_R are signed or MAC:ed (depending on 577 method) by the Initiator and the Responder, respectively, see 578 Section 5.4 and Section 5.3. 580 When the credential is a certificate, CRED_x is an end-entity 581 certificate (i.e. not the certificate chain) encoded as a CBOR bstr. 582 In X.509 certificates, signature keys typically have key usage 583 "digitalSignature" and Diffie-Hellman keys typically have key usage 584 "keyAgreement". 586 To prevent misbinding attacks in systems where an attacker can 587 register public keys without proving knowledge of the private key, 588 SIGMA [SIGMA] enforces a MAC to be calculated over the "Identity", 589 which in case of a X.509 certificate would be the 'subject' and 590 'subjectAltName' fields. EDHOC follows SIGMA by calculating a MAC 591 over the whole certificate. While the SIGMA paper only focuses on 592 the identity, the same principle is true for any information such as 593 policies connected to the public key. 595 When the credential is a COSE_Key, CRED_x is a CBOR map only 596 containing specific fields from the COSE_Key identifying the public 597 key, and optionally the "Identity". CRED_x needs to be defined such 598 that it is identical when generated by Initiator or Responder. The 599 parameters SHALL be encoded in decreasing order with int labels first 600 and text string labels last. 602 If the parties have agreed on an identity besides the public key, the 603 identity is included in the CBOR map with the label "subject name", 604 otherwise the subject name is the empty text string. The public key 605 parameters depend on key type. 607 * For COSE_Keys of type OKP the CBOR map SHALL, except for subject 608 name, only include the parameters 1 (kty), -1 (crv), and -2 609 (x-coordinate). 611 * For COSE_Keys of type EC2 the CBOR map SHALL, except for subject 612 name, only include the parameters 1 (kty), -1 (crv), -2 613 (x-coordinate), and -3 (y-coordinate). 615 An example of CRED_x when the RPK contains an X25519 static Diffie- 616 Hellman key and the parties have agreed on an EUI-64 identity is 617 shown below: 619 CRED_x = { 620 1: 1, 621 -1: 4, 622 -2: h'b1a3e89460e88d3a8d54211dc95f0b90 623 3ff205eb71912d6db8f4af980d2db83a', 624 "subject name" : "42-50-31-FF-EF-37-32-39" 625 } 627 3.3.4. Identification of Credentials 629 ID_CRED_I and ID_CRED_R are identifiers of the public authentication 630 keys of the Initiator and the Responder, respectively. ID_CRED_I and 631 ID_CRED_R do not have any cryptographic purpose in EDHOC. 633 * ID_CRED_R is intended to facilitate for the Initiator to retrieve 634 the Responder's public authentication key. 636 * ID_CRED_I is intended to facilitate for the Responder to retrieve 637 the Initiator's public authentication key. 639 The identifiers ID_CRED_I and ID_CRED_R are COSE header_maps, i.e. 640 CBOR maps containing COSE Common Header Parameters, see Section 3.1 641 of [RFC8152]). In the following we give some examples of COSE 642 header_maps. 644 Raw public keys are most optimally stored as COSE_Key objects and 645 identified with a 'kid' parameter: 647 * ID_CRED_x = { 4 : kid_x }, where kid_x : bstr, for x = I or R. 649 Public key certificates can be identified in different ways. Header 650 parameters for identifying CBOR certificates and X.509 certificates 651 are defined in [I-D.mattsson-cose-cbor-cert-compress] and 652 [I-D.ietf-cose-x509], for example: 654 * by a hash value with the 'c5t' or 'x5t' parameters; 656 - ID_CRED_x = { 34 : COSE_CertHash }, for x = I or R, 658 - ID_CRED_x = { TDB3 : COSE_CertHash }, for x = I or R, 660 * by a URI with the 'c5u' or 'x5u' parameters; 662 - ID_CRED_x = { 35 : uri }, for x = I or R, 664 - ID_CRED_x = { TBD4 : uri }, for x = I or R, 666 * ID_CRED_x MAY contain the actual credential used for 667 authentication, CRED_x. For example, a DER encoded X.509 668 certificate chain can be transported in ID_CRED_x with COSE header 669 parameter x5chain, see Section 2 of [I-D.ietf-cose-x509]. This is 670 typically how certificates are transported within EDHOC. 672 It is RECOMMENDED that ID_CRED_x uniquely identify the public 673 authentication key as the recipient may otherwise have to try several 674 keys. ID_CRED_I and ID_CRED_R are transported in the 'ciphertext', 675 see Section 5.4 and Section 5.3. 677 When ID_CRED_x does not contain the actual credential it may be very 678 short. One byte credential identifiers are realistic in many 679 scenarios as most constrained devices only have a few keys. In cases 680 where a node only has one key, the identifier may even be the empty 681 byte string. 683 3.4. Cipher Suites 685 An EDHOC cipher suite consists of an ordered set of COSE code points 686 from the "COSE Algorithms" and "COSE Elliptic Curves" registries: 688 * EDHOC AEAD algorithm 690 * EDHOC hash algorithm 692 * EDHOC ECDH curve 694 * EDHOC signature algorithm 696 * EDHOC signature algorithm curve 697 * Application AEAD algorithm 699 * Application hash algorithm 701 Each cipher suite is identified with a pre-defined int label. 703 EDHOC can be used with all algorithms and curves defined for COSE. 704 Implementation can either use one of the pre-defined cipher suites 705 (Section 9.1) or use any combination of COSE algorithms to define 706 their own private cipher suite. Private cipher suites can be 707 identified with any of the four values -24, -23, -22, -21. 709 The following cipher suites are for constrained IoT where message 710 overhead is a very important factor: 712 0. ( 10, -16, 4, -8, 6, 10, -16 ) 713 (AES-CCM-16-64-128, SHA-256, X25519, EdDSA, Ed25519, 714 AES-CCM-16-64-128, SHA-256) 716 1. ( 30, -16, 4, -8, 6, 10, -16 ) 717 (AES-CCM-16-128-128, SHA-256, X25519, EdDSA, Ed25519, 718 AES-CCM-16-64-128, SHA-256) 720 2. ( 10, -16, 1, -7, 1, 10, -16 ) 721 (AES-CCM-16-64-128, SHA-256, P-256, ES256, P-256, 722 AES-CCM-16-64-128, SHA-256) 724 3. ( 30, -16, 1, -7, 1, 10, -16 ) 725 (AES-CCM-16-128-128, SHA-256, P-256, ES256, P-256, 726 AES-CCM-16-64-128, SHA-256) 728 The following cipher suite is for general non-constrained 729 applications. It uses very high performance algorithms that also are 730 widely supported: 732 4. ( 1, -16, 4, -7, 1, 1, -16 ) 733 (A128GCM, SHA-256, X25519, ES256, P-256, 734 A128GCM, SHA-256) 736 The following cipher suite is for high security application such as 737 government use and financial applications. It is compatible with the 738 CNSA suite [CNSA]. 740 5. ( 3, -43, 2, -35, 2, 3, -43 ) 741 (A256GCM, SHA-384, P-384, ES384, P-384, 742 A256GCM, SHA-384) 744 The different methods use the same cipher suites, but some algorithms 745 are not used in some methods. The EDHOC signature algorithm and the 746 EDHOC signature algorithm curve are not used in methods without 747 signature authentication. 749 The Initiator needs to have a list of cipher suites it supports in 750 order of preference. The Responder needs to have a list of cipher 751 suites it supports. SUITES_I is a CBOR array containing cipher 752 suites that the Initiator supports. SUITES_I is formatted and 753 processed as detailed in Section 5.2.1 to secure the cipher suite 754 negotation. 756 3.5. Ephemeral Public Keys 758 The ECDH ephemeral public keys are formatted as a COSE_Key of type 759 EC2 or OKP according to Sections 13.1 and 13.2 of [RFC8152], but only 760 the 'x' parameter is included G_X and G_Y. For Elliptic Curve Keys 761 of type EC2, compact representation as per [RFC6090] MAY be used also 762 in the COSE_Key. If the COSE implementation requires an 'y' 763 parameter, any of the possible values of the y-coordinate can be 764 used, see Appendix C of [RFC6090]. COSE [RFC8152] always use compact 765 output for Elliptic Curve Keys of type EC2. 767 3.6. Auxiliary Data 769 In order to reduce round trips and number of messages, and in some 770 cases also streamline processing, certain security applications may 771 be integrated into EDHOC by transporting auxiliary data together with 772 the messages. One example is the transport of third-party 773 authorization information protected outside of EDHOC 774 [I-D.selander-ace-ake-authz]. Another example is the embedding of a 775 certificate enrolment request or a newly issued certificate. 777 EDHOC allows opaque auxiliary data (AD) to be sent in the EDHOC 778 messages. Unprotected Auxiliary Data (AD_1, AD_2) may be sent in 779 message_1 and message_2, respectively. Protected Auxiliary Data 780 (AD_3) may be sent in message_3. 782 Since data carried in AD_1 and AD_2 may not be protected, and the 783 content of AD_3 is available to both the Initiator and the Responder, 784 special considerations need to be made such that the availability of 785 the data a) does not violate security and privacy requirements of the 786 service which uses this data, and b) does not violate the security 787 properties of EDHOC. 789 3.7. Communication of Protocol Features 791 EDHOC allows the communication or negotiation of various protocol 792 features during the execution of the protocol. 794 * The Initiator proposes a cipher suite (see Section 3.4), and the 795 Responder either accepts or rejects, and may make a counter 796 proposal. 798 * The Initiator decides on the correlation parameter corr (see 799 Section 3.2.4). This is typically given by the transport which 800 the Initiator and the Responder have agreed on beforehand. The 801 Responder either accepts or rejects. 803 * The Initiator decides on the method parameter, see Figure 4. The 804 Responder either accepts or rejects. 806 * The Initiator and the Responder decide on the representation of 807 the identifier of their respective credentials, ID_CRED_I and 808 ID_CRED_R. The decision is reflected by the label used in the 809 CBOR map, see for example Section 3.3.4. 811 Editor's note: This section needs to be aligned with Appendix C. 813 4. Key Derivation 815 EDHOC uses Extract-and-Expand [RFC5869] with the EDHOC hash algorithm 816 in the selected cipher suite to derive keys. Extract is used to 817 derive fixed-length uniformly pseudorandom keys (PRK) from ECDH 818 shared secrets. Expand is used to derive additional output keying 819 material (OKM) from the PRKs. The PRKs are derived using Extract. 821 PRK = Extract( salt, IKM ) 823 If the EDHOC hash algorithm is SHA-2, then Extract( salt, IKM ) = 824 HKDF-Extract( salt, IKM ) [RFC5869]. If the EDHOC hash algorithm is 825 SHAKE128, then Extract( salt, IKM ) = KMAC128( salt, IKM, 256, "" ). 826 If the EDHOC hash algorithm is SHAKE256, then Extract( salt, IKM ) = 827 KMAC256( salt, IKM, 512, "" ). 829 PRK_2e is used to derive a keystream to encrypt message_2. PRK_3e2m 830 is used to derive keys and IVs to produce a MAC in message_2 and to 831 encrypt message_3. PRK_4x3m is used to derive keys and IVs to 832 produce a MAC in message_3 and to derive application specific data. 834 PRK_2e is derived with the following input: 836 * The salt SHALL be the empty byte string. Note that [RFC5869] 837 specifies that if the salt is not provided, it is set to a string 838 of zeros (see Section 2.2 of [RFC5869]). For implementation 839 purposes, not providing the salt is the same as setting the salt 840 to the empty byte string. 842 * The input keying material (IKM) SHALL be the ECDH shared secret 843 G_XY (calculated from G_X and Y or G_Y and X) as defined in 844 Section 12.4.1 of [RFC8152]. 846 Example: Assuming the use of SHA-256 the extract phase of HKDF 847 produces PRK_2e as follows: 849 PRK_2e = HMAC-SHA-256( salt, G_XY ) 851 where salt = 0x (the empty byte string). 853 The pseudorandom keys PRK_3e2m and PRK_4x3m are defined as follow: 855 * If the Responder authenticates with a static Diffie-Hellman key, 856 then PRK_3e2m = Extract( PRK_2e, G_RX ), where G_RX is the ECDH 857 shared secret calculated from G_R and X, or G_X and R, else 858 PRK_3e2m = PRK_2e. 860 * If the Initiator authenticates with a static Diffie-Hellman key, 861 then PRK_4x3m = Extract( PRK_3e2m, G_IY ), where G_IY is the ECDH 862 shared secret calculated from G_I and Y, or G_Y and I, else 863 PRK_4x3m = PRK_3e2m. 865 Example: Assuming the use of curve25519, the ECDH shared secrets 866 G_XY, G_RX, and G_IY are the outputs of the X25519 function 867 [RFC7748]: 869 G_XY = X25519( Y, G_X ) = X25519( X, G_Y ) 871 The keys and IVs used in EDHOC are derived from PRK using Expand 872 [RFC5869] where the EDHOC-KDF is instantiated with the EDHOC AEAD 873 algorithm in the selected cipher suite. 875 OKM = EDHOC-KDF( PRK, transcript_hash, label, length ) 876 = Expand( PRK, info, length ) 878 where info is the CBOR encoding of 879 info = [ 880 edhoc_aead_id : int / tstr, 881 transcript_hash : bstr, 882 label : tstr, 883 length : uint 884 ] 886 where 888 * edhoc_aead_id is an int or tstr containing the algorithm 889 identifier of the EDHOC AEAD algorithm in the selected cipher 890 suite encoded as defined in [RFC8152]. Note that a single fixed 891 edhoc_aead_id is used in all invocations of EDHOC-KDF, including 892 the derivation of KEYSTREAM_2 and invocations of the EDHOC- 893 Exporter. 895 * transcript_hash is a bstr set to one of the transcript hashes 896 TH_2, TH_3, or TH_4 as defined in Sections 5.3.1, 5.4.1, and 4.1. 898 * label is a tstr set to the name of the derived key or IV, i.e. 899 "K_2m", "IV_2m", "KEYSTREAM_2", "K_3m", "IV_3m", "K_3ae", or 900 "IV_3ae". 902 * length is the length of output keying material (OKM) in bytes 904 If the EDHOC hash algorithm is SHA-2, then Expand( PRK, info, length 905 ) = HKDF-Expand( PRK, info, length ) [RFC5869]. If the EDHOC hash 906 algorithm is SHAKE128, then Expand( PRK, info, length ) = KMAC128( 907 PRK, info, L, "" ). If the EDHOC hash algorithm is SHAKE256, then 908 Expand( PRK, info, length ) = KMAC256( PRK, info, L, "" ). 910 KEYSTREAM_2 are derived using the transcript hash TH_2 and the 911 pseudorandom key PRK_2e. K_2m and IV_2m are derived using the 912 transcript hash TH_2 and the pseudorandom key PRK_3e2m. K_3ae and 913 IV_3ae are derived using the transcript hash TH_3 and the 914 pseudorandom key PRK_3e2m. K_3m and IV_3m are derived using the 915 transcript hash TH_3 and the pseudorandom key PRK_4x3m. IVs are only 916 used if the EDHOC AEAD algorithm uses IVs. 918 4.1. EDHOC-Exporter Interface 920 Application keys and other application specific data can be derived 921 using the EDHOC-Exporter interface defined as: 923 EDHOC-Exporter(label, length) 924 = EDHOC-KDF(PRK_4x3m, TH_4, label, length) 926 where label is a tstr defined by the application and length is a uint 927 defined by the application. The label SHALL be different for each 928 different exporter value. The transcript hash TH_4 is a CBOR encoded 929 bstr and the input to the hash function is a CBOR Sequence. 931 TH_4 = H( TH_3, CIPHERTEXT_3 ) 933 where H() is the hash function in the selected cipher suite. Example 934 use of the EDHOC-Exporter is given in Sections 7.2.1. 936 To provide forward secrecy in an even more efficient way than re- 937 running EDHOC, EDHOC provides the function EDHOC-KeyUpdate. When 938 EDHOC-KeyUpdate is called the old PRK_4x3m is deleted and the new 939 PRk_4x3m is calculated as a "hash" of the old key using the Extract 940 function as illustrated by the following pseudocode: 942 EDHOC-KeyUpdate( nonce ): 943 PRK_4x3m = Extract( nonce, PRK_4x3m ) 945 5. Message Formatting and Processing 947 This section specifies formatting of the messages and processing 948 steps. Error messages are specified in Section 6. 950 An EDHOC message is encoded as a sequence of CBOR data (CBOR 951 Sequence, [RFC8742]). Additional optimizations are made to reduce 952 message overhead. 954 While EDHOC uses the COSE_Key, COSE_Sign1, and COSE_Encrypt0 955 structures, only a subset of the parameters is included in the EDHOC 956 messages. The unprotected COSE header in COSE_Sign1, and 957 COSE_Encrypt0 (not included in the EDHOC message) MAY contain 958 parameters (e.g. 'alg'). 960 5.1. Encoding of bstr_identifier 962 Byte strings are encoded in CBOR as two or more bytes, whereas 963 integers in the interval -24 to 23 are encoded in CBOR as one byte. 965 bstr_identifier is a special encoding of byte strings, used 966 throughout the protocol to enable the encoding of the shortest byte 967 strings as integers that only require one byte of CBOR encoding. 969 The bstr_identifier encoding is defined as follows: Byte strings in 970 the interval h'00' to h'2f' are encoded as the corresponding integer 971 minus 24, which are all represented by one byte CBOR ints. Other 972 byte strings are encoded as CBOR byte strings. 974 For example, the byte string h'59e9' encoded as a bstr_identifier is 975 equal to h'59e9', while the byte string h'2a' is encoded as the 976 integer 18. 978 The CDDL definition of the bstr_identifier is given below: 980 bstr_identifier = bstr / int 982 Note that, despite what could be interpreted by the CDDL definition 983 only, bstr_identifier once decoded are always byte strings. 985 5.2. EDHOC Message 1 987 5.2.1. Formatting of Message 1 989 message_1 SHALL be a CBOR Sequence (see Appendix A.1) as defined 990 below 992 message_1 = ( 993 METHOD_CORR : int, 994 SUITES_I : [ selected : suite, supported : 2* suite ] / suite, 995 G_X : bstr, 996 C_I : bstr_identifier, 997 ? AD_1 : bstr, 998 ) 1000 suite = int 1002 where: 1004 * METHOD_CORR = 4 * method + corr, where method = 0, 1, 2, or 3 (see 1005 Figure 4) and the correlation parameter corr is chosen based on 1006 the transport and determines which connection identifiers that are 1007 omitted (see Section 3.2.4). 1009 * SUITES_I - cipher suites which the Initiator supports in order of 1010 (decreasing) preference. The list of supported cipher suites can 1011 be truncated at the end, as is detailed in the processing steps 1012 below. One of the supported cipher suites is selected. The 1013 selected suite is the first suite in the SUITES_I CBOR array. If 1014 a single supported cipher suite is conveyed then that cipher suite 1015 is selected and the selected cipher suite is encoded as an int 1016 instead of an array. 1018 * G_X - the ephemeral public key of the Initiator 1020 * C_I - variable length connection identifier, encoded as a 1021 bstr_identifier (see Section 5.1). 1023 * AD_1 - bstr containing unprotected opaque auxiliary data 1025 5.2.2. Initiator Processing of Message 1 1027 The Initiator SHALL compose message_1 as follows: 1029 * The supported cipher suites and the order of preference MUST NOT 1030 be changed based on previous error messages. However, the list 1031 SUITES_I sent to the Responder MAY be truncated such that cipher 1032 suites which are the least preferred are omitted. The amount of 1033 truncation MAY be changed between sessions, e.g. based on previous 1034 error messages (see next bullet), but all cipher suites which are 1035 more preferred than the least preferred cipher suite in the list 1036 MUST be included in the list. 1038 * Determine the cipher suite to use with the Responder in message_1. 1039 If the Initiator previously received from the Responder an error 1040 message to a message_1 with diagnostic payload identifying a 1041 cipher suite that the Initiator supports, then the Initiator SHALL 1042 use that cipher suite. Otherwise the first supported (i.e. the 1043 most preferred) cipher suite in SUITES_I MUST be used. 1045 * Generate an ephemeral ECDH key pair as specified in Section 5 of 1046 [SP-800-56A] using the curve in the selected cipher suite and 1047 format it as a COSE_Key. Let G_X be the 'x' parameter of the 1048 COSE_Key. 1050 * Choose a connection identifier C_I and store it for the length of 1051 the protocol. 1053 * Encode message_1 as a sequence of CBOR encoded data items as 1054 specified in Section 5.2.1 1056 5.2.3. Responder Processing of Message 1 1058 The Responder SHALL process message_1 as follows: 1060 * Decode message_1 (see Appendix A.1). 1062 * Verify that the selected cipher suite is supported and that no 1063 prior cipher suite in SUITES_I is supported. 1065 * Pass AD_1 to the security application. 1067 If any verification step fails, the Responder MUST send an EDHOC 1068 error message back, formatted as defined in Section 6, and the 1069 protocol MUST be discontinued. If the Responder does not support the 1070 selected cipher suite, then SUITES_R MUST include one or more 1071 supported cipher suites. If the Responder does not support the 1072 selected cipher suite, but supports another cipher suite in SUITES_I, 1073 then SUITES_R MUST include the first supported cipher suite in 1074 SUITES_I. 1076 5.3. EDHOC Message 2 1078 5.3.1. Formatting of Message 2 1080 message_2 and data_2 SHALL be CBOR Sequences (see Appendix A.1) as 1081 defined below 1083 message_2 = ( 1084 data_2, 1085 CIPHERTEXT_2 : bstr, 1086 ) 1088 data_2 = ( 1089 ? C_I : bstr_identifier, 1090 G_Y : bstr, 1091 C_R : bstr_identifier, 1092 ) 1094 where: 1096 * G_Y - the ephemeral public key of the Responder 1098 * C_R - variable length connection identifier, encoded as a 1099 bstr_identifier (see Section 5.1). 1101 5.3.2. Responder Processing of Message 2 1103 The Responder SHALL compose message_2 as follows: 1105 * If corr (METHOD_CORR mod 4) equals 1 or 3, C_I is omitted, 1106 otherwise C_I is not omitted. 1108 * Generate an ephemeral ECDH key pair as specified in Section 5 of 1109 [SP-800-56A] using the curve in the selected cipher suite and 1110 format it as a COSE_Key. Let G_Y be the 'x' parameter of the 1111 COSE_Key. 1113 * Choose a connection identifier C_R and store it for the length of 1114 the protocol. 1116 * Compute the transcript hash TH_2 = H(message_1, data_2) where H() 1117 is the hash function in the selected cipher suite. The transcript 1118 hash TH_2 is a CBOR encoded bstr and the input to the hash 1119 function is a CBOR Sequence. 1121 * Compute an inner COSE_Encrypt0 as defined in Section 5.3 of 1122 [RFC8152], with the EDHOC AEAD algorithm in the selected cipher 1123 suite, K_2m, IV_2m, and the following parameters: 1125 - protected = << ID_CRED_R >> 1127 o ID_CRED_R - identifier to facilitate retrieval of CRED_R, 1128 see Section 3.3.4 1130 - external_aad = << TH_2, CRED_R, ? AD_2 >> 1132 o CRED_R - bstr containing the credential of the Responder, 1133 see Section 3.3.4. 1135 o AD_2 = bstr containing opaque unprotected auxiliary data 1137 - plaintext = h'' 1139 COSE constructs the input to the AEAD [RFC5116] as follows: 1141 - Key K = EDHOC-KDF( PRK_3e2m, TH_2, "K_2m", length ) 1143 - Nonce N = EDHOC-KDF( PRK_3e2m, TH_2, "IV_2m", length ) 1145 - Plaintext P = 0x (the empty string) 1147 - Associated data A = 1149 [ "Encrypt0", << ID_CRED_R >>, << TH_2, CRED_R, ? AD_2 >> ] 1151 MAC_2 is the 'ciphertext' of the inner COSE_Encrypt0. 1153 * If the Responder authenticates with a static Diffie-Hellman key 1154 (method equals 1 or 3), then Signature_or_MAC_2 is MAC_2. If the 1155 Responder authenticates with a signature key (method equals 0 or 1156 2), then Signature_or_MAC_2 is the 'signature' of a COSE_Sign1 1157 object as defined in Section 4.4 of [RFC8152] using the signature 1158 algorithm in the selected cipher suite, the private authentication 1159 key of the Responder, and the following parameters: 1161 - protected = << ID_CRED_R >> 1163 - external_aad = << TH_2, CRED_R, ? AD_2 >> 1164 - payload = MAC_2 1166 COSE constructs the input to the Signature Algorithm as: 1168 - The key is the private authentication key of the Responder. 1170 - The message M to be signed = 1172 [ "Signature1", << ID_CRED_R >>, << TH_2, CRED_R, ? AD_2 >>, 1173 MAC_2 ] 1175 * CIPHERTEXT_2 is encrypted by using the Expand function as a binary 1176 additive stream cipher. 1178 - plaintext = ( ID_CRED_R / bstr_identifier, Signature_or_MAC_2, 1179 ? AD_2 ) 1181 o Note that if ID_CRED_R contains a single 'kid' parameter, 1182 i.e., ID_CRED_R = { 4 : kid_R }, only the byte string kid_R 1183 is conveyed in the plaintext encoded as a bstr_identifier, 1184 see Section 3.3.4 and Section 5.1. 1186 - CIPHERTEXT_2 = plaintext XOR KEYSTREAM_2 1188 * Encode message_2 as a sequence of CBOR encoded data items as 1189 specified in Section 5.3.1. 1191 5.3.3. Initiator Processing of Message 2 1193 The Initiator SHALL process message_2 as follows: 1195 * Decode message_2 (see Appendix A.1). 1197 * Retrieve the protocol state using the connection identifier C_I 1198 and/or other external information such as the CoAP Token and the 1199 5-tuple. 1201 * Decrypt CIPHERTEXT_2, see Section 5.3.2. 1203 * Verify that the identity of the Responder is an allowed identity 1204 for this connection, see Section 3.3. 1206 * Verify Signature_or_MAC_2 using the algorithm in the selected 1207 cipher suite. The verification process depends on the method, see 1208 Section 5.3.2. 1210 * Pass AD_2 to the security application. 1212 If any verification step fails, the Initiator MUST send an EDHOC 1213 error message back, formatted as defined in Section 6, and the 1214 protocol MUST be discontinued. 1216 5.4. EDHOC Message 3 1218 5.4.1. Formatting of Message 3 1220 message_3 and data_3 SHALL be CBOR Sequences (see Appendix A.1) as 1221 defined below 1223 message_3 = ( 1224 data_3, 1225 CIPHERTEXT_3 : bstr, 1226 ) 1228 data_3 = ( 1229 ? C_R : bstr_identifier, 1230 ) 1232 5.4.2. Initiator Processing of Message 3 1234 The Initiator SHALL compose message_3 as follows: 1236 * If corr (METHOD_CORR mod 4) equals 2 or 3, C_R is omitted, 1237 otherwise C_R is not omitted. 1239 * Compute the transcript hash TH_3 = H(TH_2 , CIPHERTEXT_2, data_3) 1240 where H() is the hash function in the the selected cipher suite. 1241 The transcript hash TH_3 is a CBOR encoded bstr and the input to 1242 the hash function is a CBOR Sequence. 1244 * Compute an inner COSE_Encrypt0 as defined in Section 5.3 of 1245 [RFC8152], with the EDHOC AEAD algorithm in the selected cipher 1246 suite, K_3m, IV_3m, and the following parameters: 1248 - protected = << ID_CRED_I >> 1250 o ID_CRED_I - identifier to facilitate retrieval of CRED_I, 1251 see Section 3.3.4 1253 - external_aad = << TH_3, CRED_I, ? AD_3 >> 1255 o CRED_I - bstr containing the credential of the Initiator, 1256 see Section 3.3.4. 1258 o AD_3 = bstr containing opaque protected auxiliary data 1260 - plaintext = h'' 1262 COSE constructs the input to the AEAD [RFC5116] as follows: 1264 - Key K = EDHOC-KDF( PRK_4x3m, TH_3, "K_3m", length ) 1266 - Nonce N = EDHOC-KDF( PRK_4x3m, TH_3, "IV_3m", length ) 1268 - Plaintext P = 0x (the empty string) 1270 - Associated data A = 1272 [ "Encrypt0", << ID_CRED_I >>, << TH_3, CRED_I, ? AD_3 >> ] 1274 MAC_3 is the 'ciphertext' of the inner COSE_Encrypt0. 1276 * If the Initiator authenticates with a static Diffie-Hellman key 1277 (method equals 2 or 3), then Signature_or_MAC_3 is MAC_3. If the 1278 Initiator authenticates with a signature key (method equals 0 or 1279 1), then Signature_or_MAC_3 is the 'signature' of a COSE_Sign1 1280 object as defined in Section 4.4 of [RFC8152] using the signature 1281 algorithm in the selected cipher suite, the private authentication 1282 key of the Initiator, and the following parameters: 1284 - protected = << ID_CRED_I >> 1286 - external_aad = << TH_3, CRED_I, ? AD_3 >> 1288 - payload = MAC_3 1290 COSE constructs the input to the Signature Algorithm as: 1292 - The key is the private authentication key of the Initiator. 1294 - The message M to be signed = 1296 [ "Signature1", << ID_CRED_I >>, << TH_3, CRED_I, ? AD_3 >>, 1297 MAC_3 ] 1299 * Compute an outer COSE_Encrypt0 as defined in Section 5.3 of 1300 [RFC8152], with the EDHOC AEAD algorithm in the selected cipher 1301 suite, K_3ae, IV_3ae, and the following parameters. The protected 1302 header SHALL be empty. 1304 - external_aad = TH_3 1306 - plaintext = ( ID_CRED_I / bstr_identifier, Signature_or_MAC_3, 1307 ? AD_3 ) 1308 o Note that if ID_CRED_I contains a single 'kid' parameter, 1309 i.e., ID_CRED_I = { 4 : kid_I }, only the byte string kid_I 1310 is conveyed in the plaintext encoded as a bstr_identifier, 1311 see Section 3.3.4 and Section 5.1. 1313 COSE constructs the input to the AEAD [RFC5116] as follows: 1315 - Key K = EDHOC-KDF( PRK_3e2m, TH_3, "K_3ae", length ) 1317 - Nonce N = EDHOC-KDF( PRK_3e2m, TH_3, "IV_3ae", length ) 1319 - Plaintext P = ( ID_CRED_I / bstr_identifier, 1320 Signature_or_MAC_3, ? AD_3 ) 1322 - Associated data A = [ "Encrypt0", h'', TH_3 ] 1324 CIPHERTEXT_3 is the 'ciphertext' of the outer COSE_Encrypt0. 1326 * Encode message_3 as a sequence of CBOR encoded data items as 1327 specified in Section 5.4.1. 1329 Pass the connection identifiers (C_I, C_R) and the application 1330 algorithms in the selected cipher suite to the application. The 1331 application can now derive application keys using the EDHOC-Exporter 1332 interface. 1334 After sending message_3, the Initiator is assured that no other party 1335 than the Responder can compute the key PRK_4x3m (implicit key 1336 authentication). The Initiator does however not know that the 1337 Responder has actually computed the key PRK_4x3m. While the 1338 Initiator can securely send protected application data, the Initiator 1339 SHOULD NOT permanently store the keying material PRK_4x3m and TH_4 1340 until the Initiator is assured that the Responder has actually 1341 computed the key PRK_4x3m (explicit key confirmation). Explicit key 1342 confirmation is e.g. assured when the Initiator has verified an 1343 OSCORE message or message_4 from the Responder. 1345 5.4.3. Responder Processing of Message 3 1347 The Responder SHALL process message_3 as follows: 1349 * Decode message_3 (see Appendix A.1). 1351 * Retrieve the protocol state using the connection identifier C_R 1352 and/or other external information such as the CoAP Token and the 1353 5-tuple. 1355 * Decrypt and verify the outer COSE_Encrypt0 as defined in 1356 Section 5.3 of [RFC8152], with the EDHOC AEAD algorithm in the 1357 selected cipher suite, K_3ae, and IV_3ae. 1359 * Verify that the identity of the Initiator is an allowed identity 1360 for this connection, see Section 3.3. 1362 * Verify Signature_or_MAC_3 using the algorithm in the selected 1363 cipher suite. The verification process depends on the method, see 1364 Section 5.4.2. 1366 * Pass AD_3, the connection identifiers (C_I, C_R), and the 1367 application algorithms in the selected cipher suite to the 1368 security application. The application can now derive application 1369 keys using the EDHOC-Exporter interface. 1371 If any verification step fails, the Responder MUST send an EDHOC 1372 error message back, formatted as defined in Section 6, and the 1373 protocol MUST be discontinued. 1375 After verifying message_3, the Responder is assured that the 1376 Initiator has calculated the key PRK_4x3m (explicit key confirmation) 1377 and that no other party than the Responder can compute the key. The 1378 Responder can securely send protected application data and store the 1379 keying material PRK_4x3m and TH_4. 1381 6. Error Handling 1383 6.1. EDHOC Error Message 1385 This section defines a message format for the EDHOC error message. 1387 An EDHOC error message can be sent by either endpoint as a reply to 1388 any non-error EDHOC message. How errors at the EDHOC layer are 1389 transported depends on lower layers, which need to enable error 1390 messages to be sent and processed as intended. 1392 EDHOC errors sent as successful messages on the underlying layer can 1393 avoid issues created by usage of cross protocol proxies (e.g. UDP to 1394 TCP). 1396 All error messages in EDHOC are fatal. After sending an error 1397 message, the sender MUST discontinue the protocol. The receiver 1398 SHOULD treat an error message as an indication that the other party 1399 likely has discontinued the protocol. But as the error message is 1400 not authenticated, a received error messages might also have been 1401 sent by an attacker and the receiver MAY therefore try to continue 1402 the protocol. 1404 error SHALL be a CBOR Sequence (see Appendix A.1) as defined below 1406 error = ( 1407 ? C_x : bstr_identifier, 1408 DIAG_MSG : tstr, 1409 ? SUITES_R : [ supported : 2* suite ] / suite, 1410 ) 1412 where: 1414 * C_x - (optional) variable length connection identifier, encoded as 1415 a bstr_identifier (see Section 5.1). If error is sent by the 1416 Responder and corr (METHOD_CORR mod 4) equals 0 or 2 then C_x is 1417 set to C_I, else if error is sent by the Initiator and corr 1418 (METHOD_CORR mod 4) equals 0 or 1 then C_x is set to C_R, else C_x 1419 is omitted. 1421 * DIAG_MSG - text string containing the diagnostic message in 1422 English. MUST NOT be the empty string unless the error message 1423 contains SUITES_R. 1425 * SUITES_R - (optional) cipher suites from SUITES_I or the EDHOC 1426 cipher suites registry that the Responder supports. SUITES_R MUST 1427 only be included in replies to message_1. If a single supported 1428 cipher suite is conveyed then the supported cipher suite is 1429 encoded as an int instead of an array. 1431 After receiving SUITES_R, the Initiator can determine which selected 1432 cipher suite to use for the next EDHOC run with the Responder. If 1433 the Initiator intends to contact the Responder in the future, the 1434 Initiator SHOULD remember which selected cipher suite to use until 1435 the next message_1 has been sent, otherwise the Initiator and 1436 Responder will likely run into an infinite loop. After a successful 1437 run of EDHOC, the Initiator MAY remember the selected cipher suite to 1438 use in future EDHOC runs. Note that if the Initiator or Responder is 1439 updated with new cipher suite policies, any cached information may be 1440 outdated. 1442 Error messages without SUITES_R MUST contain a human-readable 1443 diagnostic message DIAG_MSG written in English, explaning the error 1444 situation. The diagnostic text message is mainly intended for 1445 software engineers that during debugging need to interpret it in the 1446 context of the EDHOC specification. The diagnostic message SHOULD be 1447 be provided to the calling application where they SHOULD be logged. 1448 Error messages with SUITES_R MAY use the empty string as the 1449 diagnostic message. The DIAG_MSG text string is mandatory and 1450 characteristic for error messages, which enables the receiver to 1451 distinguish between a normal message and an error message. 1453 6.1.1. Example Use of EDHOC Error Message with SUITES_R 1455 Assume that the Initiator supports the five cipher suites 5, 6, 7, 8, 1456 and 9 in decreasing order of preference. Figures 5 and 6 show 1457 examples of how the Initiator can truncate SUITES_I and how SUITES_R 1458 is used by Responders to give the Initiator information about the 1459 cipher suites that the Responder supports. 1461 In the first example (Figure 5), the Responder supports cipher suite 1462 6 but not the initially selected cipher suite 5. 1464 Initiator Responder 1465 | METHOD_CORR, SUITES_I = 5, G_X, C_I, AD_1 | 1466 +------------------------------------------------------------------>| 1467 | message_1 | 1468 | | 1469 | C_I, DIAG_MSG, SUITES_R = 6 | 1470 |<------------------------------------------------------------------+ 1471 | error | 1472 | | 1473 | METHOD_CORR, SUITES_I = [6, 5, 6], G_X, C_I, AD_1 | 1474 +------------------------------------------------------------------>| 1475 | message_1 | 1477 Figure 5: Example of Responder supporting suite 6 but not suite 5. 1479 In the second example (Figure 6), the Responder supports cipher 1480 suites 8 and 9 but not the more preferred (by the Initiator) cipher 1481 suites 5, 6 or 7. To illustrate the negotiation mechanics we let the 1482 Initiator make a guess that the Responder supports suite 6 but not 1483 suite 5. Since the Responder supports neither 5 nor 6, it responds 1484 with an error and SUITES_R, after which the Initiator can select a 1485 better suite. The order of cipher suites in SUITES_R does not 1486 matter. (If the Responder had supported suite 5, it would include it 1487 in SUITES_R of the response, and it would in that case be the 1488 selected suite in the second message_1.) 1489 Initiator Responder 1490 | METHOD_CORR, SUITES_I = [6, 5, 6], G_X, C_I, AD_1 | 1491 +------------------------------------------------------------------>| 1492 | message_1 | 1493 | | 1494 | C_I, DIAG_MSG, SUITES_R = [9, 8] | 1495 |<------------------------------------------------------------------+ 1496 | error | 1497 | | 1498 | METHOD_CORR, SUITES_I = [8, 5, 6, 7, 8], G_X, C_I, AD_1 | 1499 +------------------------------------------------------------------>| 1500 | message_1 | 1502 Figure 6: Example of Responder supporting suites 8 and 9 but not 1503 5, 6 or 7. 1505 Note that the Initiator's list of supported cipher suites and order 1506 of preference is fixed (see Section 5.2.1 and Section 5.2.2). 1507 Furthermore, the Responder shall only accept message_1 if the 1508 selected cipher suite is the first cipher suite in SUITES_I that the 1509 Responder supports (see Section 5.2.3). Following this procedure 1510 ensures that the selected cipher suite is the most preferred (by the 1511 Initiator) cipher suite supported by both parties. 1513 If the selected cipher suite is not the first cipher suite which the 1514 Responder supports in SUITES_I received in message_1, then Responder 1515 MUST discontinue the protocol, see Section 5.2.3. If SUITES_I in 1516 message_1 is manipulated then the integrity verification of message_2 1517 containing the transcript hash TH_2 = H( message_1, data_2 ) will 1518 fail and the Initiator will discontinue the protocol. 1520 7. Transferring EDHOC and Deriving an OSCORE Context 1522 7.1. EDHOC Message 4 1524 This section specifies message_4 which is OPTIONAL to support. Key 1525 confirmation is normally provided by sending an application message 1526 from the Responder to the Initiator protected with a key derived with 1527 the EDHOC-Exporter, e.g., using OSCORE (see Section 7.2.1). In 1528 deployments where no protected application message is sent from the 1529 Responder to the Initiator, the Responder MUST send message_4. Two 1530 examples of such deployments: 1532 1. When EDHOC is only used for authentication and no application 1533 data is sent. 1535 2. When application data is only sent from the Initiator to the 1536 Responder. 1538 Further considerations are provided in Appendix C. 1540 7.1.1. Formatting of Message 4 1542 message_4 and data_4 SHALL be CBOR Sequences (see Appendix A.1) as 1543 defined below 1545 message_4 = ( 1546 data_4, 1547 MAC_4 : bstr, 1548 ) 1550 data_4 = ( 1551 ? C_I : bstr_identifier, 1552 ) 1554 7.1.2. Responder Processing of Message 4 1556 The Responder SHALL compose message_4 as follows: 1558 * If corr (METHOD_CORR mod 4) equals 1 or 3, C_I is omitted, 1559 otherwise C_I is not omitted. 1561 * Compute an inner COSE_Encrypt0 as defined in Section 5.3 of 1562 [RFC8152], with the EDHOC AEAD algorithm in the selected cipher 1563 suite, and the following parameters: 1565 - protected = h'' 1567 - external_aad = << TH_4 >> 1569 - plaintext = h'' 1571 COSE constructs the input to the AEAD [RFC5116] as follows: 1573 - Key K = EDHOC-Exporter( "EDHOC_message_4_Key", length ) 1575 - Nonce N = EDHOC-Exporter( "EDHOC_message_4_Nonce", length ) 1577 - Plaintext P = 0x (the empty string) 1579 - Associated data A = 1581 [ "Encrypt0", h'', << TH_4 >> ] 1583 MAC_4 is the 'ciphertext' of the COSE_Encrypt0. 1585 * Encode message_4 as a sequence of CBOR encoded data items as 1586 specified in Section 7.1.1. 1588 7.1.3. Initiator Processing of Message 4 1590 The Initiator SHALL process message_4 as follows: 1592 * Decode message_4 (see Appendix A.1). 1594 * Retrieve the protocol state using the connection identifier C_I 1595 and/or other external information such as the CoAP Token and the 1596 5-tuple. 1598 * Verify MAC_4 as defined in Section 5.3 of [RFC8152], with the 1599 EDHOC AEAD algorithm in the selected cipher suite, and the 1600 parameters defined in Section 7.1.2. 1602 If any verification step fails the Initiator MUST send an EDHOC error 1603 message back, formatted as defined in Section 6, and the protocol 1604 MUST be discontinued. 1606 7.2. Transferring EDHOC in CoAP 1608 It is recommended to transport EDHOC as an exchange of CoAP [RFC7252] 1609 messages. CoAP is a reliable transport that can preserve packet 1610 ordering and handle message duplication. CoAP can also perform 1611 fragmentation and protect against denial of service attacks. It is 1612 recommended to carry the EDHOC messages in Confirmable messages, 1613 especially if fragmentation is used. 1615 By default, the CoAP client is the Initiator and the CoAP server is 1616 the Responder, but the roles SHOULD be chosen to protect the most 1617 sensitive identity, see Section 8. By default, EDHOC is transferred 1618 in POST requests and 2.04 (Changed) responses to the Uri-Path: 1619 "/.well-known/edhoc", but an application may define its own path that 1620 can be discovered e.g. using resource directory 1621 [I-D.ietf-core-resource-directory]. 1623 By default, the message flow is as follows: EDHOC message_1 is sent 1624 in the payload of a POST request from the client to the server's 1625 resource for EDHOC. EDHOC message_2 or the EDHOC error message is 1626 sent from the server to the client in the payload of a 2.04 (Changed) 1627 response. EDHOC message_3 or the EDHOC error message is sent from 1628 the client to the server's resource in the payload of a POST request. 1629 If needed, an EDHOC error message is sent from the server to the 1630 client in the payload of a 2.04 (Changed) response. Alternatively, 1631 if EDHOC message_4 is used, it is sent from the server to the client 1632 in the payload of a 2.04 (Changed) response analogously to message_2. 1634 An example of a successful EDHOC exchange using CoAP is shown in 1635 Figure 7. In this case the CoAP Token enables the Initiator to 1636 correlate message_1 and message_2 so the correlation parameter corr = 1637 1. 1639 Client Server 1640 | | 1641 +--------->| Header: POST (Code=0.02) 1642 | POST | Uri-Path: "/.well-known/edhoc" 1643 | | Content-Format: application/edhoc 1644 | | Payload: EDHOC message_1 1645 | | 1646 |<---------+ Header: 2.04 Changed 1647 | 2.04 | Content-Format: application/edhoc 1648 | | Payload: EDHOC message_2 1649 | | 1650 +--------->| Header: POST (Code=0.02) 1651 | POST | Uri-Path: "/.well-known/edhoc" 1652 | | Content-Format: application/edhoc 1653 | | Payload: EDHOC message_3 1654 | | 1655 |<---------+ Header: 2.04 Changed 1656 | 2.04 | 1657 | | 1659 Figure 7: Transferring EDHOC in CoAP when the Initiator is CoAP 1660 Client 1662 The exchange in Figure 7 protects the client identity against active 1663 attackers and the server identity against passive attackers. An 1664 alternative exchange that protects the server identity against active 1665 attackers and the client identity against passive attackers is shown 1666 in Figure 8. In this case the CoAP Token enables the Responder to 1667 correlate message_2 and message_3 so the correlation parameter corr = 1668 2. If EDHOC message_4 is used, it is transported with CoAP in the 1669 payload of a POST request with a 2.04 (Changed) response. 1671 Client Server 1672 | | 1673 +--------->| Header: POST (Code=0.02) 1674 | POST | Uri-Path: "/.well-known/edhoc" 1675 | | 1676 |<---------+ Header: 2.04 Changed 1677 | 2.04 | Content-Format: application/edhoc 1678 | | Payload: EDHOC message_1 1679 | | 1680 +--------->| Header: POST (Code=0.02) 1681 | POST | Uri-Path: "/.well-known/edhoc" 1682 | | Content-Format: application/edhoc 1683 | | Payload: EDHOC message_2 1684 | | 1685 |<---------+ Header: 2.04 Changed 1686 | 2.04 | Content-Format: application/edhoc 1687 | | Payload: EDHOC message_3 1688 | | 1690 Figure 8: Transferring EDHOC in CoAP when the Initiator is CoAP 1691 Server 1693 To protect against denial-of-service attacks, the CoAP server MAY 1694 respond to the first POST request with a 4.01 (Unauthorized) 1695 containing an Echo option [I-D.ietf-core-echo-request-tag]. This 1696 forces the initiator to demonstrate its reachability at its apparent 1697 network address. If message fragmentation is needed, the EDHOC 1698 messages may be fragmented using the CoAP Block-Wise Transfer 1699 mechanism [RFC7959]. 1701 7.2.1. Deriving an OSCORE Context from EDHOC 1703 When EDHOC is used to derive parameters for OSCORE [RFC8613], the 1704 parties make sure that the EDHOC connection identifiers are unique, 1705 i.e. C_R MUST NOT be equal to C_I. The CoAP client and server MUST 1706 be able to retrieve the OSCORE protocol state using its chosen 1707 connection identifier and optionally other information such as the 1708 5-tuple. In case that the CoAP client is the Initiator and the CoAP 1709 server is the Responder: 1711 * The client's OSCORE Sender ID is C_R and the server's OSCORE 1712 Sender ID is C_I, as defined in this document 1714 * The AEAD Algorithm and the hash algorithm are the application AEAD 1715 and hash algorithms in the selected cipher suite. 1717 * The Master Secret and Master Salt are derived as follows. By 1718 default key_length is the key length (in bytes) of the application 1719 AEAD Algorithm and salt_length is 8 bytes. The Intiator and 1720 Responder MAY agree out-of-band on a longer key_length than the 1721 default and a different salt_length. 1723 Master Secret = EDHOC-Exporter( "OSCORE Master Secret", key_length ) 1724 Master Salt = EDHOC-Exporter( "OSCORE Master Salt", salt_length ) 1726 7.2.2. Error Messages 1728 Errors messages to EDHOC messages transported over CoAP SHOULD be 1729 sent as successful requests and responses (e.g. POST and 2.04 1730 (Changed)). In case of combining EDHOC and OSCORE as specified in 1731 [I-D.palombini-core-oscore-edhoc], an error message response 1732 following a combined EDHOC message_3/OSCORE request MUST to be sent 1733 with a CoAP error code and SHALL contain the EDHOC diagnostic message 1734 DIAG_MSG as payload (see Section 6). 1736 8. Security Considerations 1738 8.1. Security Properties 1740 EDHOC inherits its security properties from the theoretical SIGMA-I 1741 protocol [SIGMA]. Using the terminology from [SIGMA], EDHOC provides 1742 perfect forward secrecy, mutual authentication with aliveness, 1743 consistency, peer awareness. As described in [SIGMA], peer awareness 1744 is provided to the Responder, but not to the Initiator. 1746 EDHOC protects the credential identifier of the Initiator against 1747 active attacks and the credential identifier of the Responder against 1748 passive attacks. The roles should be assigned to protect the most 1749 sensitive identity/identifier, typically that which is not possible 1750 to infer from routing information in the lower layers. 1752 Compared to [SIGMA], EDHOC adds an explicit method type and expands 1753 the message authentication coverage to additional elements such as 1754 algorithms, auxiliary data, and previous messages. This protects 1755 against an attacker replaying messages or injecting messages from 1756 another session. 1758 EDHOC also adds negotiation of connection identifiers and downgrade 1759 protected negotiation of cryptographic parameters, i.e. an attacker 1760 cannot affect the negotiated parameters. A single session of EDHOC 1761 does not include negotiation of cipher suites, but it enables the 1762 Responder to verify that the selected cipher suite is the most 1763 preferred cipher suite by the Initiator which is supported by both 1764 the Initiator and the Responder. 1766 As required by [RFC7258], IETF protocols need to mitigate pervasive 1767 monitoring when possible. One way to mitigate pervasive monitoring 1768 is to use a key exchange that provides perfect forward secrecy. 1769 EDHOC therefore only supports methods with perfect forward secrecy. 1770 To limit the effect of breaches, it is important to limit the use of 1771 symmetrical group keys for bootstrapping. EDHOC therefore strives to 1772 make the additional cost of using raw public keys and self-signed 1773 certificates as small as possible. Raw public keys and self-signed 1774 certificates are not a replacement for a public key infrastructure, 1775 but SHOULD be used instead of symmetrical group keys for 1776 bootstrapping. 1778 Compromise of the long-term keys (private signature or static DH 1779 keys) does not compromise the security of completed EDHOC exchanges. 1780 Compromising the private authentication keys of one party lets an 1781 active attacker impersonate that compromised party in EDHOC exchanges 1782 with other parties, but does not let the attacker impersonate other 1783 parties in EDHOC exchanges with the compromised party. Compromise of 1784 the long-term keys does not enable a passive attacker to compromise 1785 future session keys. Compromise of the HDKF input parameters (ECDH 1786 shared secret) leads to compromise of all session keys derived from 1787 that compromised shared secret. Compromise of one session key does 1788 not compromise other session keys. Compromise of PRK_4x3m leads to 1789 compromise of all exported keying material derived after the last 1790 invocation of the EDHOC-KeyUpdate function. 1792 EDHOC provides a minimum of 64-bit security against online brute 1793 force attacks and a minimum of 128-bit security against offline brute 1794 force attacks. This is in line with IPsec, TLS, and COSE. To break 1795 64-bit security against online brute force an attacker would on 1796 average have to send 4.3 billion messages per second for 68 years, 1797 which is infeasible in constrained IoT radio technologies. 1799 After sending message_3, the Initiator is assured that no other party 1800 than the Responder can compute the key PRK_4x3m (implicit key 1801 authentication). The Initiator does however not know that the 1802 Responder has actually computed the key PRK_4x3m. While the 1803 Initiator can securely send protected application data, the Initiator 1804 SHOULD NOT permanently store the keying material PRK_4x3m and TH_4 1805 until the Initiator is assured that the Responder has actually 1806 computed the key PRK_4x3m (explicit key confirmation). Explicit key 1807 confirmation is e.g. assured when the Initiator has verified an 1808 OSCORE message or message_4 from the Responder. After verifying 1809 message_3, the Responder is assured that the Initiator has calculated 1810 the key PRK_4x3m (explicit key confirmation) and that no other party 1811 than the Responder can compute the key. The Responder can securely 1812 send protected application data and store the keying material 1813 PRK_4x3m and TH_4. 1815 Key compromise impersonation (KCI): In EDHOC authenticated with 1816 signature keys, EDHOC provides KCI protection against an attacker 1817 having access to the long term key or the ephemeral secret key. With 1818 static Diffie-Hellman key authentication, KCI protection would be 1819 provided against an attacker having access to the long-term Diffie- 1820 Hellman key, but not to an attacker having access to the ephemeral 1821 secret key. Note that the term KCI has typically been used for 1822 compromise of long-term keys, and that an attacker with access to the 1823 ephemeral secret key can only attack that specific protocol run. 1825 Repudiation: In EDHOC authenticated with signature keys, the 1826 Initiator could theoretically prove that the Responder performed a 1827 run of the protocol by presenting the private ephemeral key, and vice 1828 versa. Note that storing the private ephemeral keys violates the 1829 protocol requirements. With static Diffie-Hellman key 1830 authentication, both parties can always deny having participated in 1831 the protocol. 1833 8.2. Cryptographic Considerations 1835 The security of the SIGMA protocol requires the MAC to be bound to 1836 the identity of the signer. Hence the message authenticating 1837 functionality of the authenticated encryption in EDHOC is critical: 1838 authenticated encryption MUST NOT be replaced by plain encryption 1839 only, even if authentication is provided at another level or through 1840 a different mechanism. EDHOC implements SIGMA-I using a MAC-then- 1841 Sign approach. 1843 To reduce message overhead EDHOC does not use explicit nonces and 1844 instead rely on the ephemeral public keys to provide randomness to 1845 each session. A good amount of randomness is important for the key 1846 generation, to provide liveness, and to protect against interleaving 1847 attacks. For this reason, the ephemeral keys MUST NOT be reused, and 1848 both parties SHALL generate fresh random ephemeral key pairs. 1850 As discussed the [SIGMA], the encryption of message_2 does only need 1851 to protect against passive attacker as active attackers can always 1852 get the Responders identity by sending their own message_1. EDHOC 1853 uses the Expand function (typically HKDF-Expand) as a binary additive 1854 stream cipher. HKDF-Expand provides better confidentiality than AES- 1855 CTR but is not often used as it is slow on long messages, and most 1856 applications require both IND-CCA confidentiality as well as 1857 integrity protection. For the encryption of message_2, any speed 1858 difference is negligible, IND-CCA does not increase security, and 1859 integrity is provided by the inner MAC (and signature depending on 1860 method). 1862 The data rates in many IoT deployments are very limited. Given that 1863 the application keys are protected as well as the long-term 1864 authentication keys they can often be used for years or even decades 1865 before the cryptographic limits are reached. If the application keys 1866 established through EDHOC need to be renewed, the communicating 1867 parties can derive application keys with other labels or run EDHOC 1868 again. 1870 8.3. Cipher Suites and Cryptographic Algorithms 1872 For many constrained IoT devices it is problematic to support more 1873 than one cipher suite. Existing devices can be expected to support 1874 either ECDSA or EdDSA. To enable as much interoperability as we can 1875 reasonably achieve, less constrained devices SHOULD implement both 1876 cipher suite 0 (AES-CCM-16-64-128, SHA-256, X25519, EdDSA, Ed25519, 1877 AES-CCM-16-64-128, SHA-256) and cipher suite 2 (AES-CCM-16-64-128, 1878 SHA-256, P-256, ES256, P-256, AES-CCM-16-64-128, SHA-256). 1879 Constrained endpoints SHOULD implement cipher suite 0 or cipher suite 1880 2. Implementations only need to implement the algorithms needed for 1881 their supported methods. 1883 When using private cipher suite or registering new cipher suites, the 1884 choice of key length used in the different algorithms needs to be 1885 harmonized, so that a sufficient security level is maintained for 1886 certificates, EDHOC, and the protection of application data. The 1887 Initiator and the Responder should enforce a minimum security level. 1889 The hash algorithms SHA-1 and SHA-256/64 (256-bit Hash truncated to 1890 64-bits) SHALL NOT be be supported for use in EDHOC except for 1891 certificate identification with x5u and c5u. Note that secp256k1 is 1892 only defined for use with ECDSA and not for ECDH. 1894 8.4. Unprotected Data 1896 The Initiator and the Responder must make sure that unprotected data 1897 and metadata do not reveal any sensitive information. This also 1898 applies for encrypted data sent to an unauthenticated party. In 1899 particular, it applies to AD_1, ID_CRED_R, AD_2, and ERR_MSG. Using 1900 the same AD_1 in several EDHOC sessions allows passive eavesdroppers 1901 to correlate the different sessions. Another consideration is that 1902 the list of supported cipher suites may potentially be used to 1903 identify the application. 1905 The Initiator and the Responder must also make sure that 1906 unauthenticated data does not trigger any harmful actions. In 1907 particular, this applies to AD_1 and ERR_MSG. 1909 8.5. Denial-of-Service 1911 EDHOC itself does not provide countermeasures against Denial-of- 1912 Service attacks. By sending a number of new or replayed message_1 an 1913 attacker may cause the Responder to allocate state, perform 1914 cryptographic operations, and amplify messages. To mitigate such 1915 attacks, an implementation SHOULD rely on lower layer mechanisms such 1916 as the Echo option in CoAP [I-D.ietf-core-echo-request-tag] that 1917 forces the initiator to demonstrate reachability at its apparent 1918 network address. 1920 8.6. Implementation Considerations 1922 The availability of a secure random number generator is essential for 1923 the security of EDHOC. If no true random number generator is 1924 available, a truly random seed MUST be provided from an external 1925 source and used with a cryptographically secure pseudorandom number 1926 generator. As each pseudorandom number must only be used once, an 1927 implementation need to get a new truly random seed after reboot, or 1928 continuously store state in nonvolatile memory, see ([RFC8613], 1929 Appendix B.1.1) for issues and solution approaches for writing to 1930 nonvolatile memory. Intentionally or unintentionally weak or 1931 predictable pseudorandom number generators can be abused or exploited 1932 for malicious purposes. [RFC8937] describes a way for security 1933 protocol implementations to augment their (pseudo)random number 1934 generators using a long-term private keys and a deterministic 1935 signature function. This improves randomness from broken or 1936 otherwise subverted random number generators. The same idea can be 1937 used with other secrets and functions such as a Diffie-Hellman 1938 function or a symmetric secret and a PRF like HMAC or KMAC. It is 1939 RECOMMENDED to not trust a single source of randomness and to not put 1940 unaugmented random numbers on the wire. 1942 If ECDSA is supported, "deterministic ECDSA" as specified in 1943 [RFC6979] MAY be used. Pure deterministic elliptic-curve signatures 1944 such as deterministic ECDSA and EdDSA have gained popularity over 1945 randomized ECDSA as their security do not depend on a source of high- 1946 quality randomness. Recent research has however found that 1947 implementations of these signature algorithms may be vulnerable to 1948 certain side-channel and fault injection attacks due to their 1949 determinism. See e.g. Section 1 of 1950 [I-D.mattsson-cfrg-det-sigs-with-noise] for a list of attack papers. 1951 As suggested in Section 2.1.1 of [RFC8152] this can be adressed by 1952 combining randomness and determinism. 1954 The referenced processing instructions in [SP-800-56A] must be 1955 complied with, including deleting the intermediate computed values 1956 along with any ephemeral ECDH secrets after the key derivation is 1957 completed. The ECDH shared secrets, keys, and IVs MUST be secret. 1958 Implementations should provide countermeasures to side-channel 1959 attacks such as timing attacks. Depending on the selected curve, the 1960 parties should perform various validations of each other's public 1961 keys, see e.g. Section 5 of [SP-800-56A]. 1963 The Initiator and the Responder are responsible for verifying the 1964 integrity of certificates. The selection of trusted CAs should be 1965 done very carefully and certificate revocation should be supported. 1966 The private authentication keys MUST be kept secret. 1968 The Initiator and the Responder are allowed to select the connection 1969 identifiers C_I and C_R, respectively, for the other party to use in 1970 the ongoing EDHOC protocol as well as in a subsequent application 1971 protocol (e.g. OSCORE [RFC8613]). The choice of connection 1972 identifier is not security critical in EDHOC but intended to simplify 1973 the retrieval of the right security context in combination with using 1974 short identifiers. If the wrong connection identifier of the other 1975 party is used in a protocol message it will result in the receiving 1976 party not being able to retrieve a security context (which will 1977 terminate the protocol) or retrieve the wrong security context (which 1978 also terminates the protocol as the message cannot be verified). 1980 The Responder MUST finish the verification step of message_3 before 1981 passing AD_3 to the application. 1983 If two nodes unintentionally initiate two simultaneous EDHOC message 1984 exchanges with each other even if they only want to complete a single 1985 EDHOC message exchange, they MAY terminate the exchange with the 1986 lexicographically smallest G_X. If the two G_X values are equal, the 1987 received message_1 MUST be discarded to mitigate reflection attacks. 1988 Note that in the case of two simultaneous EDHOC exchanges where the 1989 nodes only complete one and where the nodes have different preferred 1990 cipher suites, an attacker can affect which of the two nodes' 1991 preferred cipher suites will be used by blocking the other exchange. 1993 If supported by the device, it is RECOMMENDED that at least the long- 1994 term private keys is stored in a Trusted Execution Environment (TEE) 1995 and that sensitive operations using these keys are performed inside 1996 the TEE. To achieve even higher security it is RECOMMENDED that 1997 additional operations such as ephemeral key generation, all 1998 computations of shared secrets, and storage of the PRK keys can be 1999 done inside the TEE. The TEE can also be used to protect the EDHOC 2000 and application protocol (e.g. OSCORE) implementation using some 2001 form of "secure boot", memory protection etc. Typically an adversary 2002 with physical access to a device can be assumed to gain access to all 2003 information outside of the TEE, but none of the information inside 2004 the TEE. 2006 8.7. Other Documents Referencing EDHOC 2008 EDHOC has been analyzed in several other documents. A formal 2009 verification of EDHOC was done in [SSR18], an analysis of EDHOC for 2010 certificate enrollment was done in [Kron18], the use of EDHOC in 2011 LoRaWAN is analyzed in [LoRa1] and [LoRa2], the use of EDHOC in IoT 2012 bootstrapping is analyzed in [Perez18], and the use of EDHOC in 2013 6TiSCH is described in [I-D.ietf-6tisch-dtsecurity-zerotouch-join]. 2015 9. IANA Considerations 2017 9.1. EDHOC Cipher Suites Registry 2019 IANA has created a new registry titled "EDHOC Cipher Suites" under 2020 the new heading "EDHOC". The registration procedure is "Expert 2021 Review". The columns of the registry are Value, Array, Description, 2022 and Reference, where Value is an integer and the other columns are 2023 text strings. The initial contents of the registry are: 2025 Value: -24 2026 Algorithms: N/A 2027 Desc: Reserved for Private Use 2028 Reference: [[this document]] 2030 Value: -23 2031 Algorithms: N/A 2032 Desc: Reserved for Private Use 2033 Reference: [[this document]] 2035 Value: -22 2036 Algorithms: N/A 2037 Desc: Reserved for Private Use 2038 Reference: [[this document]] 2040 Value: -21 2041 Algorithms: N/A 2042 Desc: Reserved for Private Use 2043 Reference: [[this document]] 2045 Value: 0 2046 Array: 10, 5, 4, -8, 6, 10, 5 2047 Desc: AES-CCM-16-64-128, SHA-256, X25519, EdDSA, Ed25519, 2048 AES-CCM-16-64-128, SHA-256 2049 Reference: [[this document]] 2050 Value: 1 2051 Array: 30, 5, 4, -8, 6, 10, 5 2052 Desc: AES-CCM-16-128-128, SHA-256, X25519, EdDSA, Ed25519, 2053 AES-CCM-16-64-128, SHA-256 2054 Reference: [[this document]] 2056 Value: 2 2057 Array: 10, 5, 1, -7, 1, 10, 5 2058 Desc: AES-CCM-16-64-128, SHA-256, P-256, ES256, P-256, 2059 AES-CCM-16-64-128, SHA-256 2060 Reference: [[this document]] 2062 Value: 3 2063 Array: 30, 5, 1, -7, 1, 10, 5 2064 Desc: AES-CCM-16-128-128, SHA-256, P-256, ES256, P-256, 2065 AES-CCM-16-64-128, SHA-256 2066 Reference: [[this document]] 2068 Value: 4 2069 Array: 1, -16, 4, -7, 1, 1, -16 2070 Desc: A128GCM, SHA-256, X25519, ES256, P-256, 2071 A128GCM, SHA-256 2072 Reference: [[this document]] 2074 Value: 5 2075 Array: 3, -43, 2, -35, 2, 3, -43 2076 Desc: A256GCM, SHA-384, P-384, ES384, P-384, 2077 A256GCM, SHA-384 2078 Reference: [[this document]] 2080 9.2. EDHOC Method Type Registry 2082 IANA has created a new registry titled "EDHOC Method Type" under the 2083 new heading "EDHOC". The registration procedure is "Expert Review". 2084 The columns of the registry are Value, Description, and Reference, 2085 where Value is an integer and the other columns are text strings. 2086 The initial contents of the registry is shown in Figure 4. 2088 9.3. The Well-Known URI Registry 2090 IANA has added the well-known URI 'edhoc' to the Well-Known URIs 2091 registry. 2093 * URI suffix: edhoc 2095 * Change controller: IETF 2097 * Specification document(s): [[this document]] 2098 * Related information: None 2100 9.4. Media Types Registry 2102 IANA has added the media type 'application/edhoc' to the Media Types 2103 registry. 2105 * Type name: application 2107 * Subtype name: edhoc 2109 * Required parameters: N/A 2111 * Optional parameters: N/A 2113 * Encoding considerations: binary 2115 * Security considerations: See Section 7 of this document. 2117 * Interoperability considerations: N/A 2119 * Published specification: [[this document]] (this document) 2121 * Applications that use this media type: To be identified 2123 * Fragment identifier considerations: N/A 2125 * Additional information: 2127 - Magic number(s): N/A 2129 - File extension(s): N/A 2131 - Macintosh file type code(s): N/A 2133 * Person & email address to contact for further information: See 2134 "Authors' Addresses" section. 2136 * Intended usage: COMMON 2138 * Restrictions on usage: N/A 2140 * Author: See "Authors' Addresses" section. 2142 * Change Controller: IESG 2144 9.5. CoAP Content-Formats Registry 2146 IANA has added the media type 'application/edhoc' to the CoAP 2147 Content-Formats registry. 2149 * Media Type: application/edhoc 2151 * Encoding: 2153 * ID: TBD42 2155 * Reference: [[this document]] 2157 9.6. Expert Review Instructions 2159 The IANA Registries established in this document is defined as 2160 "Expert Review". This section gives some general guidelines for what 2161 the experts should be looking for, but they are being designated as 2162 experts for a reason so they should be given substantial latitude. 2164 Expert reviewers should take into consideration the following points: 2166 * Clarity and correctness of registrations. Experts are expected to 2167 check the clarity of purpose and use of the requested entries. 2168 Expert needs to make sure the values of algorithms are taken from 2169 the right registry, when that's required. Expert should consider 2170 requesting an opinion on the correctness of registered parameters 2171 from relevant IETF working groups. Encodings that do not meet 2172 these objective of clarity and completeness should not be 2173 registered. 2175 * Experts should take into account the expected usage of fields when 2176 approving point assignment. The length of the encoded value 2177 should be weighed against how many code points of that length are 2178 left, the size of device it will be used on, and the number of 2179 code points left that encode to that size. 2181 * Specifications are recommended. When specifications are not 2182 provided, the description provided needs to have sufficient 2183 information to verify the points above. 2185 10. References 2187 10.1. Normative References 2189 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2190 Requirement Levels", BCP 14, RFC 2119, 2191 DOI 10.17487/RFC2119, March 1997, 2192 . 2194 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 2195 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 2196 . 2198 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 2199 Key Derivation Function (HKDF)", RFC 5869, 2200 DOI 10.17487/RFC5869, May 2010, 2201 . 2203 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 2204 Curve Cryptography Algorithms", RFC 6090, 2205 DOI 10.17487/RFC6090, February 2011, 2206 . 2208 [RFC6979] Pornin, T., "Deterministic Usage of the Digital Signature 2209 Algorithm (DSA) and Elliptic Curve Digital Signature 2210 Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, August 2211 2013, . 2213 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 2214 Application Protocol (CoAP)", RFC 7252, 2215 DOI 10.17487/RFC7252, June 2014, 2216 . 2218 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 2219 for Security", RFC 7748, DOI 10.17487/RFC7748, January 2220 2016, . 2222 [RFC8949] Bormann, C. and P. Hoffman, "Concise Binary Object 2223 Representation (CBOR)", STD 94, RFC 8949, 2224 DOI 10.17487/RFC8949, December 2020, 2225 . 2227 [RFC7959] Bormann, C. and Z. Shelby, Ed., "Block-Wise Transfers in 2228 the Constrained Application Protocol (CoAP)", RFC 7959, 2229 DOI 10.17487/RFC7959, August 2016, 2230 . 2232 [RFC8152] Schaad, J., "CBOR Object Signing and Encryption (COSE)", 2233 RFC 8152, DOI 10.17487/RFC8152, July 2017, 2234 . 2236 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2237 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2238 May 2017, . 2240 [RFC8376] Farrell, S., Ed., "Low-Power Wide Area Network (LPWAN) 2241 Overview", RFC 8376, DOI 10.17487/RFC8376, May 2018, 2242 . 2244 [RFC8610] Birkholz, H., Vigano, C., and C. Bormann, "Concise Data 2245 Definition Language (CDDL): A Notational Convention to 2246 Express Concise Binary Object Representation (CBOR) and 2247 JSON Data Structures", RFC 8610, DOI 10.17487/RFC8610, 2248 June 2019, . 2250 [RFC8613] Selander, G., Mattsson, J., Palombini, F., and L. Seitz, 2251 "Object Security for Constrained RESTful Environments 2252 (OSCORE)", RFC 8613, DOI 10.17487/RFC8613, July 2019, 2253 . 2255 [RFC8724] Minaburo, A., Toutain, L., Gomez, C., Barthel, D., and JC. 2256 Zúñiga, "SCHC: Generic Framework for Static Context Header 2257 Compression and Fragmentation", RFC 8724, 2258 DOI 10.17487/RFC8724, April 2020, 2259 . 2261 [RFC8742] Bormann, C., "Concise Binary Object Representation (CBOR) 2262 Sequences", RFC 8742, DOI 10.17487/RFC8742, February 2020, 2263 . 2265 [I-D.ietf-cose-x509] 2266 Schaad, J., "CBOR Object Signing and Encryption (COSE): 2267 Header parameters for carrying and referencing X.509 2268 certificates", Work in Progress, Internet-Draft, draft- 2269 ietf-cose-x509-08, 14 December 2020, . 2272 [I-D.ietf-core-echo-request-tag] 2273 Amsuess, C., Mattsson, J., and G. Selander, "CoAP: Echo, 2274 Request-Tag, and Token Processing", Work in Progress, 2275 Internet-Draft, draft-ietf-core-echo-request-tag-11, 2 2276 November 2020, . 2279 [I-D.ietf-lake-reqs] 2280 Vucinic, M., Selander, G., Mattsson, J., and D. Garcia- 2281 Carillo, "Requirements for a Lightweight AKE for OSCORE", 2282 Work in Progress, Internet-Draft, draft-ietf-lake-reqs-04, 2283 8 June 2020, . 2286 10.2. Informative References 2288 [RFC7228] Bormann, C., Ersue, M., and A. Keranen, "Terminology for 2289 Constrained-Node Networks", RFC 7228, 2290 DOI 10.17487/RFC7228, May 2014, 2291 . 2293 [RFC7258] Farrell, S. and H. Tschofenig, "Pervasive Monitoring Is an 2294 Attack", BCP 188, RFC 7258, DOI 10.17487/RFC7258, May 2295 2014, . 2297 [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T. 2298 Kivinen, "Internet Key Exchange Protocol Version 2 2299 (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October 2300 2014, . 2302 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 2303 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 2304 . 2306 [RFC8937] Cremers, C., Garratt, L., Smyshlyaev, S., Sullivan, N., 2307 and C. Wood, "Randomness Improvements for Security 2308 Protocols", RFC 8937, DOI 10.17487/RFC8937, October 2020, 2309 . 2311 [I-D.ietf-6tisch-dtsecurity-zerotouch-join] 2312 Richardson, M., "6tisch Zero-Touch Secure Join protocol", 2313 Work in Progress, Internet-Draft, draft-ietf-6tisch- 2314 dtsecurity-zerotouch-join-04, 8 July 2019, 2315 . 2318 [I-D.ietf-core-resource-directory] 2319 Amsuess, C., Shelby, Z., Koster, M., Bormann, C., and P. 2320 Stok, "CoRE Resource Directory", Work in Progress, 2321 Internet-Draft, draft-ietf-core-resource-directory-26, 2 2322 November 2020, . 2325 [I-D.ietf-lwig-security-protocol-comparison] 2326 Mattsson, J., Palombini, F., and M. Vucinic, "Comparison 2327 of CoAP Security Protocols", Work in Progress, Internet- 2328 Draft, draft-ietf-lwig-security-protocol-comparison-05, 2 2329 November 2020, . 2332 [I-D.ietf-tls-dtls13] 2333 Rescorla, E., Tschofenig, H., and N. Modadugu, "The 2334 Datagram Transport Layer Security (DTLS) Protocol Version 2335 1.3", Work in Progress, Internet-Draft, draft-ietf-tls- 2336 dtls13-40, 20 January 2021, . 2339 [I-D.selander-ace-ake-authz] 2340 Selander, G., Mattsson, J., Vucinic, M., Richardson, M., 2341 and A. Schellenbaum, "Lightweight Authorization for 2342 Authenticated Key Exchange.", Work in Progress, Internet- 2343 Draft, draft-selander-ace-ake-authz-02, 2 November 2020, 2344 . 2347 [I-D.palombini-core-oscore-edhoc] 2348 Palombini, F., Tiloca, M., Hoeglund, R., Hristozov, S., 2349 and G. Selander, "Combining EDHOC and OSCORE", Work in 2350 Progress, Internet-Draft, draft-palombini-core-oscore- 2351 edhoc-01, 2 November 2020, . 2354 [I-D.mattsson-cose-cbor-cert-compress] 2355 Raza, S., Hoglund, J., Selander, G., Mattsson, J., and M. 2356 Furuhed, "CBOR Encoding of X.509 Certificates (CBOR 2357 Certificates)", Work in Progress, Internet-Draft, draft- 2358 mattsson-cose-cbor-cert-compress-06, 19 January 2021, 2359 . 2362 [I-D.mattsson-cfrg-det-sigs-with-noise] 2363 Mattsson, J., Thormarker, E., and S. Ruohomaa, 2364 "Deterministic ECDSA and EdDSA Signatures with Additional 2365 Randomness", Work in Progress, Internet-Draft, draft- 2366 mattsson-cfrg-det-sigs-with-noise-02, 11 March 2020, 2367 . 2370 [SP-800-56A] 2371 Barker, E., Chen, L., Roginsky, A., Vassilev, A., and R. 2372 Davis, "Recommendation for Pair-Wise Key-Establishment 2373 Schemes Using Discrete Logarithm Cryptography", 2374 NIST Special Publication 800-56A Revision 3, April 2018, 2375 . 2377 [SIGMA] Krawczyk, H., "SIGMA - The 'SIGn-and-MAc' Approach to 2378 Authenticated Diffie-Hellman and Its Use in the IKE- 2379 Protocols (Long version)", June 2003, 2380 . 2382 [CNSA] (Placeholder), ., "Commercial National Security Algorithm 2383 Suite", August 2015, 2384 . 2387 [LoRa1] Sanchez-Iborra, R., Sánchez-Gómez, J., Pérez, S., 2388 Fernández, P.J., Santa, J., Hernández-Ramos, J.L., and 2389 A.F. Skarmeta, "Enhancing LoRaWAN Security through a 2390 Lightweight and Authenticated Key Management Approach", 2391 June 2018, 2392 . 2395 [LoRa2] Sanchez-Iborra, R., Sánchez-Gómez, J., Pérez, S., 2396 Fernández, P.J., Santa, J., Hernández-Ramos, J.L., and 2397 A.F. Skarmeta, "Internet Access for LoRaWAN Devices 2398 Considering Security Issues", June 2018, 2399 . 2401 [Kron18] Krontiris, A., "Evaluation of Certificate Enrollment over 2402 Application Layer Security", May 2018, 2403 . 2406 [SSR18] Bruni, A., Sahl Jørgensen, T., Grønbech Petersen, T., and 2407 C. Schürmann, "Formal Verification of Ephemeral Diffie- 2408 Hellman Over COSE (EDHOC)", November 2018, 2409 . 2413 [Perez18] Pérez, S., Garcia-Carrillo, D., Marín-López, R., 2414 Hernández-Ramos, J., Marín-Pérez, R., and A. Skarmeta, 2415 "Architecture of security association establishment based 2416 on bootstrapping technologies for enabling critical IoT 2417 K", October 2018, . 2422 [CborMe] Bormann, C., "CBOR Playground", May 2018, 2423 . 2425 Appendix A. Use of CBOR, CDDL and COSE in EDHOC 2427 This Appendix is intended to simplify for implementors not familiar 2428 with CBOR [RFC8949], CDDL [RFC8610], COSE [RFC8152], and HKDF 2429 [RFC5869]. 2431 A.1. CBOR and CDDL 2433 The Concise Binary Object Representation (CBOR) [RFC8949] is a data 2434 format designed for small code size and small message size. CBOR 2435 builds on the JSON data model but extends it by e.g. encoding binary 2436 data directly without base64 conversion. In addition to the binary 2437 CBOR encoding, CBOR also has a diagnostic notation that is readable 2438 and editable by humans. The Concise Data Definition Language (CDDL) 2439 [RFC8610] provides a way to express structures for protocol messages 2440 and APIs that use CBOR. [RFC8610] also extends the diagnostic 2441 notation. 2443 CBOR data items are encoded to or decoded from byte strings using a 2444 type-length-value encoding scheme, where the three highest order bits 2445 of the initial byte contain information about the major type. CBOR 2446 supports several different types of data items, in addition to 2447 integers (int, uint), simple values (e.g. null), byte strings (bstr), 2448 and text strings (tstr), CBOR also supports arrays [] of data items, 2449 maps {} of pairs of data items, and sequences [RFC8742] of data 2450 items. Some examples are given below. For a complete specification 2451 and more examples, see [RFC8949] and [RFC8610]. We recommend 2452 implementors to get used to CBOR by using the CBOR playground 2453 [CborMe]. 2455 Diagnostic Encoded Type 2456 ------------------------------------------------------------------ 2457 1 0x01 unsigned integer 2458 24 0x1818 unsigned integer 2459 -24 0x37 negative integer 2460 -25 0x3818 negative integer 2461 null 0xf6 simple value 2462 h'12cd' 0x4212cd byte string 2463 '12cd' 0x4431326364 byte string 2464 "12cd" 0x6431326364 text string 2465 { 4 : h'cd' } 0xa10441cd map 2466 << 1, 2, null >> 0x430102f6 byte string 2467 [ 1, 2, null ] 0x830102f6 array 2468 ( 1, 2, null ) 0x0102f6 sequence 2469 1, 2, null 0x0102f6 sequence 2470 ------------------------------------------------------------------ 2472 A.2. COSE 2474 CBOR Object Signing and Encryption (COSE) [RFC8152] describes how to 2475 create and process signatures, message authentication codes, and 2476 encryption using CBOR. COSE builds on JOSE, but is adapted to allow 2477 more efficient processing in constrained devices. EDHOC makes use of 2478 COSE_Key, COSE_Encrypt0, and COSE_Sign1 objects. 2480 Appendix B. Test Vectors 2482 This appendix provides detailed test vectors based on v-05 of this 2483 specification, to ease implementation and ensure interoperability. 2484 In addition to hexadecimal, all CBOR data items and sequences are 2485 given in CBOR diagnostic notation. The test vectors use the default 2486 mapping to CoAP where the Initiator acts as CoAP client (this means 2487 that corr = 1). 2489 A more extensive test vector suite covering more combinations of 2490 authentication method used between Initiator and Responder and 2491 related code to generate them can be found at https://github.com/ 2492 lake-wg/edhoc/tree/master/test-vectors-05. 2494 NOTE 1. In the previous and current test vectors the same name is 2495 used for certain byte strings and their CBOR bstr encodings. For 2496 example the transcript hash TH_2 is used to denote both the output of 2497 the hash function and the input into the key derivation function, 2498 whereas the latter is a CBOR bstr encoding of the former. Some 2499 attempts are made to clarify that in this Appendix (e.g. using "CBOR 2500 encoded"/"CBOR unencoded"). 2502 NOTE 2. If not clear from the context, remember that CBOR sequences 2503 and CBOR arrays assume CBOR encoded data items as elements. 2505 B.1. Test Vectors for EDHOC Authenticated with Signature Keys (x5t) 2507 EDHOC with signature authentication and X.509 certificates is used. 2508 In this test vector, the hash value 'x5t' is used to identify the 2509 certificate. No auxiliary data is sent in the message exchange. 2511 method (Signature Authentication) 2512 0 2514 CoAP is used as transport and the Initiator acts as CoAP client: 2516 corr (the Initiator can correlate message_1 and message_2) 2517 1 2519 From there, METHOD_CORR has the following value: 2521 METHOD_CORR (4 * method + corr) (int) 2522 1 2524 The Initiator indicates only one cipher suite in the (potentially 2525 trunkated) list of cipher suites. 2527 Supported Cipher Suites (1 byte) 2528 00 2530 The Initiator selected the indicated cipher suite. 2532 Selected Cipher Suite (int) 2533 0 2535 Cipher suite 0 is supported by both the Initiator and the Responder, 2536 see Section 3.4. 2538 B.1.1. Message_1 2540 The Initiator generates its ephemeral key pair. 2542 X (Initiator's ephemeral private key) (32 bytes) 2543 8f 78 1a 09 53 72 f8 5b 6d 9f 61 09 ae 42 26 11 73 4d 7d bf a0 06 9a 2d 2544 f2 93 5b b2 e0 53 bf 35 2546 G_X (Initiator's ephemeral public key, CBOR unencoded) (32 bytes) 2547 89 8f f7 9a 02 06 7a 16 ea 1e cc b9 0f a5 22 46 f5 aa 4d d6 ec 07 6b ba 2548 02 59 d9 04 b7 ec 8b 0c 2549 The Initiator chooses a connection identifier C_I: 2551 Connection identifier chosen by Initiator (1 byte) 2552 09 2554 Note that since C_I is a byte string in the interval h'00' to h'2f', 2555 it is encoded as the corresponding integer subtracted by 24 (see 2556 bstr_identifier in Section 5.1). Thus 0x09 = 09, 9 - 24 = -15, and 2557 -15 in CBOR encoding is equal to 0x2e. 2559 C_I (1 byte) 2560 2e 2562 Since no auxiliary data is sent: 2564 AD_1 (0 bytes) 2566 The list of supported cipher suites needs to contain the selected 2567 cipher suite. The initiator truncates the list of supported cipher 2568 suites to one cipher suite only. In this case there is only one 2569 supported cipher suite indicated, 00. 2571 Because one single selected cipher suite is conveyed, it is encoded 2572 as an int instead of an array: 2574 SUITES_I (int) 2575 0 2577 message_1 is constructed as the CBOR Sequence of the data items above 2578 encoded as CBOR. In CBOR diagnostic notation: 2580 message_1 = 2581 ( 2582 1, 2583 0, 2584 h'898FF79A02067A16EA1ECCB90FA52246F5AA4DD6EC076BBA0259D904B7EC8B0C', 2585 -15 2586 ) 2588 Which as a CBOR encoded data item is: 2590 message_1 (CBOR Sequence) (37 bytes) 2591 01 00 58 20 89 8f f7 9a 02 06 7a 16 ea 1e cc b9 0f a5 22 46 f5 aa 4d d6 2592 ec 07 6b ba 02 59 d9 04 b7 ec 8b 0c 2e 2594 B.1.2. Message_2 2596 Since METHOD_CORR mod 4 equals 1, C_I is omitted from data_2. 2598 The Responder generates the following ephemeral key pair. 2600 Y (Responder's ephemeral private key) (32 bytes) 2601 fd 8c d8 77 c9 ea 38 6e 6a f3 4f f7 e6 06 c4 b6 4c a8 31 c8 ba 33 13 4f 2602 d4 cd 71 67 ca ba ec da 2604 G_Y (Responder's ephemeral public key, CBOR unencoded) (32 bytes) 2605 71 a3 d5 99 c2 1d a1 89 02 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 19 52 2606 81 75 4c 5e bc af 30 1e 2608 From G_X and Y or from G_Y and X the ECDH shared secret is computed: 2610 G_XY (ECDH shared secret) (32 bytes) 2611 2b b7 fa 6e 13 5b c3 35 d0 22 d6 34 cb fb 14 b3 f5 82 f3 e2 e3 af b2 b3 2612 15 04 91 49 5c 61 78 2b 2614 The key and nonce for calculating the 'ciphertext' are calculated as 2615 follows, as specified in Section 4. 2617 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 2619 PRK_2e = HMAC-SHA-256(salt, G_XY) 2621 Salt is the empty byte string. 2623 salt (0 bytes) 2625 From there, PRK_2e is computed: 2627 PRK_2e (32 bytes) 2628 ec 62 92 a0 67 f1 37 fc 7f 59 62 9d 22 6f bf c4 e0 68 89 49 f6 62 a9 7f 2629 d8 2f be b7 99 71 39 4a 2631 The Responder's sign/verify key pair is the following: 2633 SK_R (Responders's private authentication key) (32 bytes) 2634 df 69 27 4d 71 32 96 e2 46 30 63 65 37 2b 46 83 ce d5 38 1b fc ad cd 44 2635 0a 24 c3 91 d2 fe db 94 2637 PK_R (Responders's public authentication key) (32 bytes) 2638 db d9 dc 8c d0 3f b7 c3 91 35 11 46 2b b2 38 16 47 7c 6b d8 d6 6e f5 a1 2639 a0 70 ac 85 4e d7 3f d2 2640 Since neither the Initiator nor the Responder authenticates with a 2641 static Diffie-Hellman key, PRK_3e2m = PRK_2e 2643 PRK_3e2m (32 bytes) 2644 ec 62 92 a0 67 f1 37 fc 7f 59 62 9d 22 6f bf c4 e0 68 89 49 f6 62 a9 7f 2645 d8 2f be b7 99 71 39 4a 2647 The Responder chooses a connection identifier C_R. 2649 Connection identifier chosen by Responder (1 byte) 2650 00 2652 Note that since C_R is a byte string in the interval h'00' to h'2f', 2653 it is encoded as the corresponding integer subtracted by 24 (see 2654 bstr_identifier in Section 5.1). Thus 0x00 = 0, 0 - 24 = -24, and 2655 -24 in CBOR encoding is equal to 0x37. 2657 C_R (1 byte) 2658 37 2660 Data_2 is constructed as the CBOR Sequence of G_Y and C_R, encoded as 2661 CBOR byte strings. The CBOR diagnostic notation is: 2663 data_2 = 2664 ( 2665 h'71a3d599c21da18902a1aea810b2b6382ccd8d5f9bf0195281754c5ebcaf301e', 2666 -24 2667 ) 2669 Which as a CBOR encoded data item is: 2671 data_2 (CBOR Sequence) (35 bytes) 2672 58 20 71 a3 d5 99 c2 1d a1 89 02 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 2673 19 52 81 75 4c 5e bc af 30 1e 37 2675 From data_2 and message_1, compute the input to the transcript hash 2676 TH_2 = H( message_1, data_2 ), as a CBOR Sequence of these 2 data 2677 items. 2679 Input to calculate TH_2 (CBOR Sequence) (72 bytes) 2680 01 00 58 20 89 8f f7 9a 02 06 7a 16 ea 1e cc b9 0f a5 22 46 f5 aa 4d d6 2681 ec 07 6b ba 02 59 d9 04 b7 ec 8b 0c 2e 58 20 71 a3 d5 99 c2 1d a1 89 02 2682 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 19 52 81 75 4c 5e bc af 30 1e 37 2684 And from there, compute the transcript hash TH_2 = SHA-256( 2685 message_1, data_2 ) 2687 TH_2 (CBOR unencoded) (32 bytes) 2688 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 d3 76 d2 c2 2689 c1 53 c1 7f 8e 96 29 ff 2691 The Responder's subject name is the empty string: 2693 Responders's subject name (text string) 2694 "" 2696 In this version of the test vectors CRED_R is not a DER encoded X.509 2697 certificate, but a string of random bytes. 2699 CRED_R (CBOR unencoded) (100 bytes) 2700 c7 88 37 00 16 b8 96 5b db 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 6e 86 2701 44 2b 87 ec 3f f2 45 b7 0a 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e c9 d6 2702 b0 53 4b 71 c2 b4 9e 4b f9 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 38 1e 2703 98 db 71 41 08 41 5e 5c 50 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 71 be 2704 5c 22 5e b2 2706 CRED_R is defined to be the CBOR bstr containing the credential of 2707 the Responder. 2709 CRED_R (102 bytes) 2710 58 64 c7 88 37 00 16 b8 96 5b db 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 2711 6e 86 44 2b 87 ec 3f f2 45 b7 0a 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e 2712 c9 d6 b0 53 4b 71 c2 b4 9e 4b f9 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 2713 38 1e 98 db 71 41 08 41 5e 5c 50 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 2714 71 be 5c 22 5e b2 2716 And because certificates are identified by a hash value with the 2717 'x5t' parameter, ID_CRED_R is the following: 2719 ID_CRED_R = { 34 : COSE_CertHash }. In this example, the hash 2720 algorithm used is SHA-2 256-bit with hash truncated to 64-bits (value 2721 -15). The hash value is calculated over the CBOR unencoded CRED_R. 2722 The CBOR diagnostic notation is: 2724 ID_CRED_R = 2725 { 2726 34: [-15, h'6844078A53F312F5'] 2727 } 2729 which when encoded as a CBOR map becomes: 2731 ID_CRED_R (14 bytes) 2732 a1 18 22 82 2e 48 68 44 07 8a 53 f3 12 f5 2734 Since no auxiliary data is sent: 2736 AD_2 (0 bytes) 2738 The plaintext is defined as the empty string: 2740 P_2m (0 bytes) 2742 The Enc_structure is defined as follows: [ "Encrypt0", 2743 << ID_CRED_R >>, << TH_2, CRED_R >> ], indicating that ID_CRED_R is 2744 encoded as a CBOR byte string, and that the concatenation of the CBOR 2745 byte strings TH_2 and CRED_R is wrapped as a CBOR bstr. The CBOR 2746 diagnostic notation is the following: 2748 A_2m = 2749 [ 2750 "Encrypt0", 2751 h'A11822822E486844078A53F312F5', 2752 h'5820864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF 2753 5864C788370016B8965BDB2074BFF82E5A20E09BEC21F8406E86442B87EC3FF245B70A 2754 47624DC9CDC6824B2A4C52E95EC9D6B0534B71C2B49E4BF9031500CEE6869979C297BB 2755 5A8B381E98DB714108415E5C50DB78974C271579B01633A3EF6271BE5C225EB2' 2756 ] 2758 Which encodes to the following byte string to be used as Additional 2759 Authenticated Data: 2761 A_2m (CBOR-encoded) (163 bytes) 2762 83 68 45 6e 63 72 79 70 74 30 4e a1 18 22 82 2e 48 68 44 07 8a 53 f3 12 2763 f5 58 88 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 2764 72 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 58 64 c7 88 37 00 16 b8 96 5b db 2765 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 6e 86 44 2b 87 ec 3f f2 45 b7 0a 2766 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e c9 d6 b0 53 4b 71 c2 b4 9e 4b f9 2767 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 38 1e 98 db 71 41 08 41 5e 5c 50 2768 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 71 be 5c 22 5e b2 2770 info for K_2m is defined as follows in CBOR diagnostic notation: 2772 info for K_2m = 2773 [ 2774 10, 2775 h'864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF', 2776 "K_2m", 2777 16 2778 ] 2780 Which as a CBOR encoded data item is: 2782 info for K_2m (CBOR-encoded) (42 bytes) 2783 84 0a 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 2784 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 64 4b 5f 32 6d 10 2786 From these parameters, K_2m is computed. Key K_2m is the output of 2787 HKDF-Expand(PRK_3e2m, info, L), where L is the length of K_2m, so 16 2788 bytes. 2790 K_2m (16 bytes) 2791 80 cc a7 49 ab 58 f5 69 ca 35 da ee 05 be d1 94 2793 info for IV_2m is defined as follows, in CBOR diagnostic notation (10 2794 is the COSE algorithm no. of the AEAD algorithm in the selected 2795 cipher suite 0): 2797 info for IV_2m = 2798 [ 2799 10, 2800 h'864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF', 2801 "IV_2m", 2802 13 2803 ] 2805 Which as a CBOR encoded data item is: 2807 info for IV_2m (CBOR-encoded) (43 bytes) 2808 84 0a 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 2809 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 65 49 56 5f 32 6d 0d 2811 From these parameters, IV_2m is computed. IV_2m is the output of 2812 HKDF-Expand(PRK_3e2m, info, L), where L is the length of IV_2m, so 13 2813 bytes. 2815 IV_2m (13 bytes) 2816 c8 1e 1a 95 cc 93 b3 36 69 6e d5 02 55 2818 Finally, COSE_Encrypt0 is computed from the parameters above. 2820 * protected header = CBOR-encoded ID_CRED_R 2822 * external_aad = A_2m 2824 * empty plaintext = P_2m 2826 MAC_2 (CBOR unencoded) (8 bytes) 2827 fa bb a4 7e 56 71 a1 82 2828 To compute the Signature_or_MAC_2, the key is the private 2829 authentication key of the Responder and the message M_2 to be signed 2830 = [ "Signature1", << ID_CRED_R >>, << TH_2, CRED_R, ? AD_2 >>, MAC_2 2831 ]. ID_CRED_R is encoded as a CBOR byte string, the concatenation of 2832 the CBOR byte strings TH_2 and CRED_R is wrapped as a CBOR bstr, and 2833 MAC_2 is encoded as a CBOR bstr. 2835 M_2 = 2836 [ 2837 "Signature1", 2838 h'A11822822E486844078A53F312F5', 2839 h'5820864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629F 2840 F5864C788370016B8965BDB2074BFF82E5A20E09BEC21F8406E86442B87EC3FF245B7 2841 0A47624DC9CDC6824B2A4C52E95EC9D6B0534B71C2B49E4BF9031500CEE6869979C29 2842 7BB5A8B381E98DB714108415E5C50DB78974C271579B01633A3EF6271BE5C225EB2', 2843 h'FABBA47E5671A182' 2844 ] 2846 Which as a CBOR encoded data item is: 2848 M_2 (174 bytes) 2849 84 6a 53 69 67 6e 61 74 75 72 65 31 4e a1 18 22 82 2e 48 68 44 07 8a 53 2850 f3 12 f5 58 88 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a 2851 ce 99 72 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 58 64 c7 88 37 00 16 b8 96 2852 5b db 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 6e 86 44 2b 87 ec 3f f2 45 2853 b7 0a 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e c9 d6 b0 53 4b 71 c2 b4 9e 2854 4b f9 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 38 1e 98 db 71 41 08 41 5e 2855 5c 50 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 71 be 5c 22 5e b2 48 fa bb 2856 a4 7e 56 71 a1 82 2858 Since the method = 0, Signature_or_MAC_2 is a signature. The 2859 algorithm with selected cipher suite 0 is Ed25519 and the output is 2860 64 bytes. 2862 Signature_or_MAC_2 (CBOR unencoded) (64 bytes) 2863 1f 17 00 6a 98 48 c9 77 cb bd ca a7 57 b6 fd 46 82 c8 17 39 e1 5c 99 37 2864 c2 1c f5 e9 a0 e6 03 9f 54 fd 2a 6c 3a 11 18 f2 b9 d8 eb cd 48 23 48 b9 2865 9c 3e d7 ed 1b d9 80 6c 93 c8 90 68 e8 36 b4 0f 2867 CIPHERTEXT_2 is the ciphertext resulting from XOR between plaintext 2868 and KEYSTREAM_2 which is derived from TH_2 and the pseudorandom key 2869 PRK_2e. 2871 * plaintext = CBOR Sequence of the items ID_CRED_R and 2872 Signature_or_MAC_2 encoded as CBOR byte strings, in this order 2873 (AD_2 is empty). 2875 The plaintext is the following: 2877 P_2e (CBOR Sequence) (80 bytes) 2878 a1 18 22 82 2e 48 68 44 07 8a 53 f3 12 f5 58 40 1f 17 00 6a 98 48 c9 77 2879 cb bd ca a7 57 b6 fd 46 82 c8 17 39 e1 5c 99 37 c2 1c f5 e9 a0 e6 03 9f 2880 54 fd 2a 6c 3a 11 18 f2 b9 d8 eb cd 48 23 48 b9 9c 3e d7 ed 1b d9 80 6c 2881 93 c8 90 68 e8 36 b4 0f 2883 KEYSTREAM_2 = HKDF-Expand( PRK_2e, info, length ), where length is 2884 the length of the plaintext, so 80. 2886 info for KEYSTREAM_2 = 2887 [ 2888 10, 2889 h'864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF', 2890 "KEYSTREAM_2", 2891 80 2892 ] 2894 Which as a CBOR encoded data item is: 2896 info for KEYSTREAM_2 (CBOR-encoded) (50 bytes) 2897 84 0a 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 2898 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 6b 4b 45 59 53 54 52 45 41 4d 5f 32 2899 18 50 2901 From there, KEYSTREAM_2 is computed: 2903 KEYSTREAM_2 (80 bytes) 2904 ae ea 8e af 50 cf c6 70 09 da e8 2d 8d 85 b0 e7 60 91 bf 0f 07 0b 79 53 2905 6c 83 23 dc 3d 9d 61 13 10 35 94 63 f4 4b 12 4b ea b3 a1 9d 09 93 82 d7 2906 30 80 17 f4 92 62 06 e4 f5 44 9b 9f c9 24 bc b6 bd 78 ec 45 0a 66 83 fb 2907 8a 2f 5f 92 4f c4 40 4f 2909 Using the parameters above, the ciphertext CIPHERTEXT_2 can be 2910 computed: 2912 CIPHERTEXT_2 (CBOR unencoded) (80 bytes) 2913 0f f2 ac 2d 7e 87 ae 34 0e 50 bb de 9f 70 e8 a7 7f 86 bf 65 9f 43 b0 24 2914 a7 3e e9 7b 6a 2b 9c 55 92 fd 83 5a 15 17 8b 7c 28 af 54 74 a9 75 81 48 2915 64 7d 3d 98 a8 73 1e 16 4c 9c 70 52 81 07 f4 0f 21 46 3b a8 11 bf 03 97 2916 19 e7 cf fa a7 f2 f4 40 2918 message_2 is the CBOR Sequence of data_2 and CIPHERTEXT_2, in this 2919 order: 2921 message_2 = 2922 ( 2923 data_2, 2924 h'0FF2AC2D7E87AE340E50BBDE9F70E8A77F86BF659F43B024A73EE97B6A2B9C5592FD 2925 835A15178B7C28AF5474A9758148647D3D98A8731E164C9C70528107F40F21463BA811 2926 BF039719E7CFFAA7F2F440' 2927 ) 2929 Which as a CBOR encoded data item is: 2931 message_2 (CBOR Sequence) (117 bytes) 2932 58 20 71 a3 d5 99 c2 1d a1 89 02 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 2933 19 52 81 75 4c 5e bc af 30 1e 37 58 50 0f f2 ac 2d 7e 87 ae 34 0e 50 bb 2934 de 9f 70 e8 a7 7f 86 bf 65 9f 43 b0 24 a7 3e e9 7b 6a 2b 9c 55 92 fd 83 2935 5a 15 17 8b 7c 28 af 54 74 a9 75 81 48 64 7d 3d 98 a8 73 1e 16 4c 9c 70 2936 52 81 07 f4 0f 21 46 3b a8 11 bf 03 97 19 e7 cf fa a7 f2 f4 40 2938 B.1.3. Message_3 2940 Since corr equals 1, C_R is not omitted from data_3. 2942 The Initiator's sign/verify key pair is the following: 2944 SK_I (Initiator's private authentication key) (32 bytes) 2945 2f fc e7 a0 b2 b8 25 d3 97 d0 cb 54 f7 46 e3 da 3f 27 59 6e e0 6b 53 71 2946 48 1d c0 e0 12 bc 34 d7 2948 PK_I (Responders's public authentication key) (32 bytes) 2949 38 e5 d5 45 63 c2 b6 a4 ba 26 f3 01 5f 61 bb 70 6e 5c 2e fd b5 56 d2 e1 2950 69 0b 97 fc 3c 6d e1 49 2952 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 2954 PRK_4x3m = HMAC-SHA-256 (PRK_3e2m, G_IY) 2956 PRK_4x3m (32 bytes) 2957 ec 62 92 a0 67 f1 37 fc 7f 59 62 9d 22 6f bf c4 e0 68 89 49 f6 62 a9 7f 2958 d8 2f be b7 99 71 39 4a 2960 data 3 is equal to C_R. 2962 data_3 (CBOR Sequence) (1 byte) 2963 37 2965 From data_3, CIPHERTEXT_2, and TH_2, compute the input to the 2966 transcript hash TH_3 = H(TH_2 , CIPHERTEXT_2, data_3), as a CBOR 2967 Sequence of these 3 data items. 2969 Input to calculate TH_3 (CBOR Sequence) (117 bytes) 2970 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 d3 76 2971 d2 c2 c1 53 c1 7f 8e 96 29 ff 58 50 0f f2 ac 2d 7e 87 ae 34 0e 50 bb de 2972 9f 70 e8 a7 7f 86 bf 65 9f 43 b0 24 a7 3e e9 7b 6a 2b 9c 55 92 fd 83 5a 2973 15 17 8b 7c 28 af 54 74 a9 75 81 48 64 7d 3d 98 a8 73 1e 16 4c 9c 70 52 2974 81 07 f4 0f 21 46 3b a8 11 bf 03 97 19 e7 cf fa a7 f2 f4 40 37 2976 And from there, compute the transcript hash TH_3 = SHA-256(TH_2 , 2977 CIPHERTEXT_2, data_3) 2979 TH_3 (CBOR unencoded) (32 bytes) 2980 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 65 0c 30 70 2981 b6 f5 1e 68 e2 ae bb 60 2983 The Initiator's subject name is the empty string: 2985 Initiator's subject name (text string) 2986 "" 2988 In this version of the test vectors CRED_I is not a DER encoded X.509 2989 certificate, but a string of random bytes. 2991 CRED_I (CBOR unencoded) (101 bytes) 2992 54 13 20 4c 3e bc 34 28 a6 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 7e c6 2993 56 1e 52 43 3a a5 5e 71 f1 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 76 60 2994 88 09 84 49 cb 84 8f fc 79 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 67 5e 2995 8f 6c 77 a4 a2 c3 01 95 60 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 48 65 2996 02 ff 7b dd a6 2998 CRED_I is defined to be the CBOR bstr containing the credential of 2999 the Initiator. 3001 CRED_I (103 bytes) 3002 58 65 54 13 20 4c 3e bc 34 28 a6 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 3003 7e c6 56 1e 52 43 3a a5 5e 71 f1 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 3004 76 60 88 09 84 49 cb 84 8f fc 79 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 3005 67 5e 8f 6c 77 a4 a2 c3 01 95 60 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 3006 48 65 02 ff 7b dd a6 3008 And because certificates are identified by a hash value with the 3009 'x5t' parameter, ID_CRED_I is the following: 3011 ID_CRED_I = { 34 : COSE_CertHash }. In this example, the hash 3012 algorithm used is SHA-2 256-bit with hash truncated to 64-bits (value 3013 -15). The hash value is calculated over the CBOR unencoded CRED_I. 3015 ID_CRED_I = 3016 { 3017 34: [-15, h'705D5845F36FC6A6'] 3018 } 3020 which when encoded as a CBOR map becomes: 3022 ID_CRED_I (14 bytes) 3023 a1 18 22 82 2e 48 70 5d 58 45 f3 6f c6 a6 3025 Since no auxiliary data is exchanged: 3027 AD_3 (0 bytes) 3029 The plaintext of the COSE_Encrypt is the empty string: 3031 P_3m (0 bytes) 3033 The associated data is the following: [ "Encrypt0", << ID_CRED_I >>, 3034 << TH_3, CRED_I, ? AD_3 >> ]. 3036 A_3m (CBOR-encoded) (164 bytes) 3037 83 68 45 6e 63 72 79 70 74 30 4e a1 18 22 82 2e 48 70 5d 58 45 f3 6f c6 3038 a6 58 89 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 3039 0f 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 58 65 54 13 20 4c 3e bc 34 28 a6 3040 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 7e c6 56 1e 52 43 3a a5 5e 71 f1 3041 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 76 60 88 09 84 49 cb 84 8f fc 79 3042 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 67 5e 8f 6c 77 a4 a2 c3 01 95 60 3043 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 48 65 02 ff 7b dd a6 3045 Info for K_3m is computed as follows: 3047 info for K_3m = 3048 [ 3049 10, 3050 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3051 "K_3m", 3052 16 3053 ] 3055 Which as a CBOR encoded data item is: 3057 info for K_3m (CBOR-encoded) (42 bytes) 3058 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3059 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 64 4b 5f 33 6d 10 3060 From these parameters, K_3m is computed. Key K_3m is the output of 3061 HKDF-Expand(PRK_4x3m, info, L), where L is the length of K_2m, so 16 3062 bytes. 3064 K_3m (16 bytes) 3065 83 a9 c3 88 02 91 2e 7f 8f 0d 2b 84 14 d1 e5 2c 3067 Nonce IV_3m is the output of HKDF-Expand(PRK_4x3m, info, L), where L 3068 = 13 bytes. 3070 Info for IV_3m is defined as follows: 3072 info for IV_3m = 3073 [ 3074 10, 3075 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3076 "IV_3m", 3077 13 3078 ] 3080 Which as a CBOR encoded data item is: 3082 info for IV_3m (CBOR-encoded) (43 bytes) 3083 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3084 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 65 49 56 5f 33 6d 0d 3086 From these parameters, IV_3m is computed: 3088 IV_3m (13 bytes) 3089 9c 83 9c 0e e8 36 42 50 5a 8e 1c 9f b2 3091 MAC_3 is the 'ciphertext' of the COSE_Encrypt0: 3093 MAC_3 (CBOR unencoded) (8 bytes) 3094 2f a1 e3 9e ae 7d 5f 8d 3096 Since the method = 0, Signature_or_MAC_3 is a signature. The 3097 algorithm with selected cipher suite 0 is Ed25519. 3099 * The message M_3 to be signed = [ "Signature1", << ID_CRED_I >>, 3100 << TH_3, CRED_I >>, MAC_3 ], i.e. ID_CRED_I encoded as CBOR bstr, 3101 the concatenation of the CBOR byte strings TH_3 and CRED_I wrapped 3102 as a CBOR bstr, and MAC_3 encoded as a CBOR bstr. 3104 * The signing key is the private authentication key of the 3105 Initiator. 3107 M_3 = 3108 [ 3109 "Signature1", 3110 h'A11822822E48705D5845F36FC6A6', 3111 h'5820F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB6 3112 058655413204C3EBC3428A6CF57E24C9DEF59651770449BCE7EC6561E52433AA55E71 3113 F1FA34B22A9CA4A1E12924EAE1D1766088098449CB848FFC795F88AFC49CBE8AFDD1B 3114 A009F21675E8F6C77A4A2C30195601F6F0A0852978BD43D28207D44486502FF7BDD 3115 A6', 3116 h'2FA1E39EAE7D5F8D'] 3118 Which as a CBOR encoded data item is: 3120 M_3 (175 bytes) 3121 84 6a 53 69 67 6e 61 74 75 72 65 31 4e a1 18 22 82 2e 48 70 5d 58 45 f3 3122 6f c6 a6 58 89 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 3123 9c 7c 0f 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 58 65 54 13 20 4c 3e bc 34 3124 28 a6 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 7e c6 56 1e 52 43 3a a5 5e 3125 71 f1 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 76 60 88 09 84 49 cb 84 8f 3126 fc 79 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 67 5e 8f 6c 77 a4 a2 c3 01 3127 95 60 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 48 65 02 ff 7b dd a6 48 2f 3128 a1 e3 9e ae 7d 5f 8d 3130 From there, the 64 byte signature can be computed: 3132 Signature_or_MAC_3 (CBOR unencoded) (64 bytes) 3133 ab 9f 7b bd eb c4 eb f8 a3 d3 04 17 9b cc a3 9d 9c 8a 76 73 65 76 fb 3c 3134 32 d2 fa c7 e2 59 34 e5 33 dc c7 02 2e 4d 68 61 c8 f5 fe cb e9 2d 17 4e 3135 b2 be af 0a 59 a4 15 84 37 2f 43 2e 6b f4 7b 04 3137 Finally, the outer COSE_Encrypt0 is computed. 3139 The plaintext is the CBOR Sequence of the items ID_CRED_I and the 3140 CBOR encoded Signature_or_MAC_3, in this order (AD_3 is empty). 3142 P_3ae (CBOR Sequence) (80 bytes) 3143 a1 18 22 82 2e 48 70 5d 58 45 f3 6f c6 a6 58 40 ab 9f 7b bd eb c4 eb f8 3144 a3 d3 04 17 9b cc a3 9d 9c 8a 76 73 65 76 fb 3c 32 d2 fa c7 e2 59 34 e5 3145 33 dc c7 02 2e 4d 68 61 c8 f5 fe cb e9 2d 17 4e b2 be af 0a 59 a4 15 84 3146 37 2f 43 2e 6b f4 7b 04 3148 The Associated data A is the following: Associated data A = [ 3149 "Encrypt0", h'', TH_3 ] 3151 A_3ae (CBOR-encoded) (45 bytes) 3152 83 68 45 6e 63 72 79 70 74 30 40 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 3153 29 c1 52 ab 3a ea 9c 7c 0f 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 3154 Key K_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 3156 info is defined as follows: 3158 info for K_3ae = 3159 [ 3160 10, 3161 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3162 "K_3ae", 3163 16 3164 ] 3166 Which as a CBOR encoded data item is: 3168 info for K_3ae (CBOR-encoded) (43 bytes) 3169 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3170 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 65 4b 5f 33 61 65 10 3172 L is the length of K_3ae, so 16 bytes. 3174 From these parameters, K_3ae is computed: 3176 K_3ae (16 bytes) 3177 b8 79 9f e3 d1 50 4f d8 eb 22 c4 72 62 cd bb 05 3179 Nonce IV_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 3181 info is defined as follows: 3183 info for IV_3ae = 3184 [ 3185 10, 3186 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3187 "IV_3ae", 3188 13 3189 ] 3191 Which as a CBOR encoded data item is: 3193 info for IV_3ae (CBOR-encoded) (44 bytes) 3194 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3195 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 66 49 56 5f 33 61 65 0d 3197 L is the length of IV_3ae, so 13 bytes. 3199 From these parameters, IV_3ae is computed: 3201 IV_3ae (13 bytes) 3202 74 c7 de 41 b8 4a 5b b7 19 0a 85 98 dc 3204 Using the parameters above, the 'ciphertext' CIPHERTEXT_3 can be 3205 computed: 3207 CIPHERTEXT_3 (CBOR unencoded) (88 bytes) 3208 f5 f6 de bd 82 14 05 1c d5 83 c8 40 96 c4 80 1d eb f3 5b 15 36 3d d1 6e 3209 bd 85 30 df dc fb 34 fc d2 eb 6c ad 1d ac 66 a4 79 fb 38 de aa f1 d3 0a 3210 7e 68 17 a2 2a b0 4f 3d 5b 1e 97 2a 0d 13 ea 86 c6 6b 60 51 4c 96 57 ea 3211 89 c5 7b 04 01 ed c5 aa 8b bc ab 81 3c c5 d6 e7 3213 From the parameter above, message_3 is computed, as the CBOR Sequence 3214 of the following CBOR encoded data items: (C_R, CIPHERTEXT_3). 3216 message_3 = 3217 ( 3218 -24, 3219 h'F5F6DEBD8214051CD583C84096C4801DEBF35B15363DD16EBD8530DFDCFB34FCD2EB 3220 6CAD1DAC66A479FB38DEAAF1D30A7E6817A22AB04F3D5B1E972A0D13EA86C66B60514C 3221 9657EA89C57B0401EDC5AA8BBCAB813CC5D6E7' 3222 ) 3224 Which encodes to the following byte string: 3226 message_3 (CBOR Sequence) (91 bytes) 3227 37 58 58 f5 f6 de bd 82 14 05 1c d5 83 c8 40 96 c4 80 1d eb f3 5b 15 36 3228 3d d1 6e bd 85 30 df dc fb 34 fc d2 eb 6c ad 1d ac 66 a4 79 fb 38 de aa 3229 f1 d3 0a 7e 68 17 a2 2a b0 4f 3d 5b 1e 97 2a 0d 13 ea 86 c6 6b 60 51 4c 3230 96 57 ea 89 c5 7b 04 01 ed c5 aa 8b bc ab 81 3c c5 d6 e7 3232 B.1.4. OSCORE Security Context Derivation 3234 From here, the Initiator and the Responder can derive an OSCORE 3235 Security Context, using the EDHOC-Exporter interface. 3237 From TH_3 and CIPHERTEXT_3, compute the input to the transcript hash 3238 TH_4 = H( TH_3, CIPHERTEXT_3 ), as a CBOR Sequence of these 2 data 3239 items. 3241 Input to calculate TH_4 (CBOR Sequence) (124 bytes) 3242 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 65 0c 3243 30 70 b6 f5 1e 68 e2 ae bb 60 58 58 f5 f6 de bd 82 14 05 1c d5 83 c8 40 3244 96 c4 80 1d eb f3 5b 15 36 3d d1 6e bd 85 30 df dc fb 34 fc d2 eb 6c ad 3245 1d ac 66 a4 79 fb 38 de aa f1 d3 0a 7e 68 17 a2 2a b0 4f 3d 5b 1e 97 2a 3246 0d 13 ea 86 c6 6b 60 51 4c 96 57 ea 89 c5 7b 04 01 ed c5 aa 8b bc ab 81 3247 3c c5 d6 e7 3248 And from there, compute the transcript hash TH_4 = SHA-256(TH_3 , 3249 CIPHERTEXT_4) 3251 TH_4 (CBOR unencoded) (32 bytes) 3252 3b 69 a6 7f ec 7e 73 6c c1 a9 52 6c da 00 02 d4 09 f5 b9 ea 0a 2b e9 60 3253 51 a6 e3 0d 93 05 fd 51 3255 The Master Secret and Master Salt are derived as follows: 3257 Master Secret = EDHOC-Exporter( "OSCORE Master Secret", 16 ) = EDHOC- 3258 KDF(PRK_4x3m, TH_4, "OSCORE Master Secret", 16) = HKDF-Expand( 3259 PRK_4x3m, info_ms, 16 ) 3261 Master Salt = EDHOC-Exporter( "OSCORE Master Salt", 8 ) = EDHOC- 3262 KDF(PRK_4x3m, TH_4, "OSCORE Master Salt", 8) = HKDF-Expand( PRK_4x3m, 3263 info_salt, 8 ) 3265 info_ms for OSCORE Master Secret is defined as follows: 3267 info_ms = [ 3268 10, 3269 h'3B69A67FEC7E736CC1A9526CDA0002D409F5B9EA0A2BE96051A6E30D9305FD51', 3270 "OSCORE Master Secret", 3271 16 3272 ] 3274 Which as a CBOR encoded data item is: 3276 info_ms for OSCORE Master Secret (CBOR-encoded) (58 bytes) 3277 84 0a 58 20 3b 69 a6 7f ec 7e 73 6c c1 a9 52 6c da 00 02 d4 09 f5 b9 ea 3278 0a 2b e9 60 51 a6 e3 0d 93 05 fd 51 74 4f 53 43 4f 52 45 20 4d 61 73 74 3279 65 72 20 53 65 63 72 65 74 10 3281 info_salt for OSCORE Master Salt is defined as follows: 3283 info_salt = [ 3284 10, 3285 h'3B69A67FEC7E736CC1A9526CDA0002D409F5B9EA0A2BE96051A6E30D9305FD51', 3286 "OSCORE Master Salt", 3287 8 3288 ] 3290 Which as a CBOR encoded data item is: 3292 info for OSCORE Master Salt (CBOR-encoded) (56 Bytes) 3293 84 0a 58 20 3b 69 a6 7f ec 7e 73 6c c1 a9 52 6c da 00 02 d4 09 f5 b9 ea 3294 0a 2b e9 60 51 a6 e3 0d 93 05 fd 51 72 4f 53 43 4f 52 45 20 4d 61 73 74 3295 65 72 20 53 61 6c 74 08 3296 From these parameters, OSCORE Master Secret and OSCORE Master Salt 3297 are computed: 3299 OSCORE Master Secret (16 bytes) 3300 96 aa 88 ce 86 5e ba 1f fa f3 89 64 13 2c c4 42 3302 OSCORE Master Salt (8 bytes) 3303 5e c3 ee 41 7c fb ba e9 3305 The client's OSCORE Sender ID is C_R and the server's OSCORE Sender 3306 ID is C_I. 3308 Client's OSCORE Sender ID (1 byte) 3309 00 3311 Server's OSCORE Sender ID (1 byte) 3312 09 3314 The AEAD Algorithm and the hash algorithm are the application AEAD 3315 and hash algorithms in the selected cipher suite. 3317 OSCORE AEAD Algorithm (int) 3318 10 3320 OSCORE Hash Algorithm (int) 3321 -16 3323 B.2. Test Vectors for EDHOC Authenticated with Static Diffie-Hellman 3324 Keys 3326 EDHOC with static Diffie-Hellman keys and raw public keys is used. 3327 In this test vector, a key identifier is used to identify the raw 3328 public key. No auxiliary data is sent in the message exchange. 3330 method (Static DH Based Authentication) 3331 3 3333 CoAP is used as transport and the Initiator acts as CoAP client: 3335 corr (the Initiator can correlate message_1 and message_2) 3336 1 3338 From there, METHOD_CORR has the following value: 3340 METHOD_CORR (4 * method + corr) (int) 3341 13 3342 The Initiator indicates only one cipher suite in the (potentially 3343 trunkated) list of cipher suites. 3345 Supported Cipher Suites (1 byte) 3346 00 3348 The Initiator selected the indicated cipher suite. 3350 Selected Cipher Suite (int) 3351 0 3353 Cipher suite 0 is supported by both the Initiator and the Responder, 3354 see Section 3.4. 3356 B.2.1. Message_1 3358 The Initiator generates its ephemeral key pair. 3360 X (Initiator's ephemeral private key) (32 bytes) 3361 ae 11 a0 db 86 3c 02 27 e5 39 92 fe b8 f5 92 4c 50 d0 a7 ba 6e ea b4 ad 3362 1f f2 45 72 f4 f5 7c fa 3364 G_X (Initiator's ephemeral public key, CBOR unencoded) (32 bytes) 3365 8d 3e f5 6d 1b 75 0a 43 51 d6 8a c2 50 a0 e8 83 79 0e fc 80 a5 38 a4 44 3366 ee 9e 2b 57 e2 44 1a 7c 3368 The Initiator chooses a connection identifier C_I: 3370 Connection identifier chosen by Initiator (1 byte) 3371 16 3373 Note that since C_I is a byte string in the interval h'00' to h'2f', 3374 it is encoded as the corresponding integer - 24 (see bstr_identifier 3375 in Section 5.1), i.e. 0x16 = 22, 22 - 24 = -2, and -2 in CBOR 3376 encoding is equal to 0x21. 3378 C_I (1 byte) 3379 21 3381 Since no auxiliary data is sent: 3383 AD_1 (0 bytes) 3385 Since the list of supported cipher suites needs to contain the 3386 selected cipher suite, the initiator truncates the list of supported 3387 cipher suites to one cipher suite only, 00. 3389 Because one single selected cipher suite is conveyed, it is encoded 3390 as an int instead of an array: 3392 SUITES_I (int) 3393 0 3395 message_1 is constructed as the CBOR Sequence of the data items above 3396 encoded as CBOR. In CBOR diagnostic notation: 3398 message_1 = 3399 ( 3400 13, 3401 0, 3402 h'8D3EF56D1B750A4351D68AC250A0E883790EFC80A538A444EE9E2B57E2441A7C', 3403 -2 3404 ) 3406 Which as a CBOR encoded data item is: 3408 message_1 (CBOR Sequence) (37 bytes) 3409 0d 00 58 20 8d 3e f5 6d 1b 75 0a 43 51 d6 8a c2 50 a0 e8 83 79 0e fc 80 3410 a5 38 a4 44 ee 9e 2b 57 e2 44 1a 7c 21 3412 B.2.2. Message_2 3414 Since METHOD_CORR mod 4 equals 1, C_I is omitted from data_2. 3416 The Responder generates the following ephemeral key pair. 3418 Y (Responder's ephemeral private key) (32 bytes) 3419 c6 46 cd dc 58 12 6e 18 10 5f 01 ce 35 05 6e 5e bc 35 f4 d4 cc 51 07 49 3420 a3 a5 e0 69 c1 16 16 9a 3422 G_Y (Responder's ephemeral public key, CBOR unencoded) (32 bytes) 3423 52 fb a0 bd c8 d9 53 dd 86 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db fc 33 3424 01 04 70 69 45 1b af 35 3426 From G_X and Y or from G_Y and X the ECDH shared secret is computed: 3428 G_XY (ECDH shared secret) (32 bytes) 3429 de fc 2f 35 69 10 9b 3d 1f a4 a7 3d c5 e2 fe b9 e1 15 0d 90 c2 5e e2 f0 3430 66 c2 d8 85 f4 f8 ac 4e 3432 The key and nonce for calculating the 'ciphertext' are calculated as 3433 follows, as specified in Section 4. 3435 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 3437 PRK_2e = HMAC-SHA-256(salt, G_XY) 3439 Salt is the empty byte string. 3441 salt (0 bytes) 3443 From there, PRK_2e is computed: 3445 PRK_2e (32 bytes) 3446 93 9f cb 05 6d 2e 41 4f 1b ec 61 04 61 99 c2 c7 63 d2 7f 0c 3d 15 fa 16 3447 71 fa 13 4e 0d c5 a0 4d 3449 The Responder's static Diffie-Hellman key pair is the following: 3451 R (Responder's private authentication key) (32 bytes) 3452 bb 50 1a ac 67 b9 a9 5f 97 e0 ed ed 6b 82 a6 62 93 4f bb fc 7a d1 b7 4c 3453 1f ca d6 6a 07 94 22 d0 3455 G_R (Responder's public authentication key) (32 bytes) 3456 a3 ff 26 35 95 be b3 77 d1 a0 ce 1d 04 da d2 d4 09 66 ac 6b cb 62 20 51 3457 b8 46 59 18 4d 5d 9a 32 3459 Since the Responder authenticates with a static Diffie-Hellman key, 3460 PRK_3e2m = HKDF-Extract( PRK_2e, G_RX ), where G_RX is the ECDH 3461 shared secret calculated from G_R and X, or G_X and R. 3463 From the Responder's authentication key and the Initiator's ephemeral 3464 key (see Appendix B.2.1), the ECDH shared secret G_RX is calculated. 3466 G_RX (ECDH shared secret) (32 bytes) 3467 21 c7 ef f4 fb 69 fa 4b 67 97 d0 58 84 31 5d 84 11 a3 fd a5 4f 6d ad a6 3468 1d 4f cd 85 e7 90 66 68 3470 PRK_3e2m (32 bytes) 3471 75 07 7c 69 1e 35 01 2d 48 bc 24 c8 4f 2b ab 89 f5 2f ac 03 fe dd 81 3e 3472 43 8c 93 b1 0b 39 93 07 3474 The Responder chooses a connection identifier C_R. 3476 Connection identifier chosen by Responder (1 byte) 3477 00 3479 Note that since C_R is a byte string in the interval h'00' to h'2f', 3480 it is encoded as the corresponding integer - 24 (see bstr_identifier 3481 in Section 5.1), i.e. 0x00 = 0, 0 - 24 = -24, and -24 in CBOR 3482 encoding is equal to 0x37. 3484 C_R (1 byte) 3485 37 3487 Data_2 is constructed as the CBOR Sequence of G_Y and C_R. 3489 data_2 = 3490 ( 3491 h'52FBA0BDC8D953DD86CE1AB2FD7C05A4658C7C30AFDBFC3301047069451BAF35', 3492 -24 3493 ) 3495 Which as a CBOR encoded data item is: 3497 data_2 (CBOR Sequence) (35 bytes) 3498 58 20 52 fb a0 bd c8 d9 53 dd 86 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db 3499 fc 33 01 04 70 69 45 1b af 35 37 3501 From data_2 and message_1, compute the input to the transcript hash 3502 TH_2 = H( message_1, data_2 ), as a CBOR Sequence of these 2 data 3503 items. 3505 Input to calculate TH_2 (CBOR Sequence) (72 bytes) 3506 0d 00 58 20 8d 3e f5 6d 1b 75 0a 43 51 d6 8a c2 50 a0 e8 83 79 0e fc 80 3507 a5 38 a4 44 ee 9e 2b 57 e2 44 1a 7c 21 58 20 52 fb a0 bd c8 d9 53 dd 86 3508 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db fc 33 01 04 70 69 45 1b af 35 37 3510 And from there, compute the transcript hash TH_2 = SHA-256( 3511 message_1, data_2 ) 3513 TH_2 (CBOR unencoded) (32 bytes) 3514 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 36 d0 cf 8c 3515 73 a6 e8 a7 c3 62 1e 26 3517 The Responder's subject name is the empty string: 3519 Responders's subject name (text string) 3520 "" 3522 ID_CRED_R is the following: 3524 ID_CRED_R = 3525 { 3526 4: h'05' 3527 } 3529 ID_CRED_R (4 bytes) 3530 a1 04 41 05 3531 CRED_R is the following COSE_Key: 3533 { 3534 1: 1, 3535 -1: 4, 3536 -2: h'A3FF263595BEB377D1A0CE1D04DAD2D40966AC6BCB622051B84659184D5D9A32, 3537 "subject name": "" 3538 } 3540 Which encodes to the following byte string: 3542 CRED_R (54 bytes) 3543 a4 01 01 20 04 21 58 20 a3 ff 26 35 95 be b3 77 d1 a0 ce 1d 04 da d2 d4 3544 09 66 ac 6b cb 62 20 51 b8 46 59 18 4d 5d 9a 32 6c 73 75 62 6a 65 63 74 3545 20 6e 61 6d 65 60 3547 Since no auxiliary data is sent: 3549 AD_2 (0 bytes) 3551 The plaintext is defined as the empty string: 3553 P_2m (0 bytes) 3555 The Enc_structure is defined as follows: [ "Encrypt0", 3556 << ID_CRED_R >>, << TH_2, CRED_R >> ], so ID_CRED_R is encoded as a 3557 CBOR bstr, and the contatenation of the CBOR byte strings TH_2 and 3558 CRED_R is wrapped in a CBOR bstr. 3560 A_2m = 3561 [ 3562 "Encrypt0", 3563 h'A1044105', 3564 h'5820DECFD64A3667640A0233B04AA8AA91F68956B8A536D0CF8C73A6E8A7C3621E2 3565 6A401012004215820A3FF263595BEB377D1A0CE1D04DAD2D40966AC6BCB622051B846 3566 59184D5D9A326C7375626A656374206E616D6560' 3567 ] 3569 Which encodes to the following byte string to be used as Additional 3570 Authenticated Data: 3572 A_2m (CBOR-encoded) (105 bytes) 3573 83 68 45 6e 63 72 79 70 74 30 44 a1 04 41 05 58 58 58 20 de cf d6 4a 36 3574 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 36 d0 cf 8c 73 a6 e8 a7 c3 3575 62 1e 26 a4 01 01 20 04 21 58 20 a3 ff 26 35 95 be b3 77 d1 a0 ce 1d 04 3576 da d2 d4 09 66 ac 6b cb 62 20 51 b8 46 59 18 4d 5d 9a 32 6c 73 75 62 6a 3577 65 63 74 20 6e 61 6d 65 60 3578 info for K_2m is defined as follows: 3580 info for K_2m = 3581 [ 3582 10, 3583 h'DECFD64A3667640A0233B04AA8AA91F68956B8A536D0CF8C73A6E8A7C3621E26', 3584 "K_2m", 3585 16 3586 ] 3588 Which as a CBOR encoded data item is: 3590 info for K_2m (CBOR-encoded) (42 bytes) 3591 84 0a 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 3592 36 d0 cf 8c 73 a6 e8 a7 c3 62 1e 26 64 4b 5f 32 6d 10 3594 From these parameters, K_2m is computed. Key K_2m is the output of 3595 HKDF-Expand(PRK_3e2m, info, L), where L is the length of K_2m, so 16 3596 bytes. 3598 K_2m (16 bytes) 3599 4e cd ef ba d8 06 81 8b 62 51 b9 d7 86 78 bc 76 3601 info for IV_2m is defined as follows: 3603 info for IV_2m = 3604 [ 3605 10, 3606 h'A51C76463E8AE58FD3B8DC5EDE1E27143CC92D223EACD9E5FF6E3FAC876658A5', 3607 "IV_2m", 3608 13 3609 ] 3611 Which as a CBOR encoded data item is: 3613 info for IV_2m (CBOR-encoded) (43 bytes) 3614 84 0a 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 3615 36 d0 cf 8c 73 a6 e8 a7 c3 62 1e 26 65 49 56 5f 32 6d 0d 3617 From these parameters, IV_2m is computed. IV_2m is the output of 3618 HKDF-Expand(PRK_3e2m, info, L), where L is the length of IV_2m, so 13 3619 bytes. 3621 IV_2m (13 bytes) 3622 e9 b8 e4 b1 bd 02 f4 9a 82 0d d3 53 4f 3624 Finally, COSE_Encrypt0 is computed from the parameters above. 3626 * protected header = CBOR-encoded ID_CRED_R 3628 * external_aad = A_2m 3630 * empty plaintext = P_2m 3632 MAC_2 is the 'ciphertext' of the COSE_Encrypt0 with empty plaintext. 3633 In case of cipher suite 0 the AEAD is AES-CCM trunkated to 8 bytes: 3635 MAC_2 (CBOR unencoded) (8 bytes) 3636 42 e7 99 78 43 1e 6b 8f 3638 Since method = 2, Signature_or_MAC_2 is MAC_2: 3640 Signature_or_MAC_2 (CBOR unencoded) (8 bytes) 3641 42 e7 99 78 43 1e 6b 8f 3643 CIPHERTEXT_2 is the ciphertext resulting from XOR between plaintext 3644 and KEYSTREAM_2 which is derived from TH_2 and the pseudorandom key 3645 PRK_2e. 3647 The plaintext is the CBOR Sequence of the items ID_CRED_R and the 3648 CBOR encoded Signature_or_MAC_2, in this order (AD_2 is empty). 3650 Note that since ID_CRED_R contains a single 'kid' parameter, i.e., 3651 ID_CRED_R = { 4 : kid_R }, only the byte string kid_R is conveyed in 3652 the plaintext encoded as a bstr_identifier. kid_R is encoded as the 3653 corresponding integer - 24 (see bstr_identifier in Section 5.1), i.e. 3654 0x05 = 5, 5 - 24 = -19, and -19 in CBOR encoding is equal to 0x32. 3656 The plaintext is the following: 3658 P_2e (CBOR Sequence) (10 bytes) 3659 32 48 42 e7 99 78 43 1e 6b 8f 3661 KEYSTREAM_2 = HKDF-Expand( PRK_2e, info, length ), where length is 3662 the length of the plaintext, so 10. 3664 info for KEYSTREAM_2 = 3665 [ 3666 10, 3667 h'DECFD64A3667640A0233B04AA8AA91F68956B8A536D0CF8C73A6E8A7C3621E26', 3668 "KEYSTREAM_2", 3669 10 3670 ] 3672 Which as a CBOR encoded data item is: 3674 info for KEYSTREAM_2 (CBOR-encoded) (49 bytes) 3675 84 0a 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 3676 36 d0 cf 8c 73 a6 e8 a7 c3 62 1e 26 6b 4b 45 59 53 54 52 45 41 4d 5f 32 3677 0a 3679 From there, KEYSTREAM_2 is computed: 3681 KEYSTREAM_2 (10 bytes) 3682 91 b9 ff ba 9b f5 5a d1 57 16 3684 Using the parameters above, the ciphertext CIPHERTEXT_2 can be 3685 computed: 3687 CIPHERTEXT_2 (CBOR unencoded) (10 bytes) 3688 a3 f1 bd 5d 02 8d 19 cf 3c 99 3690 message_2 is the CBOR Sequence of data_2 and CIPHERTEXT_2, in this 3691 order: 3693 message_2 = 3694 ( 3695 data_2, 3696 h'A3F1BD5D028D19CF3C99' 3697 ) 3699 Which as a CBOR encoded data item is: 3701 message_2 (CBOR Sequence) (46 bytes) 3702 58 20 52 fb a0 bd c8 d9 53 dd 86 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db 3703 fc 33 01 04 70 69 45 1b af 35 37 4a a3 f1 bd 5d 02 8d 19 cf 3c 99 3705 B.2.3. Message_3 3707 Since corr equals 1, C_R is not omitted from data_3. 3709 The Initiator's static Diffie-Hellman key pair is the following: 3711 I (Initiator's private authentication key) (32 bytes) 3712 2b be a6 55 c2 33 71 c3 29 cf bd 3b 1f 02 c6 c0 62 03 38 37 b8 b5 90 99 3713 a4 43 6f 66 60 81 b0 8e 3715 G_I (Initiator's public authentication key, CBOR unencoded) (32 bytes) 3716 2c 44 0c c1 21 f8 d7 f2 4c 3b 0e 41 ae da fe 9c aa 4f 4e 7a bb 83 5e c3 3717 0f 1d e8 8a db 96 ff 71 3719 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 3721 From the Initiator's authentication key and the Responder's ephemeral 3722 key (see Appendix B.2.2), the ECDH shared secret G_IY is calculated. 3724 G_IY (ECDH shared secret) (32 bytes) 3725 cb ff 8c d3 4a 81 df ec 4c b6 5d 9a 57 2e bd 09 64 45 0c 78 56 3d a4 98 3726 1d 80 d3 6c 8b 1a 75 2a 3728 PRK_4x3m = HMAC-SHA-256 (PRK_3e2m, G_IY). 3730 PRK_4x3m (32 bytes) 3731 02 56 2f 1f 01 78 5c 0a a5 f5 94 64 0c 49 cb f6 9f 72 2e 9e 6c 57 83 7d 3732 8e 15 79 ec 45 fe 64 7a 3734 data 3 is equal to C_R. 3736 data_3 (CBOR Sequence) (1 byte) 3737 37 3739 From data_3, CIPHERTEXT_2, and TH_2, compute the input to the 3740 transcript hash TH_3 = H(TH_2 , CIPHERTEXT_2, data_3), as a CBOR 3741 Sequence of these 3 data items. 3743 Input to calculate TH_3 (CBOR Sequence) (46 bytes) 3744 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 36 d0 3745 cf 8c 73 a6 e8 a7 c3 62 1e 26 4a a3 f1 bd 5d 02 8d 19 cf 3c 99 37 3747 And from there, compute the transcript hash TH_3 = SHA-256(TH_2 , 3748 CIPHERTEXT_2, data_3) 3750 TH_3 (CBOR unencoded) (32 bytes) 3751 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 d7 cb 8b 84 3752 db 03 ff a5 83 a3 5f cb 3754 The initiator's subject name is the empty string: 3756 Initiator's subject name (text string) 3757 "" 3759 And its credential is: 3761 ID_CRED_I = 3762 { 3763 4: h'23' 3764 } 3766 ID_CRED_I (4 bytes) 3767 a1 04 41 23 3768 CRED_I is the following COSE_Key: 3770 { 3771 1: 1, 3772 -1: 4, 3773 -2: h'2C440CC121F8D7F24C3B0E41AEDAFE9CAA4F4E7ABB835EC30F1DE88ADB96FF71', 3774 "subject name": "" 3775 } 3777 Which encodes to the following byte string: 3779 CRED_I (54 bytes) 3780 a4 01 01 20 04 21 58 20 2c 44 0c c1 21 f8 d7 f2 4c 3b 0e 41 ae da fe 9c 3781 aa 4f 4e 7a bb 83 5e c3 0f 1d e8 8a db 96 ff 71 6c 73 75 62 6a 65 63 74 3782 20 6e 61 6d 65 60 3784 Since no auxiliary data is exchanged: 3786 AD_3 (0 bytes) 3788 The plaintext of the COSE_Encrypt is the empty string: 3790 P_3m (0 bytes) 3792 The associated data is the following: [ "Encrypt0", << ID_CRED_I >>, 3793 << TH_3, CRED_I, ? AD_3 >> ]. 3795 A_3m (CBOR-encoded) (105 bytes) 3796 83 68 45 6e 63 72 79 70 74 30 44 a1 04 41 23 58 58 58 20 b6 cd 80 4f c4 3797 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 d7 cb 8b 84 db 03 ff a5 83 3798 a3 5f cb a4 01 01 20 04 21 58 20 2c 44 0c c1 21 f8 d7 f2 4c 3b 0e 41 ae 3799 da fe 9c aa 4f 4e 7a bb 83 5e c3 0f 1d e8 8a db 96 ff 71 6c 73 75 62 6a 3800 65 63 74 20 6e 61 6d 65 60 3802 Info for K_3m is computed as follows: 3804 info for K_3m = 3805 [ 3806 10, 3807 h'B6CD804FC4B9D7CAC502ABD77CDA74E41CB01182D7CB8B84DB03FFA583A35FCB', 3808 "K_3m", 3809 16 3810 ] 3812 Which as a CBOR encoded data item is: 3814 info for K_3m (CBOR-encoded) (42 bytes) 3815 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 3816 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 64 4b 5f 33 6d 10 3818 From these parameters, K_3m is computed. Key K_3m is the output of 3819 HKDF-Expand(PRK_4x3m, info, L), where L is the length of K_2m, so 16 3820 bytes. 3822 K_3m (16 bytes) 3823 02 c7 e7 93 89 9d 90 d1 28 28 10 26 96 94 c9 58 3825 Nonce IV_3m is the output of HKDF-Expand(PRK_4x3m, info, L), where L 3826 = 13 bytes. 3828 Info for IV_3m is defined as follows: 3830 info for IV_3m = 3831 [ 3832 10, 3833 h'B6CD804FC4B9D7CAC502ABD77CDA74E41CB01182D7CB8B84DB03FFA583A35FCB', 3834 "IV_3m", 3835 13 3836 ] 3838 Which as a CBOR encoded data item is: 3840 info for IV_3m (CBOR-encoded) (43 bytes) 3841 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 3842 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 65 49 56 5f 33 6d 0d 3844 From these parameters, IV_3m is computed: 3846 IV_3m (13 bytes) 3847 0d a7 cc 3a 6f 9a b2 48 52 ce 8b 37 a6 3849 MAC_3 is the 'ciphertext' of the COSE_Encrypt0 with empty plaintext. 3850 In case of cipher suite 0 the AEAD is AES-CCM trunkated to 8 bytes: 3852 MAC_3 (CBOR unencoded) (8 bytes) 3853 ee 59 8e a6 61 17 dc c3 3855 Since method = 3, Signature_or_MAC_3 is MAC_3: 3857 Signature_or_MAC_3 (CBOR unencoded) (8 bytes) 3858 ee 59 8e a6 61 17 dc c3 3860 Finally, the outer COSE_Encrypt0 is computed. 3862 The plaintext is the CBOR Sequence of the items ID_CRED_I and the 3863 CBOR encoded Signature_or_MAC_3, in this order (AD_3 is empty). 3865 Note that since ID_CRED_I contains a single 'kid' parameter, i.e., 3866 ID_CRED_I = { 4 : kid_I }, only the byte string kid_I is conveyed in 3867 the plaintext encoded as a bstr_identifier. kid_I is encoded as the 3868 corresponding integer - 24 (see bstr_identifier in Section 5.1), i.e. 3869 0x23 = 35, 35 - 24 = 11, and 11 in CBOR encoding is equal to 0x0b. 3871 P_3ae (CBOR Sequence) (10 bytes) 3872 0b 48 ee 59 8e a6 61 17 dc c3 3874 The Associated data A is the following: Associated data A = [ 3875 "Encrypt0", h'', TH_3 ] 3877 A_3ae (CBOR-encoded) (45 bytes) 3878 83 68 45 6e 63 72 79 70 74 30 40 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab 3879 d7 7c da 74 e4 1c b0 11 82 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 3881 Key K_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 3883 info is defined as follows: 3885 info for K_3ae = 3886 [ 3887 10, 3888 h'B6CD804FC4B9D7CAC502ABD77CDA74E41CB01182D7CB8B84DB03FFA583A35FCB', 3889 "K_3ae", 3890 16 3891 ] 3893 Which as a CBOR encoded data item is: 3895 info for K_3ae (CBOR-encoded) (43 bytes) 3896 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 3897 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 65 4b 5f 33 61 65 10 3899 L is the length of K_3ae, so 16 bytes. 3901 From these parameters, K_3ae is computed: 3903 K_3ae (16 bytes) 3904 6b a4 c8 83 1d e3 ae 23 e9 8e f7 35 08 d0 95 86 3906 Nonce IV_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 3908 info is defined as follows: 3910 info for IV_3ae = 3911 [ 3912 10, 3913 h'97D8AD42334833EB25B960A5EB0704505F89671A0168AA1115FAF92D9E67EF04', 3914 "IV_3ae", 3915 13 3916 ] 3918 Which as a CBOR encoded data item is: 3920 info for IV_3ae (CBOR-encoded) (44 bytes) 3921 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 3922 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 66 49 56 5f 33 61 65 0d 3924 L is the length of IV_3ae, so 13 bytes. 3926 From these parameters, IV_3ae is computed: 3928 IV_3ae (13 bytes) 3929 6c 6d 0f e1 1e 9a 1a f3 7b 87 84 55 10 3931 Using the parameters above, the 'ciphertext' CIPHERTEXT_3 can be 3932 computed: 3934 CIPHERTEXT_3 (CBOR unencoded) (18 bytes) 3935 d5 53 5f 31 47 e8 5f 1c fa cd 9e 78 ab f9 e0 a8 1b bf 3937 From the parameter above, message_3 is computed, as the CBOR Sequence 3938 of the following items: (C_R, CIPHERTEXT_3). 3940 message_3 = 3941 ( 3942 -24, 3943 h'D5535F3147E85F1CFACD9E78ABF9E0A81BBF' 3944 ) 3946 Which encodes to the following byte string: 3948 message_3 (CBOR Sequence) (20 bytes) 3949 37 52 d5 53 5f 31 47 e8 5f 1c fa cd 9e 78 ab f9 e0 a8 1b bf 3951 B.2.4. OSCORE Security Context Derivation 3953 From here, the Initiator and the Responder can derive an OSCORE 3954 Security Context, using the EDHOC-Exporter interface. 3956 From TH_3 and CIPHERTEXT_3, compute the input to the transcript hash 3957 TH_4 = H( TH_3, CIPHERTEXT_3 ), as a CBOR Sequence of these 2 data 3958 items. 3960 Input to calculate TH_4 (CBOR Sequence) (53 bytes) 3961 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 d7 cb 3962 8b 84 db 03 ff a5 83 a3 5f cb 52 d5 53 5f 31 47 e8 5f 1c fa cd 9e 78 ab 3963 f9 e0 a8 1b bf 3965 And from there, compute the transcript hash TH_4 = SHA-256(TH_3 , 3966 CIPHERTEXT_4) 3968 TH_4 (CBOR unencoded) (32 bytes) 3969 7c cf de dc 2c 10 ca 03 56 e9 57 b9 f6 a5 92 e0 fa 74 db 2a b5 4f 59 24 3970 40 96 f9 a2 ac 56 d2 07 3972 The Master Secret and Master Salt are derived as follows: 3974 Master Secret = EDHOC-Exporter( "OSCORE Master Secret", 16 ) = EDHOC- 3975 KDF(PRK_4x3m, TH_4, "OSCORE Master Secret", 16) = HKDF-Expand( 3976 PRK_4x3m, info_ms, 16 ) 3978 Master Salt = EDHOC-Exporter( "OSCORE Master Salt", 8 ) = EDHOC- 3979 KDF(PRK_4x3m, TH_4, "OSCORE Master Salt", 8) = HKDF-Expand( PRK_4x3m, 3980 info_salt, 8 ) 3982 info_ms for OSCORE Master Secret is defined as follows: 3984 info_ms = [ 3985 10, 3986 h'7CCFDEDC2C10CA0356E957B9F6A592E0FA74DB2AB54F59244096F9A2AC56D207', 3987 "OSCORE Master Secret", 3988 16 3989 ] 3991 Which as a CBOR encoded data item is: 3993 info_ms for OSCORE Master Secret (CBOR-encoded) (58 bytes) 3994 84 0a 58 20 7c cf de dc 2c 10 ca 03 56 e9 57 b9 f6 a5 92 e0 fa 74 db 2a 3995 b5 4f 59 24 40 96 f9 a2 ac 56 d2 07 74 4f 53 43 4f 52 45 20 4d 61 73 74 3996 65 72 20 53 65 63 72 65 74 10 3998 info_salt for OSCORE Master Salt is defined as follows: 4000 info_salt = [ 4001 10, 4002 h'7CCFDEDC2C10CA0356E957B9F6A592E0FA74DB2AB54F59244096F9A2AC56D207', 4003 "OSCORE Master Salt", 4004 8 4005 ] 4007 Which as a CBOR encoded data item is: 4009 info for OSCORE Master Salt (CBOR-encoded) (56 Bytes) 4010 84 0a 58 20 7c cf de dc 2c 10 ca 03 56 e9 57 b9 f6 a5 92 e0 fa 74 db 2a 4011 b5 4f 59 24 40 96 f9 a2 ac 56 d2 07 72 4f 53 43 4f 52 45 20 4d 61 73 74 4012 65 72 20 53 61 6c 74 08 4014 From these parameters, OSCORE Master Secret and OSCORE Master Salt 4015 are computed: 4017 OSCORE Master Secret (16 bytes) 4018 c3 4a 50 6d 0e bf bd 17 03 04 86 13 5f 9c b3 50 4020 OSCORE Master Salt (8 bytes) 4021 c2 24 34 9d 9b 34 ca 8c 4023 The client's OSCORE Sender ID is C_R and the server's OSCORE Sender 4024 ID is C_I. 4026 Client's OSCORE Sender ID (1 byte) 4027 00 4029 Server's OSCORE Sender ID (1 byte) 4030 16 4032 The AEAD Algorithm and the hash algorithm are the application AEAD 4033 and hash algorithms in the selected cipher suite. 4035 OSCORE AEAD Algorithm (int) 4036 10 4038 OSCORE Hash Algorithm (int) 4039 -16 4041 Appendix C. Applicability Statement 4043 EDHOC requires certain parameters to be agreed upon between Initiator 4044 and Responder. EDHOC supports cipher suite negotiation, but certain 4045 other parameters need to be agreed beforehand: 4047 1. Method and correlation of underlying transport messages 4048 (METHOD_CORR; see Section 3.2.1 and Section 3.2.4). 4050 2. How EDHOC messages are transported and how the peer detects that 4051 an EDHOC message is received, e.g. URI, media type (for an 4052 example using CoAP, see Section 7.2.1). 4054 3. Type of authentication credentials (CRED_I, CRED_R; see 4055 Section 3.3.4). 4057 4. Type for identifying authentication credentials (ID_CRED_I, 4058 ID_CRED_R; see Section 3.3.4). 4060 5. Type and use of Auxiliary Data (AD_1, AD_2, AD_3; see 4061 Section 3.6). 4063 6. Identifier used as identity of endpoint (see Section 3.3). 4065 7. If message_4 shall be sent/expected, and if not, how to ensure 4066 protected application message is sent from the Responder to the 4067 Initiator (see Section 7.1). 4069 An example of an applicability statement is shown in the next 4070 section. 4072 Note that for some of the parameters, like METHOD_CORR, ID_CRED_x, 4073 type of AD_x, the receiver is able to assert whether it supports the 4074 received parameter or not and thus, if the protocol fails because of 4075 this, to infer the reason why the protocol failed. 4077 For other parameters, like authentication credential which is not 4078 transported, it may be difficult to detect if integrity failed 4079 because of wrong credential or for some other reason. For example, 4080 in the case of public key certificates where there is a large variety 4081 of profiles and alternative encodings, unless the certificate (chain) 4082 is transported, the endpoints need to agree on the precise format. 4084 Note also that it is not always necessary for the endpoints to agree 4085 on the transport for the EDHOC messages. For example, a mix of CoAP 4086 and HTTP may be used along the path and still allow correlation 4087 between message_1 and message_2. 4089 EDHOC enables policy decisions based on the identity of the peer. If 4090 other information must to be conveyed, such as target application or 4091 use (e.g. if there is more than one application/use with different 4092 policies) then this may be signalled for example in URI or Auxiliary 4093 Data and could to be specified in the applicability statement. 4095 C.1. Template: Use of EDHOC in the XX Protocol 4097 For use of EDHOC in the XX protocol, the following assumptions are 4098 made on the parameters. 4100 * METHOD_CORR = 5 4102 - method = 1 (I uses signature key, R uses static DH key.) 4104 - corr = 1 (CoAP Token or other transport data enables 4105 correlation between message_1 and message_2.) 4107 * EDHOC requests are expected by the server at /app1-edh, no 4108 Content-Format needed. 4110 * CRED_I is an 802.1AR IDevID encoded as a CBOR Certificate of type 4111 0 [I-D.mattsson-cose-cbor-cert-compress]. 4113 - R acquires CRED_I out-of-band, indicated in AD_1 4115 - ID_CRED_I = {4: h''} is a kid with value empty byte string 4117 * CRED_R is a COSE_Key of type OKP as specified in Section 3.3.4. 4119 - The CBOR map has parameters 1 (kty), -1 (crv), and -2 4120 (x-coordinate). 4122 * ID_CRED_R = CRED_R 4124 * AD_1 contains Auxiliary Data of type A (TBD) 4126 * AD_2 contains Auxiliary Data of type B (TBD) 4128 * No use of message_4: the application sends protected messages from 4129 R to I. 4131 * Auxiliary Data is processed as specified in 4132 [I-D.selander-ace-ake-authz]. 4134 * Need to specify use of C_I/C_R ? (TBD) 4136 Acknowledgments 4138 The authors want to thank Alessandro Bruni, Karthikeyan Bhargavan, 4139 Timothy Claeys, Martin Disch, Theis Groenbech Petersen, Dan Harkins, 4140 Klaus Hartke, Russ Housley, Stefan Hristozov, Alexandros Krontiris, 4141 Ilari Liusvaara, Karl Norrman, Salvador Perez, Eric Rescorla, Michael 4142 Richardson, Thorvald Sahl Joergensen, Jim Schaad, Carsten Schuermann, 4143 Ludwig Seitz, Stanislav Smyshlyaev, Valery Smyslov, Peter van der 4144 Stok, Rene Struik, Vaishnavi Sundararajan, Erik Thormarker, Marco 4145 Tiloca, Michel Veillette, and Malisa Vucinic for reviewing and 4146 commenting on intermediate versions of the draft. We are especially 4147 indebted to Jim Schaad for his continuous reviewing and 4148 implementation of different versions of the draft. 4150 Work on this document has in part been supported by the H2020 project 4151 SIFIS-Home (grant agreement 952652). 4153 Authors' Addresses 4155 Göran Selander 4156 Ericsson AB 4158 Email: goran.selander@ericsson.com 4160 John Preuß Mattsson 4161 Ericsson AB 4163 Email: john.mattsson@ericsson.com 4165 Francesca Palombini 4166 Ericsson AB 4168 Email: francesca.palombini@ericsson.com