idnits 2.17.1 draft-ietf-cose-rfc8152bis-algs-07.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 (9 March 2020) is 1502 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 1803 -- Looks like a reference, but probably isn't: '1' on line 1807 -- Looks like a reference, but probably isn't: '4' on line 1807 == Outdated reference: A later version (-15) exists of draft-ietf-cose-rfc8152bis-struct-07 -- 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-06 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) 9 March 2020 5 Intended status: Standards Track 6 Expires: 10 September 2020 8 CBOR Object Signing and Encryption (COSE): Initial Algorithms 9 draft-ietf-cose-rfc8152bis-algs-07 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 10 September 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 . . . . . . . . . . . . . . . . . . . . . . 4 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 . . . . . . . . . . . . . . . . . . 17 94 4.3.1. Security Considerations . . . . . . . . . . . . . . . 18 95 5. Key Derivation Functions (KDFs) . . . . . . . . . . . . . . . 18 96 5.1. HMAC-Based Extract-and-Expand Key Derivation Function 97 (HKDF) . . . . . . . . . . . . . . . . . . . . . . . . . 19 98 5.2. Context Information Structure . . . . . . . . . . . . . . 20 99 6. Content Key Distribution Methods . . . . . . . . . . . . . . 25 100 6.1. Direct Encryption . . . . . . . . . . . . . . . . . . . . 26 101 6.1.1. Direct Key . . . . . . . . . . . . . . . . . . . . . 26 102 6.1.2. Direct Key with KDF . . . . . . . . . . . . . . . . . 27 103 6.2. AES Key Wrap . . . . . . . . . . . . . . . . . . . . . . 29 104 6.2.1. Security Considerations for AES-KW . . . . . . . . . 29 105 6.3. Direct ECDH . . . . . . . . . . . . . . . . . . . . . . . 30 106 6.3.1. Security Considerations . . . . . . . . . . . . . . . 33 107 6.4. ECDH with Key Wrap . . . . . . . . . . . . . . . . . . . 33 108 7. Key Object Parameters . . . . . . . . . . . . . . . . . . . . 35 109 7.1. Elliptic Curve Keys . . . . . . . . . . . . . . . . . . . 35 110 7.1.1. Double Coordinate Curves . . . . . . . . . . . . . . 36 111 7.2. Octet Key Pair . . . . . . . . . . . . . . . . . . . . . 37 112 7.3. Symmetric Keys . . . . . . . . . . . . . . . . . . . . . 38 113 8. COSE Capabilities . . . . . . . . . . . . . . . . . . . . . . 39 114 8.1. Assignments for Existing Key Types . . . . . . . . . . . 39 115 8.2. Assignments for Existing Algorithms . . . . . . . . . . . 40 116 8.3. Examples . . . . . . . . . . . . . . . . . . . . . . . . 40 117 9. CBOR Encoding Restrictions . . . . . . . . . . . . . . . . . 41 118 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 41 119 10.1. Changes to "COSE Key Types" registry. . . . . . . . . . 41 120 10.2. Changes to "COSE Algorithms" registry . . . . . . . . . 42 121 10.3. Changes to the "COSE Key Type Parameters" registry . . . 42 122 11. Security Considerations . . . . . . . . . . . . . . . . . . . 42 123 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 44 124 12.1. Normative References . . . . . . . . . . . . . . . . . . 44 125 12.2. Informative References . . . . . . . . . . . . . . . . . 46 126 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 48 127 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 48 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 1.4. CBOR Grammar 189 At the time that [RFC8152] was initially published, the CBOR Data 190 Definition Language (CDDL) [RFC8610] had not yet been published. 191 This document uses a variant of CDDL which is described in 192 [I-D.ietf-cose-rfc8152bis-struct] 194 1.5. Examples 196 A GitHub project has been created at that contains a set of testing examples as well. Each 198 example is found in a JSON file that contains the inputs used to 199 create the example, some of the intermediate values that can be used 200 in debugging the example and the output of the example presented in 201 both a hex and a CBOR diagnostic notation format. Some of the 202 examples at the site are designed failure testing cases; these are 203 clearly marked as such in the JSON file. If errors in the examples 204 in this document are found, the examples on GitHub will be updated, 205 and a note to that effect will be placed in the JSON file. 207 2. Signature Algorithms 209 Part Section 9.1 of [I-D.ietf-cose-rfc8152bis-struct] contains a 210 generic description of signature algorithms. The document defines 211 signature algorithm identifiers for two signature algorithms. 213 2.1. ECDSA 215 ECDSA [DSS] defines a signature algorithm using ECC. Implementations 216 SHOULD use a deterministic version of ECDSA such as the one defined 217 in [RFC6979]. The use of a deterministic signature algorithm allows 218 for systems to avoid relying on random number generators in order to 219 avoid generating the same value of 'k' (the per-message random 220 value). Biased generation of the value 'k' can be attacked, and 221 collisions of this value leads to leaked keys. It additionally 222 allows for doing deterministic tests for the signature algorithm. 223 The use of deterministic ECDSA does not lessen the need to have good 224 random number generation when creating the private key. 226 The ECDSA signature algorithm is parameterized with a hash function 227 (h). In the event that the length of the hash function output is 228 greater than the group of the key, the leftmost bytes of the hash 229 output are used. 231 The algorithms defined in this document can be found in Table 1. 233 +-------+-------+---------+------------------+ 234 | Name | Value | Hash | Description | 235 +=======+=======+=========+==================+ 236 | ES256 | -7 | SHA-256 | ECDSA w/ SHA-256 | 237 +-------+-------+---------+------------------+ 238 | ES384 | -35 | SHA-384 | ECDSA w/ SHA-384 | 239 +-------+-------+---------+------------------+ 240 | ES512 | -36 | SHA-512 | ECDSA w/ SHA-512 | 241 +-------+-------+---------+------------------+ 243 Table 1: ECDSA Algorithm Values 245 This document defines ECDSA to work only with the curves P-256, 246 P-384, and P-521. This document requires that the curves be encoded 247 using the 'EC2' (2 coordinate elliptic curve) key type. 248 Implementations need to check that the key type and curve are correct 249 when creating and verifying a signature. Other documents can define 250 it to work with other curves and points in the future. 252 In order to promote interoperability, it is suggested that SHA-256 be 253 used only with curve P-256, SHA-384 be used only with curve P-384, 254 and SHA-512 be used with curve P-521. This is aligned with the 255 recommendation in Section 4 of [RFC5480]. 257 The signature algorithm results in a pair of integers (R, S). These 258 integers will be the same length as the length of the key used for 259 the signature process. The signature is encoded by converting the 260 integers into byte strings of the same length as the key size. The 261 length is rounded up to the nearest byte and is left padded with zero 262 bits to get to the correct length. The two integers are then 263 concatenated together to form a byte string that is the resulting 264 signature. 266 Using the function defined in [RFC8017], the signature is: 268 Signature = I2OSP(R, n) | I2OSP(S, n) 270 where n = ceiling(key_length / 8) 272 When using a COSE key for this algorithm, the following checks are 273 made: 275 * The 'kty' field MUST be present, and it MUST be 'EC2'. 277 * If the 'alg' field is present, it MUST match the ECDSA signature 278 algorithm being used. 280 * If the 'key_ops' field is present, it MUST include 'sign' when 281 creating an ECDSA signature. 283 * If the 'key_ops' field is present, it MUST include 'verify' when 284 verifying an ECDSA signature. 286 2.1.1. Security Considerations 288 The security strength of the signature is no greater than the minimum 289 of the security strength associated with the bit length of the key 290 and the security strength of the hash function. 292 Note: Use of a deterministic signature technique is a good idea even 293 when good random number generation exists. Doing so both reduces the 294 possibility of having the same value of 'k' in two signature 295 operations and allows for reproducible signature values, which helps 296 testing. 298 There are two substitution attacks that can theoretically be mounted 299 against the ECDSA signature algorithm. 301 * Changing the curve used to validate the signature: If one changes 302 the curve used to validate the signature, then potentially one 303 could have two messages with the same signature, each computed 304 under a different curve. The only requirement on the new curve is 305 that its order be the same as the old one and it be acceptable to 306 the client. An example would be to change from using the curve 307 secp256r1 (aka P-256) to using secp256k1. (Both are 256-bit 308 curves.) We currently do not have any way to deal with this 309 version of the attack except to restrict the overall set of curves 310 that can be used. 312 * Change the hash function used to validate the signature: If one 313 either has two different hash functions of the same length or can 314 truncate a hash function down, then one could potentially find 315 collisions between the hash functions rather than within a single 316 hash function (for example, truncating SHA-512 to 256 bits might 317 collide with a SHA-256 bit hash value). As the hash algorithm is 318 part of the signature algorithm identifier, this attack is 319 mitigated by including a signature algorithm identifier in the 320 protected header bucket. 322 2.2. Edwards-Curve Digital Signature Algorithms (EdDSAs) 324 [RFC8032] describes the elliptic curve signature scheme Edwards-curve 325 Digital Signature Algorithm (EdDSA). In that document, the signature 326 algorithm is instantiated using parameters for edwards25519 and 327 edwards448 curves. The document additionally describes two variants 328 of the EdDSA algorithm: Pure EdDSA, where no hash function is applied 329 to the content before signing, and HashEdDSA, where a hash function 330 is applied to the content before signing and the result of that hash 331 function is signed. For EdDSA, the content to be signed (either the 332 message or the pre-hash value) is processed twice inside of the 333 signature algorithm. For use with COSE, only the pure EdDSA version 334 is used. This is because it is not expected that extremely large 335 contents are going to be needed and, based on the arrangement of the 336 message structure, the entire message is going to need to be held in 337 memory in order to create or verify a signature. This means that 338 there does not appear to be a need to be able to do block updates of 339 the hash, followed by eliminating the message from memory. 340 Applications can provide the same features by defining the content of 341 the message as a hash value and transporting the COSE object (with 342 the hash value) and the content as separate items. 344 The algorithms defined in this document can be found in Table 2. A 345 single signature algorithm is defined, which can be used for multiple 346 curves. 348 +-------+-------+-------------+ 349 | Name | Value | Description | 350 +=======+=======+=============+ 351 | EdDSA | -8 | EdDSA | 352 +-------+-------+-------------+ 354 Table 2: EdDSA Algorithm Values 356 [RFC8032] describes the method of encoding the signature value. 358 When using a COSE key for this algorithm, the following checks are 359 made: 361 * The 'kty' field MUST be present, and it MUST be 'OKP' (Octet Key 362 Pair). 364 * The 'crv' field MUST be present, and it MUST be a curve defined 365 for this signature algorithm. 367 * If the 'alg' field is present, it MUST match 'EdDSA'. 369 * If the 'key_ops' field is present, it MUST include 'sign' when 370 creating an EdDSA signature. 372 * If the 'key_ops' field is present, it MUST include 'verify' when 373 verifying an EdDSA signature. 375 2.2.1. Security Considerations 377 How public values are computed is not the same when looking at EdDSA 378 and Elliptic Curve Diffie-Hellman (ECDH); for this reason, they 379 should not be used with the other algorithm. 381 If batch signature verification is performed, a well-seeded 382 cryptographic random number generator is REQUIRED. Signing and non- 383 batch signature verification are deterministic operations and do not 384 need random numbers of any kind. 386 3. Message Authentication Code (MAC) Algorithms 388 Part Section 9.2 of [I-D.ietf-cose-rfc8152bis-struct] contains a 389 generic description of MAC algorithms. This section defines the 390 conventions for two MAC algorithms. 392 3.1. Hash-Based Message Authentication Codes (HMACs) 394 HMAC [RFC2104] [RFC4231] was designed to deal with length extension 395 attacks. The algorithm was also designed to allow for new hash 396 algorithms to be directly plugged in without changes to the hash 397 function. The HMAC design process has been shown as solid since, 398 while the security of hash algorithms such as MD5 has decreased over 399 time; the security of HMAC combined with MD5 has not yet been shown 400 to be compromised [RFC6151]. 402 The HMAC algorithm is parameterized by an inner and outer padding, a 403 hash function (h), and an authentication tag value length. For this 404 specification, the inner and outer padding are fixed to the values 405 set in [RFC2104]. The length of the authentication tag corresponds 406 to the difficulty of producing a forgery. For use in constrained 407 environments, we define one HMAC algorithm that is truncated. There 408 are currently no known issues with truncation; however, the security 409 strength of the message tag is correspondingly reduced in strength. 410 When truncating, the leftmost tag length bits are kept and 411 transmitted. 413 The algorithms defined in this document can be found in Table 3. 415 +-------------+-------+---------+------------+----------------------+ 416 | Name | Value | Hash | Tag Length | Description | 417 +=============+=======+=========+============+======================+ 418 | HMAC | 4 | SHA-256 | 64 | HMAC w/ SHA-256 | 419 | 256/64 | | | | truncated to 64 bits | 420 +-------------+-------+---------+------------+----------------------+ 421 | HMAC | 5 | SHA-256 | 256 | HMAC w/ SHA-256 | 422 | 256/256 | | | | | 423 +-------------+-------+---------+------------+----------------------+ 424 | HMAC | 6 | SHA-384 | 384 | HMAC w/ SHA-384 | 425 | 384/384 | | | | | 426 +-------------+-------+---------+------------+----------------------+ 427 | HMAC | 7 | SHA-512 | 512 | HMAC w/ SHA-512 | 428 | 512/512 | | | | | 429 +-------------+-------+---------+------------+----------------------+ 431 Table 3: HMAC Algorithm Values 433 Some recipient algorithms carry the key while others derive a key 434 from secret data. For those algorithms that carry the key (such as 435 AES Key Wrap), the size of the HMAC key SHOULD be the same size as 436 the underlying hash function. For those algorithms that derive the 437 key (such as ECDH), the derived key MUST be the same size as the 438 underlying hash function. 440 When using a COSE key for this algorithm, the following checks are 441 made: 443 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 445 * If the 'alg' field is present, it MUST match the HMAC algorithm 446 being used. 448 * If the 'key_ops' field is present, it MUST include 'MAC create' 449 when creating an HMAC authentication tag. 451 * If the 'key_ops' field is present, it MUST include 'MAC verify' 452 when verifying an HMAC authentication tag. 454 Implementations creating and validating MAC values MUST validate that 455 the key type, key length, and algorithm are correct and appropriate 456 for the entities involved. 458 3.1.1. Security Considerations 460 HMAC has proved to be resistant to attack even when used with 461 weakened hash algorithms. The current best known attack is to brute 462 force the key. This means that key size is going to be directly 463 related to the security of an HMAC operation. 465 3.2. AES Message Authentication Code (AES-CBC-MAC) 467 AES-CBC-MAC is defined in [MAC]. (Note that this is not the same 468 algorithm as AES Cipher-Based Message Authentication Code (AES-CMAC) 469 [RFC4493].) 471 AES-CBC-MAC is parameterized by the key length, the authentication 472 tag length, and the IV used. For all of these algorithms, the IV is 473 fixed to all zeros. We provide an array of algorithms for various 474 key lengths and tag lengths. The algorithms defined in this document 475 are found in Table 4. 477 +---------+-------+------------+------------+------------------+ 478 | Name | Value | Key Length | Tag Length | Description | 479 +=========+=======+============+============+==================+ 480 | AES-MAC | 14 | 128 | 64 | AES-MAC 128-bit | 481 | 128/64 | | | | key, 64-bit tag | 482 +---------+-------+------------+------------+------------------+ 483 | AES-MAC | 15 | 256 | 64 | AES-MAC 256-bit | 484 | 256/64 | | | | key, 64-bit tag | 485 +---------+-------+------------+------------+------------------+ 486 | AES-MAC | 25 | 128 | 128 | AES-MAC 128-bit | 487 | 128/128 | | | | key, 128-bit tag | 488 +---------+-------+------------+------------+------------------+ 489 | AES-MAC | 26 | 256 | 128 | AES-MAC 256-bit | 490 | 256/128 | | | | key, 128-bit tag | 491 +---------+-------+------------+------------+------------------+ 493 Table 4: AES-MAC Algorithm Values 495 Keys may be obtained either from a key structure or from a recipient 496 structure. Implementations creating and validating MAC values MUST 497 validate that the key type, key length, and algorithm are correct and 498 appropriate for the entities involved. 500 When using a COSE key for this algorithm, the following checks are 501 made: 503 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 505 * If the 'alg' field is present, it MUST match the AES-MAC algorithm 506 being used. 508 * If the 'key_ops' field is present, it MUST include 'MAC create' 509 when creating an AES-MAC authentication tag. 511 * If the 'key_ops' field is present, it MUST include 'MAC verify' 512 when verifying an AES-MAC authentication tag. 514 3.2.1. Security Considerations 516 A number of attacks exist against Cipher Block Chaining Message 517 Authentication Code (CBC-MAC) that need to be considered. 519 * A single key must only be used for messages of a fixed or known 520 length. If this is not the case, an attacker will be able to 521 generate a message with a valid tag given two message and tag 522 pairs. This can be addressed by using different keys for messages 523 of different lengths. The current structure mitigates this 524 problem, as a specific encoding structure that includes lengths is 525 built and signed. (CMAC also addresses this issue.) 527 * Cipher Block Chaining (CBC) mode, if the same key is used for both 528 encryption and authentication operations, an attacker can produce 529 messages with a valid authentication code. 531 * If the IV can be modified, then messages can be forged. This is 532 addressed by fixing the IV to all zeros. 534 4. Content Encryption Algorithms 536 Part Section 9.3 of [I-D.ietf-cose-rfc8152bis-struct] contains a 537 generic description of Content Encryption algorithms. This document 538 defines the identifier and usages for three content encryption 539 algorithms. 541 4.1. AES GCM 543 The Galois/Counter Mode (GCM) mode is a generic authenticated 544 encryption block cipher mode defined in [AES-GCM]. The GCM mode is 545 combined with the AES block encryption algorithm to define an AEAD 546 cipher. 548 The GCM mode is parameterized by the size of the authentication tag 549 and the size of the nonce. This document fixes the size of the nonce 550 at 96 bits. The size of the authentication tag is limited to a small 551 set of values. For this document however, the size of the 552 authentication tag is fixed at 128 bits. 554 The set of algorithms defined in this document are in Table 5. 556 +---------+-------+------------------------------------------+ 557 | Name | Value | Description | 558 +=========+=======+==========================================+ 559 | A128GCM | 1 | AES-GCM mode w/ 128-bit key, 128-bit tag | 560 +---------+-------+------------------------------------------+ 561 | A192GCM | 2 | AES-GCM mode w/ 192-bit key, 128-bit tag | 562 +---------+-------+------------------------------------------+ 563 | A256GCM | 3 | AES-GCM mode w/ 256-bit key, 128-bit tag | 564 +---------+-------+------------------------------------------+ 566 Table 5: Algorithm Value for AES-GCM 568 Keys may be obtained either from a key structure or from a recipient 569 structure. Implementations encrypting and decrypting MUST validate 570 that the key type, key length, and algorithm are correct and 571 appropriate for the entities involved. 573 When using a COSE key for this algorithm, the following checks are 574 made: 576 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 578 * If the 'alg' field is present, it MUST match the AES-GCM algorithm 579 being used. 581 * If the 'key_ops' field is present, it MUST include 'encrypt' or 582 'wrap key' when encrypting. 584 * If the 'key_ops' field is present, it MUST include 'decrypt' or 585 'unwrap key' when decrypting. 587 4.1.1. Security Considerations 589 When using AES-GCM, the following restrictions MUST be enforced: 591 * The key and nonce pair MUST be unique for every message encrypted. 593 * The total amount of data encrypted for a single key MUST NOT 594 exceed 2^39 - 256 bits. An explicit check is required only in 595 environments where it is expected that it might be exceeded. 597 Consideration was given to supporting smaller tag values; the 598 constrained community would desire tag sizes in the 64-bit range. 599 Doing so drastically changes both the maximum messages size 600 (generally not an issue) and the number of times that a key can be 601 used. Given that Counter with CBC-MAC (CCM) is the usual mode for 602 constrained environments, restricted modes are not supported. 604 4.2. AES CCM 606 CCM is a generic authentication encryption block cipher mode defined 607 in [RFC3610]. The CCM mode is combined with the AES block encryption 608 algorithm to define a commonly used content encryption algorithm used 609 in constrained devices. 611 The CCM mode has two parameter choices. The first choice is M, the 612 size of the authentication field. The choice of the value for M 613 involves a trade-off between message growth (from the tag) and the 614 probability that an attacker can undetectably modify a message. The 615 second choice is L, the size of the length field. This value 616 requires a trade-off between the maximum message size and the size of 617 the Nonce. 619 It is unfortunate that the specification for CCM specified L and M as 620 a count of bytes rather than a count of bits. This leads to possible 621 misunderstandings where AES-CCM-8 is frequently used to refer to a 622 version of CCM mode where the size of the authentication is 64 bits 623 and not 8 bits. These values have traditionally been specified as 624 bit counts rather than byte counts. This document will follow the 625 convention of using bit counts so that it is easier to compare the 626 different algorithms presented in this document. 628 We define a matrix of algorithms in this document over the values of 629 L and M. Constrained devices are usually operating in situations 630 where they use short messages and want to avoid doing recipient- 631 specific cryptographic operations. This favors smaller values of 632 both L and M. Less-constrained devices will want to be able to use 633 larger messages and are more willing to generate new keys for every 634 operation. This favors larger values of L and M. 636 The following values are used for L: 638 16 bits (2): This limits messages to 2^16 bytes (64 KiB) in length. 639 This is sufficiently long for messages in the constrained world. 640 The nonce length is 13 bytes allowing for 2^104 possible values of 641 the nonce without repeating. 643 64 bits (8): This limits messages to 2^64 bytes in length. The 644 nonce length is 7 bytes allowing for 2^56 possible values of the 645 nonce without repeating. 647 The following values are used for M: 649 64 bits (8): This produces a 64-bit authentication tag. This 650 implies that there is a 1 in 2^64 chance that a modified message 651 will authenticate. 653 128 bits (16): This produces a 128-bit authentication tag. This 654 implies that there is a 1 in 2^128 chance that a modified message 655 will authenticate. 657 +--------------------+-------+----+-----+-----+---------------------+ 658 | Name | Value | L | M | k | Description | 659 +====================+=======+====+=====+=====+=====================+ 660 | AES-CCM-16-64-128 | 10 | 16 | 64 | 128 | AES-CCM mode | 661 | | | | | | 128-bit key, | 662 | | | | | | 64-bit tag, | 663 | | | | | | 13-byte nonce | 664 +--------------------+-------+----+-----+-----+---------------------+ 665 | AES-CCM-16-64-256 | 11 | 16 | 64 | 256 | AES-CCM mode | 666 | | | | | | 256-bit key, | 667 | | | | | | 64-bit tag, | 668 | | | | | | 13-byte nonce | 669 +--------------------+-------+----+-----+-----+---------------------+ 670 | AES-CCM-64-64-128 | 12 | 64 | 64 | 128 | AES-CCM mode | 671 | | | | | | 128-bit key, | 672 | | | | | | 64-bit tag, | 673 | | | | | | 7-byte nonce | 674 +--------------------+-------+----+-----+-----+---------------------+ 675 | AES-CCM-64-64-256 | 13 | 64 | 64 | 256 | AES-CCM mode | 676 | | | | | | 256-bit key, | 677 | | | | | | 64-bit tag, | 678 | | | | | | 7-byte nonce | 679 +--------------------+-------+----+-----+-----+---------------------+ 680 | AES-CCM-16-128-128 | 30 | 16 | 128 | 128 | AES-CCM mode | 681 | | | | | | 128-bit key, | 682 | | | | | | 128-bit tag, | 683 | | | | | | 13-byte nonce | 684 +--------------------+-------+----+-----+-----+---------------------+ 685 | AES-CCM-16-128-256 | 31 | 16 | 128 | 256 | AES-CCM mode | 686 | | | | | | 256-bit key, | 687 | | | | | | 128-bit tag, | 688 | | | | | | 13-byte nonce | 689 +--------------------+-------+----+-----+-----+---------------------+ 690 | AES-CCM-64-128-128 | 32 | 64 | 128 | 128 | AES-CCM mode | 691 | | | | | | 128-bit key, | 692 | | | | | | 128-bit tag, | 693 | | | | | | 7-byte nonce | 694 +--------------------+-------+----+-----+-----+---------------------+ 695 | AES-CCM-64-128-256 | 33 | 64 | 128 | 256 | AES-CCM mode | 696 | | | | | | 256-bit key, | 697 | | | | | | 128-bit tag, | 698 | | | | | | 7-byte nonce | 699 +--------------------+-------+----+-----+-----+---------------------+ 701 Table 6: Algorithm Values for AES-CCM 703 Keys may be obtained either from a key structure or from a recipient 704 structure. Implementations encrypting and decrypting MUST validate 705 that the key type, key length, and algorithm are correct and 706 appropriate for the entities involved. 708 When using a COSE key for this algorithm, the following checks are 709 made: 711 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 713 * If the 'alg' field is present, it MUST match the AES-CCM algorithm 714 being used. 716 * If the 'key_ops' field is present, it MUST include 'encrypt' or 717 'wrap key' when encrypting. 719 * If the 'key_ops' field is present, it MUST include 'decrypt' or 720 'unwrap key' when decrypting. 722 4.2.1. Security Considerations 724 When using AES-CCM, the following restrictions MUST be enforced: 726 * The key and nonce pair MUST be unique for every message encrypted. 727 Note that the value of L influences the number of unique nonces. 729 * The total number of times the AES block cipher is used MUST NOT 730 exceed 2^61 operations. This limitation is the sum of times the 731 block cipher is used in computing the MAC value and in performing 732 stream encryption operations. An explicit check is required only 733 in environments where it is expected that it might be exceeded. 735 [RFC3610] additionally calls out one other consideration of note. It 736 is possible to do a pre-computation attack against the algorithm in 737 cases where portions of the plaintext are highly predictable. This 738 reduces the security of the key size by half. Ways to deal with this 739 attack include adding a random portion to the nonce value and/or 740 increasing the key size used. Using a portion of the nonce for a 741 random value will decrease the number of messages that a single key 742 can be used for. Increasing the key size may require more resources 743 in the constrained device. See Sections 5 and 10 of [RFC3610] for 744 more information. 746 4.3. ChaCha20 and Poly1305 748 ChaCha20 and Poly1305 combined together is an AEAD mode that is 749 defined in [RFC8439]. This is an algorithm defined to be a cipher 750 that is not AES and thus would not suffer from any future weaknesses 751 found in AES. These cryptographic functions are designed to be fast 752 in software-only implementations. 754 The ChaCha20/Poly1305 AEAD construction defined in [RFC8439] has no 755 parameterization. It takes a 256-bit key and a 96-bit nonce, as well 756 as the plaintext and additional data as inputs and produces the 757 ciphertext as an option. We define one algorithm identifier for this 758 algorithm in Table 7. 760 +-------------------+-------+--------------------------+ 761 | Name | Value | Description | 762 +===================+=======+==========================+ 763 | ChaCha20/Poly1305 | 24 | ChaCha20/Poly1305 w/ | 764 | | | 256-bit key, 128-bit tag | 765 +-------------------+-------+--------------------------+ 767 Table 7: Algorithm Value for AES-GCM 769 Keys may be obtained either from a key structure or from a recipient 770 structure. Implementations encrypting and decrypting MUST validate 771 that the key type, key length, and algorithm are correct and 772 appropriate for the entities involved. 774 When using a COSE key for this algorithm, the following checks are 775 made: 777 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 779 * If the 'alg' field is present, it MUST match the ChaCha20/Poly1305 780 algorithm being used. 782 * If the 'key_ops' field is present, it MUST include 'encrypt' or 783 'wrap key' when encrypting. 785 * If the 'key_ops' field is present, it MUST include 'decrypt' or 786 'unwrap key' when decrypting. 788 4.3.1. Security Considerations 790 The key and nonce values MUST be a unique pair for every invocation 791 of the algorithm. Nonce counters are considered to be an acceptable 792 way of ensuring that they are unique. 794 5. Key Derivation Functions (KDFs) 796 Part Section 9.4 of [I-D.ietf-cose-rfc8152bis-struct] contains a 797 generic description of Key Derivation Functions. This document 798 defines a single context structure and a single KDF. These elements 799 are used for all of the recipient algorithms defined in this document 800 that require a KDF process. These algorithms are defined in Sections 801 6.1.2, 6.3, and 6.4. 803 5.1. HMAC-Based Extract-and-Expand Key Derivation Function (HKDF) 805 The HKDF key derivation algorithm is defined in [RFC5869]. 807 The HKDF algorithm takes these inputs: 809 secret -- a shared value that is secret. Secrets may be either 810 previously shared or derived from operations like a Diffie-Hellman 811 (DH) key agreement. 813 salt -- an optional value that is used to change the generation 814 process. The salt value can be either public or private. If the 815 salt is public and carried in the message, then the 'salt' 816 algorithm header parameter defined in Table 9 is used. While 817 [RFC5869] suggests that the length of the salt be the same as the 818 length of the underlying hash value, any positive salt length will 819 improve the security as different key values will be generated. 820 This parameter is protected by being included in the key 821 computation and does not need to be separately authenticated. The 822 salt value does not need to be unique for every message sent. 824 length -- the number of bytes of output that need to be generated. 826 context information -- Information that describes the context in 827 which the resulting value will be used. Making this information 828 specific to the context in which the material is going to be used 829 ensures that the resulting material will always be tied to that 830 usage. The context structure defined in Section 5.2 is used by 831 the KDFs in this document. 833 PRF -- The underlying pseudorandom function to be used in the HKDF 834 algorithm. The PRF is encoded into the HKDF algorithm selection. 836 HKDF is defined to use HMAC as the underlying PRF. However, it is 837 possible to use other functions in the same construct to provide a 838 different KDF that is more appropriate in the constrained world. 839 Specifically, one can use AES-CBC-MAC as the PRF for the expand step, 840 but not for the extract step. When using a good random shared secret 841 of the correct length, the extract step can be skipped. For the AES 842 algorithm versions, the extract step is always skipped. 844 The extract step cannot be skipped if the secret is not uniformly 845 random, for example, if it is the result of an ECDH key agreement 846 step. This implies that the AES HKDF version cannot be used with 847 ECDH. If the extract step is skipped, the 'salt' value is not used 848 as part of the HKDF functionality. 850 The algorithms defined in this document are found in Table 8. 852 +--------------+-------------------+------------------------+ 853 | Name | PRF | Description | 854 +==============+===================+========================+ 855 | HKDF SHA-256 | HMAC with SHA-256 | HKDF using HMAC | 856 | | | SHA-256 as the PRF | 857 +--------------+-------------------+------------------------+ 858 | HKDF SHA-512 | HMAC with SHA-512 | HKDF using HMAC | 859 | | | SHA-512 as the PRF | 860 +--------------+-------------------+------------------------+ 861 | HKDF AES- | AES-CBC-MAC-128 | HKDF using AES-MAC as | 862 | MAC-128 | | the PRF w/ 128-bit key | 863 +--------------+-------------------+------------------------+ 864 | HKDF AES- | AES-CBC-MAC-256 | HKDF using AES-MAC as | 865 | MAC-256 | | the PRF w/ 256-bit key | 866 +--------------+-------------------+------------------------+ 868 Table 8: HKDF Algorithms 870 +------+-------+------+----------------------------+-------------+ 871 | Name | Label | Type | Algorithm | Description | 872 +======+=======+======+============================+=============+ 873 | salt | -20 | bstr | direct+HKDF-SHA-256, | Random salt | 874 | | | | direct+HKDF-SHA-512, | | 875 | | | | direct+HKDF-AES-128, | | 876 | | | | direct+HKDF-AES-256, ECDH- | | 877 | | | | ES+HKDF-256, ECDH-ES+HKDF- | | 878 | | | | 512, ECDH-SS+HKDF-256, | | 879 | | | | ECDH-SS+HKDF-512, ECDH- | | 880 | | | | ES+A128KW, ECDH-ES+A192KW, | | 881 | | | | ECDH-ES+A256KW, ECDH- | | 882 | | | | SS+A128KW, ECDH-SS+A192KW, | | 883 | | | | ECDH-SS+A256KW | | 884 +------+-------+------+----------------------------+-------------+ 886 Table 9: HKDF Algorithm Parameters 888 5.2. Context Information Structure 890 The context information structure is used to ensure that the derived 891 keying material is "bound" to the context of the transaction. The 892 context information structure used here is based on that defined in 893 [SP800-56A]. By using CBOR for the encoding of the context 894 information structure, we automatically get the same type and length 895 separation of fields that is obtained by the use of ASN.1. This 896 means that there is no need to encode the lengths for the base 897 elements, as it is done by the encoding used in JOSE (Section 4.6.2 898 of [RFC7518]). 900 The context information structure refers to PartyU and PartyV as the 901 two parties that are doing the key derivation. Unless the 902 application protocol defines differently, we assign PartyU to the 903 entity that is creating the message and PartyV to the entity that is 904 receiving the message. By doing this association, different keys 905 will be derived for each direction as the context information is 906 different in each direction. 908 The context structure is built from information that is known to both 909 entities. This information can be obtained from a variety of 910 sources: 912 * Fields can be defined by the application. This is commonly used 913 to assign fixed names to parties, but it can be used for other 914 items such as nonces. 916 * Fields can be defined by usage of the output. Examples of this 917 are the algorithm and key size that are being generated. 919 * Fields can be defined by parameters from the message. We define a 920 set of header parameters in Table 10 that can be used to carry the 921 values associated with the context structure. Examples of this 922 are identities and nonce values. These header parameters are 923 designed to be placed in the unprotected bucket of the recipient 924 structure; they do not need to be in the protected bucket since 925 they already are included in the cryptographic computation by 926 virtue of being included in the context structure. 928 +----------+-------+------+---------------------------+-------------+ 929 | Name | Label | Type | Algorithm | Description | 930 +==========+=======+======+===========================+=============+ 931 | PartyU | -21 | bstr | direct+HKDF-SHA-256, | Party U | 932 | identity | | | direct+HKDF-SHA-512, | identity | 933 | | | | direct+HKDF-AES-128, | information | 934 | | | | direct+HKDF-AES-256, | | 935 | | | | ECDH-ES+HKDF-256, | | 936 | | | | ECDH-ES+HKDF-512, | | 937 | | | | ECDH-SS+HKDF-256, | | 938 | | | | ECDH-SS+HKDF-512, | | 939 | | | | ECDH-ES+A128KW, | | 940 | | | | ECDH-ES+A192KW, | | 941 | | | | ECDH-ES+A256KW, | | 942 | | | | ECDH-SS+A128KW, | | 943 | | | | ECDH-SS+A192KW, | | 944 | | | | ECDH-SS+A256KW | | 945 +----------+-------+------+---------------------------+-------------+ 946 | PartyU | -22 | bstr | direct+HKDF-SHA-256, | Party U | 947 | nonce | | / | direct+HKDF-SHA-512, | provided | 948 | | | int | direct+HKDF-AES-128, | nonce | 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 | -23 | bstr | direct+HKDF-SHA-256, | Party U | 962 | other | | | direct+HKDF-SHA-512, | other | 963 | | | | direct+HKDF-AES-128, | provided | 964 | | | | direct+HKDF-AES-256, | information | 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 | PartyV | -24 | bstr | direct+HKDF-SHA-256, | Party V | 977 | identity | | | direct+HKDF-SHA-512, | identity | 978 | | | | direct+HKDF-AES-128, | information | 979 | | | | direct+HKDF-AES-256, | | 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 | -25 | bstr | direct+HKDF-SHA-256, | Party V | 992 | nonce | | / | direct+HKDF-SHA-512, | provided | 993 | | | int | direct+HKDF-AES-128, | nonce | 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 | -26 | bstr | direct+HKDF-SHA-256, | Party V | 1007 | other | | | direct+HKDF-SHA-512, | other | 1008 | | | | direct+HKDF-AES-128, | provided | 1009 | | | | direct+HKDF-AES-256, | information | 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 +----------+-------+------+---------------------------+-------------+ 1022 Table 10: Context Algorithm Parameters 1024 We define a CBOR object to hold the context information. This object 1025 is referred to as COSE_KDF_Context. The object is based on a CBOR 1026 array type. The fields in the array are: 1028 AlgorithmID: This field indicates the algorithm for which the key 1029 material will be used. This normally is either a key wrap 1030 algorithm identifier or a content encryption algorithm identifier. 1031 The values are from the "COSE Algorithms" registry. This field is 1032 required to be present. The field exists in the context 1033 information so that a different key is generated for each 1034 algorithm even of all of the other context information is the 1035 same. In practice, this means if algorithm A is broken and thus 1036 finding the key is relatively easy, the key derived for algorithm 1037 B will not be the same as the key derived for algorithm A. 1039 PartyUInfo: This field holds information about party U. The 1040 PartyUInfo is encoded as a CBOR array. The elements of PartyUInfo 1041 are encoded in the order presented below. The elements of the 1042 PartyUInfo array are: 1044 identity: This contains the identity information for party U. 1045 The identities can be assigned in one of two manners. First, a 1046 protocol can assign identities based on roles. For example, 1047 the roles of "client" and "server" may be assigned to different 1048 entities in the protocol. Each entity would then use the 1049 correct label for the data they send or receive. The second 1050 way for a protocol to assign identities is to use a name based 1051 on a naming system (i.e., DNS, X.509 names). 1053 We define an algorithm parameter 'PartyU identity' that can be 1054 used to carry identity information in the message. However, 1055 identity information is often known as part of the protocol and 1056 can thus be inferred rather than made explicit. If identity 1057 information is carried in the message, applications SHOULD have 1058 a way of validating the supplied identity information. The 1059 identity information does not need to be specified and is set 1060 to nil in that case. 1062 nonce: This contains a nonce value. The nonce can either be 1063 implicit from the protocol or be carried as a value in the 1064 unprotected header bucket. 1066 We define an algorithm parameter 'PartyU nonce' that can be 1067 used to carry this value in the message; however, the nonce 1068 value could be determined by the application and the value 1069 determined from elsewhere. 1071 This option does not need to be specified and is set to nil in 1072 that case. 1074 other: This contains other information that is defined by the 1075 protocol. This option does not need to be specified and is set 1076 to nil in that case. 1078 PartyVInfo: This field holds information about party V. The content 1079 of the structure is the same as for the PartyUInfo but for party 1080 V. 1082 SuppPubInfo: This field contains public information that is mutually 1083 known to both parties. 1085 keyDataLength: This is set to the number of bits of the desired 1086 output value. This practice means if algorithm A can use two 1087 different key lengths, the key derived for longer key size will 1088 not contain the key for shorter key size as a prefix. 1090 protected: This field contains the protected parameter field. If 1091 there are no elements in the protected field, then use a zero- 1092 length bstr. 1094 other: This field is for free form data defined by the 1095 application. An example is that an application could define 1096 two different byte strings to be placed here to generate 1097 different keys for a data stream versus a control stream. This 1098 field is optional and will only be present if the application 1099 defines a structure for this information. Applications that 1100 define this SHOULD use CBOR to encode the data so that types 1101 and lengths are correctly included. 1103 SuppPrivInfo: This field contains private information that is 1104 mutually known private information. An example of this 1105 information would be a preexisting shared secret. (This could, 1106 for example, be used in combination with an ECDH key agreement to 1107 provide a secondary proof of identity.) The field is optional and 1108 will only be present if the application defines a structure for 1109 this information. Applications that define this SHOULD use CBOR 1110 to encode the data so that types and lengths are correctly 1111 included. 1113 The following CDDL fragment corresponds to the text above. 1115 PartyInfo = ( 1116 identity : bstr / nil, 1117 nonce : bstr / int / nil, 1118 other : bstr / nil 1119 ) 1121 COSE_KDF_Context = [ 1122 AlgorithmID : int / tstr, 1123 PartyUInfo : [ PartyInfo ], 1124 PartyVInfo : [ PartyInfo ], 1125 SuppPubInfo : [ 1126 keyDataLength : uint, 1127 protected : empty_or_serialized_map, 1128 ? other : bstr 1129 ], 1130 ? SuppPrivInfo : bstr 1131 ] 1133 6. Content Key Distribution Methods 1135 Part Section 9.5 of [I-D.ietf-cose-rfc8152bis-struct] contains a 1136 generic description of content key distribution methods. This 1137 document defines the identifiers and usage for a number of content 1138 key distribution methods. 1140 6.1. Direct Encryption 1142 Direct encryption algorithm is defined in Part Section 9.5.1 of 1143 [I-D.ietf-cose-rfc8152bis-struct]. Information about how to fill in 1144 the COSE_Recipient structure are detailed there. 1146 6.1.1. Direct Key 1148 This recipient algorithm is the simplest; the identified key is 1149 directly used as the key for the next layer down in the message. 1150 There are no algorithm parameters defined for this algorithm. The 1151 algorithm identifier value is assigned in Table 11. 1153 When this algorithm is used, the protected field MUST be zero length. 1154 The key type MUST be 'Symmetric'. 1156 +--------+-------+-------------------+ 1157 | Name | Value | Description | 1158 +========+=======+===================+ 1159 | direct | -6 | Direct use of CEK | 1160 +--------+-------+-------------------+ 1162 Table 11: Direct Key 1164 6.1.1.1. Security Considerations 1166 This recipient algorithm has several potential problems that need to 1167 be considered: 1169 * These keys need to have some method to be regularly updated over 1170 time. All of the content encryption algorithms specified in this 1171 document have limits on how many times a key can be used without 1172 significant loss of security. 1174 * These keys need to be dedicated to a single algorithm. There have 1175 been a number of attacks developed over time when a single key is 1176 used for multiple different algorithms. One example of this is 1177 the use of a single key for both the CBC encryption mode and the 1178 CBC-MAC authentication mode. 1180 * Breaking one message means all messages are broken. If an 1181 adversary succeeds in determining the key for a single message, 1182 then the key for all messages is also determined. 1184 6.1.2. Direct Key with KDF 1186 These recipient algorithms take a common shared secret between the 1187 two parties and applies the HKDF function (Section 5.1), using the 1188 context structure defined in Section 5.2 to transform the shared 1189 secret into the CEK. The 'protected' field can be of non-zero 1190 length. Either the 'salt' parameter of HKDF or the 'PartyU nonce' 1191 parameter of the context structure MUST be present. The salt/nonce 1192 parameter can be generated either randomly or deterministically. The 1193 requirement is that it be a unique value for the shared secret in 1194 question. 1196 If the salt/nonce value is generated randomly, then it is suggested 1197 that the length of the random value be the same length as the hash 1198 function underlying HKDF. While there is no way to guarantee that it 1199 will be unique, there is a high probability that it will be unique. 1200 If the salt/nonce value is generated deterministically, it can be 1201 guaranteed to be unique, and thus there is no length requirement. 1203 A new IV must be used for each message if the same key is used. The 1204 IV can be modified in a predictable manner, a random manner, or an 1205 unpredictable manner (i.e., encrypting a counter). 1207 The IV used for a key can also be generated from the same HKDF 1208 functionality as the key is generated. If HKDF is used for 1209 generating the IV, the algorithm identifier is set to "IV- 1210 GENERATION". 1212 When these algorithms are used, the key type MUST be 'symmetric'. 1214 The set of algorithms defined in this document can be found in 1215 Table 12. 1217 +---------------------+-------+--------------+---------------------+ 1218 | Name | Value | KDF | Description | 1219 +=====================+=======+==============+=====================+ 1220 | direct+HKDF-SHA-256 | -10 | HKDF SHA-256 | Shared secret w/ | 1221 | | | | HKDF and SHA-256 | 1222 +---------------------+-------+--------------+---------------------+ 1223 | direct+HKDF-SHA-512 | -11 | HKDF SHA-512 | Shared secret w/ | 1224 | | | | HKDF and SHA-512 | 1225 +---------------------+-------+--------------+---------------------+ 1226 | direct+HKDF-AES-128 | -12 | HKDF AES- | Shared secret w/ | 1227 | | | MAC-128 | AES-MAC 128-bit key | 1228 +---------------------+-------+--------------+---------------------+ 1229 | direct+HKDF-AES-256 | -13 | HKDF AES- | Shared secret w/ | 1230 | | | MAC-256 | AES-MAC 256-bit key | 1231 +---------------------+-------+--------------+---------------------+ 1233 Table 12: Direct Key with KDF 1235 When using a COSE key for this algorithm, the following checks are 1236 made: 1238 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 1240 * If the 'alg' field is present, it MUST match the algorithm being 1241 used. 1243 * If the 'key_ops' field is present, it MUST include 'deriveKey' or 1244 'deriveBits'. 1246 6.1.2.1. Security Considerations 1248 The shared secret needs to have some method to be regularly updated 1249 over time. The shared secret forms the basis of trust. Although not 1250 used directly, it should still be subject to scheduled rotation. 1252 While these methods do not provide for perfect forward secrecy, as 1253 the same shared secret is used for all of the keys generated, if the 1254 key for any single message is discovered, only the message (or series 1255 of messages) using that derived key are compromised. A new key 1256 derivation step will generate a new key that requires the same amount 1257 of work to get the key. 1259 6.2. AES Key Wrap 1261 The AES Key Wrap algorithm is defined in [RFC3394]. This algorithm 1262 uses an AES key to wrap a value that is a multiple of 64 bits. As 1263 such, it can be used to wrap a key for any of the content encryption 1264 algorithms defined in this document. The algorithm requires a single 1265 fixed parameter, the initial value. This is fixed to the value 1266 specified in Section 2.2.3.1 of [RFC3394]. There are no public key 1267 parameters that vary on a per-invocation basis. The protected header 1268 bucket MUST be empty. 1270 Keys may be obtained either from a key structure or from a recipient 1271 structure. Implementations encrypting and decrypting MUST validate 1272 that the key type, key length, and algorithm are correct and 1273 appropriate for the entities involved. 1275 When using a COSE key for this algorithm, the following checks are 1276 made: 1278 * The 'kty' field MUST be present, and it MUST be 'Symmetric'. 1280 * If the 'alg' field is present, it MUST match the AES Key Wrap 1281 algorithm being used. 1283 * If the 'key_ops' field is present, it MUST include 'encrypt' or 1284 'wrap key' when encrypting. 1286 * If the 'key_ops' field is present, it MUST include 'decrypt' or 1287 'unwrap key' when decrypting. 1289 +--------+-------+----------+-----------------------------+ 1290 | Name | Value | Key Size | Description | 1291 +========+=======+==========+=============================+ 1292 | A128KW | -3 | 128 | AES Key Wrap w/ 128-bit key | 1293 +--------+-------+----------+-----------------------------+ 1294 | A192KW | -4 | 192 | AES Key Wrap w/ 192-bit key | 1295 +--------+-------+----------+-----------------------------+ 1296 | A256KW | -5 | 256 | AES Key Wrap w/ 256-bit key | 1297 +--------+-------+----------+-----------------------------+ 1299 Table 13: AES Key Wrap Algorithm Values 1301 6.2.1. Security Considerations for AES-KW 1303 The shared secret needs to have some method to be regularly updated 1304 over time. The shared secret is the basis of trust. 1306 6.3. Direct ECDH 1308 The mathematics for ECDH can be found in [RFC6090]. In this 1309 document, the algorithm is extended to be used with the two curves 1310 defined in [RFC7748]. 1312 ECDH is parameterized by the following: 1314 * Curve Type/Curve: The curve selected controls not only the size of 1315 the shared secret, but the mathematics for computing the shared 1316 secret. The curve selected also controls how a point in the curve 1317 is represented and what happens for the identity points on the 1318 curve. In this specification, we allow for a number of different 1319 curves to be used. A set of curves are defined in Table 18. 1321 The math used to obtain the computed secret is based on the curve 1322 selected and not on the ECDH algorithm. For this reason, a new 1323 algorithm does not need to be defined for each of the curves. 1325 * Computed Secret to Shared Secret: Once the computed secret is 1326 known, the resulting value needs to be converted to a byte string 1327 to run the KDF. The x-coordinate is used for all of the curves 1328 defined in this document. For curves X25519 and X448, the 1329 resulting value is used directly as it is a byte string of a known 1330 length. For the P-256, P-384, and P-521 curves, the x-coordinate 1331 is run through the I2OSP function defined in [RFC8017], using the 1332 same computation for n as is defined in Section 2.1. 1334 * Ephemeral-Static or Static-Static: The key agreement process may 1335 be done using either a static or an ephemeral key for the sender's 1336 side. When using ephemeral keys, the sender MUST generate a new 1337 ephemeral key for every key agreement operation. The ephemeral 1338 key is placed in the 'ephemeral key' parameter and MUST be present 1339 for all algorithm identifiers that use ephemeral keys. When using 1340 static keys, the sender MUST either generate a new random value or 1341 create a unique value. For the KDFs used, this means either the 1342 'salt' parameter for HKDF (Table 9) or the 'PartyU nonce' 1343 parameter for the context structure (Table 10) MUST be present 1344 (both can be present if desired). The value in the parameter MUST 1345 be unique for the pair of keys being used. It is acceptable to 1346 use a global counter that is incremented for every static-static 1347 operation and use the resulting value. When using static keys, 1348 the static key should be identified to the recipient. The static 1349 key can be identified either by providing the key ('static key') 1350 or by providing a key identifier for the static key ('static key 1351 id'). Both of these header parameters are defined in Table 15. 1353 * Key Derivation Algorithm: The result of an ECDH key agreement 1354 process does not provide a uniformly random secret. As such, it 1355 needs to be run through a KDF in order to produce a usable key. 1356 Processing the secret through a KDF also allows for the 1357 introduction of context material: how the key is going to be used 1358 and one-time material for static-static key agreement. All of the 1359 algorithms defined in this document use one of the HKDF algorithms 1360 defined in Section 5.1 with the context structure defined in 1361 Section 5.2. 1363 * Key Wrap Algorithm: No key wrap algorithm is used. This is 1364 represented in Table 14 as 'none'. The key size for the context 1365 structure is the content layer encryption algorithm size. 1367 COSE does not have an Ephemeral-Ephemeral version defined. The 1368 reason for this is that COSE is not an online protocol by itself and 1369 thus does not have a method to establish ephemeral secrets on both 1370 sides. The expectation is that a protocol would establish the 1371 secrets for both sides, and then they would be used as static-static 1372 for the purposes of COSE, or that the protocol would generate a 1373 shared secret and a direct encryption would be used. 1375 The set of direct ECDH algorithms defined in this document are found 1376 in Table 14. 1378 +-----------+-------+---------+------------+------+-----------------+ 1379 | Name | Value | KDF | Ephemeral- | Key | Description | 1380 | | | | Static | Wrap | | 1381 +===========+=======+=========+============+======+=================+ 1382 | ECDH-ES | -25 | HKDF - | yes | none | ECDH ES w/ HKDF | 1383 | + | | SHA-256 | | | - generate key | 1384 | HKDF-256 | | | | | directly | 1385 +-----------+-------+---------+------------+------+-----------------+ 1386 | ECDH-ES | -26 | HKDF - | yes | none | ECDH ES w/ HKDF | 1387 | + | | SHA-512 | | | - generate key | 1388 | HKDF-512 | | | | | directly | 1389 +-----------+-------+---------+------------+------+-----------------+ 1390 | ECDH-SS | -27 | HKDF - | no | none | ECDH SS w/ HKDF | 1391 | + | | SHA-256 | | | - generate key | 1392 | HKDF-256 | | | | | directly | 1393 +-----------+-------+---------+------------+------+-----------------+ 1394 | ECDH-SS | -28 | HKDF - | no | none | ECDH SS w/ HKDF | 1395 | + | | SHA-512 | | | - generate key | 1396 | HKDF-512 | | | | | directly | 1397 +-----------+-------+---------+------------+------+-----------------+ 1399 Table 14: ECDH Algorithm Values 1401 +-----------+-------+----------+-------------------+-------------+ 1402 | Name | Label | Type | Algorithm | Description | 1403 +===========+=======+==========+===================+=============+ 1404 | ephemeral | -1 | COSE_Key | ECDH-ES+HKDF-256, | Ephemeral | 1405 | key | | | ECDH-ES+HKDF-512, | public key | 1406 | | | | ECDH-ES+A128KW, | for the | 1407 | | | | ECDH-ES+A192KW, | sender | 1408 | | | | ECDH-ES+A256KW | | 1409 +-----------+-------+----------+-------------------+-------------+ 1410 | static | -2 | COSE_Key | ECDH-SS+HKDF-256, | Static | 1411 | key | | | ECDH-SS+HKDF-512, | public key | 1412 | | | | ECDH-SS+A128KW, | for the | 1413 | | | | ECDH-SS+A192KW, | sender | 1414 | | | | ECDH-SS+A256KW | | 1415 +-----------+-------+----------+-------------------+-------------+ 1416 | static | -3 | bstr | ECDH-SS+HKDF-256, | Static | 1417 | key id | | | ECDH-SS+HKDF-512, | public key | 1418 | | | | ECDH-SS+A128KW, | identifier | 1419 | | | | ECDH-SS+A192KW, | for the | 1420 | | | | ECDH-SS+A256KW | sender | 1421 +-----------+-------+----------+-------------------+-------------+ 1423 Table 15: ECDH Algorithm Parameters 1425 This document defines these algorithms to be used with the curves 1426 P-256, P-384, P-521, X25519, and X448. Implementations MUST verify 1427 that the key type and curve are correct. Different curves are 1428 restricted to different key types. Implementations MUST verify that 1429 the curve and algorithm are appropriate for the entities involved. 1431 When using a COSE key for this algorithm, the following checks are 1432 made: 1434 * The 'kty' field MUST be present, and it MUST be 'EC2' or 'OKP'. 1436 * If the 'alg' field is present, it MUST match the key agreement 1437 algorithm being used. 1439 * If the 'key_ops' field is present, it MUST include 'derive key' or 1440 'derive bits' for the private key. 1442 * If the 'key_ops' field is present, it MUST be empty for the public 1443 key. 1445 6.3.1. Security Considerations 1447 There is a method of checking that points provided from external 1448 entities are valid. For the 'EC2' key format, this can be done by 1449 checking that the x and y values form a point on the curve. For the 1450 'OKP' format, there is no simple way to do point validation. 1452 Consideration was given to requiring that the public keys of both 1453 entities be provided as part of the key derivation process (as 1454 recommended in Section 6.1 of [RFC7748]). This was not done as COSE 1455 is used in a store and forward format rather than in online key 1456 exchange. In order for this to be a problem, either the receiver 1457 public key has to be chosen maliciously or the sender has to be 1458 malicious. In either case, all security evaporates anyway. 1460 A proof of possession of the private key associated with the public 1461 key is recommended when a key is moved from untrusted to trusted 1462 (either by the end user or by the entity that is responsible for 1463 making trust statements on keys). 1465 6.4. ECDH with Key Wrap 1467 These algorithms are defined in Table 16. 1469 ECDH with Key Agreement is parameterized by the same header 1470 parameters as for ECDH; see Section 6.3, with the following 1471 modifications: 1473 * Key Wrap Algorithm: Any of the key wrap algorithms defined in 1474 Section 6.2 are supported. The size of the key used for the key 1475 wrap algorithm is fed into the KDF. The set of identifiers are 1476 found in Table 16. 1478 +---------+-------+---------+------------+--------+----------------+ 1479 | Name | Value | KDF | Ephemeral- | Key | Description | 1480 | | | | Static | Wrap | | 1481 +=========+=======+=========+============+========+================+ 1482 | ECDH-ES | -29 | HKDF - | yes | A128KW | ECDH ES w/ | 1483 | + | | SHA-256 | | | Concat KDF and | 1484 | A128KW | | | | | AES Key Wrap | 1485 | | | | | | w/ 128-bit key | 1486 +---------+-------+---------+------------+--------+----------------+ 1487 | ECDH-ES | -30 | HKDF - | yes | A192KW | ECDH ES w/ | 1488 | + | | SHA-256 | | | Concat KDF and | 1489 | A192KW | | | | | AES Key Wrap | 1490 | | | | | | w/ 192-bit key | 1491 +---------+-------+---------+------------+--------+----------------+ 1492 | ECDH-ES | -31 | HKDF - | yes | A256KW | ECDH ES w/ | 1493 | + | | SHA-256 | | | Concat KDF and | 1494 | A256KW | | | | | AES Key Wrap | 1495 | | | | | | w/ 256-bit key | 1496 +---------+-------+---------+------------+--------+----------------+ 1497 | ECDH-SS | -32 | HKDF - | no | A128KW | ECDH SS w/ | 1498 | + | | SHA-256 | | | Concat KDF and | 1499 | A128KW | | | | | AES Key Wrap | 1500 | | | | | | w/ 128-bit key | 1501 +---------+-------+---------+------------+--------+----------------+ 1502 | ECDH-SS | -33 | HKDF - | no | A192KW | ECDH SS w/ | 1503 | + | | SHA-256 | | | Concat KDF and | 1504 | A192KW | | | | | AES Key Wrap | 1505 | | | | | | w/ 192-bit key | 1506 +---------+-------+---------+------------+--------+----------------+ 1507 | ECDH-SS | -34 | HKDF - | no | A256KW | ECDH SS w/ | 1508 | + | | SHA-256 | | | Concat KDF and | 1509 | A256KW | | | | | AES Key Wrap | 1510 | | | | | | w/ 256-bit key | 1511 +---------+-------+---------+------------+--------+----------------+ 1513 Table 16: ECDH Algorithm Values with Key Wrap 1515 When using a COSE key for this algorithm, the following checks are 1516 made: 1518 * The 'kty' field MUST be present, and it MUST be 'EC2' or 'OKP'. 1520 * If the 'alg' field is present, it MUST match the key agreement 1521 algorithm being used. 1523 * If the 'key_ops' field is present, it MUST include 'derive key' or 1524 'derive bits' for the private key. 1526 * If the 'key_ops' field is present, it MUST be empty for the public 1527 key. 1529 7. Key Object Parameters 1531 The COSE_Key object defines a way to hold a single key object. It is 1532 still required that the members of individual key types be defined. 1533 This section of the document is where we define an initial set of 1534 members for specific key types. 1536 For each of the key types, we define both public and private members. 1537 The public members are what is transmitted to others for their usage. 1538 Private members allow for the archival of keys by individuals. 1539 However, there are some circumstances in which private keys may be 1540 distributed to entities in a protocol. Examples include: entities 1541 that have poor random number generation, centralized key creation for 1542 multi-cast type operations, and protocols in which a shared secret is 1543 used as a bearer token for authorization purposes. 1545 Key types are identified by the 'kty' member of the COSE_Key object. 1546 In this document, we define four values for the member: 1548 +-----------+-------+--------------------------+ 1549 | Name | Value | Description | 1550 +===========+=======+==========================+ 1551 | OKP | 1 | Octet Key Pair | 1552 +-----------+-------+--------------------------+ 1553 | EC2 | 2 | Elliptic Curve Keys w/ | 1554 | | | x- and y-coordinate pair | 1555 +-----------+-------+--------------------------+ 1556 | Symmetric | 4 | Symmetric Keys | 1557 +-----------+-------+--------------------------+ 1558 | Reserved | 0 | This value is reserved | 1559 +-----------+-------+--------------------------+ 1561 Table 17: Key Type Values 1563 7.1. Elliptic Curve Keys 1565 Two different key structures are defined for elliptic curve keys. 1566 One version uses both an x-coordinate and a y-coordinate, potentially 1567 with point compression ('EC2'). This is the traditional EC point 1568 representation that is used in [RFC5480]. The other version uses 1569 only the x-coordinate as the y-coordinate is either to be recomputed 1570 or not needed for the key agreement operation ('OKP'). 1572 Applications MUST check that the curve and the key type are 1573 consistent and reject a key if they are not. 1575 +---------+-------+----------+------------------------------------+ 1576 | Name | Value | Key Type | Description | 1577 +=========+=======+==========+====================================+ 1578 | P-256 | 1 | EC2 | NIST P-256 also known as secp256r1 | 1579 +---------+-------+----------+------------------------------------+ 1580 | P-384 | 2 | EC2 | NIST P-384 also known as secp384r1 | 1581 +---------+-------+----------+------------------------------------+ 1582 | P-521 | 3 | EC2 | NIST P-521 also known as secp521r1 | 1583 +---------+-------+----------+------------------------------------+ 1584 | X25519 | 4 | OKP | X25519 for use w/ ECDH only | 1585 +---------+-------+----------+------------------------------------+ 1586 | X448 | 5 | OKP | X448 for use w/ ECDH only | 1587 +---------+-------+----------+------------------------------------+ 1588 | Ed25519 | 6 | OKP | Ed25519 for use w/ EdDSA only | 1589 +---------+-------+----------+------------------------------------+ 1590 | Ed448 | 7 | OKP | Ed448 for use w/ EdDSA only | 1591 +---------+-------+----------+------------------------------------+ 1593 Table 18: Elliptic Curves 1595 7.1.1. Double Coordinate Curves 1597 The traditional way of sending ECs has been to send either both the 1598 x-coordinate and y-coordinate or the x-coordinate and a sign bit for 1599 the y-coordinate. The latter encoding has not been recommended in 1600 the IETF due to potential IPR issues. However, for operations in 1601 constrained environments, the ability to shrink a message by not 1602 sending the y-coordinate is potentially useful. 1604 For EC keys with both coordinates, the 'kty' member is set to 2 1605 (EC2). The key parameters defined in this section are summarized in 1606 Table 19. The members that are defined for this key type are: 1608 crv: This contains an identifier of the curve to be used with the 1609 key. The curves defined in this document for this key type can 1610 be found in Table 18. Other curves may be registered in the 1611 future, and private curves can be used as well. 1613 x: This contains the x-coordinate for the EC point. The integer is 1614 converted to a byte string as defined in [SEC1]. Leading zero 1615 octets MUST be preserved. 1617 y: This contains either the sign bit or the value of the 1618 y-coordinate for the EC point. When encoding the value y, the 1619 integer is converted to an byte string (as defined in [SEC1]) 1620 and encoded as a CBOR bstr. Leading zero octets MUST be 1621 preserved. The compressed point encoding is also supported. 1622 Compute the sign bit as laid out in the Elliptic-Curve-Point-to- 1623 Octet-String Conversion function of [SEC1]. If the sign bit is 1624 zero, then encode y as a CBOR false value; otherwise, encode y 1625 as a CBOR true value. The encoding of the infinity point is not 1626 supported. 1628 d: This contains the private key. 1630 For public keys, it is REQUIRED that 'crv', 'x', and 'y' be present 1631 in the structure. For private keys, it is REQUIRED that 'crv' and 1632 'd' be present in the structure. For private keys, it is RECOMMENDED 1633 that 'x' and 'y' also be present, but they can be recomputed from the 1634 required elements and omitting them saves on space. 1636 +------+------+-------+--------+---------------------------------+ 1637 | Key | Name | Label | CBOR | Description | 1638 | Type | | | Type | | 1639 +======+======+=======+========+=================================+ 1640 | 2 | crv | -1 | int / | EC identifier - Taken from the | 1641 | | | | tstr | "COSE Elliptic Curves" registry | 1642 +------+------+-------+--------+---------------------------------+ 1643 | 2 | x | -2 | bstr | x-coordinate | 1644 +------+------+-------+--------+---------------------------------+ 1645 | 2 | y | -3 | bstr / | y-coordinate | 1646 | | | | bool | | 1647 +------+------+-------+--------+---------------------------------+ 1648 | 2 | d | -4 | bstr | Private key | 1649 +------+------+-------+--------+---------------------------------+ 1651 Table 19: EC Key Parameters 1653 7.2. Octet Key Pair 1655 A new key type is defined for Octet Key Pairs (OKP). Do not assume 1656 that keys using this type are elliptic curves. This key type could 1657 be used for other curve types (for example, mathematics based on 1658 hyper-elliptic surfaces). 1660 The key parameters defined in this section are summarized in 1661 Table 20. The members that are defined for this key type are: 1663 crv: This contains an identifier of the curve to be used with the 1664 key. The curves defined in this document for this key type can 1665 be found in Table 18. Other curves may be registered in the 1666 future and private curves can be used as well. 1668 x: This contains the public key. The byte string contains the 1669 public key as defined by the algorithm. (For X25591, internally 1670 it is a little-endian integer.) 1672 d: This contains the private key. 1674 For public keys, it is REQUIRED that 'crv' and 'x' be present in the 1675 structure. For private keys, it is REQUIRED that 'crv' and 'd' be 1676 present in the structure. For private keys, it is RECOMMENDED that 1677 'x' also be present, but it can be recomputed from the required 1678 elements and omitting it saves on space. 1680 +------+----------+-------+-------+---------------------------------+ 1681 | Name | Key | Label | Type | Description | 1682 | | Type | | | | 1683 +======+==========+=======+=======+=================================+ 1684 | crv | 1 | -1 | int / | EC identifier - Taken from the | 1685 | | | | tstr | "COSE Elliptic Curves" registry | 1686 +------+----------+-------+-------+---------------------------------+ 1687 | x | 1 | -2 | bstr | Public Key | 1688 +------+----------+-------+-------+---------------------------------+ 1689 | d | 1 | -4 | bstr | Private key | 1690 +------+----------+-------+-------+---------------------------------+ 1692 Table 20: Octet Key Pair Parameters 1694 7.3. Symmetric Keys 1696 Occasionally it is required that a symmetric key be transported 1697 between entities. This key structure allows for that to happen. 1699 For symmetric keys, the 'kty' member is set to 4 ('Symmetric'). The 1700 member that is defined for this key type is: 1702 k: This contains the value of the key. 1704 This key structure does not have a form that contains only public 1705 members. As it is expected that this key structure is going to be 1706 transmitted, care must be taken that it is never transmitted 1707 accidentally or insecurely. For symmetric keys, it is REQUIRED that 1708 'k' be present in the structure. 1710 +------+----------+-------+------+-------------+ 1711 | Name | Key Type | Label | Type | Description | 1712 +======+==========+=======+======+=============+ 1713 | k | 4 | -1 | bstr | Key Value | 1714 +------+----------+-------+------+-------------+ 1716 Table 21: Symmetric Key Parameters 1718 8. COSE Capabilities 1720 There are some situations that have been identified where 1721 identification of capabilities of an algorithm need to be specified. 1722 One example of this is in [I-D.ietf-core-oscore-groupcomm] where the 1723 capabilities of the counter signature algorithm are mixed into the 1724 traffic key derivation process. This has a counterpart in the S/MIME 1725 specifications where SMIMECapabilities is defined in Section 2.5.2 of 1726 [RFC8551]. The concept is being pulled forward and defined now for 1727 COSE. 1729 There is a presumption in the way that this is laid out is that the 1730 algorithm identifier itself is not needed to be a part of this as it 1731 is specified in a different location. 1733 Two different types of capabilities are defined: Capabilities for 1734 algorithms and capabilities for key structures. Once defined by 1735 registration with IANA, the list capabilities is immutable. If it is 1736 later found that a new capability is needed for a key type or an 1737 algorithm, it will require that a new code point be assigned to deal 1738 with that. As a general rule, the capabilities are going to map to 1739 algorithm specific header parameters or key parameters, but they do 1740 not need to do so. An example of this is the HSS-LMS key 1741 capabilities defined below where the hash algorithm used is included. 1743 The capability structure is an array of values, the order being 1744 dependent on the specific algorithm or key. For an algorithm, the 1745 first element should always be a key type value, but the items that 1746 are specific to a key should not be included in the algorithm 1747 capabilities. This means that if one wishes to enumerate all of the 1748 capabilities for a device which implements ECDH, it requires multiple 1749 pairs of capability structures (algorithm, key) to deal with the 1750 different key types and curves that are supported. For a key, the 1751 first element should also be a key type value, while this means that 1752 this value will be duplicated if both an algorithm and key capability 1753 are used, the key type is needed in order to understand the rest of 1754 the values. 1756 8.1. Assignments for Existing Key Types 1758 There are a number of pre-existing key types, the following deals 1759 with creating the capability definition for those structures: 1761 * OKP, EC2: The list of capabilities is: 1763 - The key type value. (1 for OKP or 2 for EC2.) 1764 - One curve for that key type from the "COSE Elliptic Curve" 1765 registry. 1767 * RSA: The list of capabilities is: 1769 - The key type value (3). 1771 * Symmetric: The list of capabilities is: 1773 - The key type value (4). 1775 * HSS-LMS: The list of capabilities is: 1777 - The key type value (5), 1779 - Algorithm identifier for the underlying hash function from the 1780 "COSE Algorithms" registry. 1782 8.2. Assignments for Existing Algorithms 1784 For the current set of algorithms in the registry, those in this 1785 document as well as those in [RFC8230] and [I-D.ietf-cose-hash-sig], 1786 the capabilities is set to the single entry of the key type (from the 1787 "COSE Key Types" Registry) that will be accepted. It is expected 1788 future registered algorithms could have zero, one, multiple items. 1790 8.3. Examples 1792 In this section a trio of examples are provided. In all three cases 1793 the pair of capabilities is always provided as the algorithm and then 1794 the key capabilities. For simplicity's sake, a CBOR sequence 1795 [I-D.ietf-cbor-sequence] is used for the two arrays. 1797 ECDSA with SHA-512 and a P-256 curve: 1799 0x8102820201 / [2],[2, 1] / 1801 ECDH-ES + A256KW with a P-256 curve: 1803 0x8102820201 / [2],[2, 1] / 1805 ECDH-ES + A256KW with an X25519 curve: 1807 0x8101820104 / [1],[1, 4] / 1809 9. CBOR Encoding Restrictions 1811 There has been an attempt to limit the number of places where the 1812 document needs to impose restrictions on how the CBOR Encoder needs 1813 to work. We have managed to narrow it down to the following 1814 restrictions: 1816 * The restriction applies to the encoding of the COSE_KDF_Context. 1818 * Encoding MUST be done using definite lengths and the length of the 1819 MUST be the minimum possible length. This means that the integer 1820 1 is encoded as "0x01" and not "0x1801". 1822 * Applications MUST NOT generate messages with the same label used 1823 twice as a key in a single map. Applications MUST NOT parse and 1824 process messages with the same label used twice as a key in a 1825 single map. Applications can enforce the parse and process 1826 requirement by using parsers that will fail the parse step or by 1827 using parsers that will pass all keys to the application, and the 1828 application can perform the check for duplicate keys. 1830 10. IANA Considerations 1832 10.1. Changes to "COSE Key Types" registry. 1834 IANA is requested to create a new column in the "COSE Key Types" 1835 registry. The new column is to be labeled "Capabilities". The new 1836 column is to be populated according the entries in Table 22. 1838 +-------+-----------+--------------------------+ 1839 | Value | Name | Capabilities | 1840 +=======+===========+==========================+ 1841 | 1 | OKP | [kty(1), crv] | 1842 +-------+-----------+--------------------------+ 1843 | 2 | EC2 | [kty(2), crv] | 1844 +-------+-----------+--------------------------+ 1845 | 3 | RSA | [kty(3)] | 1846 +-------+-----------+--------------------------+ 1847 | 4 | Symmetric | [kty(4)] | 1848 +-------+-----------+--------------------------+ 1849 | 5 | HSS-LMS | [kty(5), hash algorithm] | 1850 +-------+-----------+--------------------------+ 1852 Table 22: Key Type Capabilities 1854 10.2. Changes to "COSE Algorithms" registry 1856 IANA is requested to create a new column in the "COSE Algorithms" 1857 registry. The new column is to be labeled "Capabilities". The new 1858 column is populated with "[kty]" for all current, non-provisional, 1859 registrations. It is expected that the documents which define those 1860 algorithms will be expanded to include this registration, if this is 1861 not done then the DE should be consulted final registration for this 1862 document is done. 1864 IANA is requested to update the reference column in the "COSE 1865 Algorithms" registry to include [[This Document]] as a reference for 1866 all rows where it is not already present. Note to IANA: There is an 1867 action in [I-D.ietf-cose-rfc8152bis-struct] which also modifies data 1868 in the reference column. That action should be applied first. 1870 10.3. Changes to the "COSE Key Type Parameters" registry 1872 IANA is required to modify the description to "Public Key" for the 1873 line with "Key Type" of 2 and the "Name" of "x". See Table 20 which 1874 has been modified with this change. 1876 11. Security Considerations 1878 There are a number of security considerations that need to be taken 1879 into account by implementers of this specification. The security 1880 considerations that are specific to an individual algorithm are 1881 placed next to the description of the algorithm. While some 1882 considerations have been highlighted here, additional considerations 1883 may be found in the documents listed in the references. 1885 Implementations need to protect the private key material for any 1886 individuals. There are some cases in this document that need to be 1887 highlighted on this issue. 1889 * Using the same key for two different algorithms can leak 1890 information about the key. It is therefore recommended that keys 1891 be restricted to a single algorithm. 1893 * Use of 'direct' as a recipient algorithm combined with a second 1894 recipient algorithm exposes the direct key to the second 1895 recipient. 1897 * Several of the algorithms in this document have limits on the 1898 number of times that a key can be used without leaking information 1899 about the key. 1901 The use of ECDH and direct plus KDF (with no key wrap) will not 1902 directly lead to the private key being leaked; the one way function 1903 of the KDF will prevent that. There is, however, a different issue 1904 that needs to be addressed. Having two recipients requires that the 1905 CEK be shared between two recipients. The second recipient therefore 1906 has a CEK that was derived from material that can be used for the 1907 weak proof of origin. The second recipient could create a message 1908 using the same CEK and send it to the first recipient; the first 1909 recipient would, for either static-static ECDH or direct plus KDF, 1910 make an assumption that the CEK could be used for proof of origin 1911 even though it is from the wrong entity. If the key wrap step is 1912 added, then no proof of origin is implied and this is not an issue. 1914 Although it has been mentioned before, the use of a single key for 1915 multiple algorithms has been demonstrated in some cases to leak 1916 information about a key, provide the opportunity for attackers to 1917 forge integrity tags, or gain information about encrypted content. 1918 Binding a key to a single algorithm prevents these problems. Key 1919 creators and key consumers are strongly encouraged not only to create 1920 new keys for each different algorithm, but to include that selection 1921 of algorithm in any distribution of key material and strictly enforce 1922 the matching of algorithms in the key structure to algorithms in the 1923 message structure. In addition to checking that algorithms are 1924 correct, the key form needs to be checked as well. Do not use an 1925 'EC2' key where an 'OKP' key is expected. 1927 Before using a key for transmission, or before acting on information 1928 received, a trust decision on a key needs to be made. Is the data or 1929 action something that the entity associated with the key has a right 1930 to see or a right to request? A number of factors are associated 1931 with this trust decision. Some of the ones that are highlighted here 1932 are: 1934 * What are the permissions associated with the key owner? 1936 * Is the cryptographic algorithm acceptable in the current context? 1938 * Have the restrictions associated with the key, such as algorithm 1939 or freshness, been checked and are they correct? 1941 * Is the request something that is reasonable, given the current 1942 state of the application? 1944 * Have any security considerations that are part of the message been 1945 enforced (as specified by the application or 'crit' parameter)? 1947 There are a large number of algorithms presented in this document 1948 that use nonce values. For all of the nonces defined in this 1949 document, there is some type of restriction on the nonce being a 1950 unique value either for a key or for some other conditions. In all 1951 of these cases, there is no known requirement on the nonce being both 1952 unique and unpredictable; under these circumstances, it's reasonable 1953 to use a counter for creation of the nonce. In cases where one wants 1954 the pattern of the nonce to be unpredictable as well as unique, one 1955 can use a key created for that purpose and encrypt the counter to 1956 produce the nonce value. 1958 One area that has been starting to get exposure is doing traffic 1959 analysis of encrypted messages based on the length of the message. 1960 This specification does not provide for a uniform method of providing 1961 padding as part of the message structure. An observer can 1962 distinguish between two different messages (for example, 'YES' and 1963 'NO') based on the length for all of the content encryption 1964 algorithms that are defined in this document. This means that it is 1965 up to the applications to document how content padding is to be done 1966 in order to prevent or discourage such analysis. (For example, the 1967 text strings could be defined as 'YES' and 'NO '.) 1969 12. References 1971 12.1. Normative References 1973 [I-D.ietf-cose-rfc8152bis-struct] 1974 Schaad, J., "CBOR Object Signing and Encryption (COSE): 1975 Structures and Process", Work in Progress, Internet-Draft, 1976 draft-ietf-cose-rfc8152bis-struct-07, 17 November 2019, 1977 . 1980 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 1981 Hashing for Message Authentication", RFC 2104, 1982 DOI 10.17487/RFC2104, February 1997, 1983 . 1985 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1986 Requirement Levels", BCP 14, RFC 2119, 1987 DOI 10.17487/RFC2119, March 1997, 1988 . 1990 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 1991 (AES) Key Wrap Algorithm", RFC 3394, DOI 10.17487/RFC3394, 1992 September 2002, . 1994 [RFC3610] Whiting, D., Housley, R., and N. Ferguson, "Counter with 1995 CBC-MAC (CCM)", RFC 3610, DOI 10.17487/RFC3610, September 1996 2003, . 1998 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 1999 Key Derivation Function (HKDF)", RFC 5869, 2000 DOI 10.17487/RFC5869, May 2010, 2001 . 2003 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 2004 Curve Cryptography Algorithms", RFC 6090, 2005 DOI 10.17487/RFC6090, February 2011, 2006 . 2008 [RFC6979] Pornin, T., "Deterministic Usage of the Digital Signature 2009 Algorithm (DSA) and Elliptic Curve Digital Signature 2010 Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, August 2011 2013, . 2013 [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object 2014 Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, 2015 October 2013, . 2017 [RFC8439] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 2018 Protocols", RFC 8439, DOI 10.17487/RFC8439, June 2018, 2019 . 2021 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 2022 for Security", RFC 7748, DOI 10.17487/RFC7748, January 2023 2016, . 2025 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2026 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2027 May 2017, . 2029 [AES-GCM] National Institute of Standards and Technology, 2030 "Recommendation for Block Cipher Modes of Operation: 2031 Galois/Counter Mode (GCM) and GMAC", 2032 DOI 10.6028/NIST.SP.800-38D, NIST Special 2033 Publication 800-38D, November 2007, 2034 . 2037 [DSS] National Institute of Standards and Technology, "Digital 2038 Signature Standard (DSS)", DOI 10.6028/NIST.FIPS.186-4, 2039 FIPS PUB 186-4, July 2013, 2040 . 2043 [MAC] National Institute of Standards and Technology, "Computer 2044 Data Authentication", FIPS PUB 113, May 1985, 2045 . 2048 [SEC1] Certicom Research, "SEC 1: Elliptic Curve Cryptography", 2049 May 2009, . 2051 [RFC8032] Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital 2052 Signature Algorithm (EdDSA)", RFC 8032, 2053 DOI 10.17487/RFC8032, January 2017, 2054 . 2056 12.2. Informative References 2058 [RFC8610] Birkholz, H., Vigano, C., and C. Bormann, "Concise Data 2059 Definition Language (CDDL): A Notational Convention to 2060 Express Concise Binary Object Representation (CBOR) and 2061 JSON Data Structures", RFC 8610, DOI 10.17487/RFC8610, 2062 June 2019, . 2064 [RFC4231] Nystrom, M., "Identifiers and Test Vectors for HMAC-SHA- 2065 224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512", 2066 RFC 4231, DOI 10.17487/RFC4231, December 2005, 2067 . 2069 [RFC4493] Song, JH., Poovendran, R., Lee, J., and T. Iwata, "The 2070 AES-CMAC Algorithm", RFC 4493, DOI 10.17487/RFC4493, June 2071 2006, . 2073 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 2074 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 2075 . 2077 [RFC5480] Turner, S., Brown, D., Yiu, K., Housley, R., and T. Polk, 2078 "Elliptic Curve Cryptography Subject Public Key 2079 Information", RFC 5480, DOI 10.17487/RFC5480, March 2009, 2080 . 2082 [RFC6151] Turner, S. and L. Chen, "Updated Security Considerations 2083 for the MD5 Message-Digest and the HMAC-MD5 Algorithms", 2084 RFC 6151, DOI 10.17487/RFC6151, March 2011, 2085 . 2087 [RFC8259] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data 2088 Interchange Format", STD 90, RFC 8259, 2089 DOI 10.17487/RFC8259, December 2017, 2090 . 2092 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 2093 Application Protocol (CoAP)", RFC 7252, 2094 DOI 10.17487/RFC7252, June 2014, 2095 . 2097 [RFC7518] Jones, M., "JSON Web Algorithms (JWA)", RFC 7518, 2098 DOI 10.17487/RFC7518, May 2015, 2099 . 2101 [RFC8017] Moriarty, K., Ed., Kaliski, B., Jonsson, J., and A. Rusch, 2102 "PKCS #1: RSA Cryptography Specifications Version 2.2", 2103 RFC 8017, DOI 10.17487/RFC8017, November 2016, 2104 . 2106 [RFC8152] Schaad, J., "CBOR Object Signing and Encryption (COSE)", 2107 RFC 8152, DOI 10.17487/RFC8152, July 2017, 2108 . 2110 [RFC8551] Schaad, J., Ramsdell, B., and S. Turner, "Secure/ 2111 Multipurpose Internet Mail Extensions (S/MIME) Version 4.0 2112 Message Specification", RFC 8551, DOI 10.17487/RFC8551, 2113 April 2019, . 2115 [RFC8230] Jones, M., "Using RSA Algorithms with CBOR Object Signing 2116 and Encryption (COSE) Messages", RFC 8230, 2117 DOI 10.17487/RFC8230, September 2017, 2118 . 2120 [I-D.ietf-core-oscore-groupcomm] 2121 Tiloca, M., Selander, G., Palombini, F., and J. Park, 2122 "Group OSCORE - Secure Group Communication for CoAP", Work 2123 in Progress, Internet-Draft, draft-ietf-core-oscore- 2124 groupcomm-06, 4 November 2019, 2125 . 2128 [I-D.ietf-cose-hash-sig] 2129 Housley, R., "Use of the HSS/LMS Hash-based Signature 2130 Algorithm with CBOR Object Signing and Encryption (COSE)", 2131 Work in Progress, Internet-Draft, draft-ietf-cose-hash- 2132 sig-09, 11 December 2019, 2133 . 2135 [I-D.ietf-cbor-sequence] 2136 Bormann, C., "Concise Binary Object Representation (CBOR) 2137 Sequences", Work in Progress, Internet-Draft, draft-ietf- 2138 cbor-sequence-02, 25 September 2019, 2139 . 2141 [SP800-56A] 2142 Barker, E., Chen, L., Roginsky, A., and M. Smid, 2143 "Recommendation for Pair-Wise Key Establishment Schemes 2144 Using Discrete Logarithm Cryptography", 2145 DOI 10.6028/NIST.SP.800-56Ar2, NIST Special Publication 2146 800-56A, Revision 2, May 2013, 2147 . 2150 Acknowledgments 2152 This document is a product of the COSE working group of the IETF. 2154 The following individuals are to blame for getting me started on this 2155 project in the first place: Richard Barnes, Matt Miller, and Martin 2156 Thomson. 2158 The initial version of the specification was based to some degree on 2159 the outputs of the JOSE and S/MIME working groups. 2161 The following individuals provided input into the final form of the 2162 document: Carsten Bormann, John Bradley, Brain Campbell, Michael B. 2163 Jones, Ilari Liusvaara, Francesca Palombini, Ludwig Seitz, and Goran 2164 Selander. 2166 Author's Address 2168 Jim Schaad 2169 August Cellars 2171 Email: ietf@augustcellars.com