idnits 2.17.1 draft-ietf-lake-edhoc-07.txt: -(2483): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(2515): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(2554): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding -(2632): 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 8 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 (24 May 2021) is 1068 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 1721 -- Looks like a reference, but probably isn't: '5' on line 1721 -- Looks like a reference, but probably isn't: '9' on line 1717 -- Looks like a reference, but probably isn't: '8' on line 1721 -- Looks like a reference, but probably isn't: '7' on line 1721 ** Downref: Normative reference to an Informational RFC: RFC 5869 ** Downref: Normative reference to an Informational RFC: RFC 6090 ** Downref: Normative reference to an Informational RFC: RFC 6979 ** Downref: Normative reference to an Informational RFC: RFC 7748 ** Downref: Normative reference to an Informational RFC: RFC 8376 -- Possible downref: Normative reference to a draft: ref. 'I-D.ietf-cose-rfc8152bis-struct' ** Downref: Normative reference to an Informational draft: draft-ietf-cose-rfc8152bis-algs (ref. 'I-D.ietf-cose-rfc8152bis-algs') == Outdated reference: A later version (-09) exists of draft-ietf-cose-x509-08 == Outdated reference: A later version (-14) exists of draft-ietf-core-echo-request-tag-12 ** Downref: Normative reference to an Informational draft: draft-ietf-lake-reqs (ref. 'I-D.ietf-lake-reqs') == Outdated reference: A later version (-07) exists of draft-ietf-lwig-security-protocol-comparison-05 == Outdated reference: A later version (-05) exists of draft-selander-ace-ake-authz-02 == Outdated reference: A later version (-11) exists of draft-ietf-core-oscore-edhoc-00 == Outdated reference: A later version (-09) exists of draft-ietf-cose-cbor-encoded-cert-00 == Outdated reference: A later version (-04) exists of draft-mattsson-cfrg-det-sigs-with-noise-02 Summary: 8 errors (**), 0 flaws (~~), 9 warnings (==), 7 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group G. Selander 3 Internet-Draft J. Mattsson 4 Intended status: Standards Track F. Palombini 5 Expires: 25 November 2021 Ericsson AB 6 24 May 2021 8 Ephemeral Diffie-Hellman Over COSE (EDHOC) 9 draft-ietf-lake-edhoc-07 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 25 November 2021. 39 Copyright Notice 41 Copyright (c) 2021 IETF Trust and the persons identified as the 42 document authors. All rights reserved. 44 This document is subject to BCP 78 and the IETF Trust's Legal 45 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 46 license-info) in effect on the date of publication of this document. 47 Please review these documents carefully, as they describe your rights 48 and restrictions with respect to this document. Code Components 49 extracted from this document must include Simplified BSD License text 50 as described in Section 4.e of the Trust Legal Provisions and are 51 provided without warranty as described in the Simplified BSD License. 53 Table of Contents 55 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 56 1.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . 4 57 1.2. Use of EDHOC . . . . . . . . . . . . . . . . . . . . . . 5 58 1.3. Message Size Examples . . . . . . . . . . . . . . . . . . 6 59 1.4. Document Structure . . . . . . . . . . . . . . . . . . . 6 60 1.5. Terminology and Requirements Language . . . . . . . . . . 6 61 2. EDHOC Outline . . . . . . . . . . . . . . . . . . . . . . . . 7 62 3. Protocol Elements . . . . . . . . . . . . . . . . . . . . . . 9 63 3.1. General . . . . . . . . . . . . . . . . . . . . . . . . . 9 64 3.2. Method and Correlation . . . . . . . . . . . . . . . . . 10 65 3.2.1. Method . . . . . . . . . . . . . . . . . . . . . . . 10 66 3.2.2. Connection Identifiers . . . . . . . . . . . . . . . 10 67 3.2.3. Transport . . . . . . . . . . . . . . . . . . . . . . 11 68 3.2.4. Message Correlation . . . . . . . . . . . . . . . . . 11 69 3.3. Authentication Parameters . . . . . . . . . . . . . . . . 11 70 3.3.1. Authentication Keys . . . . . . . . . . . . . . . . . 11 71 3.3.2. Identities . . . . . . . . . . . . . . . . . . . . . 12 72 3.3.3. Authentication Credentials . . . . . . . . . . . . . 13 73 3.3.4. Identification of Credentials . . . . . . . . . . . . 15 74 3.4. Cipher Suites . . . . . . . . . . . . . . . . . . . . . . 16 75 3.5. Ephemeral Public Keys . . . . . . . . . . . . . . . . . . 18 76 3.6. External Authorization Data . . . . . . . . . . . . . . . 18 77 3.7. Applicability Statement . . . . . . . . . . . . . . . . . 19 78 4. Key Derivation . . . . . . . . . . . . . . . . . . . . . . . 20 79 4.1. EDHOC-Exporter Interface . . . . . . . . . . . . . . . . 23 80 5. Message Formatting and Processing . . . . . . . . . . . . . . 23 81 5.1. Encoding of bstr_identifier . . . . . . . . . . . . . . . 24 82 5.2. Message Processing Outline . . . . . . . . . . . . . . . 24 83 5.3. EDHOC Message 1 . . . . . . . . . . . . . . . . . . . . . 25 84 5.3.1. Formatting of Message 1 . . . . . . . . . . . . . . . 25 85 5.3.2. Initiator Processing of Message 1 . . . . . . . . . . 26 86 5.3.3. Responder Processing of Message 1 . . . . . . . . . . 27 87 5.4. EDHOC Message 2 . . . . . . . . . . . . . . . . . . . . . 28 88 5.4.1. Formatting of Message 2 . . . . . . . . . . . . . . . 28 89 5.4.2. Responder Processing of Message 2 . . . . . . . . . . 28 90 5.4.3. Initiator Processing of Message 2 . . . . . . . . . . 30 91 5.5. EDHOC Message 3 . . . . . . . . . . . . . . . . . . . . . 31 92 5.5.1. Formatting of Message 3 . . . . . . . . . . . . . . . 31 93 5.5.2. Initiator Processing of Message 3 . . . . . . . . . . 31 94 5.5.3. Responder Processing of Message 3 . . . . . . . . . . 34 95 6. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 34 96 6.1. Success . . . . . . . . . . . . . . . . . . . . . . . . . 36 97 6.2. Unspecified . . . . . . . . . . . . . . . . . . . . . . . 36 98 6.3. Wrong Selected Cipher Suite . . . . . . . . . . . . . . . 36 99 6.3.1. Cipher Suite Negotiation . . . . . . . . . . . . . . 37 100 6.3.2. Examples . . . . . . . . . . . . . . . . . . . . . . 37 101 7. Transferring EDHOC and Deriving an OSCORE Context . . . . . . 38 102 7.1. EDHOC Message 4 . . . . . . . . . . . . . . . . . . . . . 38 103 7.1.1. Formatting of Message 4 . . . . . . . . . . . . . . . 39 104 7.1.2. Responder Processing of Message 4 . . . . . . . . . . 39 105 7.1.3. Initiator Processing of Message 4 . . . . . . . . . . 40 106 7.2. Transferring EDHOC in CoAP . . . . . . . . . . . . . . . 40 107 8. Security Considerations . . . . . . . . . . . . . . . . . . . 42 108 8.1. Security Properties . . . . . . . . . . . . . . . . . . . 42 109 8.2. Cryptographic Considerations . . . . . . . . . . . . . . 45 110 8.3. Cipher Suites and Cryptographic Algorithms . . . . . . . 46 111 8.4. Unprotected Data . . . . . . . . . . . . . . . . . . . . 46 112 8.5. Denial-of-Service . . . . . . . . . . . . . . . . . . . . 47 113 8.6. Implementation Considerations . . . . . . . . . . . . . . 47 114 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 49 115 9.1. EDHOC Exporter Label . . . . . . . . . . . . . . . . . . 49 116 9.2. EDHOC Cipher Suites Registry . . . . . . . . . . . . . . 49 117 9.3. EDHOC Method Type Registry . . . . . . . . . . . . . . . 50 118 9.4. EDHOC Error Codes Registry . . . . . . . . . . . . . . . 51 119 9.5. The Well-Known URI Registry . . . . . . . . . . . . . . . 51 120 9.6. Media Types Registry . . . . . . . . . . . . . . . . . . 51 121 9.7. CoAP Content-Formats Registry . . . . . . . . . . . . . . 52 122 9.8. Expert Review Instructions . . . . . . . . . . . . . . . 52 123 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 53 124 10.1. Normative References . . . . . . . . . . . . . . . . . . 53 125 10.2. Informative References . . . . . . . . . . . . . . . . . 55 126 Appendix A. Compact Representation . . . . . . . . . . . . . . . 58 127 Appendix B. Use of CBOR, CDDL and COSE in EDHOC . . . . . . . . 58 128 B.1. CBOR and CDDL . . . . . . . . . . . . . . . . . . . . . . 59 129 B.2. CDDL Definitions . . . . . . . . . . . . . . . . . . . . 59 130 B.3. COSE . . . . . . . . . . . . . . . . . . . . . . . . . . 61 131 Appendix C. Test Vectors . . . . . . . . . . . . . . . . . . . . 61 132 C.1. Test Vectors for EDHOC Authenticated with Signature Keys 133 (x5t) . . . . . . . . . . . . . . . . . . . . . . . . . . 62 134 C.1.1. Message_1 . . . . . . . . . . . . . . . . . . . . . . 62 135 C.1.2. Message_2 . . . . . . . . . . . . . . . . . . . . . . 63 136 C.1.3. Message_3 . . . . . . . . . . . . . . . . . . . . . . 71 137 C.1.4. OSCORE Security Context Derivation . . . . . . . . . 77 138 C.2. Test Vectors for EDHOC Authenticated with Static 139 Diffie-Hellman Keys . . . . . . . . . . . . . . . . . . . 79 140 C.2.1. Message_1 . . . . . . . . . . . . . . . . . . . . . . 80 141 C.2.2. Message_2 . . . . . . . . . . . . . . . . . . . . . . 81 142 C.2.3. Message_3 . . . . . . . . . . . . . . . . . . . . . . 87 143 C.2.4. OSCORE Security Context Derivation . . . . . . . . . 92 144 Appendix D. Applicability Template . . . . . . . . . . . . . . . 94 145 Appendix E. EDHOC Message Deduplication . . . . . . . . . . . . 95 146 Appendix F. Change Log . . . . . . . . . . . . . . . . . . . . . 96 147 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 99 148 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 99 150 1. Introduction 152 1.1. Motivation 154 Many Internet of Things (IoT) deployments require technologies which 155 are highly performant in constrained environments [RFC7228]. IoT 156 devices may be constrained in various ways, including memory, 157 storage, processing capacity, and power. The connectivity for these 158 settings may also exhibit constraints such as unreliable and lossy 159 channels, highly restricted bandwidth, and dynamic topology. The 160 IETF has acknowledged this problem by standardizing a range of 161 lightweight protocols and enablers designed for the IoT, including 162 the Constrained Application Protocol (CoAP, [RFC7252]), Concise 163 Binary Object Representation (CBOR, [RFC8949]), and Static Context 164 Header Compression (SCHC, [RFC8724]). 166 The need for special protocols targeting constrained IoT deployments 167 extends also to the security domain [I-D.ietf-lake-reqs]. Important 168 characteristics in constrained environments are the number of round 169 trips and protocol message sizes, which if kept low can contribute to 170 good performance by enabling transport over a small number of radio 171 frames, reducing latency due to fragmentation or duty cycles, etc. 172 Another important criteria is code size, which may be prohibitive for 173 certain deployments due to device capabilities or network load during 174 firmware update. Some IoT deployments also need to support a variety 175 of underlying transport technologies, potentially even with a single 176 connection. 178 Some security solutions for such settings exist already. CBOR Object 179 Signing and Encryption (COSE, [I-D.ietf-cose-rfc8152bis-struct]) 180 specifies basic application-layer security services efficiently 181 encoded in CBOR. Another example is Object Security for Constrained 182 RESTful Environments (OSCORE, [RFC8613]) which is a lightweight 183 communication security extension to CoAP using CBOR and COSE. In 184 order to establish good quality cryptographic keys for security 185 protocols such as COSE and OSCORE, the two endpoints may run an 186 authenticated Diffie-Hellman key exchange protocol, from which shared 187 secret key material can be derived. Such a key exchange protocol 188 should also be lightweight; to prevent bad performance in case of 189 repeated use, e.g., due to device rebooting or frequent rekeying for 190 security reasons; or to avoid latencies in a network formation 191 setting with many devices authenticating at the same time. 193 This document specifies Ephemeral Diffie-Hellman Over COSE (EDHOC), a 194 lightweight authenticated key exchange protocol providing good 195 security properties including perfect forward secrecy, identity 196 protection, and cipher suite negotiation. Authentication can be 197 based on raw public keys (RPK) or public key certificates, and 198 requires the application to provide input on how to verify that 199 endpoints are trusted. This specification focuses on referencing 200 instead of transporting credentials to reduce message overhead. 202 EDHOC makes use of known protocol constructions, such as SIGMA 203 [SIGMA] and Extract-and-Expand [RFC5869]. COSE also provides crypto 204 agility and enables the use of future algorithms targeting IoT. 206 1.2. Use of EDHOC 208 EDHOC is designed for highly constrained settings making it 209 especially suitable for low-power wide area networks [RFC8376] such 210 as Cellular IoT, 6TiSCH, and LoRaWAN. A main objective for EDHOC is 211 to be a lightweight authenticated key exchange for OSCORE, i.e. to 212 provide authentication and session key establishment for IoT use 213 cases such as those built on CoAP [RFC7252]. CoAP is a specialized 214 web transfer protocol for use with constrained nodes and networks, 215 providing a request/response interaction model between application 216 endpoints. As such, EDHOC is targeting a large variety of use cases 217 involving 'things' with embedded microcontrollers, sensors, and 218 actuators. 220 A typical setting is when one of the endpoints is constrained or in a 221 constrained network, and the other endpoint is a node on the Internet 222 (such as a mobile phone) or at the edge of the constrained network 223 (such as a gateway). Thing-to-thing interactions over constrained 224 networks are also relevant since both endpoints would then benefit 225 from the lightweight properties of the protocol. EDHOC could e.g. be 226 run when a device connects for the first time, or to establish fresh 227 keys which are not revealed by a later compromise of the long-term 228 keys. Further security properties are described in Section 8.1. 230 EDHOC enables the reuse of the same lightweight primitives as OSCORE: 231 CBOR for encoding, COSE for cryptography, and CoAP for transport. By 232 reusing existing libraries the additional code size can be kept very 233 low. Note that, while CBOR and COSE primitives are built into the 234 protocol messages, EDHOC is not bound to a particular transport. 235 However, it is recommended to transfer EDHOC messages in CoAP 236 payloads as is detailed in Section 7.2. 238 1.3. Message Size Examples 240 Compared to the DTLS 1.3 handshake [I-D.ietf-tls-dtls13] with ECDHE 241 and connection ID, the number of bytes in EDHOC + CoAP can be less 242 than 1/6 when RPK authentication is used, see 243 [I-D.ietf-lwig-security-protocol-comparison]. Figure 1 shows two 244 examples of message sizes for EDHOC with different kinds of 245 authentication keys and different COSE header parameters for 246 identification: static Diffie-Hellman keys identified by 'kid' 247 [I-D.ietf-cose-rfc8152bis-struct], and X.509 signature certificates 248 identified by a hash value using 'x5t' [I-D.ietf-cose-x509]. 250 ================================= 251 kid x5t 252 --------------------------------- 253 message_1 37 37 254 message_2 46 117 255 message_3 20 91 256 --------------------------------- 257 Total 103 245 258 ================================= 260 Figure 1: Example of message sizes in bytes. 262 1.4. Document Structure 264 The remainder of the document is organized as follows: Section 2 265 outlines EDHOC authenticated with digital signatures, Section 3 266 describes the protocol elements of EDHOC, including message flow, and 267 formatting of the ephemeral public keys, Section 4 describes the key 268 derivation, Section 5 specifies EDHOC with authentication based on 269 signature keys or static Diffie-Hellman keys, Section 6 specifies the 270 EDHOC error message, and Section 7 describes how EDHOC can be 271 transferred in CoAP and used to establish an OSCORE security context. 273 1.5. Terminology and Requirements Language 275 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 276 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 277 "OPTIONAL" in this document are to be interpreted as described in BCP 278 14 [RFC2119] [RFC8174] when, and only when, they appear in all 279 capitals, as shown here. 281 Readers are expected to be familiar with the terms and concepts 282 described in CBOR [RFC8949], CBOR Sequences [RFC8742], COSE 283 structures and process [I-D.ietf-cose-rfc8152bis-struct], COSE 284 algorithms [I-D.ietf-cose-rfc8152bis-algs], and CDDL [RFC8610]. The 285 Concise Data Definition Language (CDDL) is used to express CBOR data 286 structures [RFC8949]. Examples of CBOR and CDDL are provided in 287 Appendix B.1. When referring to CBOR, this specification always 288 refer to Deterministically Encoded CBOR as specified in Sections 289 4.2.1 and 4.2.2 of [RFC8949]. 291 The single output from authenticated encryption (including the 292 authentication tag) is called 'ciphertext', following [RFC5116]. 294 2. EDHOC Outline 296 EDHOC specifies different authentication methods of the Diffie- 297 Hellman key exchange: digital signatures and static Diffie-Hellman 298 keys. This section outlines the digital signature based method. 299 Further details of protocol elements and other authentication methods 300 are provided in the remainder of this document. 302 SIGMA (SIGn-and-MAc) is a family of theoretical protocols with a 303 large number of variants [SIGMA]. Like IKEv2 [RFC7296] and (D)TLS 304 1.3 [RFC8446], EDHOC authenticated with digital signatures is built 305 on a variant of the SIGMA protocol which provides identity protection 306 of the initiator (SIGMA-I), and like IKEv2 [RFC7296], EDHOC 307 implements the SIGMA-I variant as MAC-then-Sign. The SIGMA-I 308 protocol using an authenticated encryption algorithm is shown in 309 Figure 2. 311 Initiator Responder 312 | G_X | 313 +-------------------------------------------------------->| 314 | | 315 | G_Y, AEAD( K_2; ID_CRED_R, Sig(R; CRED_R, G_X, G_Y) ) | 316 |<--------------------------------------------------------+ 317 | | 318 | AEAD( K_3; ID_CRED_I, Sig(I; CRED_I, G_Y, G_X) ) | 319 +-------------------------------------------------------->| 320 | | 322 Figure 2: Authenticated encryption variant of the SIGMA-I protocol. 324 The parties exchanging messages are called Initiator (I) and 325 Responder (R). They exchange ephemeral public keys, compute a shared 326 secret, and derive symmetric application keys used to protect 327 application data. 329 * G_X and G_Y are the ECDH ephemeral public keys of I and R, 330 respectively. 332 * CRED_I and CRED_R are the credentials containing the public 333 authentication keys of I and R, respectively. 335 * ID_CRED_I and ID_CRED_R are credential identifiers enabling the 336 recipient party to retrieve the credential of I and R, 337 respectively. 339 * Sig(I; . ) and Sig(R; . ) denote signatures made with the private 340 authentication key of I and R, respectively. 342 * AEAD(K; . ) denotes authenticated encryption with additional data 343 using a key K derived from the shared secret. 345 In order to create a "full-fledged" protocol some additional protocol 346 elements are needed. EDHOC adds: 348 * Explicit connection identifiers C_I, C_R chosen by I and R, 349 respectively, enabling the recipient to find the protocol state. 351 * Transcript hashes (hashes of message data) TH_2, TH_3, TH_4 used 352 for key derivation and as additional authenticated data. 354 * Computationally independent keys derived from the ECDH shared 355 secret and used for authenticated encryption of different 356 messages. 358 * An optional fourth message giving explicit key confirmation to I 359 in deployments where no protected application data is sent from R 360 to I. 362 * A key material exporter and a key update function enabling 363 frequent forward secrecy. 365 * Verification of a common preferred cipher suite: 367 - The Initiator lists supported cipher suites in order of 368 preference 370 - The Responder verifies that the selected cipher suite is the 371 first supported cipher suite (or else rejects and states 372 supported cipher suites). 374 * Method types and error handling. 376 * Transport of external authorization data. 378 EDHOC is designed to encrypt and integrity protect as much 379 information as possible, and all symmetric keys are derived using as 380 much previous information as possible. EDHOC is furthermore designed 381 to be as compact and lightweight as possible, in terms of message 382 sizes, processing, and the ability to reuse already existing CBOR, 383 COSE, and CoAP libraries. 385 To simplify for implementors, the use of CBOR and COSE in EDHOC is 386 summarized in Appendix B and test vectors including CBOR diagnostic 387 notation are given in Appendix C. 389 3. Protocol Elements 391 3.1. General 393 An EDHOC message flow consists of three mandatory messages 394 (message_1, message_2, message_3) between Initiator and Responder, an 395 optional fourth message (message_4), plus an EDHOC error message. 396 EDHOC messages are CBOR Sequences [RFC8742], see Figure 3. The 397 protocol elements in the figure are introduced in the following 398 sections. Message formatting and processing is specified in 399 Section 5 and Section 6. An implementation may support only 400 Initiator or only Responder. 402 Application data is protected using the agreed application algorithms 403 (AEAD, hash) in the selected cipher suite (see Section 3.4) and the 404 application can make use of the established connection identifiers 405 C_1, C_I, and C_R (see Section 3.2.4). EDHOC may be used with the 406 media type application/edhoc defined in Section 9. 408 The Initiator can derive symmetric application keys after creating 409 EDHOC message_3, see Section 4.1. Application protected data can 410 therefore be sent in parallel or together with EDHOC message_3. 412 Initiator Responder 413 | C_1, METHOD_CORR, SUITES_I, G_X, C_I, EAD_1 | 414 +------------------------------------------------------------------>| 415 | message_1 | 416 | | 417 | C_I, G_Y, C_R, Enc(ID_CRED_R, Signature_or_MAC_2, EAD_2) | 418 |<------------------------------------------------------------------+ 419 | message_2 | 420 | | 421 | C_R, AEAD(K_3ae; ID_CRED_I, Signature_or_MAC_3, EAD_3) | 422 +------------------------------------------------------------------>| 423 | message_3 | 425 Figure 3: EDHOC Message Flow 427 3.2. Method and Correlation 429 The data item METHOD_CORR in message_1 (see Section 5.3.1), is an 430 integer specifying the method and the correlation properties of the 431 transport, which are described in this section. 433 3.2.1. Method 435 EDHOC supports authentication with signature or static Diffie-Hellman 436 keys, as defined in the four authentication methods: 0, 1, 2, and 3, 437 see Figure 4. (Method 0 corresponds to the case outlined in 438 Section 2 where both Initiator and Responder authenticate with 439 signature keys.) 441 An implementation may support only a single method. The Initiator 442 and the Responder need to have agreed on a single method to be used 443 for EDHOC, see Section 3.7. 445 +-------+-------------------+-------------------+-------------------+ 446 | Value | Initiator | Responder | Reference | 447 +-------+-------------------+-------------------+-------------------+ 448 | 0 | Signature Key | Signature Key | [[this document]] | 449 | 1 | Signature Key | Static DH Key | [[this document]] | 450 | 2 | Static DH Key | Signature Key | [[this document]] | 451 | 3 | Static DH Key | Static DH Key | [[this document]] | 452 +-------+-------------------+-------------------+-------------------+ 454 Figure 4: Method Types 456 3.2.2. Connection Identifiers 458 EDHOC includes optional connection identifiers (C_1, C_I, C_R). The 459 connection identifiers C_1, C_I, and C_R do not have any 460 cryptographic purpose in EDHOC. They contain information 461 facilitating retrieval of the protocol state and may therefore be 462 very short. C_1 is always set to "null", while C_I and C_R are 463 chosen by I and R, respectively. One byte connection identifiers are 464 realistic in many scenarios as most constrained devices only have a 465 few connections. In cases where a node only has one connection, the 466 identifiers may even be the empty byte string. 468 The connection identifier MAY be used with an application protocol 469 (e.g. OSCORE) for which EDHOC establishes keys, in which case the 470 connection identifiers SHALL adhere to the requirements for that 471 protocol. Each party choses a connection identifier it desires the 472 other party to use in outgoing messages. (For OSCORE this results in 473 the endpoint selecting its Recipient ID, see Section 3.1 of 474 [RFC8613]). 476 3.2.3. Transport 478 Cryptographically, EDHOC does not put requirements on the lower 479 layers. EDHOC is not bound to a particular transport layer, and can 480 be used in environments without IP. The application using EDHOC is 481 responsible to handle message loss, reordering, message duplication, 482 fragmentation, demultiplex EDHOC messages from other types of 483 messages, and denial of service protection, where necessary. 485 The Initiator and the Responder need to have agreed on a transport to 486 be used for EDHOC, see Section 3.7. It is recommended to transport 487 EDHOC in CoAP payloads, see Section 7. 489 3.2.4. Message Correlation 491 If the whole transport path provides a mechanism for correlating 492 messages received with messages previously sent, then some of the 493 connection identifiers may be omitted. There are four cases: 495 * corr = 0, the transport does not provide a correlation mechanism. 497 * corr = 1, the transport provides a correlation mechanism that 498 enables the Responder to correlate message_2 and message_1 as well 499 as message_4 and message_3. 501 * corr = 2, the transport provides a correlation mechanism that 502 enables the Initiator to correlate message_3 and message_2. 504 * corr = 3, the transport provides a correlation mechanism that 505 enables both parties to correlate all three messages. 507 For example, if the key exchange is transported over CoAP, the CoAP 508 Token can be used to correlate messages, see Section 7.2. 510 3.3. Authentication Parameters 512 3.3.1. Authentication Keys 514 The authentication key MUST be a signature key or static Diffie- 515 Hellman key. The Initiator and the Responder MAY use different types 516 of authentication keys, e.g. one uses a signature key and the other 517 uses a static Diffie-Hellman key. When using a signature key, the 518 authentication is provided by a signature. When using a static 519 Diffie-Hellman key the authentication is provided by a Message 520 Authentication Code (MAC) computed from an ephemeral-static ECDH 521 shared secret which enables significant reductions in message sizes. 522 The MAC is implemented with an AEAD algorithm. When using static 523 Diffie-Hellman keys the Initiator's and Responder's private 524 authentication keys are called I and R, respectively, and the public 525 authentication keys are called G_I and G_R, respectively. The 526 authentication key algorithm needs to specified with enough 527 parameters to make it completely determined. Note that for most 528 signature algorithms, the signature is determined by the signature 529 algorithm and the authentication key algorithm together. For 530 example, the curve used in the signature is typically determined by 531 the authentication key parameters. 533 * Only the Responder SHALL have access to the Responder's private 534 authentication key. 536 * Only the Initiator SHALL have access to the Initiator's private 537 authentication key. 539 3.3.2. Identities 541 EDHOC assumes the existence of mechanisms (certification authority, 542 trusted third party, manual distribution, etc.) for specifying and 543 distributing authentication keys and identities. Policies are set 544 based on the identity of the other party, and parties typically only 545 allow connections from a specific identity or a small restricted set 546 of identities. For example, in the case of a device connecting to a 547 network, the network may only allow connections from devices which 548 authenticate with certificates having a particular range of serial 549 numbers in the subject field and signed by a particular CA. On the 550 other side, the device may only be allowed to connect to a network 551 which authenticates with a particular public key (information of 552 which may be provisioned, e.g., out of band or in the external 553 authorization data, see Section 3.6). 555 The EDHOC implementation must be able to receive and enforce 556 information from the application about what is the intended endpoint, 557 and in particular whether it is a specific identity or a set of 558 identities. 560 * When a Public Key Infrastructure (PKI) is used, the trust anchor 561 is a Certification Authority (CA) certificate, and the identity is 562 the subject whose unique name (e.g. a domain name, NAI, or EUI) is 563 included in the endpoint's certificate. Before running EDHOC each 564 party needs at least one CA public key certificate, or just the 565 public key, and a specific identity or set of identities it is 566 allowed to communicate with. Only validated public-key 567 certificates with an allowed subject name, as specified by the 568 application, are to be accepted. EDHOC provides proof that the 569 other party possesses the private authentication key corresponding 570 to the public authentication key in its certificate. The 571 certification path provides proof that the subject of the 572 certificate owns the public key in the certificate. 574 * When public keys are used but not with a PKI (RPK, self-signed 575 certificate), the trust anchor is the public authentication key of 576 the other party. In this case, the identity is typically directly 577 associated to the public authentication key of the other party. 578 For example, the name of the subject may be a canonical 579 representation of the public key. Alternatively, if identities 580 can be expressed in the form of unique subject names assigned to 581 public keys, then a binding to identity can be achieved by 582 including both public key and associated subject name in the 583 protocol message computation: CRED_I or CRED_R may be a self- 584 signed certificate or COSE_Key containing the public 585 authentication key and the subject name, see Section 3.3.3. 586 Before running EDHOC, each endpoint needs a specific public 587 authentication key/unique associated subject name, or a set of 588 public authentication keys/unique associated subject names, which 589 it is allowed to communicate with. EDHOC provides proof that the 590 other party possesses the private authentication key corresponding 591 to the public authentication key. 593 3.3.3. Authentication Credentials 595 The authentication credentials, CRED_I and CRED_R, contain the public 596 authentication key of the Initiator and the Responder, respectively. 597 The Initiator and the Responder MAY use different types of 598 credentials, e.g. one uses an RPK and the other uses a public key 599 certificate. 601 The credentials CRED_I and CRED_R are signed or MAC:ed (depending on 602 method) by the Initiator and the Responder, respectively, see 603 Section 5.5 and Section 5.4. 605 When the credential is a certificate, CRED_x is an end-entity 606 certificate (i.e. not the certificate chain) encoded as a CBOR bstr. 607 In X.509 certificates, signature keys typically have key usage 608 "digitalSignature" and Diffie-Hellman keys typically have key usage 609 "keyAgreement". 611 To prevent misbinding attacks in systems where an attacker can 612 register public keys without proving knowledge of the private key, 613 SIGMA [SIGMA] enforces a MAC to be calculated over the "Identity", 614 which in case of a X.509 certificate would be the 'subject' and 615 'subjectAltName' fields. EDHOC follows SIGMA by calculating a MAC 616 over the whole certificate. While the SIGMA paper only focuses on 617 the identity, the same principle is true for any information such as 618 policies connected to the public key. 620 When the credential is a COSE_Key, CRED_x is a CBOR map only 621 containing specific fields from the COSE_Key identifying the public 622 key, and optionally the "Identity". CRED_x needs to be defined such 623 that it is identical when generated by Initiator or Responder. The 624 parameters SHALL be encoded in bytewise lexicographic order of their 625 deterministic encodings as specified in Section 4.2.1 of [RFC8949]. 627 If the parties have agreed on an identity besides the public key, the 628 identity is included in the CBOR map with the label "subject name", 629 otherwise the subject name is the empty text string. The public key 630 parameters depend on key type. 632 * For COSE_Keys of type OKP the CBOR map SHALL, except for subject 633 name, only include the parameters 1 (kty), -1 (crv), and -2 634 (x-coordinate). 636 * For COSE_Keys of type EC2 the CBOR map SHALL, except for subject 637 name, only include the parameters 1 (kty), -1 (crv), -2 638 (x-coordinate), and -3 (y-coordinate). 640 An example of CRED_x when the RPK contains an X25519 static Diffie- 641 Hellman key and the parties have agreed on an EUI-64 identity is 642 shown below: 644 CRED_x = { 645 1: 1, 646 -1: 4, 647 -2: h'b1a3e89460e88d3a8d54211dc95f0b90 648 3ff205eb71912d6db8f4af980d2db83a', 649 "subject name" : "42-50-31-FF-EF-37-32-39" 650 } 652 3.3.4. Identification of Credentials 654 ID_CRED_I and ID_CRED_R are used to identify and optionally transport 655 the public authentication keys of the Initiator and the Responder, 656 respectively. ID_CRED_I and ID_CRED_R do not have any cryptographic 657 purpose in EDHOC. 659 * ID_CRED_R is intended to facilitate for the Initiator to retrieve 660 the Responder's public authentication key. 662 * ID_CRED_I is intended to facilitate for the Responder to retrieve 663 the Initiator's public authentication key. 665 The identifiers ID_CRED_I and ID_CRED_R are COSE header_maps, i.e. 666 CBOR maps containing Common COSE Header Parameters, see Section 3.1 667 of [I-D.ietf-cose-rfc8152bis-struct]). In the following we give some 668 examples of COSE header_maps. 670 Raw public keys are most optimally stored as COSE_Key objects and 671 identified with a 'kid' parameter: 673 * ID_CRED_x = { 4 : kid_x }, where kid_x : bstr, for x = I or R. 675 Public key certificates can be identified in different ways. Header 676 parameters for identifying C509 certificates and X.509 certificates 677 are defined in [I-D.ietf-cose-cbor-encoded-cert] and 678 [I-D.ietf-cose-x509], for example: 680 * by a hash value with the 'c5t' or 'x5t' parameters; 682 - ID_CRED_x = { 34 : COSE_CertHash }, for x = I or R, 684 - ID_CRED_x = { TDB3 : COSE_CertHash }, for x = I or R, 686 * by a URI with the 'c5u' or 'x5u' parameters; 688 - ID_CRED_x = { 35 : uri }, for x = I or R, 690 - ID_CRED_x = { TBD4 : uri }, for x = I or R, 692 * ID_CRED_x MAY contain the actual credential used for 693 authentication, CRED_x. For example, a certificate chain can be 694 transported in ID_CRED_x with COSE header parameter c5c or 695 x5chain, defined in [I-D.ietf-cose-cbor-encoded-cert] and 696 [I-D.ietf-cose-x509]. 698 It is RECOMMENDED that ID_CRED_x uniquely identify the public 699 authentication key as the recipient may otherwise have to try several 700 keys. ID_CRED_I and ID_CRED_R are transported in the 'ciphertext', 701 see Section 5.5 and Section 5.4. 703 When ID_CRED_x does not contain the actual credential it may be very 704 short. One byte credential identifiers are realistic in many 705 scenarios as most constrained devices only have a few keys. In cases 706 where a node only has one key, the identifier may even be the empty 707 byte string. 709 3.4. Cipher Suites 711 An EDHOC cipher suite consists of an ordered set of algorithms from 712 the "COSE Algorithms" and "COSE Elliptic Curves" registries. 713 Algorithms need to be specified with enough parameters to make them 714 completely determined. Currently, none of the algorithms require 715 parameters. EDHOC is only specified for use with key exchange 716 algorithms of type ECDH curves. Use with other types of key exchange 717 algorithms would likely require a specification updating EDHOC. Note 718 that for most signature algorithms, the signature is determined by 719 the signature algorithm and the authentication key algorithm 720 together, see Section 3.3.1. 722 * EDHOC AEAD algorithm 724 * EDHOC hash algorithm 726 * EDHOC key exchange algorithm (ECDH curve) 728 * EDHOC signature algorithm 730 * Application AEAD algorithm 732 * Application hash algorithm 734 Each cipher suite is identified with a pre-defined int label. 736 EDHOC can be used with all algorithms and curves defined for COSE. 737 Implementation can either use one of the pre-defined cipher suites 738 (Section 9.2) or use any combination of COSE algorithms and 739 parameters to define their own private cipher suite. Private cipher 740 suites can be identified with any of the four values -24, -23, -22, 741 -21. 743 The following cipher suites are for constrained IoT where message 744 overhead is a very important factor: 746 0. ( 10, -16, 4, -8, 10, -16 ) 747 (AES-CCM-16-64-128, SHA-256, X25519, EdDSA, 748 AES-CCM-16-64-128, SHA-256) 750 1. ( 30, -16, 4, -8, 10, -16 ) 751 (AES-CCM-16-128-128, SHA-256, X25519, EdDSA, 752 AES-CCM-16-64-128, SHA-256) 754 2. ( 10, -16, 1, -7, 10, -16 ) 755 (AES-CCM-16-64-128, SHA-256, P-256, ES256, 756 AES-CCM-16-64-128, SHA-256) 758 3. ( 30, -16, 1, -7, 10, -16 ) 759 (AES-CCM-16-128-128, SHA-256, P-256, ES256, 760 AES-CCM-16-64-128, SHA-256) 762 The following cipher suite is for general non-constrained 763 applications. It uses very high performance algorithms that also are 764 widely supported: 766 4. ( 1, -16, 4, -7, 1, -16 ) 767 (A128GCM, SHA-256, X25519, ES256, 768 A128GCM, SHA-256) 770 The following cipher suite is for high security application such as 771 government use and financial applications. It is compatible with the 772 CNSA suite [CNSA]. 774 5. ( 3, -43, 2, -35, 3, -43 ) 775 (A256GCM, SHA-384, P-384, ES384, 776 A256GCM, SHA-384) 778 The different methods use the same cipher suites, but some algorithms 779 are not used in some methods. The EDHOC signature algorithm is not 780 used in methods without signature authentication. 782 The Initiator needs to have a list of cipher suites it supports in 783 order of preference. The Responder needs to have a list of cipher 784 suites it supports. SUITES_I is a CBOR array containing cipher 785 suites that the Initiator supports. SUITES_I is formatted and 786 processed as detailed in Section 5.3.1 to secure the cipher suite 787 negotiation. Examples of cipher suite negotiation are given in 788 Section 6.3.2. 790 3.5. Ephemeral Public Keys 792 EDHOC always uses compact representation of elliptic curve points, 793 see Appendix A. In COSE compact representation is achieved by 794 formatting the ECDH ephemeral public keys as COSE_Keys of type EC2 or 795 OKP according to Sections 7.1 and 7.2 of 796 [I-D.ietf-cose-rfc8152bis-algs], but only including the 'x' parameter 797 in G_X and G_Y. For Elliptic Curve Keys of type EC2, compact 798 representation MAY be used also in the COSE_Key. If the COSE 799 implementation requires an 'y' parameter, the value y = false SHALL 800 be used. COSE always use compact output for Elliptic Curve Keys of 801 type EC2. 803 3.6. External Authorization Data 805 In order to reduce round trips and number of messages or to simplify 806 processing, external security applications may be integrated into 807 EDHOC by transporting authorization related data together with the 808 messages. One example is the transport third-party identity and 809 authorization information protected out of scope of EDHOC 810 [I-D.selander-ace-ake-authz]. Another example is the embedding of a 811 certificate enrolment request or a newly issued certificate. 813 EDHOC allows opaque external authorization data (EAD) to be sent in 814 the EDHOC messages. External authorization data sent in message_1 815 (EAD_1) or message_2 (EAD_2) must be considered unprotected by EDHOC, 816 see Section 8.4. External authorization data sent in message_3 817 (EAD_3) or message_4 (EAD_4) is protected between Initiator and 818 Responder. 820 External authorization data is a CBOR sequence (see Appendix B.1) as 821 defined below: 823 EAD = ( 824 type : int, 825 1* ext_authz_data : any, 826 ) 828 where type is an int and is followed by one or more ext_authz_data 829 depending on type as defined in a separate specification. 831 The EAD fields of EDHOC are not intended for generic application 832 data. Since data carried in EAD_1 and EAD_2 fields may not be 833 protected, special considerations need to be made such that a) it 834 does not violate security, privacy etc. requirements of the service 835 which uses this data, and b) it does not violate the security 836 properties of EDHOC. Security applications making use of the EAD 837 fields must perform the necessary security analysis. 839 3.7. Applicability Statement 841 EDHOC requires certain parameters to be agreed upon between Initiator 842 and Responder. Some parameters can be agreed through the protocol 843 execution (specifically cipher suite negotiation, see Section 3.4) 844 but other parameters may need to be known out-of-band (e.g., which 845 authentication method is used, see Section 3.2.1). 847 The purpose of the applicability statement is describe the intended 848 use of EDHOC to allow for the relevant processing and verifications 849 to be made, including things like: 851 1. How the endpoint detects that an EDHOC message is received. This 852 includes how EDHOC messages are transported, for example in the 853 payload of a CoAP message with a certain Uri-Path or Content- 854 Format; see Section 7.2. 856 2. Method and correlation of underlying transport messages 857 (METHOD_CORR; see Section 3.2.1 and Section 3.2.4). This gives 858 information about the optional connection identifier fields. 860 3. How message_1 is identified, in particular if the optional 861 initial C_1 = "null" of message_1 is present; see Section 5.3.1 863 4. Profile for authentication credentials (CRED_I, CRED_R; see 864 Section 3.3.3), e.g., profile for certificate or COSE_key, 865 including supported authentication key algorithms (subject public 866 key algorithm in X.509 certificate). 868 5. Type used to identify authentication credentials (ID_CRED_I, 869 ID_CRED_R; see Section 3.3.4). 871 6. Use and type of external authorization data (EAD_1, EAD_2, EAD_3, 872 EAD_4; see Section 3.6). 874 7. Identifier used as identity of endpoint; see Section 3.3.2. 876 8. If message_4 shall be sent/expected, and if not, how to ensure a 877 protected application message is sent from the Responder to the 878 Initiator; see Section 7.1. 880 The applicability statement may also contain information about 881 supported cipher suites. The procedure for selecting and verifying 882 cipher suite is still performed as specified by the protocol, but it 883 may become simplified by this knowledge. 885 An example of an applicability statement is shown in Appendix D. 887 For some parameters, like METHOD_CORR, ID_CRED_x, type of EAD, the 888 receiver is able to verify compliance with applicability statement, 889 and if it needs to fail because of incompliance, to infer the reason 890 why the protocol failed. 892 For other parameters, like CRED_x in the case that it is not 893 transported, it may not be possible to verify that incompliance with 894 applicability statement was the reason for failure: Integrity 895 verification in message_2 or message_3 may fail not only because of 896 wrong authentication credential. For example, in case the Initiator 897 uses public key certificate by reference (i.e. not transported within 898 the protocol) then both endpoints need to use an identical data 899 structure as CRED_I or else the integrity verification will fail. 901 Note that it is not necessary for the endpoints to specify a single 902 transport for the EDHOC messages. For example, a mix of CoAP and 903 HTTP may be used along the path, and this may still allow correlation 904 between messages. 906 The applicability statement may be dependent on the identity of the 907 other endpoint, but this applies only to the later phases of the 908 protocol when identities are known. (Initiator does not know 909 identity of Responder before having verified message_2, and Responder 910 does not know identity of Initiator before having verified 911 message_3.) 913 Other conditions may be part of the applicability statement, such as 914 target application or use (if there is more than one application/use) 915 to the extent that EDHOC can distinguish between them. In case 916 multiple applicability statements are used, the receiver needs to be 917 able to determine which is applicable for a given session, for 918 example based on URI or external authorization data type. 920 4. Key Derivation 922 EDHOC uses Extract-and-Expand [RFC5869] with the EDHOC hash algorithm 923 in the selected cipher suite to derive keys used in EDHOC and in the 924 application. Extract is used to derive fixed-length uniformly 925 pseudorandom keys (PRK) from ECDH shared secrets. Expand is used to 926 derive additional output keying material (OKM) from the PRKs. The 927 PRKs are derived using Extract. 929 PRK = Extract( salt, IKM ) 931 If the EDHOC hash algorithm is SHA-2, then Extract( salt, IKM ) = 932 HKDF-Extract( salt, IKM ) [RFC5869]. If the EDHOC hash algorithm is 933 SHAKE128, then Extract( salt, IKM ) = KMAC128( salt, IKM, 256, "" ). 934 If the EDHOC hash algorithm is SHAKE256, then Extract( salt, IKM ) = 935 KMAC256( salt, IKM, 512, "" ). 937 PRK_2e is used to derive a keystream to encrypt message_2. PRK_3e2m 938 is used to derive keys and IVs to produce a MAC in message_2 and to 939 encrypt message_3. PRK_4x3m is used to derive keys and IVs to 940 produce a MAC in message_3 and to derive application specific data. 942 PRK_2e is derived with the following input: 944 * The salt SHALL be the empty byte string. Note that [RFC5869] 945 specifies that if the salt is not provided, it is set to a string 946 of zeros (see Section 2.2 of [RFC5869]). For implementation 947 purposes, not providing the salt is the same as setting the salt 948 to the empty byte string. 950 * The input keying material (IKM) SHALL be the ECDH shared secret 951 G_XY (calculated from G_X and Y or G_Y and X) as defined in 952 Section 6.3.1 of [I-D.ietf-cose-rfc8152bis-algs]. 954 Example: Assuming the use of SHA-256 the extract phase of HKDF 955 produces PRK_2e as follows: 957 PRK_2e = HMAC-SHA-256( salt, G_XY ) 959 where salt = 0x (the empty byte string). 961 The pseudorandom keys PRK_3e2m and PRK_4x3m are defined as follow: 963 * If the Responder authenticates with a static Diffie-Hellman key, 964 then PRK_3e2m = Extract( PRK_2e, G_RX ), where G_RX is the ECDH 965 shared secret calculated from G_R and X, or G_X and R, else 966 PRK_3e2m = PRK_2e. 968 * If the Initiator authenticates with a static Diffie-Hellman key, 969 then PRK_4x3m = Extract( PRK_3e2m, G_IY ), where G_IY is the ECDH 970 shared secret calculated from G_I and Y, or G_Y and I, else 971 PRK_4x3m = PRK_3e2m. 973 Example: Assuming the use of curve25519, the ECDH shared secrets 974 G_XY, G_RX, and G_IY are the outputs of the X25519 function 975 [RFC7748]: 977 G_XY = X25519( Y, G_X ) = X25519( X, G_Y ) 979 The keys and IVs used in EDHOC are derived from PRKs using Expand 980 [RFC5869] where the EDHOC-KDF is instantiated with the EDHOC AEAD 981 algorithm in the selected cipher suite. 983 OKM = EDHOC-KDF( PRK, transcript_hash, label, length ) 984 = Expand( PRK, info, length ) 986 where info is the CBOR encoding of 988 info = [ 989 edhoc_aead_id : int / tstr, 990 transcript_hash : bstr, 991 label : tstr, 992 length : uint 993 ] 995 where 997 * edhoc_aead_id is an int or tstr containing the algorithm 998 identifier of the EDHOC AEAD algorithm in the selected cipher 999 suite encoded as defined in [I-D.ietf-cose-rfc8152bis-algs]. Note 1000 that a single fixed edhoc_aead_id is used in all invocations of 1001 EDHOC-KDF, including the derivation of KEYSTREAM_2 and invocations 1002 of the EDHOC-Exporter. 1004 * transcript_hash is a bstr set to one of the transcript hashes 1005 TH_2, TH_3, or TH_4 as defined in Sections 5.4.1, 5.5.1, and 4.1. 1007 * label is a tstr set to the name of the derived key or IV, i.e. 1008 "K_2m", "IV_2m", "KEYSTREAM_2", "K_3m", "IV_3m", "K_3ae", or 1009 "IV_3ae". 1011 * length is the length of output keying material (OKM) in bytes 1013 If the EDHOC hash algorithm is SHA-2, then Expand( PRK, info, length 1014 ) = HKDF-Expand( PRK, info, length ) [RFC5869]. If the EDHOC hash 1015 algorithm is SHAKE128, then Expand( PRK, info, length ) = KMAC128( 1016 PRK, info, L, "" ). If the EDHOC hash algorithm is SHAKE256, then 1017 Expand( PRK, info, length ) = KMAC256( PRK, info, L, "" ). 1019 KEYSTREAM_2 are derived using the transcript hash TH_2 and the 1020 pseudorandom key PRK_2e. K_2m and IV_2m are derived using the 1021 transcript hash TH_2 and the pseudorandom key PRK_3e2m. K_3ae and 1022 IV_3ae are derived using the transcript hash TH_3 and the 1023 pseudorandom key PRK_3e2m. K_3m and IV_3m are derived using the 1024 transcript hash TH_3 and the pseudorandom key PRK_4x3m. IVs are only 1025 used if the EDHOC AEAD algorithm uses IVs. 1027 4.1. EDHOC-Exporter Interface 1029 Application keys and other application specific data can be derived 1030 using the EDHOC-Exporter interface defined as: 1032 EDHOC-Exporter(label, context, length) 1033 = EDHOC-KDF(PRK_4x3m, TH_4, label_context, length) 1035 label_context is a CBOR sequence: 1037 label_context = ( 1038 label : tstr, 1039 context : bstr, 1040 ) 1042 where label is a registered tstr from the EDHOC Exporter Label 1043 registry (Section 9.1), context is a bstr defined by the application, 1044 and length is a uint defined by the application. The (label, 1045 context) pair must be unique, i.e. a (label, context) MUST NOT be 1046 used for two different purposes. However an application can re- 1047 derive the same key several times as long as it is done in a secure 1048 way. For example, in most encryption algorithms the same (key, 1049 nonce) pair must not be reused. 1051 The transcript hash TH_4 is a CBOR encoded bstr and the input to the 1052 hash function is a CBOR Sequence. 1054 TH_4 = H( TH_3, CIPHERTEXT_3 ) 1056 where H() is the hash function in the selected cipher suite. 1057 Examples of use of the EDHOC-Exporter are given in Section 7.1.2 and 1058 [I-D.ietf-core-oscore-edhoc]. 1060 To provide forward secrecy in an even more efficient way than re- 1061 running EDHOC, EDHOC provides the function EDHOC-KeyUpdate. When 1062 EDHOC-KeyUpdate is called the old PRK_4x3m is deleted and the new 1063 PRK_4x3m is calculated as a "hash" of the old key using the Extract 1064 function as illustrated by the following pseudocode: 1066 EDHOC-KeyUpdate( nonce ): 1067 PRK_4x3m = Extract( nonce, PRK_4x3m ) 1069 5. Message Formatting and Processing 1071 This section specifies formatting of the messages and processing 1072 steps. Error messages are specified in Section 6. 1074 An EDHOC message is encoded as a sequence of CBOR data (CBOR 1075 Sequence, [RFC8742]). Additional optimizations are made to reduce 1076 message overhead. 1078 While EDHOC uses the COSE_Key, COSE_Sign1, and COSE_Encrypt0 1079 structures, only a subset of the parameters is included in the EDHOC 1080 messages. The unprotected COSE header in COSE_Sign1, and 1081 COSE_Encrypt0 (not included in the EDHOC message) MAY contain 1082 parameters (e.g. 'alg'). 1084 5.1. Encoding of bstr_identifier 1086 Byte strings are encoded in CBOR as two or more bytes, whereas 1087 integers in the interval -24 to 23 are encoded in CBOR as one byte. 1089 bstr_identifier is a special encoding of byte strings, used 1090 throughout the protocol to enable the encoding of the shortest byte 1091 strings as integers that only require one byte of CBOR encoding. 1093 The bstr_identifier encoding is defined as follows: Byte strings in 1094 the interval h'00' to h'2f' are encoded as the corresponding integer 1095 minus 24, which are all represented by one byte CBOR ints. Other 1096 byte strings are encoded as CBOR byte strings. 1098 For example, the byte string h'59e9' encoded as a bstr_identifier is 1099 equal to h'59e9', while the byte string h'2a' is encoded as the 1100 integer 18. 1102 The CDDL definition of the bstr_identifier is given below: 1104 bstr_identifier = bstr / int 1106 Note that, despite what could be interpreted by the CDDL definition 1107 only, bstr_identifier once decoded are always byte strings. 1109 5.2. Message Processing Outline 1111 This section outlines the message processing of EDHOC. 1113 For each session, the endpoints are assumed to keep an associated 1114 protocol state containing connection identifiers, keys, etc. used for 1115 subsequent processing of protocol related data. The protocol state 1116 is assumed to be associated to an applicability statement 1117 (Section 3.7) which provides the context for how messages are 1118 transported, identified and processed. 1120 EDHOC messages SHALL be processed according to the current protocol 1121 state. The following steps are expected to be performed at reception 1122 of an EDHOC message: 1124 1. Detect that an EDHOC message has been received, for example by 1125 means of port number, URI, or media type (Section 3.7). 1127 2. Retrieve the protocol state, e.g. using the received connection 1128 identifier (Section 3.2.2) or with the help of message 1129 correlation provided by the transport protocol (Section 3.2.4). 1130 If there is no protocol state, in the case of message_1, a new 1131 protocol state is created. An initial C_1 = "null" byte in 1132 message_1 (Section 5.3.1) can be used to distinguish message_1 1133 from other messages. The Responder endpoint needs to make use of 1134 available Denial-of-Service mitigation (Section 8.5). 1136 3. If the message received is an error message then process 1137 according to Section 6, else process as the expected next message 1138 according to the protocol state. 1140 If the processing fails, then the protocol is discontinued, an error 1141 message sent, and the protocol state erased. Further details are 1142 provided in the following subsections. 1144 Different instances of the same message MUST NOT be processed in one 1145 session. Note that processing will fail if the same message appears 1146 a second time for EDHOC processing because the state of the protocol 1147 has moved on and now expects something else. This assumes that 1148 message duplication due to re-transmissions is handled by the 1149 transport protocol, see Section 3.2.3. The case when the transport 1150 does not support message deduplication is addressed in Appendix E. 1152 5.3. EDHOC Message 1 1154 5.3.1. Formatting of Message 1 1156 message_1 SHALL be a CBOR Sequence (see Appendix B.1) as defined 1157 below 1158 message_1 = ( 1159 ? C_1 : null, 1160 METHOD_CORR : int, 1161 SUITES_I : [ selected : suite, supported : 2* suite ] / suite, 1162 G_X : bstr, 1163 C_I : bstr_identifier, 1164 ? EAD ; EAD_1 1165 ) 1167 suite = int 1169 where: 1171 * C_1 - an initial CBOR simple value "null" (= 0xf6) MAY be used to 1172 distinguish message_1 from other messages. 1174 * METHOD_CORR = 4 * method + corr, where method = 0, 1, 2, or 3 (see 1175 Figure 4) and the correlation parameter corr is chosen based on 1176 the transport and determines which connection identifiers that are 1177 omitted (see Section 3.2.4). 1179 * SUITES_I - cipher suites which the Initiator supports in order of 1180 (decreasing) preference. The list of supported cipher suites can 1181 be truncated at the end, as is detailed in the processing steps 1182 below and Section 6.3. One of the supported cipher suites is 1183 selected. The selected suite is the first suite in the SUITES_I 1184 CBOR array. If a single supported cipher suite is conveyed then 1185 that cipher suite is selected and SUITES_I is encoded as an int 1186 instead of an array. 1188 * G_X - the ephemeral public key of the Initiator 1190 * C_I - variable length connection identifier, encoded as a 1191 bstr_identifier (see Section 5.1). 1193 * EAD_1 - unprotected external authorization data, see Section 3.6. 1195 5.3.2. Initiator Processing of Message 1 1197 The Initiator SHALL compose message_1 as follows: 1199 * The supported cipher suites and the order of preference MUST NOT 1200 be changed based on previous error messages. However, the list 1201 SUITES_I sent to the Responder MAY be truncated such that cipher 1202 suites which are the least preferred are omitted. The amount of 1203 truncation MAY be changed between sessions, e.g. based on previous 1204 error messages (see next bullet), but all cipher suites which are 1205 more preferred than the least preferred cipher suite in the list 1206 MUST be included in the list. 1208 * The Initiator MUST select its most preferred cipher suite, 1209 conditioned on what it can assume to be supported by the 1210 Responder. If the Initiator previously received from the 1211 Responder an error message with error code 2 (see Section 6.3) 1212 indicating cipher suites supported by the Responder which also are 1213 supported by the Initiator, then the Initiator SHOULD select the 1214 most preferred cipher suite of those (note that error messages are 1215 not authenticated and may be forged). 1217 * Generate an ephemeral ECDH key pair using the curve in the 1218 selected cipher suite and format it as a COSE_Key. Let G_X be the 1219 'x' parameter of the COSE_Key. 1221 * Choose a connection identifier C_I and store it for the length of 1222 the protocol. 1224 * Encode message_1 as a sequence of CBOR encoded data items as 1225 specified in Section 5.3.1 1227 5.3.3. Responder Processing of Message 1 1229 The Responder SHALL process message_1 as follows: 1231 * Decode message_1 (see Appendix B.1). 1233 * Verify that the selected cipher suite is supported and that no 1234 prior cipher suite in SUITES_I is supported. 1236 * Pass EAD_1 to the security application. 1238 If any processing step fails, the Responder SHOULD send an EDHOC 1239 error message back, formatted as defined in Section 6, and the 1240 session MUST be discontinued. Sending error messages is essential 1241 for debugging but MAY e.g. be skipped due to denial of service 1242 reasons, see Section 8. 1244 5.4. EDHOC Message 2 1246 5.4.1. Formatting of Message 2 1248 message_2 and data_2 SHALL be CBOR Sequences (see Appendix B.1) as 1249 defined below 1251 message_2 = ( 1252 data_2, 1253 CIPHERTEXT_2 : bstr, 1254 ) 1256 data_2 = ( 1257 ? C_I : bstr_identifier, 1258 G_Y : bstr, 1259 C_R : bstr_identifier, 1260 ) 1262 where: 1264 * G_Y - the ephemeral public key of the Responder 1266 * C_R - variable length connection identifier, encoded as a 1267 bstr_identifier (see Section 5.1). 1269 5.4.2. Responder Processing of Message 2 1271 The Responder SHALL compose message_2 as follows: 1273 * If corr (METHOD_CORR mod 4) equals 1 or 3, C_I is omitted, 1274 otherwise C_I is not omitted. 1276 * Generate an ephemeral ECDH key pair using the curve in the 1277 selected cipher suite and format it as a COSE_Key. Let G_Y be the 1278 'x' parameter of the COSE_Key. 1280 * Choose a connection identifier C_R and store it for the length of 1281 the protocol. 1283 * Compute the transcript hash TH_2 = H( H(message_1), data_2 ) where 1284 H() is the hash function in the selected cipher suite. The 1285 transcript hash TH_2 is a CBOR encoded bstr and the input to the 1286 hash function is a CBOR Sequence. Note that H(message_1) can be 1287 computed and cached already in the processing of message_1. 1289 * Compute an inner COSE_Encrypt0 as defined in Section 5.3 of 1290 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1291 in the selected cipher suite, K_2m, IV_2m, and the following 1292 parameters: 1294 - protected = << ID_CRED_R >> 1296 o ID_CRED_R - identifier to facilitate retrieval of CRED_R, 1297 see Section 3.3.4 1299 - external_aad = << TH_2, CRED_R, ? EAD_2 >> 1301 o CRED_R - bstr containing the credential of the Responder, 1302 see Section 3.3.4 1304 o EAD_2 = unprotected external authorization data, see 1305 Section 3.6 1307 - plaintext = h'' 1309 COSE constructs the input to the AEAD [RFC5116] as follows: 1311 - Key K = EDHOC-KDF( PRK_3e2m, TH_2, "K_2m", length ) 1313 - Nonce N = EDHOC-KDF( PRK_3e2m, TH_2, "IV_2m", length ) 1315 - Plaintext P = 0x (the empty string) 1317 - Associated data A = 1319 [ "Encrypt0", << ID_CRED_R >>, << TH_2, CRED_R, ? EAD_2 >> ] 1321 MAC_2 is the 'ciphertext' of the inner COSE_Encrypt0. 1323 * If the Responder authenticates with a static Diffie-Hellman key 1324 (method equals 1 or 3), then Signature_or_MAC_2 is MAC_2. If the 1325 Responder authenticates with a signature key (method equals 0 or 1326 2), then Signature_or_MAC_2 is the 'signature' of a COSE_Sign1 1327 object as defined in Section 4.4 of 1328 [I-D.ietf-cose-rfc8152bis-struct] using the signature algorithm in 1329 the selected cipher suite, the private authentication key of the 1330 Responder, and the following parameters: 1332 - protected = << ID_CRED_R >> 1334 - external_aad = << TH_2, CRED_R, ? EAD_2 >> 1336 - payload = MAC_2 1337 COSE constructs the input to the Signature Algorithm as: 1339 - The key is the private authentication key of the Responder. 1341 - The message M to be signed = 1343 [ "Signature1", << ID_CRED_R >>, << TH_2, CRED_R, ? EAD_2 >>, 1344 MAC_2 ] 1346 * CIPHERTEXT_2 is encrypted by using the Expand function as a binary 1347 additive stream cipher. 1349 - plaintext = ( ID_CRED_R / bstr_identifier, Signature_or_MAC_2, 1350 ? EAD_2 ) 1352 o Note that if ID_CRED_R contains a single 'kid' parameter, 1353 i.e., ID_CRED_R = { 4 : kid_R }, only the byte string kid_R 1354 is conveyed in the plaintext encoded as a bstr_identifier, 1355 see Section 3.3.4 and Section 5.1. 1357 - CIPHERTEXT_2 = plaintext XOR KEYSTREAM_2 1359 * Encode message_2 as a sequence of CBOR encoded data items as 1360 specified in Section 5.4.1. 1362 5.4.3. Initiator Processing of Message 2 1364 The Initiator SHALL process message_2 as follows: 1366 * Decode message_2 (see Appendix B.1). 1368 * Retrieve the protocol state using the connection identifier C_I 1369 and/or other external information such as the CoAP Token and the 1370 5-tuple. 1372 * Decrypt CIPHERTEXT_2, see Section 5.4.2. 1374 * Pass EAD_2 to the security application. 1376 * Verify that the identity of the Responder is an allowed identity 1377 for this connection, see Section 3.3. 1379 * Verify Signature_or_MAC_2 using the algorithm in the selected 1380 cipher suite. The verification process depends on the method, see 1381 Section 5.4.2. 1383 If any processing step fails, the Initiator SHOULD send an EDHOC 1384 error message back, formatted as defined in Section 6. Sending error 1385 messages is essential for debugging but MAY e.g.be skipped if a 1386 session cannot be found or due to denial of service reasons, see 1387 Section 8. If an error message is sent, the session MUST be 1388 discontinued. 1390 5.5. EDHOC Message 3 1392 5.5.1. Formatting of Message 3 1394 message_3 and data_3 SHALL be CBOR Sequences (see Appendix B.1) as 1395 defined below 1397 message_3 = ( 1398 data_3, 1399 CIPHERTEXT_3 : bstr, 1400 ) 1402 data_3 = ( 1403 ? C_R : bstr_identifier, 1404 ) 1406 5.5.2. Initiator Processing of Message 3 1408 The Initiator SHALL compose message_3 as follows: 1410 * If corr (METHOD_CORR mod 4) equals 2 or 3, C_R is omitted, 1411 otherwise C_R is not omitted. 1413 * Compute the transcript hash TH_3 = H( H(TH_2, CIPHERTEXT_2), 1414 data_3 ) where H() is the hash function in the selected cipher 1415 suite. The transcript hash TH_3 is a CBOR encoded bstr and the 1416 input to the hash function is a CBOR Sequence. Note that H(TH_2, 1417 CIPHERTEXT_2) can be computed and cached already in the processing 1418 of message_2. 1420 * Compute an inner COSE_Encrypt0 as defined in Section 5.3 of 1421 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1422 in the selected cipher suite, K_3m, IV_3m, and the following 1423 parameters: 1425 - protected = << ID_CRED_I >> 1427 o ID_CRED_I - identifier to facilitate retrieval of CRED_I, 1428 see Section 3.3.4 1430 - external_aad = << TH_3, CRED_I, ? EAD_3 >> 1431 o CRED_I - bstr containing the credential of the Initiator, 1432 see Section 3.3.4. 1434 o EAD_3 = protected external authorization data, see 1435 Section 3.6 1437 - plaintext = h'' 1439 COSE constructs the input to the AEAD [RFC5116] as follows: 1441 - Key K = EDHOC-KDF( PRK_4x3m, TH_3, "K_3m", length ) 1443 - Nonce N = EDHOC-KDF( PRK_4x3m, TH_3, "IV_3m", length ) 1445 - Plaintext P = 0x (the empty string) 1447 - Associated data A = 1449 [ "Encrypt0", << ID_CRED_I >>, << TH_3, CRED_I, ? EAD_3 >> ] 1451 MAC_3 is the 'ciphertext' of the inner COSE_Encrypt0. 1453 * If the Initiator authenticates with a static Diffie-Hellman key 1454 (method equals 2 or 3), then Signature_or_MAC_3 is MAC_3. If the 1455 Initiator authenticates with a signature key (method equals 0 or 1456 1), then Signature_or_MAC_3 is the 'signature' of a COSE_Sign1 1457 object as defined in Section 4.4 of 1458 [I-D.ietf-cose-rfc8152bis-struct] using the signature algorithm in 1459 the selected cipher suite, the private authentication key of the 1460 Initiator, and the following parameters: 1462 - protected = << ID_CRED_I >> 1464 - external_aad = << TH_3, CRED_I, ? EAD_3 >> 1466 - payload = MAC_3 1468 COSE constructs the input to the Signature Algorithm as: 1470 - The key is the private authentication key of the Initiator. 1472 - The message M to be signed = 1474 [ "Signature1", << ID_CRED_I >>, << TH_3, CRED_I, ? EAD_3 >>, 1475 MAC_3 ] 1477 * Compute an outer COSE_Encrypt0 as defined in Section 5.3 of 1478 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1479 in the selected cipher suite, K_3ae, IV_3ae, and the following 1480 parameters. The protected header SHALL be empty. 1482 - external_aad = TH_3 1484 - plaintext = ( ID_CRED_I / bstr_identifier, Signature_or_MAC_3, 1485 ? EAD_3 ) 1487 o Note that if ID_CRED_I contains a single 'kid' parameter, 1488 i.e., ID_CRED_I = { 4 : kid_I }, only the byte string kid_I 1489 is conveyed in the plaintext encoded as a bstr_identifier, 1490 see Section 3.3.4 and Section 5.1. 1492 COSE constructs the input to the AEAD [RFC5116] as follows: 1494 - Key K = EDHOC-KDF( PRK_3e2m, TH_3, "K_3ae", length ) 1496 - Nonce N = EDHOC-KDF( PRK_3e2m, TH_3, "IV_3ae", length ) 1498 - Plaintext P = ( ID_CRED_I / bstr_identifier, 1499 Signature_or_MAC_3, ? EAD_3 ) 1501 - Associated data A = [ "Encrypt0", h'', TH_3 ] 1503 CIPHERTEXT_3 is the 'ciphertext' of the outer COSE_Encrypt0. 1505 * Encode message_3 as a sequence of CBOR encoded data items as 1506 specified in Section 5.5.1. 1508 Pass the connection identifiers (C_I, C_R) and the application 1509 algorithms in the selected cipher suite to the application. The 1510 application can now derive application keys using the EDHOC-Exporter 1511 interface. 1513 After sending message_3, the Initiator is assured that no other party 1514 than the Responder can compute the key PRK_4x3m (implicit key 1515 authentication). The Initiator can securely derive application keys 1516 and send protected application data. However, the Initiator does not 1517 know that the Responder has actually computed the key PRK_4x3m and 1518 therefore the Initiator SHOULD NOT permanently store the keying 1519 material PRK_4x3m and TH_4, or derived application keys, until the 1520 Initiator is assured that the Responder has actually computed the key 1521 PRK_4x3m (explicit key confirmation). This is similar to waiting for 1522 acknowledgement (ACK) in a transport protocol. Explicit key 1523 confirmation is e.g. assured when the Initiator has verified an 1524 OSCORE message or message_4 from the Responder. 1526 5.5.3. Responder Processing of Message 3 1528 The Responder SHALL process message_3 as follows: 1530 * Decode message_3 (see Appendix B.1). 1532 * Retrieve the protocol state using the connection identifier C_R 1533 and/or other external information such as the CoAP Token and the 1534 5-tuple. 1536 * Decrypt and verify the outer COSE_Encrypt0 as defined in 1537 Section 5.3 of [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC 1538 AEAD algorithm in the selected cipher suite, K_3ae, and IV_3ae. 1540 * Pass EAD_3 to the security application. 1542 * Verify that the identity of the Initiator is an allowed identity 1543 for this connection, see Section 3.3. 1545 * Verify Signature_or_MAC_3 using the algorithm in the selected 1546 cipher suite. The verification process depends on the method, see 1547 Section 5.5.2. 1549 * Pass the connection identifiers (C_I, C_R), and the application 1550 algorithms in the selected cipher suite to the security 1551 application. The application can now derive application keys 1552 using the EDHOC-Exporter interface. 1554 If any processing step fails, the Responder SHOULD send an EDHOC 1555 error message back, formatted as defined in Section 6. Sending error 1556 messages is essential for debugging but MAY e.g.be skipped if a 1557 session cannot be found or due to denial of service reasons, see 1558 Section 8. If an error message is sent, the session MUST be 1559 discontinued. 1561 After verifying message_3, the Responder is assured that the 1562 Initiator has calculated the key PRK_4x3m (explicit key confirmation) 1563 and that no other party than the Responder can compute the key. The 1564 Responder can securely send protected application data and store the 1565 keying material PRK_4x3m and TH_4. 1567 6. Error Handling 1569 This section defines the format for error messages. 1571 An EDHOC error message can be sent by either endpoint as a reply to 1572 any non-error EDHOC message. How errors at the EDHOC layer are 1573 transported depends on lower layers, which need to enable error 1574 messages to be sent and processed as intended. 1576 Errors in EDHOC are fatal. After sending an error message, the 1577 sender MUST discontinue the protocol. The receiver SHOULD treat an 1578 error message as an indication that the other party likely has 1579 discontinued the protocol. But as the error message is not 1580 authenticated, a received error message might also have been sent by 1581 an attacker and the receiver MAY therefore try to continue the 1582 protocol. 1584 error SHALL be a CBOR Sequence (see Appendix B.1) as defined below 1586 error = ( 1587 ? C_x : bstr_identifier, 1588 ERR_CODE : int, 1589 ERR_INFO : any 1590 ) 1592 Figure 5: EDHOC Error Message 1594 where: 1596 * C_x - (optional) variable length connection identifier, encoded as 1597 a bstr_identifier (see Section 5.1). If error is sent by the 1598 Responder and corr (METHOD_CORR mod 4) equals 0 or 2 then C_x is 1599 set to C_I, else if error is sent by the Initiator and corr 1600 (METHOD_CORR mod 4) equals 0 or 1 then C_x is set to C_R, else C_x 1601 is omitted. 1603 * ERR_CODE - error code encoded as an integer. The value 0 is used 1604 for success, all other values (negative or positive) indicate 1605 errors. 1607 * ERR_INFO - error information. Content and encoding depend on 1608 error code. 1610 The remainder of this section specifies the currently defined error 1611 codes, see Figure 6. Error codes 1 and 2 MUST be supported. 1612 Additional error codes and corresponding error information may be 1613 specified. 1615 +----------+---------------+----------------------------------------+ 1616 | ERR_CODE | ERR_INFO Type | Description | 1617 +==========+===============+========================================+ 1618 | 0 | any | Success | 1619 +----------+---------------+----------------------------------------+ 1620 | 1 | tstr | Unspecified | 1621 +----------+---------------+----------------------------------------+ 1622 | 2 | SUITES_R | Wrong selected cipher suite | 1623 +----------+---------------+----------------------------------------+ 1625 Figure 6: Error Codes and Error Information 1627 6.1. Success 1629 Error code 0 MAY be used internally in an application to indicate 1630 success, e.g. in log files. ERR_INFO can contain any type of CBOR 1631 item. Error code 0 MUST NOT be used as part of the EDHOC message 1632 exchange flow. 1634 6.2. Unspecified 1636 Error code 1 is used for errors that do not have a specific error 1637 code defined. ERR_INFO MUST be a text string containing a human- 1638 readable diagnostic message written in English. The diagnostic text 1639 message is mainly intended for software engineers that during 1640 debugging need to interpret it in the context of the EDHOC 1641 specification. The diagnostic message SHOULD be provided to the 1642 calling application where it SHOULD be logged. 1644 6.3. Wrong Selected Cipher Suite 1646 Error code 2 MUST only be used in a response to message_1 in case the 1647 cipher suite selected by the Initiator is not supported by the 1648 Responder, or if the Responder supports a cipher suite more preferred 1649 by the Initiator than the selected cipher suite, see Section 5.3.3. 1650 ERR_INFO is of type SUITES_R: 1652 SUITES_R : [ supported : 2* suite ] / suite 1654 If the Responder does not support the selected cipher suite, then 1655 SUITES_R MUST include one or more supported cipher suites. If the 1656 Responder does not support the selected cipher suite, but supports 1657 another cipher suite in SUITES_I, then SUITES_R MUST include the 1658 first supported cipher suite in SUITES_I. 1660 6.3.1. Cipher Suite Negotiation 1662 After receiving SUITES_R, the Initiator can determine which cipher 1663 suite to select for the next EDHOC run with the Responder. 1665 If the Initiator intends to contact the Responder in the future, the 1666 Initiator SHOULD remember which selected cipher suite to use until 1667 the next message_1 has been sent, otherwise the Initiator and 1668 Responder will likely run into an infinite loop. After a successful 1669 run of EDHOC, the Initiator MAY remember the selected cipher suite to 1670 use in future EDHOC runs. Note that if the Initiator or Responder is 1671 updated with new cipher suite policies, any cached information may be 1672 outdated. 1674 6.3.2. Examples 1676 Assume that the Initiator supports the five cipher suites 5, 6, 7, 8, 1677 and 9 in decreasing order of preference. Figures 7 and 8 show 1678 examples of how the Initiator can truncate SUITES_I and how SUITES_R 1679 is used by Responders to give the Initiator information about the 1680 cipher suites that the Responder supports. 1682 In the first example (Figure 7), the Responder supports cipher suite 1683 6 but not the initially selected cipher suite 5. 1685 Initiator Responder 1686 | METHOD_CORR, SUITES_I = 5, G_X, C_I, EAD_1 | 1687 +------------------------------------------------------------------>| 1688 | message_1 | 1689 | | 1690 | C_I, DIAG_MSG, SUITES_R = 6 | 1691 |<------------------------------------------------------------------+ 1692 | error | 1693 | | 1694 | METHOD_CORR, SUITES_I = [6, 5, 6], G_X, C_I, EAD_1 | 1695 +------------------------------------------------------------------>| 1696 | message_1 | 1698 Figure 7: Example of Responder supporting suite 6 but not suite 5. 1700 In the second example (Figure 8), the Responder supports cipher 1701 suites 8 and 9 but not the more preferred (by the Initiator) cipher 1702 suites 5, 6 or 7. To illustrate the negotiation mechanics we let the 1703 Initiator first make a guess that the Responder supports suite 6 but 1704 not suite 5. Since the Responder supports neither 5 nor 6, it 1705 responds with an error and SUITES_R, after which the Initiator 1706 selects its most preferred supported suite. The order of cipher 1707 suites in SUITES_R does not matter. (If the Responder had supported 1708 suite 5, it would include it in SUITES_R of the response, and it 1709 would in that case have become the selected suite in the second 1710 message_1.) 1712 Initiator Responder 1713 | METHOD_CORR, SUITES_I = [6, 5, 6], G_X, C_I, EAD_1 | 1714 +------------------------------------------------------------------>| 1715 | message_1 | 1716 | | 1717 | C_I, DIAG_MSG, SUITES_R = [9, 8] | 1718 |<------------------------------------------------------------------+ 1719 | error | 1720 | | 1721 | METHOD_CORR, SUITES_I = [8, 5, 6, 7, 8], G_X, C_I, EAD_1 | 1722 +------------------------------------------------------------------>| 1723 | message_1 | 1725 Figure 8: Example of Responder supporting suites 8 and 9 but not 1726 5, 6 or 7. 1728 Note that the Initiator's list of supported cipher suites and order 1729 of preference is fixed (see Section 5.3.1 and Section 5.3.2). 1730 Furthermore, the Responder shall only accept message_1 if the 1731 selected cipher suite is the first cipher suite in SUITES_I that the 1732 Responder supports (see Section 5.3.3). Following this procedure 1733 ensures that the selected cipher suite is the most preferred (by the 1734 Initiator) cipher suite supported by both parties. 1736 If the selected cipher suite is not the first cipher suite which the 1737 Responder supports in SUITES_I received in message_1, then Responder 1738 MUST discontinue the protocol, see Section 5.3.3. If SUITES_I in 1739 message_1 is manipulated then the integrity verification of message_2 1740 containing the transcript hash TH_2 will fail and the Initiator will 1741 discontinue the protocol. 1743 7. Transferring EDHOC and Deriving an OSCORE Context 1745 7.1. EDHOC Message 4 1747 This section specifies message_4 which is OPTIONAL to support. Key 1748 confirmation is normally provided by sending an application message 1749 from the Responder to the Initiator protected with a key derived with 1750 the EDHOC-Exporter, e.g., using OSCORE (see 1751 [I-D.ietf-core-oscore-edhoc]). In deployments where no protected 1752 application message is sent from the Responder to the Initiator, the 1753 Responder MUST send message_4. Two examples of such deployments: 1755 1. When EDHOC is only used for authentication and no application 1756 data is sent. 1758 2. When application data is only sent from the Initiator to the 1759 Responder. 1761 Further considerations are provided in Section 3.7. 1763 7.1.1. Formatting of Message 4 1765 message_4 and data_4 SHALL be CBOR Sequences (see Appendix B.1) as 1766 defined below 1768 message_4 = ( 1769 data_4, 1770 CIPHERTEXT_4 : bstr, 1771 ) 1773 data_4 = ( 1774 ? C_I : bstr_identifier, 1775 ) 1777 7.1.2. Responder Processing of Message 4 1779 The Responder SHALL compose message_4 as follows: 1781 * If corr (METHOD_CORR mod 4) equals 1 or 3, C_I is omitted, 1782 otherwise C_I is not omitted. 1784 * Compute a COSE_Encrypt0 as defined in Section 5.3 of 1785 [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC AEAD algorithm 1786 in the selected cipher suite, and the following parameters. The 1787 protected header SHALL be empty. 1789 - protected = h'' 1791 - external_aad = TH_4 1793 - plaintext = ( ? EAD_4 ) 1795 where EAD_4 is protected external authorization data, see 1796 Section 3.6. COSE constructs the input to the AEAD [RFC5116] as 1797 follows: 1799 - Key K = EDHOC-Exporter( "EDHOC_message_4_Key", length ) 1801 - Nonce N = EDHOC-Exporter( "EDHOC_message_4_Nonce", length ) 1802 - Plaintext P = ( ? EAD_4 ) 1804 - Associated data A = [ "Encrypt0", h'', TH_4 ] 1806 CIPHERTEXT_4 is the 'ciphertext' of the COSE_Encrypt0. 1808 * Encode message_4 as a sequence of CBOR encoded data items as 1809 specified in Section 7.1.1. 1811 7.1.3. Initiator Processing of Message 4 1813 The Initiator SHALL process message_4 as follows: 1815 * Decode message_4 (see Appendix B.1). 1817 * Retrieve the protocol state using the connection identifier C_I 1818 and/or other external information such as the CoAP Token and the 1819 5-tuple. 1821 * Decrypt and verify the outer COSE_Encrypt0 as defined in 1822 Section 5.3 of [I-D.ietf-cose-rfc8152bis-struct], with the EDHOC 1823 AEAD algorithm in the selected cipher suite, and the parameters 1824 defined in Section 7.1.2. 1826 * Pass EAD_4 to the security application. 1828 If any verification step fails the Initiator MUST send an EDHOC error 1829 message back, formatted as defined in Section 6, and the session MUST 1830 be discontinued. 1832 7.2. Transferring EDHOC in CoAP 1834 It is recommended to transport EDHOC as an exchange of CoAP [RFC7252] 1835 messages. CoAP is a reliable transport that can preserve packet 1836 ordering and handle message duplication. CoAP can also perform 1837 fragmentation and protect against denial of service attacks. It is 1838 recommended to carry the EDHOC messages in Confirmable messages, 1839 especially if fragmentation is used. 1841 By default, the CoAP client is the Initiator and the CoAP server is 1842 the Responder, but the roles SHOULD be chosen to protect the most 1843 sensitive identity, see Section 8. By default, EDHOC is transferred 1844 in POST requests and 2.04 (Changed) responses to the Uri-Path: 1845 "/.well-known/edhoc", but an application may define its own path that 1846 can be discovered e.g. using resource directory 1847 [I-D.ietf-core-resource-directory]. 1849 By default, the message flow is as follows: EDHOC message_1 is sent 1850 in the payload of a POST request from the client to the server's 1851 resource for EDHOC. EDHOC message_2 or the EDHOC error message is 1852 sent from the server to the client in the payload of a 2.04 (Changed) 1853 response. EDHOC message_3 or the EDHOC error message is sent from 1854 the client to the server's resource in the payload of a POST request. 1855 If needed, an EDHOC error message is sent from the server to the 1856 client in the payload of a 2.04 (Changed) response. Alternatively, 1857 if EDHOC message_4 is used, it is sent from the server to the client 1858 in the payload of a 2.04 (Changed) response analogously to message_2. 1860 An example of a successful EDHOC exchange using CoAP is shown in 1861 Figure 9. In this case the CoAP Token enables the Initiator to 1862 correlate message_1 and message_2 so the correlation parameter corr = 1863 1. 1865 Client Server 1866 | | 1867 +--------->| Header: POST (Code=0.02) 1868 | POST | Uri-Path: "/.well-known/edhoc" 1869 | | Content-Format: application/edhoc 1870 | | Payload: EDHOC message_1 1871 | | 1872 |<---------+ Header: 2.04 Changed 1873 | 2.04 | Content-Format: application/edhoc 1874 | | Payload: EDHOC message_2 1875 | | 1876 +--------->| Header: POST (Code=0.02) 1877 | POST | Uri-Path: "/.well-known/edhoc" 1878 | | Content-Format: application/edhoc 1879 | | Payload: EDHOC message_3 1880 | | 1881 |<---------+ Header: 2.04 Changed 1882 | 2.04 | 1883 | | 1885 Figure 9: Transferring EDHOC in CoAP when the Initiator is CoAP 1886 Client 1888 The exchange in Figure 9 protects the client identity against active 1889 attackers and the server identity against passive attackers. An 1890 alternative exchange that protects the server identity against active 1891 attackers and the client identity against passive attackers is shown 1892 in Figure 10. In this case the CoAP Token enables the Responder to 1893 correlate message_2 and message_3 so the correlation parameter corr = 1894 2. If EDHOC message_4 is used, it is transported with CoAP in the 1895 payload of a POST request with a 2.04 (Changed) response. 1897 Client Server 1898 | | 1899 +--------->| Header: POST (Code=0.02) 1900 | POST | Uri-Path: "/.well-known/edhoc" 1901 | | 1902 |<---------+ Header: 2.04 Changed 1903 | 2.04 | Content-Format: application/edhoc 1904 | | Payload: EDHOC message_1 1905 | | 1906 +--------->| Header: POST (Code=0.02) 1907 | POST | Uri-Path: "/.well-known/edhoc" 1908 | | Content-Format: application/edhoc 1909 | | Payload: EDHOC message_2 1910 | | 1911 |<---------+ Header: 2.04 Changed 1912 | 2.04 | Content-Format: application/edhoc 1913 | | Payload: EDHOC message_3 1914 | | 1916 Figure 10: Transferring EDHOC in CoAP when the Initiator is CoAP 1917 Server 1919 To protect against denial-of-service attacks, the CoAP server MAY 1920 respond to the first POST request with a 4.01 (Unauthorized) 1921 containing an Echo option [I-D.ietf-core-echo-request-tag]. This 1922 forces the initiator to demonstrate its reachability at its apparent 1923 network address. If message fragmentation is needed, the EDHOC 1924 messages may be fragmented using the CoAP Block-Wise Transfer 1925 mechanism [RFC7959]. EDHOC does not restrict how error messages are 1926 transported with CoAP, as long as the appropriate error message can 1927 to be transported in response to a message that failed (see 1928 Section 6). The use of EDHOC with OSCORE is specified in 1929 [I-D.ietf-core-oscore-edhoc]. 1931 8. Security Considerations 1933 8.1. Security Properties 1935 EDHOC inherits its security properties from the theoretical SIGMA-I 1936 protocol [SIGMA]. Using the terminology from [SIGMA], EDHOC provides 1937 perfect forward secrecy, mutual authentication with aliveness, 1938 consistency, and peer awareness. As described in [SIGMA], peer 1939 awareness is provided to the Responder, but not to the Initiator. 1941 EDHOC protects the credential identifier of the Initiator against 1942 active attacks and the credential identifier of the Responder against 1943 passive attacks. The roles should be assigned to protect the most 1944 sensitive identity/identifier, typically that which is not possible 1945 to infer from routing information in the lower layers. 1947 Compared to [SIGMA], EDHOC adds an explicit method type and expands 1948 the message authentication coverage to additional elements such as 1949 algorithms, external authorization data, and previous messages. This 1950 protects against an attacker replaying messages or injecting messages 1951 from another session. 1953 EDHOC also adds negotiation of connection identifiers and downgrade 1954 protected negotiation of cryptographic parameters, i.e. an attacker 1955 cannot affect the negotiated parameters. A single session of EDHOC 1956 does not include negotiation of cipher suites, but it enables the 1957 Responder to verify that the selected cipher suite is the most 1958 preferred cipher suite by the Initiator which is supported by both 1959 the Initiator and the Responder. 1961 As required by [RFC7258], IETF protocols need to mitigate pervasive 1962 monitoring when possible. One way to mitigate pervasive monitoring 1963 is to use a key exchange that provides perfect forward secrecy. 1964 EDHOC therefore only supports methods with perfect forward secrecy. 1965 To limit the effect of breaches, it is important to limit the use of 1966 symmetrical group keys for bootstrapping. EDHOC therefore strives to 1967 make the additional cost of using raw public keys and self-signed 1968 certificates as small as possible. Raw public keys and self-signed 1969 certificates are not a replacement for a public key infrastructure, 1970 but SHOULD be used instead of symmetrical group keys for 1971 bootstrapping. 1973 Compromise of the long-term keys (private signature or static DH 1974 keys) does not compromise the security of completed EDHOC exchanges. 1975 Compromising the private authentication keys of one party lets an 1976 active attacker impersonate that compromised party in EDHOC exchanges 1977 with other parties, but does not let the attacker impersonate other 1978 parties in EDHOC exchanges with the compromised party. Compromise of 1979 the long-term keys does not enable a passive attacker to compromise 1980 future session keys. Compromise of the HDKF input parameters (ECDH 1981 shared secret) leads to compromise of all session keys derived from 1982 that compromised shared secret. Compromise of one session key does 1983 not compromise other session keys. Compromise of PRK_4x3m leads to 1984 compromise of all exported keying material derived after the last 1985 invocation of the EDHOC-KeyUpdate function. 1987 EDHOC provides a minimum of 64-bit security against online brute 1988 force attacks and a minimum of 128-bit security against offline brute 1989 force attacks. This is in line with IPsec, TLS, and COSE. To break 1990 64-bit security against online brute force an attacker would on 1991 average have to send 4.3 billion messages per second for 68 years, 1992 which is infeasible in constrained IoT radio technologies. 1994 After sending message_3, the Initiator is assured that no other party 1995 than the Responder can compute the key PRK_4x3m (implicit key 1996 authentication). The Initiator does however not know that the 1997 Responder has actually computed the key PRK_4x3m. While the 1998 Initiator can securely send protected application data, the Initiator 1999 SHOULD NOT permanently store the keying material PRK_4x3m and TH_4 2000 until the Initiator is assured that the Responder has actually 2001 computed the key PRK_4x3m (explicit key confirmation). Explicit key 2002 confirmation is e.g. assured when the Initiator has verified an 2003 OSCORE message or message_4 from the Responder. After verifying 2004 message_3, the Responder is assured that the Initiator has calculated 2005 the key PRK_4x3m (explicit key confirmation) and that no other party 2006 than the Responder can compute the key. The Responder can securely 2007 send protected application data and store the keying material 2008 PRK_4x3m and TH_4. 2010 Key compromise impersonation (KCI): In EDHOC authenticated with 2011 signature keys, EDHOC provides KCI protection against an attacker 2012 having access to the long term key or the ephemeral secret key. With 2013 static Diffie-Hellman key authentication, KCI protection would be 2014 provided against an attacker having access to the long-term Diffie- 2015 Hellman key, but not to an attacker having access to the ephemeral 2016 secret key. Note that the term KCI has typically been used for 2017 compromise of long-term keys, and that an attacker with access to the 2018 ephemeral secret key can only attack that specific protocol run. 2020 Repudiation: In EDHOC authenticated with signature keys, the 2021 Initiator could theoretically prove that the Responder performed a 2022 run of the protocol by presenting the private ephemeral key, and vice 2023 versa. Note that storing the private ephemeral keys violates the 2024 protocol requirements. With static Diffie-Hellman key 2025 authentication, both parties can always deny having participated in 2026 the protocol. 2028 Two earlier versions of EDHOC have been formally analyzed [Norrman20] 2029 [Bruni18] and the specification has been updated based on the 2030 analysis. 2032 8.2. Cryptographic Considerations 2034 The security of the SIGMA protocol requires the MAC to be bound to 2035 the identity of the signer. Hence the message authenticating 2036 functionality of the authenticated encryption in EDHOC is critical: 2037 authenticated encryption MUST NOT be replaced by plain encryption 2038 only, even if authentication is provided at another level or through 2039 a different mechanism. EDHOC implements SIGMA-I using a MAC-then- 2040 Sign approach. 2042 To reduce message overhead EDHOC does not use explicit nonces and 2043 instead rely on the ephemeral public keys to provide randomness to 2044 each session. A good amount of randomness is important for the key 2045 generation, to provide liveness, and to protect against interleaving 2046 attacks. For this reason, the ephemeral keys MUST NOT be reused, and 2047 both parties SHALL generate fresh random ephemeral key pairs. 2049 As discussed the [SIGMA], the encryption of message_2 does only need 2050 to protect against passive attacker as active attackers can always 2051 get the Responders identity by sending their own message_1. EDHOC 2052 uses the Expand function (typically HKDF-Expand) as a binary additive 2053 stream cipher. HKDF-Expand provides better confidentiality than AES- 2054 CTR but is not often used as it is slow on long messages, and most 2055 applications require both IND-CCA confidentiality as well as 2056 integrity protection. For the encryption of message_2, any speed 2057 difference is negligible, IND-CCA does not increase security, and 2058 integrity is provided by the inner MAC (and signature depending on 2059 method). 2061 The data rates in many IoT deployments are very limited. Given that 2062 the application keys are protected as well as the long-term 2063 authentication keys they can often be used for years or even decades 2064 before the cryptographic limits are reached. If the application keys 2065 established through EDHOC need to be renewed, the communicating 2066 parties can derive application keys with other labels or run EDHOC 2067 again. 2069 Requirement for how to securely generate, validate, and process the 2070 ephermeral public keys depend on the elliptic curve. For X25519 and 2071 X448, the requirements are defined in [RFC7748]. For secp256r1, 2072 secp384r1, and secp521r1, the requirements are defined in Section 5 2073 of [SP-800-56A]. For secp256r1, secp384r1, and secp521r1, at least 2074 partial public-key validation MUST be done. 2076 8.3. Cipher Suites and Cryptographic Algorithms 2078 For many constrained IoT devices it is problematic to support more 2079 than one cipher suite. Existing devices can be expected to support 2080 either ECDSA or EdDSA. To enable as much interoperability as we can 2081 reasonably achieve, less constrained devices SHOULD implement both 2082 cipher suite 0 (AES-CCM-16-64-128, SHA-256, X25519, EdDSA, AES-CCM- 2083 16-64-128, SHA-256) and cipher suite 2 (AES-CCM-16-64-128, SHA-256, 2084 P-256, ES256, AES-CCM-16-64-128, SHA-256). Constrained endpoints 2085 SHOULD implement cipher suite 0 or cipher suite 2. Implementations 2086 only need to implement the algorithms needed for their supported 2087 methods. 2089 When using private cipher suite or registering new cipher suites, the 2090 choice of key length used in the different algorithms needs to be 2091 harmonized, so that a sufficient security level is maintained for 2092 certificates, EDHOC, and the protection of application data. The 2093 Initiator and the Responder should enforce a minimum security level. 2095 The hash algorithms SHA-1 and SHA-256/64 (256-bit Hash truncated to 2096 64-bits) SHALL NOT be supported for use in EDHOC except for 2097 certificate identification with x5u and c5u. Note that secp256k1 is 2098 only defined for use with ECDSA and not for ECDH. 2100 8.4. Unprotected Data 2102 The Initiator and the Responder must make sure that unprotected data 2103 and metadata do not reveal any sensitive information. This also 2104 applies for encrypted data sent to an unauthenticated party. In 2105 particular, it applies to EAD_1, ID_CRED_R, EAD_2, and error 2106 messages. Using the same EAD_1 in several EDHOC sessions allows 2107 passive eavesdroppers to correlate the different sessions. Another 2108 consideration is that the list of supported cipher suites may 2109 potentially be used to identify the application. 2111 The Initiator and the Responder must also make sure that 2112 unauthenticated data does not trigger any harmful actions. In 2113 particular, this applies to EAD_1 and error messages. 2115 8.5. Denial-of-Service 2117 EDHOC itself does not provide countermeasures against Denial-of- 2118 Service attacks. By sending a number of new or replayed message_1 an 2119 attacker may cause the Responder to allocate state, perform 2120 cryptographic operations, and amplify messages. To mitigate such 2121 attacks, an implementation SHOULD rely on lower layer mechanisms such 2122 as the Echo option in CoAP [I-D.ietf-core-echo-request-tag] that 2123 forces the initiator to demonstrate reachability at its apparent 2124 network address. 2126 An attacker can also send faked message_2, message_3, message_4, or 2127 error in an attempt to trick the receiving party to send an error 2128 message and discontinue the session. EDHOC implementations MAY 2129 evaluate if a received message is likely to have be forged by and 2130 attacker and ignore it without sending an error message or 2131 discontinuing the session. 2133 8.6. Implementation Considerations 2135 The availability of a secure random number generator is essential for 2136 the security of EDHOC. If no true random number generator is 2137 available, a truly random seed MUST be provided from an external 2138 source and used with a cryptographically secure pseudorandom number 2139 generator. As each pseudorandom number must only be used once, an 2140 implementation need to get a new truly random seed after reboot, or 2141 continuously store state in nonvolatile memory, see ([RFC8613], 2142 Appendix B.1.1) for issues and solution approaches for writing to 2143 nonvolatile memory. Intentionally or unintentionally weak or 2144 predictable pseudorandom number generators can be abused or exploited 2145 for malicious purposes. [RFC8937] describes a way for security 2146 protocol implementations to augment their (pseudo)random number 2147 generators using a long-term private keys and a deterministic 2148 signature function. This improves randomness from broken or 2149 otherwise subverted random number generators. The same idea can be 2150 used with other secrets and functions such as a Diffie-Hellman 2151 function or a symmetric secret and a PRF like HMAC or KMAC. It is 2152 RECOMMENDED to not trust a single source of randomness and to not put 2153 unaugmented random numbers on the wire. 2155 If ECDSA is supported, "deterministic ECDSA" as specified in 2156 [RFC6979] MAY be used. Pure deterministic elliptic-curve signatures 2157 such as deterministic ECDSA and EdDSA have gained popularity over 2158 randomized ECDSA as their security do not depend on a source of high- 2159 quality randomness. Recent research has however found that 2160 implementations of these signature algorithms may be vulnerable to 2161 certain side-channel and fault injection attacks due to their 2162 determinism. See e.g. Section 1 of 2164 [I-D.mattsson-cfrg-det-sigs-with-noise] for a list of attack papers. 2165 As suggested in Section 6.1.2 of [I-D.ietf-cose-rfc8152bis-algs] this 2166 can be addressed by combining randomness and determinism. 2168 All private keys, symmetric keys, and IVs MUST be secret. 2169 Implementations should provide countermeasures to side-channel 2170 attacks such as timing attacks. Intermediate computed values such as 2171 ephemeral ECDH keys and ECDH shared secrets MUST be deleted after key 2172 derivation is completed. 2174 The Initiator and the Responder are responsible for verifying the 2175 integrity of certificates. The selection of trusted CAs should be 2176 done very carefully and certificate revocation should be supported. 2177 The private authentication keys MUST be kept secret. 2179 The Initiator and the Responder are allowed to select the connection 2180 identifiers C_I and C_R, respectively, for the other party to use in 2181 the ongoing EDHOC protocol as well as in a subsequent application 2182 protocol (e.g. OSCORE [RFC8613]). The choice of connection 2183 identifier is not security critical in EDHOC but intended to simplify 2184 the retrieval of the right security context in combination with using 2185 short identifiers. If the wrong connection identifier of the other 2186 party is used in a protocol message it will result in the receiving 2187 party not being able to retrieve a security context (which will 2188 terminate the protocol) or retrieve the wrong security context (which 2189 also terminates the protocol as the message cannot be verified). 2191 If two nodes unintentionally initiate two simultaneous EDHOC message 2192 exchanges with each other even if they only want to complete a single 2193 EDHOC message exchange, they MAY terminate the exchange with the 2194 lexicographically smallest G_X. If the two G_X values are equal, the 2195 received message_1 MUST be discarded to mitigate reflection attacks. 2196 Note that in the case of two simultaneous EDHOC exchanges where the 2197 nodes only complete one and where the nodes have different preferred 2198 cipher suites, an attacker can affect which of the two nodes' 2199 preferred cipher suites will be used by blocking the other exchange. 2201 If supported by the device, it is RECOMMENDED that at least the long- 2202 term private keys are stored in a Trusted Execution Environment (TEE) 2203 and that sensitive operations using these keys are performed inside 2204 the TEE. To achieve even higher security it is RECOMMENDED that in 2205 additional operations such as ephemeral key generation, all 2206 computations of shared secrets, and storage of the pseudorandom keys 2207 (PRK) can be done inside the TEE. The use of a TEE enforces that 2208 code within that environment cannot be tampered with, and that any 2209 data used by such code cannot be read or tampered with by code 2210 outside that environment. Note that non-EDHOC code inside the TEE 2211 might still be able to read EDHOC data and tamper with EDHOC code, to 2212 protect against such attacks EDHOC needs to be in its own zone. To 2213 provide better protection against some forms of physical attacks, 2214 sensitive EDHOC data should be stored inside the SoC or encrypted and 2215 integrity protected when sent on a data bus (e.g. between the CPU and 2216 RAM or Flash). Secure boot can be used to increase the security of 2217 code and data in the Rich Execution Environment (REE) by validating 2218 the REE image. 2220 9. IANA Considerations 2222 9.1. EDHOC Exporter Label 2224 IANA has created a new registry titled "EDHOC Exporter Label" under 2225 the new heading "EDHOC". The registration procedure is "Expert 2226 Review". The columns of the registry are Label, Description, and 2227 Reference. All columns are text strings. The initial contents of 2228 the registry are: 2230 Label: EDHOC_message_4_Key 2231 Description: Key used to protect EDHOC message_4 2232 Reference: [[this document]] 2234 Label: EDHOC_message_4_Nonce 2235 Description: Nonce used to protect EDHOC message_4 2236 Reference: [[this document]] 2238 9.2. EDHOC Cipher Suites Registry 2240 IANA has created a new registry titled "EDHOC Cipher Suites" under 2241 the new heading "EDHOC". The registration procedure is "Expert 2242 Review". The columns of the registry are Value, Array, Description, 2243 and Reference, where Value is an integer and the other columns are 2244 text strings. The initial contents of the registry are: 2246 Value: -24 2247 Algorithms: N/A 2248 Desc: Reserved for Private Use 2249 Reference: [[this document]] 2251 Value: -23 2252 Algorithms: N/A 2253 Desc: Reserved for Private Use 2254 Reference: [[this document]] 2256 Value: -22 2257 Algorithms: N/A 2258 Desc: Reserved for Private Use 2259 Reference: [[this document]] 2260 Value: -21 2261 Algorithms: N/A 2262 Desc: Reserved for Private Use 2263 Reference: [[this document]] 2265 Value: 0 2266 Array: 10, -16, 4, -8, 10, -16 2267 Desc: AES-CCM-16-64-128, SHA-256, X25519, EdDSA, 2268 AES-CCM-16-64-128, SHA-256 2269 Reference: [[this document]] 2271 Value: 1 2272 Array: 30, -16, 4, -8, 10, -16 2273 Desc: AES-CCM-16-128-128, SHA-256, X25519, EdDSA, 2274 AES-CCM-16-64-128, SHA-256 2275 Reference: [[this document]] 2277 Value: 2 2278 Array: 10, -16, 1, -7, 10, -16 2279 Desc: AES-CCM-16-64-128, SHA-256, P-256, ES256, 2280 AES-CCM-16-64-128, SHA-256 2281 Reference: [[this document]] 2283 Value: 3 2284 Array: 30, -16, 1, -7, 10, -16 2285 Desc: AES-CCM-16-128-128, SHA-256, P-256, ES256, 2286 AES-CCM-16-64-128, SHA-256 2287 Reference: [[this document]] 2289 Value: 4 2290 Array: 1, -16, 4, -7, 1, -16 2291 Desc: A128GCM, SHA-256, X25519, ES256, 2292 A128GCM, SHA-256 2293 Reference: [[this document]] 2295 Value: 5 2296 Array: 3, -43, 2, -35, 3, -43 2297 Desc: A256GCM, SHA-384, P-384, ES384, 2298 A256GCM, SHA-384 2299 Reference: [[this document]] 2301 9.3. EDHOC Method Type Registry 2303 IANA has created a new registry entitled "EDHOC Method Type" under 2304 the new heading "EDHOC". The registration procedure is "Expert 2305 Review". The columns of the registry are Value, Description, and 2306 Reference, where Value is an integer and the other columns are text 2307 strings. The initial contents of the registry is shown in Figure 4. 2309 9.4. EDHOC Error Codes Registry 2311 IANA has created a new registry entitled "EDHOC Error Codes" under 2312 the new heading "EDHOC". The registration procedure is 2313 "Specification Required". The columns of the registry are ERR_CODE, 2314 ERR_INFO Type and Description, where ERR_CODE is an integer, ERR_INFO 2315 is a CDDL defined type, and Description is a text string. The 2316 initial contents of the registry is shown in Figure 6. 2318 9.5. The Well-Known URI Registry 2320 IANA has added the well-known URI 'edhoc' to the Well-Known URIs 2321 registry. 2323 * URI suffix: edhoc 2325 * Change controller: IETF 2327 * Specification document(s): [[this document]] 2329 * Related information: None 2331 9.6. Media Types Registry 2333 IANA has added the media type 'application/edhoc' to the Media Types 2334 registry. 2336 * Type name: application 2338 * Subtype name: edhoc 2340 * Required parameters: N/A 2342 * Optional parameters: N/A 2344 * Encoding considerations: binary 2346 * Security considerations: See Section 7 of this document. 2348 * Interoperability considerations: N/A 2350 * Published specification: [[this document]] (this document) 2352 * Applications that use this media type: To be identified 2354 * Fragment identifier considerations: N/A 2356 * Additional information: 2358 - Magic number(s): N/A 2360 - File extension(s): N/A 2362 - Macintosh file type code(s): N/A 2364 * Person & email address to contact for further information: See 2365 "Authors' Addresses" section. 2367 * Intended usage: COMMON 2369 * Restrictions on usage: N/A 2371 * Author: See "Authors' Addresses" section. 2373 * Change Controller: IESG 2375 9.7. CoAP Content-Formats Registry 2377 IANA has added the media type 'application/edhoc' to the CoAP 2378 Content-Formats registry. 2380 * Media Type: application/edhoc 2382 * Encoding: 2384 * ID: TBD42 2386 * Reference: [[this document]] 2388 9.8. Expert Review Instructions 2390 The IANA Registries established in this document is defined as 2391 "Expert Review". This section gives some general guidelines for what 2392 the experts should be looking for, but they are being designated as 2393 experts for a reason so they should be given substantial latitude. 2395 Expert reviewers should take into consideration the following points: 2397 * Clarity and correctness of registrations. Experts are expected to 2398 check the clarity of purpose and use of the requested entries. 2399 Expert needs to make sure the values of algorithms are taken from 2400 the right registry, when that's required. Expert should consider 2401 requesting an opinion on the correctness of registered parameters 2402 from relevant IETF working groups. Encodings that do not meet 2403 these objective of clarity and completeness should not be 2404 registered. 2406 * Experts should take into account the expected usage of fields when 2407 approving point assignment. The length of the encoded value 2408 should be weighed against how many code points of that length are 2409 left, the size of device it will be used on, and the number of 2410 code points left that encode to that size. 2412 * Specifications are recommended. When specifications are not 2413 provided, the description provided needs to have sufficient 2414 information to verify the points above. 2416 10. References 2418 10.1. Normative References 2420 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2421 Requirement Levels", BCP 14, RFC 2119, 2422 DOI 10.17487/RFC2119, March 1997, 2423 . 2425 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 2426 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 2427 . 2429 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 2430 Key Derivation Function (HKDF)", RFC 5869, 2431 DOI 10.17487/RFC5869, May 2010, 2432 . 2434 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 2435 Curve Cryptography Algorithms", RFC 6090, 2436 DOI 10.17487/RFC6090, February 2011, 2437 . 2439 [RFC6979] Pornin, T., "Deterministic Usage of the Digital Signature 2440 Algorithm (DSA) and Elliptic Curve Digital Signature 2441 Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, August 2442 2013, . 2444 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 2445 Application Protocol (CoAP)", RFC 7252, 2446 DOI 10.17487/RFC7252, June 2014, 2447 . 2449 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 2450 for Security", RFC 7748, DOI 10.17487/RFC7748, January 2451 2016, . 2453 [RFC8949] Bormann, C. and P. Hoffman, "Concise Binary Object 2454 Representation (CBOR)", STD 94, RFC 8949, 2455 DOI 10.17487/RFC8949, December 2020, 2456 . 2458 [RFC7959] Bormann, C. and Z. Shelby, Ed., "Block-Wise Transfers in 2459 the Constrained Application Protocol (CoAP)", RFC 7959, 2460 DOI 10.17487/RFC7959, August 2016, 2461 . 2463 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2464 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2465 May 2017, . 2467 [RFC8376] Farrell, S., Ed., "Low-Power Wide Area Network (LPWAN) 2468 Overview", RFC 8376, DOI 10.17487/RFC8376, May 2018, 2469 . 2471 [RFC8610] Birkholz, H., Vigano, C., and C. Bormann, "Concise Data 2472 Definition Language (CDDL): A Notational Convention to 2473 Express Concise Binary Object Representation (CBOR) and 2474 JSON Data Structures", RFC 8610, DOI 10.17487/RFC8610, 2475 June 2019, . 2477 [RFC8613] Selander, G., Mattsson, J., Palombini, F., and L. Seitz, 2478 "Object Security for Constrained RESTful Environments 2479 (OSCORE)", RFC 8613, DOI 10.17487/RFC8613, July 2019, 2480 . 2482 [RFC8724] Minaburo, A., Toutain, L., Gomez, C., Barthel, D., and JC. 2483 Zúñiga, "SCHC: Generic Framework for Static Context Header 2484 Compression and Fragmentation", RFC 8724, 2485 DOI 10.17487/RFC8724, April 2020, 2486 . 2488 [RFC8742] Bormann, C., "Concise Binary Object Representation (CBOR) 2489 Sequences", RFC 8742, DOI 10.17487/RFC8742, February 2020, 2490 . 2492 [I-D.ietf-cose-rfc8152bis-struct] 2493 Schaad, J., "CBOR Object Signing and Encryption (COSE): 2494 Structures and Process", Work in Progress, Internet-Draft, 2495 draft-ietf-cose-rfc8152bis-struct-15, 1 February 2021, 2496 . 2499 [I-D.ietf-cose-rfc8152bis-algs] 2500 Schaad, J., "CBOR Object Signing and Encryption (COSE): 2501 Initial Algorithms", Work in Progress, Internet-Draft, 2502 draft-ietf-cose-rfc8152bis-algs-12, 24 September 2020, 2503 . 2506 [I-D.ietf-cose-x509] 2507 Schaad, J., "CBOR Object Signing and Encryption (COSE): 2508 Header parameters for carrying and referencing X.509 2509 certificates", Work in Progress, Internet-Draft, draft- 2510 ietf-cose-x509-08, 14 December 2020, 2511 . 2514 [I-D.ietf-core-echo-request-tag] 2515 Amsüss, C., Mattsson, J. P., and G. Selander, "CoAP: Echo, 2516 Request-Tag, and Token Processing", Work in Progress, 2517 Internet-Draft, draft-ietf-core-echo-request-tag-12, 1 2518 February 2021, . 2521 [I-D.ietf-lake-reqs] 2522 Vucinic, M., Selander, G., Mattsson, J. P., and D. Garcia- 2523 Carrillo, "Requirements for a Lightweight AKE for OSCORE", 2524 Work in Progress, Internet-Draft, draft-ietf-lake-reqs-04, 2525 8 June 2020, . 2528 10.2. Informative References 2530 [RFC7228] Bormann, C., Ersue, M., and A. Keranen, "Terminology for 2531 Constrained-Node Networks", RFC 7228, 2532 DOI 10.17487/RFC7228, May 2014, 2533 . 2535 [RFC7258] Farrell, S. and H. Tschofenig, "Pervasive Monitoring Is an 2536 Attack", BCP 188, RFC 7258, DOI 10.17487/RFC7258, May 2537 2014, . 2539 [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T. 2540 Kivinen, "Internet Key Exchange Protocol Version 2 2541 (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October 2542 2014, . 2544 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 2545 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 2546 . 2548 [RFC8937] Cremers, C., Garratt, L., Smyshlyaev, S., Sullivan, N., 2549 and C. Wood, "Randomness Improvements for Security 2550 Protocols", RFC 8937, DOI 10.17487/RFC8937, October 2020, 2551 . 2553 [I-D.ietf-core-resource-directory] 2554 Amsüss, C., Shelby, Z., Koster, M., Bormann, C., and P. V. 2555 D. Stok, "CoRE Resource Directory", Work in Progress, 2556 Internet-Draft, draft-ietf-core-resource-directory-28, 7 2557 March 2021, . 2560 [I-D.ietf-lwig-security-protocol-comparison] 2561 Mattsson, J. P., Palombini, F., and M. Vucinic, 2562 "Comparison of CoAP Security Protocols", Work in Progress, 2563 Internet-Draft, draft-ietf-lwig-security-protocol- 2564 comparison-05, 2 November 2020, 2565 . 2568 [I-D.ietf-tls-dtls13] 2569 Rescorla, E., Tschofenig, H., and N. Modadugu, "The 2570 Datagram Transport Layer Security (DTLS) Protocol Version 2571 1.3", Work in Progress, Internet-Draft, draft-ietf-tls- 2572 dtls13-43, 30 April 2021, . 2575 [I-D.selander-ace-ake-authz] 2576 Selander, G., Mattsson, J. P., Vucinic, M., Richardson, 2577 M., and A. Schellenbaum, "Lightweight Authorization for 2578 Authenticated Key Exchange.", Work in Progress, Internet- 2579 Draft, draft-selander-ace-ake-authz-02, 2 November 2020, 2580 . 2583 [I-D.ietf-core-oscore-edhoc] 2584 Palombini, F., Tiloca, M., Hoeglund, R., Hristozov, S., 2585 and G. Selander, "Combining EDHOC and OSCORE", Work in 2586 Progress, Internet-Draft, draft-ietf-core-oscore-edhoc-00, 2587 1 April 2021, . 2590 [I-D.ietf-cose-cbor-encoded-cert] 2591 Raza, S., Höglund, J., Selander, G., Mattsson, J. P., and 2592 M. Furuhed, "CBOR Encoded X.509 Certificates (C509 2593 Certificates)", Work in Progress, Internet-Draft, draft- 2594 ietf-cose-cbor-encoded-cert-00, 28 April 2021, 2595 . 2598 [I-D.mattsson-cfrg-det-sigs-with-noise] 2599 Mattsson, J. P., Thormarker, E., and S. Ruohomaa, 2600 "Deterministic ECDSA and EdDSA Signatures with Additional 2601 Randomness", Work in Progress, Internet-Draft, draft- 2602 mattsson-cfrg-det-sigs-with-noise-02, 11 March 2020, 2603 . 2606 [SP-800-56A] 2607 Barker, E., Chen, L., Roginsky, A., Vassilev, A., and R. 2608 Davis, "Recommendation for Pair-Wise Key-Establishment 2609 Schemes Using Discrete Logarithm Cryptography", 2610 NIST Special Publication 800-56A Revision 3, April 2018, 2611 . 2613 [SECG] "Standards for Efficient Cryptography 1 (SEC 1)", May 2614 2009, . 2616 [SIGMA] Krawczyk, H., "SIGMA - The 'SIGn-and-MAc' Approach to 2617 Authenticated Diffie-Hellman and Its Use in the IKE- 2618 Protocols (Long version)", June 2003, 2619 . 2621 [CNSA] (Placeholder), ., "Commercial National Security Algorithm 2622 Suite", August 2015, 2623 . 2626 [Norrman20] 2627 Norrman, K., Sundararajan, V., and A. Bruni, "Formal 2628 Analysis of EDHOC Key Establishment for Constrained IoT 2629 Devices", September 2020, 2630 . 2632 [Bruni18] Bruni, A., Sahl Jørgensen, T., Grønbech Petersen, T., and 2633 C. Schürmann, "Formal Verification of Ephemeral Diffie- 2634 Hellman Over COSE (EDHOC)", November 2018, 2635 . 2639 [CborMe] Bormann, C., "CBOR Playground", May 2018, 2640 . 2642 Appendix A. Compact Representation 2644 As described in Section 4.2 of [RFC6090] the x-coordinate of an 2645 elliptic curve public key is a suitable representative for the entire 2646 point whenever scalar multiplication is used as a one-way function. 2647 One example is ECDH with compact output, where only the x-coordinate 2648 of the computed value is used as the shared secret. 2650 This section defines a format for compact representation based on the 2651 Elliptic-Curve-Point-to-Octet-String Conversion defined in 2652 Section 2.3.3 of [SECG]. Using the notation from [SECG], the output 2653 is an octet string of length ceil( (log2 q) / 8 ). See [SECG] for a 2654 definition of q, M, X, xp, and ~yp. The steps in Section 2.3.3 of 2655 [SECG] are replaced by: 2657 1. Convert the field element xp to an octet string X of length ceil( 2658 (log2 q) / 8 ) octets using the conversion routine specified in 2659 Section 2.3.5 of [SECG]. 2661 2. Output M = X 2663 The encoding of the point at infinity is not supported. Compact 2664 representation does not change any requirements on validation. If a 2665 y-coordinate is required for validation or compatibily with APIs the 2666 value ~yp SHALL be set to zero. For such use, the compact 2667 representation can be transformed into the SECG point compressed 2668 format by prepending it with the single byte 0x02 (i.e. M = 0x02 || 2669 X). 2671 Using compact representation have some security benefits. An 2672 implementation does not need to check that the point is not the point 2673 at infinity (the identity element). Similarly, as not even the sign 2674 of the y-coordinate is encoded, compact representation trivially 2675 avoids so called "benign malleability" attacks where an attacker 2676 changes the sign, see [SECG]. 2678 Appendix B. Use of CBOR, CDDL and COSE in EDHOC 2680 This Appendix is intended to simplify for implementors not familiar 2681 with CBOR [RFC8949], CDDL [RFC8610], COSE 2682 [I-D.ietf-cose-rfc8152bis-struct], and HKDF [RFC5869]. 2684 B.1. CBOR and CDDL 2686 The Concise Binary Object Representation (CBOR) [RFC8949] is a data 2687 format designed for small code size and small message size. CBOR 2688 builds on the JSON data model but extends it by e.g. encoding binary 2689 data directly without base64 conversion. In addition to the binary 2690 CBOR encoding, CBOR also has a diagnostic notation that is readable 2691 and editable by humans. The Concise Data Definition Language (CDDL) 2692 [RFC8610] provides a way to express structures for protocol messages 2693 and APIs that use CBOR. [RFC8610] also extends the diagnostic 2694 notation. 2696 CBOR data items are encoded to or decoded from byte strings using a 2697 type-length-value encoding scheme, where the three highest order bits 2698 of the initial byte contain information about the major type. CBOR 2699 supports several different types of data items, in addition to 2700 integers (int, uint), simple values (e.g. null), byte strings (bstr), 2701 and text strings (tstr), CBOR also supports arrays [] of data items, 2702 maps {} of pairs of data items, and sequences [RFC8742] of data 2703 items. Some examples are given below. For a complete specification 2704 and more examples, see [RFC8949] and [RFC8610]. We recommend 2705 implementors to get used to CBOR by using the CBOR playground 2706 [CborMe]. 2708 Diagnostic Encoded Type 2709 ------------------------------------------------------------------ 2710 1 0x01 unsigned integer 2711 24 0x1818 unsigned integer 2712 -24 0x37 negative integer 2713 -25 0x3818 negative integer 2714 null 0xf6 simple value 2715 h'12cd' 0x4212cd byte string 2716 '12cd' 0x4431326364 byte string 2717 "12cd" 0x6431326364 text string 2718 { 4 : h'cd' } 0xa10441cd map 2719 << 1, 2, null >> 0x430102f6 byte string 2720 [ 1, 2, null ] 0x830102f6 array 2721 ( 1, 2, null ) 0x0102f6 sequence 2722 1, 2, null 0x0102f6 sequence 2723 ------------------------------------------------------------------ 2725 B.2. CDDL Definitions 2727 This sections compiles the CDDL definitions for ease of reference. 2729 bstr_identifier = bstr / int 2731 suite = int 2733 SUITES_R : [ supported : 2* suite ] / suite 2735 message_1 = ( 2736 ? C_1 : null, 2737 METHOD_CORR : int, 2738 SUITES_I : [ selected : suite, supported : 2* suite ] / suite, 2739 G_X : bstr, 2740 C_I : bstr_identifier, 2741 ? EAD ; EAD_1 2742 ) 2744 message_2 = ( 2745 data_2, 2746 CIPHERTEXT_2 : bstr, 2747 ) 2749 data_2 = ( 2750 ? C_I : bstr_identifier, 2751 G_Y : bstr, 2752 C_R : bstr_identifier, 2753 ) 2755 message_3 = ( 2756 data_3, 2757 CIPHERTEXT_3 : bstr, 2758 ) 2760 data_3 = ( 2761 ? C_R : bstr_identifier, 2762 ) 2764 message_4 = ( 2765 data_4, 2766 CIPHERTEXT_4 : bstr, 2767 ) 2769 data_4 = ( 2770 ? C_I : bstr_identifier, 2771 ) 2773 error = ( 2774 ? C_x : bstr_identifier, 2775 ERR_CODE : int, 2776 ERR_INFO : any 2778 ) 2780 info = [ 2781 edhoc_aead_id : int / tstr, 2782 transcript_hash : bstr, 2783 label : tstr, 2784 length : uint 2785 ] 2787 B.3. COSE 2789 CBOR Object Signing and Encryption (COSE) 2790 [I-D.ietf-cose-rfc8152bis-struct] describes how to create and process 2791 signatures, message authentication codes, and encryption using CBOR. 2792 COSE builds on JOSE, but is adapted to allow more efficient 2793 processing in constrained devices. EDHOC makes use of COSE_Key, 2794 COSE_Encrypt0, and COSE_Sign1 objects. 2796 Appendix C. Test Vectors 2798 Note: The test vectors are not updated to version -07 of the draft. 2799 More changes affecting the test vectors are anticipated for -08. 2801 This appendix provides detailed test vectors to ease implementation 2802 and ensure interoperability. The test vectors in this version are 2803 compatible with versions -05 and -06 of the specification. In 2804 addition to hexadecimal, all CBOR data items and sequences are given 2805 in CBOR diagnostic notation. The test vectors use the default 2806 mapping to CoAP where the Initiator acts as CoAP client (this means 2807 that corr = 1). 2809 A more extensive test vector suite covering more combinations of 2810 authentication method used between Initiator and Responder and 2811 related code to generate them can be found at https://github.com/ 2812 lake-wg/edhoc/tree/master/test-vectors-05. 2814 NOTE 1. In the previous and current test vectors the same name is 2815 used for certain byte strings and their CBOR bstr encodings. For 2816 example the transcript hash TH_2 is used to denote both the output of 2817 the hash function and the input into the key derivation function, 2818 whereas the latter is a CBOR bstr encoding of the former. Some 2819 attempts are made to clarify that in this Appendix (e.g. using "CBOR 2820 encoded"/"CBOR unencoded"). 2822 NOTE 2. If not clear from the context, remember that CBOR sequences 2823 and CBOR arrays assume CBOR encoded data items as elements. 2825 C.1. Test Vectors for EDHOC Authenticated with Signature Keys (x5t) 2827 EDHOC with signature authentication and X.509 certificates is used. 2828 In this test vector, the hash value 'x5t' is used to identify the 2829 certificate. The optional C_1 in message_1 is omitted. No external 2830 authorization data is sent in the message exchange. 2832 method (Signature Authentication) 2833 0 2835 CoAP is used as transport and the Initiator acts as CoAP client: 2837 corr (the Initiator can correlate message_1 and message_2) 2838 1 2840 From there, METHOD_CORR has the following value: 2842 METHOD_CORR (4 * method + corr) (int) 2843 1 2845 The Initiator indicates only one cipher suite in the (potentially 2846 truncated) list of cipher suites. 2848 Supported Cipher Suites (1 byte) 2849 00 2851 The Initiator selected the indicated cipher suite. 2853 Selected Cipher Suite (int) 2854 0 2856 Cipher suite 0 is supported by both the Initiator and the Responder, 2857 see Section 3.4. 2859 C.1.1. Message_1 2861 The Initiator generates its ephemeral key pair. 2863 X (Initiator's ephemeral private key) (32 bytes) 2864 8f 78 1a 09 53 72 f8 5b 6d 9f 61 09 ae 42 26 11 73 4d 7d bf a0 06 9a 2d 2865 f2 93 5b b2 e0 53 bf 35 2867 G_X (Initiator's ephemeral public key, CBOR unencoded) (32 bytes) 2868 89 8f f7 9a 02 06 7a 16 ea 1e cc b9 0f a5 22 46 f5 aa 4d d6 ec 07 6b ba 2869 02 59 d9 04 b7 ec 8b 0c 2871 The Initiator chooses a connection identifier C_I: 2873 Connection identifier chosen by Initiator (1 byte) 2874 09 2876 Note that since C_I is a byte string in the interval h'00' to h'2f', 2877 it is encoded as the corresponding integer subtracted by 24 (see 2878 bstr_identifier in Section 5.1). Thus 0x09 = 09, 9 - 24 = -15, and 2879 -15 in CBOR encoding is equal to 0x2e. 2881 C_I (1 byte) 2882 2e 2884 Since no external authorization data is sent: 2886 EAD_1 (0 bytes) 2888 The list of supported cipher suites needs to contain the selected 2889 cipher suite. The initiator truncates the list of supported cipher 2890 suites to one cipher suite only. In this case there is only one 2891 supported cipher suite indicated, 00. 2893 Because one single selected cipher suite is conveyed, it is encoded 2894 as an int instead of an array: 2896 SUITES_I (int) 2897 0 2899 message_1 is constructed as the CBOR Sequence of the data items above 2900 encoded as CBOR. In CBOR diagnostic notation: 2902 message_1 = 2903 ( 2904 1, 2905 0, 2906 h'898FF79A02067A16EA1ECCB90FA52246F5AA4DD6EC076BBA0259D904B7EC8B0C', 2907 -15 2908 ) 2910 Which as a CBOR encoded data item is: 2912 message_1 (CBOR Sequence) (37 bytes) 2913 01 00 58 20 89 8f f7 9a 02 06 7a 16 ea 1e cc b9 0f a5 22 46 f5 aa 4d d6 2914 ec 07 6b ba 02 59 d9 04 b7 ec 8b 0c 2e 2916 C.1.2. Message_2 2918 Since METHOD_CORR mod 4 equals 1, C_I is omitted from data_2. 2920 The Responder generates the following ephemeral key pair. 2922 Y (Responder's ephemeral private key) (32 bytes) 2923 fd 8c d8 77 c9 ea 38 6e 6a f3 4f f7 e6 06 c4 b6 4c a8 31 c8 ba 33 13 4f 2924 d4 cd 71 67 ca ba ec da 2926 G_Y (Responder's ephemeral public key, CBOR unencoded) (32 bytes) 2927 71 a3 d5 99 c2 1d a1 89 02 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 19 52 2928 81 75 4c 5e bc af 30 1e 2930 From G_X and Y or from G_Y and X the ECDH shared secret is computed: 2932 G_XY (ECDH shared secret) (32 bytes) 2933 2b b7 fa 6e 13 5b c3 35 d0 22 d6 34 cb fb 14 b3 f5 82 f3 e2 e3 af b2 b3 2934 15 04 91 49 5c 61 78 2b 2936 The key and nonce for calculating the 'ciphertext' are calculated as 2937 follows, as specified in Section 4. 2939 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 2941 PRK_2e = HMAC-SHA-256(salt, G_XY) 2943 Salt is the empty byte string. 2945 salt (0 bytes) 2947 From there, PRK_2e is computed: 2949 PRK_2e (32 bytes) 2950 ec 62 92 a0 67 f1 37 fc 7f 59 62 9d 22 6f bf c4 e0 68 89 49 f6 62 a9 7f 2951 d8 2f be b7 99 71 39 4a 2953 The Responder's sign/verify key pair is the following: 2955 SK_R (Responder's private authentication key) (32 bytes) 2956 df 69 27 4d 71 32 96 e2 46 30 63 65 37 2b 46 83 ce d5 38 1b fc ad cd 44 2957 0a 24 c3 91 d2 fe db 94 2959 PK_R (Responder's public authentication key) (32 bytes) 2960 db d9 dc 8c d0 3f b7 c3 91 35 11 46 2b b2 38 16 47 7c 6b d8 d6 6e f5 a1 2961 a0 70 ac 85 4e d7 3f d2 2963 Since neither the Initiator nor the Responder authenticates with a 2964 static Diffie-Hellman key, PRK_3e2m = PRK_2e 2966 PRK_3e2m (32 bytes) 2967 ec 62 92 a0 67 f1 37 fc 7f 59 62 9d 22 6f bf c4 e0 68 89 49 f6 62 a9 7f 2968 d8 2f be b7 99 71 39 4a 2969 The Responder chooses a connection identifier C_R. 2971 Connection identifier chosen by Responder (1 byte) 2972 00 2974 Note that since C_R is a byte string in the interval h'00' to h'2f', 2975 it is encoded as the corresponding integer subtracted by 24 (see 2976 bstr_identifier in Section 5.1). Thus 0x00 = 0, 0 - 24 = -24, and 2977 -24 in CBOR encoding is equal to 0x37. 2979 C_R (1 byte) 2980 37 2982 Data_2 is constructed as the CBOR Sequence of G_Y and C_R, encoded as 2983 CBOR byte strings. The CBOR diagnostic notation is: 2985 data_2 = 2986 ( 2987 h'71a3d599c21da18902a1aea810b2b6382ccd8d5f9bf0195281754c5ebcaf301e', 2988 -24 2989 ) 2991 Which as a CBOR encoded data item is: 2993 data_2 (CBOR Sequence) (35 bytes) 2994 58 20 71 a3 d5 99 c2 1d a1 89 02 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 2995 19 52 81 75 4c 5e bc af 30 1e 37 2997 From data_2 and message_1, compute the input to the transcript hash 2998 TH_2 = H( H(message_1), data_2 ), as a CBOR Sequence of these 2 data 2999 items. 3001 Input to calculate TH_2 (CBOR Sequence) (72 bytes) 3002 01 00 58 20 89 8f f7 9a 02 06 7a 16 ea 1e cc b9 0f a5 22 46 f5 aa 4d d6 3003 ec 07 6b ba 02 59 d9 04 b7 ec 8b 0c 2e 58 20 71 a3 d5 99 c2 1d a1 89 02 3004 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 19 52 81 75 4c 5e bc af 30 1e 37 3006 And from there, compute the transcript hash TH_2 = SHA-256( 3007 H(message_1), data_2 ) 3009 TH_2 (CBOR unencoded) (32 bytes) 3010 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 d3 76 d2 c2 3011 c1 53 c1 7f 8e 96 29 ff 3013 The Responder's subject name is the empty string: 3015 Responder's subject name (text string) 3016 "" 3017 In this version of the test vectors CRED_R is not a DER encoded X.509 3018 certificate, but a string of random bytes. 3020 CRED_R (CBOR unencoded) (100 bytes) 3021 c7 88 37 00 16 b8 96 5b db 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 6e 86 3022 44 2b 87 ec 3f f2 45 b7 0a 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e c9 d6 3023 b0 53 4b 71 c2 b4 9e 4b f9 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 38 1e 3024 98 db 71 41 08 41 5e 5c 50 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 71 be 3025 5c 22 5e b2 3027 CRED_R is defined to be the CBOR bstr containing the credential of 3028 the Responder. 3030 CRED_R (102 bytes) 3031 58 64 c7 88 37 00 16 b8 96 5b db 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 3032 6e 86 44 2b 87 ec 3f f2 45 b7 0a 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e 3033 c9 d6 b0 53 4b 71 c2 b4 9e 4b f9 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 3034 38 1e 98 db 71 41 08 41 5e 5c 50 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 3035 71 be 5c 22 5e b2 3037 And because certificates are identified by a hash value with the 3038 'x5t' parameter, ID_CRED_R is the following: 3040 ID_CRED_R = { 34 : COSE_CertHash }. In this example, the hash 3041 algorithm used is SHA-2 256-bit with hash truncated to 64-bits (value 3042 -15). The hash value is calculated over the CBOR unencoded CRED_R. 3043 The CBOR diagnostic notation is: 3045 ID_CRED_R = 3046 { 3047 34: [-15, h'6844078A53F312F5'] 3048 } 3050 which when encoded as a CBOR map becomes: 3052 ID_CRED_R (14 bytes) 3053 a1 18 22 82 2e 48 68 44 07 8a 53 f3 12 f5 3055 Since no external authorization data is sent: 3057 EAD_2 (0 bytes) 3059 The plaintext is defined as the empty string: 3061 P_2m (0 bytes) 3062 The Enc_structure is defined as follows: [ "Encrypt0", 3063 << ID_CRED_R >>, << TH_2, CRED_R >> ], indicating that ID_CRED_R is 3064 encoded as a CBOR byte string, and that the concatenation of the CBOR 3065 byte strings TH_2 and CRED_R is wrapped as a CBOR bstr. The CBOR 3066 diagnostic notation is the following: 3068 A_2m = 3069 [ 3070 "Encrypt0", 3071 h'A11822822E486844078A53F312F5', 3072 h'5820864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF 3073 5864C788370016B8965BDB2074BFF82E5A20E09BEC21F8406E86442B87EC3FF245B70A 3074 47624DC9CDC6824B2A4C52E95EC9D6B0534B71C2B49E4BF9031500CEE6869979C297BB 3075 5A8B381E98DB714108415E5C50DB78974C271579B01633A3EF6271BE5C225EB2' 3076 ] 3078 Which encodes to the following byte string to be used as Additional 3079 Authenticated Data: 3081 A_2m (CBOR-encoded) (163 bytes) 3082 83 68 45 6e 63 72 79 70 74 30 4e a1 18 22 82 2e 48 68 44 07 8a 53 f3 12 3083 f5 58 88 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 3084 72 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 58 64 c7 88 37 00 16 b8 96 5b db 3085 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 6e 86 44 2b 87 ec 3f f2 45 b7 0a 3086 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e c9 d6 b0 53 4b 71 c2 b4 9e 4b f9 3087 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 38 1e 98 db 71 41 08 41 5e 5c 50 3088 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 71 be 5c 22 5e b2 3090 info for K_2m is defined as follows in CBOR diagnostic notation: 3092 info for K_2m = 3093 [ 3094 10, 3095 h'864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF', 3096 "K_2m", 3097 16 3098 ] 3100 Which as a CBOR encoded data item is: 3102 info for K_2m (CBOR-encoded) (42 bytes) 3103 84 0a 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 3104 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 64 4b 5f 32 6d 10 3106 From these parameters, K_2m is computed. Key K_2m is the output of 3107 HKDF-Expand(PRK_3e2m, info, L), where L is the length of K_2m, so 16 3108 bytes. 3110 K_2m (16 bytes) 3111 80 cc a7 49 ab 58 f5 69 ca 35 da ee 05 be d1 94 3113 info for IV_2m is defined as follows, in CBOR diagnostic notation (10 3114 is the COSE algorithm no. of the AEAD algorithm in the selected 3115 cipher suite 0): 3117 info for IV_2m = 3118 [ 3119 10, 3120 h'864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF', 3121 "IV_2m", 3122 13 3123 ] 3125 Which as a CBOR encoded data item is: 3127 info for IV_2m (CBOR-encoded) (43 bytes) 3128 84 0a 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 3129 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 65 49 56 5f 32 6d 0d 3131 From these parameters, IV_2m is computed. IV_2m is the output of 3132 HKDF-Expand(PRK_3e2m, info, L), where L is the length of IV_2m, so 13 3133 bytes. 3135 IV_2m (13 bytes) 3136 c8 1e 1a 95 cc 93 b3 36 69 6e d5 02 55 3138 Finally, COSE_Encrypt0 is computed from the parameters above. 3140 * protected header = CBOR-encoded ID_CRED_R 3142 * external_aad = A_2m 3144 * empty plaintext = P_2m 3146 MAC_2 (CBOR unencoded) (8 bytes) 3147 fa bb a4 7e 56 71 a1 82 3149 To compute the Signature_or_MAC_2, the key is the private 3150 authentication key of the Responder and the message M_2 to be signed 3151 = [ "Signature1", << ID_CRED_R >>, << TH_2, CRED_R, ? EAD_2 >>, MAC_2 3152 ]. ID_CRED_R is encoded as a CBOR byte string, the concatenation of 3153 the CBOR byte strings TH_2 and CRED_R is wrapped as a CBOR bstr, and 3154 MAC_2 is encoded as a CBOR bstr. 3156 M_2 = 3157 [ 3158 "Signature1", 3159 h'A11822822E486844078A53F312F5', 3160 h'5820864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629F 3161 F5864C788370016B8965BDB2074BFF82E5A20E09BEC21F8406E86442B87EC3FF245B7 3162 0A47624DC9CDC6824B2A4C52E95EC9D6B0534B71C2B49E4BF9031500CEE6869979C29 3163 7BB5A8B381E98DB714108415E5C50DB78974C271579B01633A3EF6271BE5C225EB2', 3164 h'FABBA47E5671A182' 3165 ] 3167 Which as a CBOR encoded data item is: 3169 M_2 (174 bytes) 3170 84 6a 53 69 67 6e 61 74 75 72 65 31 4e a1 18 22 82 2e 48 68 44 07 8a 53 3171 f3 12 f5 58 88 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a 3172 ce 99 72 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 58 64 c7 88 37 00 16 b8 96 3173 5b db 20 74 bf f8 2e 5a 20 e0 9b ec 21 f8 40 6e 86 44 2b 87 ec 3f f2 45 3174 b7 0a 47 62 4d c9 cd c6 82 4b 2a 4c 52 e9 5e c9 d6 b0 53 4b 71 c2 b4 9e 3175 4b f9 03 15 00 ce e6 86 99 79 c2 97 bb 5a 8b 38 1e 98 db 71 41 08 41 5e 3176 5c 50 db 78 97 4c 27 15 79 b0 16 33 a3 ef 62 71 be 5c 22 5e b2 48 fa bb 3177 a4 7e 56 71 a1 82 3179 Since the method = 0, Signature_or_MAC_2 is a signature. The 3180 algorithm with selected cipher suite 0 is Ed25519 and the output is 3181 64 bytes. 3183 Signature_or_MAC_2 (CBOR unencoded) (64 bytes) 3184 1f 17 00 6a 98 48 c9 77 cb bd ca a7 57 b6 fd 46 82 c8 17 39 e1 5c 99 37 3185 c2 1c f5 e9 a0 e6 03 9f 54 fd 2a 6c 3a 11 18 f2 b9 d8 eb cd 48 23 48 b9 3186 9c 3e d7 ed 1b d9 80 6c 93 c8 90 68 e8 36 b4 0f 3188 CIPHERTEXT_2 is the ciphertext resulting from XOR between plaintext 3189 and KEYSTREAM_2 which is derived from TH_2 and the pseudorandom key 3190 PRK_2e. 3192 * plaintext = CBOR Sequence of the items ID_CRED_R and 3193 Signature_or_MAC_2 encoded as CBOR byte strings, in this order 3194 (EAD_2 is empty). 3196 The plaintext is the following: 3198 P_2e (CBOR Sequence) (80 bytes) 3199 a1 18 22 82 2e 48 68 44 07 8a 53 f3 12 f5 58 40 1f 17 00 6a 98 48 c9 77 3200 cb bd ca a7 57 b6 fd 46 82 c8 17 39 e1 5c 99 37 c2 1c f5 e9 a0 e6 03 9f 3201 54 fd 2a 6c 3a 11 18 f2 b9 d8 eb cd 48 23 48 b9 9c 3e d7 ed 1b d9 80 6c 3202 93 c8 90 68 e8 36 b4 0f 3203 KEYSTREAM_2 = HKDF-Expand( PRK_2e, info, length ), where length is 3204 the length of the plaintext, so 80. 3206 info for KEYSTREAM_2 = 3207 [ 3208 10, 3209 h'864E32B36A7B5F21F19E99F0C66D911E0ACE9972D376D2C2C153C17F8E9629FF', 3210 "KEYSTREAM_2", 3211 80 3212 ] 3214 Which as a CBOR encoded data item is: 3216 info for KEYSTREAM_2 (CBOR-encoded) (50 bytes) 3217 84 0a 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 3218 d3 76 d2 c2 c1 53 c1 7f 8e 96 29 ff 6b 4b 45 59 53 54 52 45 41 4d 5f 32 3219 18 50 3221 From there, KEYSTREAM_2 is computed: 3223 KEYSTREAM_2 (80 bytes) 3224 ae ea 8e af 50 cf c6 70 09 da e8 2d 8d 85 b0 e7 60 91 bf 0f 07 0b 79 53 3225 6c 83 23 dc 3d 9d 61 13 10 35 94 63 f4 4b 12 4b ea b3 a1 9d 09 93 82 d7 3226 30 80 17 f4 92 62 06 e4 f5 44 9b 9f c9 24 bc b6 bd 78 ec 45 0a 66 83 fb 3227 8a 2f 5f 92 4f c4 40 4f 3229 Using the parameters above, the ciphertext CIPHERTEXT_2 can be 3230 computed: 3232 CIPHERTEXT_2 (CBOR unencoded) (80 bytes) 3233 0f f2 ac 2d 7e 87 ae 34 0e 50 bb de 9f 70 e8 a7 7f 86 bf 65 9f 43 b0 24 3234 a7 3e e9 7b 6a 2b 9c 55 92 fd 83 5a 15 17 8b 7c 28 af 54 74 a9 75 81 48 3235 64 7d 3d 98 a8 73 1e 16 4c 9c 70 52 81 07 f4 0f 21 46 3b a8 11 bf 03 97 3236 19 e7 cf fa a7 f2 f4 40 3238 message_2 is the CBOR Sequence of data_2 and CIPHERTEXT_2, in this 3239 order: 3241 message_2 = 3242 ( 3243 data_2, 3244 h'0FF2AC2D7E87AE340E50BBDE9F70E8A77F86BF659F43B024A73EE97B6A2B9C5592FD 3245 835A15178B7C28AF5474A9758148647D3D98A8731E164C9C70528107F40F21463BA811 3246 BF039719E7CFFAA7F2F440' 3247 ) 3249 Which as a CBOR encoded data item is: 3251 message_2 (CBOR Sequence) (117 bytes) 3252 58 20 71 a3 d5 99 c2 1d a1 89 02 a1 ae a8 10 b2 b6 38 2c cd 8d 5f 9b f0 3253 19 52 81 75 4c 5e bc af 30 1e 37 58 50 0f f2 ac 2d 7e 87 ae 34 0e 50 bb 3254 de 9f 70 e8 a7 7f 86 bf 65 9f 43 b0 24 a7 3e e9 7b 6a 2b 9c 55 92 fd 83 3255 5a 15 17 8b 7c 28 af 54 74 a9 75 81 48 64 7d 3d 98 a8 73 1e 16 4c 9c 70 3256 52 81 07 f4 0f 21 46 3b a8 11 bf 03 97 19 e7 cf fa a7 f2 f4 40 3258 C.1.3. Message_3 3260 Since corr equals 1, C_R is not omitted from data_3. 3262 The Initiator's sign/verify key pair is the following: 3264 SK_I (Initiator's private authentication key) (32 bytes) 3265 2f fc e7 a0 b2 b8 25 d3 97 d0 cb 54 f7 46 e3 da 3f 27 59 6e e0 6b 53 71 3266 48 1d c0 e0 12 bc 34 d7 3268 PK_I (Responder's public authentication key) (32 bytes) 3269 38 e5 d5 45 63 c2 b6 a4 ba 26 f3 01 5f 61 bb 70 6e 5c 2e fd b5 56 d2 e1 3270 69 0b 97 fc 3c 6d e1 49 3272 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 3274 PRK_4x3m = HMAC-SHA-256 (PRK_3e2m, G_IY) 3276 PRK_4x3m (32 bytes) 3277 ec 62 92 a0 67 f1 37 fc 7f 59 62 9d 22 6f bf c4 e0 68 89 49 f6 62 a9 7f 3278 d8 2f be b7 99 71 39 4a 3280 data 3 is equal to C_R. 3282 data_3 (CBOR Sequence) (1 byte) 3283 37 3285 From data_3, CIPHERTEXT_2, and TH_2, compute the input to the 3286 transcript hash TH_3 = H( H(TH_2 , CIPHERTEXT_2), data_3), as a CBOR 3287 Sequence of 2 data items. 3289 Input to calculate TH_3 (CBOR Sequence) (117 bytes) 3290 58 20 86 4e 32 b3 6a 7b 5f 21 f1 9e 99 f0 c6 6d 91 1e 0a ce 99 72 d3 76 3291 d2 c2 c1 53 c1 7f 8e 96 29 ff 58 50 0f f2 ac 2d 7e 87 ae 34 0e 50 bb de 3292 9f 70 e8 a7 7f 86 bf 65 9f 43 b0 24 a7 3e e9 7b 6a 2b 9c 55 92 fd 83 5a 3293 15 17 8b 7c 28 af 54 74 a9 75 81 48 64 7d 3d 98 a8 73 1e 16 4c 9c 70 52 3294 81 07 f4 0f 21 46 3b a8 11 bf 03 97 19 e7 cf fa a7 f2 f4 40 37 3296 And from there, compute the transcript hash TH_3 = SHA-256( H(TH_2 , 3297 CIPHERTEXT_2), data_3) 3299 TH_3 (CBOR unencoded) (32 bytes) 3300 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 65 0c 30 70 3301 b6 f5 1e 68 e2 ae bb 60 3303 The Initiator's subject name is the empty string: 3305 Initiator's subject name (text string) 3306 "" 3308 In this version of the test vectors CRED_I is not a DER encoded X.509 3309 certificate, but a string of random bytes. 3311 CRED_I (CBOR unencoded) (101 bytes) 3312 54 13 20 4c 3e bc 34 28 a6 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 7e c6 3313 56 1e 52 43 3a a5 5e 71 f1 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 76 60 3314 88 09 84 49 cb 84 8f fc 79 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 67 5e 3315 8f 6c 77 a4 a2 c3 01 95 60 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 48 65 3316 02 ff 7b dd a6 3318 CRED_I is defined to be the CBOR bstr containing the credential of 3319 the Initiator. 3321 CRED_I (103 bytes) 3322 58 65 54 13 20 4c 3e bc 34 28 a6 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 3323 7e c6 56 1e 52 43 3a a5 5e 71 f1 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 3324 76 60 88 09 84 49 cb 84 8f fc 79 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 3325 67 5e 8f 6c 77 a4 a2 c3 01 95 60 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 3326 48 65 02 ff 7b dd a6 3328 And because certificates are identified by a hash value with the 3329 'x5t' parameter, ID_CRED_I is the following: 3331 ID_CRED_I = { 34 : COSE_CertHash }. In this example, the hash 3332 algorithm used is SHA-2 256-bit with hash truncated to 64-bits (value 3333 -15). The hash value is calculated over the CBOR unencoded CRED_I. 3335 ID_CRED_I = 3336 { 3337 34: [-15, h'705D5845F36FC6A6'] 3338 } 3340 which when encoded as a CBOR map becomes: 3342 ID_CRED_I (14 bytes) 3343 a1 18 22 82 2e 48 70 5d 58 45 f3 6f c6 a6 3345 Since no external authorization data is exchanged: 3347 EAD_3 (0 bytes) 3349 The plaintext of the COSE_Encrypt is the empty string: 3351 P_3m (0 bytes) 3353 The associated data is the following: [ "Encrypt0", << ID_CRED_I >>, 3354 << TH_3, CRED_I, ? EAD_3 >> ]. 3356 A_3m (CBOR-encoded) (164 bytes) 3357 83 68 45 6e 63 72 79 70 74 30 4e a1 18 22 82 2e 48 70 5d 58 45 f3 6f c6 3358 a6 58 89 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 3359 0f 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 58 65 54 13 20 4c 3e bc 34 28 a6 3360 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 7e c6 56 1e 52 43 3a a5 5e 71 f1 3361 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 76 60 88 09 84 49 cb 84 8f fc 79 3362 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 67 5e 8f 6c 77 a4 a2 c3 01 95 60 3363 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 48 65 02 ff 7b dd a6 3365 Info for K_3m is computed as follows: 3367 info for K_3m = 3368 [ 3369 10, 3370 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3371 "K_3m", 3372 16 3373 ] 3375 Which as a CBOR encoded data item is: 3377 info for K_3m (CBOR-encoded) (42 bytes) 3378 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3379 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 64 4b 5f 33 6d 10 3381 From these parameters, K_3m is computed. Key K_3m is the output of 3382 HKDF-Expand(PRK_4x3m, info, L), where L is the length of K_2m, so 16 3383 bytes. 3385 K_3m (16 bytes) 3386 83 a9 c3 88 02 91 2e 7f 8f 0d 2b 84 14 d1 e5 2c 3388 Nonce IV_3m is the output of HKDF-Expand(PRK_4x3m, info, L), where L 3389 = 13 bytes. 3391 Info for IV_3m is defined as follows: 3393 info for IV_3m = 3394 [ 3395 10, 3396 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3397 "IV_3m", 3398 13 3399 ] 3401 Which as a CBOR encoded data item is: 3403 info for IV_3m (CBOR-encoded) (43 bytes) 3404 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3405 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 65 49 56 5f 33 6d 0d 3407 From these parameters, IV_3m is computed: 3409 IV_3m (13 bytes) 3410 9c 83 9c 0e e8 36 42 50 5a 8e 1c 9f b2 3412 MAC_3 is the 'ciphertext' of the COSE_Encrypt0: 3414 MAC_3 (CBOR unencoded) (8 bytes) 3415 2f a1 e3 9e ae 7d 5f 8d 3417 Since the method = 0, Signature_or_MAC_3 is a signature. The 3418 algorithm with selected cipher suite 0 is Ed25519. 3420 * The message M_3 to be signed = [ "Signature1", << ID_CRED_I >>, 3421 << TH_3, CRED_I >>, MAC_3 ], i.e. ID_CRED_I encoded as CBOR bstr, 3422 the concatenation of the CBOR byte strings TH_3 and CRED_I wrapped 3423 as a CBOR bstr, and MAC_3 encoded as a CBOR bstr. 3425 * The signing key is the private authentication key of the 3426 Initiator. 3428 M_3 = 3429 [ 3430 "Signature1", 3431 h'A11822822E48705D5845F36FC6A6', 3432 h'5820F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB6 3433 058655413204C3EBC3428A6CF57E24C9DEF59651770449BCE7EC6561E52433AA55E71 3434 F1FA34B22A9CA4A1E12924EAE1D1766088098449CB848FFC795F88AFC49CBE8AFDD1B 3435 A009F21675E8F6C77A4A2C30195601F6F0A0852978BD43D28207D44486502FF7BDD 3436 A6', 3437 h'2FA1E39EAE7D5F8D'] 3439 Which as a CBOR encoded data item is: 3441 M_3 (175 bytes) 3442 84 6a 53 69 67 6e 61 74 75 72 65 31 4e a1 18 22 82 2e 48 70 5d 58 45 f3 3443 6f c6 a6 58 89 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 3444 9c 7c 0f 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 58 65 54 13 20 4c 3e bc 34 3445 28 a6 cf 57 e2 4c 9d ef 59 65 17 70 44 9b ce 7e c6 56 1e 52 43 3a a5 5e 3446 71 f1 fa 34 b2 2a 9c a4 a1 e1 29 24 ea e1 d1 76 60 88 09 84 49 cb 84 8f 3447 fc 79 5f 88 af c4 9c be 8a fd d1 ba 00 9f 21 67 5e 8f 6c 77 a4 a2 c3 01 3448 95 60 1f 6f 0a 08 52 97 8b d4 3d 28 20 7d 44 48 65 02 ff 7b dd a6 48 2f 3449 a1 e3 9e ae 7d 5f 8d 3451 From there, the 64 byte signature can be computed: 3453 Signature_or_MAC_3 (CBOR unencoded) (64 bytes) 3454 ab 9f 7b bd eb c4 eb f8 a3 d3 04 17 9b cc a3 9d 9c 8a 76 73 65 76 fb 3c 3455 32 d2 fa c7 e2 59 34 e5 33 dc c7 02 2e 4d 68 61 c8 f5 fe cb e9 2d 17 4e 3456 b2 be af 0a 59 a4 15 84 37 2f 43 2e 6b f4 7b 04 3458 Finally, the outer COSE_Encrypt0 is computed. 3460 The plaintext is the CBOR Sequence of the items ID_CRED_I and the 3461 CBOR encoded Signature_or_MAC_3, in this order (EAD_3 is empty). 3463 P_3ae (CBOR Sequence) (80 bytes) 3464 a1 18 22 82 2e 48 70 5d 58 45 f3 6f c6 a6 58 40 ab 9f 7b bd eb c4 eb f8 3465 a3 d3 04 17 9b cc a3 9d 9c 8a 76 73 65 76 fb 3c 32 d2 fa c7 e2 59 34 e5 3466 33 dc c7 02 2e 4d 68 61 c8 f5 fe cb e9 2d 17 4e b2 be af 0a 59 a4 15 84 3467 37 2f 43 2e 6b f4 7b 04 3469 The Associated data A is the following: Associated data A = [ 3470 "Encrypt0", h'', TH_3 ] 3472 A_3ae (CBOR-encoded) (45 bytes) 3473 83 68 45 6e 63 72 79 70 74 30 40 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 3474 29 c1 52 ab 3a ea 9c 7c 0f 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 3476 Key K_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 3478 info is defined as follows: 3480 info for K_3ae = 3481 [ 3482 10, 3483 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3484 "K_3ae", 3485 16 3486 ] 3488 Which as a CBOR encoded data item is: 3490 info for K_3ae (CBOR-encoded) (43 bytes) 3491 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3492 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 65 4b 5f 33 61 65 10 3494 L is the length of K_3ae, so 16 bytes. 3496 From these parameters, K_3ae is computed: 3498 K_3ae (16 bytes) 3499 b8 79 9f e3 d1 50 4f d8 eb 22 c4 72 62 cd bb 05 3501 Nonce IV_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 3503 info is defined as follows: 3505 info for IV_3ae = 3506 [ 3507 10, 3508 h'F24D18CAFCE374D4E3736329C152AB3AEA9C7C0F650C3070B6F51E68E2AEBB60', 3509 "IV_3ae", 3510 13 3511 ] 3513 Which as a CBOR encoded data item is: 3515 info for IV_3ae (CBOR-encoded) (44 bytes) 3516 84 0a 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 3517 65 0c 30 70 b6 f5 1e 68 e2 ae bb 60 66 49 56 5f 33 61 65 0d 3519 L is the length of IV_3ae, so 13 bytes. 3521 From these parameters, IV_3ae is computed: 3523 IV_3ae (13 bytes) 3524 74 c7 de 41 b8 4a 5b b7 19 0a 85 98 dc 3526 Using the parameters above, the 'ciphertext' CIPHERTEXT_3 can be 3527 computed: 3529 CIPHERTEXT_3 (CBOR unencoded) (88 bytes) 3530 f5 f6 de bd 82 14 05 1c d5 83 c8 40 96 c4 80 1d eb f3 5b 15 36 3d d1 6e 3531 bd 85 30 df dc fb 34 fc d2 eb 6c ad 1d ac 66 a4 79 fb 38 de aa f1 d3 0a 3532 7e 68 17 a2 2a b0 4f 3d 5b 1e 97 2a 0d 13 ea 86 c6 6b 60 51 4c 96 57 ea 3533 89 c5 7b 04 01 ed c5 aa 8b bc ab 81 3c c5 d6 e7 3535 From the parameter above, message_3 is computed, as the CBOR Sequence 3536 of the following CBOR encoded data items: (C_R, CIPHERTEXT_3). 3538 message_3 = 3539 ( 3540 -24, 3541 h'F5F6DEBD8214051CD583C84096C4801DEBF35B15363DD16EBD8530DFDCFB34FCD2EB 3542 6CAD1DAC66A479FB38DEAAF1D30A7E6817A22AB04F3D5B1E972A0D13EA86C66B60514C 3543 9657EA89C57B0401EDC5AA8BBCAB813CC5D6E7' 3544 ) 3546 Which encodes to the following byte string: 3548 message_3 (CBOR Sequence) (91 bytes) 3549 37 58 58 f5 f6 de bd 82 14 05 1c d5 83 c8 40 96 c4 80 1d eb f3 5b 15 36 3550 3d d1 6e bd 85 30 df dc fb 34 fc d2 eb 6c ad 1d ac 66 a4 79 fb 38 de aa 3551 f1 d3 0a 7e 68 17 a2 2a b0 4f 3d 5b 1e 97 2a 0d 13 ea 86 c6 6b 60 51 4c 3552 96 57 ea 89 c5 7b 04 01 ed c5 aa 8b bc ab 81 3c c5 d6 e7 3554 C.1.4. OSCORE Security Context Derivation 3556 From here, the Initiator and the Responder can derive an OSCORE 3557 Security Context, using the EDHOC-Exporter interface. 3559 From TH_3 and CIPHERTEXT_3, compute the input to the transcript hash 3560 TH_4 = H( TH_3, CIPHERTEXT_3 ), as a CBOR Sequence of these 2 data 3561 items. 3563 Input to calculate TH_4 (CBOR Sequence) (124 bytes) 3564 58 20 f2 4d 18 ca fc e3 74 d4 e3 73 63 29 c1 52 ab 3a ea 9c 7c 0f 65 0c 3565 30 70 b6 f5 1e 68 e2 ae bb 60 58 58 f5 f6 de bd 82 14 05 1c d5 83 c8 40 3566 96 c4 80 1d eb f3 5b 15 36 3d d1 6e bd 85 30 df dc fb 34 fc d2 eb 6c ad 3567 1d ac 66 a4 79 fb 38 de aa f1 d3 0a 7e 68 17 a2 2a b0 4f 3d 5b 1e 97 2a 3568 0d 13 ea 86 c6 6b 60 51 4c 96 57 ea 89 c5 7b 04 01 ed c5 aa 8b bc ab 81 3569 3c c5 d6 e7 3571 And from there, compute the transcript hash TH_4 = SHA-256(TH_3 , 3572 CIPHERTEXT_4) 3574 TH_4 (CBOR unencoded) (32 bytes) 3575 3b 69 a6 7f ec 7e 73 6c c1 a9 52 6c da 00 02 d4 09 f5 b9 ea 0a 2b e9 60 3576 51 a6 e3 0d 93 05 fd 51 3578 The Master Secret and Master Salt are derived as follows: 3580 Master Secret = EDHOC-Exporter( "OSCORE Master Secret", 16 ) = EDHOC- 3581 KDF(PRK_4x3m, TH_4, "OSCORE Master Secret", 16) = HKDF-Expand( 3582 PRK_4x3m, info_ms, 16 ) 3583 Master Salt = EDHOC-Exporter( "OSCORE Master Salt", 8 ) = EDHOC- 3584 KDF(PRK_4x3m, TH_4, "OSCORE Master Salt", 8) = HKDF-Expand( PRK_4x3m, 3585 info_salt, 8 ) 3587 info_ms for OSCORE Master Secret is defined as follows: 3589 info_ms = [ 3590 10, 3591 h'3B69A67FEC7E736CC1A9526CDA0002D409F5B9EA0A2BE96051A6E30D9305FD51', 3592 "OSCORE Master Secret", 3593 16 3594 ] 3596 Which as a CBOR encoded data item is: 3598 info_ms for OSCORE Master Secret (CBOR-encoded) (58 bytes) 3599 84 0a 58 20 3b 69 a6 7f ec 7e 73 6c c1 a9 52 6c da 00 02 d4 09 f5 b9 ea 3600 0a 2b e9 60 51 a6 e3 0d 93 05 fd 51 74 4f 53 43 4f 52 45 20 4d 61 73 74 3601 65 72 20 53 65 63 72 65 74 10 3603 info_salt for OSCORE Master Salt is defined as follows: 3605 info_salt = [ 3606 10, 3607 h'3B69A67FEC7E736CC1A9526CDA0002D409F5B9EA0A2BE96051A6E30D9305FD51', 3608 "OSCORE Master Salt", 3609 8 3610 ] 3612 Which as a CBOR encoded data item is: 3614 info for OSCORE Master Salt (CBOR-encoded) (56 Bytes) 3615 84 0a 58 20 3b 69 a6 7f ec 7e 73 6c c1 a9 52 6c da 00 02 d4 09 f5 b9 ea 3616 0a 2b e9 60 51 a6 e3 0d 93 05 fd 51 72 4f 53 43 4f 52 45 20 4d 61 73 74 3617 65 72 20 53 61 6c 74 08 3619 From these parameters, OSCORE Master Secret and OSCORE Master Salt 3620 are computed: 3622 OSCORE Master Secret (16 bytes) 3623 96 aa 88 ce 86 5e ba 1f fa f3 89 64 13 2c c4 42 3625 OSCORE Master Salt (8 bytes) 3626 5e c3 ee 41 7c fb ba e9 3628 The client's OSCORE Sender ID is C_R and the server's OSCORE Sender 3629 ID is C_I. 3631 Client's OSCORE Sender ID (1 byte) 3632 00 3634 Server's OSCORE Sender ID (1 byte) 3635 09 3637 The AEAD Algorithm and the hash algorithm are the application AEAD 3638 and hash algorithms in the selected cipher suite. 3640 OSCORE AEAD Algorithm (int) 3641 10 3643 OSCORE Hash Algorithm (int) 3644 -16 3646 C.2. Test Vectors for EDHOC Authenticated with Static Diffie-Hellman 3647 Keys 3649 EDHOC with static Diffie-Hellman keys and raw public keys is used. 3650 In this test vector, a key identifier is used to identify the raw 3651 public key. The optional C_1 in message_1 is omitted. No external 3652 authorization data is sent in the message exchange. 3654 method (Static DH Based Authentication) 3655 3 3657 CoAP is used as transport and the Initiator acts as CoAP client: 3659 corr (the Initiator can correlate message_1 and message_2) 3660 1 3662 From there, METHOD_CORR has the following value: 3664 METHOD_CORR (4 * method + corr) (int) 3665 13 3667 The Initiator indicates only one cipher suite in the (potentially 3668 truncated) list of cipher suites. 3670 Supported Cipher Suites (1 byte) 3671 00 3673 The Initiator selected the indicated cipher suite. 3675 Selected Cipher Suite (int) 3676 0 3677 Cipher suite 0 is supported by both the Initiator and the Responder, 3678 see Section 3.4. 3680 C.2.1. Message_1 3682 The Initiator generates its ephemeral key pair. 3684 X (Initiator's ephemeral private key) (32 bytes) 3685 ae 11 a0 db 86 3c 02 27 e5 39 92 fe b8 f5 92 4c 50 d0 a7 ba 6e ea b4 ad 3686 1f f2 45 72 f4 f5 7c fa 3688 G_X (Initiator's ephemeral public key, CBOR unencoded) (32 bytes) 3689 8d 3e f5 6d 1b 75 0a 43 51 d6 8a c2 50 a0 e8 83 79 0e fc 80 a5 38 a4 44 3690 ee 9e 2b 57 e2 44 1a 7c 3692 The Initiator chooses a connection identifier C_I: 3694 Connection identifier chosen by Initiator (1 byte) 3695 16 3697 Note that since C_I is a byte string in the interval h'00' to h'2f', 3698 it is encoded as the corresponding integer - 24 (see bstr_identifier 3699 in Section 5.1), i.e. 0x16 = 22, 22 - 24 = -2, and -2 in CBOR 3700 encoding is equal to 0x21. 3702 C_I (1 byte) 3703 21 3705 Since no external authorization data is sent: 3707 EAD_1 (0 bytes) 3709 Since the list of supported cipher suites needs to contain the 3710 selected cipher suite, the initiator truncates the list of supported 3711 cipher suites to one cipher suite only, 00. 3713 Because one single selected cipher suite is conveyed, it is encoded 3714 as an int instead of an array: 3716 SUITES_I (int) 3717 0 3719 message_1 is constructed as the CBOR Sequence of the data items above 3720 encoded as CBOR. In CBOR diagnostic notation: 3722 message_1 = 3723 ( 3724 13, 3725 0, 3726 h'8D3EF56D1B750A4351D68AC250A0E883790EFC80A538A444EE9E2B57E2441A7C', 3727 -2 3728 ) 3730 Which as a CBOR encoded data item is: 3732 message_1 (CBOR Sequence) (37 bytes) 3733 0d 00 58 20 8d 3e f5 6d 1b 75 0a 43 51 d6 8a c2 50 a0 e8 83 79 0e fc 80 3734 a5 38 a4 44 ee 9e 2b 57 e2 44 1a 7c 21 3736 C.2.2. Message_2 3738 Since METHOD_CORR mod 4 equals 1, C_I is omitted from data_2. 3740 The Responder generates the following ephemeral key pair. 3742 Y (Responder's ephemeral private key) (32 bytes) 3743 c6 46 cd dc 58 12 6e 18 10 5f 01 ce 35 05 6e 5e bc 35 f4 d4 cc 51 07 49 3744 a3 a5 e0 69 c1 16 16 9a 3746 G_Y (Responder's ephemeral public key, CBOR unencoded) (32 bytes) 3747 52 fb a0 bd c8 d9 53 dd 86 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db fc 33 3748 01 04 70 69 45 1b af 35 3750 From G_X and Y or from G_Y and X the ECDH shared secret is computed: 3752 G_XY (ECDH shared secret) (32 bytes) 3753 de fc 2f 35 69 10 9b 3d 1f a4 a7 3d c5 e2 fe b9 e1 15 0d 90 c2 5e e2 f0 3754 66 c2 d8 85 f4 f8 ac 4e 3756 The key and nonce for calculating the 'ciphertext' are calculated as 3757 follows, as specified in Section 4. 3759 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 3761 PRK_2e = HMAC-SHA-256(salt, G_XY) 3763 Salt is the empty byte string. 3765 salt (0 bytes) 3767 From there, PRK_2e is computed: 3769 PRK_2e (32 bytes) 3770 93 9f cb 05 6d 2e 41 4f 1b ec 61 04 61 99 c2 c7 63 d2 7f 0c 3d 15 fa 16 3771 71 fa 13 4e 0d c5 a0 4d 3773 The Responder's static Diffie-Hellman key pair is the following: 3775 R (Responder's private authentication key) (32 bytes) 3776 bb 50 1a ac 67 b9 a9 5f 97 e0 ed ed 6b 82 a6 62 93 4f bb fc 7a d1 b7 4c 3777 1f ca d6 6a 07 94 22 d0 3779 G_R (Responder's public authentication key) (32 bytes) 3780 a3 ff 26 35 95 be b3 77 d1 a0 ce 1d 04 da d2 d4 09 66 ac 6b cb 62 20 51 3781 b8 46 59 18 4d 5d 9a 32 3783 Since the Responder authenticates with a static Diffie-Hellman key, 3784 PRK_3e2m = HKDF-Extract( PRK_2e, G_RX ), where G_RX is the ECDH 3785 shared secret calculated from G_R and X, or G_X and R. 3787 From the Responder's authentication key and the Initiator's ephemeral 3788 key (see Appendix C.2.1), the ECDH shared secret G_RX is calculated. 3790 G_RX (ECDH shared secret) (32 bytes) 3791 21 c7 ef f4 fb 69 fa 4b 67 97 d0 58 84 31 5d 84 11 a3 fd a5 4f 6d ad a6 3792 1d 4f cd 85 e7 90 66 68 3794 PRK_3e2m (32 bytes) 3795 75 07 7c 69 1e 35 01 2d 48 bc 24 c8 4f 2b ab 89 f5 2f ac 03 fe dd 81 3e 3796 43 8c 93 b1 0b 39 93 07 3798 The Responder chooses a connection identifier C_R. 3800 Connection identifier chosen by Responder (1 byte) 3801 00 3803 Note that since C_R is a byte string in the interval h'00' to h'2f', 3804 it is encoded as the corresponding integer - 24 (see bstr_identifier 3805 in Section 5.1), i.e. 0x00 = 0, 0 - 24 = -24, and -24 in CBOR 3806 encoding is equal to 0x37. 3808 C_R (1 byte) 3809 37 3811 Data_2 is constructed as the CBOR Sequence of G_Y and C_R. 3813 data_2 = 3814 ( 3815 h'52FBA0BDC8D953DD86CE1AB2FD7C05A4658C7C30AFDBFC3301047069451BAF35', 3816 -24 3817 ) 3819 Which as a CBOR encoded data item is: 3821 data_2 (CBOR Sequence) (35 bytes) 3822 58 20 52 fb a0 bd c8 d9 53 dd 86 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db 3823 fc 33 01 04 70 69 45 1b af 35 37 3825 From data_2 and message_1, compute the input to the transcript hash 3826 TH_2 = H( H(message_1), data_2 ), as a CBOR Sequence of these 2 data 3827 items. 3829 Input to calculate TH_2 (CBOR Sequence) (72 bytes) 3830 0d 00 58 20 8d 3e f5 6d 1b 75 0a 43 51 d6 8a c2 50 a0 e8 83 79 0e fc 80 3831 a5 38 a4 44 ee 9e 2b 57 e2 44 1a 7c 21 58 20 52 fb a0 bd c8 d9 53 dd 86 3832 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db fc 33 01 04 70 69 45 1b af 35 37 3834 And from there, compute the transcript hash TH_2 = SHA-256( 3835 H(message_1), data_2 ) 3837 TH_2 (CBOR unencoded) (32 bytes) 3838 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 36 d0 cf 8c 3839 73 a6 e8 a7 c3 62 1e 26 3841 The Responder's subject name is the empty string: 3843 Responder's subject name (text string) 3844 "" 3846 ID_CRED_R is the following: 3848 ID_CRED_R = 3849 { 3850 4: h'05' 3851 } 3853 ID_CRED_R (4 bytes) 3854 a1 04 41 05 3856 CRED_R is the following COSE_Key: 3858 { 3859 1: 1, 3860 -1: 4, 3861 -2: h'A3FF263595BEB377D1A0CE1D04DAD2D40966AC6BCB622051B84659184D5D9A32, 3862 "subject name": "" 3863 } 3865 Which encodes to the following byte string: 3867 CRED_R (54 bytes) 3868 a4 01 01 20 04 21 58 20 a3 ff 26 35 95 be b3 77 d1 a0 ce 1d 04 da d2 d4 3869 09 66 ac 6b cb 62 20 51 b8 46 59 18 4d 5d 9a 32 6c 73 75 62 6a 65 63 74 3870 20 6e 61 6d 65 60 3872 Since no external authorization data is sent: 3874 EAD_2 (0 bytes) 3876 The plaintext is defined as the empty string: 3878 P_2m (0 bytes) 3880 The Enc_structure is defined as follows: [ "Encrypt0", 3881 << ID_CRED_R >>, << TH_2, CRED_R >> ], so ID_CRED_R is encoded as a 3882 CBOR bstr, and the concatenation of the CBOR byte strings TH_2 and 3883 CRED_R is wrapped in a CBOR bstr. 3885 A_2m = 3886 [ 3887 "Encrypt0", 3888 h'A1044105', 3889 h'5820DECFD64A3667640A0233B04AA8AA91F68956B8A536D0CF8C73A6E8A7C3621E2 3890 6A401012004215820A3FF263595BEB377D1A0CE1D04DAD2D40966AC6BCB622051B846 3891 59184D5D9A326C7375626A656374206E616D6560' 3892 ] 3894 Which encodes to the following byte string to be used as Additional 3895 Authenticated Data: 3897 A_2m (CBOR-encoded) (105 bytes) 3898 83 68 45 6e 63 72 79 70 74 30 44 a1 04 41 05 58 58 58 20 de cf d6 4a 36 3899 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 36 d0 cf 8c 73 a6 e8 a7 c3 3900 62 1e 26 a4 01 01 20 04 21 58 20 a3 ff 26 35 95 be b3 77 d1 a0 ce 1d 04 3901 da d2 d4 09 66 ac 6b cb 62 20 51 b8 46 59 18 4d 5d 9a 32 6c 73 75 62 6a 3902 65 63 74 20 6e 61 6d 65 60 3904 info for K_2m is defined as follows: 3906 info for K_2m = 3907 [ 3908 10, 3909 h'DECFD64A3667640A0233B04AA8AA91F68956B8A536D0CF8C73A6E8A7C3621E26', 3910 "K_2m", 3911 16 3912 ] 3914 Which as a CBOR encoded data item is: 3916 info for K_2m (CBOR-encoded) (42 bytes) 3917 84 0a 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 3918 36 d0 cf 8c 73 a6 e8 a7 c3 62 1e 26 64 4b 5f 32 6d 10 3920 From these parameters, K_2m is computed. Key K_2m is the output of 3921 HKDF-Expand(PRK_3e2m, info, L), where L is the length of K_2m, so 16 3922 bytes. 3924 K_2m (16 bytes) 3925 4e cd ef ba d8 06 81 8b 62 51 b9 d7 86 78 bc 76 3927 info for IV_2m is defined as follows: 3929 info for IV_2m = 3930 [ 3931 10, 3932 h'A51C76463E8AE58FD3B8DC5EDE1E27143CC92D223EACD9E5FF6E3FAC876658A5', 3933 "IV_2m", 3934 13 3935 ] 3937 Which as a CBOR encoded data item is: 3939 info for IV_2m (CBOR-encoded) (43 bytes) 3940 84 0a 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 3941 36 d0 cf 8c 73 a6 e8 a7 c3 62 1e 26 65 49 56 5f 32 6d 0d 3943 From these parameters, IV_2m is computed. IV_2m is the output of 3944 HKDF-Expand(PRK_3e2m, info, L), where L is the length of IV_2m, so 13 3945 bytes. 3947 IV_2m (13 bytes) 3948 e9 b8 e4 b1 bd 02 f4 9a 82 0d d3 53 4f 3950 Finally, COSE_Encrypt0 is computed from the parameters above. 3952 * protected header = CBOR-encoded ID_CRED_R 3953 * external_aad = A_2m 3955 * empty plaintext = P_2m 3957 MAC_2 is the 'ciphertext' of the COSE_Encrypt0 with empty plaintext. 3958 In case of cipher suite 0 the AEAD is AES-CCM truncated to 8 bytes: 3960 MAC_2 (CBOR unencoded) (8 bytes) 3961 42 e7 99 78 43 1e 6b 8f 3963 Since method = 2, Signature_or_MAC_2 is MAC_2: 3965 Signature_or_MAC_2 (CBOR unencoded) (8 bytes) 3966 42 e7 99 78 43 1e 6b 8f 3968 CIPHERTEXT_2 is the ciphertext resulting from XOR between plaintext 3969 and KEYSTREAM_2 which is derived from TH_2 and the pseudorandom key 3970 PRK_2e. 3972 The plaintext is the CBOR Sequence of the items ID_CRED_R and the 3973 CBOR encoded Signature_or_MAC_2, in this order (EAD_2 is empty). 3975 Note that since ID_CRED_R contains a single 'kid' parameter, i.e., 3976 ID_CRED_R = { 4 : kid_R }, only the byte string kid_R is conveyed in 3977 the plaintext encoded as a bstr_identifier. kid_R is encoded as the 3978 corresponding integer - 24 (see bstr_identifier in Section 5.1), i.e. 3979 0x05 = 5, 5 - 24 = -19, and -19 in CBOR encoding is equal to 0x32. 3981 The plaintext is the following: 3983 P_2e (CBOR Sequence) (10 bytes) 3984 32 48 42 e7 99 78 43 1e 6b 8f 3986 KEYSTREAM_2 = HKDF-Expand( PRK_2e, info, length ), where length is 3987 the length of the plaintext, so 10. 3989 info for KEYSTREAM_2 = 3990 [ 3991 10, 3992 h'DECFD64A3667640A0233B04AA8AA91F68956B8A536D0CF8C73A6E8A7C3621E26', 3993 "KEYSTREAM_2", 3994 10 3995 ] 3997 Which as a CBOR encoded data item is: 3999 info for KEYSTREAM_2 (CBOR-encoded) (49 bytes) 4000 84 0a 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 4001 36 d0 cf 8c 73 a6 e8 a7 c3 62 1e 26 6b 4b 45 59 53 54 52 45 41 4d 5f 32 4002 0a 4004 From there, KEYSTREAM_2 is computed: 4006 KEYSTREAM_2 (10 bytes) 4007 91 b9 ff ba 9b f5 5a d1 57 16 4009 Using the parameters above, the ciphertext CIPHERTEXT_2 can be 4010 computed: 4012 CIPHERTEXT_2 (CBOR unencoded) (10 bytes) 4013 a3 f1 bd 5d 02 8d 19 cf 3c 99 4015 message_2 is the CBOR Sequence of data_2 and CIPHERTEXT_2, in this 4016 order: 4018 message_2 = 4019 ( 4020 data_2, 4021 h'A3F1BD5D028D19CF3C99' 4022 ) 4024 Which as a CBOR encoded data item is: 4026 message_2 (CBOR Sequence) (46 bytes) 4027 58 20 52 fb a0 bd c8 d9 53 dd 86 ce 1a b2 fd 7c 05 a4 65 8c 7c 30 af db 4028 fc 33 01 04 70 69 45 1b af 35 37 4a a3 f1 bd 5d 02 8d 19 cf 3c 99 4030 C.2.3. Message_3 4032 Since corr equals 1, C_R is not omitted from data_3. 4034 The Initiator's static Diffie-Hellman key pair is the following: 4036 I (Initiator's private authentication key) (32 bytes) 4037 2b be a6 55 c2 33 71 c3 29 cf bd 3b 1f 02 c6 c0 62 03 38 37 b8 b5 90 99 4038 a4 43 6f 66 60 81 b0 8e 4040 G_I (Initiator's public authentication key, CBOR unencoded) (32 bytes) 4041 2c 44 0c c1 21 f8 d7 f2 4c 3b 0e 41 ae da fe 9c aa 4f 4e 7a bb 83 5e c3 4042 0f 1d e8 8a db 96 ff 71 4044 HKDF SHA-256 is the HKDF used (as defined by cipher suite 0). 4046 From the Initiator's authentication key and the Responder's ephemeral 4047 key (see Appendix C.2.2), the ECDH shared secret G_IY is calculated. 4049 G_IY (ECDH shared secret) (32 bytes) 4050 cb ff 8c d3 4a 81 df ec 4c b6 5d 9a 57 2e bd 09 64 45 0c 78 56 3d a4 98 4051 1d 80 d3 6c 8b 1a 75 2a 4053 PRK_4x3m = HMAC-SHA-256 (PRK_3e2m, G_IY). 4055 PRK_4x3m (32 bytes) 4056 02 56 2f 1f 01 78 5c 0a a5 f5 94 64 0c 49 cb f6 9f 72 2e 9e 6c 57 83 7d 4057 8e 15 79 ec 45 fe 64 7a 4059 data 3 is equal to C_R. 4061 data_3 (CBOR Sequence) (1 byte) 4062 37 4064 From data_3, CIPHERTEXT_2, and TH_2, compute the input to the 4065 transcript hash TH_3 = H( H(TH_2 , CIPHERTEXT_2), data_3), as a CBOR 4066 Sequence of these 2 data items. 4068 Input to calculate TH_3 (CBOR Sequence) (46 bytes) 4069 58 20 de cf d6 4a 36 67 64 0a 02 33 b0 4a a8 aa 91 f6 89 56 b8 a5 36 d0 4070 cf 8c 73 a6 e8 a7 c3 62 1e 26 4a a3 f1 bd 5d 02 8d 19 cf 3c 99 37 4072 And from there, compute the transcript hash TH_3 = SHA-256( H(TH_2 , 4073 CIPHERTEXT_2), data_3) 4075 TH_3 (CBOR unencoded) (32 bytes) 4076 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 d7 cb 8b 84 4077 db 03 ff a5 83 a3 5f cb 4079 The initiator's subject name is the empty string: 4081 Initiator's subject name (text string) 4082 "" 4084 And its credential is: 4086 ID_CRED_I = 4087 { 4088 4: h'23' 4089 } 4091 ID_CRED_I (4 bytes) 4092 a1 04 41 23 4093 CRED_I is the following COSE_Key: 4095 { 4096 1: 1, 4097 -1: 4, 4098 -2: h'2C440CC121F8D7F24C3B0E41AEDAFE9CAA4F4E7ABB835EC30F1DE88ADB96FF71', 4099 "subject name": "" 4100 } 4102 Which encodes to the following byte string: 4104 CRED_I (54 bytes) 4105 a4 01 01 20 04 21 58 20 2c 44 0c c1 21 f8 d7 f2 4c 3b 0e 41 ae da fe 9c 4106 aa 4f 4e 7a bb 83 5e c3 0f 1d e8 8a db 96 ff 71 6c 73 75 62 6a 65 63 74 4107 20 6e 61 6d 65 60 4109 Since no external authorization data is exchanged: 4111 EAD_3 (0 bytes) 4113 The plaintext of the COSE_Encrypt is the empty string: 4115 P_3m (0 bytes) 4117 The associated data is the following: [ "Encrypt0", << ID_CRED_I >>, 4118 << TH_3, CRED_I, ? EAD_3 >> ]. 4120 A_3m (CBOR-encoded) (105 bytes) 4121 83 68 45 6e 63 72 79 70 74 30 44 a1 04 41 23 58 58 58 20 b6 cd 80 4f c4 4122 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 d7 cb 8b 84 db 03 ff a5 83 4123 a3 5f cb a4 01 01 20 04 21 58 20 2c 44 0c c1 21 f8 d7 f2 4c 3b 0e 41 ae 4124 da fe 9c aa 4f 4e 7a bb 83 5e c3 0f 1d e8 8a db 96 ff 71 6c 73 75 62 6a 4125 65 63 74 20 6e 61 6d 65 60 4127 Info for K_3m is computed as follows: 4129 info for K_3m = 4130 [ 4131 10, 4132 h'B6CD804FC4B9D7CAC502ABD77CDA74E41CB01182D7CB8B84DB03FFA583A35FCB', 4133 "K_3m", 4134 16 4135 ] 4137 Which as a CBOR encoded data item is: 4139 info for K_3m (CBOR-encoded) (42 bytes) 4140 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 4141 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 64 4b 5f 33 6d 10 4143 From these parameters, K_3m is computed. Key K_3m is the output of 4144 HKDF-Expand(PRK_4x3m, info, L), where L is the length of K_2m, so 16 4145 bytes. 4147 K_3m (16 bytes) 4148 02 c7 e7 93 89 9d 90 d1 28 28 10 26 96 94 c9 58 4150 Nonce IV_3m is the output of HKDF-Expand(PRK_4x3m, info, L), where L 4151 = 13 bytes. 4153 Info for IV_3m is defined as follows: 4155 info for IV_3m = 4156 [ 4157 10, 4158 h'B6CD804FC4B9D7CAC502ABD77CDA74E41CB01182D7CB8B84DB03FFA583A35FCB', 4159 "IV_3m", 4160 13 4161 ] 4163 Which as a CBOR encoded data item is: 4165 info for IV_3m (CBOR-encoded) (43 bytes) 4166 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 4167 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 65 49 56 5f 33 6d 0d 4169 From these parameters, IV_3m is computed: 4171 IV_3m (13 bytes) 4172 0d a7 cc 3a 6f 9a b2 48 52 ce 8b 37 a6 4174 MAC_3 is the 'ciphertext' of the COSE_Encrypt0 with empty plaintext. 4175 In case of cipher suite 0 the AEAD is AES-CCM truncated to 8 bytes: 4177 MAC_3 (CBOR unencoded) (8 bytes) 4178 ee 59 8e a6 61 17 dc c3 4180 Since method = 3, Signature_or_MAC_3 is MAC_3: 4182 Signature_or_MAC_3 (CBOR unencoded) (8 bytes) 4183 ee 59 8e a6 61 17 dc c3 4185 Finally, the outer COSE_Encrypt0 is computed. 4187 The plaintext is the CBOR Sequence of the items ID_CRED_I and the 4188 CBOR encoded Signature_or_MAC_3, in this order (EAD_3 is empty). 4190 Note that since ID_CRED_I contains a single 'kid' parameter, i.e., 4191 ID_CRED_I = { 4 : kid_I }, only the byte string kid_I is conveyed in 4192 the plaintext encoded as a bstr_identifier. kid_I is encoded as the 4193 corresponding integer - 24 (see bstr_identifier in Section 5.1), i.e. 4194 0x23 = 35, 35 - 24 = 11, and 11 in CBOR encoding is equal to 0x0b. 4196 P_3ae (CBOR Sequence) (10 bytes) 4197 0b 48 ee 59 8e a6 61 17 dc c3 4199 The Associated data A is the following: Associated data A = [ 4200 "Encrypt0", h'', TH_3 ] 4202 A_3ae (CBOR-encoded) (45 bytes) 4203 83 68 45 6e 63 72 79 70 74 30 40 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab 4204 d7 7c da 74 e4 1c b0 11 82 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 4206 Key K_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 4208 info is defined as follows: 4210 info for K_3ae = 4211 [ 4212 10, 4213 h'B6CD804FC4B9D7CAC502ABD77CDA74E41CB01182D7CB8B84DB03FFA583A35FCB', 4214 "K_3ae", 4215 16 4216 ] 4218 Which as a CBOR encoded data item is: 4220 info for K_3ae (CBOR-encoded) (43 bytes) 4221 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 4222 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 65 4b 5f 33 61 65 10 4224 L is the length of K_3ae, so 16 bytes. 4226 From these parameters, K_3ae is computed: 4228 K_3ae (16 bytes) 4229 6b a4 c8 83 1d e3 ae 23 e9 8e f7 35 08 d0 95 86 4231 Nonce IV_3ae is the output of HKDF-Expand(PRK_3e2m, info, L). 4233 info is defined as follows: 4235 info for IV_3ae = 4236 [ 4237 10, 4238 h'97D8AD42334833EB25B960A5EB0704505F89671A0168AA1115FAF92D9E67EF04', 4239 "IV_3ae", 4240 13 4241 ] 4243 Which as a CBOR encoded data item is: 4245 info for IV_3ae (CBOR-encoded) (44 bytes) 4246 84 0a 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 4247 d7 cb 8b 84 db 03 ff a5 83 a3 5f cb 66 49 56 5f 33 61 65 0d 4249 L is the length of IV_3ae, so 13 bytes. 4251 From these parameters, IV_3ae is computed: 4253 IV_3ae (13 bytes) 4254 6c 6d 0f e1 1e 9a 1a f3 7b 87 84 55 10 4256 Using the parameters above, the 'ciphertext' CIPHERTEXT_3 can be 4257 computed: 4259 CIPHERTEXT_3 (CBOR unencoded) (18 bytes) 4260 d5 53 5f 31 47 e8 5f 1c fa cd 9e 78 ab f9 e0 a8 1b bf 4262 From the parameter above, message_3 is computed, as the CBOR Sequence 4263 of the following items: (C_R, CIPHERTEXT_3). 4265 message_3 = 4266 ( 4267 -24, 4268 h'D5535F3147E85F1CFACD9E78ABF9E0A81BBF' 4269 ) 4271 Which encodes to the following byte string: 4273 message_3 (CBOR Sequence) (20 bytes) 4274 37 52 d5 53 5f 31 47 e8 5f 1c fa cd 9e 78 ab f9 e0 a8 1b bf 4276 C.2.4. OSCORE Security Context Derivation 4278 From here, the Initiator and the Responder can derive an OSCORE 4279 Security Context, using the EDHOC-Exporter interface. 4281 From TH_3 and CIPHERTEXT_3, compute the input to the transcript hash 4282 TH_4 = H( TH_3, CIPHERTEXT_3 ), as a CBOR Sequence of these 2 data 4283 items. 4285 Input to calculate TH_4 (CBOR Sequence) (53 bytes) 4286 58 20 b6 cd 80 4f c4 b9 d7 ca c5 02 ab d7 7c da 74 e4 1c b0 11 82 d7 cb 4287 8b 84 db 03 ff a5 83 a3 5f cb 52 d5 53 5f 31 47 e8 5f 1c fa cd 9e 78 ab 4288 f9 e0 a8 1b bf 4290 And from there, compute the transcript hash TH_4 = SHA-256(TH_3 , 4291 CIPHERTEXT_4) 4293 TH_4 (CBOR unencoded) (32 bytes) 4294 7c cf de dc 2c 10 ca 03 56 e9 57 b9 f6 a5 92 e0 fa 74 db 2a b5 4f 59 24 4295 40 96 f9 a2 ac 56 d2 07 4297 The Master Secret and Master Salt are derived as follows: 4299 Master Secret = EDHOC-Exporter( "OSCORE Master Secret", 16 ) = EDHOC- 4300 KDF(PRK_4x3m, TH_4, "OSCORE Master Secret", 16) = HKDF-Expand( 4301 PRK_4x3m, info_ms, 16 ) 4303 Master Salt = EDHOC-Exporter( "OSCORE Master Salt", 8 ) = EDHOC- 4304 KDF(PRK_4x3m, TH_4, "OSCORE Master Salt", 8) = HKDF-Expand( PRK_4x3m, 4305 info_salt, 8 ) 4307 info_ms for OSCORE Master Secret is defined as follows: 4309 info_ms = [ 4310 10, 4311 h'7CCFDEDC2C10CA0356E957B9F6A592E0FA74DB2AB54F59244096F9A2AC56D207', 4312 "OSCORE Master Secret", 4313 16 4314 ] 4316 Which as a CBOR encoded data item is: 4318 info_ms for OSCORE Master Secret (CBOR-encoded) (58 bytes) 4319 84 0a 58 20 7c cf de dc 2c 10 ca 03 56 e9 57 b9 f6 a5 92 e0 fa 74 db 2a 4320 b5 4f 59 24 40 96 f9 a2 ac 56 d2 07 74 4f 53 43 4f 52 45 20 4d 61 73 74 4321 65 72 20 53 65 63 72 65 74 10 4323 info_salt for OSCORE Master Salt is defined as follows: 4325 info_salt = [ 4326 10, 4327 h'7CCFDEDC2C10CA0356E957B9F6A592E0FA74DB2AB54F59244096F9A2AC56D207', 4328 "OSCORE Master Salt", 4329 8 4330 ] 4332 Which as a CBOR encoded data item is: 4334 info for OSCORE Master Salt (CBOR-encoded) (56 Bytes) 4335 84 0a 58 20 7c cf de dc 2c 10 ca 03 56 e9 57 b9 f6 a5 92 e0 fa 74 db 2a 4336 b5 4f 59 24 40 96 f9 a2 ac 56 d2 07 72 4f 53 43 4f 52 45 20 4d 61 73 74 4337 65 72 20 53 61 6c 74 08 4339 From these parameters, OSCORE Master Secret and OSCORE Master Salt 4340 are computed: 4342 OSCORE Master Secret (16 bytes) 4343 c3 4a 50 6d 0e bf bd 17 03 04 86 13 5f 9c b3 50 4345 OSCORE Master Salt (8 bytes) 4346 c2 24 34 9d 9b 34 ca 8c 4348 The client's OSCORE Sender ID is C_R and the server's OSCORE Sender 4349 ID is C_I. 4351 Client's OSCORE Sender ID (1 byte) 4352 00 4354 Server's OSCORE Sender ID (1 byte) 4355 16 4357 The AEAD Algorithm and the hash algorithm are the application AEAD 4358 and hash algorithms in the selected cipher suite. 4360 OSCORE AEAD Algorithm (int) 4361 10 4363 OSCORE Hash Algorithm (int) 4364 -16 4366 Appendix D. Applicability Template 4368 This appendix contains an example of an applicability statement, see 4369 Section 3.7. 4371 For use of EDHOC in the XX protocol, the following assumptions are 4372 made on the parameters: 4374 * METHOD_CORR = 5 4376 - method = 1 (I uses signature key, R uses static DH key.) 4378 - corr = 1 (CoAP Token or other transport data enables 4379 correlation between message_1 and message_2.) 4381 * EDHOC requests are expected by the server at /app1-edh, no 4382 Content-Format needed. 4384 * C_1 = "null" is present to identify message_1 4386 * CRED_I is an 802.1AR IDevID encoded as a C509 Certificate of type 4387 0 [I-D.ietf-cose-cbor-encoded-cert]. 4389 - R acquires CRED_I out-of-band, indicated in EAD_1 4391 - ID_CRED_I = {4: h''} is a kid with value empty byte string 4393 * CRED_R is a COSE_Key of type OKP as specified in Section 3.3.4. 4395 - The CBOR map has parameters 1 (kty), -1 (crv), and -2 4396 (x-coordinate). 4398 * ID_CRED_R = CRED_R 4400 * No use of message_4: the application sends protected messages from 4401 R to I. 4403 * External authorization data is defined and processed as specified 4404 in [I-D.selander-ace-ake-authz]. 4406 Appendix E. EDHOC Message Deduplication 4408 EDHOC by default assumes that message duplication is handled by the 4409 transport, in this section exemplified with CoAP. 4411 Deduplication of CoAP messages is described in Section 4.5 of 4412 [RFC7252]. This handles the case when the same Confirmable (CON) 4413 message is received multiple times due to missing acknowledgement on 4414 CoAP messaging layer. The recommended processing in [RFC7252] is 4415 that the duplicate message is acknowledged (ACK), but the received 4416 message is only processed once by the CoAP stack. 4418 Message deduplication is resource demanding and therefore not 4419 supported in all CoAP implementations. Since EDHOC is targeting 4420 constrained environments, it is desirable that EDHOC can optionally 4421 support transport layers which does not handle message duplication. 4422 Special care is needed to avoid issues with duplicate messages, see 4423 Section 5.2. 4425 The guiding principle here is similar to the deduplication processing 4426 on CoAP messaging layer: a received duplicate EDHOC message SHALL NOT 4427 result in a response consisting of another instance of the next EDHOC 4428 message. The result MAY be that a duplicate EDHOC response is sent, 4429 provided it is still relevant with respect the current protocol 4430 state. In any case, the received message MUST NOT be processed more 4431 than once in the same EDHOC session. This is called "EDHOC message 4432 deduplication". 4434 An EDHOC implementation MAY store the previously sent EDHOC message 4435 to be able to resend it. An EDHOC implementation MAY keep the 4436 protocol state to be able to recreate the previously sent EDHOC 4437 message and resend it. The previous message or protocol state MUST 4438 NOT be kept longer than what is required for retransmission, for 4439 example, in the case of CoAP transport, no longer than the 4440 EXCHANGE_LIFETIME (see Section 4.8.2 of [RFC7252]). 4442 Note that the requirements in Section 5.2 still apply because 4443 duplicate messages are not processed by the EDHOC state machine: 4445 * EDHOC messages SHALL be processed according to the current 4446 protocol state. 4448 * Different instances of the same message MUST NOT be processed in 4449 one session. 4451 Appendix F. Change Log 4453 Main changes: 4455 * From -06 to -07: 4457 - Changed transcript hash definition for TH_2 and TH_3 4459 - Removed "EDHOC signature algorithm curve" from cipher suite 4461 - New IANA registry "EDHOC Exporter Label" 4463 - New application defined parameter "context" in EDHOC-Exporter 4464 - Changed normative language for failure from MUST to SHOULD send 4465 error 4467 - Made error codes non-negative and 0 for success 4469 - Added detail on success error code 4471 - Aligned terminology "protocol instance" -> "session" 4473 - New appendix on compact EC point representation 4475 - Added detail on use of ephemeral public keys 4477 - Moved key derivation for OSCORE to draft-ietf-core-oscore-edhoc 4479 - Additional security considerations 4481 - Renamed "Auxililary Data" as "External Authorization Data" 4483 - Added encrypted EAD_4 to message_4 4485 * From -05 to -06: 4487 - New section 5.2 "Message Processing Outline" 4489 - Optional inital byte C_1 = null in message_1 4491 - New format of error messages, table of error codes, IANA 4492 registry 4494 - Change of recommendation transport of error in CoAP 4496 - Merge of content in 3.7 and appendix C into new section 3.7 4497 "Applicability Statement" 4499 - Requiring use of deterministic CBOR 4501 - New section on message deduplication 4503 - New appendix containin all CDDL definitions 4505 - New appendix with change log 4507 - Removed section "Other Documents Referencing EDHOC" 4509 - Clarifications based on review comments 4511 * From -04 to -05: 4513 - EDHOC-Rekey-FS -> EDHOC-KeyUpdate 4515 - Clarification of cipher suite negotiation 4517 - Updated security considerations 4519 - Updated test vectors 4521 - Updated applicability statement template 4523 * From -03 to -04: 4525 - Restructure of section 1 4527 - Added references to C509 Certificates 4529 - Change in CIPHERTEXT_2 -> plaintext XOR KEYSTREAM_2 (test 4530 vector not updated) 4532 - "K_2e", "IV_2e" -> KEYSTREAM_2 4534 - Specified optional message 4 4536 - EDHOC-Exporter-FS -> EDHOC-Rekey-FS 4538 - Less constrained devices SHOULD implement both suite 0 and 2 4540 - Clarification of error message 4542 - Added exporter interface test vector 4544 * From -02 to -03: 4546 - Rearrangements of section 3 and beginning of section 4 4548 - Key derivation new section 4 4550 - Cipher suites 4 and 5 added 4552 - EDHOC-EXPORTER-FS - generate a new PRK_4x3m from an old one 4554 - Change in CIPHERTEXT_2 -> COSE_Encrypt0 without tag (no change 4555 to test vector) 4557 - Clarification of error message 4559 - New appendix C applicability statement 4561 * From -01 to -02: 4563 - New section 1.2 Use of EDHOC 4565 - Clarification of identities 4567 - New section 4.3 clarifying bstr_identifier 4569 - Updated security considerations 4571 - Updated text on cipher suite negotiation and key confirmation 4573 - Test vector for static DH 4575 * From -00 to -01: 4577 - Removed PSK method 4579 - Removed references to certificate by value 4581 Acknowledgments 4583 The authors want to thank Alessandro Bruni, Karthikeyan Bhargavan, 4584 Timothy Claeys, Martin Disch, Theis Groenbech Petersen, Dan Harkins, 4585 Klaus Hartke, Russ Housley, Stefan Hristozov, Alexandros Krontiris, 4586 Ilari Liusvaara, Karl Norrman, Salvador Perez, Eric Rescorla, Michael 4587 Richardson, Thorvald Sahl Joergensen, Jim Schaad, Carsten Schuermann, 4588 Ludwig Seitz, Stanislav Smyshlyaev, Valery Smyslov, Peter van der 4589 Stok, Rene Struik, Vaishnavi Sundararajan, Erik Thormarker, Marco 4590 Tiloca, Michel Veillette, and Malisa Vucinic for reviewing and 4591 commenting on intermediate versions of the draft. We are especially 4592 indebted to Jim Schaad for his continuous reviewing and 4593 implementation of different versions of the draft. 4595 Work on this document has in part been supported by the H2020 project 4596 SIFIS-Home (grant agreement 952652). 4598 Authors' Addresses 4600 Göran Selander 4601 Ericsson AB 4603 Email: goran.selander@ericsson.com 4605 John Preuß Mattsson 4606 Ericsson AB 4607 Email: john.mattsson@ericsson.com 4609 Francesca Palombini 4610 Ericsson AB 4612 Email: francesca.palombini@ericsson.com