idnits 2.17.1 draft-schaad-cose-rfc8152bis-algs-00.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The abstract seems to contain references ([I-D.schaad-cose-RFC8152bis-struct]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (August 22, 2018) is 2073 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) -- Possible downref: Non-RFC (?) normative reference: ref. 'AES-GCM' -- Possible downref: Non-RFC (?) normative reference: ref. 'DSS' -- Possible downref: Normative reference to a draft: ref. 'I-D.schaad-cose-rfc8152bis-struct' -- Possible downref: Non-RFC (?) normative reference: ref. 'MAC' ** Downref: Normative reference to an Informational RFC: RFC 2104 ** Downref: Normative reference to an Informational RFC: RFC 3394 ** Downref: Normative reference to an Informational RFC: RFC 3610 ** 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 ** Obsolete normative reference: RFC 7049 (Obsoleted by RFC 8949) ** Obsolete normative reference: RFC 7539 (Obsoleted by RFC 8439) ** Downref: Normative reference to an Informational RFC: RFC 7748 ** Downref: Normative reference to an Informational RFC: RFC 8032 -- Possible downref: Non-RFC (?) normative reference: ref. 'SEC1' == Outdated reference: A later version (-11) exists of draft-greevenbosch-appsawg-cbor-cddl-09 -- Obsolete informational reference (is this intentional?): RFC 7159 (Obsoleted by RFC 8259) Summary: 11 errors (**), 0 flaws (~~), 2 warnings (==), 7 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 COSE Working Group J. Schaad 3 Internet-Draft August Cellars 4 Obsoletes: 8152 (if approved) August 22, 2018 5 Intended status: Standards Track 6 Expires: February 23, 2019 8 CBOR Algoritms for Object Signing and Encryption (COSE) 9 draft-schaad-cose-rfc8152bis-algs-00 11 Abstract 13 Concise Binary Object Representation (CBOR) is a data format designed 14 for small code size and small message size. There is a need for the 15 ability to have basic security services defined for this data format. 16 This document defines the CBOR Object Signing and Encryption (COSE) 17 protocol. This specification describes how to create and process 18 signatures, message authentication codes, and encryption using CBOR 19 for serialization. COSE additionally describes how to represent 20 cryptographic keys using CBOR. 22 In this specification the conventions for the use of a number of 23 cryptographic algorithms with COSE. The details of the structure of 24 COSE are defined in [I-D.schaad-cose-rfc8152bis-struct]. 26 This document along with [I-D.schaad-cose-rfc8152bis-struct] 27 obsoletes RFC8152. 29 Status of This Memo 31 This Internet-Draft is submitted in full conformance with the 32 provisions of BCP 78 and BCP 79. 34 Internet-Drafts are working documents of the Internet Engineering 35 Task Force (IETF). Note that other groups may also distribute 36 working documents as Internet-Drafts. The list of current Internet- 37 Drafts is at https://datatracker.ietf.org/drafts/current/. 39 Internet-Drafts are draft documents valid for a maximum of six months 40 and may be updated, replaced, or obsoleted by other documents at any 41 time. It is inappropriate to use Internet-Drafts as reference 42 material or to cite them other than as "work in progress." 44 This Internet-Draft will expire on February 23, 2019. 46 Copyright Notice 48 Copyright (c) 2018 IETF Trust and the persons identified as the 49 document authors. All rights reserved. 51 This document is subject to BCP 78 and the IETF Trust's Legal 52 Provisions Relating to IETF Documents 53 (https://trustee.ietf.org/license-info) in effect on the date of 54 publication of this document. Please review these documents 55 carefully, as they describe your rights and restrictions with respect 56 to this document. Code Components extracted from this document must 57 include Simplified BSD License text as described in Section 4.e of 58 the Trust Legal Provisions and are provided without warranty as 59 described in the Simplified BSD License. 61 Table of Contents 63 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 64 1.1. Requirements Terminology . . . . . . . . . . . . . . . . 4 65 1.2. Document Terminology . . . . . . . . . . . . . . . . . . 4 66 2. Signature Algorithms . . . . . . . . . . . . . . . . . . . . 5 67 2.1. ECDSA . . . . . . . . . . . . . . . . . . . . . . . . . . 5 68 2.1.1. Security Considerations . . . . . . . . . . . . . . . 6 69 2.2. Edwards-Curve Digital Signature Algorithms (EdDSAs) . . . 7 70 2.2.1. Security Considerations . . . . . . . . . . . . . . . 8 71 3. Message Authentication Code (MAC) Algorithms . . . . . . . . 8 72 3.1. Hash-Based Message Authentication Codes (HMACs) . . . . . 8 73 3.1.1. Security Considerations . . . . . . . . . . . . . . . 10 74 3.2. AES Message Authentication Code (AES-CBC-MAC) . . . . . . 10 75 3.2.1. Security Considerations . . . . . . . . . . . . . . . 11 76 4. Content Encryption Algorithms . . . . . . . . . . . . . . . . 11 77 4.1. AES GCM . . . . . . . . . . . . . . . . . . . . . . . . . 11 78 4.1.1. Security Considerations . . . . . . . . . . . . . . . 12 79 4.2. AES CCM . . . . . . . . . . . . . . . . . . . . . . . . . 13 80 4.2.1. Security Considerations . . . . . . . . . . . . . . . 15 81 4.3. ChaCha20 and Poly1305 . . . . . . . . . . . . . . . . . . 15 82 4.3.1. Security Considerations . . . . . . . . . . . . . . . 16 83 5. Key Derivation Functions (KDFs) . . . . . . . . . . . . . . . 16 84 5.1. HMAC-Based Extract-and-Expand Key Derivation Function 85 (HKDF) . . . . . . . . . . . . . . . . . . . . . . . . . 16 86 5.2. Context Information Structure . . . . . . . . . . . . . . 18 87 6. Content Key Distribution Methods . . . . . . . . . . . . . . 23 88 6.1. Direct Key . . . . . . . . . . . . . . . . . . . . . . . 23 89 6.1.1. Security Considerations . . . . . . . . . . . . . . . 24 90 6.2. Direct Key with KDF . . . . . . . . . . . . . . . . . . . 24 91 6.2.1. Security Considerations . . . . . . . . . . . . . . . 25 92 6.3. AES Key Wrap . . . . . . . . . . . . . . . . . . . . . . 26 93 6.3.1. Security Considerations for AES-KW . . . . . . . . . 27 95 6.4. Direct ECDH . . . . . . . . . . . . . . . . . . . . . . . 27 96 6.4.1. Security Considerations . . . . . . . . . . . . . . . 29 97 6.5. ECDH with Key Wrap . . . . . . . . . . . . . . . . . . . 30 98 7. Key Object Parameters . . . . . . . . . . . . . . . . . . . . 32 99 7.1. Elliptic Curve Keys . . . . . . . . . . . . . . . . . . . 32 100 7.1.1. Double Coordinate Curves . . . . . . . . . . . . . . 33 101 7.2. Octet Key Pair . . . . . . . . . . . . . . . . . . . . . 34 102 7.3. Symmetric Keys . . . . . . . . . . . . . . . . . . . . . 35 103 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 35 104 8.1. COSE Algorithms Registry . . . . . . . . . . . . . . . . 35 105 8.2. COSE Key Type Parameters Registry . . . . . . . . . . . . 37 106 8.3. COSE Key Types Registry . . . . . . . . . . . . . . . . . 37 107 8.4. COSE Elliptic Curves Registry . . . . . . . . . . . . . . 38 108 8.5. Expert Review Instructions . . . . . . . . . . . . . . . 39 109 9. Security Considerations . . . . . . . . . . . . . . . . . . . 40 110 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 42 111 10.1. Normative References . . . . . . . . . . . . . . . . . . 42 112 10.2. Informative References . . . . . . . . . . . . . . . . . 43 113 Appendix A. Examples . . . . . . . . . . . . . . . . . . . . . . 45 114 A.1. Examples of Signed Messages . . . . . . . . . . . . . . . 45 115 A.1.1. Single Signature . . . . . . . . . . . . . . . . . . 45 116 A.1.2. Multiple Signers . . . . . . . . . . . . . . . . . . 46 117 A.1.3. Counter Signature . . . . . . . . . . . . . . . . . . 47 118 A.1.4. Signature with Criticality . . . . . . . . . . . . . 48 119 A.2. Single Signer Examples . . . . . . . . . . . . . . . . . 49 120 A.2.1. Single ECDSA Signature . . . . . . . . . . . . . . . 49 121 A.3. Examples of Enveloped Messages . . . . . . . . . . . . . 50 122 A.3.1. Direct ECDH . . . . . . . . . . . . . . . . . . . . . 50 123 A.3.2. Direct Plus Key Derivation . . . . . . . . . . . . . 51 124 A.3.3. Counter Signature on Encrypted Content . . . . . . . 52 125 A.3.4. Encrypted Content with External Data . . . . . . . . 54 126 A.4. Examples of Encrypted Messages . . . . . . . . . . . . . 54 127 A.4.1. Simple Encrypted Message . . . . . . . . . . . . . . 54 128 A.4.2. Encrypted Message with a Partial IV . . . . . . . . . 55 129 A.5. Examples of MACed Messages . . . . . . . . . . . . . . . 55 130 A.5.1. Shared Secret Direct MAC . . . . . . . . . . . . . . 55 131 A.5.2. ECDH Direct MAC . . . . . . . . . . . . . . . . . . . 56 132 A.5.3. Wrapped MAC . . . . . . . . . . . . . . . . . . . . . 57 133 A.5.4. Multi-Recipient MACed Message . . . . . . . . . . . . 58 134 A.6. Examples of MAC0 Messages . . . . . . . . . . . . . . . . 59 135 A.6.1. Shared Secret Direct MAC . . . . . . . . . . . . . . 59 136 A.7. COSE Keys . . . . . . . . . . . . . . . . . . . . . . . . 60 137 A.7.1. Public Keys . . . . . . . . . . . . . . . . . . . . . 60 138 A.7.2. Private Keys . . . . . . . . . . . . . . . . . . . . 61 139 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 63 140 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 64 142 1. Introduction 144 There has been an increased focus on small, constrained devices that 145 make up the Internet of Things (IoT). One of the standards that has 146 come out of this process is "Concise Binary Object Representation 147 (CBOR)" [RFC7049]. CBOR extended the data model of the JavaScript 148 Object Notation (JSON) [RFC7159] by allowing for binary data, among 149 other changes. CBOR is being adopted by several of the IETF working 150 groups dealing with the IoT world as their encoding of data 151 structures. CBOR was designed specifically to be both small in terms 152 of messages transport and implementation size and be a schema-free 153 decoder. A need exists to provide message security services for IoT, 154 and using CBOR as the message-encoding format makes sense. 156 The core COSE specification consists of two documents. 157 [I-D.schaad-cose-rfc8152bis-struct] contains the serialization 158 structures and the procedures for using the different cryptographic 159 algorithms. This document provides for an initial set of algorithms 160 that are then use with those structures. 162 1.1. Requirements Terminology 164 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 165 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 166 "OPTIONAL" in this document are to be interpreted as described in BCP 167 14 [RFC2119] [RFC8174] when, and only when, they appear in all 168 capitals, as shown here. 170 1.2. Document Terminology 172 In this document, we use the following terminology: 174 Byte is a synonym for octet. 176 Constrained Application Protocol (CoAP) is a specialized web transfer 177 protocol for use in constrained systems. It is defined in [RFC7252]. 179 Authenticated Encryption (AE) [RFC5116] algorithms are those 180 encryption algorithms that provide an authentication check of the 181 plain text contents as part of the encryption service. 183 Authenticated Encryption with Authenticated Data (AEAD) [RFC5116] 184 algorithms provide the same content authentication service as AE 185 algorithms, but they additionally provide for authentication of non- 186 encrypted data as well. 188 2. Signature Algorithms 190 The document defines signature algorithm identifiers for two 191 signature algorithms. 193 2.1. ECDSA 195 ECDSA [DSS] defines a signature algorithm using ECC. Implementations 196 SHOULD use a deterministic version of ECDSA such as the one defined 197 in [RFC6979]. The use of a deterministic signature algorithm allows 198 for systems to avoid relying on random number generators in order to 199 avoid generating the same value of 'k' (the per-message random 200 value). Biased generation of the value 'k' can be attacked, and 201 collisions of this value leads to leaked keys. It additionally 202 allows for doing deterministic tests for the signature algorithm. 203 The use of deterministic ECDSA does not lessen the need to have good 204 random number generation when creating the private key. 206 The ECDSA signature algorithm is parameterized with a hash function 207 (h). In the event that the length of the hash function output is 208 greater than the group of the key, the leftmost bytes of the hash 209 output are used. 211 The algorithms defined in this document can be found in Table 1. 213 +-------+-------+---------+------------------+ 214 | Name | Value | Hash | Description | 215 +-------+-------+---------+------------------+ 216 | ES256 | -7 | SHA-256 | ECDSA w/ SHA-256 | 217 | ES384 | -35 | SHA-384 | ECDSA w/ SHA-384 | 218 | ES512 | -36 | SHA-512 | ECDSA w/ SHA-512 | 219 +-------+-------+---------+------------------+ 221 Table 1: ECDSA Algorithm Values 223 This document defines ECDSA to work only with the curves P-256, 224 P-384, and P-521. This document requires that the curves be encoded 225 using the 'EC2' (2 coordinate elliptic curve) key type. 226 Implementations need to check that the key type and curve are correct 227 when creating and verifying a signature. Other documents can define 228 it to work with other curves and points in the future. 230 In order to promote interoperability, it is suggested that SHA-256 be 231 used only with curve P-256, SHA-384 be used only with curve P-384, 232 and SHA-512 be used with curve P-521. This is aligned with the 233 recommendation in Section 4 of [RFC5480]. 235 The signature algorithm results in a pair of integers (R, S). These 236 integers will be the same length as the length of the key used for 237 the signature process. The signature is encoded by converting the 238 integers into byte strings of the same length as the key size. The 239 length is rounded up to the nearest byte and is left padded with zero 240 bits to get to the correct length. The two integers are then 241 concatenated together to form a byte string that is the resulting 242 signature. 244 Using the function defined in [RFC8017], the signature is: 246 Signature = I2OSP(R, n) | I2OSP(S, n) 247 where n = ceiling(key_length / 8) 249 When using a COSE key for this algorithm, the following checks are 250 made: 252 o The 'kty' field MUST be present, and it MUST be 'EC2'. 254 o If the 'alg' field is present, it MUST match the ECDSA signature 255 algorithm being used. 257 o If the 'key_ops' field is present, it MUST include 'sign' when 258 creating an ECDSA signature. 260 o If the 'key_ops' field is present, it MUST include 'verify' when 261 verifying an ECDSA signature. 263 2.1.1. Security Considerations 265 The security strength of the signature is no greater than the minimum 266 of the security strength associated with the bit length of the key 267 and the security strength of the hash function. 269 Note: Use of this technique is a good idea even when good random 270 number generation exists. Doing so both reduces the possibility of 271 having the same value of 'k' in two signature operations and allows 272 for reproducible signature values, which helps testing. 274 There are two substitution attacks that can theoretically be mounted 275 against the ECDSA signature algorithm. 277 o Changing the curve used to validate the signature: If one changes 278 the curve used to validate the signature, then potentially one 279 could have two messages with the same signature, each computed 280 under a different curve. The only requirement on the new curve is 281 that its order be the same as the old one and it be acceptable to 282 the client. An example would be to change from using the curve 283 secp256r1 (aka P-256) to using secp256k1. (Both are 256-bit 284 curves.) We currently do not have any way to deal with this 285 version of the attack except to restrict the overall set of curves 286 that can be used. 288 o Change the hash function used to validate the signature: If one 289 either has two different hash functions of the same length or can 290 truncate a hash function down, then one could potentially find 291 collisions between the hash functions rather than within a single 292 hash function (for example, truncating SHA-512 to 256 bits might 293 collide with a SHA-256 bit hash value). As the hash algorithm is 294 part of the signature algorithm identifier, this attack is 295 mitigated by including a signature algorithm identifier in the 296 protected header. 298 2.2. Edwards-Curve Digital Signature Algorithms (EdDSAs) 300 [RFC8032] describes the elliptic curve signature scheme Edwards-curve 301 Digital Signature Algorithm (EdDSA). In that document, the signature 302 algorithm is instantiated using parameters for edwards25519 and 303 edwards448 curves. The document additionally describes two variants 304 of the EdDSA algorithm: Pure EdDSA, where no hash function is applied 305 to the content before signing, and HashEdDSA, where a hash function 306 is applied to the content before signing and the result of that hash 307 function is signed. For EdDSA, the content to be signed (either the 308 message or the pre-hash value) is processed twice inside of the 309 signature algorithm. For use with COSE, only the pure EdDSA version 310 is used. This is because it is not expected that extremely large 311 contents are going to be needed and, based on the arrangement of the 312 message structure, the entire message is going to need to be held in 313 memory in order to create or verify a signature. This means that 314 there does not appear to be a need to be able to do block updates of 315 the hash, followed by eliminating the message from memory. 316 Applications can provide the same features by defining the content of 317 the message as a hash value and transporting the COSE object (with 318 the hash value) and the content as separate items. 320 The algorithms defined in this document can be found in Table 2. A 321 single signature algorithm is defined, which can be used for multiple 322 curves. 324 +-------+-------+-------------+ 325 | Name | Value | Description | 326 +-------+-------+-------------+ 327 | EdDSA | -8 | EdDSA | 328 +-------+-------+-------------+ 330 Table 2: EdDSA Algorithm Values 332 [RFC8032] describes the method of encoding the signature value. 334 When using a COSE key for this algorithm, the following checks are 335 made: 337 o The 'kty' field MUST be present, and it MUST be 'OKP' (Octet Key 338 Pair). 340 o The 'crv' field MUST be present, and it MUST be a curve defined 341 for this signature algorithm. 343 o If the 'alg' field is present, it MUST match 'EdDSA'. 345 o If the 'key_ops' field is present, it MUST include 'sign' when 346 creating an EdDSA signature. 348 o If the 'key_ops' field is present, it MUST include 'verify' when 349 verifying an EdDSA signature. 351 2.2.1. Security Considerations 353 How public values are computed is not the same when looking at EdDSA 354 and Elliptic Curve Diffie-Hellman (ECDH); for this reason, they 355 should not be used with the other algorithm. 357 If batch signature verification is performed, a well-seeded 358 cryptographic random number generator is REQUIRED. Signing and non- 359 batch signature verification are deterministic operations and do not 360 need random numbers of any kind. 362 3. Message Authentication Code (MAC) Algorithms 364 This section defines the usages for two MAC algorithms. 366 3.1. Hash-Based Message Authentication Codes (HMACs) 368 HMAC [RFC2104] [RFC4231] was designed to deal with length extension 369 attacks. The algorithm was also designed to allow for new hash 370 algorithms to be directly plugged in without changes to the hash 371 function. The HMAC design process has been shown as solid since, 372 while the security of hash algorithms such as MD5 has decreased over 373 time; the security of HMAC combined with MD5 has not yet been shown 374 to be compromised [RFC6151]. 376 The HMAC algorithm is parameterized by an inner and outer padding, a 377 hash function (h), and an authentication tag value length. For this 378 specification, the inner and outer padding are fixed to the values 379 set in [RFC2104]. The length of the authentication tag corresponds 380 to the difficulty of producing a forgery. For use in constrained 381 environments, we define a set of HMAC algorithms that are truncated. 382 There are currently no known issues with truncation; however, the 383 security strength of the message tag is correspondingly reduced in 384 strength. When truncating, the leftmost tag length bits are kept and 385 transmitted. 387 The algorithms defined in this document can be found in Table 3. 389 +-----------+-------+---------+----------+--------------------------+ 390 | Name | Value | Hash | Tag | Description | 391 | | | | Length | | 392 +-----------+-------+---------+----------+--------------------------+ 393 | HMAC | 4 | SHA-256 | 64 | HMAC w/ SHA-256 | 394 | 256/64 | | | | truncated to 64 bits | 395 | HMAC | 5 | SHA-256 | 256 | HMAC w/ SHA-256 | 396 | 256/256 | | | | | 397 | HMAC | 6 | SHA-384 | 384 | HMAC w/ SHA-384 | 398 | 384/384 | | | | | 399 | HMAC | 7 | SHA-512 | 512 | HMAC w/ SHA-512 | 400 | 512/512 | | | | | 401 +-----------+-------+---------+----------+--------------------------+ 403 Table 3: HMAC Algorithm Values 405 Some recipient algorithms carry the key while others derive a key 406 from secret data. For those algorithms that carry the key (such as 407 AES Key Wrap), the size of the HMAC key SHOULD be the same size as 408 the underlying hash function. For those algorithms that derive the 409 key (such as ECDH), the derived key MUST be the same size as the 410 underlying hash function. 412 When using a COSE key for this algorithm, the following checks are 413 made: 415 o The 'kty' field MUST be present, and it MUST be 'Symmetric'. 417 o If the 'alg' field is present, it MUST match the HMAC algorithm 418 being used. 420 o If the 'key_ops' field is present, it MUST include 'MAC create' 421 when creating an HMAC authentication tag. 423 o If the 'key_ops' field is present, it MUST include 'MAC verify' 424 when verifying an HMAC authentication tag. 426 Implementations creating and validating MAC values MUST validate that 427 the key type, key length, and algorithm are correct and appropriate 428 for the entities involved. 430 3.1.1. Security Considerations 432 HMAC has proved to be resistant to attack even when used with 433 weakened hash algorithms. The current best known attack is to brute 434 force the key. This means that key size is going to be directly 435 related to the security of an HMAC operation. 437 3.2. AES Message Authentication Code (AES-CBC-MAC) 439 AES-CBC-MAC is defined in [MAC]. (Note that this is not the same 440 algorithm as AES Cipher-Based Message Authentication Code (AES-CMAC) 441 [RFC4493].) 443 AES-CBC-MAC is parameterized by the key length, the authentication 444 tag length, and the IV used. For all of these algorithms, the IV is 445 fixed to all zeros. We provide an array of algorithms for various 446 key lengths and tag lengths. The algorithms defined in this document 447 are found in Table 4. 449 +-------------+-------+----------+----------+-----------------------+ 450 | Name | Value | Key | Tag | Description | 451 | | | Length | Length | | 452 +-------------+-------+----------+----------+-----------------------+ 453 | AES-MAC | 14 | 128 | 64 | AES-MAC 128-bit key, | 454 | 128/64 | | | | 64-bit tag | 455 | AES-MAC | 15 | 256 | 64 | AES-MAC 256-bit key, | 456 | 256/64 | | | | 64-bit tag | 457 | AES-MAC | 25 | 128 | 128 | AES-MAC 128-bit key, | 458 | 128/128 | | | | 128-bit tag | 459 | AES-MAC | 26 | 256 | 128 | AES-MAC 256-bit key, | 460 | 256/128 | | | | 128-bit tag | 461 +-------------+-------+----------+----------+-----------------------+ 463 Table 4: AES-MAC Algorithm Values 465 Keys may be obtained either from a key structure or from a recipient 466 structure. Implementations creating and validating MAC values MUST 467 validate that the key type, key length, and algorithm are correct and 468 appropriate for the entities involved. 470 When using a COSE key for this algorithm, the following checks are 471 made: 473 o The 'kty' field MUST be present, and it MUST be 'Symmetric'. 475 o If the 'alg' field is present, it MUST match the AES-MAC algorithm 476 being used. 478 o If the 'key_ops' field is present, it MUST include 'MAC create' 479 when creating an AES-MAC authentication tag. 481 o If the 'key_ops' field is present, it MUST include 'MAC verify' 482 when verifying an AES-MAC authentication tag. 484 3.2.1. Security Considerations 486 A number of attacks exist against Cipher Block Chaining Message 487 Authentication Code (CBC-MAC) that need to be considered. 489 o A single key must only be used for messages of a fixed and known 490 length. If this is not the case, an attacker will be able to 491 generate a message with a valid tag given two message and tag 492 pairs. This can be addressed by using different keys for messages 493 of different lengths. The current structure mitigates this 494 problem, as a specific encoding structure that includes lengths is 495 built and signed. (CMAC also addresses this issue.) 497 o Cipher Block Chaining (CBC) mode, if the same key is used for both 498 encryption and authentication operations, an attacker can produce 499 messages with a valid authentication code. 501 o If the IV can be modified, then messages can be forged. This is 502 addressed by fixing the IV to all zeros. 504 4. Content Encryption Algorithms 506 This docuement defines the identifier and usages for three content 507 encryption algorithms. 509 4.1. AES GCM 511 The Galois/Counter Mode (GCM) mode is a generic authenticated 512 encryption block cipher mode defined in [AES-GCM]. The GCM mode is 513 combined with the AES block encryption algorithm to define an AEAD 514 cipher. 516 The GCM mode is parameterized by the size of the authentication tag 517 and the size of the nonce. This document fixes the size of the nonce 518 at 96 bits. The size of the authentication tag is limited to a small 519 set of values. For this document however, the size of the 520 authentication tag is fixed at 128 bits. 522 The set of algorithms defined in this document are in Table 5. 524 +---------+-------+------------------------------------------+ 525 | Name | Value | Description | 526 +---------+-------+------------------------------------------+ 527 | A128GCM | 1 | AES-GCM mode w/ 128-bit key, 128-bit tag | 528 | A192GCM | 2 | AES-GCM mode w/ 192-bit key, 128-bit tag | 529 | A256GCM | 3 | AES-GCM mode w/ 256-bit key, 128-bit tag | 530 +---------+-------+------------------------------------------+ 532 Table 5: Algorithm Value for AES-GCM 534 Keys may be obtained either from a key structure or from a recipient 535 structure. Implementations encrypting and decrypting MUST validate 536 that the key type, key length, and algorithm are correct and 537 appropriate for the entities involved. 539 When using a COSE key for this algorithm, the following checks are 540 made: 542 o The 'kty' field MUST be present, and it MUST be 'Symmetric'. 544 o If the 'alg' field is present, it MUST match the AES-GCM algorithm 545 being used. 547 o If the 'key_ops' field is present, it MUST include 'encrypt' or 548 'wrap key' when encrypting. 550 o If the 'key_ops' field is present, it MUST include 'decrypt' or 551 'unwrap key' when decrypting. 553 4.1.1. Security Considerations 555 When using AES-GCM, the following restrictions MUST be enforced: 557 o The key and nonce pair MUST be unique for every message encrypted. 559 o The total amount of data encrypted for a single key MUST NOT 560 exceed 2^39 - 256 bits. An explicit check is required only in 561 environments where it is expected that it might be exceeded. 563 Consideration was given to supporting smaller tag values; the 564 constrained community would desire tag sizes in the 64-bit range. 565 Doing so drastically changes both the maximum messages size 566 (generally not an issue) and the number of times that a key can be 567 used. Given that Counter with CBC-MAC (CCM) is the usual mode for 568 constrained environments, restricted modes are not supported. 570 4.2. AES CCM 572 CCM is a generic authentication encryption block cipher mode defined 573 in [RFC3610]. The CCM mode is combined with the AES block encryption 574 algorithm to define a commonly used content encryption algorithm used 575 in constrained devices. 577 The CCM mode has two parameter choices. The first choice is M, the 578 size of the authentication field. The choice of the value for M 579 involves a trade-off between message growth (from the tag) and the 580 probability that an attacker can undetectably modify a message. The 581 second choice is L, the size of the length field. This value 582 requires a trade-off between the maximum message size and the size of 583 the Nonce. 585 It is unfortunate that the specification for CCM specified L and M as 586 a count of bytes rather than a count of bits. This leads to possible 587 misunderstandings where AES-CCM-8 is frequently used to refer to a 588 version of CCM mode where the size of the authentication is 64 bits 589 and not 8 bits. These values have traditionally been specified as 590 bit counts rather than byte counts. This document will follow the 591 convention of using bit counts so that it is easier to compare the 592 different algorithms presented in this document. 594 We define a matrix of algorithms in this document over the values of 595 L and M. Constrained devices are usually operating in situations 596 where they use short messages and want to avoid doing recipient- 597 specific cryptographic operations. This favors smaller values of 598 both L and M. Less-constrained devices will want to be able to use 599 larger messages and are more willing to generate new keys for every 600 operation. This favors larger values of L and M. 602 The following values are used for L: 604 16 bits (2): This limits messages to 2^16 bytes (64 KiB) in length. 605 This is sufficiently long for messages in the constrained world. 606 The nonce length is 13 bytes allowing for 2^(13*8) possible values 607 of the nonce without repeating. 609 64 bits (8): This limits messages to 2^64 bytes in length. The 610 nonce length is 7 bytes allowing for 2^56 possible values of the 611 nonce without repeating. 613 The following values are used for M: 615 64 bits (8): This produces a 64-bit authentication tag. This 616 implies that there is a 1 in 2^64 chance that a modified message 617 will authenticate. 619 128 bits (16): This produces a 128-bit authentication tag. This 620 implies that there is a 1 in 2^128 chance that a modified message 621 will authenticate. 623 +--------------------+-------+----+-----+-----+---------------------+ 624 | Name | Value | L | M | k | Description | 625 +--------------------+-------+----+-----+-----+---------------------+ 626 | AES-CCM-16-64-128 | 10 | 16 | 64 | 128 | AES-CCM mode | 627 | | | | | | 128-bit key, 64-bit | 628 | | | | | | tag, 13-byte nonce | 629 | AES-CCM-16-64-256 | 11 | 16 | 64 | 256 | AES-CCM mode | 630 | | | | | | 256-bit key, 64-bit | 631 | | | | | | tag, 13-byte nonce | 632 | AES-CCM-64-64-128 | 12 | 64 | 64 | 128 | AES-CCM mode | 633 | | | | | | 128-bit key, 64-bit | 634 | | | | | | tag, 7-byte nonce | 635 | AES-CCM-64-64-256 | 13 | 64 | 64 | 256 | AES-CCM mode | 636 | | | | | | 256-bit key, 64-bit | 637 | | | | | | tag, 7-byte nonce | 638 | AES-CCM-16-128-128 | 30 | 16 | 128 | 128 | AES-CCM mode | 639 | | | | | | 128-bit key, | 640 | | | | | | 128-bit tag, | 641 | | | | | | 13-byte nonce | 642 | AES-CCM-16-128-256 | 31 | 16 | 128 | 256 | AES-CCM mode | 643 | | | | | | 256-bit key, | 644 | | | | | | 128-bit tag, | 645 | | | | | | 13-byte nonce | 646 | AES-CCM-64-128-128 | 32 | 64 | 128 | 128 | AES-CCM mode | 647 | | | | | | 128-bit key, | 648 | | | | | | 128-bit tag, 7-byte | 649 | | | | | | nonce | 650 | AES-CCM-64-128-256 | 33 | 64 | 128 | 256 | AES-CCM mode | 651 | | | | | | 256-bit key, | 652 | | | | | | 128-bit tag, 7-byte | 653 | | | | | | nonce | 654 +--------------------+-------+----+-----+-----+---------------------+ 656 Table 6: Algorithm Values for AES-CCM 658 Keys may be obtained either from a key structure or from a recipient 659 structure. Implementations encrypting and decrypting MUST validate 660 that the key type, key length, and algorithm are correct and 661 appropriate for the entities involved. 663 When using a COSE key for this algorithm, the following checks are 664 made: 666 o The 'kty' field MUST be present, and it MUST be 'Symmetric'. 668 o If the 'alg' field is present, it MUST match the AES-CCM algorithm 669 being used. 671 o If the 'key_ops' field is present, it MUST include 'encrypt' or 672 'wrap key' when encrypting. 674 o If the 'key_ops' field is present, it MUST include 'decrypt' or 675 'unwrap key' when decrypting. 677 4.2.1. Security Considerations 679 When using AES-CCM, the following restrictions MUST be enforced: 681 o The key and nonce pair MUST be unique for every message encrypted. 682 Note that the value of L influences the number of unique nonces. 684 o The total number of times the AES block cipher is used MUST NOT 685 exceed 2^61 operations. This limitation is the sum of times the 686 block cipher is used in computing the MAC value and in performing 687 stream encryption operations. An explicit check is required only 688 in environments where it is expected that it might be exceeded. 690 [RFC3610] additionally calls out one other consideration of note. It 691 is possible to do a pre-computation attack against the algorithm in 692 cases where portions of the plaintext are highly predictable. This 693 reduces the security of the key size by half. Ways to deal with this 694 attack include adding a random portion to the nonce value and/or 695 increasing the key size used. Using a portion of the nonce for a 696 random value will decrease the number of messages that a single key 697 can be used for. Increasing the key size may require more resources 698 in the constrained device. See Sections 5 and 10 of [RFC3610] for 699 more information. 701 4.3. ChaCha20 and Poly1305 703 ChaCha20 and Poly1305 combined together is an AEAD mode that is 704 defined in [RFC7539]. This is an algorithm defined to be a cipher 705 that is not AES and thus would not suffer from any future weaknesses 706 found in AES. These cryptographic functions are designed to be fast 707 in software-only implementations. 709 The ChaCha20/Poly1305 AEAD construction defined in [RFC7539] has no 710 parameterization. It takes a 256-bit key and a 96-bit nonce, as well 711 as the plaintext and additional data as inputs and produces the 712 ciphertext as an option. We define one algorithm identifier for this 713 algorithm in Table 7. 715 +-------------------+-------+---------------------------------------+ 716 | Name | Value | Description | 717 +-------------------+-------+---------------------------------------+ 718 | ChaCha20/Poly1305 | 24 | ChaCha20/Poly1305 w/ 256-bit key, | 719 | | | 128-bit tag | 720 +-------------------+-------+---------------------------------------+ 722 Table 7: Algorithm Value for AES-GCM 724 Keys may be obtained either from a key structure or from a recipient 725 structure. Implementations encrypting and decrypting MUST validate 726 that the key type, key length, and algorithm are correct and 727 appropriate for the entities involved. 729 When using a COSE key for this algorithm, the following checks are 730 made: 732 o The 'kty' field MUST be present, and it MUST be 'Symmetric'. 734 o If the 'alg' field is present, it MUST match the ChaCha20/Poly1305 735 algorithm being used. 737 o If the 'key_ops' field is present, it MUST include 'encrypt' or 738 'wrap key' when encrypting. 740 o If the 'key_ops' field is present, it MUST include 'decrypt' or 741 'unwrap key' when decrypting. 743 4.3.1. Security Considerations 745 The key and nounce values MUST be a unique pair for every invocation 746 of the algorithm. Nonce counters are considered to be an acceptable 747 way of ensuring that they are unique. 749 5. Key Derivation Functions (KDFs) 751 This document defines a single context structure and a single KDF. 752 These elements are used for all of the recipient algorithms defined 753 in this document that require a KDF process. These algorithms are 754 defined in Sections 6.2, 6.4, and 6.5. 756 5.1. HMAC-Based Extract-and-Expand Key Derivation Function (HKDF) 758 The HKDF key derivation algorithm is defined in [RFC5869]. 760 The HKDF algorithm takes these inputs: 762 secret -- a shared value that is secret. Secrets may be either 763 previously shared or derived from operations like a Diffie-Hellman 764 (DH) key agreement. 766 salt -- an optional value that is used to change the generation 767 process. The salt value can be either public or private. If the 768 salt is public and carried in the message, then the 'salt' 769 algorithm header parameter defined in Table 9 is used. While 770 [RFC5869] suggests that the length of the salt be the same as the 771 length of the underlying hash value, any amount of salt will 772 improve the security as different key values will be generated. 773 This parameter is protected by being included in the key 774 computation and does not need to be separately authenticated. The 775 salt value does not need to be unique for every message sent. 777 length -- the number of bytes of output that need to be generated. 779 context information -- Information that describes the context in 780 which the resulting value will be used. Making this information 781 specific to the context in which the material is going to be used 782 ensures that the resulting material will always be tied to that 783 usage. The context structure defined in Section 5.2 is used by 784 the KDFs in this document. 786 PRF -- The underlying pseudorandom function to be used in the HKDF 787 algorithm. The PRF is encoded into the HKDF algorithm selection. 789 HKDF is defined to use HMAC as the underlying PRF. However, it is 790 possible to use other functions in the same construct to provide a 791 different KDF that is more appropriate in the constrained world. 792 Specifically, one can use AES-CBC-MAC as the PRF for the expand step, 793 but not for the extract step. When using a good random shared secret 794 of the correct length, the extract step can be skipped. For the AES 795 algorithm versions, the extract step is always skipped. 797 The extract step cannot be skipped if the secret is not uniformly 798 random, for example, if it is the result of an ECDH key agreement 799 step. This implies that the AES HKDF version cannot be used with 800 ECDH. If the extract step is skipped, the 'salt' value is not used 801 as part of the HKDF functionality. 803 The algorithms defined in this document are found in Table 8. 805 +---------------+-----------------+---------------------------------+ 806 | Name | PRF | Description | 807 +---------------+-----------------+---------------------------------+ 808 | HKDF SHA-256 | HMAC with | HKDF using HMAC SHA-256 as the | 809 | | SHA-256 | PRF | 810 | HKDF SHA-512 | HMAC with | HKDF using HMAC SHA-512 as the | 811 | | SHA-512 | PRF | 812 | HKDF AES- | AES-CBC-MAC-128 | HKDF using AES-MAC as the PRF | 813 | MAC-128 | | w/ 128-bit key | 814 | HKDF AES- | AES-CBC-MAC-256 | HKDF using AES-MAC as the PRF | 815 | MAC-256 | | w/ 256-bit key | 816 +---------------+-----------------+---------------------------------+ 818 Table 8: HKDF Algorithms 820 +------+-------+------+-------------------------------+-------------+ 821 | Name | Label | Type | Algorithm | Description | 822 +------+-------+------+-------------------------------+-------------+ 823 | salt | -20 | bstr | direct+HKDF-SHA-256, direct | Random salt | 824 | | | | +HKDF-SHA-512, direct+HKDF- | | 825 | | | | AES-128, direct+HKDF-AES-256, | | 826 | | | | ECDH-ES+HKDF-256, ECDH- | | 827 | | | | ES+HKDF-512, ECDH- | | 828 | | | | SS+HKDF-256, ECDH- | | 829 | | | | SS+HKDF-512, ECDH-ES+A128KW, | | 830 | | | | ECDH-ES+A192KW, ECDH- | | 831 | | | | ES+A256KW, ECDH-SS+A128KW, | | 832 | | | | ECDH-SS+A192KW, ECDH- | | 833 | | | | SS+A256KW | | 834 +------+-------+------+-------------------------------+-------------+ 836 Table 9: HKDF Algorithm Parameters 838 5.2. Context Information Structure 840 The context information structure is used to ensure that the derived 841 keying material is "bound" to the context of the transaction. The 842 context information structure used here is based on that defined in 843 [SP800-56A]. By using CBOR for the encoding of the context 844 information structure, we automatically get the same type and length 845 separation of fields that is obtained by the use of ASN.1. This 846 means that there is no need to encode the lengths for the base 847 elements, as it is done by the encoding used in JOSE (Section 4.6.2 848 of [RFC7518]). 850 The context information structure refers to PartyU and PartyV as the 851 two parties that are doing the key derivation. Unless the 852 application protocol defines differently, we assign PartyU to the 853 entity that is creating the message and PartyV to the entity that is 854 receiving the message. By doing this association, different keys 855 will be derived for each direction as the context information is 856 different in each direction. 858 The context structure is built from information that is known to both 859 entities. This information can be obtained from a variety of 860 sources: 862 o Fields can be defined by the application. This is commonly used 863 to assign fixed names to parties, but it can be used for other 864 items such as nonces. 866 o Fields can be defined by usage of the output. Examples of this 867 are the algorithm and key size that are being generated. 869 o Fields can be defined by parameters from the message. We define a 870 set of parameters in Table 10 that can be used to carry the values 871 associated with the context structure. Examples of this are 872 identities and nonce values. These parameters are designed to be 873 placed in the unprotected bucket of the recipient structure; they 874 do not need to be in the protected bucket since they already are 875 included in the cryptographic computation by virtue of being 876 included in the context structure. 878 +----------+-------+------+---------------------------+-------------+ 879 | Name | Label | Type | Algorithm | Description | 880 +----------+-------+------+---------------------------+-------------+ 881 | PartyU | -21 | bstr | direct+HKDF-SHA-256, | Party U | 882 | identity | | | direct+HKDF-SHA-512, | identity | 883 | | | | direct+HKDF-AES-128, | information | 884 | | | | direct+HKDF-AES-256, | | 885 | | | | ECDH-ES+HKDF-256, ECDH- | | 886 | | | | ES+HKDF-512, ECDH- | | 887 | | | | SS+HKDF-256, ECDH- | | 888 | | | | SS+HKDF-512, ECDH- | | 889 | | | | ES+A128KW, ECDH- | | 890 | | | | ES+A192KW, ECDH- | | 891 | | | | ES+A256KW, ECDH- | | 892 | | | | SS+A128KW, ECDH- | | 893 | | | | SS+A192KW, ECDH-SS+A256KW | | 894 | PartyU | -22 | bstr | direct+HKDF-SHA-256, | Party U | 895 | nonce | | / | direct+HKDF-SHA-512, | provided | 896 | | | int | direct+HKDF-AES-128, | nonce | 897 | | | | direct+HKDF-AES-256, | | 898 | | | | ECDH-ES+HKDF-256, ECDH- | | 899 | | | | ES+HKDF-512, ECDH- | | 900 | | | | SS+HKDF-256, ECDH- | | 901 | | | | SS+HKDF-512, ECDH- | | 902 | | | | ES+A128KW, ECDH- | | 903 | | | | ES+A192KW, ECDH- | | 904 | | | | ES+A256KW, ECDH- | | 905 | | | | SS+A128KW, ECDH- | | 906 | | | | SS+A192KW, ECDH-SS+A256KW | | 907 | PartyU | -23 | bstr | direct+HKDF-SHA-256, | Party U | 908 | other | | | direct+HKDF-SHA-512, | other | 909 | | | | direct+HKDF-AES-128, | provided | 910 | | | | direct+HKDF-AES-256, | information | 911 | | | | ECDH-ES+HKDF-256, ECDH- | | 912 | | | | ES+HKDF-512, ECDH- | | 913 | | | | SS+HKDF-256, ECDH- | | 914 | | | | SS+HKDF-512, ECDH- | | 915 | | | | ES+A128KW, ECDH- | | 916 | | | | ES+A192KW, ECDH- | | 917 | | | | ES+A256KW, ECDH- | | 918 | | | | SS+A128KW, ECDH- | | 919 | | | | SS+A192KW, ECDH-SS+A256KW | | 920 | PartyV | -24 | bstr | direct+HKDF-SHA-256, | Party V | 921 | identity | | | direct+HKDF-SHA-512, | identity | 922 | | | | direct+HKDF-AES-128, | information | 923 | | | | direct+HKDF-AES-256, | | 924 | | | | ECDH-ES+HKDF-256, ECDH- | | 925 | | | | ES+HKDF-512, ECDH- | | 926 | | | | SS+HKDF-256, ECDH- | | 927 | | | | SS+HKDF-512, ECDH- | | 928 | | | | ES+A128KW, ECDH- | | 929 | | | | ES+A192KW, ECDH- | | 930 | | | | ES+A256KW, ECDH- | | 931 | | | | SS+A128KW, ECDH- | | 932 | | | | SS+A192KW, ECDH-SS+A256KW | | 933 | PartyV | -25 | bstr | direct+HKDF-SHA-256, | Party V | 934 | nonce | | / | direct+HKDF-SHA-512, | provided | 935 | | | int | direct+HKDF-AES-128, | nonce | 936 | | | | direct+HKDF-AES-256, | | 937 | | | | ECDH-ES+HKDF-256, ECDH- | | 938 | | | | ES+HKDF-512, ECDH- | | 939 | | | | SS+HKDF-256, ECDH- | | 940 | | | | SS+HKDF-512, ECDH- | | 941 | | | | ES+A128KW, ECDH- | | 942 | | | | ES+A192KW, ECDH- | | 943 | | | | ES+A256KW, ECDH- | | 944 | | | | SS+A128KW, ECDH- | | 945 | | | | SS+A192KW, ECDH-SS+A256KW | | 946 | PartyV | -26 | bstr | direct+HKDF-SHA-256, | Party V | 947 | other | | | direct+HKDF-SHA-512, | other | 948 | | | | direct+HKDF-AES-128, | provided | 949 | | | | direct+HKDF-AES-256, | information | 950 | | | | ECDH-ES+HKDF-256, ECDH- | | 951 | | | | ES+HKDF-512, ECDH- | | 952 | | | | SS+HKDF-256, ECDH- | | 953 | | | | SS+HKDF-512, ECDH- | | 954 | | | | ES+A128KW, ECDH- | | 955 | | | | ES+A192KW, ECDH- | | 956 | | | | ES+A256KW, ECDH- | | 957 | | | | SS+A128KW, ECDH- | | 958 | | | | SS+A192KW, ECDH-SS+A256KW | | 959 +----------+-------+------+---------------------------+-------------+ 961 Table 10: Context Algorithm Parameters 963 We define a CBOR object to hold the context information. This object 964 is referred to as COSE_KDF_Context. The object is based on a CBOR 965 array type. The fields in the array are: 967 AlgorithmID: This field indicates the algorithm for which the key 968 material will be used. This normally is either a key wrap 969 algorithm identifier or a content encryption algorithm identifier. 970 The values are from the "COSE Algorithms" registry. This field is 971 required to be present. The field exists in the context 972 information so that if the same environment is used for different 973 algorithms, then completely different keys will be generated for 974 each of those algorithms. This practice means if algorithm A is 975 broken and thus is easier to find, the key derived for algorithm B 976 will not be the same as the key derived for algorithm A. 978 PartyUInfo: This field holds information about party U. The 979 PartyUInfo is encoded as a CBOR array. The elements of PartyUInfo 980 are encoded in the order presented. The elements of the 981 PartyUInfo array are: 983 identity: This contains the identity information for party U. 984 The identities can be assigned in one of two manners. First, a 985 protocol can assign identities based on roles. For example, 986 the roles of "client" and "server" may be assigned to different 987 entities in the protocol. Each entity would then use the 988 correct label for the data they send or receive. The second 989 way for a protocol to assign identities is to use a name based 990 on a naming system (i.e., DNS, X.509 names). 992 We define an algorithm parameter 'PartyU identity' that can be 993 used to carry identity information in the message. However, 994 identity information is often known as part of the protocol and 995 can thus be inferred rather than made explicit. If identity 996 information is carried in the message, applications SHOULD have 997 a way of validating the supplied identity information. The 998 identity information does not need to be specified and is set 999 to nil in that case. 1001 nonce: This contains a nonce value. The nonce can either be 1002 implicit from the protocol or be carried as a value in the 1003 unprotected headers. 1005 We define an algorithm parameter 'PartyU nonce' that can be 1006 used to carry this value in the message; however, the nonce 1007 value could be determined by the application and the value 1008 determined from elsewhere. 1010 This option does not need to be specified and is set to nil in 1011 that case. 1013 other: This contains other information that is defined by the 1014 protocol. This option does not need to be specified and is set 1015 to nil in that case. 1017 PartyVInfo: This field holds information about party V. The content 1018 of the structure is the same as for the PartyUInfo but for party 1019 V. 1021 SuppPubInfo: This field contains public information that is mutually 1022 known to both parties. 1024 keyDataLength: This is set to the number of bits of the desired 1025 output value. This practice means if algorithm A can use two 1026 different key lengths, the key derived for longer key size will 1027 not contain the key for shorter key size as a prefix. 1029 protected: This field contains the protected parameter field. If 1030 there are no elements in the protected field, then use a zero- 1031 length bstr. 1033 other: This field is for free form data defined by the 1034 application. An example is that an application could define 1035 two different strings to be placed here to generate different 1036 keys for a data stream versus a control stream. This field is 1037 optional and will only be present if the application defines a 1038 structure for this information. Applications that define this 1039 SHOULD use CBOR to encode the data so that types and lengths 1040 are correctly included. 1042 SuppPrivInfo: This field contains private information that is 1043 mutually known private information. An example of this 1044 information would be a preexisting shared secret. (This could, 1045 for example, be used in combination with an ECDH key agreement to 1046 provide a secondary proof of identity.) The field is optional and 1047 will only be present if the application defines a structure for 1048 this information. Applications that define this SHOULD use CBOR 1049 to encode the data so that types and lengths are correctly 1050 included. 1052 The following CDDL fragment corresponds to the text above. 1054 PartyInfo = ( 1055 identity : bstr / nil, 1056 nonce : bstr / int / nil, 1057 other : bstr / nil 1058 ) 1060 COSE_KDF_Context = [ 1061 AlgorithmID : int / tstr, 1062 PartyUInfo : [ PartyInfo ], 1063 PartyVInfo : [ PartyInfo ], 1064 SuppPubInfo : [ 1065 keyDataLength : uint, 1066 protected : empty_or_serialized_map, 1067 ? other : bstr 1068 ], 1069 ? SuppPrivInfo : bstr 1070 ] 1072 6. Content Key Distribution Methods 1074 This document defines the identifiers and usage for a number of 1075 content key distribution methods. 1077 6.1. Direct Key 1079 This recipient algorithm is the simplest; the identified key is 1080 directly used as the key for the next layer down in the message. 1081 There are no algorithm parameters defined for this algorithm. The 1082 algorithm identifier value is assigned in Table 11. 1084 When this algorithm is used, the protected field MUST be zero length. 1085 The key type MUST be 'Symmetric'. 1087 +--------+-------+-------------------+ 1088 | Name | Value | Description | 1089 +--------+-------+-------------------+ 1090 | direct | -6 | Direct use of CEK | 1091 +--------+-------+-------------------+ 1093 Table 11: Direct Key 1095 6.1.1. Security Considerations 1097 This recipient algorithm has several potential problems that need to 1098 be considered: 1100 o These keys need to have some method to be regularly updated over 1101 time. All of the content encryption algorithms specified in this 1102 document have limits on how many times a key can be used without 1103 significant loss of security. 1105 o These keys need to be dedicated to a single algorithm. There have 1106 been a number of attacks developed over time when a single key is 1107 used for multiple different algorithms. One example of this is 1108 the use of a single key for both the CBC encryption mode and the 1109 CBC-MAC authentication mode. 1111 o Breaking one message means all messages are broken. If an 1112 adversary succeeds in determining the key for a single message, 1113 then the key for all messages is also determined. 1115 6.2. Direct Key with KDF 1117 These recipient algorithms take a common shared secret between the 1118 two parties and applies the HKDF function (Section 5.1), using the 1119 context structure defined in Section 5.2 to transform the shared 1120 secret into the CEK. The 'protected' field can be of non-zero 1121 length. Either the 'salt' parameter of HKDF or the 'PartyU nonce' 1122 parameter of the context structure MUST be present. The salt/nonce 1123 parameter can be generated either randomly or deterministically. The 1124 requirement is that it be a unique value for the shared secret in 1125 question. 1127 If the salt/nonce value is generated randomly, then it is suggested 1128 that the length of the random value be the same length as the hash 1129 function underlying HKDF. While there is no way to guarantee that it 1130 will be unique, there is a high probability that it will be unique. 1131 If the salt/nonce value is generated deterministically, it can be 1132 guaranteed to be unique, and thus there is no length requirement. 1134 A new IV must be used for each message if the same key is used. The 1135 IV can be modified in a predictable manner, a random manner, or an 1136 unpredictable manner (i.e., encrypting a counter). 1138 The IV used for a key can also be generated from the same HKDF 1139 functionality as the key is generated. If HKDF is used for 1140 generating the IV, the algorithm identifier is set to "IV- 1141 GENERATION". 1143 When these algorithms are used, the key type MUST be 'symmetric'. 1145 The set of algorithms defined in this document can be found in 1146 Table 12. 1148 +---------------------+-------+-------------+-----------------------+ 1149 | Name | Value | KDF | Description | 1150 +---------------------+-------+-------------+-----------------------+ 1151 | direct+HKDF-SHA-256 | -10 | HKDF | Shared secret w/ HKDF | 1152 | | | SHA-256 | and SHA-256 | 1153 | direct+HKDF-SHA-512 | -11 | HKDF | Shared secret w/ HKDF | 1154 | | | SHA-512 | and SHA-512 | 1155 | direct+HKDF-AES-128 | -12 | HKDF AES- | Shared secret w/ AES- | 1156 | | | MAC-128 | MAC 128-bit key | 1157 | direct+HKDF-AES-256 | -13 | HKDF AES- | Shared secret w/ AES- | 1158 | | | MAC-256 | MAC 256-bit key | 1159 +---------------------+-------+-------------+-----------------------+ 1161 Table 12: Direct Key with KDF 1163 When using a COSE key for this algorithm, the following checks are 1164 made: 1166 o The 'kty' field MUST be present, and it MUST be 'Symmetric'. 1168 o If the 'alg' field is present, it MUST match the algorithm being 1169 used. 1171 o If the 'key_ops' field is present, it MUST include 'deriveKey' or 1172 'deriveBits'. 1174 6.2.1. Security Considerations 1176 The shared secret needs to have some method to be regularly updated 1177 over time. The shared secret forms the basis of trust. Although not 1178 used directly, it should still be subject to scheduled rotation. 1180 While these methods do not provide for perfect forward secrecy, as 1181 the same shared secret is used for all of the keys generated, if the 1182 key for any single message is discovered, only the message (or series 1183 of messages) using that derived key are compromised. A new key 1184 derivation step will generate a new key that requires the same amount 1185 of work to get the key. 1187 6.3. AES Key Wrap 1189 The AES Key Wrap algorithm is defined in [RFC3394]. This algorithm 1190 uses an AES key to wrap a value that is a multiple of 64 bits. As 1191 such, it can be used to wrap a key for any of the content encryption 1192 algorithms defined in this document. The algorithm requires a single 1193 fixed parameter, the initial value. This is fixed to the value 1194 specified in Section 2.2.3.1 of [RFC3394]. There are no public 1195 parameters that vary on a per-invocation basis. The protected header 1196 field MUST be empty. 1198 Keys may be obtained either from a key structure or from a recipient 1199 structure. Implementations encrypting and decrypting MUST validate 1200 that the key type, key length, and algorithm are correct and 1201 appropriate for the entities involved. 1203 When using a COSE key for this algorithm, the following checks are 1204 made: 1206 o The 'kty' field MUST be present, and it MUST be 'Symmetric'. 1208 o If the 'alg' field is present, it MUST match the AES Key Wrap 1209 algorithm being used. 1211 o If the 'key_ops' field is present, it MUST include 'encrypt' or 1212 'wrap key' when encrypting. 1214 o If the 'key_ops' field is present, it MUST include 'decrypt' or 1215 'unwrap key' when decrypting. 1217 +--------+-------+----------+-----------------------------+ 1218 | Name | Value | Key Size | Description | 1219 +--------+-------+----------+-----------------------------+ 1220 | A128KW | -3 | 128 | AES Key Wrap w/ 128-bit key | 1221 | A192KW | -4 | 192 | AES Key Wrap w/ 192-bit key | 1222 | A256KW | -5 | 256 | AES Key Wrap w/ 256-bit key | 1223 +--------+-------+----------+-----------------------------+ 1225 Table 13: AES Key Wrap Algorithm Values 1227 6.3.1. Security Considerations for AES-KW 1229 The shared secret needs to have some method to be regularly updated 1230 over time. The shared secret is the basis of trust. 1232 6.4. Direct ECDH 1234 The mathematics for ECDH can be found in [RFC6090]. In this 1235 document, the algorithm is extended to be used with the two curves 1236 defined in [RFC7748]. 1238 ECDH is parameterized by the following: 1240 o Curve Type/Curve: The curve selected controls not only the size of 1241 the shared secret, but the mathematics for computing the shared 1242 secret. The curve selected also controls how a point in the curve 1243 is represented and what happens for the identity points on the 1244 curve. In this specification, we allow for a number of different 1245 curves to be used. A set of curves are defined in Table 18. 1246 The math used to obtain the computed secret is based on the curve 1247 selected and not on the ECDH algorithm. For this reason, a new 1248 algorithm does not need to be defined for each of the curves. 1250 o Computed Secret to Shared Secret: Once the computed secret is 1251 known, the resulting value needs to be converted to a byte string 1252 to run the KDF. The x-coordinate is used for all of the curves 1253 defined in this document. For curves X25519 and X448, the 1254 resulting value is used directly as it is a byte string of a known 1255 length. For the P-256, P-384, and P-521 curves, the x-coordinate 1256 is run through the I2OSP function defined in [RFC8017], using the 1257 same computation for n as is defined in Section 2.1. 1259 o Ephemeral-Static or Static-Static: The key agreement process may 1260 be done using either a static or an ephemeral key for the sender's 1261 side. When using ephemeral keys, the sender MUST generate a new 1262 ephemeral key for every key agreement operation. The ephemeral 1263 key is placed in the 'ephemeral key' parameter and MUST be present 1264 for all algorithm identifiers that use ephemeral keys. When using 1265 static keys, the sender MUST either generate a new random value or 1266 create a unique value. For the KDFs used, this means either the 1267 'salt' parameter for HKDF (Table 9) or the 'PartyU nonce' 1268 parameter for the context structure (Table 10) MUST be present 1269 (both can be present if desired). The value in the parameter MUST 1270 be unique for the pair of keys being used. It is acceptable to 1271 use a global counter that is incremented for every static-static 1272 operation and use the resulting value. When using static keys, 1273 the static key should be identified to the recipient. The static 1274 key can be identified either by providing the key ('static key') 1275 or by providing a key identifier for the static key ('static key 1276 id'). Both of these parameters are defined in Table 15. 1278 o Key Derivation Algorithm: The result of an ECDH key agreement 1279 process does not provide a uniformly random secret. As such, it 1280 needs to be run through a KDF in order to produce a usable key. 1281 Processing the secret through a KDF also allows for the 1282 introduction of context material: how the key is going to be used 1283 and one-time material for static-static key agreement. All of the 1284 algorithms defined in this document use one of the HKDF algorithms 1285 defined in Section 5.1 with the context structure defined in 1286 Section 5.2. 1288 o Key Wrap Algorithm: No key wrap algorithm is used. This is 1289 represented in Table 14 as 'none'. The key size for the context 1290 structure is the content layer encryption algorithm size. 1292 The set of direct ECDH algorithms defined in this document are found 1293 in Table 14. 1295 +-----------+-------+---------+------------+--------+---------------+ 1296 | Name | Value | KDF | Ephemeral- | Key | Description | 1297 | | | | Static | Wrap | | 1298 +-----------+-------+---------+------------+--------+---------------+ 1299 | ECDH-ES + | -25 | HKDF - | yes | none | ECDH ES w/ | 1300 | HKDF-256 | | SHA-256 | | | HKDF - | 1301 | | | | | | generate key | 1302 | | | | | | directly | 1303 | ECDH-ES + | -26 | HKDF - | yes | none | ECDH ES w/ | 1304 | HKDF-512 | | SHA-512 | | | HKDF - | 1305 | | | | | | generate key | 1306 | | | | | | directly | 1307 | ECDH-SS + | -27 | HKDF - | no | none | ECDH SS w/ | 1308 | HKDF-256 | | SHA-256 | | | HKDF - | 1309 | | | | | | generate key | 1310 | | | | | | directly | 1311 | ECDH-SS + | -28 | HKDF - | no | none | ECDH SS w/ | 1312 | HKDF-512 | | SHA-512 | | | HKDF - | 1313 | | | | | | generate key | 1314 | | | | | | directly | 1315 +-----------+-------+---------+------------+--------+---------------+ 1317 Table 14: ECDH Algorithm Values 1319 +-----------+-------+----------+---------------------+--------------+ 1320 | Name | Label | Type | Algorithm | Description | 1321 +-----------+-------+----------+---------------------+--------------+ 1322 | ephemeral | -1 | COSE_Key | ECDH-ES+HKDF-256, | Ephemeral | 1323 | key | | | ECDH-ES+HKDF-512, | public key | 1324 | | | | ECDH-ES+A128KW, | for the | 1325 | | | | ECDH-ES+A192KW, | sender | 1326 | | | | ECDH-ES+A256KW | | 1327 | static | -2 | COSE_Key | ECDH-SS+HKDF-256, | Static | 1328 | key | | | ECDH-SS+HKDF-512, | public key | 1329 | | | | ECDH-SS+A128KW, | for the | 1330 | | | | ECDH-SS+A192KW, | sender | 1331 | | | | ECDH-SS+A256KW | | 1332 | static | -3 | bstr | ECDH-SS+HKDF-256, | Static | 1333 | key id | | | ECDH-SS+HKDF-512, | public key | 1334 | | | | ECDH-SS+A128KW, | identifier | 1335 | | | | ECDH-SS+A192KW, | for the | 1336 | | | | ECDH-SS+A256KW | sender | 1337 +-----------+-------+----------+---------------------+--------------+ 1339 Table 15: ECDH Algorithm Parameters 1341 This document defines these algorithms to be used with the curves 1342 P-256, P-384, P-521, X25519, and X448. Implementations MUST verify 1343 that the key type and curve are correct. Different curves are 1344 restricted to different key types. Implementations MUST verify that 1345 the curve and algorithm are appropriate for the entities involved. 1347 When using a COSE key for this algorithm, the following checks are 1348 made: 1350 o The 'kty' field MUST be present, and it MUST be 'EC2' or 'OKP'. 1352 o If the 'alg' field is present, it MUST match the key agreement 1353 algorithm being used. 1355 o If the 'key_ops' field is present, it MUST include 'derive key' or 1356 'derive bits' for the private key. 1358 o If the 'key_ops' field is present, it MUST be empty for the public 1359 key. 1361 6.4.1. Security Considerations 1363 There is a method of checking that points provided from external 1364 entities are valid. For the 'EC2' key format, this can be done by 1365 checking that the x and y values form a point on the curve. For the 1366 'OKP' format, there is no simple way to do point validation. 1368 Consideration was given to requiring that the public keys of both 1369 entities be provided as part of the key derivation process (as 1370 recommended in Section 6.1 of [RFC7748]). This was not done as COSE 1371 is used in a store and forward format rather than in online key 1372 exchange. In order for this to be a problem, either the receiver 1373 public key has to be chosen maliciously or the sender has to be 1374 malicious. In either case, all security evaporates anyway. 1376 A proof of possession of the private key associated with the public 1377 key is recommended when a key is moved from untrusted to trusted 1378 (either by the end user or by the entity that is responsible for 1379 making trust statements on keys). 1381 6.5. ECDH with Key Wrap 1383 These algorithms are defined in Table 16. 1385 ECDH with Key Agreement is parameterized by the same parameters as 1386 for ECDH; see Section 6.4, with the following modifications: 1388 o Key Wrap Algorithm: Any of the key wrap algorithms defined in 1389 Section 6.3 are supported. The size of the key used for the key 1390 wrap algorithm is fed into the KDF. The set of identifiers are 1391 found in Table 16. 1393 +-----------+-------+---------+------------+--------+---------------+ 1394 | Name | Value | KDF | Ephemeral- | Key | Description | 1395 | | | | Static | Wrap | | 1396 +-----------+-------+---------+------------+--------+---------------+ 1397 | ECDH-ES + | -29 | HKDF - | yes | A128KW | ECDH ES w/ | 1398 | A128KW | | SHA-256 | | | Concat KDF | 1399 | | | | | | and AES Key | 1400 | | | | | | Wrap w/ | 1401 | | | | | | 128-bit key | 1402 | | | | | | | 1403 | ECDH-ES + | -30 | HKDF - | yes | A192KW | ECDH ES w/ | 1404 | A192KW | | SHA-256 | | | Concat KDF | 1405 | | | | | | and AES Key | 1406 | | | | | | Wrap w/ | 1407 | | | | | | 192-bit key | 1408 | | | | | | | 1409 | ECDH-ES + | -31 | HKDF - | yes | A256KW | ECDH ES w/ | 1410 | A256KW | | SHA-256 | | | Concat KDF | 1411 | | | | | | and AES Key | 1412 | | | | | | Wrap w/ | 1413 | | | | | | 256-bit key | 1414 | | | | | | | 1415 | ECDH-SS + | -32 | HKDF - | no | A128KW | ECDH SS w/ | 1416 | A128KW | | SHA-256 | | | Concat KDF | 1417 | | | | | | and AES Key | 1418 | | | | | | Wrap w/ | 1419 | | | | | | 128-bit key | 1420 | | | | | | | 1421 | ECDH-SS + | -33 | HKDF - | no | A192KW | ECDH SS w/ | 1422 | A192KW | | SHA-256 | | | Concat KDF | 1423 | | | | | | and AES Key | 1424 | | | | | | Wrap w/ | 1425 | | | | | | 192-bit key | 1426 | | | | | | | 1427 | ECDH-SS + | -34 | HKDF - | no | A256KW | ECDH SS w/ | 1428 | A256KW | | SHA-256 | | | Concat KDF | 1429 | | | | | | and AES Key | 1430 | | | | | | Wrap w/ | 1431 | | | | | | 256-bit key | 1432 +-----------+-------+---------+------------+--------+---------------+ 1434 Table 16: ECDH Algorithm Values with Key Wrap 1436 When using a COSE key for this algorithm, the following checks are 1437 made: 1439 o The 'kty' field MUST be present, and it MUST be 'EC2' or 'OKP'. 1441 o If the 'alg' field is present, it MUST match the key agreement 1442 algorithm being used. 1444 o If the 'key_ops' field is present, it MUST include 'derive key' or 1445 'derive bits' for the private key. 1447 o If the 'key_ops' field is present, it MUST be empty for the public 1448 key. 1450 7. Key Object Parameters 1452 The COSE_Key object defines a way to hold a single key object. It is 1453 still required that the members of individual key types be defined. 1454 This section of the document is where we define an initial set of 1455 members for specific key types. 1457 For each of the key types, we define both public and private members. 1458 The public members are what is transmitted to others for their usage. 1459 Private members allow for the archival of keys by individuals. 1460 However, there are some circumstances in which private keys may be 1461 distributed to entities in a protocol. Examples include: entities 1462 that have poor random number generation, centralized key creation for 1463 multi-cast type operations, and protocols in which a shared secret is 1464 used as a bearer token for authorization purposes. 1466 Key types are identified by the 'kty' member of the COSE_Key object. 1467 In this document, we define four values for the member: 1469 +-----------+-------+-----------------------------------------------+ 1470 | Name | Value | Description | 1471 +-----------+-------+-----------------------------------------------+ 1472 | OKP | 1 | Octet Key Pair | 1473 | EC2 | 2 | Elliptic Curve Keys w/ x- and y-coordinate | 1474 | | | pair | 1475 | Symmetric | 4 | Symmetric Keys | 1476 | Reserved | 0 | This value is reserved | 1477 +-----------+-------+-----------------------------------------------+ 1479 Table 17: Key Type Values 1481 7.1. Elliptic Curve Keys 1483 Two different key structures are defined for elliptic curve keys. 1484 One version uses both an x-coordinate and a y-coordinate, potentially 1485 with point compression ('EC2'). This is the traditional EC point 1486 representation that is used in [RFC5480]. The other version uses 1487 only the x-coordinate as the y-coordinate is either to be recomputed 1488 or not needed for the key agreement operation ('OKP'). 1490 Applications MUST check that the curve and the key type are 1491 consistent and reject a key if they are not. 1493 +---------+-------+----------+------------------------------------+ 1494 | Name | Value | Key Type | Description | 1495 +---------+-------+----------+------------------------------------+ 1496 | P-256 | 1 | EC2 | NIST P-256 also known as secp256r1 | 1497 | P-384 | 2 | EC2 | NIST P-384 also known as secp384r1 | 1498 | P-521 | 3 | EC2 | NIST P-521 also known as secp521r1 | 1499 | X25519 | 4 | OKP | X25519 for use w/ ECDH only | 1500 | X448 | 5 | OKP | X448 for use w/ ECDH only | 1501 | Ed25519 | 6 | OKP | Ed25519 for use w/ EdDSA only | 1502 | Ed448 | 7 | OKP | Ed448 for use w/ EdDSA only | 1503 +---------+-------+----------+------------------------------------+ 1505 Table 18: Elliptic Curves 1507 7.1.1. Double Coordinate Curves 1509 The traditional way of sending ECs has been to send either both the 1510 x-coordinate and y-coordinate or the x-coordinate and a sign bit for 1511 the y-coordinate. The latter encoding has not been recommended in 1512 the IETF due to potential IPR issues. However, for operations in 1513 constrained environments, the ability to shrink a message by not 1514 sending the y-coordinate is potentially useful. 1516 For EC keys with both coordinates, the 'kty' member is set to 2 1517 (EC2). The key parameters defined in this section are summarized in 1518 Table 19. The members that are defined for this key type are: 1520 crv: This contains an identifier of the curve to be used with the 1521 key. The curves defined in this document for this key type can 1522 be found in Table 18. Other curves may be registered in the 1523 future, and private curves can be used as well. 1525 x: This contains the x-coordinate for the EC point. The integer is 1526 converted to an octet string as defined in [SEC1]. Leading zero 1527 octets MUST be preserved. 1529 y: This contains either the sign bit or the value of the 1530 y-coordinate for the EC point. When encoding the value y, the 1531 integer is converted to an octet string (as defined in [SEC1]) 1532 and encoded as a CBOR bstr. Leading zero octets MUST be 1533 preserved. The compressed point encoding is also supported. 1534 Compute the sign bit as laid out in the Elliptic-Curve-Point-to- 1535 Octet-String Conversion function of [SEC1]. If the sign bit is 1536 zero, then encode y as a CBOR false value; otherwise, encode y 1537 as a CBOR true value. The encoding of the infinity point is not 1538 supported. 1540 d: This contains the private key. 1542 For public keys, it is REQUIRED that 'crv', 'x', and 'y' be present 1543 in the structure. For private keys, it is REQUIRED that 'crv' and 1544 'd' be present in the structure. For private keys, it is RECOMMENDED 1545 that 'x' and 'y' also be present, but they can be recomputed from the 1546 required elements and omitting them saves on space. 1548 +-------+------+-------+--------+-----------------------------------+ 1549 | Key | Name | Label | CBOR | Description | 1550 | Type | | | Type | | 1551 +-------+------+-------+--------+-----------------------------------+ 1552 | 2 | crv | -1 | int / | EC identifier - Taken from the | 1553 | | | | tstr | "COSE Elliptic Curves" registry | 1554 | 2 | x | -2 | bstr | x-coordinate | 1555 | 2 | y | -3 | bstr / | y-coordinate | 1556 | | | | bool | | 1557 | 2 | d | -4 | bstr | Private key | 1558 +-------+------+-------+--------+-----------------------------------+ 1560 Table 19: EC Key Parameters 1562 7.2. Octet Key Pair 1564 A new key type is defined for Octet Key Pairs (OKP). Do not assume 1565 that keys using this type are elliptic curves. This key type could 1566 be used for other curve types (for example, mathematics based on 1567 hyper-elliptic surfaces). 1569 The key parameters defined in this section are summarized in 1570 Table 20. The members that are defined for this key type are: 1572 crv: This contains an identifier of the curve to be used with the 1573 key. The curves defined in this document for this key type can 1574 be found in Table 18. Other curves may be registered in the 1575 future and private curves can be used as well. 1577 x: This contains the x-coordinate for the EC point. The octet 1578 string represents a little-endian encoding of x. 1580 d: This contains the private key. 1582 For public keys, it is REQUIRED that 'crv' and 'x' be present in the 1583 structure. For private keys, it is REQUIRED that 'crv' and 'd' be 1584 present in the structure. For private keys, it is RECOMMENDED that 1585 'x' also be present, but it can be recomputed from the required 1586 elements and omitting it saves on space. 1588 +------+-------+-------+--------+-----------------------------------+ 1589 | Name | Key | Label | Type | Description | 1590 | | Type | | | | 1591 +------+-------+-------+--------+-----------------------------------+ 1592 | crv | 1 | -1 | int / | EC identifier - Taken from the | 1593 | | | | tstr | "COSE Key Common Parameters" | 1594 | | | | | registry | 1595 | x | 1 | -2 | bstr | x-coordinate | 1596 | d | 1 | -4 | bstr | Private key | 1597 +------+-------+-------+--------+-----------------------------------+ 1599 Table 20: Octet Key Pair Parameters 1601 7.3. Symmetric Keys 1603 Occasionally it is required that a symmetric key be transported 1604 between entities. This key structure allows for that to happen. 1606 For symmetric keys, the 'kty' member is set to 4 ('Symmetric'). The 1607 member that is defined for this key type is: 1609 k: This contains the value of the key. 1611 This key structure does not have a form that contains only public 1612 members. As it is expected that this key structure is going to be 1613 transmitted, care must be taken that it is never transmitted 1614 accidentally or insecurely. For symmetric keys, it is REQUIRED that 1615 'k' be present in the structure. 1617 +------+----------+-------+------+-------------+ 1618 | Name | Key Type | Label | Type | Description | 1619 +------+----------+-------+------+-------------+ 1620 | k | 4 | -1 | bstr | Key Value | 1621 +------+----------+-------+------+-------------+ 1623 Table 21: Symmetric Key Parameters 1625 8. IANA Considerations 1627 8.1. COSE Algorithms Registry 1629 IANA has created a new registry titled "COSE Algorithms". The 1630 registry has been created to use the "Expert Review Required" 1631 registration procedure. Guidelines for the experts are provided in 1632 Section 8.5. It should be noted that, in addition to the expert 1633 review, some portions of the registry require a specification, 1634 potentially a Standards Track RFC, be supplied as well. 1636 The columns of the registry are: 1638 Name: A value that can be used to identify an algorithm in documents 1639 for easier comprehension. The name SHOULD be unique. However, 1640 the 'Value' field is what is used to identify the algorithm, not 1641 the 'name' field. 1643 Value: The value to be used to identify this algorithm. Algorithm 1644 values MUST be unique. The value can be a positive integer, a 1645 negative integer, or a string. Integer values between -256 and 1646 255 and strings of length 1 are designated as "Standards Action". 1647 Integer values from -65536 to 65535 and strings of length 2 are 1648 designated as "Specification Required". Integer values greater 1649 than 65535 and strings of length greater than 2 are designated as 1650 "Expert Review". Integer values less than -65536 are marked as 1651 private use. 1653 Description: A short description of the algorithm. 1655 Reference: A document where the algorithm is defined (if publicly 1656 available). 1658 Recommended: Does the IETF have a consensus recommendation to use 1659 the algorithm? The legal values are 'Yes', 'No', and 1660 'Deprecated'. 1662 The initial contents of the registry can be found in Tables 1, 2, 3, 1663 4, 5, 6, 7, 11, 12, 13, 14, and 16. All of the entries in the 1664 "References" column of this registry point to this document. All of 1665 the entries in the "Recommended" column are set to "Yes". 1667 Additionally, the label of 0 is to be marked as 'Reserved'. 1669 NOTE: The assignment of algorithm identifiers in this document was 1670 done so that positive numbers were used for the first layer objects 1671 (COSE_Sign, COSE_Sign1, COSE_Encrypt, COSE_Encrypt0, COSE_Mac, and 1672 COSE_Mac0). Negative numbers were used for second layer objects 1673 (COSE_Signature and COSE_recipient). Expert reviewers should 1674 consider this practice, but are not expected to be restricted by this 1675 precedent. 1677 8.2. COSE Key Type Parameters Registry 1679 IANA has created a new registry titled "COSE Key Type Parameters". 1680 The registry has been created to use the "Expert Review Required" 1681 registration procedure. Expert review guidelines are provided in 1682 Section 8.5. 1684 The columns of the table are: 1686 Key Type: This field contains a descriptive string of a key type. 1687 This should be a value that is in the "COSE Key Common Parameters" 1688 registry and is placed in the 'kty' field of a COSE Key structure. 1690 Name: This is a descriptive name that enables easier reference to 1691 the item. It is not used in the encoding. 1693 Label: The label is to be unique for every value of key type. The 1694 range of values is from -65536 to -1. Labels are expected to be 1695 reused for different keys. 1697 CBOR Type: This field contains the CBOR type for the field. 1699 Description: This field contains a brief description for the field. 1701 Reference: This contains a pointer to the public specification for 1702 the field if one exists. 1704 This registry has been initially populated by the values in Tables 1705 19, 20, and 21. All of the entries in the "References" column of 1706 this registry point to this document. 1708 8.3. COSE Key Types Registry 1710 IANA has created a new registry titled "COSE Key Types". The 1711 registry has been created to use the "Expert Review Required" 1712 registration procedure. Expert review guidelines are provided in 1713 Section 8.5. 1715 The columns of this table are: 1717 Name: This is a descriptive name that enables easier reference to 1718 the item. The name MUST be unique. It is not used in the 1719 encoding. 1721 Value: This is the value used to identify the curve. These values 1722 MUST be unique. The value can be a positive integer, a negative 1723 integer, or a string. 1725 Description: This field contains a brief description of the curve. 1727 References: This contains a pointer to the public specification for 1728 the curve if one exists. 1730 This registry has been initially populated by the values in Table 17. 1731 The specification column for all of these entries will be this 1732 document. 1734 8.4. COSE Elliptic Curves Registry 1736 IANA has created a new registry titled "COSE Elliptic Curves". The 1737 registry has been created to use the "Expert Review Required" 1738 registration procedure. Guidelines for the experts are provided in 1739 Section 8.5. It should be noted that, in addition to the expert 1740 review, some portions of the registry require a specification, 1741 potentially a Standards Track RFC, be supplied as well. 1743 The columns of the table are: 1745 Name: This is a descriptive name that enables easier reference to 1746 the item. It is not used in the encoding. 1748 Value: This is the value used to identify the curve. These values 1749 MUST be unique. The integer values from -256 to 255 are 1750 designated as "Standards Action". The integer values from 256 to 1751 65535 and -65536 to -257 are designated as "Specification 1752 Required". Integer values over 65535 are designated as "Expert 1753 Review". Integer values less than -65536 are marked as private 1754 use. 1756 Key Type: This designates the key type(s) that can be used with this 1757 curve. 1759 Description: This field contains a brief description of the curve. 1761 Reference: This contains a pointer to the public specification for 1762 the curve if one exists. 1764 Recommended: Does the IETF have a consensus recommendation to use 1765 the algorithm? The legal values are 'Yes', 'No', and 1766 'Deprecated'. 1768 This registry has been initially populated by the values in Table 18. 1769 All of the entries in the "References" column of this registry point 1770 to this document. All of the entries in the "Recommended" column are 1771 set to "Yes". 1773 8.5. Expert Review Instructions 1775 All of the IANA registries established in this document are defined 1776 as expert review. This section gives some general guidelines for 1777 what the experts should be looking for, but they are being designated 1778 as experts for a reason, so they should be given substantial 1779 latitude. 1781 Expert reviewers should take into consideration the following points: 1783 o Point squatting should be discouraged. Reviewers are encouraged 1784 to get sufficient information for registration requests to ensure 1785 that the usage is not going to duplicate one that is already 1786 registered, and that the point is likely to be used in 1787 deployments. The zones tagged as private use are intended for 1788 testing purposes and closed environments; code points in other 1789 ranges should not be assigned for testing. 1791 o Specifications are required for the standards track range of point 1792 assignment. Specifications should exist for specification 1793 required ranges, but early assignment before a specification is 1794 available is considered to be permissible. Specifications are 1795 needed for the first-come, first-serve range if they are expected 1796 to be used outside of closed environments in an interoperable way. 1797 When specifications are not provided, the description provided 1798 needs to have sufficient information to identify what the point is 1799 being used for. 1801 o Experts should take into account the expected usage of fields when 1802 approving point assignment. The fact that there is a range for 1803 standards track documents does not mean that a standards track 1804 document cannot have points assigned outside of that range. The 1805 length of the encoded value should be weighed against how many 1806 code points of that length are left, the size of device it will be 1807 used on, and the number of code points left that encode to that 1808 size. 1810 o When algorithms are registered, vanity registrations should be 1811 discouraged. One way to do this is to require registrations to 1812 provide additional documentation on security analysis of the 1813 algorithm. Another thing that should be considered is requesting 1814 an opinion on the algorithm from the Crypto Forum Research Group 1815 (CFRG). Algorithms that do not meet the security requirements of 1816 the community and the messages structures should not be 1817 registered. 1819 9. Security Considerations 1821 There are a number of security considerations that need to be taken 1822 into account by implementers of this specification. The security 1823 considerations that are specific to an individual algorithm are 1824 placed next to the description of the algorithm. While some 1825 considerations have been highlighted here, additional considerations 1826 may be found in the documents listed in the references. 1828 Implementations need to protect the private key material for any 1829 individuals. There are some cases in this document that need to be 1830 highlighted on this issue. 1832 o Using the same key for two different algorithms can leak 1833 information about the key. It is therefore recommended that keys 1834 be restricted to a single algorithm. 1836 o Use of 'direct' as a recipient algorithm combined with a second 1837 recipient algorithm exposes the direct key to the second 1838 recipient. 1840 o Several of the algorithms in this document have limits on the 1841 number of times that a key can be used without leaking information 1842 about the key. 1844 The use of ECDH and direct plus KDF (with no key wrap) will not 1845 directly lead to the private key being leaked; the one way function 1846 of the KDF will prevent that. There is, however, a different issue 1847 that needs to be addressed. Having two recipients requires that the 1848 CEK be shared between two recipients. The second recipient therefore 1849 has a CEK that was derived from material that can be used for the 1850 weak proof of origin. The second recipient could create a message 1851 using the same CEK and send it to the first recipient; the first 1852 recipient would, for either static-static ECDH or direct plus KDF, 1853 make an assumption that the CEK could be used for proof of origin 1854 even though it is from the wrong entity. If the key wrap step is 1855 added, then no proof of origin is implied and this is not an issue. 1857 Although it has been mentioned before, the use of a single key for 1858 multiple algorithms has been demonstrated in some cases to leak 1859 information about a key, provide the opportunity for attackers to 1860 forge integrity tags, or gain information about encrypted content. 1861 Binding a key to a single algorithm prevents these problems. Key 1862 creators and key consumers are strongly encouraged not only to create 1863 new keys for each different algorithm, but to include that selection 1864 of algorithm in any distribution of key material and strictly enforce 1865 the matching of algorithms in the key structure to algorithms in the 1866 message structure. In addition to checking that algorithms are 1867 correct, the key form needs to be checked as well. Do not use an 1868 'EC2' key where an 'OKP' key is expected. 1870 Before using a key for transmission, or before acting on information 1871 received, a trust decision on a key needs to be made. Is the data or 1872 action something that the entity associated with the key has a right 1873 to see or a right to request? A number of factors are associated 1874 with this trust decision. Some of the ones that are highlighted here 1875 are: 1877 o What are the permissions associated with the key owner? 1879 o Is the cryptographic algorithm acceptable in the current context? 1881 o Have the restrictions associated with the key, such as algorithm 1882 or freshness, been checked and are they correct? 1884 o Is the request something that is reasonable, given the current 1885 state of the application? 1887 o Have any security considerations that are part of the message been 1888 enforced (as specified by the application or 'crit' parameter)? 1890 There are a large number of algorithms presented in this document 1891 that use nonce values. For all of the nonces defined in this 1892 document, there is some type of restriction on the nonce being a 1893 unique value either for a key or for some other conditions. In all 1894 of these cases, there is no known requirement on the nonce being both 1895 unique and unpredictable; under these circumstances, it's reasonable 1896 to use a counter for creation of the nonce. In cases where one wants 1897 the pattern of the nonce to be unpredictable as well as unique, one 1898 can use a key created for that purpose and encrypt the counter to 1899 produce the nonce value. 1901 One area that has been starting to get exposure is doing traffic 1902 analysis of encrypted messages based on the length of the message. 1903 This specification does not provide for a uniform method of providing 1904 padding as part of the message structure. An observer can 1905 distinguish between two different strings (for example, 'YES' and 1906 'NO') based on the length for all of the content encryption 1907 algorithms that are defined in this document. This means that it is 1908 up to the applications to document how content padding is to be done 1909 in order to prevent or discourage such analysis. (For example, the 1910 strings could be defined as 'YES' and 'NO '.) 1912 10. References 1914 10.1. Normative References 1916 [AES-GCM] National Institute of Standards and Technology, 1917 "Recommendation for Block Cipher Modes of Operation: 1918 Galois/Counter Mode (GCM) and GMAC", NIST Special 1919 Publication 800-38D, DOI 10.6028/NIST.SP.800-38D, November 1920 2007, . 1923 [DSS] National Institute of Standards and Technology, "Digital 1924 Signature Standard (DSS)", FIPS PUB 186-4, 1925 DOI 10.6028/NIST.FIPS.186-4, July 2013, 1926 . 1929 [I-D.schaad-cose-rfc8152bis-struct] 1930 Schaad, J., "COSE Struct", November 2019, 1931 . 1933 [MAC] National Institute of Standards and Technology, "Computer 1934 Data Authentication", FIPS PUB 113, May 1985, 1935 . 1938 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 1939 Hashing for Message Authentication", RFC 2104, 1940 DOI 10.17487/RFC2104, February 1997, 1941 . 1943 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1944 Requirement Levels", BCP 14, RFC 2119, 1945 DOI 10.17487/RFC2119, March 1997, 1946 . 1948 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 1949 (AES) Key Wrap Algorithm", RFC 3394, DOI 10.17487/RFC3394, 1950 September 2002, . 1952 [RFC3610] Whiting, D., Housley, R., and N. Ferguson, "Counter with 1953 CBC-MAC (CCM)", RFC 3610, DOI 10.17487/RFC3610, September 1954 2003, . 1956 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 1957 Key Derivation Function (HKDF)", RFC 5869, 1958 DOI 10.17487/RFC5869, May 2010, 1959 . 1961 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 1962 Curve Cryptography Algorithms", RFC 6090, 1963 DOI 10.17487/RFC6090, February 2011, 1964 . 1966 [RFC6979] Pornin, T., "Deterministic Usage of the Digital Signature 1967 Algorithm (DSA) and Elliptic Curve Digital Signature 1968 Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, August 1969 2013, . 1971 [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object 1972 Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, 1973 October 2013, . 1975 [RFC7539] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1976 Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015, 1977 . 1979 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 1980 for Security", RFC 7748, DOI 10.17487/RFC7748, January 1981 2016, . 1983 [RFC8032] Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital 1984 Signature Algorithm (EdDSA)", RFC 8032, 1985 DOI 10.17487/RFC8032, January 2017, 1986 . 1988 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1989 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1990 May 2017, . 1992 [SEC1] Certicom Research, "SEC 1: Elliptic Curve Cryptography", 1993 Standards for Efficient Cryptography, Version 2.0, May 1994 2009, . 1996 10.2. Informative References 1998 [CDDL] Vigano, C. and H. Birkholz, "CBOR data definition language 1999 (CDDL): a notational convention to express CBOR data 2000 structures", Work in Progress, draft-greevenbosch-appsawg- 2001 cbor-cddl-09, March 2017. 2003 [RFC4231] Nystrom, M., "Identifiers and Test Vectors for HMAC-SHA- 2004 224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512", 2005 RFC 4231, DOI 10.17487/RFC4231, December 2005, 2006 . 2008 [RFC4493] Song, JH., Poovendran, R., Lee, J., and T. Iwata, "The 2009 AES-CMAC Algorithm", RFC 4493, DOI 10.17487/RFC4493, June 2010 2006, . 2012 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 2013 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 2014 . 2016 [RFC5480] Turner, S., Brown, D., Yiu, K., Housley, R., and T. Polk, 2017 "Elliptic Curve Cryptography Subject Public Key 2018 Information", RFC 5480, DOI 10.17487/RFC5480, March 2009, 2019 . 2021 [RFC6151] Turner, S. and L. Chen, "Updated Security Considerations 2022 for the MD5 Message-Digest and the HMAC-MD5 Algorithms", 2023 RFC 6151, DOI 10.17487/RFC6151, March 2011, 2024 . 2026 [RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data 2027 Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 2028 2014, . 2030 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 2031 Application Protocol (CoAP)", RFC 7252, 2032 DOI 10.17487/RFC7252, June 2014, 2033 . 2035 [RFC7518] Jones, M., "JSON Web Algorithms (JWA)", RFC 7518, 2036 DOI 10.17487/RFC7518, May 2015, 2037 . 2039 [RFC8017] Moriarty, K., Ed., Kaliski, B., Jonsson, J., and A. Rusch, 2040 "PKCS #1: RSA Cryptography Specifications Version 2.2", 2041 RFC 8017, DOI 10.17487/RFC8017, November 2016, 2042 . 2044 [SP800-56A] 2045 Barker, E., Chen, L., Roginsky, A., and M. Smid, 2046 "Recommendation for Pair-Wise Key Establishment Schemes 2047 Using Discrete Logarithm Cryptography", NIST Special 2048 Publication 800-56A, Revision 2, 2049 DOI 10.6028/NIST.SP.800-56Ar2, May 2013, 2050 . 2053 Appendix A. Examples 2055 This appendix includes a set of examples that show the different 2056 features and message types that have been defined in this document. 2057 To make the examples easier to read, they are presented using the 2058 extended CBOR diagnostic notation (defined in [CDDL]) rather than as 2059 a binary dump. 2061 A GitHub project has been created at that contains not only the examples presented in this 2063 document, but a more complete set of testing examples as well. Each 2064 example is found in a JSON file that contains the inputs used to 2065 create the example, some of the intermediate values that can be used 2066 in debugging the example and the output of the example presented in 2067 both a hex and a CBOR diagnostic notation format. Some of the 2068 examples at the site are designed failure testing cases; these are 2069 clearly marked as such in the JSON file. If errors in the examples 2070 in this document are found, the examples on GitHub will be updated, 2071 and a note to that effect will be placed in the JSON file. 2073 As noted, the examples are presented using the CBOR's diagnostic 2074 notation. A Ruby-based tool exists that can convert between the 2075 diagnostic notation and binary. This tool can be installed with the 2076 command line: 2078 gem install cbor-diag 2080 The diagnostic notation can be converted into binary files using the 2081 following command line: 2083 diag2cbor.rb < inputfile > outputfile 2085 The examples can be extracted from the XML version of this document 2086 via an XPath expression as all of the artwork is tagged with the 2087 attribute type='CBORdiag'. (Depending on the XPath evaluator one is 2088 using, it may be necessary to deal with > as an entity.) 2090 //artwork[@type='CDDL']/text() 2092 A.1. Examples of Signed Messages 2094 A.1.1. Single Signature 2096 This example uses the following: 2098 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 2100 Size of binary file is 103 bytes 2101 98( 2102 [ 2103 / protected / h'', 2104 / unprotected / {}, 2105 / payload / 'This is the content.', 2106 / signatures / [ 2107 [ 2108 / protected / h'a10126' / { 2109 \ alg \ 1:-7 \ ECDSA 256 \ 2110 } / , 2111 / unprotected / { 2112 / kid / 4:'11' 2113 }, 2114 / signature / h'e2aeafd40d69d19dfe6e52077c5d7ff4e408282cbefb 2115 5d06cbf414af2e19d982ac45ac98b8544c908b4507de1e90b717c3d34816fe926a2b 2116 98f53afd2fa0f30a' 2117 ] 2118 ] 2119 ] 2120 ) 2122 A.1.2. Multiple Signers 2124 This example uses the following: 2126 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 2128 o Signature Algorithm: ECDSA w/ SHA-512, Curve P-521 2130 Size of binary file is 277 bytes 2131 98( 2132 [ 2133 / protected / h'', 2134 / unprotected / {}, 2135 / payload / 'This is the content.', 2136 / signatures / [ 2137 [ 2138 / protected / h'a10126' / { 2139 \ alg \ 1:-7 \ ECDSA 256 \ 2140 } / , 2141 / unprotected / { 2142 / kid / 4:'11' 2143 }, 2144 / signature / h'e2aeafd40d69d19dfe6e52077c5d7ff4e408282cbefb 2145 5d06cbf414af2e19d982ac45ac98b8544c908b4507de1e90b717c3d34816fe926a2b 2146 98f53afd2fa0f30a' 2147 ], 2148 [ 2149 / protected / h'a1013823' / { 2150 \ alg \ 1:-36 2151 } / , 2152 / unprotected / { 2153 / kid / 4:'bilbo.baggins@hobbiton.example' 2154 }, 2155 / signature / h'00a2d28a7c2bdb1587877420f65adf7d0b9a06635dd1 2156 de64bb62974c863f0b160dd2163734034e6ac003b01e8705524c5c4ca479a952f024 2157 7ee8cb0b4fb7397ba08d009e0c8bf482270cc5771aa143966e5a469a09f613488030 2158 c5b07ec6d722e3835adb5b2d8c44e95ffb13877dd2582866883535de3bb03d01753f 2159 83ab87bb4f7a0297' 2160 ] 2161 ] 2162 ] 2163 ) 2165 A.1.3. Counter Signature 2167 This example uses the following: 2169 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 2171 o The same parameters are used for both the signature and the 2172 counter signature. 2174 Size of binary file is 180 bytes 2175 98( 2176 [ 2177 / protected / h'', 2178 / unprotected / { 2179 / countersign / 7:[ 2180 / protected / h'a10126' / { 2181 \ alg \ 1:-7 \ ECDSA 256 \ 2182 } / , 2183 / unprotected / { 2184 / kid / 4:'11' 2185 }, 2186 / signature / h'5ac05e289d5d0e1b0a7f048a5d2b643813ded50bc9e4 2187 9220f4f7278f85f19d4a77d655c9d3b51e805a74b099e1e085aacd97fc29d72f887e 2188 8802bb6650cceb2c' 2189 ] 2190 }, 2191 / payload / 'This is the content.', 2192 / signatures / [ 2193 [ 2194 / protected / h'a10126' / { 2195 \ alg \ 1:-7 \ ECDSA 256 \ 2196 } / , 2197 / unprotected / { 2198 / kid / 4:'11' 2199 }, 2200 / signature / h'e2aeafd40d69d19dfe6e52077c5d7ff4e408282cbefb 2201 5d06cbf414af2e19d982ac45ac98b8544c908b4507de1e90b717c3d34816fe926a2b 2202 98f53afd2fa0f30a' 2203 ] 2204 ] 2205 ] 2206 ) 2208 A.1.4. Signature with Criticality 2210 This example uses the following: 2212 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 2214 o There is a criticality marker on the "reserved" header parameter 2216 Size of binary file is 125 bytes 2217 98( 2218 [ 2219 / protected / h'a2687265736572766564f40281687265736572766564' / 2220 { 2221 "reserved":false, 2222 \ crit \ 2:[ 2223 "reserved" 2224 ] 2225 } / , 2226 / unprotected / {}, 2227 / payload / 'This is the content.', 2228 / signatures / [ 2229 [ 2230 / protected / h'a10126' / { 2231 \ alg \ 1:-7 \ ECDSA 256 \ 2232 } / , 2233 / unprotected / { 2234 / kid / 4:'11' 2235 }, 2236 / signature / h'3fc54702aa56e1b2cb20284294c9106a63f91bac658d 2237 69351210a031d8fc7c5ff3e4be39445b1a3e83e1510d1aca2f2e8a7c081c7645042b 2238 18aba9d1fad1bd9c' 2239 ] 2240 ] 2241 ] 2242 ) 2244 A.2. Single Signer Examples 2246 A.2.1. Single ECDSA Signature 2248 This example uses the following: 2250 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 2252 Size of binary file is 98 bytes 2253 18( 2254 [ 2255 / protected / h'a10126' / { 2256 \ alg \ 1:-7 \ ECDSA 256 \ 2257 } / , 2258 / unprotected / { 2259 / kid / 4:'11' 2260 }, 2261 / payload / 'This is the content.', 2262 / signature / h'8eb33e4ca31d1c465ab05aac34cc6b23d58fef5c083106c4 2263 d25a91aef0b0117e2af9a291aa32e14ab834dc56ed2a223444547e01f11d3b0916e5 2264 a4c345cacb36' 2265 ] 2266 ) 2268 A.3. Examples of Enveloped Messages 2270 A.3.1. Direct ECDH 2272 This example uses the following: 2274 o CEK: AES-GCM w/ 128-bit key 2276 o Recipient class: ECDH Ephemeral-Static, Curve P-256 2278 Size of binary file is 151 bytes 2279 96( 2280 [ 2281 / protected / h'a10101' / { 2282 \ alg \ 1:1 \ AES-GCM 128 \ 2283 } / , 2284 / unprotected / { 2285 / iv / 5:h'c9cf4df2fe6c632bf7886413' 2286 }, 2287 / ciphertext / h'7adbe2709ca818fb415f1e5df66f4e1a51053ba6d65a1a0 2288 c52a357da7a644b8070a151b0', 2289 / recipients / [ 2290 [ 2291 / protected / h'a1013818' / { 2292 \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ 2293 } / , 2294 / unprotected / { 2295 / ephemeral / -1:{ 2296 / kty / 1:2, 2297 / crv / -1:1, 2298 / x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf 2299 bf054e1c7b4d91d6280', 2300 / y / -3:true 2301 }, 2302 / kid / 4:'meriadoc.brandybuck@buckland.example' 2303 }, 2304 / ciphertext / h'' 2305 ] 2306 ] 2307 ] 2308 ) 2310 A.3.2. Direct Plus Key Derivation 2312 This example uses the following: 2314 o CEK: AES-CCM w/ 128-bit key, truncate the tag to 64 bits 2316 o Recipient class: Use HKDF on a shared secret with the following 2317 implicit fields as part of the context. 2319 * salt: "aabbccddeeffgghh" 2321 * PartyU identity: "lighting-client" 2323 * PartyV identity: "lighting-server" 2325 * Supplementary Public Other: "Encryption Example 02" 2327 Size of binary file is 91 bytes 2329 96( 2330 [ 2331 / protected / h'a1010a' / { 2332 \ alg \ 1:10 \ AES-CCM-16-64-128 \ 2333 } / , 2334 / unprotected / { 2335 / iv / 5:h'89f52f65a1c580933b5261a76c' 2336 }, 2337 / ciphertext / h'753548a19b1307084ca7b2056924ed95f2e3b17006dfe93 2338 1b687b847', 2339 / recipients / [ 2340 [ 2341 / protected / h'a10129' / { 2342 \ alg \ 1:-10 2343 } / , 2344 / unprotected / { 2345 / salt / -20:'aabbccddeeffgghh', 2346 / kid / 4:'our-secret' 2347 }, 2348 / ciphertext / h'' 2349 ] 2350 ] 2351 ] 2352 ) 2354 A.3.3. Counter Signature on Encrypted Content 2356 This example uses the following: 2358 o CEK: AES-GCM w/ 128-bit key 2360 o Recipient class: ECDH Ephemeral-Static, Curve P-256 2362 Size of binary file is 326 bytes 2363 96( 2364 [ 2365 / protected / h'a10101' / { 2366 \ alg \ 1:1 \ AES-GCM 128 \ 2367 } / , 2368 / unprotected / { 2369 / iv / 5:h'c9cf4df2fe6c632bf7886413', 2370 / countersign / 7:[ 2371 / protected / h'a1013823' / { 2372 \ alg \ 1:-36 2373 } / , 2374 / unprotected / { 2375 / kid / 4:'bilbo.baggins@hobbiton.example' 2376 }, 2377 / signature / h'00929663c8789bb28177ae28467e66377da12302d7f9 2378 594d2999afa5dfa531294f8896f2b6cdf1740014f4c7f1a358e3a6cf57f4ed6fb02f 2379 cf8f7aa989f5dfd07f0700a3a7d8f3c604ba70fa9411bd10c2591b483e1d2c31de00 2380 3183e434d8fba18f17a4c7e3dfa003ac1cf3d30d44d2533c4989d3ac38c38b71481c 2381 c3430c9d65e7ddff' 2382 ] 2383 }, 2384 / ciphertext / h'7adbe2709ca818fb415f1e5df66f4e1a51053ba6d65a1a0 2385 c52a357da7a644b8070a151b0', 2386 / recipients / [ 2387 [ 2388 / protected / h'a1013818' / { 2389 \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ 2390 } / , 2391 / unprotected / { 2392 / ephemeral / -1:{ 2393 / kty / 1:2, 2394 / crv / -1:1, 2395 / x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf 2396 bf054e1c7b4d91d6280', 2397 / y / -3:true 2398 }, 2399 / kid / 4:'meriadoc.brandybuck@buckland.example' 2400 }, 2401 / ciphertext / h'' 2402 ] 2403 ] 2404 ] 2405 ) 2407 A.3.4. Encrypted Content with External Data 2409 This example uses the following: 2411 o CEK: AES-GCM w/ 128-bit key 2413 o Recipient class: ECDH static-Static, Curve P-256 with AES Key Wrap 2415 o Externally Supplied AAD: h'0011bbcc22dd44ee55ff660077' 2417 Size of binary file is 173 bytes 2419 96( 2420 [ 2421 / protected / h'a10101' / { 2422 \ alg \ 1:1 \ AES-GCM 128 \ 2423 } / , 2424 / unprotected / { 2425 / iv / 5:h'02d1f7e6f26c43d4868d87ce' 2426 }, 2427 / ciphertext / h'64f84d913ba60a76070a9a48f26e97e863e28529d8f5335 2428 e5f0165eee976b4a5f6c6f09d', 2429 / recipients / [ 2430 [ 2431 / protected / h'a101381f' / { 2432 \ alg \ 1:-32 \ ECHD-SS+A128KW \ 2433 } / , 2434 / unprotected / { 2435 / static kid / -3:'peregrin.took@tuckborough.example', 2436 / kid / 4:'meriadoc.brandybuck@buckland.example', 2437 / U nonce / -22:h'0101' 2438 }, 2439 / ciphertext / h'41e0d76f579dbd0d936a662d54d8582037de2e366fd 2440 e1c62' 2441 ] 2442 ] 2443 ] 2444 ) 2446 A.4. Examples of Encrypted Messages 2448 A.4.1. Simple Encrypted Message 2450 This example uses the following: 2452 o CEK: AES-CCM w/ 128-bit key and a 64-bit tag 2454 Size of binary file is 52 bytes 2455 16( 2456 [ 2457 / protected / h'a1010a' / { 2458 \ alg \ 1:10 \ AES-CCM-16-64-128 \ 2459 } / , 2460 / unprotected / { 2461 / iv / 5:h'89f52f65a1c580933b5261a78c' 2462 }, 2463 / ciphertext / h'5974e1b99a3a4cc09a659aa2e9e7fff161d38ce71cb45ce 2464 460ffb569' 2465 ] 2466 ) 2468 A.4.2. Encrypted Message with a Partial IV 2470 This example uses the following: 2472 o CEK: AES-CCM w/ 128-bit key and a 64-bit tag 2474 o Prefix for IV is 89F52F65A1C580933B52 2476 Size of binary file is 41 bytes 2478 16( 2479 [ 2480 / protected / h'a1010a' / { 2481 \ alg \ 1:10 \ AES-CCM-16-64-128 \ 2482 } / , 2483 / unprotected / { 2484 / partial iv / 6:h'61a7' 2485 }, 2486 / ciphertext / h'252a8911d465c125b6764739700f0141ed09192de139e05 2487 3bd09abca' 2488 ] 2489 ) 2491 A.5. Examples of MACed Messages 2493 A.5.1. Shared Secret Direct MAC 2495 This example uses the following: 2497 o MAC: AES-CMAC, 256-bit key, truncated to 64 bits 2499 o Recipient class: direct shared secret 2501 Size of binary file is 57 bytes 2502 97( 2503 [ 2504 / protected / h'a1010f' / { 2505 \ alg \ 1:15 \ AES-CBC-MAC-256//64 \ 2506 } / , 2507 / unprotected / {}, 2508 / payload / 'This is the content.', 2509 / tag / h'9e1226ba1f81b848', 2510 / recipients / [ 2511 [ 2512 / protected / h'', 2513 / unprotected / { 2514 / alg / 1:-6 / direct /, 2515 / kid / 4:'our-secret' 2516 }, 2517 / ciphertext / h'' 2518 ] 2519 ] 2520 ] 2521 ) 2523 A.5.2. ECDH Direct MAC 2525 This example uses the following: 2527 o MAC: HMAC w/SHA-256, 256-bit key 2529 o Recipient class: ECDH key agreement, two static keys, HKDF w/ 2530 context structure 2532 Size of binary file is 214 bytes 2533 97( 2534 [ 2535 / protected / h'a10105' / { 2536 \ alg \ 1:5 \ HMAC 256//256 \ 2537 } / , 2538 / unprotected / {}, 2539 / payload / 'This is the content.', 2540 / tag / h'81a03448acd3d305376eaa11fb3fe416a955be2cbe7ec96f012c99 2541 4bc3f16a41', 2542 / recipients / [ 2543 [ 2544 / protected / h'a101381a' / { 2545 \ alg \ 1:-27 \ ECDH-SS + HKDF-256 \ 2546 } / , 2547 / unprotected / { 2548 / static kid / -3:'peregrin.took@tuckborough.example', 2549 / kid / 4:'meriadoc.brandybuck@buckland.example', 2550 / U nonce / -22:h'4d8553e7e74f3c6a3a9dd3ef286a8195cbf8a23d 2551 19558ccfec7d34b824f42d92bd06bd2c7f0271f0214e141fb779ae2856abf585a583 2552 68b017e7f2a9e5ce4db5' 2553 }, 2554 / ciphertext / h'' 2555 ] 2556 ] 2557 ] 2558 ) 2560 A.5.3. Wrapped MAC 2562 This example uses the following: 2564 o MAC: AES-MAC, 128-bit key, truncated to 64 bits 2566 o Recipient class: AES Key Wrap w/ a pre-shared 256-bit key 2568 Size of binary file is 109 bytes 2569 97( 2570 [ 2571 / protected / h'a1010e' / { 2572 \ alg \ 1:14 \ AES-CBC-MAC-128//64 \ 2573 } / , 2574 / unprotected / {}, 2575 / payload / 'This is the content.', 2576 / tag / h'36f5afaf0bab5d43', 2577 / recipients / [ 2578 [ 2579 / protected / h'', 2580 / unprotected / { 2581 / alg / 1:-5 / A256KW /, 2582 / kid / 4:'018c0ae5-4d9b-471b-bfd6-eef314bc7037' 2583 }, 2584 / ciphertext / h'711ab0dc2fc4585dce27effa6781c8093eba906f227 2585 b6eb0' 2586 ] 2587 ] 2588 ] 2589 ) 2591 A.5.4. Multi-Recipient MACed Message 2593 This example uses the following: 2595 o MAC: HMAC w/ SHA-256, 128-bit key 2597 o Recipient class: Uses three different methods 2599 1. ECDH Ephemeral-Static, Curve P-521, AES Key Wrap w/ 128-bit 2600 key 2602 2. AES Key Wrap w/ 256-bit key 2604 Size of binary file is 309 bytes 2605 97( 2606 [ 2607 / protected / h'a10105' / { 2608 \ alg \ 1:5 \ HMAC 256//256 \ 2609 } / , 2610 / unprotected / {}, 2611 / payload / 'This is the content.', 2612 / tag / h'bf48235e809b5c42e995f2b7d5fa13620e7ed834e337f6aa43df16 2613 1e49e9323e', 2614 / recipients / [ 2615 [ 2616 / protected / h'a101381c' / { 2617 \ alg \ 1:-29 \ ECHD-ES+A128KW \ 2618 } / , 2619 / unprotected / { 2620 / ephemeral / -1:{ 2621 / kty / 1:2, 2622 / crv / -1:3, 2623 / x / -2:h'0043b12669acac3fd27898ffba0bcd2e6c366d53bc4db 2624 71f909a759304acfb5e18cdc7ba0b13ff8c7636271a6924b1ac63c02688075b55ef2 2625 d613574e7dc242f79c3', 2626 / y / -3:true 2627 }, 2628 / kid / 4:'bilbo.baggins@hobbiton.example' 2629 }, 2630 / ciphertext / h'339bc4f79984cdc6b3e6ce5f315a4c7d2b0ac466fce 2631 a69e8c07dfbca5bb1f661bc5f8e0df9e3eff5' 2632 ], 2633 [ 2634 / protected / h'', 2635 / unprotected / { 2636 / alg / 1:-5 / A256KW /, 2637 / kid / 4:'018c0ae5-4d9b-471b-bfd6-eef314bc7037' 2638 }, 2639 / ciphertext / h'0b2c7cfce04e98276342d6476a7723c090dfdd15f9a 2640 518e7736549e998370695e6d6a83b4ae507bb' 2641 ] 2642 ] 2643 ] 2644 ) 2646 A.6. Examples of MAC0 Messages 2648 A.6.1. Shared Secret Direct MAC 2650 This example uses the following: 2652 o MAC: AES-CMAC, 256-bit key, truncated to 64 bits 2653 o Recipient class: direct shared secret 2655 Size of binary file is 37 bytes 2657 17( 2658 [ 2659 / protected / h'a1010f' / { 2660 \ alg \ 1:15 \ AES-CBC-MAC-256//64 \ 2661 } / , 2662 / unprotected / {}, 2663 / payload / 'This is the content.', 2664 / tag / h'726043745027214f' 2665 ] 2666 ) 2668 Note that this example uses the same inputs as Appendix A.5.1. 2670 A.7. COSE Keys 2672 A.7.1. Public Keys 2674 This is an example of a COSE Key Set. This example includes the 2675 public keys for all of the previous examples. 2677 In order the keys are: 2679 o An EC key with a kid of "meriadoc.brandybuck@buckland.example" 2681 o An EC key with a kid of "peregrin.took@tuckborough.example" 2683 o An EC key with a kid of "bilbo.baggins@hobbiton.example" 2685 o An EC key with a kid of "11" 2687 Size of binary file is 481 bytes 2689 [ 2690 { 2691 -1:1, 2692 -2:h'65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c0 2693 8551d', 2694 -3:h'1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd008 2695 4d19c', 2696 1:2, 2697 2:'meriadoc.brandybuck@buckland.example' 2698 }, 2699 { 2700 -1:1, 2701 -2:h'bac5b11cad8f99f9c72b05cf4b9e26d244dc189f745228255a219a86d6a 2702 09eff', 2703 -3:h'20138bf82dc1b6d562be0fa54ab7804a3a64b6d72ccfed6b6fb6ed28bbf 2704 c117e', 2705 1:2, 2706 2:'11' 2707 }, 2708 { 2709 -1:3, 2710 -2:h'0072992cb3ac08ecf3e5c63dedec0d51a8c1f79ef2f82f94f3c737bf5de 2711 7986671eac625fe8257bbd0394644caaa3aaf8f27a4585fbbcad0f2457620085e5c8 2712 f42ad', 2713 -3:h'01dca6947bce88bc5790485ac97427342bc35f887d86d65a089377e247e 2714 60baa55e4e8501e2ada5724ac51d6909008033ebc10ac999b9d7f5cc2519f3fe1ea1 2715 d9475', 2716 1:2, 2717 2:'bilbo.baggins@hobbiton.example' 2718 }, 2719 { 2720 -1:1, 2721 -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbfbf054e1c7b4d91 2722 d6280', 2723 -3:h'f01400b089867804b8e9fc96c3932161f1934f4223069170d924b7e03bf 2724 822bb', 2725 1:2, 2726 2:'peregrin.took@tuckborough.example' 2727 } 2728 ] 2730 A.7.2. Private Keys 2732 This is an example of a COSE Key Set. This example includes the 2733 private keys for all of the previous examples. 2735 In order the keys are: 2737 o An EC key with a kid of "meriadoc.brandybuck@buckland.example" 2739 o A shared-secret key with a kid of "our-secret" 2741 o An EC key with a kid of "peregrin.took@tuckborough.example" 2743 o A shared-secret key with a kid of "018c0ae5-4d9b-471b- 2744 bfd6-eef314bc7037" 2746 o An EC key with a kid of "bilbo.baggins@hobbiton.example" 2748 o An EC key with a kid of "11" 2750 Size of binary file is 816 bytes 2752 [ 2753 { 2754 1:2, 2755 2:'meriadoc.brandybuck@buckland.example', 2756 -1:1, 2757 -2:h'65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c0 2758 8551d', 2759 -3:h'1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd008 2760 4d19c', 2761 -4:h'aff907c99f9ad3aae6c4cdf21122bce2bd68b5283e6907154ad911840fa 2762 208cf' 2763 }, 2764 { 2765 1:2, 2766 2:'11', 2767 -1:1, 2768 -2:h'bac5b11cad8f99f9c72b05cf4b9e26d244dc189f745228255a219a86d6a 2769 09eff', 2770 -3:h'20138bf82dc1b6d562be0fa54ab7804a3a64b6d72ccfed6b6fb6ed28bbf 2771 c117e', 2772 -4:h'57c92077664146e876760c9520d054aa93c3afb04e306705db609030850 2773 7b4d3' 2774 }, 2775 { 2776 1:2, 2777 2:'bilbo.baggins@hobbiton.example', 2778 -1:3, 2779 -2:h'0072992cb3ac08ecf3e5c63dedec0d51a8c1f79ef2f82f94f3c737bf5de 2780 7986671eac625fe8257bbd0394644caaa3aaf8f27a4585fbbcad0f2457620085e5c8 2781 f42ad', 2782 -3:h'01dca6947bce88bc5790485ac97427342bc35f887d86d65a089377e247e 2783 60baa55e4e8501e2ada5724ac51d6909008033ebc10ac999b9d7f5cc2519f3fe1ea1 2784 d9475', 2785 -4:h'00085138ddabf5ca975f5860f91a08e91d6d5f9a76ad4018766a476680b 2786 55cd339e8ab6c72b5facdb2a2a50ac25bd086647dd3e2e6e99e84ca2c3609fdf177f 2787 eb26d' 2788 }, 2789 { 2790 1:4, 2791 2:'our-secret', 2792 -1:h'849b57219dae48de646d07dbb533566e976686457c1491be3a76dcea6c4 2793 27188' 2794 }, 2795 { 2796 1:2, 2797 -1:1, 2798 2:'peregrin.took@tuckborough.example', 2799 -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbfbf054e1c7b4d91 2800 d6280', 2801 -3:h'f01400b089867804b8e9fc96c3932161f1934f4223069170d924b7e03bf 2802 822bb', 2803 -4:h'02d1f7e6f26c43d4868d87ceb2353161740aacf1f7163647984b522a848 2804 df1c3' 2805 }, 2806 { 2807 1:4, 2808 2:'our-secret2', 2809 -1:h'849b5786457c1491be3a76dcea6c4271' 2810 }, 2811 { 2812 1:4, 2813 2:'018c0ae5-4d9b-471b-bfd6-eef314bc7037', 2814 -1:h'849b57219dae48de646d07dbb533566e976686457c1491be3a76dcea6c4 2815 27188' 2816 } 2817 ] 2819 Acknowledgments 2821 This document is a product of the COSE working group of the IETF. 2823 The following individuals are to blame for getting me started on this 2824 project in the first place: Richard Barnes, Matt Miller, and Martin 2825 Thomson. 2827 The initial version of the specification was based to some degree on 2828 the outputs of the JOSE and S/MIME working groups. 2830 The following individuals provided input into the final form of the 2831 document: Carsten Bormann, John Bradley, Brain Campbell, Michael B. 2833 Jones, Ilari Liusvaara, Francesca Palombini, Ludwig Seitz, and Goran 2834 Selander. 2836 Author's Address 2838 Jim Schaad 2839 August Cellars 2841 Email: ietf@augustcellars.com