idnits 2.17.1 draft-ietf-cose-msg-20.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 : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 754 has weird spacing: '...otected as de...' == Line 756 has weird spacing: '...otected as de...' == Line 758 has weird spacing: '...payload conta...' == Line 774 has weird spacing: '...natures is an...' == Line 789 has weird spacing: '...otected as de...' == (28 more instances...) -- The document date (October 10, 2016) is 2753 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Possible downref: Non-RFC (?) normative reference: ref. 'AES-GCM' -- Possible downref: Non-RFC (?) normative reference: ref. 'DSS' ** Downref: Normative reference to an Informational draft: draft-irtf-cfrg-eddsa (ref. 'I-D.irtf-cfrg-eddsa') -- Possible downref: Non-RFC (?) normative reference: ref. 'MAC' ** Downref: Normative reference to an Informational RFC: RFC 2104 ** Downref: Normative reference to an Informational RFC: RFC 3394 ** Downref: Normative reference to an Informational RFC: RFC 3610 ** Downref: Normative reference to an Informational RFC: RFC 5869 ** Downref: Normative reference to an Informational RFC: RFC 6090 ** Downref: Normative reference to an Informational RFC: RFC 6979 ** Obsolete normative reference: RFC 7049 (Obsoleted by RFC 8949) ** Obsolete normative reference: RFC 7539 (Obsoleted by RFC 8439) ** Downref: Normative reference to an Informational RFC: RFC 7748 -- Possible downref: Non-RFC (?) normative reference: ref. 'SEC1' == Outdated reference: A later version (-11) exists of draft-greevenbosch-appsawg-cbor-cddl-09 == Outdated reference: A later version (-06) exists of draft-selander-ace-object-security-05 -- Obsolete informational reference (is this intentional?): RFC 2633 (Obsoleted by RFC 3851) -- Obsolete informational reference (is this intentional?): RFC 5751 (Obsoleted by RFC 8551) -- Obsolete informational reference (is this intentional?): RFC 7159 (Obsoleted by RFC 8259) Summary: 10 errors (**), 0 flaws (~~), 9 warnings (==), 8 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 Intended status: Standards Track October 10, 2016 5 Expires: April 13, 2017 7 CBOR Object Signing and Encryption (COSE) 8 draft-ietf-cose-msg-20 10 Abstract 12 Concise Binary Object Representation (CBOR) is data format designed 13 for small code size and small message size. There is a need for the 14 ability to have basic security services defined for this data format. 15 This document defines the CBOR Object Signing and Encryption (COSE) 16 specification. This specification describes how to create and 17 process signature, message authentication codes and encryption using 18 CBOR for serialization. This specification additionally specifies 19 how to represent cryptographic keys using CBOR. 21 Contributing to this document 23 The source for this draft is being maintained in GitHub. Suggested 24 changes should be submitted as pull requests at . Instructions are on that page as well. 26 Editorial changes can be managed in GitHub, but any substantial 27 issues need to be discussed on the COSE mailing list. 29 Status of This Memo 31 This Internet-Draft is submitted in full conformance with the 32 provisions of BCP 78 and BCP 79. 34 Internet-Drafts are working documents of the Internet Engineering 35 Task Force (IETF). Note that other groups may also distribute 36 working documents as Internet-Drafts. The list of current Internet- 37 Drafts is at http://datatracker.ietf.org/drafts/current/. 39 Internet-Drafts are draft documents valid for a maximum of six months 40 and may be updated, replaced, or obsoleted by other documents at any 41 time. It is inappropriate to use Internet-Drafts as reference 42 material or to cite them other than as "work in progress." 44 This Internet-Draft will expire on April 13, 2017. 46 Copyright Notice 48 Copyright (c) 2016 IETF Trust and the persons identified as the 49 document authors. All rights reserved. 51 This document is subject to BCP 78 and the IETF Trust's Legal 52 Provisions Relating to IETF Documents 53 (http://trustee.ietf.org/license-info) in effect on the date of 54 publication of this document. Please review these documents 55 carefully, as they describe your rights and restrictions with respect 56 to this document. Code Components extracted from this document must 57 include Simplified BSD License text as described in Section 4.e of 58 the Trust Legal Provisions and are provided without warranty as 59 described in the Simplified BSD License. 61 Table of Contents 63 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 64 1.1. Design changes from JOSE . . . . . . . . . . . . . . . . 5 65 1.2. Requirements Terminology . . . . . . . . . . . . . . . . 6 66 1.3. CBOR Grammar . . . . . . . . . . . . . . . . . . . . . . 6 67 1.4. CBOR Related Terminology . . . . . . . . . . . . . . . . 7 68 1.5. Document Terminology . . . . . . . . . . . . . . . . . . 8 69 2. Basic COSE Structure . . . . . . . . . . . . . . . . . . . . 8 70 3. Header Parameters . . . . . . . . . . . . . . . . . . . . . . 10 71 3.1. Common COSE Headers Parameters . . . . . . . . . . . . . 12 72 4. Signing Objects . . . . . . . . . . . . . . . . . . . . . . . 16 73 4.1. Signing with One or More Signers . . . . . . . . . . . . 16 74 4.2. Signing with One Signer . . . . . . . . . . . . . . . . . 18 75 4.3. Externally Supplied Data . . . . . . . . . . . . . . . . 19 76 4.4. Signing and Verification Process . . . . . . . . . . . . 20 77 4.5. Computing Counter Signatures . . . . . . . . . . . . . . 21 78 5. Encryption Objects . . . . . . . . . . . . . . . . . . . . . 22 79 5.1. Enveloped COSE Structure . . . . . . . . . . . . . . . . 22 80 5.1.1. Content Key Distribution Methods . . . . . . . . . . 24 81 5.2. Single Recipient Encrypted . . . . . . . . . . . . . . . 25 82 5.3. How to encrypt and decrypt for AEAD Algorithms . . . . . 25 83 5.4. How to encrypt and decrypt for AE Algorithms . . . . . . 28 84 6. MAC Objects . . . . . . . . . . . . . . . . . . . . . . . . . 29 85 6.1. MACed Message with Recipients . . . . . . . . . . . . . . 30 86 6.2. MACed Messages with Implicit Key . . . . . . . . . . . . 31 87 6.3. How to compute and verify a MAC . . . . . . . . . . . . . 31 88 7. Key Objects . . . . . . . . . . . . . . . . . . . . . . . . . 33 89 7.1. COSE Key Common Parameters . . . . . . . . . . . . . . . 33 90 8. Signature Algorithms . . . . . . . . . . . . . . . . . . . . 36 91 8.1. ECDSA . . . . . . . . . . . . . . . . . . . . . . . . . . 37 92 8.1.1. Security Considerations . . . . . . . . . . . . . . . 39 93 8.2. Edwards-curve Digital Signature Algorithms (EdDSA) . . . 40 94 8.2.1. Security Considerations . . . . . . . . . . . . . . . 41 95 9. Message Authentication (MAC) Algorithms . . . . . . . . . . . 41 96 9.1. Hash-based Message Authentication Codes (HMAC) . . . . . 41 97 9.1.1. Security Considerations . . . . . . . . . . . . . . . 43 98 9.2. AES Message Authentication Code (AES-CBC-MAC) . . . . . . 43 99 9.2.1. Security Considerations . . . . . . . . . . . . . . . 44 100 10. Content Encryption Algorithms . . . . . . . . . . . . . . . . 45 101 10.1. AES GCM . . . . . . . . . . . . . . . . . . . . . . . . 45 102 10.1.1. Security Considerations . . . . . . . . . . . . . . 46 103 10.2. AES CCM . . . . . . . . . . . . . . . . . . . . . . . . 47 104 10.2.1. Security Considerations . . . . . . . . . . . . . . 50 105 10.3. ChaCha20 and Poly1305 . . . . . . . . . . . . . . . . . 50 106 10.3.1. Security Considerations . . . . . . . . . . . . . . 51 107 11. Key Derivation Functions (KDF) . . . . . . . . . . . . . . . 51 108 11.1. HMAC-based Extract-and-Expand Key Derivation Function 109 (HKDF) . . . . . . . . . . . . . . . . . . . . . . . . . 52 110 11.2. Context Information Structure . . . . . . . . . . . . . 54 111 12. Content Key Distribution Methods . . . . . . . . . . . . . . 57 112 12.1. Direct Encryption . . . . . . . . . . . . . . . . . . . 58 113 12.1.1. Direct Key . . . . . . . . . . . . . . . . . . . . . 58 114 12.1.2. Direct Key with KDF . . . . . . . . . . . . . . . . 59 115 12.2. Key Wrapping . . . . . . . . . . . . . . . . . . . . . . 60 116 12.2.1. AES Key Wrapping . . . . . . . . . . . . . . . . . . 61 117 12.3. Key Transport . . . . . . . . . . . . . . . . . . . . . 62 118 12.4. Direct Key Agreement . . . . . . . . . . . . . . . . . . 62 119 12.4.1. ECDH . . . . . . . . . . . . . . . . . . . . . . . . 63 120 12.4.2. Security Considerations . . . . . . . . . . . . . . 66 121 12.5. Key Agreement with Key Wrap . . . . . . . . . . . . . . 67 122 12.5.1. ECDH . . . . . . . . . . . . . . . . . . . . . . . . 67 123 13. Key Object Parameters . . . . . . . . . . . . . . . . . . . . 69 124 13.1. Elliptic Curve Keys . . . . . . . . . . . . . . . . . . 69 125 13.1.1. Double Coordinate Curves . . . . . . . . . . . . . . 70 126 13.2. Octet Key Pair . . . . . . . . . . . . . . . . . . . . . 71 127 13.3. Symmetric Keys . . . . . . . . . . . . . . . . . . . . . 72 128 14. CBOR Encoder Restrictions . . . . . . . . . . . . . . . . . . 73 129 15. Application Profiling Considerations . . . . . . . . . . . . 73 130 16. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 75 131 16.1. CBOR Tag assignment . . . . . . . . . . . . . . . . . . 75 132 16.2. COSE Header Parameters Registry . . . . . . . . . . . . 75 133 16.3. COSE Header Algorithm Parameters Registry . . . . . . . 76 134 16.4. COSE Algorithms Registry . . . . . . . . . . . . . . . . 77 135 16.5. COSE Key Common Parameters Registry . . . . . . . . . . 77 136 16.6. COSE Key Type Parameters Registry . . . . . . . . . . . 78 137 16.7. COSE Key Type Registry . . . . . . . . . . . . . . . . . 79 138 16.8. COSE Elliptic Curve Parameters Registry . . . . . . . . 79 139 16.9. Media Type Registrations . . . . . . . . . . . . . . . . 80 140 16.9.1. COSE Security Message . . . . . . . . . . . . . . . 80 141 16.9.2. COSE Key media type . . . . . . . . . . . . . . . . 81 143 16.10. CoAP Content-Format Registrations . . . . . . . . . . . 83 144 16.11. Expert Review Instructions . . . . . . . . . . . . . . . 84 145 17. Implementation Status . . . . . . . . . . . . . . . . . . . . 85 146 17.1. Author's Versions . . . . . . . . . . . . . . . . . . . 86 147 17.2. COSE Testing Library . . . . . . . . . . . . . . . . . . 86 148 18. Security Considerations . . . . . . . . . . . . . . . . . . . 87 149 19. References . . . . . . . . . . . . . . . . . . . . . . . . . 89 150 19.1. Normative References . . . . . . . . . . . . . . . . . . 89 151 19.2. Informative References . . . . . . . . . . . . . . . . . 90 152 Appendix A. Making Mandatory Algorithm Header Optional . . . . . 93 153 A.1. Algorithm Identification . . . . . . . . . . . . . . . . 93 154 A.2. Counter Signature Without Headers . . . . . . . . . . . . 96 155 Appendix B. Two Layers of Recipient Information . . . . . . . . 97 156 Appendix C. Examples . . . . . . . . . . . . . . . . . . . . . . 99 157 C.1. Examples of Signed Message . . . . . . . . . . . . . . . 100 158 C.1.1. Single Signature . . . . . . . . . . . . . . . . . . 100 159 C.1.2. Multiple Signers . . . . . . . . . . . . . . . . . . 101 160 C.1.3. Counter Signature . . . . . . . . . . . . . . . . . . 102 161 C.1.4. Signature w/ Criticality . . . . . . . . . . . . . . 103 162 C.2. Single Signer Examples . . . . . . . . . . . . . . . . . 104 163 C.2.1. Single ECDSA signature . . . . . . . . . . . . . . . 104 164 C.3. Examples of Enveloped Messages . . . . . . . . . . . . . 105 165 C.3.1. Direct ECDH . . . . . . . . . . . . . . . . . . . . . 105 166 C.3.2. Direct plus Key Derivation . . . . . . . . . . . . . 106 167 C.3.3. Counter Signature on Encrypted Content . . . . . . . 107 168 C.3.4. Encrypted Content with External Data . . . . . . . . 109 169 C.4. Examples of Encrypted Messages . . . . . . . . . . . . . 109 170 C.4.1. Simple Encrypted Message . . . . . . . . . . . . . . 109 171 C.4.2. Encrypted Message w/ a Partial IV . . . . . . . . . . 110 172 C.5. Examples of MACed messages . . . . . . . . . . . . . . . 110 173 C.5.1. Shared Secret Direct MAC . . . . . . . . . . . . . . 110 174 C.5.2. ECDH Direct MAC . . . . . . . . . . . . . . . . . . . 111 175 C.5.3. Wrapped MAC . . . . . . . . . . . . . . . . . . . . . 112 176 C.5.4. Multi-recipient MACed message . . . . . . . . . . . . 113 177 C.6. Examples of MAC0 messages . . . . . . . . . . . . . . . . 114 178 C.6.1. Shared Secret Direct MAC . . . . . . . . . . . . . . 114 179 C.7. COSE Keys . . . . . . . . . . . . . . . . . . . . . . . . 115 180 C.7.1. Public Keys . . . . . . . . . . . . . . . . . . . . . 115 181 C.7.2. Private Keys . . . . . . . . . . . . . . . . . . . . 116 182 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 118 183 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 119 185 1. Introduction 187 There has been an increased focus on small, constrained devices that 188 make up the Internet of Things (IoT). One of the standards that has 189 come out of this process is the Concise Binary Object Representation 190 (CBOR) [RFC7049]. CBOR extended the data model of the JavaScript 191 Object Notation (JSON) [RFC7159] by allowing for binary data, among 192 other changes. CBOR is being adopted by several of the IETF working 193 groups dealing with the IoT world as their encoding of data 194 structures. CBOR was designed specifically to be both small in terms 195 of messages transport and implementation size, as well having a 196 schema free decoder. A need exists to provide message security 197 services for IoT, and using CBOR as the message encoding format makes 198 sense. 200 The JOSE working group produced a set of documents 201 [RFC7515][RFC7516][RFC7517][RFC7518] using JSON that specified how to 202 process encryption, signatures and Message Authentication Code (MAC) 203 operations, and how to encode keys using JSON. This document defines 204 the CBOR Object Encryption and Signing (COSE) standard which does the 205 same thing for the CBOR encoding format. While there is a strong 206 attempt to keep the flavor of the original JOSE documents, two 207 considerations are taken into account: 209 o CBOR has capabilities that are not present in JSON and are 210 appropriate to use. One example of this is the fact that CBOR has 211 a method of encoding binary directly without first converting it 212 into a base64 encoded string. 214 o COSE is not a direct copy of the JOSE specification. In the 215 process of creating COSE, decisions that were made for JOSE were 216 re-examined. In many cases different results were decided on as 217 the criteria was not always the same. 219 1.1. Design changes from JOSE 221 o Define a single top message structure so that encrypted, signed 222 and MACed messages can easily be identified and still have a 223 consistent view. 225 o Signed messages distinguish between the protected and unprotected 226 parameters that relate to the content from those that relate to 227 the signature. 229 o MACed messages are separated from signed messages. 231 o MACed messages have the ability to use the same set of recipient 232 algorithms as enveloped messages for obtaining the MAC 233 authentication key. 235 o Use binary encodings for binary data rather than base64url 236 encodings. 238 o Combine the authentication tag for encryption algorithms with the 239 cipher text. 241 o The set of cryptographic algorithms has been expanded in some 242 directions, and trimmed in others. 244 1.2. Requirements Terminology 246 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 247 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 248 "OPTIONAL" in this document are to be interpreted as described in 249 [RFC2119]. 251 When the words appear in lower case, their natural language meaning 252 is used. 254 1.3. CBOR Grammar 256 There is currently no standard CBOR grammar available for use by 257 specifications. The CBOR structures are therefore described in 258 prose. 260 The document was developed by first working on the grammar and then 261 developing the prose to go with it. An artifact of this is that the 262 prose was written using the primitive type strings defined by CBOR 263 Data Definition Language (CDDL) [I-D.greevenbosch-appsawg-cbor-cddl]. 264 In this specification, the following primitive types are used: 266 any - non-specific value that permits all CBOR values to be placed 267 here. 269 bool - a boolean value (true: major type 7, value 21; false: major 270 type 7, value 20). 272 bstr - byte string (major type 2). 274 int - an unsigned integer or a negative integer. 276 nil - a null value (major type 7, value 22). 278 nint - a negative integer (major type 1). 280 tstr - a UTF-8 text string (major type 3). 282 uint - an unsigned integer (major type 0). 284 Two syntaxes from CDDL appear in this document as shorthand. These 285 are: 287 FOO / BAR - indicates that either FOO or BAR can appear here 289 [+ FOO] - indicates that the type FOO appears one or more times in 290 an array 292 As well as the prose description, a version of a CBOR grammar is 293 presented in CDDL. Since CDDL has not been published as an RFC, this 294 grammar may not work with the final version of CDDL. The CDDL 295 grammar is informational, the prose description is normative. 297 The collected CDDL can be extracted from the XML version of this 298 document via the following XPath expression below. (Depending on the 299 XPath evaluator one is using, it may be necessary to deal with > 300 as an entity.) 302 //artwork[@type='CDDL']/text() 304 CDDL expects the initial non-terminal symbol to be the first symbol 305 in the file. For this reason the first fragment of CDDL is presented 306 here. 308 start = COSE_Messages / COSE_Key / COSE_KeySet / Internal_Types 310 ; This is defined to make the tool quieter: 311 Internal_Types = Sig_structure / Enc_structure / MAC_structure / 312 COSE_KDF_Context 314 The non-terminal Internal_Types is defined for dealing with the 315 automated validation tools used during the writing of this document. 316 It references those non-terminals that are used for security 317 computations, but are not emitted for transport. 319 1.4. CBOR Related Terminology 321 In JSON, maps are called objects and only have one kind of map key: a 322 string. In COSE, we use strings, negative integers and unsigned 323 integers as map keys. The integers are used for compactness of 324 encoding and easy comparison. The inclusion of strings allows for an 325 additional range of short encoded values to be used as well. Since 326 the word "key" is mainly used in its other meaning, as a 327 cryptographic key, we use the term "label" for this usage as a map 328 key. 330 The presence of a label in a COSE map which is not a string or an 331 integer is an error. Applications can either fail processing or 332 process messages with incorrect labels, however they MUST NOT create 333 messages with incorrect labels. 335 A CDDL grammar fragment is defined that defines the non-terminals 336 'label', as in the previous paragraph and 'values', which permits any 337 value to be used. 339 label = int / tstr 340 values = any 342 1.5. Document Terminology 344 In this document, we use the following terminology: 346 Byte is a synonym for octet. 348 Constrained Application Protocol (CoAP) is a specialized web transfer 349 protocol for use in constrained systems. It is defined in [RFC7252]. 351 Authenticated Encryption (AE) [RFC5116] algorithms are those 352 encryption algorithms which provide an authentication check of the 353 contents algorithm with the encryption service. 355 Authenticated Encryption with Authenticated Data (AEAD) [RFC5116] 356 algorithms provide the same content authentication service as AE 357 algorithms, but additionally provide for authentication of non- 358 encrypted data as well. 360 2. Basic COSE Structure 362 The COSE object structure is designed so that there can be a large 363 amount of common code when parsing and processing the different types 364 of security messages. All of the message structures are built on the 365 CBOR array type. The first three elements of the array always 366 contain the same information: 368 1. The set of protected header parameters wrapped in a bstr. 370 2. The set of unprotected header parameters as a map. 372 3. The content of the message. The content is either the plain text 373 or the cipher text as appropriate. The content may be detached, 374 but the location is still used. The content is wrapped in a bstr 375 when present and is a nil value when detached. 377 Elements after this point are dependent on the specific message type. 379 COSE messages are also built using the concept of layers to separate 380 different types of cryptographic concepts. As an example of how this 381 works, consider the COSE_Encrypt message (Section 5.1). This message 382 type is broken into two layers: the content layer and the recipient 383 layer. In the content layer, the plain text is encrypted and 384 information about the encrypted message are placed. In the recipient 385 layer, the content encryption key (CEK) is encrypted and information 386 about how it is encrypted for each recipient is placed. A single 387 layer version of the encryption message COSE_Encrypt0 (Section 5.2) 388 is provided for cases where the CEK is pre-shared. 390 Identification of which type of message has been presented is done by 391 the following methods: 393 1. The specific message type is known from the context. This may be 394 defined by a marker in the containing structure or by 395 restrictions specified by the application protocol. 397 2. The message type is identified by a CBOR tag. Messages with a 398 CBOR tag are known in this specification as tagged messages, 399 while those without the CBOR tag are known as untagged messages. 400 This document defines a CBOR tag for each of the message 401 structures. These tags can be found in Table 1. 403 3. When a COSE object is carried in a media type of application/ 404 cose, the optional parameter 'cose-type' can be used to identify 405 the embedded object. The parameter is OPTIONAL if the tagged 406 version of the structure is used. The parameter is REQUIRED if 407 the untagged version of the structure is used. The value to use 408 with the parameter for each of the structures can be found in 409 Table 1. 411 4. When a COSE object is carried as a CoAP payload, the CoAP 412 Content-Format Option can be used to identify the message 413 content. The CoAP Content-Format values can be found in 414 Table 26. The CBOR tag for the message structure is not required 415 as each security message is uniquely identified. 417 +-------+---------------+---------------+---------------------------+ 418 | CBOR | cose-type | Data Item | Semantics | 419 | Tag | | | | 420 +-------+---------------+---------------+---------------------------+ 421 | TBD1 | cose-sign | COSE_Sign | COSE Signed Data Object | 422 | | | | | 423 | TBD7 | cose-sign1 | COSE_Sign1 | COSE Single Signer Data | 424 | | | | Object | 425 | | | | | 426 | TBD2 | cose-encrypt | COSE_Encrypt | COSE Encrypted Data | 427 | | | | Object | 428 | | | | | 429 | TBD3 | cose-encrypt0 | COSE_Encrypt0 | COSE Single Recipient | 430 | | | | Encrypted Data Object | 431 | | | | | 432 | TBD4 | cose-mac | COSE_Mac | COSE Mac-ed Data Object | 433 | | | | | 434 | TBD6 | cose-mac0 | COSE_Mac0 | COSE Mac w/o Recipients | 435 | | | | Object | 436 +-------+---------------+---------------+---------------------------+ 438 Table 1: COSE Message Identification 440 The following CDDL fragment identifies all of the top messages 441 defined in this document. Separate non-terminals are defined for the 442 tagged and the untagged versions of the messages. 444 COSE_Messages = COSE_Untagged_Message / COSE_Tagged_Message 446 COSE_Untagged_Message = COSE_Sign / COSE_Sign1 / 447 COSE_Encrypt / COSE_Encrypt0 / 448 COSE_Mac / COSE_Mac0 450 COSE_Tagged_Message = COSE_Sign_Tagged / COSE_Sign1_Tagged / 451 COSE_Encrypt_Tagged / COSE_Encrypt0_Tagged / 452 COSE_Mac_Tagged / COSE_Mac0_Tagged 454 3. Header Parameters 456 The structure of COSE has been designed to have two buckets of 457 information that are not considered to be part of the payload itself, 458 but are used for holding information about content, algorithms, keys, 459 or evaluation hints for the processing of the layer. These two 460 buckets are available for use in all of the structures except for 461 keys. While these buckets are present, they may not all be usable in 462 all instances. For example, while the protected bucket is defined as 463 part of the recipient structure, some of the algorithms used for 464 recipient structures do not provide for authenticated data. If this 465 is the case, the protected bucket is left empty. 467 Both buckets are implemented as CBOR maps. The map key is a 'label' 468 (Section 1.4). The value portion is dependent on the definition for 469 the label. Both maps use the same set of label/value pairs. The 470 integer and string values for labels have been divided into several 471 sections with a standard range, a private range, and a range that is 472 dependent on the algorithm selected. The defined labels can be found 473 in the "COSE Header Parameters" IANA registry (Section 16.2). 475 Two buckets are provided for each layer: 477 protected: Contains parameters about the current layer that are to 478 be cryptographically protected. This bucket MUST be empty if it 479 is not going to be included in a cryptographic computation. This 480 bucket is encoded in the message as a binary object. This value 481 is obtained by CBOR encoding the protected map and wrapping it in 482 a bstr object. Senders SHOULD encode a zero length map as a zero 483 length string rather than as a zero length map (encoded as h'a0'). 484 The zero length binary encoding is preferred because it is both 485 shorter and the version used in the serialization structures for 486 cryptographic computation. After encoding the map, the value is 487 wrapped in the binary object. Recipients MUST accept both a zero 488 length binary value and a zero length map encoded in the binary 489 value. The wrapping allows for the encoding of the protected map 490 to be transported with a greater chance that it will not be 491 altered in transit. (Badly behaved intermediates could decode and 492 re-encode, but this will result in a failure to verify unless the 493 re-encoded byte string is identical to the decoded byte string.) 494 This avoids the problem of all parties needing to be able to do a 495 common canonical encoding. 497 unprotected: Contains parameters about the current layer that are 498 not cryptographically protected. 500 Only parameters that deal with the current layer are to be placed at 501 that layer. As an example of this, the parameter 'content type' 502 describes the content of the message being carried in the message. 503 As such, this parameter is placed only in the content layer and is 504 not placed in the recipient or signature layers. In principle, one 505 should be able to process any given layer without reference to any 506 other layer. With the exception of the COSE_Sign structure, the only 507 data that needs to cross layers is the cryptographic key. 509 The buckets are present in all of the security objects defined in 510 this document. The fields in order are the 'protected' bucket (as a 511 CBOR 'bstr' type) and then the 'unprotected' bucket (as a CBOR 'map' 512 type). The presence of both buckets is required. The parameters 513 that go into the buckets come from the IANA "COSE Header Parameters" 514 registry (Section 16.2). Some common parameters are defined in the 515 next section, but a number of parameters are defined throughout this 516 document. 518 Labels in each of the maps MUST be unique. When processing messages, 519 if a label appears multiple times, the message MUST be rejected as 520 malformed. Applications SHOULD verify that the same label does not 521 occur in both the protected and unprotected headers. If the message 522 is not rejected as malformed, attributes MUST be obtained from the 523 protected bucket before they are obtained from the unprotected 524 bucket. 526 The following CDDL fragment represents the two header buckets. A 527 group Headers is defined in CDDL that represents the two buckets in 528 which attributes are placed. This group is used to provide these two 529 fields consistently in all locations. A type is also defined which 530 represents the map of common headers. 532 Headers = ( 533 protected : empty_or_serialized_map, 534 unprotected : header_map 535 ) 537 header_map = { 538 Generic_Headers, 539 * label => values 540 } 542 empty_or_serialized_map = bstr .cbor header_map / bstr .size 0 544 3.1. Common COSE Headers Parameters 546 This section defines a set of common header parameters. A summary of 547 these parameters can be found in Table 2. This table should be 548 consulted to determine the value of label, and the type of the value. 550 The set of header parameters defined in this section are: 552 alg: This parameter is used to indicate the algorithm used for the 553 security processing. This parameter MUST be present in the 554 COSE_Signature, COSE_Sign1, COSE_Encrypt, COSE_Encrypt0, COSE_Mac, 555 and COSE_Mac0 structures. When the algorithm supports 556 authenticating associated data, this parameter MUST be in the 557 protected header bucket. The value is taken from the "COSE 558 Algorithms" Registry (see Section 16.4). 560 crit: The parameter is used to indicate which protected header 561 labels an application that is processing a message is required to 562 understand. Parameters defined in this document do not need to be 563 included as they should be understood by all implementations. 564 When present, this parameter MUST be placed in the protected 565 header bucket. The array MUST have at least one value in it. 566 Not all labels need to be included in the 'crit' parameter. The 567 rules for deciding which header labels are placed in the array 568 are: 570 * Integer labels in the range of 0 to 8 SHOULD be omitted. 572 * Integer labels in the range -1 to -128 can be omitted as they 573 are algorithm dependent. If an application can correctly 574 process an algorithm, it can be assumed that it will correctly 575 process all of the common parameters associated with that 576 algorithm. Integer labels in the range -129 to -65536 SHOULD 577 be included as these would be less common parameters that might 578 not be generally supported. 580 * Labels for parameters required for an application MAY be 581 omitted. Applications should have a statement if the label can 582 be omitted. 584 The header parameter values indicated by 'crit' can be processed 585 by either the security library code or by an application using a 586 security library; the only requirement is that the parameter is 587 processed. If the 'crit' value list includes a value for which 588 the parameter is not in the protected bucket, this is a fatal 589 error in processing the message. 591 content type: This parameter is used to indicate the content type of 592 the data in the payload or cipher text fields. Integers are from 593 the "CoAP Content-Formats" IANA registry table [COAP.Formats]. 594 Text values following the syntax of Content-Type defined in 595 Section 4.2 of [RFC6838] omitting the prefix string "Content- 596 Type:". Leading and trailing whitespace is also omitted. Textual 597 content values along with parameters and subparameters can be 598 located using the IANA "Media Types" registry. Applications 599 SHOULD provide this parameter if the content structure is 600 potentially ambiguous. 602 kid: This parameter identifies one piece of data that can be used as 603 input to find the needed cryptographic key. The value of this 604 parameter can be matched against the 'kid' member in a COSE_Key 605 structure. Other methods of key distribution can define an 606 equivalent field to be matched. Applications MUST NOT assume that 607 'kid' values are unique. There may be more than one key with the 608 same 'kid' value, so all of the keys associated with this 'kid' 609 may need to be checked. The internal structure of 'kid' values is 610 not defined and cannot be relied on by applications. Key 611 identifier values are hints about which key to use. This is not a 612 security critical field. For this reason, it can be placed in the 613 unprotected headers bucket. 615 IV: This parameter holds the Initialization Vector (IV) value. For 616 some symmetric encryption algorithms this may be referred to as a 617 nonce. The IV can be placed in the unprotected header as 618 modifying the IV will cause the decryption to yield plaintext that 619 is readily detectable as garbled. 621 Partial IV This parameter holds a part of the IV value. When using 622 the COSE_Encrypt0 structure, a portion of the IV can be part of 623 the context associated with the key. This field is used to carry 624 a value that causes the IV to be changed for each message. The IV 625 can be placed in the unprotected header as modifying the IV will 626 cause the decryption to yield plaintext that is readily detectable 627 as garbled. The 'Initialization Vector' and 'Partial 628 Initialization Vector' parameters MUST NOT both be present in the 629 same security layer. 630 The message IV is generated by the following steps: 632 1. Left pad the partial IV with zeros to the length of IV. 634 2. XOR the padded partial IV with the context IV. 636 counter signature: This parameter holds one or more counter 637 signature values. Counter signatures provide a method of having a 638 second party sign some data. The counter signature parameter can 639 occur as an unprotected attribute in any of the following 640 structures: COSE_Sign1, COSE_Signature, COSE_Encrypt, 641 COSE_recipient, COSE_Encrypt0, COSE_Mac and COSE_Mac0. These 642 structures all have the same beginning elements so that a 643 consistent calculation of the counter signature can be computed. 644 Details on computing counter signatures are found in Section 4.5. 646 +-----------+-------+----------------+-------------+----------------+ 647 | name | label | value type | value | description | 648 | | | | registry | | 649 +-----------+-------+----------------+-------------+----------------+ 650 | alg | 1 | int / tstr | COSE | Cryptographic | 651 | | | | Algorithms | algorithm to | 652 | | | | registry | use | 653 | | | | | | 654 | crit | 2 | [+ label] | COSE Header | Critical | 655 | | | | Labels | headers to be | 656 | | | | registry | understood | 657 | | | | | | 658 | content | 3 | tstr / uint | CoAP | Content type | 659 | type | | | Content- | of the payload | 660 | | | | Formats or | | 661 | | | | Media Types | | 662 | | | | registry | | 663 | | | | | | 664 | kid | 4 | bstr | | Key identifier | 665 | | | | | | 666 | IV | 5 | bstr | | Full | 667 | | | | | Initialization | 668 | | | | | Vector | 669 | | | | | | 670 | Partial | 6 | bstr | | Partial | 671 | IV | | | | Initialization | 672 | | | | | Vector | 673 | | | | | | 674 | counter | 7 | COSE_Signature | | CBOR encoded | 675 | signature | | / [+ | | signature | 676 | | | COSE_Signature | | structure | 677 | | | ] | | | 678 +-----------+-------+----------------+-------------+----------------+ 680 Table 2: Common Header Parameters 682 The CDDL fragment that represents the set of headers defined in this 683 section is given below. Each of the headers is tagged as optional 684 because they do not need to be in every map; headers required in 685 specific maps are discussed above. 687 Generic_Headers = ( 688 ? 1 => int / tstr, ; algorithm identifier 689 ? 2 => [+label], ; criticality 690 ? 3 => tstr / int, ; content type 691 ? 4 => bstr, ; key identifier 692 ? 5 => bstr, ; IV 693 ? 6 => bstr, ; Partial IV 694 ? 7 => COSE_Signature / [+COSE_Signature] ; Counter signature 695 ) 697 4. Signing Objects 699 COSE supports two different signature structures. COSE_Sign allows 700 for one or more signatures to be applied to the same content. 701 COSE_Sign1 is restricted to a single signer. The structures cannot 702 be converted between each other; as the signature computation 703 includes a parameter identifying which structure is being used, the 704 converted structure will fail signature validation. 706 4.1. Signing with One or More Signers 708 The COSE_Sign structure allows for one or more signatures to be 709 applied to a message payload. Parameters relating to the content and 710 parameters relating to the signature are carried along with the 711 signature itself. These parameters may be authenticated by the 712 signature, or just present. An example of a parameter about the 713 content is the content type. Examples of parameters about the 714 signature would be the algorithm and key used to create the signature 715 and counter signatures. 717 When more than one signature is present, the successful validation of 718 one signature associated with a given signer is usually treated as a 719 successful signature by that signer. However, there are some 720 application environments where other rules are needed. An 721 application that employs a rule other than one valid signature for 722 each signer must specify those rules. Also, where simple matching of 723 the signer identifier is not sufficient to determine whether the 724 signatures were generated by the same signer, the application 725 specification must describe how to determine which signatures were 726 generated by the same signer. Support for different communities of 727 recipients is the primary reason that signers choose to include more 728 than one signature. For example, the COSE_Sign structure might 729 include signatures generated with the Edwards Digital Signature 730 Algorithm (EdDSA) [I-D.irtf-cfrg-eddsa] signature algorithm and with 731 the Elliptic Curve Digital Signature Algorithm (ECDSA) [DSS] 732 signature algorithm. This allows recipients to verify the signature 733 associated with one algorithm or the other. (The original source of 734 this text is [RFC5652].) More detailed information on multiple 735 signature evaluation can be found in [RFC5752]. 737 The signature structure can be encoded either as tagged or untagged 738 depending on the context it will be used in. A tagged COSE_Sign 739 structure is identified by the CBOR tag TBD1. The CDDL fragment that 740 represents this is: 742 COSE_Sign_Tagged = #6.991(COSE_Sign) ; Replace 991 with TBD1 744 A COSE Signed Message is defined in two parts. The CBOR object that 745 carries the body and information about the body is called the 746 COSE_Sign structure. The CBOR object that carries the signature and 747 information about the signature is called the COSE_Signature 748 structure. Examples of COSE Signed Messages can be found in 749 Appendix C.1. 751 The COSE_Sign structure is a CBOR array. The fields of the array in 752 order are: 754 protected as described in Section 3. 756 unprotected as described in Section 3. 758 payload contains the serialized content to be signed. If the 759 payload is not present in the message, the application is required 760 to supply the payload separately. The payload is wrapped in a 761 bstr to ensure that it is transported without changes. If the 762 payload is transported separately ("detached content"), then a nil 763 CBOR object is placed in this location and it is the 764 responsibility of the application to ensure that it will be 765 transported without changes. 767 Note: When a signature with message recovery algorithm is used 768 (Section 8), the maximum number of bytes that can be recovered is 769 the length of the payload. The size of the payload is reduced by 770 the number of bytes that will be recovered. If all of the bytes 771 of the payload are consumed, then the payload is encoded as a zero 772 length binary string rather than as being absent. 774 signatures is an array of signatures. Each signature is represented 775 as a COSE_Signature structure. 777 The CDDL fragment that represents the above text for COSE_Sign 778 follows. 780 COSE_Sign = [ 781 Headers, 782 payload : bstr / nil, 783 signatures : [+ COSE_Signature] 784 ] 786 The COSE_Signature structure is a CBOR array. The fields of the 787 array in order are: 789 protected as described in Section 3. 791 unprotected as described in Section 3. 793 signature contains the computed signature value. The type of the 794 field is a bstr. Algorithms MUST specify padding if the signature 795 value is not a multiple of 8 bits. 797 The CDDL fragment that represents the above text for COSE_Signature 798 follows. 800 COSE_Signature = [ 801 Headers, 802 signature : bstr 803 ] 805 4.2. Signing with One Signer 807 The COSE_Sign1 signature structure is used when only one signature is 808 going to be placed on a message. The parameters dealing with the 809 content and the signature are placed in the same pair of buckets 810 rather than having the separation of COSE_Sign. 812 The structure can be encoded either tagged or untagged depending on 813 the context it will be used in. A tagged COSE_Sign1 structure is 814 identified by the CBOR tag TBD7. The CDDL fragment that represents 815 this is: 817 COSE_Sign1_Tagged = #6.997(COSE_Sign1) ; Replace 997 with TBD7 819 The CBOR object that carries the body, the signature, and the 820 information about the body and signature is called the COSE_Sign1 821 structure. Examples of COSE_Sign1 messages can be found in 822 Appendix C.2. 824 The COSE_Sign1 structure is a CBOR array. The fields of the array in 825 order are: 827 protected as described in Section 3. 829 unprotected as described in Section 3. 831 payload as described in Section 4.1. 833 signature contains the computed signature value. The type of the 834 field is a bstr. 836 The CDDL fragment that represents the above text for COSE_Sign1 837 follows. 839 COSE_Sign1 = [ 840 Headers, 841 payload : bstr / nil, 842 signature : bstr 843 ] 845 4.3. Externally Supplied Data 847 One of the features offered in the COSE document is the ability for 848 applications to provide additional data to be authenticated, but that 849 is not carried as part of the COSE object. The primary reason for 850 supporting this can be seen by looking at the CoAP message structure 851 [RFC7252], where the facility exists for options to be carried before 852 the payload. Examples of data that can be placed in this location 853 would be the CoAP code or CoAP options. If the data is in the header 854 section, then it is available for proxies to help in performing its 855 operations. For example, the Accept Option can be used by a proxy to 856 determine if an appropriate value is in the Proxy's cache. But the 857 sender can prevent a proxy from changing the set of values that it 858 will accept by including that value in the resulting authentication 859 tag. However, it may also be desired to protect these values so that 860 if they are modified in transit, it can be detected. 862 This document describes the process for using a byte array of 863 externally supplied authenticated data; however, the method of 864 constructing the byte array is a function of the application. 865 Applications that use this feature need to define how the externally 866 supplied authenticated data is to be constructed. Such a 867 construction needs to take into account the following issues: 869 o If multiple items are included, applications need to ensure that 870 the same byte string is not produced if there are different 871 inputs. This could occur by appending the strings 'AB' and 'CDE' 872 or by appending the strings 'ABC' and 'DE'. This is usually 873 addressed by making fields a fixed width and/or encoding the 874 length of the field as part of the output. Using options from 875 CoAP [RFC7252] as an example, these fields use a TLV structure so 876 they can be concatenated without any problems. 878 o If multiple items are included, an order for the items needs to be 879 defined. Using options from CoAP as an example, an application 880 could state that the fields are to be ordered by the option 881 number. 883 o Applications need to ensure that the byte stream is going to be 884 the same on both sides. Using options from CoAP might give a 885 problem if the same relative numbering is kept. An intermediate 886 node could insert or remove an option, changing how the relative 887 number is done. An application would need to specify that the 888 relative number must be re-encoded to be relative only to the 889 options that are in the external data. 891 4.4. Signing and Verification Process 893 In order to create a signature, a well-defined byte stream is needed. 894 The Sig_struture is used to create the canonical form. This signing 895 and verification process takes in the body information (COSE_Sign or 896 COSE_Sign1), the signer information (COSE_Signature), and the 897 application data (external source). A Sig_structure is a CBOR array. 898 The fields of the Sig_struture in order are: 900 1. A text string identifying the context of the signature. The 901 context string is: 903 "Signature" for signatures using the COSE_Signature structure. 905 "Signature1" for signatures using the COSE_Sign1 structure. 907 "CounterSignature" for signatures used as counter signature 908 attributes. 910 2. The protected attributes from the body structure encoded in a 911 bstr type. If there are no protected attributes, a bstr of 912 length zero is used. 914 3. The protected attributes from the signer structure encoded in a 915 bstr type. If there are no protected attributes, a bstr of 916 length zero is used. This field is omitted for the COSE_Sign1 917 signature structure. 919 4. The protected attributes from the application encoded in a bstr 920 type. If this field is not supplied, it defaults to a zero 921 length binary string. (See Section 4.3 for application guidance 922 on constructing this field.) 924 5. The payload to be signed encoded in a bstr type. The payload is 925 placed here independent of how it is transported. 927 The CDDL fragment that describes the above text is. 929 Sig_structure = [ 930 context : "Signature" / "Signature1" / "CounterSignature", 931 body_protected : empty_or_serialized_map, 932 ? sign_protected : empty_or_serialized_map, 933 external_aad : bstr, 934 payload : bstr 935 ] 937 How to compute a signature: 939 1. Create a Sig_structure and populate it with the appropriate 940 fields. 942 2. Create the value ToBeSigned by encoding the Sig_structure to a 943 byte string, using the encoding described in Section 14. 945 3. Call the signature creation algorithm passing in K (the key to 946 sign with), alg (the algorithm to sign with), and ToBeSigned (the 947 value to sign). 949 4. Place the resulting signature value in the 'signature' field of 950 the array. 952 The steps for verifying a signature are: 954 1. Create a Sig_structure object and populate it with the 955 appropriate fields. 957 2. Create the value ToBeSigned by encoding the Sig_structure to a 958 byte string, using the encoding described in Section 14. 960 3. Call the signature verification algorithm passing in K (the key 961 to verify with), alg (the algorithm used sign with), ToBeSigned 962 (the value to sign), and sig (the signature to be verified). 964 In addition to performing the signature verification, the application 965 may also perform the appropriate checks to ensure that the key is 966 correctly paired with the signing identity and that the signing 967 identity is authorized before performing actions. 969 4.5. Computing Counter Signatures 971 Counter signatures provide a method of associating different 972 signature generated by different signers with some piece of content. 973 This is normally used to provide a signature on a signature allowing 974 for a proof that a signature existed at a given time (i.e., a 975 Timestamp). In this document, we allow for counter signatures to 976 exist in a greater number of environments. As an example, it is 977 possible to place a counter signature in the unprotected attributes 978 of a COSE_Encrypt object. This would allow for an intermediary to 979 either verify that the encrypted byte stream has not been modified, 980 without being able to decrypt it, or for the intermediary to assert 981 that an encrypted byte stream either existed at a given time or 982 passed through it in terms of routing (i.e., a proxy signature). 984 An example of a counter signature on a signature can be found in 985 Appendix C.1.3. An example of a counter signature in an encryption 986 object can be found in Appendix C.3.3. 988 The creation and validation of counter signatures over the different 989 items relies on the fact that the structure of the objects have the 990 same structure. The elements are a set of protected attributes, a 991 set of unprotected attributes, and a body, in that order. This means 992 that the Sig_structure can be used in a uniform manner to get the 993 byte stream for processing a signature. If the counter signature is 994 going to be computed over a COSE_Encrypt structure, the 995 body_protected and payload items can be mapped into the Sig_structure 996 in the same manner as from the COSE_Sign structure. 998 It should be noted that only a signature algorithm with appendix (see 999 Section 8) can be used for counter signatures. This is because the 1000 body should be able to be processed without having to evaluate the 1001 counter signature, and this is not possible for signature schemes 1002 with message recovery. 1004 5. Encryption Objects 1006 COSE supports two different encryption structures. COSE_Encrypt0 is 1007 used when a recipient structure is not needed because the key to be 1008 used is known implicitly. COSE_Encrypt is used the rest of the time. 1009 This includes cases where there are multiple recipients or a 1010 recipient algorithm other than direct is used. 1012 5.1. Enveloped COSE Structure 1014 The enveloped structure allows for one or more recipients of a 1015 message. There are provisions for parameters about the content and 1016 parameters about the recipient information to be carried in the 1017 message. The protected parameters associated with the content are 1018 authenticated by the content encryption algorithm. The protected 1019 parameters associated with the recipient are authenticated by the 1020 recipient algorithm (when the algorithm supports it). Examples of 1021 parameters about the content are the type of the content and the 1022 content encryption algorithm. Examples of parameters about the 1023 recipient are the recipient's key identifier and the recipient's 1024 encryption algorithm. 1026 The same techniques and structures are used for encrypting both the 1027 plain text and the keys. This is different from the approach used by 1028 both CMS [RFC5652] and JSON Web Encryption (JWE) [RFC7516] where 1029 different structures are used for the content layer and for the 1030 recipient layer. Two structures are defined: COSE_Encrypt to hold 1031 the encrypted content and COSE_recipient to hold the encrypted keys 1032 for recipients. Examples of encrypted messages can be found in 1033 Appendix C.3. 1035 The COSE_Encrypt structure can be encoded either tagged or untagged 1036 depending on the context it will be used in. A tagged COSE_Encrypt 1037 structure is identified by the CBOR tag TBD2. The CDDL fragment that 1038 represents this is: 1040 COSE_Encrypt_Tagged = #6.992(COSE_Encrypt) ; Replace 992 with TBD2 1042 The COSE_Encrypt structure is a CBOR array. The fields of the array 1043 in order are: 1045 protected as described in Section 3. 1047 unprotected as described in Section 3. ' 1049 ciphertext contains the cipher text encoded as a bstr. If the 1050 cipher text is to be transported independently of the control 1051 information about the encryption process (i.e., detached content) 1052 then the field is encoded as a nil value. 1054 recipients contains an array of recipient information structures. 1055 The type for the recipient information structure is a 1056 COSE_recipient. 1058 The CDDL fragment that corresponds to the above text is: 1060 COSE_Encrypt = [ 1061 Headers, 1062 ciphertext : bstr / nil, 1063 recipients : [+COSE_recipient] 1064 ] 1066 The COSE_recipient structure is a CBOR array. The fields of the 1067 array in order are: 1069 protected as described in Section 3. 1071 unprotected as described in Section 3. 1073 ciphertext contains the encrypted key encoded as a bstr. All 1074 encoded keys are symetric keys, the binary value of the key is the 1075 content. If there is not an encrypted key, then this field is 1076 encoded as a nil value. 1078 recipients contains an array of recipient information structures. 1079 The type for the recipient information structure is a 1080 COSE_recipient. (An example of this can be found in Appendix B.) 1081 If there are no recipient information structures, this element is 1082 absent. 1084 The CDDL fragment that corresponds to the above text for 1085 COSE_recipient is: 1087 COSE_recipient = [ 1088 Headers, 1089 ciphertext : bstr / nil, 1090 ? recipients : [+COSE_recipient] 1091 ] 1093 5.1.1. Content Key Distribution Methods 1095 An encrypted message consists of an encrypted content and an 1096 encrypted CEK for one or more recipients. The CEK is encrypted for 1097 each recipient, using a key specific to that recipient. The details 1098 of this encryption depend on which class the recipient algorithm 1099 falls into. Specific details on each of the classes can be found in 1100 Section 12. A short summary of the five content key distribution 1101 methods is: 1103 direct: The CEK is the same as the identified previously distributed 1104 symmetric key or derived from a previously distributed secret. No 1105 CEK is transported in the message. 1107 symmetric key-encryption keys: The CEK is encrypted using a 1108 previously distributed symmetric KEK. 1110 key agreement: The recipient's public key and a sender's private key 1111 are used to generate a pairwise secret, a KDF is applied to derive 1112 a key, and then the CEK is either the derived key or encrypted by 1113 the derived key. 1115 key transport: The CEK is encrypted with the recipient's public key. 1116 No key transport algorithms are defined in this document. 1118 passwords: The CEK is encrypted in a KEK that is derived from a 1119 password. No password algorithms are defined in this document. 1121 5.2. Single Recipient Encrypted 1123 The COSE_Encrypt0 encrypted structure does not have the ability to 1124 specify recipients of the message. The structure assumes that the 1125 recipient of the object will already know the identity of the key to 1126 be used in order to decrypt the message. If a key needs to be 1127 identified to the recipient, the enveloped structure ought to be 1128 used. 1130 Examples of encrypted messages can be found in Appendix C.3. 1132 The COSE_Encrypt0 structure can be encoded either tagged or untagged 1133 depending on the context it will be used in. A tagged COSE_Encrypt0 1134 structure is identified by the CBOR tag TBD3. The CDDL fragment that 1135 represents this is: 1137 COSE_Encrypt0_Tagged = #6.993(COSE_Encrypt0) ; Replace 993 with TBD3 1139 The COSE_Encrypt0 structure is a CBOR array. The fields of the array 1140 in order are: 1142 protected as described in Section 3. 1144 unprotected as described in Section 3. 1146 ciphertext as described in Section 5.1. 1148 The CDDL fragment for COSE_Encrypt0 that corresponds to the above 1149 text is: 1151 COSE_Encrypt0 = [ 1152 Headers, 1153 ciphertext : bstr / nil, 1154 ] 1156 5.3. How to encrypt and decrypt for AEAD Algorithms 1158 The encryption algorithm for AEAD algorithms is fairly simple. The 1159 first step is to create a consistent byte stream for the 1160 authenticated data structure. For this purpose, we use an 1161 Enc_structure. The Enc_structure is a CBOR array. The fields of the 1162 Enc_structure in order are: 1164 1. A text string identifying the context of the authenticated data 1165 structure. The context string is: 1167 "Encrypt0" for the content encryption of a COSE_Encrypt0 data 1168 structure. 1170 "Encrypt" for the first layer of a COSE_Encrypt data structure 1171 (i.e., for content encryption). 1173 "Enc_Recipient" for a recipient encoding to be placed in an 1174 COSE_Encrypt data structure. 1176 "Mac_Recipient" for a recipient encoding to be placed in a MACed 1177 message structure. 1179 "Rec_Recipient" for a recipient encoding to be placed in a 1180 recipient structure. 1182 2. The protected attributes from the body structure encoded in a 1183 bstr type. If there are no protected attributes, a bstr of 1184 length zero is used. 1186 3. The protected attributes from the application encoded in a bstr 1187 type. If this field is not supplied, it defaults to a zero 1188 length bstr. (See Section 4.3 for application guidance on 1189 constructing this field.) 1191 The CDDL fragment that describes the above text is: 1193 Enc_structure = [ 1194 context : "Encrypt" / "Encrypt0" / "Enc_Recipient" / 1195 "Mac_Recipient" / "Rec_Recipient", 1196 protected : empty_or_serialized_map, 1197 external_aad : bstr 1198 ] 1200 How to encrypt a message: 1202 1. Create an Enc_structure and populate it with the appropriate 1203 fields. 1205 2. Encode the Enc_structure to a byte stream (AAD), using the 1206 encoding described in Section 14. 1208 3. Determine the encryption key (K). This step is dependent on the 1209 class of recipient algorithm being used. For: 1211 No Recipients: The key to be used is determined by the algorithm 1212 and key at the current layer. Examples are key transport keys 1213 Section 12.3, key wrap keys Section 12.2.1 or pre-shared 1214 secrets. 1216 Direct Encryption and Direct Key Agreement: The key is 1217 determined by the key and algorithm in the recipient 1218 structure. The encryption algorithm and size of the key to be 1219 used are inputs into the KDF used for the recipient. (For 1220 direct, the KDF can be thought of as the identity operation.) 1221 Examples of these algorithms are found in Section 12.1.2 and 1222 Section 12.4.1. 1224 Other: The key is randomly or pseudo-randomly generated. 1226 4. Call the encryption algorithm with K (the encryption key), P (the 1227 plain text) and AAD. Place the returned cipher text into the 1228 'ciphertext' field of the structure. 1230 5. For recipients of the message, recursively perform the encryption 1231 algorithm for that recipient, using K (the encryption key) as the 1232 plain text. 1234 How to decrypt a message: 1236 1. Create a Enc_structure and populate it with the appropriate 1237 fields. 1239 2. Encode the Enc_structure to a byte stream (AAD), using the 1240 encoding described in Section 14. 1242 3. Determine the decryption key. This step is dependent on the 1243 class of recipient algorithm being used. For: 1245 No Recipients: The key to be used is determined by the algorithm 1246 and key at the current layer. Examples are key transport keys 1247 Section 12.3, key wrap keys Section 12.2.1 or pre-shared 1248 secrets. 1250 Direct Encryption and Direct Key Agreement: The key is 1251 determined by the key and algorithm in the recipient 1252 structure. The encryption algorithm and size of the key to be 1253 used are inputs into the KDF used for the recipient. (For 1254 direct, the KDF can be thought of as the identity operation.) 1255 Examples of these algorithms are found in Section 12.1.2 and 1256 Section 12.4.1. 1258 Other: The key is determined by decoding and decrypting one of 1259 the recipient structures. 1261 4. Call the decryption algorithm with K (the decryption key to use), 1262 C (the cipher text) and AAD. 1264 5.4. How to encrypt and decrypt for AE Algorithms 1266 How to encrypt a message: 1268 1. Verify that the 'protected' field is empty. 1270 2. Verify that there was no external additional authenticated data 1271 supplied for this operation. 1273 3. Determine the encryption key. This step is dependent on the 1274 class of recipient algorithm being used. For: 1276 No Recipients: The key to be used is determined by the algorithm 1277 and key at the current layer. Examples are key transport keys 1278 Section 12.3, key wrap keys Section 12.2.1 or pre-shared 1279 secrets. 1281 Direct Encryption and Direct Key Agreement: The key is 1282 determined by the key and algorithm in the recipient 1283 structure. The encryption algorithm and size of the key to be 1284 used are inputs into the KDF used for the recipient. (For 1285 direct, the KDF can be thought of as the identity operation.) 1286 Examples of these algorithms are found in Section 12.1.2 and 1287 Section 12.4.1. 1289 Other: The key is randomly generated. 1291 4. Call the encryption algorithm with K (the encryption key to use) 1292 and the P (the plain text). Place the returned cipher text into 1293 the 'ciphertext' field of the structure. 1295 5. For recipients of the message, recursively perform the encryption 1296 algorithm for that recipient, using K (the encryption key) as the 1297 plain text. 1299 How to decrypt a message: 1301 1. Verify that the 'protected' field is empty. 1303 2. Verify that there was no external additional authenticated data 1304 supplied for this operation. 1306 3. Determine the decryption key. This step is dependent on the 1307 class of recipient algorithm being used. For: 1309 No Recipients: The key to be used is determined by the algorithm 1310 and key at the current layer. Examples are key transport keys 1311 Section 12.3, key wrap keys Section 12.2.1 or pre-shared 1312 secrets. 1314 Direct Encryption and Direct Key Agreement: The key is 1315 determined by the key and algorithm in the recipient 1316 structure. The encryption algorithm and size of the key to be 1317 used are inputs into the KDF used for the recipient. (For 1318 direct, the KDF can be thought of as the identity operation.) 1319 Examples of these algorithms are found in Section 12.1.2 and 1320 Section 12.4.1. 1322 Other: The key is determined by decoding and decrypting one of 1323 the recipient structures. 1325 4. Call the decryption algorithm with K (the decryption key to use), 1326 and C (the cipher text). 1328 6. MAC Objects 1330 COSE supports two different MAC structures. COSE_MAC0 is used when a 1331 recipient structure is not needed because the key to be used is 1332 implicitly known. COSE_MAC is used for all other cases. These 1333 include a requirement for multiple recipients, the key being unknown, 1334 and a recipient algorithm of other than direct. 1336 In this section, we describe the structure and methods to be used 1337 when doing MAC authentication in COSE. This document allows for the 1338 use of all of the same classes of recipient algorithms as are allowed 1339 for encryption. 1341 When using MAC operations, there are two modes in which they can be 1342 used. The first is just a check that the content has not been 1343 changed since the MAC was computed. Any class of recipient algorithm 1344 can be used for this purpose. The second mode is to both check that 1345 the content has not been changed since the MAC was computed, and to 1346 use the recipient algorithm to verify who sent it. The classes of 1347 recipient algorithms that support this are those that use a pre- 1348 shared secret or do static-static key agreement (without the key wrap 1349 step). In both of these cases, the entity that created and sent the 1350 message MAC can be validated. (This knowledge of sender assumes that 1351 there are only two parties involved and you did not send the message 1352 to yourself.) The origination property can be obtained with both of 1353 the MAC message structures. 1355 6.1. MACed Message with Recipients 1357 The multiple recipient MACed message uses two structures, the 1358 COSE_Mac structure defined in this section for carrying the body and 1359 the COSE_recipient structure (Section 5.1) to hold the key used for 1360 the MAC computation. Examples of MACed messages can be found in 1361 Appendix C.5. 1363 The MAC structure can be encoded either tagged or untagged depending 1364 on the context it will be used in. A tagged COSE_Mac structure is 1365 identified by the CBOR tag TBD4. The CDDL fragment that represents 1366 this is: 1368 COSE_Mac_Tagged = #6.994(COSE_Mac) ; Replace 994 with TBD4 1370 The COSE_Mac structure is a CBOR array. The fields of the array in 1371 order are: 1373 protected as described in Section 3. 1375 unprotected as described in Section 3. 1377 payload contains the serialized content to be MACed. If the payload 1378 is not present in the message, the application is required to 1379 supply the payload separately. The payload is wrapped in a bstr 1380 to ensure that it is transported without changes. If the payload 1381 is transported separately (i.e., detached content), then a nil 1382 CBOR value is placed in this location and it is the responsibility 1383 of the application to ensure that it will be transported without 1384 changes. 1386 tag contains the MAC value. 1388 recipients as described in Section 5.1. 1390 The CDDL fragment that represents the above text for COSE_Mac 1391 follows. 1393 COSE_Mac = [ 1394 Headers, 1395 payload : bstr / nil, 1396 tag : bstr, 1397 recipients :[+COSE_recipient] 1398 ] 1400 6.2. MACed Messages with Implicit Key 1402 In this section, we describe the structure and methods to be used 1403 when doing MAC authentication for those cases where the recipient is 1404 implicitly known. 1406 The MACed message uses the COSE_Mac0 structure defined in this 1407 section for carrying the body. Examples of MACed messages with an 1408 implicit key can be found in Appendix C.6. 1410 The MAC structure can be encoded either tagged or untagged depending 1411 on the context it will be used in. A tagged COSE_Mac0 structure is 1412 identified by the CBOR tag TBD6. The CDDL fragment that represents 1413 this is: 1415 COSE_Mac0_Tagged = #6.996(COSE_Mac0) ; Replace 996 with TBD6 1417 The COSE_Mac0 structure is a CBOR array. The fields of the array in 1418 order are: 1420 protected as described in Section 3. 1422 unprotected as described in Section 3. 1424 payload as described in Section 6.1. 1426 tag contains the MAC value. 1428 The CDDL fragment that corresponds to the above text is: 1430 COSE_Mac0 = [ 1431 Headers, 1432 payload : bstr / nil, 1433 tag : bstr, 1434 ] 1436 6.3. How to compute and verify a MAC 1438 In order to get a consistent encoding of the data to be 1439 authenticated, the MAC_structure is used to have a canonical form. 1440 The MAC_structure is a CBOR array. The fields of the MAC_structure 1441 in order are: 1443 1. A text string that identifies the structure that is being 1444 encoded. This string is "MAC" for the COSE_Mac structure. This 1445 string is "MAC0" for the COSE_Mac0 structure. 1447 2. The protected attributes from the COSE_MAC structure. If there 1448 are no protected attributes, a zero length bstr is used. 1450 3. The protected attributes from the application encoded as a bstr 1451 type. If this field is not supplied, it defaults to a zero 1452 length binary string. (See Section 4.3 for application guidance 1453 on constructing this field.) 1455 4. The payload to be MAC-ed encoded in a bstr type. The payload is 1456 placed here independent of how it is transported. 1458 The CDDL fragment that corresponds to the above text is: 1460 MAC_structure = [ 1461 context : "MAC" / "MAC0", 1462 protected : empty_or_serialized_map, 1463 external_aad : bstr, 1464 payload : bstr 1465 ] 1467 The steps to compute a MAC are: 1469 1. Create a MAC_structure and populate it with the appropriate 1470 fields. 1472 2. Create the value ToBeMaced by encoding the MAC_structure to a 1473 byte stream, using the encoding described in Section 14. 1475 3. Call the MAC creation algorithm passing in K (the key to use), 1476 alg (the algorithm to MAC with) and ToBeMaced (the value to 1477 compute the MAC on). 1479 4. Place the resulting MAC in the 'tag' field of the COSE_Mac or 1480 COSE_Mac0 structure. 1482 5. Encrypt and encode the MAC key for each recipient of the message. 1484 The steps to verify a MAC are: 1486 1. Create a MAC_structure object and populate it with the 1487 appropriate fields. 1489 2. Create the value ToBeMaced by encoding the MAC_structure to a 1490 byte stream, using the encoding described in Section 14. 1492 3. Obtain the cryptographic key from one of the recipients of the 1493 message. 1495 4. Call the MAC creation algorithm passing in K (the key to use), 1496 alg (the algorithm to MAC with) and ToBeMaced (the value to 1497 compute the MAC on). 1499 5. Compare the MAC value to the 'tag' field of the COSE_Mac or 1500 COSE_Mac0 structure. 1502 7. Key Objects 1504 A COSE Key structure is built on a CBOR map object. The set of 1505 common parameters that can appear in a COSE Key can be found in the 1506 IANA "COSE Key Common Parameters" registry (Section 16.5). 1507 Additional parameters defined for specific key types can be found in 1508 the IANA "COSE Key Type Parameters" registry (Section 16.6). 1510 A COSE Key Set uses a CBOR array object as its underlying type. The 1511 values of the array elements are COSE Keys. A Key Set MUST have at 1512 least one element in the array. Examples of Key Sets can be found in 1513 Appendix C.7. 1515 Each element in a key set MUST be processed independently. If one 1516 element in a key set is either malformed or uses a key that is not 1517 understood by an application, that key is ignored and the other keys 1518 are processed normally. 1520 The element "kty" is a required element in a COSE_Key map. 1522 The CDDL grammar describing COSE_Key and COSE_KeySet is: 1524 COSE_Key = { 1525 1 => tstr / int, ; kty 1526 ? 2 => bstr, ; kid 1527 ? 3 => tstr / int, ; alg 1528 ? 4 => [+ (tstr / int) ], ; key_ops 1529 ? 5 => bstr, ; Base IV 1530 * label => values 1531 } 1533 COSE_KeySet = [+COSE_Key] 1535 7.1. COSE Key Common Parameters 1537 This document defines a set of common parameters for a COSE Key 1538 object. Table 3 provides a summary of the parameters defined in this 1539 section. There are also parameters that are defined for specific key 1540 types. Key type specific parameters can be found in Section 13. 1542 +---------+-------+----------------+------------+-------------------+ 1543 | name | label | CBOR type | registry | description | 1544 +---------+-------+----------------+------------+-------------------+ 1545 | kty | 1 | tstr / int | COSE Key | Identification of | 1546 | | | | Common | the key type | 1547 | | | | Parameters | | 1548 | | | | | | 1549 | alg | 3 | tstr / int | COSE | Key usage | 1550 | | | | Algorithm | restriction to | 1551 | | | | Values | this algorithm | 1552 | | | | | | 1553 | kid | 2 | bstr | | Key | 1554 | | | | | Identification | 1555 | | | | | value - match to | 1556 | | | | | kid in message | 1557 | | | | | | 1558 | key_ops | 4 | [+ (tstr/int)] | | Restrict set of | 1559 | | | | | permissible | 1560 | | | | | operations | 1561 | | | | | | 1562 | Base IV | 5 | bstr | | Base IV to be | 1563 | | | | | xor-ed with | 1564 | | | | | Partial IVs | 1565 +---------+-------+----------------+------------+-------------------+ 1567 Table 3: Key Map Labels 1569 kty: This parameter is used to identify the family of keys for this 1570 structure, and thus the set of key type specific parameters to be 1571 found. The set of values defined in this document can be found in 1572 Table 21. This parameter MUST be present in a key object. 1573 Implementations MUST verify that the key type is appropriate for 1574 the algorithm being processed. The key type MUST be included as 1575 part of the trust decision process. 1577 alg: This parameter is used to restrict the algorithm that is used 1578 with the key. If this parameter is present in the key structure, 1579 the application MUST verify that this algorithm matches the 1580 algorithm for which the key is being used. If the algorithms do 1581 not match, then this key object MUST NOT be used to perform the 1582 cryptographic operation. Note that the same key can be in a 1583 different key structure with a different or no algorithm 1584 specified, however this is considered to be a poor security 1585 practice. 1587 kid: This parameter is used to give an identifier for a key. The 1588 identifier is not structured and can be anything from a user 1589 provided string to a value computed on the public portion of the 1590 key. This field is intended for matching against a 'kid' 1591 parameter in a message in order to filter down the set of keys 1592 that need to be checked. 1594 key_ops: This parameter is defined to restrict the set of operations 1595 that a key is to be used for. The value of the field is an array 1596 of values from Table 4. Algorithms define the values of key ops 1597 that are permitted to appear and are required for specific 1598 operations. The set of values matches that in [RFC7517] and 1599 [W3C.WebCrypto]. 1601 Base IV: This parameter is defined to carry the base portion of an 1602 IV. It is designed to be used with the partial IV header 1603 parameter defined in Section 3.1. This field provides the ability 1604 to associate a partial IV with a key that is then modified on a 1605 per message basis with the partial IV. 1607 Extreme care needs to be taken when using a Base IV in an 1608 application. Many encryption algorithms lose security if the same 1609 IV is used twice. 1611 If different keys are derived for each sender, using the same base 1612 IV with partial IVs starting at zero is likely to ensure that the 1613 IV would not be used twice for a single key. If different keys 1614 are derived for each sender, starting at the same base IV is 1615 likely to satisfy this condition. If the same key is used for 1616 multiple senders, then the application needs to provide for a 1617 method of dividing the IV space up between the senders. This 1618 could be done by providing a different base point to start from or 1619 a different partial IV to start with and restricting the number of 1620 messages to be sent before re-keying. 1622 +---------+-------+-------------------------------------------------+ 1623 | name | value | description | 1624 +---------+-------+-------------------------------------------------+ 1625 | sign | 1 | The key is used to create signatures. Requires | 1626 | | | private key fields. | 1627 | | | | 1628 | verify | 2 | The key is used for verification of signatures. | 1629 | | | | 1630 | encrypt | 3 | The key is used for key transport encryption. | 1631 | | | | 1632 | decrypt | 4 | The key is used for key transport decryption. | 1633 | | | Requires private key fields. | 1634 | | | | 1635 | wrap | 5 | The key is used for key wrapping. | 1636 | key | | | 1637 | | | | 1638 | unwrap | 6 | The key is used for key unwrapping. Requires | 1639 | key | | private key fields. | 1640 | | | | 1641 | derive | 7 | The key is used for deriving keys. Requires | 1642 | key | | private key fields. | 1643 | | | | 1644 | derive | 8 | The key is used for deriving bits not to be | 1645 | bits | | used as a key. Requires private key fields. | 1646 | | | | 1647 | MAC | 9 | The key is used for creating MACs. | 1648 | create | | | 1649 | | | | 1650 | MAC | 10 | The key is used for validating MACs. | 1651 | verify | | | 1652 +---------+-------+-------------------------------------------------+ 1654 Table 4: Key Operation Values 1656 8. Signature Algorithms 1658 There are two signature algorithm schemes. The first is signature 1659 with appendix. In this scheme, the message content is processed and 1660 a signature is produced, the signature is called the appendix. This 1661 is the scheme used by algorithms such as ECDSA and RSASSA-PSS. (In 1662 fact the SSA in RSASSA-PSS stands for Signature Scheme with 1663 Appendix.) 1665 The signature functions for this scheme are: 1667 signature = Sign(message content, key) 1669 valid = Verification(message content, key, signature) 1670 The second scheme is signature with message recovery. (An example of 1671 such an algorithm is [PVSig].) In this scheme, the message content 1672 is processed, but part of it is included in the signature. Moving 1673 bytes of the message content into the signature allows for smaller 1674 signatures, the signature size is still potentially large, but the 1675 message content has shrunk. This has implications for systems 1676 implementing these algorithms and for applications that use them. 1677 The first is that the message content is not fully available until 1678 after a signature has been validated. Until that point the part of 1679 the message contained inside of the signature is unrecoverable. The 1680 second is that the security analysis of the strength of the signature 1681 is very much based on the structure of the message content. Messages 1682 that are highly predictable require additional randomness to be 1683 supplied as part of the signature process. In the worst case, it 1684 becomes the same as doing a signature with appendix. Finally, in the 1685 event that multiple signatures are applied to a message, all of the 1686 signature algorithms are going to be required to consume the same 1687 number of bytes of message content. This means that mixing of the 1688 different schemes in a single message is not supported, and if a 1689 recovery signature scheme is used, then the same amount of content 1690 needs to be consumed by all of the signatures. 1692 The signature functions for this scheme are: 1694 signature, message sent = Sign(message content, key) 1696 valid, message content = Verification(message sent, key, signature) 1698 Signature algorithms are used with the COSE_Signature and COSE_Sign1 1699 structures. At this time, only signatures with appendixes are 1700 defined for use with COSE, however considerable interest has been 1701 expressed in using a signature with message recovery algorithm due to 1702 the effective size reduction that is possible. Implementations will 1703 need to keep this in mind for later possible integration. 1705 8.1. ECDSA 1707 ECDSA [DSS] defines a signature algorithm using ECC. Implementations 1708 SHOULD use a deterministic version of ECDSA such as the one defined 1709 in [RFC6979]. The use of a deterministic signature algorithms allows 1710 for systems to avoid relying on random number generators in order to 1711 avoid generating the same value of 'k' (the per-message random 1712 value). Biased generation of the value be attacked and collisions 1713 will lead to leaked keys. It additionally allows for doing 1714 deterministic tests for the signature algorithm. The use of 1715 deterministic ECDSA does not lessen the need to to have good random 1716 number generation when creating the private key. 1718 The ECDSA signature algorithm is parameterized with a hash function 1719 (h). In the event that the length of the hash function output is 1720 greater than the group of the key, the left-most bytes of the hash 1721 output are used. 1723 The algorithms defined in this document can be found in Table 5. 1725 +-------+-------+---------+------------------+ 1726 | name | value | hash | description | 1727 +-------+-------+---------+------------------+ 1728 | ES256 | -7 | SHA-256 | ECDSA w/ SHA-256 | 1729 | | | | | 1730 | ES384 | -35 | SHA-384 | ECDSA w/ SHA-384 | 1731 | | | | | 1732 | ES512 | -36 | SHA-512 | ECDSA w/ SHA-512 | 1733 +-------+-------+---------+------------------+ 1735 Table 5: ECDSA Algorithm Values 1737 This document defines ECDSA to work only with the curves P-256, P-384 1738 and P-521. This document requires that the curves be encoded using 1739 the 'EC2' (2 coordinate Elliptic Curve) key type. Implementations 1740 need to check that the key type and curve are correct when creating 1741 and verifying a signature. Other documents can define it to work 1742 with other curves and points in the future. 1744 In order to promote interoperability, it is suggested that SHA-256 be 1745 used only with curve P-256, SHA-384 be used only with curve P-384 and 1746 SHA-512 be used with curve P-521. This is aligned with the 1747 recommendation in Section 4 of [RFC5480]. 1749 The signature algorithm results in a pair of integers (R, S). These 1750 integers will the same length as length of the key used for the 1751 signature process. The signature is encoded by converting the 1752 integers into byte strings of the same length as the key size. The 1753 length is rounded up to the nearest byte and is left padded with zero 1754 bits to get to the correct length. The two integers are then 1755 concatenated together to form a byte string that is the resulting 1756 signature. 1758 Using the function defined in [I-D.moriarty-pkcs1] the signature is: 1759 Signature = I2OSP(R, n) | I2OSP(S, n) 1760 where n = ceiling(key_length / 8) 1762 When using a COSE key for this algorithm, the following checks are 1763 made: 1765 o The 'kty' field MUST be present and it MUST be 'EC2'. 1767 o If the 'alg' field is present, it MUST match the ECDSA signature 1768 algorithm being used. 1770 o If the 'key_ops' field is present, it MUST include 'sign' when 1771 creating an ECDSA signature. 1773 o If the 'key_ops' field is present, it MUST include 'verify' when 1774 verifying an ECDSA signature. 1776 8.1.1. Security Considerations 1778 The security strength of the signature is no greater than the minimum 1779 of the security strength associated with the bit length of the key 1780 and the security strength of the hash function. 1782 Note: Use of this technique is a good idea even when good random 1783 number generation exists. Doing so both reduces the possibility of 1784 having the same value of 'k' in two signature operations and allows 1785 for reproducible signature values, which helps testing. 1787 There are two substitution attacks that can theoretically be mounted 1788 against the ECDSA signature algorithm. 1790 o Changing the curve used to validate the signature: If one changes 1791 the curve used to validate the signature, then potentially one 1792 could have a two messages with the same signature each computed 1793 under a different curve. The only requirement on the new curve is 1794 that its order be the same as the old one and it be acceptable to 1795 the client. An example would be to change from using the curve 1796 secp256r1 (aka P-256) to using secp256k1. (Both are 256 bit 1797 curves.) We current do not have any way to deal with this version 1798 of the attack except to restrict the overall set of curves that 1799 can be used. 1801 o Change the hash function used to validate the signature: If one 1802 has either two different hash functions of the same length, or one 1803 can truncate a hash function down, then one could potentially find 1804 collisions between the hash functions rather than within a single 1805 hash function. (For example, truncating SHA-512 to 256 bits might 1806 collide with a SHA-256 bit hash value.) As the hash algorithm is 1807 part of the signature algorithm identifier, this attack is 1808 mitigated by including signature algorithm identifier in the 1809 protected header. 1811 8.2. Edwards-curve Digital Signature Algorithms (EdDSA) 1813 [I-D.irtf-cfrg-eddsa] describes the elliptic curve signature scheme 1814 Edwards-curve Digital Signature Algorithm (EdDSA). In that document, 1815 the signature algorithm is instantiated using parameters for 1816 edwards25519 and edwards448 curves. The document additionally 1817 describes two variants of the EdDSA algorithm: Pure EdDSA, where no 1818 hash function is applied to the content before signing and, HashEdDSA 1819 where a hash function is applied to the content before signing and 1820 the result of that hash function is signed. For the EdDSA, the 1821 content to be signed (either the message or the pre-hash value) is 1822 processed twice inside of the signature algorithm. For use with 1823 COSE, only the pure EdDSA version is used. This is because it is not 1824 expected that extremely large contents are going to be needed and, 1825 based on the arrangement of the message structure, the entire message 1826 is going to need to be held in memory in order to create or verify a 1827 signature. This means that there does not appear to be a need to be 1828 able to do block updates of the hash, followed by eliminating the 1829 message from memory. Applications can provide the same features by 1830 defining the content of the message as a hash value and transporting 1831 the COSE object (with the hash value) and the content as separate 1832 items. 1834 The algorithms defined in this document can be found in Table 6. A 1835 single signature algorithm is defined, which can be used for multiple 1836 curves. 1838 +-------+-------+-------------+ 1839 | name | value | description | 1840 +-------+-------+-------------+ 1841 | EdDSA | -8 | EdDSA | 1842 +-------+-------+-------------+ 1844 Table 6: EdDSA Algorithm Values 1846 [I-D.irtf-cfrg-eddsa] describes the method of encoding the signature 1847 value. 1849 When using a COSE key for this algorithm the following checks are 1850 made: 1852 o The 'kty' field MUST be present and it MUST be 'OKP' (Octet Key 1853 Pair). 1855 o The 'crv' field MUST be present, and it MUST be a curve defined 1856 for this signature algorithm. 1858 o If the 'alg' field is present, it MUST match 'EdDSA'. 1860 o If the 'key_ops' field is present, it MUST include 'sign' when 1861 creating an EdDSA signature. 1863 o If the 'key_ops' field is present, it MUST include 'verify' when 1864 verifying an EdDSA signature. 1866 8.2.1. Security Considerations 1868 How public values are computed is not the same when looking at EdDSA 1869 and ECDH, for this reason they should not be used with the other 1870 algorithm. 1872 If batch signature verification is performed, a well-seeded 1873 cryptographic random number generator is REQUIRED. Signing and non- 1874 batch signature verification are deterministic operations and do not 1875 need random numbers of any kind. 1877 9. Message Authentication (MAC) Algorithms 1879 Message Authentication Codes (MACs) provide data authentication and 1880 integrity protection. They provide either no or very limited data 1881 origination. A MAC, for example, be used to prove the identity of 1882 the sender to a third party. 1884 MACs use the same scheme as signature with appendix algorithms. The 1885 message content is processed and an authentication code is produced. 1886 The authentication code is frequently called a tag. 1888 The MAC functions are: 1890 tag = MAC_Create(message content, key) 1892 valid = MAC_Verify(message content, key, tag) 1894 MAC algorithms can be based on either a block cipher algorithm (i.e., 1895 AES-MAC) or a hash algorithm (i.e., HMAC). This document defines a 1896 MAC algorithm using each of these constructions. 1898 MAC algorithms are used in the COSE_Mac and COSE_Mac0 structures. 1900 9.1. Hash-based Message Authentication Codes (HMAC) 1902 The Hash-based Message Authentication Code algorithm (HMAC) 1903 [RFC2104][RFC4231] was designed to deal with length extension 1904 attacks. The algorithm was also designed to allow for new hash 1905 algorithms to be directly plugged in without changes to the hash 1906 function. The HMAC design process has been shown as solid since, 1907 while the security of hash algorithms such as MD5 has decreased over 1908 time, the security of HMAC combined with MD5 has not yet been shown 1909 to be compromised [RFC6151]. 1911 The HMAC algorithm is parameterized by an inner and outer padding, a 1912 hash function (h), and an authentication tag value length. For this 1913 specification, the inner and outer padding are fixed to the values 1914 set in [RFC2104]. The length of the authentication tag corresponds 1915 to the difficulty of producing a forgery. For use in constrained 1916 environments, we define a set of HMAC algorithms that are truncated. 1917 There are currently no known issues with truncation, however the 1918 security strength of the message tag is correspondingly reduced in 1919 strength. When truncating, the left-most tag length bits are kept 1920 and transmitted. 1922 The algorithms defined in this document can be found in Table 7. 1924 +-----------+-------+---------+----------+--------------------------+ 1925 | name | value | Hash | Tag | description | 1926 | | | | Length | | 1927 +-----------+-------+---------+----------+--------------------------+ 1928 | HMAC | 4 | SHA-256 | 64 | HMAC w/ SHA-256 | 1929 | 256/64 | | | | truncated to 64 bits | 1930 | | | | | | 1931 | HMAC | 5 | SHA-256 | 256 | HMAC w/ SHA-256 | 1932 | 256/256 | | | | | 1933 | | | | | | 1934 | HMAC | 6 | SHA-384 | 384 | HMAC w/ SHA-384 | 1935 | 384/384 | | | | | 1936 | | | | | | 1937 | HMAC | 7 | SHA-512 | 512 | HMAC w/ SHA-512 | 1938 | 512/512 | | | | | 1939 +-----------+-------+---------+----------+--------------------------+ 1941 Table 7: HMAC Algorithm Values 1943 Some recipient algorithms carry the key while others derive a key 1944 from secret data. For those algorithms that carry the key (such as 1945 AES-KeyWrap), the size of the HMAC key SHOULD be the same size as the 1946 underlying hash function. For those algorithms that derive the key 1947 (such as ECDH), the derived key MUST be the same size as the 1948 underlying hash function. 1950 When using a COSE key for this algorithm, the following checks are 1951 made: 1953 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 1955 o If the 'alg' field is present, it MUST match the HMAC algorithm 1956 being used. 1958 o If the 'key_ops' field is present, it MUST include 'MAC create' 1959 when creating an HMAC authentication tag. 1961 o If the 'key_ops' field is present, it MUST include 'MAC verify' 1962 when verifying an HMAC authentication tag. 1964 Implementations creating and validating MAC values MUST validate that 1965 the key type, key length, and algorithm are correct and appropriate 1966 for the entities involved. 1968 9.1.1. Security Considerations 1970 HMAC has proved to be resistant to attack even when used with 1971 weakened hash algorithms. The current best known attack appears is 1972 to brute force the key. This means that key size is going to be 1973 directly related to the security of an HMAC operation. 1975 9.2. AES Message Authentication Code (AES-CBC-MAC) 1977 AES-CBC-MAC is defined in [MAC]. (Note this is not the same 1978 algorithm as AES-CMAC [RFC4493]). 1980 AES-CBC-MAC is parameterized by the key length, the authentication 1981 tag length and the IV used. For all of these algorithms, the IV is 1982 fixed to all zeros. We provide an array of algorithms for various 1983 key lengths and tag lengths. The algorithms defined in this document 1984 are found in Table 8. 1986 +-------------+-------+----------+----------+-----------------------+ 1987 | name | value | key | tag | description | 1988 | | | length | length | | 1989 +-------------+-------+----------+----------+-----------------------+ 1990 | AES-MAC | 14 | 128 | 64 | AES-MAC 128 bit key, | 1991 | 128/64 | | | | 64-bit tag | 1992 | | | | | | 1993 | AES-MAC | 15 | 256 | 64 | AES-MAC 256 bit key, | 1994 | 256/64 | | | | 64-bit tag | 1995 | | | | | | 1996 | AES-MAC | 25 | 128 | 128 | AES-MAC 128 bit key, | 1997 | 128/128 | | | | 128-bit tag | 1998 | | | | | | 1999 | AES-MAC | 26 | 256 | 128 | AES-MAC 256 bit key, | 2000 | 256/128 | | | | 128-bit tag | 2001 +-------------+-------+----------+----------+-----------------------+ 2003 Table 8: AES-MAC Algorithm Values 2005 Keys may be obtained either from a key structure or from a recipient 2006 structure. Implementations creating and validating MAC values MUST 2007 validate that the key type, key length and algorithm are correct and 2008 appropriate for the entities involved. 2010 When using a COSE key for this algorithm, the following checks are 2011 made: 2013 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2015 o If the 'alg' field is present, it MUST match the AES-MAC algorithm 2016 being used. 2018 o If the 'key_ops' field is present, it MUST include 'MAC create' 2019 when creating an AES-MAC authentication tag. 2021 o If the 'key_ops' field is present, it MUST include 'MAC verify' 2022 when verifying an AES-MAC authentication tag. 2024 9.2.1. Security Considerations 2026 A number of attacks exist against CBC-MAC that need to be considered. 2027 - 2029 o A single key must only be used for messages of a fixed and known 2030 length. If this is not the case, an attacker will be able to 2031 generate a message with a valid tag given two message and tag 2032 pairs. This can be addressed by using different keys for 2033 different length messages. The current structure mitigates this 2034 problem, as a specific encoding structure that includes lengths is 2035 built and signed. (CMAC also addresses this issue.) 2037 o When using CBC mode, if the same key is used for both encryption 2038 and authentication operations, an attacker can produce messages 2039 with a valid authentication code. 2041 o If the IV can be modified, then messages can be forged. This is 2042 addressed by fixing the IV to all zeros. 2044 10. Content Encryption Algorithms 2046 Content Encryption Algorithms provide data confidentiality for 2047 potentially large blocks of data using a symmetric key. They provide 2048 integrity on the data that was encrypted, however they provide either 2049 no or very limited data origination. (One cannot, for example, be 2050 used to prove the identity of the sender to a third party.) The 2051 ability to provide data origination is linked to how the CEK is 2052 obtained. 2054 COSE restricts the set of legal content encryption algorithms to 2055 those that support authentication both of the content and additional 2056 data. The encryption process will generate some type of 2057 authentication value, but that value may be either explicit or 2058 implicit in terms of the algorithm definition. For simplicity sake, 2059 the authentication code will normally be defined as being appended to 2060 the cipher text stream. The encryption functions are: 2062 ciphertext = Encrypt(message content, key, additional data) 2064 valid, message content = Decrypt(cipher text, key, additional data) 2066 Most AEAD algorithms are logically defined as returning the message 2067 content only if the decryption is valid. Many but not all 2068 implementations will follow this convention. The message content 2069 MUST NOT be used if the decryption does not validate. 2071 These algorithms are used in COSE_Encrypt and COSE_Encrypt0. 2073 10.1. AES GCM 2075 The GCM mode is a generic authenticated encryption block cipher mode 2076 defined in [AES-GCM]. The GCM mode is combined with the AES block 2077 encryption algorithm to define an AEAD cipher. 2079 The GCM mode is parameterized by the size of the authentication tag 2080 and the size of the nonce. This document fixes the size of the nonce 2081 at 96 bits. The size of the authentication tag is limited to a small 2082 set of values. For this document however, the size of the 2083 authentication tag is fixed at 128 bits. 2085 The set of algorithms defined in this document are in Table 9. 2087 +---------+-------+------------------------------------------+ 2088 | name | value | description | 2089 +---------+-------+------------------------------------------+ 2090 | A128GCM | 1 | AES-GCM mode w/ 128-bit key, 128-bit tag | 2091 | | | | 2092 | A192GCM | 2 | AES-GCM mode w/ 192-bit key, 128-bit tag | 2093 | | | | 2094 | A256GCM | 3 | AES-GCM mode w/ 256-bit key, 128-bit tag | 2095 +---------+-------+------------------------------------------+ 2097 Table 9: Algorithm Value for AES-GCM 2099 Keys may be obtained either from a key structure or from a recipient 2100 structure. Implementations encrypting and decrypting MUST validate 2101 that the key type, key length and algorithm are correct and 2102 appropriate for the entities involved. 2104 When using a COSE key for this algorithm, the following checks are 2105 made: 2107 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2109 o If the 'alg' field is present, it MUST match the AES-GCM algorithm 2110 being used. 2112 o If the 'key_ops' field is present, it MUST include 'encrypt' or 2113 'wrap key' when encrypting. 2115 o If the 'key_ops' field is present, it MUST include 'decrypt' or 2116 'unwrap key' when decrypting. 2118 10.1.1. Security Considerations 2120 When using AES-GCM, the following restrictions MUST be enforced: 2122 o The key and nonce pair MUST be unique for every message encrypted. 2124 o The total amount of data encrypted for a single key MUST NOT 2125 exceed 2^39 - 256 bits. An explicit check is required only in 2126 environments where it is expected that it might be exceeded. 2128 Consideration was given to supporting smaller tag values; the 2129 constrained community would desire tag sizes in the 64-bit range. 2131 Doing so drastically changes both the maximum messages size 2132 (generally not an issue) and the number of times that a key can be 2133 used. Given that CCM is the usual mode for constrained environments, 2134 restricted modes are not supported. 2136 10.2. AES CCM 2138 Counter with CBC-MAC (CCM) is a generic authentication encryption 2139 block cipher mode defined in [RFC3610]. The CCM mode is combined 2140 with the AES block encryption algorithm to define a commonly used 2141 content encryption algorithm used in constrained devices. 2143 The CCM mode has two parameter choices. The first choice is M, the 2144 size of the authentication field. The choice of the value for M 2145 involves a trade-off between message growth (from the tag) and the 2146 probably that an attacker can undetectably modify a message. The 2147 second choice is L, the size of the length field. This value 2148 requires a trade-off between the maximum message size and the size of 2149 the Nonce. 2151 It is unfortunate that the specification for CCM specified L and M as 2152 a count of bytes rather than a count of bits. This leads to possible 2153 misunderstandings where AES-CCM-8 is frequently used to refer to a 2154 version of CCM mode where the size of the authentication is 64 bits 2155 and not 8 bits. These values have traditionally been specified as 2156 bit counts rather than byte counts. This document will follow the 2157 convention of using bit counts so that it is easier to compare the 2158 different algorithms presented in this document. 2160 We define a matrix of algorithms in this document over the values of 2161 L and M. Constrained devices are usually operating in situations 2162 where they use short messages and want to avoid doing recipient 2163 specific cryptographic operations. This favors smaller values of 2164 both L and M. Less constrained devices will want to be able to use 2165 larger messages and are more willing to generate new keys for every 2166 operation. This favors larger values of L and M. 2168 The following values are used for L: 2170 16 bits (2) limits messages to 2^16 bytes (64 KiB) in length. This 2171 is sufficiently long for messages in the constrained world. The 2172 nonce length is 13 bytes allowing for 2^(13*8) possible values of 2173 the nonce without repeating. 2175 64 bits (8) limits messages to 2^64 bytes in length. The nonce 2176 length is 7 bytes allowing for 2^56 possible values of the nonce 2177 without repeating. 2179 The following values are used for M: 2181 64 bits (8) produces a 64-bit authentication tag. This implies that 2182 there is a 1 in 2^64 chance that a modified message will 2183 authenticate. 2185 128 bits (16) produces a 128-bit authentication tag. This implies 2186 that there is a 1 in 2^128 chance that a modified message will 2187 authenticate. 2189 +--------------------+-------+----+-----+-----+---------------------+ 2190 | name | value | L | M | k | description | 2191 +--------------------+-------+----+-----+-----+---------------------+ 2192 | AES-CCM-16-64-128 | 10 | 16 | 64 | 128 | AES-CCM mode | 2193 | | | | | | 128-bit key, 64-bit | 2194 | | | | | | tag, 13-byte nonce | 2195 | | | | | | | 2196 | AES-CCM-16-64-256 | 11 | 16 | 64 | 256 | AES-CCM mode | 2197 | | | | | | 256-bit key, 64-bit | 2198 | | | | | | tag, 13-byte nonce | 2199 | | | | | | | 2200 | AES-CCM-64-64-128 | 12 | 64 | 64 | 128 | AES-CCM mode | 2201 | | | | | | 128-bit key, 64-bit | 2202 | | | | | | tag, 7-byte nonce | 2203 | | | | | | | 2204 | AES-CCM-64-64-256 | 13 | 64 | 64 | 256 | AES-CCM mode | 2205 | | | | | | 256-bit key, 64-bit | 2206 | | | | | | tag, 7-byte nonce | 2207 | | | | | | | 2208 | AES-CCM-16-128-128 | 30 | 16 | 128 | 128 | AES-CCM mode | 2209 | | | | | | 128-bit key, | 2210 | | | | | | 128-bit tag, | 2211 | | | | | | 13-byte nonce | 2212 | | | | | | | 2213 | AES-CCM-16-128-256 | 31 | 16 | 128 | 256 | AES-CCM mode | 2214 | | | | | | 256-bit key, | 2215 | | | | | | 128-bit tag, | 2216 | | | | | | 13-byte nonce | 2217 | | | | | | | 2218 | AES-CCM-64-128-128 | 32 | 64 | 128 | 128 | AES-CCM mode | 2219 | | | | | | 128-bit key, | 2220 | | | | | | 128-bit tag, 7-byte | 2221 | | | | | | nonce | 2222 | | | | | | | 2223 | AES-CCM-64-128-256 | 33 | 64 | 128 | 256 | AES-CCM mode | 2224 | | | | | | 256-bit key, | 2225 | | | | | | 128-bit tag, 7-byte | 2226 | | | | | | nonce | 2227 +--------------------+-------+----+-----+-----+---------------------+ 2229 Table 10: Algorithm Values for AES-CCM 2231 Keys may be obtained either from a key structure or from a recipient 2232 structure. Implementations encrypting and decrypting MUST validate 2233 that the key type, key length and algorithm are correct and 2234 appropriate for the entities involved. 2236 When using a COSE key for this algorithm, the following checks are 2237 made: 2239 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2241 o If the 'alg' field is present, it MUST match the AES-CCM algorithm 2242 being used. 2244 o If the 'key_ops' field is present, it MUST include 'encrypt' or 2245 'wrap key' when encrypting. 2247 o If the 'key_ops' field is present, it MUST include 'decrypt' or 2248 'unwrap key' when decrypting. 2250 10.2.1. Security Considerations 2252 When using AES-CCM, the following restrictions MUST be enforced: 2254 o The key and nonce pair MUST be unique for every message encrypted. 2255 Note that the value of L influences the number of unique nonces. 2257 o The total number of times the AES block cipher is used MUST NOT 2258 exceed 2^61 operations. This limitation is the sum of times the 2259 block cipher is used in computing the MAC value and in performing 2260 stream encryption operations. An explicit check is required only 2261 in environments where it is expected that it might be exceeded. 2263 [RFC3610] additionally calls out one other consideration of note. It 2264 is possible to do a pre-computation attack against the algorithm in 2265 cases where portions of the plaintext are highly predictable. This 2266 reduces the security of the key size by half. Ways to deal with this 2267 attack include adding a random portion to the nonce value and/or 2268 increasing the key size used. Using a portion of the nonce for a 2269 random value will decrease the number of messages that a single key 2270 can be used for. Increasing the key size may require more resources 2271 in the constrained device. See sections 5 and 10 of [RFC3610] for 2272 more information. 2274 10.3. ChaCha20 and Poly1305 2276 ChaCha20 and Poly1305 combined together is an AEAD mode that is 2277 defined in [RFC7539]. This is an algorithm defined to be a cipher 2278 that is not AES and thus would not suffer from any future weaknesses 2279 found in AES. These cryptographic functions are designed to be fast 2280 in software-only implementations. 2282 The ChaCha20/Poly1305 AEAD construction defined in [RFC7539] has no 2283 parameterization. It takes a 256-bit key and a 96-bit nonce, as well 2284 as the plain text and additional data as inputs and produces the 2285 cipher text as an option. We define one algorithm identifier for 2286 this algorithm in Table 11. 2288 +-------------------+-------+---------------------------------------+ 2289 | name | value | description | 2290 +-------------------+-------+---------------------------------------+ 2291 | ChaCha20/Poly1305 | 24 | ChaCha20/Poly1305 w/ 256-bit key, | 2292 | | | 128-bit tag | 2293 +-------------------+-------+---------------------------------------+ 2295 Table 11: Algorithm Value for AES-GCM 2297 Keys may be obtained either from a key structure or from a recipient 2298 structure. Implementations encrypting and decrypting MUST validate 2299 that the key type, key length and algorithm are correct and 2300 appropriate for the entities involved. 2302 When using a COSE key for this algorithm, the following checks are 2303 made: 2305 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2307 o If the 'alg' field is present, it MUST match the ChaCha20/Poly1305 2308 algorithm being used. 2310 o If the 'key_ops' field is present, it MUST include 'encrypt' or 2311 'wrap key' when encrypting. 2313 o If the 'key_ops' field is present, it MUST include 'decrypt' or 2314 'unwrap key' when decrypting. 2316 10.3.1. Security Considerations 2318 The pair of key, nonce MUST be unique for every invocation of the 2319 algorithm. Nonce counters are considered to be an acceptable way of 2320 ensuring that they are unique. 2322 11. Key Derivation Functions (KDF) 2324 Key Derivation Functions (KDFs) are used to take some secret value 2325 and generate a different one. The secret value comes in three 2326 flavors: 2328 o Secrets that are uniformly random: This is the type of secret that 2329 is created by a good random number generator. 2331 o Secrets that are not uniformly random: This is type of secret that 2332 is created by operations like key agreement. 2334 o Secrets that are not random: This is the type of secret that 2335 people generate for things like passwords. 2337 General KDF functions work well with the first type of secret, can do 2338 reasonably well with the second type of secret, and generally do 2339 poorly with the last type of secret. None of the KDF functions in 2340 this section are designed to deal with the type of secrets that are 2341 used for passwords. Functions like PBES2 [I-D.moriarty-pkcs5-v2dot1] 2342 need to be used for that type of secret. 2344 The same KDF function can be setup to deal with the first two types 2345 of secrets in a different way. The KDF function defined in 2346 Section 11.1 is such a function. This is reflected in the set of 2347 algorithms defined for HKDF. 2349 When using KDF functions, one component that is included is context 2350 information. Context information is used to allow for different 2351 keying information to be derived from the same secret. The use of 2352 context based keying material is considered to be a good security 2353 practice. 2355 This document defines a single context structure and a single KDF 2356 function. These elements are used for all of the recipient 2357 algorithms defined in this document that require a KDF process. 2358 These algorithms are defined in Section 12.1.2, Section 12.4.1, and 2359 Section 12.5.1. 2361 11.1. HMAC-based Extract-and-Expand Key Derivation Function (HKDF) 2363 The HKDF key derivation algorithm is defined in [RFC5869]. 2365 The HKDF algorithm takes these inputs: 2367 secret - a shared value that is secret. Secrets may be either 2368 previously shared or derived from operations like a DH key 2369 agreement. 2371 salt - an optional value that is used to change the generation 2372 process. The salt value can be either public or private. If the 2373 salt is public and carried in the message, then the 'salt' 2374 algorithm header parameter defined in Table 13 is used. While 2375 [RFC5869] suggests that the length of the salt be the same as the 2376 length of the underlying hash value, any amount of salt will 2377 improve the security as different key values will be generated. 2378 This parameter is protected by being included in the key 2379 computation and does not need to be separately authenticated. The 2380 salt value does not need to be unique for every message sent. 2382 length - the number of bytes of output that need to be generated. 2384 context information - Information that describes the context in 2385 which the resulting value will be used. Making this information 2386 specific to the context in which the material is going to be used 2387 ensures that the resulting material will always be tied to that 2388 usage. The context structure defined in Section 11.2 is used by 2389 the KDF functions in this document. 2391 PRF - The underlying pseudo-random function to be used in the HKDF 2392 algorithm. The PRF is encoded into the HKDF algorithm selection. 2394 HKDF is defined to use HMAC as the underlying PRF. However, it is 2395 possible to use other functions in the same construct to provide a 2396 different KDF function that is more appropriate in the constrained 2397 world. Specifically, one can use AES-CBC-MAC as the PRF for the 2398 expand step, but not for the extract step. When using a good random 2399 shared secret of the correct length, the extract step can be skipped. 2400 For the AES algorithm versions, the extract step is always skipped. 2402 The extract step cannot be skipped if the secret is not uniformly 2403 random, for example, if it is the result of an ECDH key agreement 2404 step. (This implies that the AES HKDF version cannot be used with 2405 ECDH.) If the extract step is skipped, the 'salt' value is not used 2406 as part of the HKDF functionality. 2408 The algorithms defined in this document are found in Table 12. 2410 +---------------+-----------------+---------------------------------+ 2411 | name | PRF | description | 2412 +---------------+-----------------+---------------------------------+ 2413 | HKDF SHA-256 | HMAC with | HKDF using HMAC SHA-256 as the | 2414 | | SHA-256 | PRF | 2415 | | | | 2416 | HKDF SHA-512 | HMAC with | HKDF using HMAC SHA-512 as the | 2417 | | SHA-512 | PRF | 2418 | | | | 2419 | HKDF AES- | AES-CBC-MAC-128 | HKDF using AES-MAC as the PRF | 2420 | MAC-128 | | w/ 128-bit key | 2421 | | | | 2422 | HKDF AES- | AES-CBC-MAC-256 | HKDF using AES-MAC as the PRF | 2423 | MAC-256 | | w/ 256-bit key | 2424 +---------------+-----------------+---------------------------------+ 2426 Table 12: HKDF algorithms 2428 +------+-------+------+-------------+ 2429 | name | label | type | description | 2430 +------+-------+------+-------------+ 2431 | salt | -20 | bstr | Random salt | 2432 +------+-------+------+-------------+ 2434 Table 13: HKDF Algorithm Parameters 2436 11.2. Context Information Structure 2438 The context information structure is used to ensure that the derived 2439 keying material is "bound" to the context of the transaction. The 2440 context information structure used here is based on that defined in 2441 [SP800-56A]. By using CBOR for the encoding of the context 2442 information structure, we automatically get the same type and length 2443 separation of fields that is obtained by the use of ASN.1. This 2444 means that there is no need to encode the lengths for the base 2445 elements as it is done by the encoding used in JOSE (Section 4.6.2 of 2446 [RFC7518]). 2448 The context information structure refers to PartyU and PartyV as the 2449 two parties that are doing the key derivation. Unless the 2450 application protocol defines differently, we assign PartyU to the 2451 entity that is creating the message and PartyV to the entity that is 2452 receiving the message. By doing this association, different keys 2453 will be derived for each direction as the context information is 2454 different in each direction. 2456 The context structure is built from information that is known to both 2457 entities. This information can be obtained from a variety of 2458 sources: 2460 o Fields can be defined by the application. This is commonly used 2461 to assign fixed names to parties, but can be used for other items 2462 such as nonces. 2464 o Fields can be defined by usage of the output. Examples of this 2465 are the algorithm and key size that are being generated. 2467 o Fields can be defined by parameters from the message. We define a 2468 set of parameters in Table 14 that can be used to carry the values 2469 associated with the context structure. Examples of this are 2470 identities and nonce values. These parameters are designed to be 2471 placed in the unprotected bucket of the recipient structure. 2472 (They do not need to be in the protected bucket since they already 2473 are included in the cryptographic computation by virtue of being 2474 included in the context structure.) 2476 +---------------+-------+-----------+-------------------------------+ 2477 | name | label | type | description | 2478 +---------------+-------+-----------+-------------------------------+ 2479 | PartyU | -21 | bstr | Party U identity Information | 2480 | identity | | | | 2481 | | | | | 2482 | PartyU nonce | -22 | bstr / | Party U provided nonce | 2483 | | | int | | 2484 | | | | | 2485 | PartyU other | -23 | bstr | Party U other provided | 2486 | | | | information | 2487 | | | | | 2488 | PartyV | -24 | bstr | Party V identity Information | 2489 | identity | | | | 2490 | | | | | 2491 | PartyV nonce | -25 | bstr / | Party V provided nonce | 2492 | | | int | | 2493 | | | | | 2494 | PartyV other | -26 | bstr | Party V other provided | 2495 | | | | information | 2496 +---------------+-------+-----------+-------------------------------+ 2498 Table 14: Context Algorithm Parameters 2500 We define a CBOR object to hold the context information. This object 2501 is referred to as COSE_KDF_Context. The object is based on a CBOR 2502 array type. The fields in the array are: 2504 AlgorithmID This field indicates the algorithm for which the key 2505 material will be used. This normally is either a Key Wrap 2506 algorithm identifier or a Content Encryption algorithm identifier. 2507 The values are from the "COSE Algorithm Value" registry. This 2508 field is required to be present. The field exists in the context 2509 information so that if the same environment is used for different 2510 algorithms, then completely different keys will be generated for 2511 each of those algorithms. (This practice means if algorithm A is 2512 broken and thus is easier to find, the key derived for algorithm B 2513 will not be the same as the key derived for algorithm A.) 2515 PartyUInfo This field holds information about party U. The 2516 PartyUInfo is encoded as a CBOR array. The elements of PartyUInfo 2517 are encoded in the order presented, however if the element does 2518 not exist no element is placed in the array. The elements of the 2519 PartyUInfo array are: 2521 identity This contains the identity information for party U. The 2522 identities can be assigned in one of two manners. Firstly, a 2523 protocol can assign identities based on roles. For example, 2524 the roles of "client" and "server" may be assigned to different 2525 entities in the protocol. Each entity would then use the 2526 correct label for the data they send or receive. The second 2527 way for a protocol to assign identities is to use a name based 2528 on a naming system (i.e., DNS, X.509 names). 2529 We define an algorithm parameter 'PartyU identity' that can be 2530 used to carry identity information in the message. However, 2531 identity information is often known as part of the protocol and 2532 can thus be inferred rather than made explicit. If identity 2533 information is carried in the message, applications SHOULD have 2534 a way of validating the supplied identity information. The 2535 identity information does not need to be specified and is set 2536 to nil in that case. 2538 nonce This contains a nonce value. The nonce can either be 2539 implicit from the protocol or carried as a value in the 2540 unprotected headers. 2541 We define an algorithm parameter 'PartyU nonce' that can be 2542 used to carry this value in the message However, the nonce 2543 value could be determined by the application and the value 2544 determined from elsewhere. 2545 This option does not need to be specified and is set to nil in 2546 that case 2548 other This contains other information that is defined by the 2549 protocol. 2550 This option does not need to be specified and is set to nil in 2551 that case 2553 PartyVInfo This field holds information about party V. The content 2554 of the structure are the same as for the PartyUInfo but for party 2555 V. 2557 SuppPubInfo This field contains public information that is mutually 2558 known to both parties. 2560 keyDataLength This is set to the number of bits of the desired 2561 output value. (This practice means if algorithm A can use two 2562 different key lengths, the key derived for longer key size will 2563 not contain the key for shorter key size as a prefix.) 2565 protected This field contains the protected parameter field. If 2566 there are no elements in the protected field, then use a zero 2567 length bstr. 2569 other This field is for free form data defined by the 2570 application. An example is that an application could define 2571 two different strings to be placed here to generate different 2572 keys for a data stream vs a control stream. This field is 2573 optional and will only be present if the application defines a 2574 structure for this information. Applications that define this 2575 SHOULD use CBOR to encode the data so that types and lengths 2576 are correctly included. 2578 SuppPrivInfo This field contains private information that is 2579 mutually known private information. An example of this 2580 information would be a pre-existing shared secret. (This could, 2581 for example, be used in combination with an ECDH key agreement to 2582 provide a secondary proof of identity.) The field is optional and 2583 will only be present if the application defines a structure for 2584 this information. Applications that define this SHOULD use CBOR 2585 to encode the data so that types and lengths are correctly 2586 included. 2588 The following CDDL fragment corresponds to the text above. 2590 PartyInfo = ( 2591 identity : bstr / nil, 2592 nonce : bstr / int / nil, 2593 other : bstr / nil, 2594 ) 2596 COSE_KDF_Context = [ 2597 AlgorithmID : int / tstr, 2598 PartyUInfo : [ PartyInfo ], 2599 PartyVInfo : [ PartyInfo ], 2600 SuppPubInfo : [ 2601 keyDataLength : uint, 2602 protected : empty_or_serialized_map, 2603 ? other : bstr 2604 ], 2605 ? SuppPrivInfo : bstr 2606 ] 2608 12. Content Key Distribution Methods 2610 Content key distribution methods (recipient algorithms) can be 2611 defined into a number of different classes. COSE has the ability to 2612 support many classes of recipient algorithms. In this section, a 2613 number of classes are listed and then a set of algorithms are 2614 specified for each of the classes. The names of the recipient 2615 algorithm classes used here are the same as are defined in [RFC7516]. 2616 Other specifications use different terms for the recipient algorithm 2617 classes or do not support some of the recipient algorithm classes. 2619 12.1. Direct Encryption 2621 The direct encryption class algorithms share a secret between the 2622 sender and the recipient that is used either directly or after 2623 manipulation as the CEK. When direct encryption mode is used, it 2624 MUST be the only mode used on the message. 2626 The COSE_Encrypt structure for the recipient is organized as follows: 2628 o The 'protected' field MUST be a zero length item unless it is used 2629 in the computation of the content key. 2631 o The 'alg' parameter MUST be present. 2633 o A parameter identifying the shared secret SHOULD be present. 2635 o The 'ciphertext' field MUST be a zero length item. 2637 o The 'recipients' field MUST be absent. 2639 12.1.1. Direct Key 2641 This recipient algorithm is the simplest; the identified key is 2642 directly used as the key for the next layer down in the message. 2643 There are no algorithm parameters defined for this algorithm. The 2644 algorithm identifier value is assigned in Table 15. 2646 When this algorithm is used, the protected field MUST be zero length. 2647 The key type MUST be 'Symmetric'. 2649 +--------+-------+-------------------+ 2650 | name | value | description | 2651 +--------+-------+-------------------+ 2652 | direct | -6 | Direct use of CEK | 2653 +--------+-------+-------------------+ 2655 Table 15: Direct Key 2657 12.1.1.1. Security Considerations 2659 This recipient algorithm has several potential problems that need to 2660 be considered: 2662 o These keys need to have some method to be regularly updated over 2663 time. All of the content encryption algorithms specified in this 2664 document have limits on how many times a key can be used without 2665 significant loss of security. 2667 o These keys need to be dedicated to a single algorithm. There have 2668 been a number of attacks developed over time when a single key is 2669 used for multiple different algorithms. One example of this is 2670 the use of a single key both for CBC encryption mode and CBC-MAC 2671 authentication mode. 2673 o Breaking one message means all messages are broken. If an 2674 adversary succeeds in determining the key for a single message, 2675 then the key for all messages is also determined. 2677 12.1.2. Direct Key with KDF 2679 These recipient algorithms take a common shared secret between the 2680 two parties and applies the HKDF function (Section 11.1), using the 2681 context structure defined in Section 11.2 to transform the shared 2682 secret into the CEK. The 'protected' field can be of non-zero 2683 length. Either the 'salt' parameter of HKDF or the partyU 'nonce' 2684 parameter of the context structure MUST be present. The salt/nonce 2685 parameter can be generated either randomly or deterministically. The 2686 requirement is that it be a unique value for the shared secret in 2687 question. 2689 If the salt/nonce value is generated randomly, then it is suggested 2690 that the length of the random value be the same length as the hash 2691 function underlying HKDF. While there is no way to guarantee that it 2692 will be unique, there is a high probability that it will be unique. 2693 If the salt/nonce value is generated deterministically, it can be 2694 guaranteed to be unique and thus there is no length requirement. 2696 A new IV must be used for each message if the same key is used. The 2697 IV can be modified in a predictable manner, a random manner or an 2698 unpredictable manner (i.e., encrypting a counter). 2700 The IV used for a key can also be generated from the same HKDF 2701 functionality as the key is generated. If HKDF is used for 2702 generating the IV, the algorithm identifier is set to "IV- 2703 GENERATION". 2705 When these algorithms are used, the key type MUST be 'symmetric'. 2707 The set of algorithms defined in this document can be found in 2708 Table 16. 2710 +---------------------+-------+-------------+-----------------------+ 2711 | name | value | KDF | description | 2712 +---------------------+-------+-------------+-----------------------+ 2713 | direct+HKDF-SHA-256 | -10 | HKDF | Shared secret w/ HKDF | 2714 | | | SHA-256 | and SHA-256 | 2715 | | | | | 2716 | direct+HKDF-SHA-512 | -11 | HKDF | Shared secret w/ HKDF | 2717 | | | SHA-512 | and SHA-512 | 2718 | | | | | 2719 | direct+HKDF-AES-128 | -12 | HKDF AES- | Shared secret w/ AES- | 2720 | | | MAC-128 | MAC 128-bit key | 2721 | | | | | 2722 | direct+HKDF-AES-256 | -13 | HKDF AES- | Shared secret w/ AES- | 2723 | | | MAC-256 | MAC 256-bit key | 2724 +---------------------+-------+-------------+-----------------------+ 2726 Table 16: Direct Key with KDF 2728 When using a COSE key for this algorithm, the following checks are 2729 made: 2731 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2733 o If the 'alg' field is present, it MUST match the algorithm being 2734 used. 2736 o If the 'key_ops' field is present, it MUST include 'deriveKey' or 2737 'deriveBits'. 2739 12.1.2.1. Security Considerations 2741 The shared secret needs to have some method to be regularly updated 2742 over time. The shared secret forms the basis of trust. Although not 2743 used directly, it should still be subject to scheduled rotation. 2745 While these methods do not provide for perfect forward secrecy, as 2746 the same shared secret is used for all of the keys generated, if the 2747 key for any single message is discovered only the message (or series 2748 of messages) using that derived key are compromised. A new key 2749 derivation step will generate a new key which requires the same 2750 amount of work to get the key. 2752 12.2. Key Wrapping 2754 In key wrapping mode, the CEK is randomly generated and that key is 2755 then encrypted by a shared secret between the sender and the 2756 recipient. All of the currently defined key wrapping algorithms for 2757 COSE are AE algorithms. Key wrapping mode is considered to be 2758 superior to direct encryption if the system has any capability for 2759 doing random key generation. This is because the shared key is used 2760 to wrap random data rather than data that has some degree of 2761 organization and may in fact be repeating the same content. The use 2762 of Key Wrapping loses the weak data origination that is provided by 2763 the direct encryption algorithms. 2765 The COSE_Encrypt structure for the recipient is organized as follows: 2767 o The 'protected' field MUST be absent if the key wrap algorithm is 2768 an AE algorithm. 2770 o The 'recipients' field is normally absent, but can be used. 2771 Applications MUST deal with a recipient field being present, not 2772 being able to decrypt that recipient is an acceptable way of 2773 dealing with it. Failing to process the message is not an 2774 acceptable way of dealing with it. 2776 o The plain text to be encrypted is the key from next layer down 2777 (usually the content layer). 2779 o At a minimum, the 'unprotected' field MUST contain the 'alg' 2780 parameter and SHOULD contain a parameter identifying the shared 2781 secret. 2783 12.2.1. AES Key Wrapping 2785 The AES Key Wrapping algorithm is defined in [RFC3394]. This 2786 algorithm uses an AES key to wrap a value that is a multiple of 64 2787 bits. As such, it can be used to wrap a key for any of the content 2788 encryption algorithms defined in this document. The algorithm 2789 requires a single fixed parameter, the initial value. This is fixed 2790 to the value specified in Section 2.2.3.1 of [RFC3394]. There are no 2791 public parameters that vary on a per invocation basis. The protected 2792 header field MUST be empty. 2794 Keys may be obtained either from a key structure or from a recipient 2795 structure. Implementations encrypting and decrypting MUST validate 2796 that the key type, key length and algorithm are correct and 2797 appropriate for the entities involved. 2799 When using a COSE key for this algorithm, the following checks are 2800 made: 2802 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2804 o If the 'alg' field is present, it MUST match the AES Key Wrap 2805 algorithm being used. 2807 o If the 'key_ops' field is present, it MUST include 'encrypt' or 2808 'wrap key' when encrypting. 2810 o If the 'key_ops' field is present, it MUST include 'decrypt' or 2811 'unwrap key' when decrypting. 2813 +--------+-------+----------+-----------------------------+ 2814 | name | value | key size | description | 2815 +--------+-------+----------+-----------------------------+ 2816 | A128KW | -3 | 128 | AES Key Wrap w/ 128-bit key | 2817 | | | | | 2818 | A192KW | -4 | 192 | AES Key Wrap w/ 192-bit key | 2819 | | | | | 2820 | A256KW | -5 | 256 | AES Key Wrap w/ 256-bit key | 2821 +--------+-------+----------+-----------------------------+ 2823 Table 17: AES Key Wrap Algorithm Values 2825 12.2.1.1. Security Considerations for AES-KW 2827 The shared secret needs to have some method to be regularly updated 2828 over time. The shared secret is the basis of trust. 2830 12.3. Key Transport 2832 Key transport mode is also called key encryption mode in some 2833 standards. Key transport mode differs from key wrap mode in that it 2834 uses an asymmetric encryption algorithm rather than a symmetric 2835 encryption algorithm to protect the key. This document does not 2836 define any key transport mode algorithms. 2838 When using a key transport algorithm, the COSE_Encrypt structure for 2839 the recipient is organized as follows: 2841 o The 'protected' field MUST be absent. 2843 o The plain text to be encrypted is the key from next layer down 2844 (usually the content layer). 2846 o At a minimum, the 'unprotected' field MUST contain the 'alg' 2847 parameter and SHOULD contain a parameter identifying the 2848 asymmetric key. 2850 12.4. Direct Key Agreement 2852 The 'direct key agreement' class of recipient algorithms uses a key 2853 agreement method to create a shared secret. A KDF is then applied to 2854 the shared secret to derive a key to be used in protecting the data. 2856 This key is normally used as a CEK or MAC key, but could be used for 2857 other purposes if more than two layers are in use (see Appendix B). 2859 The most commonly used key agreement algorithm is Diffie-Hellman, but 2860 other variants exist. Since COSE is designed for a store and forward 2861 environment rather than an on-line environment, many of the DH 2862 variants cannot be used as the receiver of the message cannot provide 2863 any dynamic key material. One side-effect of this is that perfect 2864 forward secrecy (see [RFC4949]) is not achievable. A static key will 2865 always be used for the receiver of the COSE object. 2867 Two variants of DH that are supported are: 2869 Ephemeral-Static DH: where the sender of the message creates a 2870 one-time DH key and uses a static key for the recipient. The use 2871 of the ephemeral sender key means that no additional random input 2872 is needed as this is randomly generated for each message. 2874 Static-Static DH: where a static key is used for both the sender 2875 and the recipient. The use of static keys allows for recipient to 2876 get a weak version of data origination for the message. When 2877 static-static key agreement is used, then some piece of unique 2878 data for the KDF is required to ensure that a different key is 2879 created for each message. 2881 When direct key agreement mode is used, there MUST be only one 2882 recipient in the message. This method creates the key directly and 2883 that makes it difficult to mix with additional recipients. If 2884 multiple recipients are needed, then the version with key wrap needs 2885 to be used. 2887 The COSE_Encrypt structure for the recipient is organized as follows: 2889 o At a minimum, headers MUST contain the 'alg' parameter and SHOULD 2890 contain a parameter identifying the recipient's asymmetric key. 2892 o The headers SHOULD identify the sender's key for the static-static 2893 versions and MUST contain the sender's ephemeral key for the 2894 ephemeral-static versions. 2896 12.4.1. ECDH 2898 The mathematics for Elliptic Curve Diffie-Hellman can be found in 2899 [RFC6090]. In this document, the algorithm is extended to be used 2900 with the two curves defined in [RFC7748]. 2902 ECDH is parameterized by the following: 2904 o Curve Type/Curve: The curve selected controls not only the size of 2905 the shared secret, but the mathematics for computing the shared 2906 secret. The curve selected also controls how a point in the curve 2907 is represented and what happens for the identity points on the 2908 curve. In this specification, we allow for a number of different 2909 curves to be used. A set of curves are defined in Table 22. 2910 The math used to obtain the computed secret is based on the curve 2911 selected and not on the ECDH algorithm. For this reason, a new 2912 algorithm does not need to be defined for each of the curves. 2914 o Computed Secret to Shared Secret: Once the computed secret is 2915 known, the resulting value needs to be converted to a byte string 2916 to run the KDF function. The X coordinate is used for all of the 2917 curves defined in this document. For curves X25519 and X448, the 2918 resulting value is used directly as it is a byte string of a known 2919 length. For the P-256, P-384 and P-521 curves, the X coordinate 2920 is run through the I2OSP function defined in [I-D.moriarty-pkcs1], 2921 using the same computation for n as is defined in Section 8.1. 2923 o Ephemeral-static or static-static: The key agreement process may 2924 be done using either a static or an ephemeral key for the sender's 2925 side. When using ephemeral keys, the sender MUST generate a new 2926 ephemeral key for every key agreement operation. The ephemeral 2927 key is placed in the 'ephemeral key' parameter and MUST be present 2928 for all algorithm identifiers that use ephemeral keys. When using 2929 static keys, the sender MUST either generate a new random value or 2930 otherwise create a unique value. For the KDF functions used, this 2931 means either in the 'salt' parameter for HKDF (Table 13) or in the 2932 'PartyU nonce' parameter for the context structure (Table 14) MUST 2933 be present. (Both may be present if desired.) The value in the 2934 parameter MUST be unique for the pair of keys being used. It is 2935 acceptable to use a global counter that is incremented for every 2936 static-static operation and use the resulting value. When using 2937 static keys, the static key should be identified to the recipient. 2938 The static key can be identified either by providing the key 2939 ('static key') or by providing a key identifier for the static key 2940 ('static key id'). Both of these parameters are defined in 2941 Table 19. 2943 o Key derivation algorithm: The result of an ECDH key agreement 2944 process does not provide a uniformly random secret. As such, it 2945 needs to be run through a KDF in order to produce a usable key. 2946 Processing the secret through a KDF also allows for the 2947 introduction of context material: how the key is going to be used, 2948 and one-time material for static-static key agreement. All of the 2949 algorithms defined in this document use one of the HKDF algorithms 2950 defined in Section 11.1 with the context structure defined in 2951 Section 11.2. 2953 o Key Wrap algorithm: No key wrap algorithm is used. This is 2954 represented in Table 18 as 'none'. The key size for the context 2955 structure is the content layer encryption algorithm size. 2957 The set of direct ECDH algorithms defined in this document are found 2958 in Table 18. 2960 +-----------+-------+---------+------------+--------+---------------+ 2961 | name | value | KDF | Ephemeral- | Key | description | 2962 | | | | Static | Wrap | | 2963 +-----------+-------+---------+------------+--------+---------------+ 2964 | ECDH-ES + | -25 | HKDF - | yes | none | ECDH ES w/ | 2965 | HKDF-256 | | SHA-256 | | | HKDF - | 2966 | | | | | | generate key | 2967 | | | | | | directly | 2968 | | | | | | | 2969 | ECDH-ES + | -26 | HKDF - | yes | none | ECDH ES w/ | 2970 | HKDF-512 | | SHA-512 | | | HKDF - | 2971 | | | | | | generate key | 2972 | | | | | | directly | 2973 | | | | | | | 2974 | ECDH-SS + | -27 | HKDF - | no | none | ECDH SS w/ | 2975 | HKDF-256 | | SHA-256 | | | HKDF - | 2976 | | | | | | generate key | 2977 | | | | | | directly | 2978 | | | | | | | 2979 | ECDH-SS + | -28 | HKDF - | no | none | ECDH SS w/ | 2980 | HKDF-512 | | SHA-512 | | | HKDF - | 2981 | | | | | | generate key | 2982 | | | | | | directly | 2983 +-----------+-------+---------+------------+--------+---------------+ 2985 Table 18: ECDH Algorithm Values 2987 +-----------+-------+----------+-----------+------------------------+ 2988 | name | label | type | algorithm | description | 2989 +-----------+-------+----------+-----------+------------------------+ 2990 | ephemeral | -1 | COSE_Key | ECDH-ES | Ephemeral Public key | 2991 | key | | | | for the sender | 2992 | | | | | | 2993 | static | -2 | COSE_Key | ECDH-SS | Static Public key for | 2994 | key | | | | the sender | 2995 | | | | | | 2996 | static | -3 | bstr | ECDH-SS | Static Public key | 2997 | key id | | | | identifier for the | 2998 | | | | | sender | 2999 +-----------+-------+----------+-----------+------------------------+ 3001 Table 19: ECDH Algorithm Parameters 3003 This document defines these algorithms to be used with the curves 3004 P-256, P-384, P-521, X25519, and X448. Implementations MUST verify 3005 that the key type and curve are correct. Different curves are 3006 restricted to different key types. Implementations MUST verify that 3007 the curve and algorithm are appropriate for the entities involved. 3009 When using a COSE key for this algorithm, the following checks are 3010 made: 3012 o The 'kty' field MUST be present and it MUST be 'EC2' or 'OKP'. 3014 o If the 'alg' field is present, it MUST match the Key Agreement 3015 algorithm being used. 3017 o If the 'key_ops' field is present, it MUST include 'derive key' or 3018 'derive bits' for the private key. 3020 o If the 'key_ops' field is present, it MUST be empty for the public 3021 key. 3023 12.4.2. Security Considerations 3025 Some method of checking that points provided from external entities 3026 are valid. For the 'EC2' key format, this can be done by checking 3027 that the x and y values form a point on the curve. For the 'OKP' 3028 format, there is no simple way to do point validation. 3030 Consideration was given to requiring that the public keys of both 3031 entities be provided as part of the key derivation process. (As 3032 recommended in section 6.1 of [RFC7748].) This was not done as COSE 3033 is used in a store and forward format rather than in on line key 3034 exchange. In order for this to be a problem, either the receiver 3035 public key has to be chosen maliciously or the sender has to be 3036 malicious. In either case, all security evaporates anyway. 3038 A proof of possession of the private key associated with the public 3039 key is recommended when a key is moved from untrusted to trusted. 3040 (Either by the end user or by the entity that is responsible for 3041 making trust statements on keys.) 3043 12.5. Key Agreement with Key Wrap 3045 Key Agreement with Key Wrapping uses a randomly generated CEK. The 3046 CEK is then encrypted using a Key Wrapping algorithm and a key 3047 derived from the shared secret computed by the key agreement 3048 algorithm. The function for this would be: 3050 encryptedKey = KeyWrap(KDF(DH-Shared, context), CEK) 3052 The COSE_Encrypt structure for the recipient is organized as follows: 3054 o The 'protected' field is fed into the KDF context structure. 3056 o The plain text to be encrypted is the key from next layer down 3057 (usually the content layer). 3059 o The 'alg' parameter MUST be present in the layer. 3061 o A parameter identifying the recipient's key SHOULD be present. A 3062 parameter identifying the sender's key SHOULD be present. 3064 12.5.1. ECDH 3066 These algorithms are defined in Table 20. 3068 ECDH with Key Agreement is parameterized by the same parameters as 3069 for ECDH Section 12.4.1 with the following modifications: 3071 o Key Wrap Algorithm: Any of the key wrap algorithms defined in 3072 Section 12.2.1 are supported. The size of the key used for the 3073 key wrap algorithm is fed into the KDF function. The set of 3074 identifiers are found in Table 20. 3076 +-----------+-------+---------+------------+--------+---------------+ 3077 | name | value | KDF | Ephemeral- | Key | description | 3078 | | | | Static | Wrap | | 3079 +-----------+-------+---------+------------+--------+---------------+ 3080 | ECDH-ES + | -29 | HKDF - | yes | A128KW | ECDH ES w/ | 3081 | A128KW | | SHA-256 | | | Concat KDF | 3082 | | | | | | and AES Key | 3083 | | | | | | wrap w/ 128 | 3084 | | | | | | bit key | 3085 | | | | | | | 3086 | ECDH-ES + | -30 | HKDF - | yes | A192KW | ECDH ES w/ | 3087 | A192KW | | SHA-256 | | | Concat KDF | 3088 | | | | | | and AES Key | 3089 | | | | | | wrap w/ 192 | 3090 | | | | | | bit key | 3091 | | | | | | | 3092 | ECDH-ES + | -31 | HKDF - | yes | A256KW | ECDH ES w/ | 3093 | A256KW | | SHA-256 | | | Concat KDF | 3094 | | | | | | and AES Key | 3095 | | | | | | wrap w/ 256 | 3096 | | | | | | bit key | 3097 | | | | | | | 3098 | ECDH-SS + | -32 | HKDF - | no | A128KW | ECDH SS w/ | 3099 | A128KW | | SHA-256 | | | Concat KDF | 3100 | | | | | | and AES Key | 3101 | | | | | | wrap w/ 128 | 3102 | | | | | | bit key | 3103 | | | | | | | 3104 | ECDH-SS + | -33 | HKDF - | no | A192KW | ECDH SS w/ | 3105 | A192KW | | SHA-256 | | | Concat KDF | 3106 | | | | | | and AES Key | 3107 | | | | | | wrap w/ 192 | 3108 | | | | | | bit key | 3109 | | | | | | | 3110 | ECDH-SS + | -34 | HKDF - | no | A256KW | ECDH SS w/ | 3111 | A256KW | | SHA-256 | | | Concat KDF | 3112 | | | | | | and AES Key | 3113 | | | | | | wrap w/ 256 | 3114 | | | | | | bit key | 3115 +-----------+-------+---------+------------+--------+---------------+ 3117 Table 20: ECDH Algorithm Values with Key Wrap 3119 When using a COSE key for this algorithm, the following checks are 3120 made: 3122 o The 'kty' field MUST be present and it MUST be 'EC2' or 'OKP'. 3124 o If the 'alg' field is present, it MUST match the Key Agreement 3125 algorithm being used. 3127 o If the 'key_ops' field is present, it MUST include 'derive key' or 3128 'derive bits' for the private key. 3130 o If the 'key_ops' field is present, it MUST be empty for the public 3131 key. 3133 13. Key Object Parameters 3135 The COSE_Key object defines a way to hold a single key object. It is 3136 still required that the members of individual key types be defined. 3137 This section of the document is where we define an initial set of 3138 members for specific key types. 3140 For each of the key types, we define both public and private members. 3141 The public members are what is transmitted to others for their usage. 3142 Private members allow for the archival of keys by individuals. 3143 However, there are some circumstances in which private keys may be 3144 distributed to entities in a protocol. Examples include: entities 3145 that have poor random number generation, centralized key creation for 3146 multi-cast type operations, and protocols in which a shared secret is 3147 used as a bearer token for authorization purposes. 3149 Key types are identified by the 'kty' member of the COSE_Key object. 3150 In this document, we define four values for the member: 3152 +-----------+-------+--------------------------------------------+ 3153 | name | value | description | 3154 +-----------+-------+--------------------------------------------+ 3155 | OKP | 1 | Octet Key Pair | 3156 | | | | 3157 | EC2 | 2 | Elliptic Curve Keys w/ X,Y Coordinate pair | 3158 | | | | 3159 | Symmetric | 4 | Symmetric Keys | 3160 | | | | 3161 | Reserved | 0 | This value is reserved | 3162 +-----------+-------+--------------------------------------------+ 3164 Table 21: Key Type Values 3166 13.1. Elliptic Curve Keys 3168 Two different key structures could be defined for Elliptic Curve 3169 keys. One version uses both an x and a y coordinate, potentially 3170 with point compression ('EC2'). This is the traditional EC point 3171 representation that is used in [RFC5480]. The other version uses 3172 only the x coordinate as the y coordinate is either to be recomputed 3173 or not needed for the key agreement operation ('OKP'). 3175 Applications MUST check that the curve and the key type are 3176 consistent and reject a key if they are not. 3178 +---------+----------+-------+------------------------------------+ 3179 | name | key type | value | description | 3180 +---------+----------+-------+------------------------------------+ 3181 | P-256 | EC2 | 1 | NIST P-256 also known as secp256r1 | 3182 | | | | | 3183 | P-384 | EC2 | 2 | NIST P-384 also known as secp384r1 | 3184 | | | | | 3185 | P-521 | EC2 | 3 | NIST P-521 also known as secp521r1 | 3186 | | | | | 3187 | X25519 | OKP | 4 | X25519 for use w/ ECDH only | 3188 | | | | | 3189 | X448 | OKP | 5 | X448 for use w/ ECDH only | 3190 | | | | | 3191 | Ed25519 | OKP | 6 | Ed25519 for use w/ EdDSA only | 3192 | | | | | 3193 | Ed448 | OKP | 7 | Ed448 for use w/ EdDSA only | 3194 +---------+----------+-------+------------------------------------+ 3196 Table 22: EC Curves 3198 13.1.1. Double Coordinate Curves 3200 The traditional way of sending EC curves has been to send either both 3201 the x and y coordinates, or the x coordinate and a sign bit for the y 3202 coordinate. The latter encoding has not been recommended in the IETF 3203 due to potential IPR issues. However, for operations in constrained 3204 environments, the ability to shrink a message by not sending the y 3205 coordinate is potentially useful. 3207 For EC keys with both coordinates, the 'kty' member is set to 2 3208 (EC2). The key parameters defined in this section are summarized in 3209 Table 23. The members that are defined for this key type are: 3211 crv contains an identifier of the curve to be used with the key. 3212 The curves defined in this document for this key type can be found 3213 in Table 22. Other curves may be registered in the future and 3214 private curves can be used as well. 3216 x contains the x coordinate for the EC point. The integer is 3217 converted to an octet string as defined in [SEC1]. Leading zero 3218 octets MUST be preserved. 3220 y contains either the sign bit or the value of y coordinate for the 3221 EC point. When encoding the value y, the integer is converted to 3222 an octet string (as defined in [SEC1]) and encoded as a CBOR bstr. 3223 Leading zero octets MUST be preserved. The compressed point 3224 encoding is also supported. Compute the sign bit as laid out in 3225 the Elliptic-Curve-Point-to-Octet-String Conversion function of 3226 [SEC1]. If the sign bit is zero, then encode y as a CBOR false 3227 value, otherwise encode y as a CBOR true value. The encoding of 3228 the infinity point is not supported. 3230 d contains the private key. 3232 For public keys, it is REQUIRED that 'crv', 'x' and 'y' be present in 3233 the structure. For private keys, it is REQUIRED that 'crv' and 'd' 3234 be present in the structure. For private keys, it is RECOMMENDED 3235 that 'x' and 'y' also be present, but they can be recomputed from the 3236 required elements and omitting them saves on space. 3238 +------+-------+-------+---------+----------------------------------+ 3239 | name | key | value | type | description | 3240 | | type | | | | 3241 +------+-------+-------+---------+----------------------------------+ 3242 | crv | 2 | -1 | int / | EC Curve identifier - Taken from | 3243 | | | | tstr | the COSE Curves registry | 3244 | | | | | | 3245 | x | 2 | -2 | bstr | X Coordinate | 3246 | | | | | | 3247 | y | 2 | -3 | bstr / | Y Coordinate | 3248 | | | | bool | | 3249 | | | | | | 3250 | d | 2 | -4 | bstr | Private key | 3251 +------+-------+-------+---------+----------------------------------+ 3253 Table 23: EC Key Parameters 3255 13.2. Octet Key Pair 3257 A new key type is defined for Octet Key Pairs (OKP). Do not assume 3258 that keys using this type are elliptic curves. This key type could 3259 be used for other curve types (for example, mathematics based on 3260 hyper-elliptic surfaces). 3262 The key parameters defined in this section are summarized in 3263 Table 24. The members that are defined for this key type are: 3265 crv contains an identifier of the curve to be used with the key. 3266 The curves defined in this document for this key type can be found 3267 in Table 22. Other curves may be registered in the future and 3268 private curves can be used as well. 3270 x contains the x coordinate for the EC point. The octet string 3271 represents a little-endian encoding of x. 3273 d contains the private key. 3275 For public keys, it is REQUIRED that 'crv' and 'x' be present in the 3276 structure. For private keys, it is REQUIRED that 'crv' and 'd' be 3277 present in the structure. For private keys, it is RECOMMENDED that 3278 'x' also be present, but it can be recomputed from the required 3279 elements and omitting it saves on space. 3281 +------+------+-------+-------+-------------------------------------+ 3282 | name | key | value | type | description | 3283 | | type | | | | 3284 +------+------+-------+-------+-------------------------------------+ 3285 | crv | 1 | -1 | int / | EC Curve identifier - Taken from | 3286 | | | | tstr | the COSE Key Common Parameters | 3287 | | | | | registry | 3288 | | | | | | 3289 | x | 1 | -2 | bstr | X Coordinate | 3290 | | | | | | 3291 | d | 1 | -4 | bstr | Private key | 3292 +------+------+-------+-------+-------------------------------------+ 3294 Table 24: Octet Key Pair Parameters 3296 13.3. Symmetric Keys 3298 Occasionally it is required that a symmetric key be transported 3299 between entities. This key structure allows for that to happen. 3301 For symmetric keys, the 'kty' member is set to 3 (Symmetric). The 3302 member that is defined for this key type is: 3304 k contains the value of the key. 3306 This key structure does not have a form that contains only public 3307 members. As it is expected that this key structure is going to be 3308 transmitted, care must be taking that it is never transmitted 3309 accidentally or insecurely. For symmetric keys, it is REQUIRED that 3310 'k' be present in the structure. 3312 +------+----------+-------+------+-------------+ 3313 | name | key type | value | type | description | 3314 +------+----------+-------+------+-------------+ 3315 | k | 4 | -1 | bstr | Key Value | 3316 +------+----------+-------+------+-------------+ 3318 Table 25: Symmetric Key Parameters 3320 14. CBOR Encoder Restrictions 3322 There has been an attempt to limit the number of places where the 3323 document needs to impose restrictions on how the CBOR Encoder needs 3324 to work. We have managed to narrow it down to the following 3325 restrictions: 3327 o The restriction applies to the encoding the Sig_structure, the 3328 Enc_structure, and the MAC_structure. 3330 o The rules for Canonical CBOR (Section 3.9 of RFC 7049) MUST be 3331 used in these locations. The main rule that needs to be enforced 3332 is that all lengths in these structures MUST be encoded such that 3333 they are encoded using definite lengths and the minimum length 3334 encoding is used. 3336 o Applications MUST NOT generate messages with the same label used 3337 twice as a key in a single map. Applications MUST NOT parse and 3338 process messages with the same label used twice as a key in a 3339 single map. Applications can enforce the parse and process 3340 requirement by using parsers that will fail the parse step or by 3341 using parsers that will pass all keys to the application and the 3342 application can perform the check for duplicate keys. 3344 15. Application Profiling Considerations 3346 This document is designed to provide a set of security services, but 3347 not to provide implementation requirements for specific usage. The 3348 interoperability requirements are provided for how each of the 3349 individual services are used and how the algorithms are to be used 3350 for interoperability. The requirements about which algorithms and 3351 which services are needed are deferred to each application. 3353 An example of a profile can be found in 3354 [I-D.selander-ace-object-security] where two profiles are being 3355 developed. One is for carrying content by itself, and the other is 3356 for carrying content in combination with CoAP headers. 3358 It is intended that a profile of this document be created that 3359 defines the interoperability requirements for that specific 3360 application. This section provides a set of guidelines and topics 3361 that need to be considered when profiling this document. 3363 o Applications need to determine the set of messages defined in this 3364 document that they will be using. The set of messages corresponds 3365 fairly directly to the set of security services that are needed 3366 and to the security levels needed. 3368 o Applications may define new header parameters for a specific 3369 purpose. Applications will often times select specific header 3370 parameters to use or not to use. For example, an application 3371 would normally state a preference for using either the IV or the 3372 partial IV parameter. If the partial IV parameter is specified, 3373 then the application would also need to define how the fixed 3374 portion of the IV would be determined. 3376 o When applications use externally defined authenticated data, they 3377 need to define how that data is encoded. This document assumes 3378 that the data will be provided as a byte stream. More information 3379 can be found in Section 4.3. 3381 o Applications need to determine the set of security algorithms that 3382 are to be used. When selecting the algorithms to be used as the 3383 mandatory to implement set, consideration should be given to 3384 choosing different types of algorithms when two are chosen for a 3385 specific purpose. An example of this would be choosing HMAC- 3386 SHA512 and AES-CMAC as different MAC algorithms; the construction 3387 is vastly different between these two algorithms. This means that 3388 a weakening of one algorithm would be unlikely to lead to a 3389 weakening of the other algorithms. Of course, these algorithms do 3390 not provide the same level of security and thus may not be 3391 comparable for the desired security functionality. 3393 o Applications may need to provide some type of negotiation or 3394 discovery method if multiple algorithms or message structures are 3395 permitted. The method can be as simple as requiring 3396 preconfiguration of the set of algorithms to providing a discovery 3397 method built into the protocol. S/MIME provided a number of 3398 different ways to approach the problem that applications could 3399 follow: 3401 * Advertising in the message (S/MIME capabilities) [RFC5751]. 3403 * Advertising in the certificate (capabilities extension) 3404 [RFC4262]. 3406 * Minimum requirements for the S/MIME, which have been updated 3407 over time [RFC2633][RFC5751]. 3409 16. IANA Considerations 3411 16.1. CBOR Tag assignment 3413 It is requested that IANA assign the following tags from the "CBOR 3414 Tags" registry. It is requested that the tags for COSE_Sign1, 3415 COSE_Encrypt0, and COSE_Mac0 be assigned in the 1 to 23 value range 3416 (one byte long when encoded). It is requested that the tags for 3417 COSE_Sign, COSE_Encrypt and COSE_MAC be assigned in the 24 to 255 3418 value range (two bytes long when encoded). 3420 The tags to be assigned are in Table 1. 3422 16.2. COSE Header Parameters Registry 3424 It is requested that IANA create a new registry entitled "COSE Header 3425 Parameters". The registry should be created as Expert Review 3426 Required. Guidelines for the experts is provided Section 16.11. It 3427 should be noted that in additional to the expert review, some 3428 portions of the registry require a specification, potentially on 3429 standards track, be supplied as well. 3431 The columns of the registry are: 3433 name The name is present to make it easier to refer to and discuss 3434 the registration entry. The value is not used in the protocol. 3435 Names are to be unique in the table. 3437 label This is the value used for the label. The label can be either 3438 an integer or a string. Registration in the table is based on the 3439 value of the label requested. Integer values between 1 and 255 3440 and strings of length 1 are designated as Standards Track Document 3441 required. Integer values from 256 to 65535 and strings of length 3442 2 are designated as Specification Required. Integer values of 3443 greater than 65535 and strings of length greater than 2 are 3444 designated as expert review. Integer values in the range -1 to 3445 -65536 are delegated to the "COSE Header Algorithm Parameters" 3446 registry. Integer values less than -65536 are marked as private 3447 use. 3449 value This contains the CBOR type for the value portion of the 3450 label. 3452 value registry This contains a pointer to the registry used to 3453 contain values where the set is limited. 3455 description This contains a brief description of the header field. 3457 specification This contains a pointer to the specification defining 3458 the header field (where public). 3460 The initial contents of the registry can be found in Table 2 and 3461 Table 27. The specification column for all rows in that table should 3462 be this document. 3464 Additionally, the label of 0 is to be marked as 'Reserved'. 3466 16.3. COSE Header Algorithm Parameters Registry 3468 It is requested that IANA create a new registry entitled "COSE Header 3469 Algorithm Parameters". The registry is to be created as Expert 3470 Review Required. Expert review guidelines are provided in 3471 Section 16.11. 3473 The columns of the registry are: 3475 name The name is present to make it easier to refer to and discuss 3476 the registration entry. The value is not used in the protocol. 3478 algorithm The algorithm(s) that this registry entry is used for. 3479 This value is taken from the "COSE Algorithm Values" registry. 3480 Multiple algorithms can be specified in this entry. For the 3481 table, the algorithm, label pair MUST be unique. 3483 label This is the value used for the label. The label is an integer 3484 in the range of -1 to -65536. 3486 value This contains the CBOR type for the value portion of the 3487 label. 3489 value registry This contains a pointer to the registry used to 3490 contain values where the set is limited. 3492 description This contains a brief description of the header field. 3494 specification This contains a pointer to the specification defining 3495 the header field (where public). 3497 The initial contents of the registry can be found in Table 13, 3498 Table 14, and Table 19. The specification column for all rows in 3499 that table should be this document. 3501 16.4. COSE Algorithms Registry 3503 It is requested that IANA create a new registry entitled "COSE 3504 Algorithms Registry". The registry is to be created as Expert Review 3505 Required. Guidelines for the experts is provided Section 16.11. It 3506 should be noted that in additional to the expert review, some 3507 portions of the registry require a specification, potentially on 3508 standards track, be supplied as well. 3510 The columns of the registry are: 3512 value: The value to be used to identify this algorithm. Algorithm 3513 values MUST be unique. The value can be a positive integer, a 3514 negative integer or a string. Integer values between -256 and 255 3515 and strings of length 1 are designated as Standards Track Document 3516 required. Integer values from -65536 to 65535 and strings of 3517 length 2 are designated as Specification Required. Integer values 3518 of greater than 65535 and strings of length greater than 2 are 3519 designated as expert review. Integer values less than -65536 are 3520 marked as private use. 3522 description: A short description of the algorithm. 3524 specification: A document where the algorithm is defined (if 3525 publicly available). 3527 recommended: Does the IETF have a concensus recommendation to use 3528 the algorithm. The legal values are 'yes', 'no' and 'deprecated'. 3530 The initial contents of the registry can be found in Table 10, 3531 Table 9, Table 11, Table 5, Table 7, Table 8, Table 15, Table 16, 3532 Table 17, Table 6, Table 20 and Table 18. The specification column 3533 for all rows in the table should be this document. The recommneded 3534 column for all rows in the table are set to 'yes'. 3536 NOTE: The assignment of algorithm identifiers in this document was 3537 done so that positive numbers were used for the first layer objects 3538 (COSE_Sign, COSE_Sign1, COSE_Encrypt, COSE_Encrypt0, COSE_Mac, and 3539 COSE_Mac0). Negative numbers were used for second layer objects 3540 (COSE_Signature and COSE_recipient). Expert reviewers should 3541 consider this practice, but are not expected to be restricted by this 3542 precedent. 3544 16.5. COSE Key Common Parameters Registry 3546 It is requested that IANA create a new registry entitled "COSE Key 3547 Common Parameters" registry. The registry is to be created as Expert 3548 Review Required. Guidelines for the experts is provided 3549 Section 16.11. It should be noted that in additional to the expert 3550 review, some portions of the registry require a specification, 3551 potentially on standards track, be supplied as well. 3553 The columns of the registry are: 3555 name This is a descriptive name that enables easier reference to the 3556 item. It is not used in the encoding. 3558 label The value to be used to identify this algorithm. Key map 3559 labels MUST be unique. The label can be a positive integer, a 3560 negative integer or a string. Integer values between 0 and 255 3561 and strings of length 1 are designated as Standards Track Document 3562 required. Integer values from 256 to 65535 and strings of length 3563 2 are designated as Specification Required. Integer values of 3564 greater than 65535 and strings of length greater than 2 are 3565 designated as expert review. Integer values in the range -1 to 3566 -65536 are used for key parameters specific to a single algorithm 3567 delegated to the "COSE Key Type Parameter Labels" registry. 3568 Integer values less than -65536 are marked as private use. 3570 CBOR Type This field contains the CBOR type for the field. 3572 registry This field denotes the registry that values come from, if 3573 one exists. 3575 description This field contains a brief description for the field. 3577 specification This contains a pointer to the public specification 3578 for the field if one exists 3580 This registry will be initially populated by the values in Table 3. 3581 The specification column for all of these entries will be this 3582 document. 3584 16.6. COSE Key Type Parameters Registry 3586 It is requested that IANA create a new registry "COSE Key Type 3587 Parameters". The registry is to be created as Expert Review 3588 Required. Expert review guidelines are provided in Section 16.11. 3590 The columns of the table are: 3592 key type This field contains a descriptive string of a key type. 3593 This should be a value that is in the COSE Key Common Parameters 3594 table and is placed in the 'kty' field of a COSE Key structure. 3596 name This is a descriptive name that enables easier reference to the 3597 item. It is not used in the encoding. 3599 label The label is to be unique for every value of key type. The 3600 range of values is from -256 to -1. Labels are expected to be 3601 reused for different keys. 3603 CBOR type This field contains the CBOR type for the field. 3605 description This field contains a brief description for the field. 3607 specification This contains a pointer to the public specification 3608 for the field if one exists. 3610 This registry will be initially populated by the values in Table 23, 3611 Table 24, and Table 25. The specification column for all of these 3612 entries will be this document. 3614 16.7. COSE Key Type Registry 3616 It is requested that IANA create a new registry "COSE Key Type 3617 Registry". The registry is to be created as Expert Review Required. 3618 Expert review guidelines are provided in Section 16.11. 3620 The columns of this table are: 3622 name This is a descriptive name that enables easier reference to the 3623 item. The name MUST be unique. It is not used in the encoding. 3625 value This is the value used to identify the curve. These values 3626 MUST be unique. The value can be a positive integer, a negative 3627 integer or a string. 3629 description This field contains a brief description of the curve. 3631 specification This contains a pointer to the public specification 3632 for the curve if one exists. 3634 This registry will be initially populated by the values in Table 21. 3635 The specification column for all of these entries will be this 3636 document. 3638 16.8. COSE Elliptic Curve Parameters Registry 3640 It is requested that IANA create a new registry "COSE Elliptic Curve 3641 Parameters". The registry is to be created as Expert Review 3642 Required. Guidelines for the experts is provided Section 16.11. It 3643 should be noted that in additional to the expert review, some 3644 portions of the registry require a specification, potentially on 3645 standards track, be supplied as well. 3647 The columns of the table are: 3649 name This is a descriptive name that enables easier reference to the 3650 item. It is not used in the encoding. 3652 value This is the value used to identify the curve. These values 3653 MUST be unique. The integer values from -256 to 255 are 3654 designated as Standards Track Document Required. The integer 3655 values from 256 to 65535 and -65536 to -257 are designated as 3656 Specification Required. Integer values over 65535 are designated 3657 as expert review. Integer values less than -65536 are marked as 3658 private use. 3660 key type This designates the key type(s) that can be used with this 3661 curve. 3663 description This field contains a brief description of the curve. 3665 specification This contains a pointer to the public specification 3666 for the curve if one exists. 3668 recommended: Does the IETF have a concensus recommendation to use 3669 the algorithm. The legal values are 'yes', 'no' and 'deprecated'. 3671 This registry will be initially populated by the values in Table 22. 3672 The specification column for all of these entries will be this 3673 document. The recommended column for all of the inital entries will 3674 be 'yes'. 3676 16.9. Media Type Registrations 3678 16.9.1. COSE Security Message 3680 This section registers the "application/cose" media type in the 3681 "Media Types" registry. These media types are used to indicate that 3682 the content is a COSE message. 3684 Type name: application 3686 Subtype name: cose 3688 Required parameters: N/A 3690 Optional parameters: cose-type 3691 Encoding considerations: binary 3693 Security considerations: See the Security Considerations section 3694 of RFC TBD. 3696 Interoperability considerations: N/A 3698 Published specification: RFC TBD 3700 Applications that use this media type: IoT applications sending 3701 security content over HTTP(S) transports. 3703 Fragment identifier considerations: N/A 3705 Additional information: 3707 * Magic number(s): N/A 3709 * File extension(s): cbor 3711 * Macintosh file type code(s): N/A 3713 Person & email address to contact for further information: 3714 iesg@ietf.org 3716 Intended usage: COMMON 3718 Restrictions on usage: N/A 3720 Author: Jim Schaad, ietf@augustcellars.com 3722 Change Controller: IESG 3724 Provisional registration? No 3726 16.9.2. COSE Key media type 3728 This section registers the "application/cose-key" and "application/ 3729 cose-key-set" media types in the "Media Types" registry. These media 3730 types are used to indicate, respectively, that content is a COSE_Key 3731 or COSE_KeySet object. 3733 The template for registering "application/cose-key" is: 3735 Type name: application 3737 Subtype name: cose-key 3738 Required parameters: N/A 3740 Optional parameters: N/A 3742 Encoding considerations: binary 3744 Security considerations: See the Security Considerations section 3745 of RFC TBD. 3747 Interoperability considerations: N/A 3749 Published specification: RFC TBD 3751 Applications that use this media type: Distribution of COSE based 3752 keys for IoT applications. 3754 Fragment identifier considerations: N/A 3756 Additional information: 3758 * Magic number(s): N/A 3760 * File extension(s): cbor 3762 * Macintosh file type code(s): N/A 3764 Person & email address to contact for further information: 3765 iesg@ietf.org 3767 Intended usage: COMMON 3769 Restrictions on usage: N/A 3771 Author: Jim Schaad, ietf@augustcellars.com 3773 Change Controller: IESG 3775 Provisional registration? No 3777 The template for registering "application/cose-key-set" is: 3779 Type name: application 3781 Subtype name: cose-key-set 3783 Required parameters: N/A 3785 Optional parameters: N/A 3786 Encoding considerations: binary 3788 Security considerations: See the Security Considerations section 3789 of RFC TBD. 3791 Interoperability considerations: N/A 3793 Published specification: RFC TBD 3795 Applications that use this media type: Distribution of COSE based 3796 keys for IoT applications. 3798 Fragment identifier considerations: N/A 3800 Additional information: 3802 * Magic number(s): N/A 3804 * File extension(s): cbor 3806 * Macintosh file type code(s): N/A 3808 Person & email address to contact for further information: 3809 iesg@ietf.org 3811 Intended usage: COMMON 3813 Restrictions on usage: N/A 3815 Author: Jim Schaad, ietf@augustcellars.com 3817 Change Controller: IESG 3819 Provisional registration? No 3821 16.10. CoAP Content-Format Registrations 3823 IANA is requested to add the following entries to the "CoAP Content- 3824 Format" registry. ID assignment in the 24-255 range is requested. 3826 +---------------------------------+----------+-------+--------------+ 3827 | Media Type | Encoding | ID | Reference | 3828 +---------------------------------+----------+-------+--------------+ 3829 | application/cose; cose-type | | TBD10 | [This | 3830 | ="cose-sign" | | | Document] | 3831 | | | | | 3832 | application/cose; cose-type | | TBD11 | [This | 3833 | ="cose-sign1" | | | Document] | 3834 | | | | | 3835 | application/cose; cose-type | | TBD12 | [This | 3836 | ="cose-encrypt" | | | Document] | 3837 | | | | | 3838 | application/cose; cose-type | | TBD13 | [This | 3839 | ="cose-encrypt0" | | | Document] | 3840 | | | | | 3841 | application/cose; cose-type | | TBD14 | [This | 3842 | ="cose-mac" | | | Document] | 3843 | | | | | 3844 | application/cose; cose-type | | TBD15 | [This | 3845 | ="cose-mac0" | | | Document] | 3846 | | | | | 3847 | application/cose-key | | TBD16 | [This | 3848 | | | | Document] | 3849 | | | | | 3850 | application/cose-key-set | | TBD17 | [This | 3851 | | | | Document | 3852 +---------------------------------+----------+-------+--------------+ 3854 Table 26 3856 16.11. Expert Review Instructions 3858 All of the IANA registries established in this document are defined 3859 as expert review. This section gives some general guidelines for 3860 what the experts should be looking for, but they are being designated 3861 as experts for a reason so they should be given substantial latitude. 3863 Expert reviewers should take into consideration the following points: 3865 o Point squatting should be discouraged. Reviewers are encouraged 3866 to get sufficient information for registration requests to ensure 3867 that the usage is not going to duplicate one that is already 3868 registered and that the point is likely to be used in deployments. 3869 The zones tagged as private use are intended for testing purposes 3870 and closed environments, code points in other ranges should not be 3871 assigned for testing. 3873 o Specifications are required for the standards track range of point 3874 assignment. Specifications should exist for specification 3875 required ranges, but early assignment before a specification is 3876 available is considered to be permissible. Specifications are 3877 needed for the first-come, first-serve range if they are expected 3878 to be used outside of closed environments in an interoperable way. 3879 When specifications are not provided, the description provided 3880 needs to have sufficient information to identify what the point is 3881 being used for. 3883 o Experts should take into account the expected usage of fields when 3884 approving point assignment. The fact that there is a range for 3885 standards track documents does not mean that a standards track 3886 document cannot have points assigned outside of that range. The 3887 length of the encoded value should be weighed against how many 3888 code points of that length are left, the size of device it will be 3889 used on, and the number of code points left that encode to that 3890 size. 3892 o When algorithms are registered, vanity registrations should be 3893 discouraged. One way to do this is to require registrations to 3894 provide additional documentation on security analysis of the 3895 algorithm. Another thing that should be considered is to request 3896 for an opinion on the algorithm from the Crypto Forum Research 3897 Group (CFRG). Algorithms that do not meet the security 3898 requirements of the community and the messages structures should 3899 not be registered. 3901 17. Implementation Status 3903 This section records the status of known implementations of the 3904 protocol defined by this specification at the time of posting of this 3905 Internet-Draft, and is based on a proposal described in [RFC7942]. 3906 The description of implementations in this section is intended to 3907 assist the IETF in its decision processes in progressing drafts to 3908 RFCs. Please note that the listing of any individual implementation 3909 here does not imply endorsement by the IETF. Furthermore, no effort 3910 has been spent to verify the information presented here that was 3911 supplied by IETF contributors. This is not intended as, and must not 3912 be construed to be, a catalog of available implementations or their 3913 features. Readers are advised to note that other implementations may 3914 exist. 3916 According to [RFC7942], "this will allow reviewers and working groups 3917 to assign due consideration to documents that have the benefit of 3918 running code, which may serve as evidence of valuable experimentation 3919 and feedback that have made the implemented protocols more mature. 3921 It is up to the individual working groups to use this information as 3922 they see fit". 3924 17.1. Author's Versions 3926 There are three different implementations that have been created by 3927 the author of the document both to create the examples that are 3928 included in the document and to validate the structures and 3929 methodology used in the design of COSE. 3931 Implementation Location: https://github.com/cose-wg 3933 Primary Maintainer: Jim Schaad 3935 Languages: There are three different languages that are currently 3936 supported: Java, C# and C. 3938 Cryptography: The Java and C# libraries use Bouncy Castle to 3939 provide the required cryptography. The C version uses OPENSSL 3940 Version 1.0 for the cryptography. 3942 Coverage: The libraries currently do not have full support for 3943 counter signatures of either variety. They do have support to 3944 allow for implicit algorithm support as they allow for the 3945 application to set attributes that are not to be sent in the 3946 message. 3948 Testing: All of the examples in the example library are generated 3949 by the C# library and then validated using the Java and C 3950 libraries. All three libraries have tests to allow for the 3951 creating of the same messages that are in the example library 3952 followed by validating them. These are not compared against the 3953 example library. The Java and C# libraries have unit testing 3954 included. Not all of the MUST statements in the document have 3955 been implemented as part of the libraries. One such statement is 3956 the requirement that unique labels be present. 3958 Licensing: Revised BSD License 3960 17.2. COSE Testing Library 3962 Implementation Location: https://github.com/cose-wg/Examples 3964 Primary Maintainer: Jim Schaad 3966 Description: A set of tests for the COSE library is provided as 3967 part of the implementation effort. Both success and fail tests 3968 have been provided. All of the examples in this document are part 3969 of this example set. 3971 Coverage: An attempt has been made to have test cases for every 3972 message type and algorithm in the document. Currently examples 3973 dealing with counter signatures, EdDSA, and ECDH with Curve24459 3974 and Goldilocks are missing. 3976 Licensing: Public Domain 3978 18. Security Considerations 3980 There are a number of security considerations that need to be taken 3981 into account by implementers of this specification. The security 3982 considerations that are specific to an individual algorithm are 3983 placed next to the description of the algorithm. While some 3984 considerations have been highlighted here, additional considerations 3985 may be found in the documents listed in the references. 3987 Implementations need to protect the private key material for any 3988 individuals. There are some cases in this document that need to be 3989 highlighted on this issue. 3991 o Using the same key for two different algorithms can leak 3992 information about the key. It is therefore recommended that keys 3993 be restricted to a single algorithm. 3995 o Use of 'direct' as a recipient algorithm combined with a second 3996 recipient algorithm, exposes the direct key to the second 3997 recipient. 3999 o Several of the algorithms in this document have limits on the 4000 number of times that a key can be used without leaking information 4001 about the key. 4003 The use of ECDH and direct plus KDF (with no key wrap) will not 4004 directly lead to the private key being leaked; the one way function 4005 of the KDF will prevent that. There is however, a different issue 4006 that needs to be addressed. Having two recipients requires that the 4007 CEK be shared between two recipients. The second recipient therefore 4008 has a CEK that was derived from material that can be used for the 4009 weak proof of origin. The second recipient could create a message 4010 using the same CEK and send it to the first recipient, the first 4011 recipient would, for either static-static ECDH or direct plus KDF, 4012 make an assumption that the CEK could be used for proof of origin 4013 even though it is from the wrong entity. If the key wrap step is 4014 added, then no proof of origin is implied and this is not an issue. 4016 Although it has been mentioned before, the use of a single key for 4017 multiple algorithms has been demonstrated in some cases to leak 4018 information about a key, provide for attackers to forge integrity 4019 tags, or gain information about encrypted content. Binding a key to 4020 a single algorithm prevents these problems. Key creators and key 4021 consumers are strongly encouraged not only to create new keys for 4022 each different algorithm, but to include that selection of algorithm 4023 in any distribution of key material and strictly enforce the matching 4024 of algorithms in the key structure to algorithms in the message 4025 structure. In addition to checking that algorithms are correct, the 4026 key form needs to be checked as well. Do not use an 'EC2' key where 4027 an 'OKP' key is expected. 4029 Before using a key for transmission, or before acting on information 4030 received, a trust decision on a key needs to be made. Is the data or 4031 action something that the entity associated with the key has a right 4032 to see or a right to request? A number of factors are associated 4033 with this trust decision. Some of the ones that are highlighted here 4034 are: 4036 o What are the permissions associated with the key owner? 4038 o Is the cryptographic algorithm acceptable in the current context? 4040 o Have the restrictions associated with the key, such as algorithm 4041 or freshness, been checked and are correct? 4043 o Is the request something that is reasonable, given the current 4044 state of the application? 4046 o Have any security considerations that are part of the message been 4047 enforced (as specified by the application or 'crit' parameter)? 4049 There are a large number of algorithms presented in this document 4050 that use nonce values. For all of the nonces defined in this 4051 document, there is some type of restriction on the nonce being a 4052 unique value either for a key or for some other conditions. In all 4053 of these cases, there is no known requirement on the nonce being both 4054 unique and unpredictable, under these circumstances it reasonable to 4055 use a counter for creation of the nonce. In cases where one wants 4056 the pattern of the nonce to be unpredictable as well as unique, one 4057 can use a key created for that purpose and encrypt the counter to 4058 produce the nonce value. 4060 One area that has been starting to get exposure is doing traffic 4061 analysis of encrypted messages based on the length of the message. 4062 This specification does not provide for a uniform method of providing 4063 padding as part of the message structure. An observer can 4064 distinguish between two different strings (for example, 'YES' and 4065 'NO') based on length for all of the content encryption algorithms 4066 that are defined in this document. This means that it is up to 4067 applications to document how content padding is to be done in order 4068 to prevent or discourage such analysis. (For example, the strings 4069 could be defined as 'YES' and 'NO '.) 4071 19. References 4073 19.1. Normative References 4075 [AES-GCM] Dworkin, M., "NIST Special Publication 800-38D: 4076 Recommendation for Block Cipher Modes of Operation: 4077 Galois/Counter Mode (GCM) and GMAC.", Nov 2007. 4079 [COAP.Formats] 4080 IANA, , "CoAP Content-Formats". 4082 [DSS] U.S. National Institute of Standards and Technology, 4083 "Digital Signature Standard (DSS)", July 2013. 4085 [I-D.irtf-cfrg-eddsa] 4086 Josefsson, S. and I. Liusvaara, "Edwards-curve Digital 4087 Signature Algorithm (EdDSA)", draft-irtf-cfrg-eddsa-08 4088 (work in progress), August 2016. 4090 [MAC] NiST, N., "FIPS PUB 113: Computer Data Authentication", 4091 May 1985. 4093 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 4094 Hashing for Message Authentication", RFC 2104, 4095 DOI 10.17487/RFC2104, February 1997, 4096 . 4098 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 4099 Requirement Levels", BCP 14, RFC 2119, 4100 DOI 10.17487/RFC2119, March 1997, 4101 . 4103 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 4104 (AES) Key Wrap Algorithm", RFC 3394, DOI 10.17487/RFC3394, 4105 September 2002, . 4107 [RFC3610] Whiting, D., Housley, R., and N. Ferguson, "Counter with 4108 CBC-MAC (CCM)", RFC 3610, DOI 10.17487/RFC3610, September 4109 2003, . 4111 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 4112 Key Derivation Function (HKDF)", RFC 5869, 4113 DOI 10.17487/RFC5869, May 2010, 4114 . 4116 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 4117 Curve Cryptography Algorithms", RFC 6090, 4118 DOI 10.17487/RFC6090, February 2011, 4119 . 4121 [RFC6979] Pornin, T., "Deterministic Usage of the Digital Signature 4122 Algorithm (DSA) and Elliptic Curve Digital Signature 4123 Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, August 4124 2013, . 4126 [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object 4127 Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, 4128 October 2013, . 4130 [RFC7539] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 4131 Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015, 4132 . 4134 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 4135 for Security", RFC 7748, DOI 10.17487/RFC7748, January 4136 2016, . 4138 [SEC1] Standards for Efficient Cryptography Group, "SEC 1: 4139 Elliptic Curve Cryptography", May 2009. 4141 19.2. Informative References 4143 [I-D.greevenbosch-appsawg-cbor-cddl] 4144 Vigano, C. and H. Birkholz, "CBOR data definition language 4145 (CDDL): a notational convention to express CBOR data 4146 structures", draft-greevenbosch-appsawg-cbor-cddl-09 (work 4147 in progress), September 2016. 4149 [I-D.moriarty-pkcs1] 4150 Moriarty, K., Kaliski, B., Jonsson, J., and A. Rusch, 4151 "PKCS #1 Version 2.2: RSA Cryptography Specifications", 4152 draft-moriarty-pkcs1-03 (work in progress), September 4153 2016. 4155 [I-D.moriarty-pkcs5-v2dot1] 4156 Moriarty, K., Kaliski, B., and A. Rusch, "PKCS #5: 4157 Password-Based Cryptography Specification Version 2.1", 4158 draft-moriarty-pkcs5-v2dot1-04 (work in progress), 4159 September 2016. 4161 [I-D.selander-ace-object-security] 4162 Selander, G., Mattsson, J., Palombini, F., and L. Seitz, 4163 "Object Security of CoAP (OSCOAP)", draft-selander-ace- 4164 object-security-05 (work in progress), July 2016. 4166 [PVSig] Brown, D. and D. Johnson, "Formal Security Proofs for a 4167 Signature Scheme with Partial Message Recover", February 4168 2000. 4170 [RFC2633] Ramsdell, B., Ed., "S/MIME Version 3 Message 4171 Specification", RFC 2633, DOI 10.17487/RFC2633, June 1999, 4172 . 4174 [RFC4231] Nystrom, M., "Identifiers and Test Vectors for HMAC-SHA- 4175 224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512", 4176 RFC 4231, DOI 10.17487/RFC4231, December 2005, 4177 . 4179 [RFC4262] Santesson, S., "X.509 Certificate Extension for Secure/ 4180 Multipurpose Internet Mail Extensions (S/MIME) 4181 Capabilities", RFC 4262, DOI 10.17487/RFC4262, December 4182 2005, . 4184 [RFC4493] Song, JH., Poovendran, R., Lee, J., and T. Iwata, "The 4185 AES-CMAC Algorithm", RFC 4493, DOI 10.17487/RFC4493, June 4186 2006, . 4188 [RFC4949] Shirey, R., "Internet Security Glossary, Version 2", 4189 FYI 36, RFC 4949, DOI 10.17487/RFC4949, August 2007, 4190 . 4192 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 4193 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 4194 . 4196 [RFC5480] Turner, S., Brown, D., Yiu, K., Housley, R., and T. Polk, 4197 "Elliptic Curve Cryptography Subject Public Key 4198 Information", RFC 5480, DOI 10.17487/RFC5480, March 2009, 4199 . 4201 [RFC5652] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70, 4202 RFC 5652, DOI 10.17487/RFC5652, September 2009, 4203 . 4205 [RFC5751] Ramsdell, B. and S. Turner, "Secure/Multipurpose Internet 4206 Mail Extensions (S/MIME) Version 3.2 Message 4207 Specification", RFC 5751, DOI 10.17487/RFC5751, January 4208 2010, . 4210 [RFC5752] Turner, S. and J. Schaad, "Multiple Signatures in 4211 Cryptographic Message Syntax (CMS)", RFC 5752, 4212 DOI 10.17487/RFC5752, January 2010, 4213 . 4215 [RFC5990] Randall, J., Kaliski, B., Brainard, J., and S. Turner, 4216 "Use of the RSA-KEM Key Transport Algorithm in the 4217 Cryptographic Message Syntax (CMS)", RFC 5990, 4218 DOI 10.17487/RFC5990, September 2010, 4219 . 4221 [RFC6151] Turner, S. and L. Chen, "Updated Security Considerations 4222 for the MD5 Message-Digest and the HMAC-MD5 Algorithms", 4223 RFC 6151, DOI 10.17487/RFC6151, March 2011, 4224 . 4226 [RFC6838] Freed, N., Klensin, J., and T. Hansen, "Media Type 4227 Specifications and Registration Procedures", BCP 13, 4228 RFC 6838, DOI 10.17487/RFC6838, January 2013, 4229 . 4231 [RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data 4232 Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 4233 2014, . 4235 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 4236 Application Protocol (CoAP)", RFC 7252, 4237 DOI 10.17487/RFC7252, June 2014, 4238 . 4240 [RFC7515] Jones, M., Bradley, J., and N. Sakimura, "JSON Web 4241 Signature (JWS)", RFC 7515, DOI 10.17487/RFC7515, May 4242 2015, . 4244 [RFC7516] Jones, M. and J. Hildebrand, "JSON Web Encryption (JWE)", 4245 RFC 7516, DOI 10.17487/RFC7516, May 2015, 4246 . 4248 [RFC7517] Jones, M., "JSON Web Key (JWK)", RFC 7517, 4249 DOI 10.17487/RFC7517, May 2015, 4250 . 4252 [RFC7518] Jones, M., "JSON Web Algorithms (JWA)", RFC 7518, 4253 DOI 10.17487/RFC7518, May 2015, 4254 . 4256 [RFC7942] Sheffer, Y. and A. Farrel, "Improving Awareness of Running 4257 Code: The Implementation Status Section", BCP 205, 4258 RFC 7942, DOI 10.17487/RFC7942, July 2016, 4259 . 4261 [SP800-56A] 4262 Barker, E., Chen, L., Roginsky, A., and M. Smid, "NIST 4263 Special Publication 800-56A: Recommendation for Pair-Wise 4264 Key Establishment Schemes Using Discrete Logarithm 4265 Cryptography", May 2013. 4267 [W3C.WebCrypto] 4268 Watson, M., "Web Cryptography API", July 2016. 4270 Appendix A. Making Mandatory Algorithm Header Optional 4272 There has been a portion of the working group who have expressed a 4273 strong desire to relax the rule that the algorithm identifier be 4274 required to appear in each level of a COSE object. There are two 4275 basic reasons that have been advanced to support this position. 4276 First, the resulting message will be smaller if the algorithm 4277 identifier is omitted from the most common messages in a CoAP 4278 environment. Second, there is a potential bug that will arise if 4279 full checking is not done correctly between the different places that 4280 an algorithm identifier could be placed (the message itself, an 4281 application statement, the key structure that the sender possesses 4282 and the key structure the recipient possesses). 4284 This appendix lays out how such a change can be made and the details 4285 that an application needs to specify in order to use this option. 4286 Two different sets of details are specified: Those needed to omit an 4287 algorithm identifier and those needed to use a variant on the counter 4288 signature attribute that contains no attributes about itself. 4290 A.1. Algorithm Identification 4292 In this section are laid out three sets of recommendations. The 4293 first set of recommendations apply to having an implicit algorithm 4294 identified for a single layer of a COSE object. The second set of 4295 recommendations apply to having multiple implicit algorithms 4296 identified for multiple layers of a COSE object. The third set of 4297 recommendations apply to having implicit algorithms for multiple COSE 4298 object constructs. 4300 RFC 2119 language is deliberately not used here. This specification 4301 can provide recommendations, but it cannot enforce them. 4303 This set of recommendations applies to the case where an application 4304 is distributing a fixed algorithm along with the key information for 4305 use in a single COSE object. This normally applies to the smallest 4306 of the COSE objects, specifically COSE_Sign1, COSE_Mac0, and 4307 COSE_Encrypt0, but could apply to the other structures as well. 4309 The following items should be taken into account: 4311 o Applications need to list the set of COSE structures that implicit 4312 algorithms are to be used in. Applications need to require that 4313 the receipt of an explicit algorithm identifier in one of these 4314 structures will lead to the message being rejected. This 4315 requirement is stated so that there will never be a case where 4316 there is any ambiguity about the question of which algorithm 4317 should be used, the implicit or the explicit one. This applies 4318 even if the transported algorithm identifier is a protected 4319 attribute. This applies even if the transported algorithm is the 4320 same as the implicit algorithm. 4322 o Applications need to define the set of information that is to be 4323 considered to be part of a context when omitting algorithm 4324 identifiers. At a minimum, this would be the key identifier (if 4325 needed), the key, the algorithm, and the COSE structure it is used 4326 with. Applications should restrict the use of a single key to a 4327 single algorithm. As noted for some of the algorithms in this 4328 document, the use of the same key in different related algorithms 4329 can lead to leakage of information about the key, leakage about 4330 the data or the ability to perform forgeries. 4332 o In many cases, applications that make the algorithm identifier 4333 implicit will also want to make the context identifier implicit 4334 for the same reason. That is, omitting the context identifier 4335 will decrease the message size (potentially significantly 4336 depending on the length of the identifier). Applications that do 4337 this will need to describe the circumstances where the context 4338 identifier is to be omitted and how the context identifier is to 4339 be inferred in these cases. (Exhaustive search over all of the 4340 keys would normally not be considered to be acceptable.) An 4341 example of how this can be done is to tie the context to a 4342 transaction identifier. Both would be sent on the original 4343 message, but only the transaction identifier would need to be sent 4344 after that point as the context is tied into the transaction 4345 identifier. Another way would be to associate a context with a 4346 network address. All messages coming from a single network 4347 address can be assumed to be associated with a specific context. 4348 (In this case the address would normally be distributed as part of 4349 the context.) 4351 o Applications cannot rely on key identifiers being unique unless 4352 they take significant efforts to ensure that they are computed in 4353 such a way as to create this guarantee. Even when an application 4354 does this, the uniqueness might be violated if the application is 4355 run in different contexts (i.e., with a different context 4356 provider) or if the system combines the security contexts from 4357 different applications together into a single store. 4359 o Applications should continue the practice of protecting the 4360 algorithm identifier. Since this is not done by placing it in the 4361 protected attributes field, applications should define an 4362 application specific external data structure that includes this 4363 value. This external data field can be used as such for content 4364 encryption, MAC, and signature algorithms. It can be used in the 4365 SuppPrivInfo field for those algorithms which use a KDF function 4366 to derive a key value. Applications may also want to protect 4367 other information that is part of the context structure as well. 4368 It should be noted that those fields, such as the key or a base 4369 IV, are protected by virtue of being used in the cryptographic 4370 computation and do not need to be included in the external data 4371 field. 4373 The second case is having multiple implicit algorithm identifiers 4374 specified for a multiple layer COSE object. An example of how this 4375 would work is the encryption context that an application specifies 4376 contains a content encryption algorithm, a key wrap algorithm, a key 4377 identifier, and a shared secret. The sender omits sending the 4378 algorithm identifier for both the content layer and the recipient 4379 layer leaving only the key identifier. The receiver then uses the 4380 key identifier to get the implicit algorithm identifiers. 4382 The following additional items need to be taken into consideration: 4384 o Applications that want to support this will need to define a 4385 structure that allows for, and clearly identifies, both the COSE 4386 structure to be used with a given key and the structure and 4387 algorithm to be used for the secondary layer. The key for the 4388 secondary layer is computed per normal from the recipient layer. 4390 The third case is having multiple implicit algorithm identifiers, but 4391 targeted at potentially unrelated layers or different COSE objects. 4393 There are a number of different scenarios where this might be 4394 applicable. Some of these scenarios are: 4396 o Two contexts are distributed as a pair. Each of the contexts is 4397 for use with a COSE_Encrypt message. Each context will consist of 4398 distinct secret keys and IVs and potentially even different 4399 algorithms. One context is for sending messages from party A to 4400 party B, the second context is for sending messages from party B 4401 to party A. This means that there is no chance for a reflection 4402 attack to occur as each party uses different secret keys to send 4403 its messages, a message that is reflected back to it would fail to 4404 decrypt. 4406 o Two contexts are distributed as a pair. The first context is used 4407 for encryption of the message; the second context is used to place 4408 a counter signature on the message. The intention is that the 4409 second context can be distributed to other entities independently 4410 of the first context. This allows these entities to validate that 4411 the message came from an individual without being able to decrypt 4412 the message and see the content. 4414 o Two contexts are distributed as a pair. The first context 4415 contains a key for dealing with MACed messages, the second context 4416 contains a key for dealing with encrypted messages. This allows 4417 for a unified distribution of keys to participants for different 4418 types of messages that have different keys, but where the keys may 4419 be used in coordinated manner. 4421 For these cases, the following additional items need to be 4422 considered: 4424 o Applications need to ensure that the multiple contexts stay 4425 associated. If one of the contexts is invalidated for any reason, 4426 all of the contexts associated with it should also be invalidated. 4428 A.2. Counter Signature Without Headers 4430 There is a group of people who want to have a counter signature 4431 parameter that is directly tied to the value being signed and thus 4432 the authenticated and unauthenticated buckets can be removed from the 4433 message being sent. The focus on this is an even smaller size, as 4434 all of the information on the process of creating the counter 4435 signature is implicit rather than being explicitly carried in the 4436 message. This includes not only the algorithm identifier as 4437 presented above, but also items such as the key identification is 4438 always external to the signature structure. This means that the 4439 entities that are doing the validation of the counter signature are 4440 required to infer which key is to be used from context rather than 4441 being explicit. One way of doing this would be to presume that all 4442 data coming from a specific port (or to a specific URL) is to be 4443 validated by a specific key. (Note that this does not require that 4444 the key identifier be part of the value signed as it does not serve a 4445 cryptographic purpose. If the key validates the counter signature, 4446 then it should be presumed that the entity associated with that key 4447 produced the signature.) 4449 When computing the signature for the bare counter signature header, 4450 the same Sig_structure defined in Section 4.4 is used. The 4451 sign_protected field is omitted, as there is no protected header 4452 field in in this counter signature header. The value of 4453 "CounterSignature0" is placed in the context field of the 4454 Sig_stucture. 4456 +-------------------+-------+--------+------------------------------+ 4457 | name | label | value | description | 4458 | | | type | | 4459 +-------------------+-------+--------+------------------------------+ 4460 | CounterSignature0 | 9 | bstr | Counter signature with | 4461 | | | | implied signer and headers | 4462 +-------------------+-------+--------+------------------------------+ 4464 Table 27 4466 Appendix B. Two Layers of Recipient Information 4468 All of the currently defined recipient algorithms classes only use 4469 two layers of the COSE_Encrypt structure. The first layer is the 4470 message content and the second layer is the content key encryption. 4471 However, if one uses a recipient algorithm such as RSA-KEM (see 4472 Appendix A of RSA-KEM [RFC5990]), then it makes sense to have three 4473 layers of the COSE_Encrypt structure. 4475 These layers would be: 4477 o Layer 0: The content encryption layer. This layer contains the 4478 payload of the message. 4480 o Layer 1: The encryption of the CEK by a KEK. 4482 o Layer 2: The encryption of a long random secret using an RSA key 4483 and a key derivation function to convert that secret into the KEK. 4485 This is an example of what a triple layer message would look like. 4486 The message has the following layers: 4488 o Layer 0: Has a content encrypted with AES-GCM using a 128-bit key. 4490 o Layer 1: Uses the AES Key wrap algorithm with a 128-bit key. 4492 o Layer 2: Uses ECDH Ephemeral-Static direct to generate the layer 1 4493 key. 4495 In effect, this example is a decomposed version of using the ECDH- 4496 ES+A128KW algorithm. 4498 Size of binary file is 184 bytes 4499 992( 4500 [ 4501 / protected / h'a10101' / { 4502 \ alg \ 1:1 \ AES-GCM 128 \ 4503 } / , 4504 / unprotected / { 4505 / iv / 5:h'02d1f7e6f26c43d4868d87ce' 4506 }, 4507 / ciphertext / h'64f84d913ba60a76070a9a48f26e97e863e2852948658f0 4508 811139868826e89218a75715b', 4509 / recipients / [ 4510 [ 4511 / protected / h'', 4512 / unprotected / { 4513 / alg / 1:-3 / A128KW / 4514 }, 4515 / ciphertext / h'dbd43c4e9d719c27c6275c67d628d493f090593db82 4516 18f11', 4517 / recipients / [ 4518 [ 4519 / protected / h'a1013818' / { 4520 \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ 4521 } / , 4522 / unprotected / { 4523 / ephemeral / -1:{ 4524 / kty / 1:2, 4525 / crv / -1:1, 4526 / x / -2:h'b2add44368ea6d641f9ca9af308b4079aeb519f11 4527 e9b8a55a600b21233e86e68', 4528 / y / -3:false 4529 }, 4530 / kid / 4:'meriadoc.brandybuck@buckland.example' 4531 }, 4532 / ciphertext / h'' 4533 ] 4534 ] 4535 ] 4536 ] 4537 ] 4538 ) 4540 Appendix C. Examples 4542 This appendix includes a set of examples that show the different 4543 features and message types that have been defined in this document. 4544 To make the examples easier to read, they are presented using the 4545 extended CBOR diagnostic notation (defined in 4546 [I-D.greevenbosch-appsawg-cbor-cddl]) rather than as a binary dump. 4548 A GitHub project has been created at https://github.com/cose-wg/ 4549 Examples that contains not only the examples presented in this 4550 document, but a more complete set of testing examples as well. Each 4551 example is found in a JSON file that contains the inputs used to 4552 create the example, some of the intermediate values that can be used 4553 in debugging the example and the output of the example presented in 4554 both a hex and a CBOR diagnostic notation format. Some of the 4555 examples at the site are designed failure testing cases; these are 4556 clearly marked as such in the JSON file. If errors in the examples 4557 in this document are found, the examples on github will be updated 4558 and a note to that effect will be placed in the JSON file. 4560 As noted, the examples are presented using the CBOR's diagnostic 4561 notation. A Ruby based tool exists that can convert between the 4562 diagnostic notation and binary. This tool can be installed with the 4563 command line: 4565 gem install cbor-diag 4567 The diagnostic notation can be converted into binary files using the 4568 following command line: 4570 diag2cbor.rb < inputfile > outputfile 4572 The examples can be extracted from the XML version of this document 4573 via an XPath expression as all of the artwork is tagged with the 4574 attribute type='CBORdiag'. (Depending on the XPath evaluator one is 4575 using, it may be necessary to deal with > as an entity.) 4577 //artwork[@type='CDDL']/text() 4579 C.1. Examples of Signed Message 4581 C.1.1. Single Signature 4583 This example uses the following: 4585 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4587 Size of binary file is 104 bytes 4588 991( 4589 [ 4590 / protected / h'', 4591 / unprotected / {}, 4592 / payload / 'This is the content.', 4593 / signatures / [ 4594 [ 4595 / protected / h'a10126' / { 4596 \ alg \ 1:-7 \ ECDSA 256 \ 4597 } / , 4598 / unprotected / { 4599 / kid / 4:'11' 4600 }, 4601 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5 4602 51ce5705b793914348e14eea4aee6e0c9f09db4ef3ddeca8f3506cd1a98a8fb64327 4603 be470355c9657ce0' 4604 ] 4605 ] 4606 ] 4607 ) 4609 C.1.2. Multiple Signers 4611 This example uses the following: 4613 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4615 o Signature Algorithm: ECDSA w/ SHA-512, Curve P-521 4617 Size of binary file is 278 bytes 4618 991( 4619 [ 4620 / protected / h'', 4621 / unprotected / {}, 4622 / payload / 'This is the content.', 4623 / signatures / [ 4624 [ 4625 / protected / h'a10126' / { 4626 \ alg \ 1:-7 \ ECDSA 256 \ 4627 } / , 4628 / unprotected / { 4629 / kid / 4:'11' 4630 }, 4631 / signature / h'0dc1c5e62719d8f3cce1468b7c881eee6a8088b46bf8 4632 36ae956dd38fe93199199951a6a5e02a24aed5edde3509748366b1c539aaef7dea34 4633 f2cd618fe19fe55d' 4634 ], 4635 [ 4636 / protected / h'a1013823' / { 4637 \ alg \ 1:-36 4638 } / , 4639 / unprotected / { 4640 / kid / 4:'bilbo.baggins@hobbiton.example' 4641 }, 4642 / signature / h'012ce5b1dfe8b5aa6eaa09a54c58a84ad0900e4fdf27 4643 59ec22d1c861cccd75c7e1c4025a2da35e512fc2874d6ac8fd862d09ad07ed2deac2 4644 97b897561e04a8d42476017c11a4a34e26c570c9eff22c1dc84d56cdf6e03ed34bc9 4645 e934c5fdf676c7948d79e97dfe161730217c57748aadb364a0207cee811e9dde65ae 4646 37942e8a8348cc91' 4647 ] 4648 ] 4649 ] 4650 ) 4652 C.1.3. Counter Signature 4654 This example uses the following: 4656 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4658 o The same parameters are used for both the signature and the 4659 counter signature. 4661 Size of binary file is 181 bytes 4662 991( 4663 [ 4664 / protected / h'', 4665 / unprotected / { 4666 / countersign / 7:[ 4667 / protected / h'a10126' / { 4668 \ alg \ 1:-7 \ ECDSA 256 \ 4669 } / , 4670 / unprotected / { 4671 / kid / 4:'11' 4672 }, 4673 / signature / h'c9d3402485aa585cee3efc69b14496c0b00714584b26 4674 0f8e05764b7dbc70ae2b23b89812f5895b805f07a792f7ce77ef6d63875dc37d6a78 4675 ef4d175da45c9a51' 4676 ] 4677 }, 4678 / payload / 'This is the content.', 4679 / signatures / [ 4680 [ 4681 / protected / h'a10126' / { 4682 \ alg \ 1:-7 \ ECDSA 256 \ 4683 } / , 4684 / unprotected / { 4685 / kid / 4:'11' 4686 }, 4687 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5 4688 51ce5705b793914348e14eea4aee6e0c9f09db4ef3ddeca8f3506cd1a98a8fb64327 4689 be470355c9657ce0' 4690 ] 4691 ] 4692 ] 4693 ) 4695 C.1.4. Signature w/ Criticality 4697 This example uses the following: 4699 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4701 o There is a criticality marker on the "reserved" header parameter 4703 Size of binary file is 126 bytes 4704 991( 4705 [ 4706 / protected / h'a2687265736572766564f40281687265736572766564' / 4707 { 4708 "reserved":false, 4709 \ crit \ 2:[ 4710 "reserved" 4711 ] 4712 } / , 4713 / unprotected / {}, 4714 / payload / 'This is the content.', 4715 / signatures / [ 4716 [ 4717 / protected / h'a10126' / { 4718 \ alg \ 1:-7 \ ECDSA 256 \ 4719 } / , 4720 / unprotected / { 4721 / kid / 4:'11' 4722 }, 4723 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5 4724 51ce5705b793914348e1ff259ead2c38d8a7d8a9c87c2ce534d762dab059773115a6 4725 176fa780e85b6b25' 4726 ] 4727 ] 4728 ] 4729 ) 4731 C.2. Single Signer Examples 4733 C.2.1. Single ECDSA signature 4735 This example uses the following: 4737 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4739 Size of binary file is 100 bytes 4740 997( 4741 [ 4742 / protected / h'a10126' / { 4743 \ alg \ 1:-7 \ ECDSA 256 \ 4744 } / , 4745 / unprotected / { 4746 / kid / 4:'11' 4747 }, 4748 / payload / 'This is the content.', 4749 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a551ce 4750 5705b793914348e19f43d6c6ba654472da301b645b293c9ba939295b97c4bdb84778 4751 2bff384c5794' 4752 ] 4753 ) 4755 C.3. Examples of Enveloped Messages 4757 C.3.1. Direct ECDH 4759 This example uses the following: 4761 o CEK: AES-GCM w/ 128-bit key 4763 o Recipient class: ECDH Ephemeral-Static, Curve P-256 4765 Size of binary file is 152 bytes 4766 992( 4767 [ 4768 / protected / h'a10101' / { 4769 \ alg \ 1:1 \ AES-GCM 128 \ 4770 } / , 4771 / unprotected / { 4772 / iv / 5:h'c9cf4df2fe6c632bf7886413' 4773 }, 4774 / ciphertext / h'7adbe2709ca818fb415f1e5df66f4e1a51053ba6d65a1a0 4775 c52a357da7a644b8070a151b0', 4776 / recipients / [ 4777 [ 4778 / protected / h'a1013818' / { 4779 \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ 4780 } / , 4781 / unprotected / { 4782 / ephemeral / -1:{ 4783 / kty / 1:2, 4784 / crv / -1:1, 4785 / x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf 4786 bf054e1c7b4d91d6280', 4787 / y / -3:true 4788 }, 4789 / kid / 4:'meriadoc.brandybuck@buckland.example' 4790 }, 4791 / ciphertext / h'' 4792 ] 4793 ] 4794 ] 4795 ) 4797 C.3.2. Direct plus Key Derivation 4799 This example uses the following: 4801 o CEK: AES-CCM w/128-bit key, truncate the tag to 64 bits 4803 o Recipient class: Use HKDF on a shared secret with the following 4804 implicit fields as part of the context. 4806 * salt: "aabbccddeeffgghh" 4808 * APU identity: "lighting-client" 4810 * APV identity: "lighting-server" 4812 * Supplementary Public Other: "Encryption Example 02" 4814 Size of binary file is 92 bytes 4816 992( 4817 [ 4818 / protected / h'a1010a' / { 4819 \ alg \ 1:10 \ AES-CCM-16-64-128 \ 4820 } / , 4821 / unprotected / { 4822 / iv / 5:h'89f52f65a1c580933b5261a76c' 4823 }, 4824 / ciphertext / h'753548a19b1307084ca7b2056924ed95f2e3b17006dfe93 4825 1b687b847', 4826 / recipients / [ 4827 [ 4828 / protected / h'a10129' / { 4829 \ alg \ 1:-10 4830 } / , 4831 / unprotected / { 4832 / salt / -20:'aabbccddeeffgghh', 4833 / kid / 4:'our-secret' 4834 }, 4835 / ciphertext / h'' 4836 ] 4837 ] 4838 ] 4839 ) 4841 C.3.3. Counter Signature on Encrypted Content 4843 This example uses the following: 4845 o CEK: AES-GCM w/ 128-bit key 4847 o Recipient class: ECDH Ephemeral-Static, Curve P-256 4849 Size of binary file is 327 bytes 4850 992( 4851 [ 4852 / protected / h'a10101' / { 4853 \ alg \ 1:1 \ AES-GCM 128 \ 4854 } / , 4855 / unprotected / { 4856 / iv / 5:h'c9cf4df2fe6c632bf7886413', 4857 / countersign / 7:[ 4858 / protected / h'a1013823' / { 4859 \ alg \ 1:-36 4860 } / , 4861 / unprotected / { 4862 / kid / 4:'bilbo.baggins@hobbiton.example' 4863 }, 4864 / signature / h'00aa98cbfd382610a375d046a275f30266e8d0faacb9 4865 069fde06e37825ae7825419c474f416ded0c8e3e7b55bff68f2a704135bdf99186f6 4866 6659461c8cf929cc7fb300f5e2b33c3b433655042ff719804ff73b0be3e988ecebc0 4867 c70ef6616996809c6eb59a918dbe0a5edb0d15137ece0aba2a0b0f68ad2631cb62f2 4868 ea4d7099804218b0' 4869 ] 4870 }, 4871 / ciphertext / h'7adbe2709ca818fb415f1e5df66f4e1a51053ba6d65a1a0 4872 c52a357da7a644b8070a151b0', 4873 / recipients / [ 4874 [ 4875 / protected / h'a1013818' / { 4876 \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ 4877 } / , 4878 / unprotected / { 4879 / ephemeral / -1:{ 4880 / kty / 1:2, 4881 / crv / -1:1, 4882 / x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf 4883 bf054e1c7b4d91d6280', 4884 / y / -3:true 4885 }, 4886 / kid / 4:'meriadoc.brandybuck@buckland.example' 4887 }, 4888 / ciphertext / h'' 4889 ] 4890 ] 4891 ] 4892 ) 4894 C.3.4. Encrypted Content with External Data 4896 This example uses the following: 4898 o CEK: AES-GCM w/ 128-bit key 4900 o Recipient class: ECDH static-Static, Curve P-256 with AES Key Wrap 4902 o Externally Supplied AAD: h'0011bbcc22dd44ee55ff660077' 4904 Size of binary file is 174 bytes 4906 992( 4907 [ 4908 / protected / h'a10101' / { 4909 \ alg \ 1:1 \ AES-GCM 128 \ 4910 } / , 4911 / unprotected / { 4912 / iv / 5:h'02d1f7e6f26c43d4868d87ce' 4913 }, 4914 / ciphertext / h'64f84d913ba60a76070a9a48f26e97e863e28529d8f5335 4915 e5f0165eee976b4a5f6c6f09d', 4916 / recipients / [ 4917 [ 4918 / protected / h'a101381f' / { 4919 \ alg \ 1:-32 \ ECHD-SS+A128KW \ 4920 } / , 4921 / unprotected / { 4922 / static kid / -3:'peregrin.took@tuckborough.example', 4923 / kid / 4:'meriadoc.brandybuck@buckland.example', 4924 / U nonce / -22:h'0101' 4925 }, 4926 / ciphertext / h'41e0d76f579dbd0d936a662d54d8582037de2e366fd 4927 e1c62' 4928 ] 4929 ] 4930 ] 4931 ) 4933 C.4. Examples of Encrypted Messages 4935 C.4.1. Simple Encrypted Message 4937 This example uses the following: 4939 o CEK: AES-CCM w/ 128-bit key and a 64-bit tag 4941 Size of binary file is 54 bytes 4942 993( 4943 [ 4944 / protected / h'a1010a' / { 4945 \ alg \ 1:10 \ AES-CCM-16-64-128 \ 4946 } / , 4947 / unprotected / { 4948 / iv / 5:h'89f52f65a1c580933b5261a78c' 4949 }, 4950 / ciphertext / h'5974e1b99a3a4cc09a659aa2e9e7fff161d38ce7edd5617 4951 388e77baf' 4952 ] 4953 ) 4955 C.4.2. Encrypted Message w/ a Partial IV 4957 This example uses the following: 4959 o CEK: AES-CCM w/ 128-bit key and a 64-bit tag 4961 o Prefix for IV is 89F52F65A1C580933B52 4963 Size of binary file is 43 bytes 4965 993( 4966 [ 4967 / protected / h'a1010a' / { 4968 \ alg \ 1:10 \ AES-CCM-16-64-128 \ 4969 } / , 4970 / unprotected / { 4971 / partial iv / 6:h'61a7' 4972 }, 4973 / ciphertext / h'252a8911d465c125b6764739700f0141ed09192da5c69e5 4974 33abf852b' 4975 ] 4976 ) 4978 C.5. Examples of MACed messages 4980 C.5.1. Shared Secret Direct MAC 4982 This example uses the following: 4984 o MAC: AES-CMAC, 256-bit key, truncated to 64 bits 4986 o Recipient class: direct shared secret 4988 Size of binary file is 58 bytes 4989 994( 4990 [ 4991 / protected / h'a1010f' / { 4992 \ alg \ 1:15 \ AES-CBC-MAC-256//64 \ 4993 } / , 4994 / unprotected / {}, 4995 / payload / 'This is the content.', 4996 / tag / h'9e1226ba1f81b848', 4997 / recipients / [ 4998 [ 4999 / protected / h'', 5000 / unprotected / { 5001 / alg / 1:-6 / direct /, 5002 / kid / 4:'our-secret' 5003 }, 5004 / ciphertext / h'' 5005 ] 5006 ] 5007 ] 5008 ) 5010 C.5.2. ECDH Direct MAC 5012 This example uses the following: 5014 o MAC: HMAC w/SHA-256, 256-bit key 5016 o Recipient class: ECDH key agreement, two static keys, HKDF w/ 5017 context structure 5019 Size of binary file is 215 bytes 5020 994( 5021 [ 5022 / protected / h'a10105' / { 5023 \ alg \ 1:5 \ HMAC 256//256 \ 5024 } / , 5025 / unprotected / {}, 5026 / payload / 'This is the content.', 5027 / tag / h'81a03448acd3d305376eaa11fb3fe416a955be2cbe7ec96f012c99 5028 4bc3f16a41', 5029 / recipients / [ 5030 [ 5031 / protected / h'a101381a' / { 5032 \ alg \ 1:-27 \ ECDH-SS + HKDF-256 \ 5033 } / , 5034 / unprotected / { 5035 / static kid / -3:'peregrin.took@tuckborough.example', 5036 / kid / 4:'meriadoc.brandybuck@buckland.example', 5037 / U nonce / -22:h'4d8553e7e74f3c6a3a9dd3ef286a8195cbf8a23d 5038 19558ccfec7d34b824f42d92bd06bd2c7f0271f0214e141fb779ae2856abf585a583 5039 68b017e7f2a9e5ce4db5' 5040 }, 5041 / ciphertext / h'' 5042 ] 5043 ] 5044 ] 5045 ) 5047 C.5.3. Wrapped MAC 5049 This example uses the following: 5051 o MAC: AES-MAC, 128-bit key, truncated to 64 bits 5053 o Recipient class: AES keywrap w/ a pre-shared 256-bit key 5055 Size of binary file is 110 bytes 5056 994( 5057 [ 5058 / protected / h'a1010e' / { 5059 \ alg \ 1:14 \ AES-CBC-MAC-128//64 \ 5060 } / , 5061 / unprotected / {}, 5062 / payload / 'This is the content.', 5063 / tag / h'36f5afaf0bab5d43', 5064 / recipients / [ 5065 [ 5066 / protected / h'', 5067 / unprotected / { 5068 / alg / 1:-5 / A256KW /, 5069 / kid / 4:'018c0ae5-4d9b-471b-bfd6-eef314bc7037' 5070 }, 5071 / ciphertext / h'711ab0dc2fc4585dce27effa6781c8093eba906f227 5072 b6eb0' 5073 ] 5074 ] 5075 ] 5076 ) 5078 C.5.4. Multi-recipient MACed message 5080 This example uses the following: 5082 o MAC: HMAC w/ SHA-256, 128-bit key 5084 o Recipient class: Uses three different methods 5086 1. ECDH Ephemeral-Static, Curve P-521, AES-Key Wrap w/ 128-bit 5087 key 5089 2. AES-Key Wrap w/ 256-bit key 5091 Size of binary file is 310 bytes 5092 994( 5093 [ 5094 / protected / h'a10105' / { 5095 \ alg \ 1:5 \ HMAC 256//256 \ 5096 } / , 5097 / unprotected / {}, 5098 / payload / 'This is the content.', 5099 / tag / h'bf48235e809b5c42e995f2b7d5fa13620e7ed834e337f6aa43df16 5100 1e49e9323e', 5101 / recipients / [ 5102 [ 5103 / protected / h'a101381c' / { 5104 \ alg \ 1:-29 \ ECHD-ES+A128KW \ 5105 } / , 5106 / unprotected / { 5107 / ephemeral / -1:{ 5108 / kty / 1:2, 5109 / crv / -1:3, 5110 / x / -2:h'0043b12669acac3fd27898ffba0bcd2e6c366d53bc4db 5111 71f909a759304acfb5e18cdc7ba0b13ff8c7636271a6924b1ac63c02688075b55ef2 5112 d613574e7dc242f79c3', 5113 / y / -3:true 5114 }, 5115 / kid / 4:'bilbo.baggins@hobbiton.example' 5116 }, 5117 / ciphertext / h'339bc4f79984cdc6b3e6ce5f315a4c7d2b0ac466fce 5118 a69e8c07dfbca5bb1f661bc5f8e0df9e3eff5' 5119 ], 5120 [ 5121 / protected / h'', 5122 / unprotected / { 5123 / alg / 1:-5 / A256KW /, 5124 / kid / 4:'018c0ae5-4d9b-471b-bfd6-eef314bc7037' 5125 }, 5126 / ciphertext / h'0b2c7cfce04e98276342d6476a7723c090dfdd15f9a 5127 518e7736549e998370695e6d6a83b4ae507bb' 5128 ] 5129 ] 5130 ] 5131 ) 5133 C.6. Examples of MAC0 messages 5135 C.6.1. Shared Secret Direct MAC 5137 This example uses the following: 5139 o MAC: AES-CMAC, 256-bit key, truncated to 64 bits 5140 o Recipient class: direct shared secret 5142 Size of binary file is 39 bytes 5144 996( 5145 [ 5146 / protected / h'a1010f' / { 5147 \ alg \ 1:15 \ AES-CBC-MAC-256//64 \ 5148 } / , 5149 / unprotected / {}, 5150 / payload / 'This is the content.', 5151 / tag / h'726043745027214f' 5152 ] 5153 ) 5155 Note that this example uses the same inputs as Appendix C.5.1. 5157 C.7. COSE Keys 5159 C.7.1. Public Keys 5161 This is an example of a COSE Key set. This example includes the 5162 public keys for all of the previous examples. 5164 In order the keys are: 5166 o An EC key with a kid of "meriadoc.brandybuck@buckland.example" 5168 o An EC key with a kid of "peregrin.took@tuckborough.example" 5170 o An EC key with a kid of "bilbo.baggins@hobbiton.example" 5172 o An EC key with a kid of "11" 5174 Size of binary file is 481 bytes 5176 [ 5177 { 5178 -1:1, 5179 -2:h'65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c0 5180 8551d', 5181 -3:h'1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd008 5182 4d19c', 5183 1:2, 5184 2:'meriadoc.brandybuck@buckland.example' 5185 }, 5186 { 5187 -1:1, 5188 -2:h'bac5b11cad8f99f9c72b05cf4b9e26d244dc189f745228255a219a86d6a 5189 09eff', 5190 -3:h'20138bf82dc1b6d562be0fa54ab7804a3a64b6d72ccfed6b6fb6ed28bbf 5191 c117e', 5192 1:2, 5193 2:'11' 5194 }, 5195 { 5196 -1:3, 5197 -2:h'0072992cb3ac08ecf3e5c63dedec0d51a8c1f79ef2f82f94f3c737bf5de 5198 7986671eac625fe8257bbd0394644caaa3aaf8f27a4585fbbcad0f2457620085e5c8 5199 f42ad', 5200 -3:h'01dca6947bce88bc5790485ac97427342bc35f887d86d65a089377e247e 5201 60baa55e4e8501e2ada5724ac51d6909008033ebc10ac999b9d7f5cc2519f3fe1ea1 5202 d9475', 5203 1:2, 5204 2:'bilbo.baggins@hobbiton.example' 5205 }, 5206 { 5207 -1:1, 5208 -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbfbf054e1c7b4d91 5209 d6280', 5210 -3:h'f01400b089867804b8e9fc96c3932161f1934f4223069170d924b7e03bf 5211 822bb', 5212 1:2, 5213 2:'peregrin.took@tuckborough.example' 5214 } 5215 ] 5217 C.7.2. Private Keys 5219 This is an example of a COSE Key set. This example includes the 5220 private keys for all of the previous examples. 5222 In order the keys are: 5224 o An EC key with a kid of "meriadoc.brandybuck@buckland.example" 5226 o A shared-secret key with a kid of "our-secret" 5228 o An EC key with a kid of "peregrin.took@tuckborough.example" 5230 o A shared-secret key with a kid of "018c0ae5-4d9b-471b- 5231 bfd6-eef314bc7037" 5233 o An EC key with a kid of "bilbo.baggins@hobbiton.example" 5235 o An EC key with a kid of "11" 5237 Size of binary file is 816 bytes 5239 [ 5240 { 5241 1:2, 5242 2:'meriadoc.brandybuck@buckland.example', 5243 -1:1, 5244 -2:h'65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c0 5245 8551d', 5246 -3:h'1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd008 5247 4d19c', 5248 -4:h'aff907c99f9ad3aae6c4cdf21122bce2bd68b5283e6907154ad911840fa 5249 208cf' 5250 }, 5251 { 5252 1:2, 5253 2:'11', 5254 -1:1, 5255 -2:h'bac5b11cad8f99f9c72b05cf4b9e26d244dc189f745228255a219a86d6a 5256 09eff', 5257 -3:h'20138bf82dc1b6d562be0fa54ab7804a3a64b6d72ccfed6b6fb6ed28bbf 5258 c117e', 5259 -4:h'57c92077664146e876760c9520d054aa93c3afb04e306705db609030850 5260 7b4d3' 5261 }, 5262 { 5263 1:2, 5264 2:'bilbo.baggins@hobbiton.example', 5265 -1:3, 5266 -2:h'0072992cb3ac08ecf3e5c63dedec0d51a8c1f79ef2f82f94f3c737bf5de 5267 7986671eac625fe8257bbd0394644caaa3aaf8f27a4585fbbcad0f2457620085e5c8 5268 f42ad', 5269 -3:h'01dca6947bce88bc5790485ac97427342bc35f887d86d65a089377e247e 5270 60baa55e4e8501e2ada5724ac51d6909008033ebc10ac999b9d7f5cc2519f3fe1ea1 5271 d9475', 5272 -4:h'00085138ddabf5ca975f5860f91a08e91d6d5f9a76ad4018766a476680b 5273 55cd339e8ab6c72b5facdb2a2a50ac25bd086647dd3e2e6e99e84ca2c3609fdf177f 5274 eb26d' 5275 }, 5276 { 5277 1:4, 5278 2:'our-secret', 5279 -1:h'849b57219dae48de646d07dbb533566e976686457c1491be3a76dcea6c4 5280 27188' 5281 }, 5282 { 5283 1:2, 5284 -1:1, 5285 2:'peregrin.took@tuckborough.example', 5286 -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbfbf054e1c7b4d91 5287 d6280', 5288 -3:h'f01400b089867804b8e9fc96c3932161f1934f4223069170d924b7e03bf 5289 822bb', 5290 -4:h'02d1f7e6f26c43d4868d87ceb2353161740aacf1f7163647984b522a848 5291 df1c3' 5292 }, 5293 { 5294 1:4, 5295 2:'our-secret2', 5296 -1:h'849b5786457c1491be3a76dcea6c4271' 5297 }, 5298 { 5299 1:4, 5300 2:'018c0ae5-4d9b-471b-bfd6-eef314bc7037', 5301 -1:h'849b57219dae48de646d07dbb533566e976686457c1491be3a76dcea6c4 5302 27188' 5303 } 5304 ] 5306 Acknowledgments 5308 This document is a product of the COSE working group of the IETF. 5310 The following individuals are to blame for getting me started on this 5311 project in the first place: Richard Barnes, Matt Miller, and Martin 5312 Thomson. 5314 The initial version of the draft was based to some degree on the 5315 outputs of the JOSE and S/MIME working groups. 5317 The following individuals provided input into the final form of the 5318 document: Carsten Bormann, John Bradley, Brain Campbell, Michael B. 5320 Jones, Ilari Liusvaara, Francesca Palombini, Goran Selander, and 5321 Ludwig Seitz. 5323 Author's Address 5325 Jim Schaad 5326 August Cellars 5328 Email: ietf@augustcellars.com