idnits 2.17.1 draft-ietf-cose-rfc8152bis-algs-09.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.ietf-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 (2 June 2020) is 1425 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '2' on line 1818 -- Looks like a reference, but probably isn't: '1' on line 1822 -- Looks like a reference, but probably isn't: '4' on line 1822 == Outdated reference: A later version (-15) exists of draft-ietf-cose-rfc8152bis-struct-09 -- Possible downref: Normative reference to a draft: ref. 'I-D.ietf-cose-rfc8152bis-struct' ** 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) ** Downref: Normative reference to an Informational RFC: RFC 8439 ** Downref: Normative reference to an Informational RFC: RFC 7748 -- Possible downref: Non-RFC (?) normative reference: ref. 'AES-GCM' -- Possible downref: Non-RFC (?) normative reference: ref. 'DSS' -- Possible downref: Non-RFC (?) normative reference: ref. 'MAC' -- Possible downref: Non-RFC (?) normative reference: ref. 'SEC1' ** Downref: Normative reference to an Informational RFC: RFC 8032 -- Obsolete informational reference (is this intentional?): RFC 8152 (Obsoleted by RFC 9052, RFC 9053) == Outdated reference: A later version (-21) exists of draft-ietf-core-oscore-groupcomm-08 Summary: 11 errors (**), 0 flaws (~~), 3 warnings (==), 10 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) 2 June 2020 5 Intended status: Standards Track 6 Expires: 4 December 2020 8 CBOR Object Signing and Encryption (COSE): Initial Algorithms 9 draft-ietf-cose-rfc8152bis-algs-09 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.ietf-cose-rfc8152bis-struct]. 26 This document along with [I-D.ietf-cose-rfc8152bis-struct] obsoletes 27 RFC8152. 29 Contributing to this document 31 This note is to be removed before publishing as an RFC. 33 The source for this draft is being maintained in GitHub. Suggested 34 changes should be submitted as pull requests at https://github.com/ 35 cose-wg/cose-rfc8152bis. Instructions are on that page as well. 36 Editorial changes can be managed in GitHub, but any substantial 37 issues need to be discussed on the COSE mailing list. 39 Status of This Memo 41 This Internet-Draft is submitted in full conformance with the 42 provisions of BCP 78 and BCP 79. 44 Internet-Drafts are working documents of the Internet Engineering 45 Task Force (IETF). Note that other groups may also distribute 46 working documents as Internet-Drafts. The list of current Internet- 47 Drafts is at https://datatracker.ietf.org/drafts/current/. 49 Internet-Drafts are draft documents valid for a maximum of six months 50 and may be updated, replaced, or obsoleted by other documents at any 51 time. It is inappropriate to use Internet-Drafts as reference 52 material or to cite them other than as "work in progress." 54 This Internet-Draft will expire on 4 December 2020. 56 Copyright Notice 58 Copyright (c) 2020 IETF Trust and the persons identified as the 59 document authors. All rights reserved. 61 This document is subject to BCP 78 and the IETF Trust's Legal 62 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 63 license-info) in effect on the date of publication of this document. 64 Please review these documents carefully, as they describe your rights 65 and restrictions with respect to this document. Code Components 66 extracted from this document must include Simplified BSD License text 67 as described in Section 4.e of the Trust Legal Provisions and are 68 provided without warranty as described in the Simplified BSD License. 70 Table of Contents 72 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 73 1.1. Requirements Terminology . . . . . . . . . . . . . . . . 4 74 1.2. Changes from RFC8152 . . . . . . . . . . . . . . . . . . 4 75 1.3. Document Terminology . . . . . . . . . . . . . . . . . . 4 76 1.4. CBOR Grammar . . . . . . . . . . . . . . . . . . . . . . 5 77 1.5. Examples . . . . . . . . . . . . . . . . . . . . . . . . 5 78 2. Signature Algorithms . . . . . . . . . . . . . . . . . . . . 5 79 2.1. ECDSA . . . . . . . . . . . . . . . . . . . . . . . . . . 5 80 2.1.1. Security Considerations . . . . . . . . . . . . . . . 7 81 2.2. Edwards-Curve Digital Signature Algorithms (EdDSAs) . . . 8 82 2.2.1. Security Considerations . . . . . . . . . . . . . . . 9 83 3. Message Authentication Code (MAC) Algorithms . . . . . . . . 9 84 3.1. Hash-Based Message Authentication Codes (HMACs) . . . . . 9 85 3.1.1. Security Considerations . . . . . . . . . . . . . . . 11 86 3.2. AES Message Authentication Code (AES-CBC-MAC) . . . . . . 11 87 3.2.1. Security Considerations . . . . . . . . . . . . . . . 12 88 4. Content Encryption Algorithms . . . . . . . . . . . . . . . . 12 89 4.1. AES GCM . . . . . . . . . . . . . . . . . . . . . . . . . 12 90 4.1.1. Security Considerations . . . . . . . . . . . . . . . 13 91 4.2. AES CCM . . . . . . . . . . . . . . . . . . . . . . . . . 14 92 4.2.1. Security Considerations . . . . . . . . . . . . . . . 17 93 4.3. ChaCha20 and Poly1305 . . . . . . . . . . . . . . . . . . 18 94 4.3.1. Security Considerations . . . . . . . . . . . . . . . 18 95 5. Key Derivation Functions (KDFs) . . . . . . . . . . . . . . . 19 96 5.1. HMAC-Based Extract-and-Expand Key Derivation Function 97 (HKDF) . . . . . . . . . . . . . . . . . . . . . . . . . 19 98 5.2. Context Information Structure . . . . . . . . . . . . . . 21 99 6. Content Key Distribution Methods . . . . . . . . . . . . . . 26 100 6.1. Direct Encryption . . . . . . . . . . . . . . . . . . . . 26 101 6.1.1. Direct Key . . . . . . . . . . . . . . . . . . . . . 27 102 6.1.2. Direct Key with KDF . . . . . . . . . . . . . . . . . 28 103 6.2. AES Key Wrap . . . . . . . . . . . . . . . . . . . . . . 29 104 6.2.1. Security Considerations for AES-KW . . . . . . . . . 30 105 6.3. Direct ECDH . . . . . . . . . . . . . . . . . . . . . . . 30 106 6.3.1. Security Considerations . . . . . . . . . . . . . . . 34 107 6.4. ECDH with Key Wrap . . . . . . . . . . . . . . . . . . . 34 108 7. Key Object Parameters . . . . . . . . . . . . . . . . . . . . 36 109 7.1. Elliptic Curve Keys . . . . . . . . . . . . . . . . . . . 36 110 7.1.1. Double Coordinate Curves . . . . . . . . . . . . . . 37 111 7.2. Octet Key Pair . . . . . . . . . . . . . . . . . . . . . 38 112 7.3. Symmetric Keys . . . . . . . . . . . . . . . . . . . . . 39 113 8. COSE Capabilities . . . . . . . . . . . . . . . . . . . . . . 40 114 8.1. Assignments for Existing Key Types . . . . . . . . . . . 40 115 8.2. Assignments for Existing Algorithms . . . . . . . . . . . 41 116 8.3. Examples . . . . . . . . . . . . . . . . . . . . . . . . 41 117 9. CBOR Encoding Restrictions . . . . . . . . . . . . . . . . . 42 118 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 42 119 10.1. Changes to "COSE Key Types" registry. . . . . . . . . . 42 120 10.2. Changes to "COSE Algorithms" registry . . . . . . . . . 43 121 10.3. Changes to the "COSE Key Type Parameters" registry . . . 43 122 11. Security Considerations . . . . . . . . . . . . . . . . . . . 44 123 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 46 124 12.1. Normative References . . . . . . . . . . . . . . . . . . 46 125 12.2. Informative References . . . . . . . . . . . . . . . . . 48 126 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 50 127 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 50 129 1. Introduction 131 There has been an increased focus on small, constrained devices that 132 make up the Internet of Things (IoT). One of the standards that has 133 come out of this process is "Concise Binary Object Representation 134 (CBOR)" [RFC7049]. CBOR extended the data model of the JavaScript 135 Object Notation (JSON) [RFC8259] by allowing for binary data, among 136 other changes. CBOR is being adopted by several of the IETF working 137 groups dealing with the IoT world as their encoding of data 138 structures. CBOR was designed specifically to be both small in terms 139 of messages transport and implementation size and be a schema-free 140 decoder. A need exists to provide message security services for IoT, 141 and using CBOR as the message-encoding format makes sense. 143 The core COSE specification consists of two documents. 144 [I-D.ietf-cose-rfc8152bis-struct] contains the serialization 145 structures and the procedures for using the different cryptographic 146 algorithms. This document provides an initial set of algorithms for 147 use with those structures. Additional algorithms beyond what are in 148 this document are defined elsewhere. 150 1.1. Requirements Terminology 152 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 153 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 154 "OPTIONAL" in this document are to be interpreted as described in BCP 155 14 [RFC2119] [RFC8174] when, and only when, they appear in all 156 capitals, as shown here. 158 1.2. Changes from RFC8152 160 * Extract the sections dealing with specific algorithms into this 161 document. The sections dealing with structure and general 162 processing rules are placed in [I-D.ietf-cose-rfc8152bis-struct]. 164 * Text clarifications and changes in terminology. 166 1.3. Document Terminology 168 In this document, we use the following terminology: 170 Byte is a synonym for octet. 172 Constrained Application Protocol (CoAP) is a specialized web transfer 173 protocol for use in constrained systems. It is defined in [RFC7252]. 175 Authenticated Encryption (AE) [RFC5116] algorithms are those 176 encryption algorithms that provide an authentication check of the 177 plain text contents as part of the encryption service. 179 Authenticated Encryption with Associated Data (AEAD) [RFC5116] 180 algorithms provide the same content authentication service as AE 181 algorithms, but they additionally provide for authentication of non- 182 encrypted data as well. 184 The term 'byte string' is used for sequences of bytes, while the term 185 'text string' is used for sequences of characters. 187 The tables for algorithms contain the following columns: 189 * A name for use in documents for the algorithms. 191 * The value used on the wire for the algorithm. One place this is 192 used is the algorithm header parameter of a message. 194 * A short description so that the algorithm can be easily identified 195 when scanning the IANA registry. 197 Additional columns may be present in the table depending on the 198 algorithms. 200 1.4. CBOR Grammar 202 At the time that [RFC8152] was initially published, the CBOR Data 203 Definition Language (CDDL) [RFC8610] had not yet been published. 204 This document uses a variant of CDDL which is described in 205 [I-D.ietf-cose-rfc8152bis-struct] 207 1.5. Examples 209 A GitHub project has been created at that contains a set of testing examples as well. Each 211 example is found in a JSON file that contains the inputs used to 212 create the example, some of the intermediate values that can be used 213 for debugging, and the output of the example. The results are 214 encoded using both hexadecimal and CBOR diagnostic notation format. 216 Some of the examples are designed to test failure case; these are 217 clearly marked as such in the JSON file. If errors in the examples 218 in this document are found, the examples on GitHub will be updated, 219 and a note to that effect will be placed in the JSON file. 221 2. Signature Algorithms 223 Part Section 9.1 of [I-D.ietf-cose-rfc8152bis-struct] contains a 224 generic description of signature algorithms. The document defines 225 signature algorithm identifiers for two signature algorithms. 227 2.1. ECDSA 229 ECDSA [DSS] defines a signature algorithm using ECC. Implementations 230 SHOULD use a deterministic version of ECDSA such as the one defined 231 in [RFC6979]. The use of a deterministic signature algorithm allows 232 for systems to avoid relying on random number generators in order to 233 avoid generating the same value of 'k' (the per-message random 234 value). Biased generation of the value 'k' can be attacked, and 235 collisions of this value leads to leaked keys. It additionally 236 allows for doing deterministic tests for the signature algorithm. 237 The use of deterministic ECDSA does not lessen the need to have good 238 random number generation when creating the private key. 240 The ECDSA signature algorithm is parameterized with a hash function 241 (h). In the event that the length of the hash function output is 242 greater than the group of the key, the leftmost bytes of the hash 243 output are used. 245 The algorithms defined in this document can be found in Table 1. 247 +-------+-------+---------+------------------+ 248 | Name | Value | Hash | Description | 249 +=======+=======+=========+==================+ 250 | ES256 | -7 | SHA-256 | ECDSA w/ SHA-256 | 251 +-------+-------+---------+------------------+ 252 | ES384 | -35 | SHA-384 | ECDSA w/ SHA-384 | 253 +-------+-------+---------+------------------+ 254 | ES512 | -36 | SHA-512 | ECDSA w/ SHA-512 | 255 +-------+-------+---------+------------------+ 257 Table 1: ECDSA Algorithm Values 259 This document defines ECDSA to work only with the curves P-256, 260 P-384, and P-521. This document requires that the curves be encoded 261 using the 'EC2' (2 coordinate elliptic curve) key type. 262 Implementations need to check that the key type and curve are correct 263 when creating and verifying a signature. Other documents can define 264 it to work with other curves and points in the future. 266 In order to promote interoperability, it is suggested that SHA-256 be 267 used only with curve P-256, SHA-384 be used only with curve P-384, 268 and SHA-512 be used with curve P-521. This is aligned with the 269 recommendation in Section 4 of [RFC5480]. 271 The signature algorithm results in a pair of integers (R, S). These 272 integers will be the same length as the length of the key used for 273 the signature process. The signature is encoded by converting the 274 integers into byte strings of the same length as the key size. The 275 length is rounded up to the nearest byte and is left padded with zero 276 bits to get to the correct length. The two integers are then 277 concatenated together to form a byte string that is the resulting 278 signature. 280 Using the function defined in [RFC8017], the signature is: 282 Signature = I2OSP(R, n) | I2OSP(S, n) 284 where n = ceiling(key_length / 8) 286 When using a COSE key for this algorithm, the following checks are 287 made: 289 * The 'kty' field MUST be present, and it MUST be 'EC2'. 291 * If the 'alg' field is present, it MUST match the ECDSA signature 292 algorithm being used. 294 * If the 'key_ops' field is present, it MUST include 'sign' when 295 creating an ECDSA signature. 297 * If the 'key_ops' field is present, it MUST include 'verify' when 298 verifying an ECDSA signature. 300 2.1.1. Security Considerations 302 The security strength of the signature is no greater than the minimum 303 of the security strength associated with the bit length of the key 304 and the security strength of the hash function. 306 Note: Use of a deterministic signature technique is a good idea even 307 when good random number generation exists. Doing so both reduces the 308 possibility of having the same value of 'k' in two signature 309 operations and allows for reproducible signature values, which helps 310 testing. 312 There are two substitution attacks that can theoretically be mounted 313 against the ECDSA signature algorithm. 315 * Changing the curve used to validate the signature: If one changes 316 the curve used to validate the signature, then potentially one 317 could have two messages with the same signature, each computed 318 under a different curve. The only requirement on the new curve is 319 that its order be the same as the old one and it be acceptable to 320 the client. An example would be to change from using the curve 321 secp256r1 (aka P-256) to using secp256k1. (Both are 256-bit 322 curves.) We currently do not have any way to deal with this 323 version of the attack except to restrict the overall set of curves 324 that can be used. 326 * Change the hash function used to validate the signature: If one 327 either has two different hash functions of the same length or can 328 truncate a hash function down, then one could potentially find 329 collisions between the hash functions rather than within a single 330 hash function (for example, truncating SHA-512 to 256 bits might 331 collide with a SHA-256 bit hash value). As the hash algorithm is 332 part of the signature algorithm identifier, this attack is 333 mitigated by including a signature algorithm identifier in the 334 protected header bucket. 336 2.2. Edwards-Curve Digital Signature Algorithms (EdDSAs) 338 [RFC8032] describes the elliptic curve signature scheme Edwards-curve 339 Digital Signature Algorithm (EdDSA). In that document, the signature 340 algorithm is instantiated using parameters for edwards25519 and 341 edwards448 curves. The document additionally describes two variants 342 of the EdDSA algorithm: Pure EdDSA, where no hash function is applied 343 to the content before signing, and HashEdDSA, where a hash function 344 is applied to the content before signing and the result of that hash 345 function is signed. For EdDSA, the content to be signed (either the 346 message or the pre-hash value) is processed twice inside of the 347 signature algorithm. For use with COSE, only the pure EdDSA version 348 is used. This is because it is not expected that extremely large 349 contents are going to be needed and, based on the arrangement of the 350 message structure, the entire message is going to need to be held in 351 memory in order to create or verify a signature. This means that 352 there does not appear to be a need to be able to do block updates of 353 the hash, followed by eliminating the message from memory. 354 Applications can provide the same features by defining the content of 355 the message as a hash value and transporting the COSE object (with 356 the hash value) and the content as separate items. 358 The algorithms defined in this document can be found in Table 2. A 359 single signature algorithm is defined, which can be used for multiple 360 curves. 362 +-------+-------+-------------+ 363 | Name | Value | Description | 364 +=======+=======+=============+ 365 | EdDSA | -8 | EdDSA | 366 +-------+-------+-------------+ 368 Table 2: EdDSA Algorithm Values 370 [RFC8032] describes the method of encoding the signature value. 372 When using a COSE key for this algorithm, the following checks are 373 made: 375 * The 'kty' field MUST be present, and it MUST be 'OKP' (Octet Key 376 Pair). 378 * The 'crv' field MUST be present, and it MUST be a curve defined 379 for this signature algorithm. 381 * If the 'alg' field is present, it MUST match 'EdDSA'. 383 * If the 'key_ops' field is present, it MUST include 'sign' when 384 creating an EdDSA signature. 386 * If the 'key_ops' field is present, it MUST include 'verify' when 387 verifying an EdDSA signature. 389 2.2.1. Security Considerations 391 How public values are computed is not the same when looking at EdDSA 392 and Elliptic Curve Diffie-Hellman (ECDH); for this reason, they 393 should not be used with the other algorithm. 395 If batch signature verification is performed, a well-seeded 396 cryptographic random number generator is REQUIRED. Signing and non- 397 batch signature verification are deterministic operations and do not 398 need random numbers of any kind. 400 3. Message Authentication Code (MAC) Algorithms 402 Part Section 9.2 of [I-D.ietf-cose-rfc8152bis-struct] contains a 403 generic description of MAC algorithms. This section defines the 404 conventions for two MAC algorithms. 406 3.1. Hash-Based Message Authentication Codes (HMACs) 408 HMAC [RFC2104] [RFC4231] was designed to deal with length extension 409 attacks. The algorithm was also designed to allow for new hash 410 algorithms to be directly plugged in without changes to the hash 411 function. The HMAC design process has been shown as solid since, 412 while the security of hash algorithms such as MD5 has decreased over 413 time; the security of HMAC combined with MD5 has not yet been shown 414 to be compromised [RFC6151]. 416 The HMAC algorithm is parameterized by an inner and outer padding, a 417 hash function (h), and an authentication tag value length. For this 418 specification, the inner and outer padding are fixed to the values 419 set in [RFC2104]. The length of the authentication tag corresponds 420 to the difficulty of producing a forgery. For use in constrained 421 environments, we define one HMAC algorithm that is truncated. There 422 are currently no known issues with truncation; however, the security 423 strength of the message tag is correspondingly reduced in strength. 424 When truncating, the leftmost tag length bits are kept and 425 transmitted. 427 The algorithms defined in this document can be found in Table 3. 429 +-------------+-------+---------+------------+----------------------+ 430 | Name | Value | Hash | Tag Length | Description | 431 +=============+=======+=========+============+======================+ 432 | HMAC | 4 | SHA-256 | 64 | HMAC w/ SHA-256 | 433 | 256/64 | | | | truncated to 64 bits | 434 +-------------+-------+---------+------------+----------------------+ 435 | HMAC | 5 | SHA-256 | 256 | HMAC w/ SHA-256 | 436 | 256/256 | | | | | 437 +-------------+-------+---------+------------+----------------------+ 438 | HMAC | 6 | SHA-384 | 384 | HMAC w/ SHA-384 | 439 | 384/384 | | | | | 440 +-------------+-------+---------+------------+----------------------+ 441 | HMAC | 7 | SHA-512 | 512 | HMAC w/ SHA-512 | 442 | 512/512 | | | | | 443 +-------------+-------+---------+------------+----------------------+ 445 Table 3: HMAC Algorithm Values 447 Some recipient algorithms transport the key, while others derive a 448 key from secret data. For those algorithms that transport the key 449 (such as AES Key Wrap), the size of the HMAC key SHOULD be the same 450 size as the underlying hash function. For those algorithms that 451 derive the key (such as ECDH), the derived key MUST be the same size 452 as the underlying hash function. 454 When using a COSE key for this algorithm, the following checks are 455 made: 457 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 459 * If the 'alg' field is present, it MUST match the HMAC algorithm 460 being used. 462 * If the 'key_ops' field is present, it MUST include 'MAC create' 463 when creating an HMAC authentication tag. 465 * If the 'key_ops' field is present, it MUST include 'MAC verify' 466 when verifying an HMAC authentication tag. 468 Implementations creating and validating MAC values MUST validate that 469 the key type, key length, and algorithm are correct and appropriate 470 for the entities involved. 472 3.1.1. Security Considerations 474 HMAC has proved to be resistant to attack even when used with 475 weakened hash algorithms. The current best known attack is to brute 476 force the key. This means that key size is going to be directly 477 related to the security of an HMAC operation. 479 3.2. AES Message Authentication Code (AES-CBC-MAC) 481 AES-CBC-MAC is defined in [MAC]. (Note that this is not the same 482 algorithm as AES Cipher-Based Message Authentication Code (AES-CMAC) 483 [RFC4493].) 485 AES-CBC-MAC is parameterized by the key length, the authentication 486 tag length, and the IV used. For all of these algorithms, the IV is 487 fixed to all zeros. We provide an array of algorithms for various 488 key lengths and tag lengths. The algorithms defined in this document 489 are found in Table 4. 491 +---------+-------+------------+------------+------------------+ 492 | Name | Value | Key Length | Tag Length | Description | 493 +=========+=======+============+============+==================+ 494 | AES-MAC | 14 | 128 | 64 | AES-MAC 128-bit | 495 | 128/64 | | | | key, 64-bit tag | 496 +---------+-------+------------+------------+------------------+ 497 | AES-MAC | 15 | 256 | 64 | AES-MAC 256-bit | 498 | 256/64 | | | | key, 64-bit tag | 499 +---------+-------+------------+------------+------------------+ 500 | AES-MAC | 25 | 128 | 128 | AES-MAC 128-bit | 501 | 128/128 | | | | key, 128-bit tag | 502 +---------+-------+------------+------------+------------------+ 503 | AES-MAC | 26 | 256 | 128 | AES-MAC 256-bit | 504 | 256/128 | | | | key, 128-bit tag | 505 +---------+-------+------------+------------+------------------+ 507 Table 4: AES-MAC Algorithm Values 509 Keys may be obtained either from a key structure or from a recipient 510 structure. Implementations creating and validating MAC values MUST 511 validate that the key type, key length, and algorithm are correct and 512 appropriate for the entities involved. 514 When using a COSE key for this algorithm, the following checks are 515 made: 517 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 519 * If the 'alg' field is present, it MUST match the AES-MAC algorithm 520 being used. 522 * If the 'key_ops' field is present, it MUST include 'MAC create' 523 when creating an AES-MAC authentication tag. 525 * If the 'key_ops' field is present, it MUST include 'MAC verify' 526 when verifying an AES-MAC authentication tag. 528 3.2.1. Security Considerations 530 A number of attacks exist against Cipher Block Chaining Message 531 Authentication Code (CBC-MAC) that need to be considered. 533 * A single key must only be used for messages of a fixed or known 534 length. If this is not the case, an attacker will be able to 535 generate a message with a valid tag given two message and tag 536 pairs. This can be addressed by using different keys for messages 537 of different lengths. The current structure mitigates this 538 problem, as a specific encoding structure that includes lengths is 539 built and signed. (CMAC also addresses this issue.) 541 * Cipher Block Chaining (CBC) mode, if the same key is used for both 542 encryption and authentication operations, an attacker can produce 543 messages with a valid authentication code. 545 * If the IV can be modified, then messages can be forged. This is 546 addressed by fixing the IV to all zeros. 548 4. Content Encryption Algorithms 550 Part Section 9.3 of [I-D.ietf-cose-rfc8152bis-struct] contains a 551 generic description of Content Encryption algorithms. This document 552 defines the identifier and usages for three content encryption 553 algorithms. 555 4.1. AES GCM 557 The Galois/Counter Mode (GCM) mode is a generic authenticated 558 encryption block cipher mode defined in [AES-GCM]. The GCM mode is 559 combined with the AES block encryption algorithm to define an AEAD 560 cipher. 562 The GCM mode is parameterized by the size of the authentication tag 563 and the size of the nonce. This document fixes the size of the nonce 564 at 96 bits. The size of the authentication tag is limited to a small 565 set of values. For this document however, the size of the 566 authentication tag is fixed at 128 bits. 568 The set of algorithms defined in this document are in Table 5. 570 +---------+-------+------------------------------------------+ 571 | Name | Value | Description | 572 +=========+=======+==========================================+ 573 | A128GCM | 1 | AES-GCM mode w/ 128-bit key, 128-bit tag | 574 +---------+-------+------------------------------------------+ 575 | A192GCM | 2 | AES-GCM mode w/ 192-bit key, 128-bit tag | 576 +---------+-------+------------------------------------------+ 577 | A256GCM | 3 | AES-GCM mode w/ 256-bit key, 128-bit tag | 578 +---------+-------+------------------------------------------+ 580 Table 5: Algorithm Value for AES-GCM 582 Keys may be obtained either from a key structure or from a recipient 583 structure. Implementations encrypting and decrypting MUST validate 584 that the key type, key length, and algorithm are correct and 585 appropriate for the entities involved. 587 When using a COSE key for this algorithm, the following checks are 588 made: 590 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 592 * If the 'alg' field is present, it MUST match the AES-GCM algorithm 593 being used. 595 * If the 'key_ops' field is present, it MUST include 'encrypt' or 596 'wrap key' when encrypting. 598 * If the 'key_ops' field is present, it MUST include 'decrypt' or 599 'unwrap key' when decrypting. 601 4.1.1. Security Considerations 603 When using AES-GCM, the following restrictions MUST be enforced: 605 * The key and nonce pair MUST be unique for every message encrypted. 607 * The total amount of data encrypted for a single key MUST NOT 608 exceed 2^39 - 256 bits. An explicit check is required only in 609 environments where it is expected that it might be exceeded. 611 Consideration was given to supporting smaller tag values; the 612 constrained community would desire tag sizes in the 64-bit range. 613 Doing so drastically changes both the maximum messages size 614 (generally not an issue) and the number of times that a key can be 615 used. Given that Counter with CBC-MAC (CCM) is the usual mode for 616 constrained environments, restricted modes are not supported. 618 4.2. AES CCM 620 CCM is a generic authentication encryption block cipher mode defined 621 in [RFC3610]. The CCM mode is combined with the AES block encryption 622 algorithm to define a commonly used content encryption algorithm used 623 in constrained devices. 625 The CCM mode has two parameter choices. The first choice is M, the 626 size of the authentication field. The choice of the value for M 627 involves a trade-off between message growth (from the tag) and the 628 probability that an attacker can undetectably modify a message. The 629 second choice is L, the size of the length field. This value 630 requires a trade-off between the maximum message size and the size of 631 the Nonce. 633 It is unfortunate that the specification for CCM specified L and M as 634 a count of bytes rather than a count of bits. This leads to possible 635 misunderstandings where AES-CCM-8 is frequently used to refer to a 636 version of CCM mode where the size of the authentication is 64 bits 637 and not 8 bits. These values have traditionally been specified as 638 bit counts rather than byte counts. This document will follow the 639 convention of using bit counts so that it is easier to compare the 640 different algorithms presented in this document. 642 We define a matrix of algorithms in this document over the values of 643 L and M. Constrained devices are usually operating in situations 644 where they use short messages and want to avoid doing recipient- 645 specific cryptographic operations. This favors smaller values of 646 both L and M. Less-constrained devices will want to be able to use 647 larger messages and are more willing to generate new keys for every 648 operation. This favors larger values of L and M. 650 The following values are used for L: 652 16 bits (2): This limits messages to 2^16 bytes (64 KiB) in length. 653 This is sufficiently long for messages in the constrained world. 654 The nonce length is 13 bytes allowing for 2^104 possible values of 655 the nonce without repeating. 657 64 bits (8): This limits messages to 2^64 bytes in length. The 658 nonce length is 7 bytes allowing for 2^56 possible values of the 659 nonce without repeating. 661 The following values are used for M: 663 64 bits (8): This produces a 64-bit authentication tag. This 664 implies that there is a 1 in 2^64 chance that a modified message 665 will authenticate. 667 128 bits (16): This produces a 128-bit authentication tag. This 668 implies that there is a 1 in 2^128 chance that a modified message 669 will authenticate. 671 +--------------------+-------+----+-----+--------+---------------+ 672 | Name | Value | L | M | Key | Description | 673 | | | | | Length | | 674 +====================+=======+====+=====+========+===============+ 675 | AES-CCM-16-64-128 | 10 | 16 | 64 | 128 | AES-CCM mode | 676 | | | | | | 128-bit key, | 677 | | | | | | 64-bit tag, | 678 | | | | | | 13-byte nonce | 679 +--------------------+-------+----+-----+--------+---------------+ 680 | AES-CCM-16-64-256 | 11 | 16 | 64 | 256 | AES-CCM mode | 681 | | | | | | 256-bit key, | 682 | | | | | | 64-bit tag, | 683 | | | | | | 13-byte nonce | 684 +--------------------+-------+----+-----+--------+---------------+ 685 | AES-CCM-64-64-128 | 12 | 64 | 64 | 128 | AES-CCM mode | 686 | | | | | | 128-bit key, | 687 | | | | | | 64-bit tag, | 688 | | | | | | 7-byte nonce | 689 +--------------------+-------+----+-----+--------+---------------+ 690 | AES-CCM-64-64-256 | 13 | 64 | 64 | 256 | AES-CCM mode | 691 | | | | | | 256-bit key, | 692 | | | | | | 64-bit tag, | 693 | | | | | | 7-byte nonce | 694 +--------------------+-------+----+-----+--------+---------------+ 695 | AES-CCM-16-128-128 | 30 | 16 | 128 | 128 | AES-CCM mode | 696 | | | | | | 128-bit key, | 697 | | | | | | 128-bit tag, | 698 | | | | | | 13-byte nonce | 699 +--------------------+-------+----+-----+--------+---------------+ 700 | AES-CCM-16-128-256 | 31 | 16 | 128 | 256 | AES-CCM mode | 701 | | | | | | 256-bit key, | 702 | | | | | | 128-bit tag, | 703 | | | | | | 13-byte nonce | 704 +--------------------+-------+----+-----+--------+---------------+ 705 | AES-CCM-64-128-128 | 32 | 64 | 128 | 128 | AES-CCM mode | 706 | | | | | | 128-bit key, | 707 | | | | | | 128-bit tag, | 708 | | | | | | 7-byte nonce | 709 +--------------------+-------+----+-----+--------+---------------+ 710 | AES-CCM-64-128-256 | 33 | 64 | 128 | 256 | AES-CCM mode | 711 | | | | | | 256-bit key, | 712 | | | | | | 128-bit tag, | 713 | | | | | | 7-byte nonce | 714 +--------------------+-------+----+-----+--------+---------------+ 716 Table 6: Algorithm Values for AES-CCM 718 Keys may be obtained either from a key structure or from a recipient 719 structure. Implementations encrypting and decrypting MUST validate 720 that the key type, key length, and algorithm are correct and 721 appropriate for the entities involved. 723 When using a COSE key for this algorithm, the following checks are 724 made: 726 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 728 * If the 'alg' field is present, it MUST match the AES-CCM algorithm 729 being used. 731 * If the 'key_ops' field is present, it MUST include 'encrypt' or 732 'wrap key' when encrypting. 734 * If the 'key_ops' field is present, it MUST include 'decrypt' or 735 'unwrap key' when decrypting. 737 4.2.1. Security Considerations 739 When using AES-CCM, the following restrictions MUST be enforced: 741 * The key and nonce pair MUST be unique for every message encrypted. 742 Note that the value of L influences the number of unique nonces. 744 * The total number of times the AES block cipher is used MUST NOT 745 exceed 2^61 operations. This limitation is the sum of times the 746 block cipher is used in computing the MAC value and in performing 747 stream encryption operations. An explicit check is required only 748 in environments where it is expected that it might be exceeded. 750 [RFC3610] additionally calls out one other consideration of note. It 751 is possible to do a pre-computation attack against the algorithm in 752 cases where portions of the plaintext are highly predictable. This 753 reduces the security of the key size by half. Ways to deal with this 754 attack include adding a random portion to the nonce value and/or 755 increasing the key size used. Using a portion of the nonce for a 756 random value will decrease the number of messages that a single key 757 can be used for. Increasing the key size may require more resources 758 in the constrained device. See Sections 5 and 10 of [RFC3610] for 759 more information. 761 4.3. ChaCha20 and Poly1305 763 ChaCha20 and Poly1305 combined together is an AEAD mode that is 764 defined in [RFC8439]. This is an algorithm defined to be a cipher 765 that is not AES and thus would not suffer from any future weaknesses 766 found in AES. These cryptographic functions are designed to be fast 767 in software-only implementations. 769 The ChaCha20/Poly1305 AEAD construction defined in [RFC8439] has no 770 parameterization. It takes a 256-bit key and a 96-bit nonce, as well 771 as the plaintext and additional data as inputs and produces the 772 ciphertext as an option. We define one algorithm identifier for this 773 algorithm in Table 7. 775 +-------------------+-------+--------------------------+ 776 | Name | Value | Description | 777 +===================+=======+==========================+ 778 | ChaCha20/Poly1305 | 24 | ChaCha20/Poly1305 w/ | 779 | | | 256-bit key, 128-bit tag | 780 +-------------------+-------+--------------------------+ 782 Table 7: Algorithm Value for AES-GCM 784 Keys may be obtained either from a key structure or from a recipient 785 structure. Implementations encrypting and decrypting MUST validate 786 that the key type, key length, and algorithm are correct and 787 appropriate for the entities involved. 789 When using a COSE key for this algorithm, the following checks are 790 made: 792 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 794 * If the 'alg' field is present, it MUST match the ChaCha20/Poly1305 795 algorithm being used. 797 * If the 'key_ops' field is present, it MUST include 'encrypt' or 798 'wrap key' when encrypting. 800 * If the 'key_ops' field is present, it MUST include 'decrypt' or 801 'unwrap key' when decrypting. 803 4.3.1. Security Considerations 805 The key and nonce values MUST be a unique pair for every invocation 806 of the algorithm. Nonce counters are considered to be an acceptable 807 way of ensuring that they are unique. 809 5. Key Derivation Functions (KDFs) 811 Part Section 9.4 of [I-D.ietf-cose-rfc8152bis-struct] contains a 812 generic description of Key Derivation Functions. This document 813 defines a single context structure and a single KDF. These elements 814 are used for all of the recipient algorithms defined in this document 815 that require a KDF process. These algorithms are defined in Sections 816 6.1.2, 6.3, and 6.4. 818 5.1. HMAC-Based Extract-and-Expand Key Derivation Function (HKDF) 820 The HKDF key derivation algorithm is defined in [RFC5869]. 822 The HKDF algorithm takes these inputs: 824 secret -- a shared value that is secret. Secrets may be either 825 previously shared or derived from operations like a Diffie-Hellman 826 (DH) key agreement. 828 salt -- an optional value that is used to change the generation 829 process. The salt value can be either public or private. If the 830 salt is public and carried in the message, then the 'salt' 831 algorithm header parameter defined in Table 9 is used. While 832 [RFC5869] suggests that the length of the salt be the same as the 833 length of the underlying hash value, any positive salt length will 834 improve the security as different key values will be generated. 835 This parameter is protected by being included in the key 836 computation and does not need to be separately authenticated. The 837 salt value does not need to be unique for every message sent. 839 length -- the number of bytes of output that need to be generated. 841 context information -- Information that describes the context in 842 which the resulting value will be used. Making this information 843 specific to the context in which the material is going to be used 844 ensures that the resulting material will always be tied to that 845 usage. The context structure defined in Section 5.2 is used by 846 the KDFs in this document. 848 PRF -- The underlying pseudorandom function to be used in the HKDF 849 algorithm. The PRF is encoded into the HKDF algorithm selection. 851 HKDF is defined to use HMAC as the underlying PRF. However, it is 852 possible to use other functions in the same construct to provide a 853 different KDF that is more appropriate in the constrained world. 854 Specifically, one can use AES-CBC-MAC as the PRF for the expand step, 855 but not for the extract step. When using a good random shared secret 856 of the correct length, the extract step can be skipped. For the AES 857 algorithm versions, the extract step is always skipped. 859 The extract step cannot be skipped if the secret is not uniformly 860 random, for example, if it is the result of an ECDH key agreement 861 step. This implies that the AES HKDF version cannot be used with 862 ECDH. If the extract step is skipped, the 'salt' value is not used 863 as part of the HKDF functionality. 865 The algorithms defined in this document are found in Table 8. 867 +--------------+-------------------+------------------------+ 868 | Name | PRF | Description | 869 +==============+===================+========================+ 870 | HKDF SHA-256 | HMAC with SHA-256 | HKDF using HMAC | 871 | | | SHA-256 as the PRF | 872 +--------------+-------------------+------------------------+ 873 | HKDF SHA-512 | HMAC with SHA-512 | HKDF using HMAC | 874 | | | SHA-512 as the PRF | 875 +--------------+-------------------+------------------------+ 876 | HKDF AES- | AES-CBC-MAC-128 | HKDF using AES-MAC as | 877 | MAC-128 | | the PRF w/ 128-bit key | 878 +--------------+-------------------+------------------------+ 879 | HKDF AES- | AES-CBC-MAC-256 | HKDF using AES-MAC as | 880 | MAC-256 | | the PRF w/ 256-bit key | 881 +--------------+-------------------+------------------------+ 883 Table 8: HKDF Algorithms 885 +------+-------+------+----------------------------+-------------+ 886 | Name | Label | Type | Algorithm | Description | 887 +======+=======+======+============================+=============+ 888 | salt | -20 | bstr | direct+HKDF-SHA-256, | Random salt | 889 | | | | direct+HKDF-SHA-512, | | 890 | | | | direct+HKDF-AES-128, | | 891 | | | | direct+HKDF-AES-256, ECDH- | | 892 | | | | ES+HKDF-256, ECDH-ES+HKDF- | | 893 | | | | 512, ECDH-SS+HKDF-256, | | 894 | | | | ECDH-SS+HKDF-512, ECDH- | | 895 | | | | ES+A128KW, ECDH-ES+A192KW, | | 896 | | | | ECDH-ES+A256KW, ECDH- | | 897 | | | | SS+A128KW, ECDH-SS+A192KW, | | 898 | | | | ECDH-SS+A256KW | | 899 +------+-------+------+----------------------------+-------------+ 901 Table 9: HKDF Algorithm Parameters 903 5.2. Context Information Structure 905 The context information structure is used to ensure that the derived 906 keying material is "bound" to the context of the transaction. The 907 context information structure used here is based on that defined in 908 [SP800-56A]. By using CBOR for the encoding of the context 909 information structure, we automatically get the same type and length 910 separation of fields that is obtained by the use of ASN.1. This 911 means that there is no need to encode the lengths for the base 912 elements, as it is done by the encoding used in JOSE (Section 4.6.2 913 of [RFC7518]). 915 The context information structure refers to PartyU and PartyV as the 916 two parties that are doing the key derivation. Unless the 917 application protocol defines differently, we assign PartyU to the 918 entity that is creating the message and PartyV to the entity that is 919 receiving the message. By doing this association, different keys 920 will be derived for each direction as the context information is 921 different in each direction. 923 The context structure is built from information that is known to both 924 entities. This information can be obtained from a variety of 925 sources: 927 * Fields can be defined by the application. This is commonly used 928 to assign fixed names to parties, but it can be used for other 929 items such as nonces. 931 * Fields can be defined by usage of the output. Examples of this 932 are the algorithm and key size that are being generated. 934 * Fields can be defined by parameters from the message. We define a 935 set of header parameters in Table 10 that can be used to carry the 936 values associated with the context structure. Examples of this 937 are identities and nonce values. These header parameters are 938 designed to be placed in the unprotected bucket of the recipient 939 structure; they do not need to be in the protected bucket since 940 they already are included in the cryptographic computation by 941 virtue of being included in the context structure. 943 +----------+-------+------+---------------------------+-------------+ 944 | Name | Label | Type | Algorithm | Description | 945 +==========+=======+======+===========================+=============+ 946 | PartyU | -21 | bstr | direct+HKDF-SHA-256, | Party U | 947 | identity | | | direct+HKDF-SHA-512, | identity | 948 | | | | direct+HKDF-AES-128, | information | 949 | | | | direct+HKDF-AES-256, | | 950 | | | | ECDH-ES+HKDF-256, | | 951 | | | | ECDH-ES+HKDF-512, | | 952 | | | | ECDH-SS+HKDF-256, | | 953 | | | | ECDH-SS+HKDF-512, | | 954 | | | | ECDH-ES+A128KW, | | 955 | | | | ECDH-ES+A192KW, | | 956 | | | | ECDH-ES+A256KW, | | 957 | | | | ECDH-SS+A128KW, | | 958 | | | | ECDH-SS+A192KW, | | 959 | | | | ECDH-SS+A256KW | | 960 +----------+-------+------+---------------------------+-------------+ 961 | PartyU | -22 | bstr | direct+HKDF-SHA-256, | Party U | 962 | nonce | | / | direct+HKDF-SHA-512, | provided | 963 | | | int | direct+HKDF-AES-128, | nonce | 964 | | | | direct+HKDF-AES-256, | | 965 | | | | ECDH-ES+HKDF-256, | | 966 | | | | ECDH-ES+HKDF-512, | | 967 | | | | ECDH-SS+HKDF-256, | | 968 | | | | ECDH-SS+HKDF-512, | | 969 | | | | ECDH-ES+A128KW, | | 970 | | | | ECDH-ES+A192KW, | | 971 | | | | ECDH-ES+A256KW, | | 972 | | | | ECDH-SS+A128KW, | | 973 | | | | ECDH-SS+A192KW, | | 974 | | | | ECDH-SS+A256KW | | 975 +----------+-------+------+---------------------------+-------------+ 976 | PartyU | -23 | bstr | direct+HKDF-SHA-256, | Party U | 977 | other | | | direct+HKDF-SHA-512, | other | 978 | | | | direct+HKDF-AES-128, | provided | 979 | | | | direct+HKDF-AES-256, | information | 980 | | | | ECDH-ES+HKDF-256, | | 981 | | | | ECDH-ES+HKDF-512, | | 982 | | | | ECDH-SS+HKDF-256, | | 983 | | | | ECDH-SS+HKDF-512, | | 984 | | | | ECDH-ES+A128KW, | | 985 | | | | ECDH-ES+A192KW, | | 986 | | | | ECDH-ES+A256KW, | | 987 | | | | ECDH-SS+A128KW, | | 988 | | | | ECDH-SS+A192KW, | | 989 | | | | ECDH-SS+A256KW | | 990 +----------+-------+------+---------------------------+-------------+ 991 | PartyV | -24 | bstr | direct+HKDF-SHA-256, | Party V | 992 | identity | | | direct+HKDF-SHA-512, | identity | 993 | | | | direct+HKDF-AES-128, | information | 994 | | | | direct+HKDF-AES-256, | | 995 | | | | ECDH-ES+HKDF-256, | | 996 | | | | ECDH-ES+HKDF-512, | | 997 | | | | ECDH-SS+HKDF-256, | | 998 | | | | ECDH-SS+HKDF-512, | | 999 | | | | ECDH-ES+A128KW, | | 1000 | | | | ECDH-ES+A192KW, | | 1001 | | | | ECDH-ES+A256KW, | | 1002 | | | | ECDH-SS+A128KW, | | 1003 | | | | ECDH-SS+A192KW, | | 1004 | | | | ECDH-SS+A256KW | | 1005 +----------+-------+------+---------------------------+-------------+ 1006 | PartyV | -25 | bstr | direct+HKDF-SHA-256, | Party V | 1007 | nonce | | / | direct+HKDF-SHA-512, | provided | 1008 | | | int | direct+HKDF-AES-128, | nonce | 1009 | | | | direct+HKDF-AES-256, | | 1010 | | | | ECDH-ES+HKDF-256, | | 1011 | | | | ECDH-ES+HKDF-512, | | 1012 | | | | ECDH-SS+HKDF-256, | | 1013 | | | | ECDH-SS+HKDF-512, | | 1014 | | | | ECDH-ES+A128KW, | | 1015 | | | | ECDH-ES+A192KW, | | 1016 | | | | ECDH-ES+A256KW, | | 1017 | | | | ECDH-SS+A128KW, | | 1018 | | | | ECDH-SS+A192KW, | | 1019 | | | | ECDH-SS+A256KW | | 1020 +----------+-------+------+---------------------------+-------------+ 1021 | PartyV | -26 | bstr | direct+HKDF-SHA-256, | Party V | 1022 | other | | | direct+HKDF-SHA-512, | other | 1023 | | | | direct+HKDF-AES-128, | provided | 1024 | | | | direct+HKDF-AES-256, | information | 1025 | | | | ECDH-ES+HKDF-256, | | 1026 | | | | ECDH-ES+HKDF-512, | | 1027 | | | | ECDH-SS+HKDF-256, | | 1028 | | | | ECDH-SS+HKDF-512, | | 1029 | | | | ECDH-ES+A128KW, | | 1030 | | | | ECDH-ES+A192KW, | | 1031 | | | | ECDH-ES+A256KW, | | 1032 | | | | ECDH-SS+A128KW, | | 1033 | | | | ECDH-SS+A192KW, | | 1034 | | | | ECDH-SS+A256KW | | 1035 +----------+-------+------+---------------------------+-------------+ 1037 Table 10: Context Algorithm Parameters 1039 We define a CBOR object to hold the context information. This object 1040 is referred to as COSE_KDF_Context. The object is based on a CBOR 1041 array type. The fields in the array are: 1043 AlgorithmID: This field indicates the algorithm for which the key 1044 material will be used. This normally is either a key wrap 1045 algorithm identifier or a content encryption algorithm identifier. 1046 The values are from the "COSE Algorithms" registry. This field is 1047 required to be present. The field exists in the context 1048 information so that a different key is generated for each 1049 algorithm even of all of the other context information is the 1050 same. In practice, this means if algorithm A is broken and thus 1051 finding the key is relatively easy, the key derived for algorithm 1052 B will not be the same as the key derived for algorithm A. 1054 PartyUInfo: This field holds information about party U. The 1055 PartyUInfo is encoded as a CBOR array. The elements of PartyUInfo 1056 are encoded in the order presented below. The elements of the 1057 PartyUInfo array are: 1059 identity: This contains the identity information for party U. 1060 The identities can be assigned in one of two manners. First, a 1061 protocol can assign identities based on roles. For example, 1062 the roles of "client" and "server" may be assigned to different 1063 entities in the protocol. Each entity would then use the 1064 correct label for the data they send or receive. The second 1065 way for a protocol to assign identities is to use a name based 1066 on a naming system (i.e., DNS, X.509 names). 1068 We define an algorithm parameter 'PartyU identity' that can be 1069 used to carry identity information in the message. However, 1070 identity information is often known as part of the protocol and 1071 can thus be inferred rather than made explicit. If identity 1072 information is carried in the message, applications SHOULD have 1073 a way of validating the supplied identity information. The 1074 identity information does not need to be specified and is set 1075 to nil in that case. 1077 nonce: This contains a nonce value. The nonce can either be 1078 implicit from the protocol or be carried as a value in the 1079 unprotected header bucket. 1081 We define an algorithm parameter 'PartyU nonce' that can be 1082 used to carry this value in the message; however, the nonce 1083 value could be determined by the application and the value 1084 determined from elsewhere. 1086 This option does not need to be specified and is set to nil in 1087 that case. 1089 other: This contains other information that is defined by the 1090 protocol. This option does not need to be specified and is set 1091 to nil in that case. 1093 PartyVInfo: This field holds information about party V. The content 1094 of the structure is the same as for the PartyUInfo but for party 1095 V. 1097 SuppPubInfo: This field contains public information that is mutually 1098 known to both parties. 1100 keyDataLength: This is set to the number of bits of the desired 1101 output value. This practice means if algorithm A can use two 1102 different key lengths, the key derived for longer key size will 1103 not contain the key for shorter key size as a prefix. 1105 protected: This field contains the protected parameter field. If 1106 there are no elements in the protected field, then use a zero- 1107 length bstr. 1109 other: This field is for free form data defined by the 1110 application. An example is that an application could define 1111 two different byte strings to be placed here to generate 1112 different keys for a data stream versus a control stream. This 1113 field is optional and will only be present if the application 1114 defines a structure for this information. Applications that 1115 define this SHOULD use CBOR to encode the data so that types 1116 and lengths are correctly included. 1118 SuppPrivInfo: This field contains private information that is 1119 mutually known private information. An example of this 1120 information would be a preexisting shared secret. (This could, 1121 for example, be used in combination with an ECDH key agreement to 1122 provide a secondary proof of identity.) The field is optional and 1123 will only be present if the application defines a structure for 1124 this information. Applications that define this SHOULD use CBOR 1125 to encode the data so that types and lengths are correctly 1126 included. 1128 The following CDDL fragment corresponds to the text above. 1130 PartyInfo = ( 1131 identity : bstr / nil, 1132 nonce : bstr / int / nil, 1133 other : bstr / nil 1134 ) 1136 COSE_KDF_Context = [ 1137 AlgorithmID : int / tstr, 1138 PartyUInfo : [ PartyInfo ], 1139 PartyVInfo : [ PartyInfo ], 1140 SuppPubInfo : [ 1141 keyDataLength : uint, 1142 protected : empty_or_serialized_map, 1143 ? other : bstr 1144 ], 1145 ? SuppPrivInfo : bstr 1146 ] 1148 6. Content Key Distribution Methods 1150 Part Section 9.5 of [I-D.ietf-cose-rfc8152bis-struct] contains a 1151 generic description of content key distribution methods. This 1152 document defines the identifiers and usage for a number of content 1153 key distribution methods. 1155 6.1. Direct Encryption 1157 Direct encryption algorithm is defined in Part Section 9.5.1 of 1158 [I-D.ietf-cose-rfc8152bis-struct]. Information about how to fill in 1159 the COSE_Recipient structure are detailed there. 1161 6.1.1. Direct Key 1163 This recipient algorithm is the simplest; the identified key is 1164 directly used as the key for the next layer down in the message. 1165 There are no algorithm parameters defined for this algorithm. The 1166 algorithm identifier value is assigned in Table 11. 1168 When this algorithm is used, the protected field MUST be zero length. 1169 The key type MUST be 'Symmetric'. 1171 +--------+-------+-------------------+ 1172 | Name | Value | Description | 1173 +========+=======+===================+ 1174 | direct | -6 | Direct use of CEK | 1175 +--------+-------+-------------------+ 1177 Table 11: Direct Key 1179 6.1.1.1. Security Considerations 1181 This recipient algorithm has several potential problems that need to 1182 be considered: 1184 * These keys need to have some method to be regularly updated over 1185 time. All of the content encryption algorithms specified in this 1186 document have limits on how many times a key can be used without 1187 significant loss of security. 1189 * These keys need to be dedicated to a single algorithm. There have 1190 been a number of attacks developed over time when a single key is 1191 used for multiple different algorithms. One example of this is 1192 the use of a single key for both the CBC encryption mode and the 1193 CBC-MAC authentication mode. 1195 * Breaking one message means all messages are broken. If an 1196 adversary succeeds in determining the key for a single message, 1197 then the key for all messages is also determined. 1199 6.1.2. Direct Key with KDF 1201 These recipient algorithms take a common shared secret between the 1202 two parties and applies the HKDF function (Section 5.1), using the 1203 context structure defined in Section 5.2 to transform the shared 1204 secret into the CEK. The 'protected' field can be of non-zero 1205 length. Either the 'salt' parameter of HKDF or the 'PartyU nonce' 1206 parameter of the context structure MUST be present. The salt/nonce 1207 parameter can be generated either randomly or deterministically. The 1208 requirement is that it be a unique value for the shared secret in 1209 question. 1211 If the salt/nonce value is generated randomly, then it is suggested 1212 that the length of the random value be the same length as the hash 1213 function underlying HKDF. While there is no way to guarantee that it 1214 will be unique, there is a high probability that it will be unique. 1215 If the salt/nonce value is generated deterministically, it can be 1216 guaranteed to be unique, and thus there is no length requirement. 1218 A new IV must be used for each message if the same key is used. The 1219 IV can be modified in a predictable manner, a random manner, or an 1220 unpredictable manner (i.e., encrypting a counter). 1222 The IV used for a key can also be generated from the same HKDF 1223 functionality as the key is generated. If HKDF is used for 1224 generating the IV, the algorithm identifier is set to "IV- 1225 GENERATION". 1227 The set of algorithms defined in this document can be found in 1228 Table 12. 1230 +---------------------+-------+--------------+---------------------+ 1231 | Name | Value | KDF | Description | 1232 +=====================+=======+==============+=====================+ 1233 | direct+HKDF-SHA-256 | -10 | HKDF SHA-256 | Shared secret w/ | 1234 | | | | HKDF and SHA-256 | 1235 +---------------------+-------+--------------+---------------------+ 1236 | direct+HKDF-SHA-512 | -11 | HKDF SHA-512 | Shared secret w/ | 1237 | | | | HKDF and SHA-512 | 1238 +---------------------+-------+--------------+---------------------+ 1239 | direct+HKDF-AES-128 | -12 | HKDF AES- | Shared secret w/ | 1240 | | | MAC-128 | AES-MAC 128-bit key | 1241 +---------------------+-------+--------------+---------------------+ 1242 | direct+HKDF-AES-256 | -13 | HKDF AES- | Shared secret w/ | 1243 | | | MAC-256 | AES-MAC 256-bit key | 1244 +---------------------+-------+--------------+---------------------+ 1246 Table 12: Direct Key with KDF 1248 When using a COSE key for this algorithm, the following checks are 1249 made: 1251 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 1253 * If the 'alg' field is present, it MUST match the algorithm being 1254 used. 1256 * If the 'key_ops' field is present, it MUST include 'deriveKey' or 1257 'deriveBits'. 1259 6.1.2.1. Security Considerations 1261 The shared secret needs to have some method to be regularly updated 1262 over time. The shared secret forms the basis of trust. Although not 1263 used directly, it should still be subject to scheduled rotation. 1265 While these methods do not provide for perfect forward secrecy, as 1266 the same shared secret is used for all of the keys generated, if the 1267 key for any single message is discovered, only the message (or series 1268 of messages) using that derived key are compromised. A new key 1269 derivation step will generate a new key that requires the same amount 1270 of work to get the key. 1272 6.2. AES Key Wrap 1274 The AES Key Wrap algorithm is defined in [RFC3394]. This algorithm 1275 uses an AES key to wrap a value that is a multiple of 64 bits. As 1276 such, it can be used to wrap a key for any of the content encryption 1277 algorithms defined in this document. The algorithm requires a single 1278 fixed parameter, the initial value. This is fixed to the value 1279 specified in Section 2.2.3.1 of [RFC3394]. There are no public key 1280 parameters that vary on a per-invocation basis. The protected header 1281 bucket MUST be empty. 1283 Keys may be obtained either from a key structure or from a recipient 1284 structure. Implementations encrypting and decrypting MUST validate 1285 that the key type, key length, and algorithm are correct and 1286 appropriate for the entities involved. 1288 When using a COSE key for this algorithm, the following checks are 1289 made: 1291 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 1293 * If the 'alg' field is present, it MUST match the AES Key Wrap 1294 algorithm being used. 1296 * If the 'key_ops' field is present, it MUST include 'encrypt' or 1297 'wrap key' when encrypting. 1299 * If the 'key_ops' field is present, it MUST include 'decrypt' or 1300 'unwrap key' when decrypting. 1302 +--------+-------+----------+-----------------------------+ 1303 | Name | Value | Key Size | Description | 1304 +========+=======+==========+=============================+ 1305 | A128KW | -3 | 128 | AES Key Wrap w/ 128-bit key | 1306 +--------+-------+----------+-----------------------------+ 1307 | A192KW | -4 | 192 | AES Key Wrap w/ 192-bit key | 1308 +--------+-------+----------+-----------------------------+ 1309 | A256KW | -5 | 256 | AES Key Wrap w/ 256-bit key | 1310 +--------+-------+----------+-----------------------------+ 1312 Table 13: AES Key Wrap Algorithm Values 1314 6.2.1. Security Considerations for AES-KW 1316 The shared secret needs to have some method to be regularly updated 1317 over time. The shared secret is the basis of trust. 1319 6.3. Direct ECDH 1321 The mathematics for ECDH can be found in [RFC6090]. In this 1322 document, the algorithm is extended to be used with the two curves 1323 defined in [RFC7748]. 1325 ECDH is parameterized by the following: 1327 * Curve Type/Curve: The curve selected controls not only the size of 1328 the shared secret, but the mathematics for computing the shared 1329 secret. The curve selected also controls how a point in the curve 1330 is represented and what happens for the identity points on the 1331 curve. In this specification, we allow for a number of different 1332 curves to be used. A set of curves are defined in Table 18. 1334 The math used to obtain the computed secret is based on the curve 1335 selected and not on the ECDH algorithm. For this reason, a new 1336 algorithm does not need to be defined for each of the curves. 1338 * Computed Secret to Shared Secret: Once the computed secret is 1339 known, the resulting value needs to be converted to a byte string 1340 to run the KDF. The x-coordinate is used for all of the curves 1341 defined in this document. For curves X25519 and X448, the 1342 resulting value is used directly as it is a byte string of a known 1343 length. For the P-256, P-384, and P-521 curves, the x-coordinate 1344 is run through the I2OSP function defined in [RFC8017], using the 1345 same computation for n as is defined in Section 2.1. 1347 * Ephemeral-Static or Static-Static: The key agreement process may 1348 be done using either a static or an ephemeral key for the sender's 1349 side. When using ephemeral keys, the sender MUST generate a new 1350 ephemeral key for every key agreement operation. The ephemeral 1351 key is placed in the 'ephemeral key' parameter and MUST be present 1352 for all algorithm identifiers that use ephemeral keys. When using 1353 static keys, the sender MUST either generate a new random value or 1354 create a unique value. For the KDFs used, this means either the 1355 'salt' parameter for HKDF (Table 9) or the 'PartyU nonce' 1356 parameter for the context structure (Table 10) MUST be present 1357 (both can be present if desired). The value in the parameter MUST 1358 be unique for the pair of keys being used. It is acceptable to 1359 use a global counter that is incremented for every static-static 1360 operation and use the resulting value. When using static keys, 1361 the static key should be identified to the recipient. The static 1362 key can be identified either by providing the key ('static key') 1363 or by providing a key identifier for the static key ('static key 1364 id'). Both of these header parameters are defined in Table 15. 1366 * Key Derivation Algorithm: The result of an ECDH key agreement 1367 process does not provide a uniformly random secret. As such, it 1368 needs to be run through a KDF in order to produce a usable key. 1369 Processing the secret through a KDF also allows for the 1370 introduction of context material: how the key is going to be used 1371 and one-time material for static-static key agreement. All of the 1372 algorithms defined in this document use one of the HKDF algorithms 1373 defined in Section 5.1 with the context structure defined in 1374 Section 5.2. 1376 * Key Wrap Algorithm: No key wrap algorithm is used. This is 1377 represented in Table 14 as 'none'. The key size for the context 1378 structure is the content layer encryption algorithm size. 1380 COSE does not have an Ephemeral-Ephemeral version defined. The 1381 reason for this is that COSE is not an online protocol by itself and 1382 thus does not have a method to establish ephemeral secrets on both 1383 sides. The expectation is that a protocol would establish the 1384 secrets for both sides, and then they would be used as static-static 1385 for the purposes of COSE, or that the protocol would generate a 1386 shared secret and a direct encryption would be used. 1388 The set of direct ECDH algorithms defined in this document are found 1389 in Table 14. 1391 +-----------+-------+---------+------------+------+-----------------+ 1392 | Name | Value | KDF | Ephemeral- | Key | Description | 1393 | | | | Static | Wrap | | 1394 +===========+=======+=========+============+======+=================+ 1395 | ECDH-ES | -25 | HKDF - | yes | none | ECDH ES w/ HKDF | 1396 | + | | SHA-256 | | | - generate key | 1397 | HKDF-256 | | | | | directly | 1398 +-----------+-------+---------+------------+------+-----------------+ 1399 | ECDH-ES | -26 | HKDF - | yes | none | ECDH ES w/ HKDF | 1400 | + | | SHA-512 | | | - generate key | 1401 | HKDF-512 | | | | | directly | 1402 +-----------+-------+---------+------------+------+-----------------+ 1403 | ECDH-SS | -27 | HKDF - | no | none | ECDH SS w/ HKDF | 1404 | + | | SHA-256 | | | - generate key | 1405 | HKDF-256 | | | | | directly | 1406 +-----------+-------+---------+------------+------+-----------------+ 1407 | ECDH-SS | -28 | HKDF - | no | none | ECDH SS w/ HKDF | 1408 | + | | SHA-512 | | | - generate key | 1409 | HKDF-512 | | | | | directly | 1410 +-----------+-------+---------+------------+------+-----------------+ 1412 Table 14: ECDH Algorithm Values 1414 +-----------+-------+----------+-------------------+-------------+ 1415 | Name | Label | Type | Algorithm | Description | 1416 +===========+=======+==========+===================+=============+ 1417 | ephemeral | -1 | COSE_Key | ECDH-ES+HKDF-256, | Ephemeral | 1418 | key | | | ECDH-ES+HKDF-512, | public key | 1419 | | | | ECDH-ES+A128KW, | for the | 1420 | | | | ECDH-ES+A192KW, | sender | 1421 | | | | ECDH-ES+A256KW | | 1422 +-----------+-------+----------+-------------------+-------------+ 1423 | static | -2 | COSE_Key | ECDH-SS+HKDF-256, | Static | 1424 | key | | | ECDH-SS+HKDF-512, | public key | 1425 | | | | ECDH-SS+A128KW, | for the | 1426 | | | | ECDH-SS+A192KW, | sender | 1427 | | | | ECDH-SS+A256KW | | 1428 +-----------+-------+----------+-------------------+-------------+ 1429 | static | -3 | bstr | ECDH-SS+HKDF-256, | Static | 1430 | key id | | | ECDH-SS+HKDF-512, | public key | 1431 | | | | ECDH-SS+A128KW, | identifier | 1432 | | | | ECDH-SS+A192KW, | for the | 1433 | | | | ECDH-SS+A256KW | sender | 1434 +-----------+-------+----------+-------------------+-------------+ 1436 Table 15: ECDH Algorithm Parameters 1438 This document defines these algorithms to be used with the curves 1439 P-256, P-384, P-521, X25519, and X448. Implementations MUST verify 1440 that the key type and curve are correct. Different curves are 1441 restricted to different key types. Implementations MUST verify that 1442 the curve and algorithm are appropriate for the entities involved. 1444 When using a COSE key for this algorithm, the following checks are 1445 made: 1447 * The 'kty' field MUST be present, and it MUST be 'EC2' or 'OKP'. 1449 * If the 'alg' field is present, it MUST match the key agreement 1450 algorithm being used. 1452 * If the 'key_ops' field is present, it MUST include 'derive key' or 1453 'derive bits' for the private key. 1455 * If the 'key_ops' field is present, it MUST be empty for the public 1456 key. 1458 6.3.1. Security Considerations 1460 There is a method of checking that points provided from external 1461 entities are valid. For the 'EC2' key format, this can be done by 1462 checking that the x and y values form a point on the curve. For the 1463 'OKP' format, there is no simple way to do point validation. 1465 Consideration was given to requiring that the public keys of both 1466 entities be provided as part of the key derivation process (as 1467 recommended in Section 6.4 of [RFC7748]). This was not done as COSE 1468 is used in a store and forward format rather than in online key 1469 exchange. In order for this to be a problem, either the receiver 1470 public key has to be chosen maliciously or the sender has to be 1471 malicious. In either case, all security evaporates anyway. 1473 A proof of possession of the private key associated with the public 1474 key is recommended when a key is moved from untrusted to trusted 1475 (either by the end user or by the entity that is responsible for 1476 making trust statements on keys). 1478 6.4. ECDH with Key Wrap 1480 These algorithms are defined in Table 16. 1482 ECDH with Key Agreement is parameterized by the same header 1483 parameters as for ECDH; see Section 6.3, with the following 1484 modifications: 1486 * Key Wrap Algorithm: Any of the key wrap algorithms defined in 1487 Section 6.2 are supported. The size of the key used for the key 1488 wrap algorithm is fed into the KDF. The set of identifiers are 1489 found in Table 16. 1491 +---------+-------+---------+------------+--------+----------------+ 1492 | Name | Value | KDF | Ephemeral- | Key | Description | 1493 | | | | Static | Wrap | | 1494 +=========+=======+=========+============+========+================+ 1495 | ECDH-ES | -29 | HKDF - | yes | A128KW | ECDH ES w/ | 1496 | + | | SHA-256 | | | Concat KDF and | 1497 | A128KW | | | | | AES Key Wrap | 1498 | | | | | | w/ 128-bit key | 1499 +---------+-------+---------+------------+--------+----------------+ 1500 | ECDH-ES | -30 | HKDF - | yes | A192KW | ECDH ES w/ | 1501 | + | | SHA-256 | | | Concat KDF and | 1502 | A192KW | | | | | AES Key Wrap | 1503 | | | | | | w/ 192-bit key | 1504 +---------+-------+---------+------------+--------+----------------+ 1505 | ECDH-ES | -31 | HKDF - | yes | A256KW | ECDH ES w/ | 1506 | + | | SHA-256 | | | Concat KDF and | 1507 | A256KW | | | | | AES Key Wrap | 1508 | | | | | | w/ 256-bit key | 1509 +---------+-------+---------+------------+--------+----------------+ 1510 | ECDH-SS | -32 | HKDF - | no | A128KW | ECDH SS w/ | 1511 | + | | SHA-256 | | | Concat KDF and | 1512 | A128KW | | | | | AES Key Wrap | 1513 | | | | | | w/ 128-bit key | 1514 +---------+-------+---------+------------+--------+----------------+ 1515 | ECDH-SS | -33 | HKDF - | no | A192KW | ECDH SS w/ | 1516 | + | | SHA-256 | | | Concat KDF and | 1517 | A192KW | | | | | AES Key Wrap | 1518 | | | | | | w/ 192-bit key | 1519 +---------+-------+---------+------------+--------+----------------+ 1520 | ECDH-SS | -34 | HKDF - | no | A256KW | ECDH SS w/ | 1521 | + | | SHA-256 | | | Concat KDF and | 1522 | A256KW | | | | | AES Key Wrap | 1523 | | | | | | w/ 256-bit key | 1524 +---------+-------+---------+------------+--------+----------------+ 1526 Table 16: ECDH Algorithm Values with Key Wrap 1528 When using a COSE key for this algorithm, the following checks are 1529 made: 1531 * The 'kty' field MUST be present, and it MUST be 'EC2' or 'OKP'. 1533 * If the 'alg' field is present, it MUST match the key agreement 1534 algorithm being used. 1536 * If the 'key_ops' field is present, it MUST include 'derive key' or 1537 'derive bits' for the private key. 1539 * If the 'key_ops' field is present, it MUST be empty for the public 1540 key. 1542 7. Key Object Parameters 1544 The COSE_Key object defines a way to hold a single key object. It is 1545 still required that the members of individual key types be defined. 1546 This section of the document is where we define an initial set of 1547 members for specific key types. 1549 For each of the key types, we define both public and private members. 1550 The public members are what is transmitted to others for their usage. 1551 Private members allow for the archival of keys by individuals. 1552 However, there are some circumstances in which private keys may be 1553 distributed to entities in a protocol. Examples include: entities 1554 that have poor random number generation, centralized key creation for 1555 multi-cast type operations, and protocols in which a shared secret is 1556 used as a bearer token for authorization purposes. 1558 Key types are identified by the 'kty' member of the COSE_Key object. 1559 In this document, we define four values for the member: 1561 +-----------+-------+--------------------------+ 1562 | Name | Value | Description | 1563 +===========+=======+==========================+ 1564 | OKP | 1 | Octet Key Pair | 1565 +-----------+-------+--------------------------+ 1566 | EC2 | 2 | Elliptic Curve Keys w/ | 1567 | | | x- and y-coordinate pair | 1568 +-----------+-------+--------------------------+ 1569 | Symmetric | 4 | Symmetric Keys | 1570 +-----------+-------+--------------------------+ 1571 | Reserved | 0 | This value is reserved | 1572 +-----------+-------+--------------------------+ 1574 Table 17: Key Type Values 1576 7.1. Elliptic Curve Keys 1578 Two different key structures are defined for elliptic curve keys. 1579 One version uses both an x-coordinate and a y-coordinate, potentially 1580 with point compression ('EC2'). This is the traditional EC point 1581 representation that is used in [RFC5480]. The other version uses 1582 only the x-coordinate as the y-coordinate is either to be recomputed 1583 or not needed for the key agreement operation ('OKP'). 1585 Applications MUST check that the curve and the key type are 1586 consistent and reject a key if they are not. 1588 +---------+-------+----------+------------------------------------+ 1589 | Name | Value | Key Type | Description | 1590 +=========+=======+==========+====================================+ 1591 | P-256 | 1 | EC2 | NIST P-256 also known as secp256r1 | 1592 +---------+-------+----------+------------------------------------+ 1593 | P-384 | 2 | EC2 | NIST P-384 also known as secp384r1 | 1594 +---------+-------+----------+------------------------------------+ 1595 | P-521 | 3 | EC2 | NIST P-521 also known as secp521r1 | 1596 +---------+-------+----------+------------------------------------+ 1597 | X25519 | 4 | OKP | X25519 for use w/ ECDH only | 1598 +---------+-------+----------+------------------------------------+ 1599 | X448 | 5 | OKP | X448 for use w/ ECDH only | 1600 +---------+-------+----------+------------------------------------+ 1601 | Ed25519 | 6 | OKP | Ed25519 for use w/ EdDSA only | 1602 +---------+-------+----------+------------------------------------+ 1603 | Ed448 | 7 | OKP | Ed448 for use w/ EdDSA only | 1604 +---------+-------+----------+------------------------------------+ 1606 Table 18: Elliptic Curves 1608 7.1.1. Double Coordinate Curves 1610 The traditional way of sending ECs has been to send either both the 1611 x-coordinate and y-coordinate or the x-coordinate and a sign bit for 1612 the y-coordinate. The latter encoding has not been recommended in 1613 the IETF due to potential IPR issues. However, for operations in 1614 constrained environments, the ability to shrink a message by not 1615 sending the y-coordinate is potentially useful. 1617 For EC keys with both coordinates, the 'kty' member is set to 2 1618 (EC2). The key parameters defined in this section are summarized in 1619 Table 19. The members that are defined for this key type are: 1621 crv: This contains an identifier of the curve to be used with the 1622 key. The curves defined in this document for this key type can 1623 be found in Table 18. Other curves may be registered in the 1624 future, and private curves can be used as well. 1626 x: This contains the x-coordinate for the EC point. The integer is 1627 converted to a byte string as defined in [SEC1]. Leading zero 1628 octets MUST be preserved. 1630 y: This contains either the sign bit or the value of the 1631 y-coordinate for the EC point. When encoding the value y, the 1632 integer is converted to an byte string (as defined in [SEC1]) 1633 and encoded as a CBOR bstr. Leading zero octets MUST be 1634 preserved. The compressed point encoding is also supported. 1635 Compute the sign bit as laid out in the Elliptic-Curve-Point-to- 1636 Octet-String Conversion function of [SEC1]. If the sign bit is 1637 zero, then encode y as a CBOR false value; otherwise, encode y 1638 as a CBOR true value. The encoding of the infinity point is not 1639 supported. 1641 d: This contains the private key. 1643 For public keys, it is REQUIRED that 'crv', 'x', and 'y' be present 1644 in the structure. For private keys, it is REQUIRED that 'crv' and 1645 'd' be present in the structure. For private keys, it is RECOMMENDED 1646 that 'x' and 'y' also be present, but they can be recomputed from the 1647 required elements and omitting them saves on space. 1649 +------+------+-------+--------+---------------------------------+ 1650 | Key | Name | Label | CBOR | Description | 1651 | Type | | | Type | | 1652 +======+======+=======+========+=================================+ 1653 | 2 | crv | -1 | int / | EC identifier - Taken from the | 1654 | | | | tstr | "COSE Elliptic Curves" registry | 1655 +------+------+-------+--------+---------------------------------+ 1656 | 2 | x | -2 | bstr | x-coordinate | 1657 +------+------+-------+--------+---------------------------------+ 1658 | 2 | y | -3 | bstr / | y-coordinate | 1659 | | | | bool | | 1660 +------+------+-------+--------+---------------------------------+ 1661 | 2 | d | -4 | bstr | Private key | 1662 +------+------+-------+--------+---------------------------------+ 1664 Table 19: EC Key Parameters 1666 7.2. Octet Key Pair 1668 A new key type is defined for Octet Key Pairs (OKP). Do not assume 1669 that keys using this type are elliptic curves. This key type could 1670 be used for other curve types (for example, mathematics based on 1671 hyper-elliptic surfaces). 1673 The key parameters defined in this section are summarized in 1674 Table 20. The members that are defined for this key type are: 1676 crv: This contains an identifier of the curve to be used with the 1677 key. The curves defined in this document for this key type can 1678 be found in Table 18. Other curves may be registered in the 1679 future and private curves can be used as well. 1681 x: This contains the public key. The byte string contains the 1682 public key as defined by the algorithm. (For X25591, internally 1683 it is a little-endian integer.) 1685 d: This contains the private key. 1687 For public keys, it is REQUIRED that 'crv' and 'x' be present in the 1688 structure. For private keys, it is REQUIRED that 'crv' and 'd' be 1689 present in the structure. For private keys, it is RECOMMENDED that 1690 'x' also be present, but it can be recomputed from the required 1691 elements and omitting it saves on space. 1693 +------+----------+-------+-------+---------------------------------+ 1694 | Name | Key | Label | Type | Description | 1695 | | Type | | | | 1696 +======+==========+=======+=======+=================================+ 1697 | crv | 1 | -1 | int / | EC identifier - Taken from the | 1698 | | | | tstr | "COSE Elliptic Curves" registry | 1699 +------+----------+-------+-------+---------------------------------+ 1700 | x | 1 | -2 | bstr | Public Key | 1701 +------+----------+-------+-------+---------------------------------+ 1702 | d | 1 | -4 | bstr | Private key | 1703 +------+----------+-------+-------+---------------------------------+ 1705 Table 20: Octet Key Pair Parameters 1707 7.3. Symmetric Keys 1709 Occasionally it is required that a symmetric key be transported 1710 between entities. This key structure allows for that to happen. 1712 For symmetric keys, the 'kty' member is set to 4 ('Symmetric'). The 1713 member that is defined for this key type is: 1715 k: This contains the value of the key. 1717 This key structure does not have a form that contains only public 1718 members. As it is expected that this key structure is going to be 1719 transmitted, care must be taken that it is never transmitted 1720 accidentally or insecurely. For symmetric keys, it is REQUIRED that 1721 'k' be present in the structure. 1723 +------+----------+-------+------+-------------+ 1724 | Name | Key Type | Label | Type | Description | 1725 +======+==========+=======+======+=============+ 1726 | k | 4 | -1 | bstr | Key Value | 1727 +------+----------+-------+------+-------------+ 1729 Table 21: Symmetric Key Parameters 1731 8. COSE Capabilities 1733 There are some situations that have been identified where 1734 identification of capabilities of an algorithm need to be specified. 1735 One example of this is in [I-D.ietf-core-oscore-groupcomm] where the 1736 capabilities of the counter signature algorithm are mixed into the 1737 traffic key derivation process. This has a counterpart in the S/MIME 1738 specifications where SMIMECapabilities is defined in Section 2.5.2 of 1739 [RFC8551]. The concept is being pulled forward and defined now for 1740 COSE. 1742 The algorithm identifier is not part of the capabilities data as it 1743 should already be part of message structure. There is a presumption 1744 in the way that this is laid out is that the algorithm identifier 1745 itself is not needed to be a part of this as it is specified in a 1746 different location. 1748 Two different types of capabilities are defined: capabilities for 1749 algorithms and capabilities for key structures. Once defined by 1750 registration with IANA, the list of capabilities is immutable. If it 1751 is later found that a new capability is needed for a key type or an 1752 algorithm, it will require that a new code point be assigned to deal 1753 with that. As a general rule, the capabilities are going to map to 1754 algorithm-specific header parameters or key parameters, but they do 1755 not need to do so. An example of this is the HSS-LMS key 1756 capabilities defined below where the hash algorithm used is included. 1758 The capability structure is an array of values, the order being 1759 dependent on the specific algorithm or key. For an algorithm, the 1760 first element should always be a key type value, but the items that 1761 are specific to a key should not be included in the algorithm 1762 capabilities. This means that if one wishes to enumerate all of the 1763 capabilities for a device which implements ECDH, it requires multiple 1764 pairs of capability structures (algorithm, key) to deal with the 1765 different key types and curves that are supported. For a key, the 1766 first element should also be a key type value. While this means that 1767 this value will be duplicated if both an algorithm and key capability 1768 are used, the key type is needed in order to understand the rest of 1769 the values. 1771 8.1. Assignments for Existing Key Types 1773 There are a number of pre-existing key types, the following deals 1774 with creating the capability definition for those structures: 1776 * OKP, EC2: The list of capabilities is: 1778 - The key type value. (1 for OKP or 2 for EC2.) 1779 - One curve for that key type from the "COSE Elliptic Curve" 1780 registry. 1782 * RSA: The list of capabilities is: 1784 - The key type value (3). 1786 * Symmetric: The list of capabilities is: 1788 - The key type value (4). 1790 * HSS-LMS: The list of capabilities is: 1792 - The key type value (5), 1794 - Algorithm identifier for the underlying hash function from the 1795 "COSE Algorithms" registry. 1797 8.2. Assignments for Existing Algorithms 1799 For the current set of algorithms in the registry, those in this 1800 document as well as those in [RFC8230] and [I-D.ietf-cose-hash-sig], 1801 the capabilities list is an array with one element, the key type 1802 (from the "COSE Key Types" Registry). It is expected future 1803 registered algorithms could have zero, one, or multiple elements. 1805 8.3. Examples 1807 In this section a trio of examples is provided. In all three cases 1808 it it encodes the algorithm capabilities followed by the key 1809 capabilities. For simplicity's sake, a CBOR sequence 1810 [I-D.ietf-cbor-sequence] is used for the two arrays. 1812 ECDSA with SHA-512 and a P-256 curve: 1814 0x8102820201 / [2],[2, 1] / 1816 ECDH-ES + A256KW with a P-256 curve: 1818 0x8102820201 / [2],[2, 1] / 1820 ECDH-ES + A256KW with an X25519 curve: 1822 0x8101820104 / [1],[1, 4] / 1824 9. CBOR Encoding Restrictions 1826 This document limits the restrictions it imposes on how the CBOR 1827 Encoder needs to work. We have managed to narrow it down to the 1828 following restrictions: 1830 * The restriction applies to the encoding of the COSE_KDF_Context. 1832 * Encoding MUST be done using definite lengths and the length of the 1833 MUST be the minimum possible length. This means that the integer 1834 1 is encoded as "0x01" and not "0x1801". 1836 * Applications MUST NOT generate messages with the same label used 1837 twice as a key in a single map. Applications MUST NOT parse and 1838 process messages with the same label used twice as a key in a 1839 single map. Applications can enforce the parse and process 1840 requirement by using parsers that will fail the parse step or by 1841 using parsers that will pass all keys to the application, and the 1842 application can perform the check for duplicate keys. 1844 10. IANA Considerations 1846 10.1. Changes to "COSE Key Types" registry. 1848 IANA is requested to create a new column in the "COSE Key Types" 1849 registry. The new column is to be labeled "Capabilities". The new 1850 column is to be populated according the entries in Table 22. 1852 +-------+-----------+--------------------------+ 1853 | Value | Name | Capabilities | 1854 +=======+===========+==========================+ 1855 | 1 | OKP | [kty(1), crv] | 1856 +-------+-----------+--------------------------+ 1857 | 2 | EC2 | [kty(2), crv] | 1858 +-------+-----------+--------------------------+ 1859 | 3 | RSA | [kty(3)] | 1860 +-------+-----------+--------------------------+ 1861 | 4 | Symmetric | [kty(4)] | 1862 +-------+-----------+--------------------------+ 1863 | 5 | HSS-LMS | [kty(5), hash algorithm] | 1864 +-------+-----------+--------------------------+ 1866 Table 22: Key Type Capabilities 1868 10.2. Changes to "COSE Algorithms" registry 1870 IANA is requested to create a new column in the "COSE Algorithms" 1871 registry. The new column is to be labeled "Capabilities". The new 1872 column is populated with "[kty]" for all current, non-provisional, 1873 registrations. It is expected that the documents which define those 1874 algorithms will be expanded to include this registration, if this is 1875 not done then the DE should be consulted before final registration 1876 for this document is done. 1878 IANA is requested to update the reference column in the "COSE 1879 Algorithms" registry to include [[This Document]] as a reference for 1880 all rows where it is not already present. Note to IANA: There is an 1881 action in [I-D.ietf-cose-rfc8152bis-struct] which also modifies data 1882 in the reference column. That action should be applied first. 1884 IANA is rquested to add a new row to the "COSE Algorithms" registry. 1886 +----------+---------------+-------------+------------+-------------+ 1887 | Name | Value | Description | Reference | Recommended | 1888 +==========+===============+=============+============+=============+ 1889 | IV | IV-GENERATION |Reserved for | [[THIS | No | 1890 |Generation| | doing IV | DOCUMENT]] | | 1891 | | | generation | | | 1892 | | |for symmetric| | | 1893 | | | algorithms. | | | 1894 +----------+---------------+-------------+------------+-------------+ 1896 Table 23 1898 The capabilities column for this registration is to be empty. 1900 10.3. Changes to the "COSE Key Type Parameters" registry 1902 IANA is requested to modify the description to "Public Key" for the 1903 line with "Key Type" of 2 and the "Name" of "x". See Table 20 which 1904 has been modified with this change. 1906 IANA is requested to update the references in the table from RFC8152 1907 to [[This Document]]. 1909 11. Security Considerations 1911 There are a number of security considerations that need to be taken 1912 into account by implementers of this specification. The security 1913 considerations that are specific to an individual algorithm are 1914 placed next to the description of the algorithm. While some 1915 considerations have been highlighted here, additional considerations 1916 may be found in the documents listed in the references. 1918 Implementations need to protect the private key material for any 1919 individuals. There are some cases in this document that need to be 1920 highlighted on this issue. 1922 * Using the same key for two different algorithms can leak 1923 information about the key. It is therefore recommended that keys 1924 be restricted to a single algorithm. 1926 * Use of 'direct' as a recipient algorithm combined with a second 1927 recipient algorithm exposes the direct key to the second 1928 recipient. 1930 * Several of the algorithms in this document have limits on the 1931 number of times that a key can be used without leaking information 1932 about the key. 1934 The use of ECDH and direct plus KDF (with no key wrap) will not 1935 directly lead to the private key being leaked; the one way function 1936 of the KDF will prevent that. There is, however, a different issue 1937 that needs to be addressed. Having two recipients requires that the 1938 CEK be shared between two recipients. The second recipient therefore 1939 has a CEK that was derived from material that can be used for the 1940 weak proof of origin. The second recipient could create a message 1941 using the same CEK and send it to the first recipient; the first 1942 recipient would, for either static-static ECDH or direct plus KDF, 1943 make an assumption that the CEK could be used for proof of origin 1944 even though it is from the wrong entity. If the key wrap step is 1945 added, then no proof of origin is implied and this is not an issue. 1947 Although it has been mentioned before, the use of a single key for 1948 multiple algorithms has been demonstrated in some cases to leak 1949 information about a key, provide the opportunity for attackers to 1950 forge integrity tags, or gain information about encrypted content. 1951 Binding a key to a single algorithm prevents these problems. Key 1952 creators and key consumers are strongly encouraged not only to create 1953 new keys for each different algorithm, but to include that selection 1954 of algorithm in any distribution of key material and strictly enforce 1955 the matching of algorithms in the key structure to algorithms in the 1956 message structure. In addition to checking that algorithms are 1957 correct, the key form needs to be checked as well. Do not use an 1958 'EC2' key where an 'OKP' key is expected. 1960 Before using a key for transmission, or before acting on information 1961 received, a trust decision on a key needs to be made. Is the data or 1962 action something that the entity associated with the key has a right 1963 to see or a right to request? A number of factors are associated 1964 with this trust decision. Some of the ones that are highlighted here 1965 are: 1967 * What are the permissions associated with the key owner? 1969 * Is the cryptographic algorithm acceptable in the current context? 1971 * Have the restrictions associated with the key, such as algorithm 1972 or freshness, been checked and are they correct? 1974 * Is the request something that is reasonable, given the current 1975 state of the application? 1977 * Have any security considerations that are part of the message been 1978 enforced (as specified by the application or 'crit' parameter)? 1980 There are a large number of algorithms presented in this document 1981 that use nonce values. For all of the nonces defined in this 1982 document, there is some type of restriction on the nonce being a 1983 unique value either for a key or for some other conditions. In all 1984 of these cases, there is no known requirement on the nonce being both 1985 unique and unpredictable; under these circumstances, it's reasonable 1986 to use a counter for creation of the nonce. In cases where one wants 1987 the pattern of the nonce to be unpredictable as well as unique, one 1988 can use a key created for that purpose and encrypt the counter to 1989 produce the nonce value. 1991 One area that has been starting to get exposure is doing traffic 1992 analysis of encrypted messages based on the length of the message. 1993 This specification does not provide for a uniform method of providing 1994 padding as part of the message structure. An observer can 1995 distinguish between two different messages (for example, 'YES' and 1996 'NO') based on the length for all of the content encryption 1997 algorithms that are defined in this document. This means that it is 1998 up to the applications to document how content padding is to be done 1999 in order to prevent or discourage such analysis. (For example, the 2000 text strings could be defined as 'YES' and 'NO '.) 2002 12. References 2004 12.1. Normative References 2006 [I-D.ietf-cose-rfc8152bis-struct] 2007 Schaad, J., "CBOR Object Signing and Encryption (COSE): 2008 Structures and Process", Work in Progress, Internet-Draft, 2009 draft-ietf-cose-rfc8152bis-struct-09, 14 May 2020, 2010 . 2013 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 2014 Hashing for Message Authentication", RFC 2104, 2015 DOI 10.17487/RFC2104, February 1997, 2016 . 2018 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2019 Requirement Levels", BCP 14, RFC 2119, 2020 DOI 10.17487/RFC2119, March 1997, 2021 . 2023 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 2024 (AES) Key Wrap Algorithm", RFC 3394, DOI 10.17487/RFC3394, 2025 September 2002, . 2027 [RFC3610] Whiting, D., Housley, R., and N. Ferguson, "Counter with 2028 CBC-MAC (CCM)", RFC 3610, DOI 10.17487/RFC3610, September 2029 2003, . 2031 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 2032 Key Derivation Function (HKDF)", RFC 5869, 2033 DOI 10.17487/RFC5869, May 2010, 2034 . 2036 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 2037 Curve Cryptography Algorithms", RFC 6090, 2038 DOI 10.17487/RFC6090, February 2011, 2039 . 2041 [RFC6979] Pornin, T., "Deterministic Usage of the Digital Signature 2042 Algorithm (DSA) and Elliptic Curve Digital Signature 2043 Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, August 2044 2013, . 2046 [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object 2047 Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, 2048 October 2013, . 2050 [RFC8439] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 2051 Protocols", RFC 8439, DOI 10.17487/RFC8439, June 2018, 2052 . 2054 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 2055 for Security", RFC 7748, DOI 10.17487/RFC7748, January 2056 2016, . 2058 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2059 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2060 May 2017, . 2062 [AES-GCM] National Institute of Standards and Technology, 2063 "Recommendation for Block Cipher Modes of Operation: 2064 Galois/Counter Mode (GCM) and GMAC", 2065 DOI 10.6028/NIST.SP.800-38D, NIST Special 2066 Publication 800-38D, November 2007, 2067 . 2070 [DSS] National Institute of Standards and Technology, "Digital 2071 Signature Standard (DSS)", DOI 10.6028/NIST.FIPS.186-4, 2072 FIPS PUB 186-4, July 2013, 2073 . 2076 [MAC] National Institute of Standards and Technology, "Computer 2077 Data Authentication", FIPS PUB 113, May 1985, 2078 . 2081 [SEC1] Certicom Research, "SEC 1: Elliptic Curve Cryptography", 2082 May 2009, . 2084 [RFC8032] Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital 2085 Signature Algorithm (EdDSA)", RFC 8032, 2086 DOI 10.17487/RFC8032, January 2017, 2087 . 2089 12.2. Informative References 2091 [RFC8610] Birkholz, H., Vigano, C., and C. Bormann, "Concise Data 2092 Definition Language (CDDL): A Notational Convention to 2093 Express Concise Binary Object Representation (CBOR) and 2094 JSON Data Structures", RFC 8610, DOI 10.17487/RFC8610, 2095 June 2019, . 2097 [RFC4231] Nystrom, M., "Identifiers and Test Vectors for HMAC-SHA- 2098 224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512", 2099 RFC 4231, DOI 10.17487/RFC4231, December 2005, 2100 . 2102 [RFC4493] Song, JH., Poovendran, R., Lee, J., and T. Iwata, "The 2103 AES-CMAC Algorithm", RFC 4493, DOI 10.17487/RFC4493, June 2104 2006, . 2106 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 2107 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 2108 . 2110 [RFC5480] Turner, S., Brown, D., Yiu, K., Housley, R., and T. Polk, 2111 "Elliptic Curve Cryptography Subject Public Key 2112 Information", RFC 5480, DOI 10.17487/RFC5480, March 2009, 2113 . 2115 [RFC6151] Turner, S. and L. Chen, "Updated Security Considerations 2116 for the MD5 Message-Digest and the HMAC-MD5 Algorithms", 2117 RFC 6151, DOI 10.17487/RFC6151, March 2011, 2118 . 2120 [RFC8259] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data 2121 Interchange Format", STD 90, RFC 8259, 2122 DOI 10.17487/RFC8259, December 2017, 2123 . 2125 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 2126 Application Protocol (CoAP)", RFC 7252, 2127 DOI 10.17487/RFC7252, June 2014, 2128 . 2130 [RFC7518] Jones, M., "JSON Web Algorithms (JWA)", RFC 7518, 2131 DOI 10.17487/RFC7518, May 2015, 2132 . 2134 [RFC8017] Moriarty, K., Ed., Kaliski, B., Jonsson, J., and A. Rusch, 2135 "PKCS #1: RSA Cryptography Specifications Version 2.2", 2136 RFC 8017, DOI 10.17487/RFC8017, November 2016, 2137 . 2139 [RFC8152] Schaad, J., "CBOR Object Signing and Encryption (COSE)", 2140 RFC 8152, DOI 10.17487/RFC8152, July 2017, 2141 . 2143 [RFC8551] Schaad, J., Ramsdell, B., and S. Turner, "Secure/ 2144 Multipurpose Internet Mail Extensions (S/MIME) Version 4.0 2145 Message Specification", RFC 8551, DOI 10.17487/RFC8551, 2146 April 2019, . 2148 [RFC8230] Jones, M., "Using RSA Algorithms with CBOR Object Signing 2149 and Encryption (COSE) Messages", RFC 8230, 2150 DOI 10.17487/RFC8230, September 2017, 2151 . 2153 [I-D.ietf-core-oscore-groupcomm] 2154 Tiloca, M., Selander, G., Palombini, F., and J. Park, 2155 "Group OSCORE - Secure Group Communication for CoAP", Work 2156 in Progress, Internet-Draft, draft-ietf-core-oscore- 2157 groupcomm-08, 6 April 2020, . 2160 [I-D.ietf-cose-hash-sig] 2161 Housley, R., "Use of the HSS/LMS Hash-based Signature 2162 Algorithm with CBOR Object Signing and Encryption (COSE)", 2163 Work in Progress, Internet-Draft, draft-ietf-cose-hash- 2164 sig-09, 11 December 2019, 2165 . 2167 [I-D.ietf-cbor-sequence] 2168 Bormann, C., "Concise Binary Object Representation (CBOR) 2169 Sequences", Work in Progress, Internet-Draft, draft-ietf- 2170 cbor-sequence-02, 25 September 2019, 2171 . 2173 [SP800-56A] 2174 Barker, E., Chen, L., Roginsky, A., and M. Smid, 2175 "Recommendation for Pair-Wise Key Establishment Schemes 2176 Using Discrete Logarithm Cryptography", 2177 DOI 10.6028/NIST.SP.800-56Ar2, NIST Special Publication 2178 800-56A, Revision 2, May 2013, 2179 . 2182 Acknowledgments 2184 This document is a product of the COSE working group of the IETF. 2186 The following individuals are to blame for getting me started on this 2187 project in the first place: Richard Barnes, Matt Miller, and Martin 2188 Thomson. 2190 The initial version of the specification was based to some degree on 2191 the outputs of the JOSE and S/MIME working groups. 2193 The following individuals provided input into the final form of the 2194 document: Carsten Bormann, John Bradley, Brain Campbell, Michael B. 2195 Jones, Ilari Liusvaara, Francesca Palombini, Ludwig Seitz, and Goran 2196 Selander. 2198 Author's Address 2200 Jim Schaad 2201 August Cellars 2203 Email: ietf@augustcellars.com