idnits 2.17.1 draft-ietf-cose-msg-18.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 743 has weird spacing: '...otected as de...' == Line 745 has weird spacing: '...otected as de...' == Line 747 has weird spacing: '...payload conta...' == Line 763 has weird spacing: '...natures is an...' == Line 778 has weird spacing: '...otected as de...' == (28 more instances...) -- The document date (September 10, 2016) is 2783 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Possible downref: Non-RFC (?) normative reference: ref. 'AES-GCM' -- Possible downref: Non-RFC (?) normative reference: ref. 'DSS' -- Possible downref: 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 ** Obsolete normative reference: RFC 7049 (Obsoleted by RFC 8949) ** Obsolete normative reference: RFC 7539 (Obsoleted by RFC 8439) -- Possible downref: Non-RFC (?) normative reference: ref. 'SEC1' == Outdated reference: A later version (-11) exists of draft-greevenbosch-appsawg-cbor-cddl-08 -- Obsolete informational reference (is this intentional?): RFC 2633 (Obsoleted by RFC 3851) -- Obsolete informational reference (is this intentional?): RFC 2898 (Obsoleted by RFC 8018) -- Obsolete informational reference (is this intentional?): RFC 3447 (Obsoleted by RFC 8017) -- 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: 7 errors (**), 0 flaws (~~), 8 warnings (==), 10 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 COSE Working Group J. Schaad 3 Internet-Draft August Cellars 4 Intended status: Standards Track September 10, 2016 5 Expires: March 14, 2017 7 CBOR Object Signing and Encryption (COSE) 8 draft-ietf-cose-msg-18 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 March 14, 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. Recipient Algorithm Classes . . . . . . . . . . . . . 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. Recipient Algorithm Classes . . . . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . . . . . . . 98 157 C.1. Examples of Signed Message . . . . . . . . . . . . . . . 99 158 C.1.1. Single Signature . . . . . . . . . . . . . . . . . . 99 159 C.1.2. Multiple Signers . . . . . . . . . . . . . . . . . . 100 160 C.1.3. Counter Signature . . . . . . . . . . . . . . . . . . 101 161 C.1.4. Signature w/ Criticality . . . . . . . . . . . . . . 102 162 C.2. Single Signer Examples . . . . . . . . . . . . . . . . . 103 163 C.2.1. Single ECDSA signature . . . . . . . . . . . . . . . 103 164 C.3. Examples of Enveloped Messages . . . . . . . . . . . . . 104 165 C.3.1. Direct ECDH . . . . . . . . . . . . . . . . . . . . . 104 166 C.3.2. Direct plus Key Derivation . . . . . . . . . . . . . 105 167 C.3.3. Counter Signature on Encrypted Content . . . . . . . 106 168 C.3.4. Encrypted Content with External Data . . . . . . . . 108 169 C.4. Examples of Encrypted Messages . . . . . . . . . . . . . 108 170 C.4.1. Simple Encrypted Message . . . . . . . . . . . . . . 108 171 C.4.2. Encrypted Message w/ a Partial IV . . . . . . . . . . 109 172 C.5. Examples of MACed messages . . . . . . . . . . . . . . . 109 173 C.5.1. Shared Secret Direct MAC . . . . . . . . . . . . . . 109 174 C.5.2. ECDH Direct MAC . . . . . . . . . . . . . . . . . . . 110 175 C.5.3. Wrapped MAC . . . . . . . . . . . . . . . . . . . . . 111 176 C.5.4. Multi-recipient MACed message . . . . . . . . . . . . 112 177 C.6. Examples of MAC0 messages . . . . . . . . . . . . . . . . 113 178 C.6.1. Shared Secret Direct MAC . . . . . . . . . . . . . . 113 179 C.7. COSE Keys . . . . . . . . . . . . . . . . . . . . . . . . 114 180 C.7.1. Public Keys . . . . . . . . . . . . . . . . . . . . . 114 181 C.7.2. Private Keys . . . . . . . . . . . . . . . . . . . . 115 182 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 117 183 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 118 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, 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 (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 currently is 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 As well as the prose description, a version of a CBOR grammar is 285 presented in CDDL. Since CDDL has not been published as an RFC, this 286 grammar may not work with the final version of CDDL. The CDDL 287 grammar is informational, the prose description is normative. 289 The collected CDDL can be extracted from the XML version of this 290 document via the following XPath expression below. (Depending on the 291 XPath evaluator one is using, it may be necessary to deal with > 292 as an entity.) 294 //artwork[@type='CDDL']/text() 296 CDDL expects the initial non-terminal symbol to be the first symbol 297 in the file. For this, reason the first fragment of CDDL is 298 presented here. 300 start = COSE_Messages / COSE_Key / COSE_KeySet / Internal_Types 302 ; This is defined to make the tool quieter: 303 Internal_Types = Sig_structure / Enc_structure / MAC_structure / 304 COSE_KDF_Context 306 The non-terminal Internal_Types is defined for dealing with the 307 automated validation tools used during the writing of this document. 308 It references those non-terminals that are used for security 309 computations, but are not emitted for transport. 311 1.4. CBOR Related Terminology 313 In JSON, maps are called objects and only have one kind of map key: a 314 string. In COSE, we use strings, negative integers and unsigned 315 integers as map keys. The integers are used for compactness of 316 encoding and easy comparison. The inclusion of strings allows for an 317 additional range of short encoded values to be used as well. Since 318 the word "key" is mainly used in its other meaning, as a 319 cryptographic key, we use the term "label" for this usage as a map 320 key. 322 The presence of a label in a COSE map which is not a string or an 323 integer is an error. Applications can either fail processing or 324 process messages with incorrect labels, however they MUST NOT create 325 messages with incorrect labels. 327 A CDDL grammar fragment is defined that defines the non-terminals 328 'label', as in the previous paragraph and 'values', which permits any 329 value to be used. 331 label = int / tstr 332 values = any 334 1.5. Document Terminology 336 In this document, we use the following terminology: 338 Byte is a synonym for octet. 340 Constrained Application Protocol (CoAP) is a specialized web transfer 341 protocol for use in constrained systems. It is defined in [RFC7252]. 343 Authenticated Encryption (AE) algorithms are those encryption 344 algorithms which provide an authentication check of the contents 345 algorithm with the encryption service. 347 Authenticated Encryption with Authenticated Data (AEAD) algorithms 348 provide the same content authentication service as AE algorithms, but 349 additionally provide for authentication of non-encrypted data as 350 well. 352 2. Basic COSE Structure 354 The COSE object structure is designed so that there can be a large 355 amount of common code when parsing and processing the different 356 security messages. All of the message structures are built on the 357 CBOR array type. The first three elements of the array always 358 contain the same information: 360 1. The set of protected header parameters wrapped in a bstr. 362 2. The set of unprotected header parameters as a map. 364 3. The content of the message. The content is either the plain text 365 or the cipher text as appropriate. The content may be detached, 366 but the location is still used. The content is wrapped in a bstr 367 when present and is a nil value when detached. 369 Elements after this point are dependent on the specific message type. 371 COSE messages are also built using the concept of using layers to 372 separate different types of cryptographic concepts. As an example of 373 how this works consider the COSE_Encrypt message (Section 5.1). This 374 message type is broken into two layers: the content layer and the 375 recipient layer. In the content layer, the plain text is encrypted 376 and information about the encrypted message are placed. In the 377 recipient layer, the content encryption key (CEK) is encrypted and 378 information about how it is encrypted for each recipient is placed. 379 A single layer version of the encryption message COSE_Encrypt0 380 (Section 5.2) is provided for cases where the CEK is pre-shared. 382 Identification of which type of message has been presented is done by 383 the following method: 385 1. The specific message type is known from the context. This may be 386 defined by a marker in the containing structure or by 387 restrictions specified by the application protocol. 389 2. The message type is identified by a CBOR tag. Messages with a 390 CBOR tag are known in this specification as tagged messages, 391 while those without the CBOR tag are known as untagged messages. 392 This document defines a CBOR tag for each of the message 393 structures. These tags can be found in Table 1. 395 3. When a COSE object is carried in a media type of application/ 396 cose, the optional parameter 'cose-type' can be used to identify 397 the embedded object. The parameter is OPTIONAL if the tagged 398 version of the structure is used. The parameter is REQUIRED if 399 the untagged version of the structure is used. The value to use 400 with the parameter for each of the structures can be found in 401 Table 1. 403 4. When a COSE object is carried as a CoAP payload, the CoAP 404 Content-Format Option can be used to identify the message 405 content. The CoAP Content-Format values can be found in 406 Table 26. The CBOR tag for the message structure is not required 407 as each security message is uniquely identified. 409 +-------+---------------+---------------+---------------------------+ 410 | CBOR | cose-type | Data Item | Semantics | 411 | Tag | | | | 412 +-------+---------------+---------------+---------------------------+ 413 | TBD1 | cose-sign | COSE_Sign | COSE Signed Data Object | 414 | | | | | 415 | TBD7 | cose-sign1 | COSE_Sign1 | COSE Single Signer Data | 416 | | | | Object | 417 | | | | | 418 | TBD2 | cose-encrypt | COSE_Encrypt | COSE Encrypted Data | 419 | | | | Object | 420 | | | | | 421 | TBD3 | cose-encrypt0 | COSE_Encrypt0 | COSE Single Recipient | 422 | | | | Encrypted Data Object | 423 | | | | | 424 | TBD4 | cose-mac | COSE_Mac | COSE Mac-ed Data Object | 425 | | | | | 426 | TBD6 | cose-mac0 | COSE_Mac0 | COSE Mac w/o Recipients | 427 | | | | Object | 428 +-------+---------------+---------------+---------------------------+ 430 Table 1: COSE Message Identification 432 The following CDDL fragment identifies all of the top messages 433 defined in this document. Separate non-terminals are defined for the 434 tagged and the untagged versions of the messages. 436 COSE_Messages = COSE_Untagged_Message / COSE_Tagged_Message 438 COSE_Untagged_Message = COSE_Sign / COSE_Sign1 / 439 COSE_Encrypt / COSE_Encrypt0 / 440 COSE_Mac / COSE_Mac0 442 COSE_Tagged_Message = COSE_Sign_Tagged / COSE_Sign1_Tagged / 443 COSE_Encrypt_Tagged / COSE_Encrypt0_Tagged / 444 COSE_Mac_Tagged / COSE_Mac0_Tagged 446 3. Header Parameters 448 The structure of COSE has been designed to have two buckets of 449 information that are not considered to be part of the payload itself, 450 but are used for holding information about content, algorithms, keys, 451 or evaluation hints for the processing of the layer. These two 452 buckets are available for use in all of the structures except for 453 keys. While these buckets are present, they may not all be usable in 454 all instances. For example, while the protected bucket is defined as 455 part of the recipient structure, some of the algorithms used for 456 recipient structures do not provide for authenticated data. If this 457 is the case, the protected bucket is left empty. 459 Both buckets are implemented as CBOR maps. The map key is a 'label' 460 (Section 1.4). The value portion is dependent on the definition for 461 the label. Both maps use the same set of label/value pairs. The 462 integer and string values for labels has been divided into several 463 sections with a standard range, a private range, and a range that is 464 dependent on the algorithm selected. The defined labels can be found 465 in the "COSE Header Parameters" IANA registry (Section 16.2). 467 Two buckets are provided for each layer: 469 protected: Contains parameters about the current layer that are to 470 be cryptographically protected. This bucket MUST be empty if it 471 is not going to be included in a cryptographic computation. This 472 bucket is encoded in the message as a binary object. This value 473 is obtained by CBOR encoding the protected map and wrapping it in 474 a bstr object. Senders SHOULD encode a zero length map as a zero 475 length string rather than as a zero length map (encoded as h'a0'). 476 The zero length binary encoding is preferred because it is both 477 shorter and the version used in the serialization structures for 478 cryptographic computation. After encoding the map, the value is 479 wrapped in the binary object. Recipients MUST accept both a zero 480 length binary value and a zero length map encoded in the binary 481 value. The wrapping allows for the encoding of the protected map 482 to be transported with a greater chance that it will not be 483 altered in transit. (Badly behaved intermediates could decode and 484 re-encode, but this will result in a failure to verify unless the 485 re-encoded byte string is identical to the decoded byte string.) 486 This avoids the problem of all parties needing to be able to do a 487 common canonical encoding. 489 unprotected: Contains parameters about the current layer that are 490 not cryptographically protected. 492 Only parameters that deal with the current layer are to be placed at 493 that layer. As an example of this, the parameter 'content type' 494 describes the content of the message being carried in the message. 495 As such, this parameter is placed only in the content layer and is 496 not placed in the recipient or signature layers. In principle, one 497 should be able to process any given layer without reference to any 498 other layer. With the exception of the COSE_Sign structure, the only 499 data that needs to cross layers is the cryptographic key. 501 The buckets are present in all of the security objects defined in 502 this document. The fields in order are the 'protected' bucket (as a 503 CBOR 'bstr' type) and then the 'unprotected' bucket (as a CBOR 'map' 504 type). The presence of both buckets is required. The parameters 505 that go into the buckets come from the IANA "COSE Header Parameters" 506 registry (Section 16.2). Some common parameters are defined in the 507 next section, but a number of parameters are defined throughout this 508 document. 510 Labels in each of the maps MUST be unique. When processing messages, 511 if a label appears multiple times, the message MUST be rejected as 512 malformed. Applications SHOULD perform the same checks that the same 513 label does not occur in both the protected and unprotected headers. 514 If the message is not rejected as malformed, attributes MUST be 515 obtained from the protected bucket before they are obtained from the 516 unprotected bucket. 518 The following CDDL fragment represents the two header buckets. A 519 group Headers is defined in CDDL that represents the two buckets in 520 which attributes are placed. This group is used to provide these two 521 fields consistently in all locations. A type is also defined which 522 represents the map of common headers. 524 Headers = ( 525 protected : empty_or_serialized_map, 526 unprotected : header_map 527 ) 529 header_map = { 530 Generic_Headers, 531 * label => values 532 } 534 empty_or_serialized_map = bstr .cbor header_map / bstr .size 0 536 3.1. Common COSE Headers Parameters 538 This section defines a set of common header parameters. A summary of 539 these parameters can be found in Table 2. This table should be 540 consulted to determine the value of label, and the type of the value. 542 The set of header parameters defined in this section are: 544 alg This parameter is used to indicate the algorithm used for the 545 security processing. This parameter MUST be present in the 546 COSE_Signature, COSE_Sign1, COSE_Encrypt, COSE_Encrypt0, COSE_Mac, 547 and COSE_Mac0 structures. When the algorithm supports 548 authenticating associated data, this parameter MUST be in the 549 protected header bucket. The value is taken from the "COSE 550 Algorithms" Registry (see Section 16.4). 552 crit The parameter is used to indicate which protected header labels 553 an application that is processing a message is required to 554 understand. Parameters defined in this document do not need to be 555 included as they should be understood by all implementations. 556 When present, this parameter MUST be placed in the protected 557 header bucket. The array MUST have at least one value in it. 558 Not all labels need to be included in the 'crit' parameter. The 559 rules for deciding which header labels are placed in the array 560 are: 562 * Integer labels in the range of 0 to 8 SHOULD be omitted. 564 * Integer labels in the range -1 to -128 can be omitted as they 565 are algorithm dependent. If an application can correctly 566 process an algorithm, it can be assumed that it will correctly 567 process all of the common parameters associated with that 568 algorithm. Integer labels in the range -129 to -65536 SHOULD 569 be included as these would be less common parameters that might 570 not be generally supported. 572 * Labels for parameters required for an application MAY be 573 omitted. Applications should have a statement if the label can 574 be omitted. 576 The header parameter values indicated by 'crit' can be processed 577 by either the security library code or by an application using a 578 security library; the only requirement is that the parameter is 579 processed. If the 'crit' value list includes a value for which 580 the parameter is not in the protected bucket, this is a fatal 581 error in processing the message. 583 content type This parameter is used to indicate the content type of 584 the data in the payload or cipher text fields. Integers are from 585 the "CoAP Content-Formats" IANA registry table. Text values 586 following the syntax of Content-Type defined in Section 5.1 of 587 [RFC2045] omitting the prefix string "Content-Type:". Leading and 588 trailing whitespace is also omitted. Textual content values along 589 with parameters and subparameters can be located using the IANA 590 "Media Types" registry. Applications SHOULD provide this 591 parameter if the content structure is potentially ambiguous. 593 kid This parameter identifies one piece of data that can be used as 594 input to find the needed cryptographic key. The value of this 595 parameter can be matched against the 'kid' member in a COSE_Key 596 structure. Other methods of key distribution can define an 597 equivalent field to be matched. Applications MUST NOT assume that 598 'kid' values are unique. There may be more than one key with the 599 same 'kid' value, so all of the keys may need to be checked to 600 find the correct one. The internal structure of 'kid' values is 601 not defined and cannot be relied on by applications. Key 602 identifier values are hints about which key to use. This is not a 603 security critical field. For this reason, it can be placed in the 604 unprotected headers bucket. 606 IV This parameter holds the Initialization Vector (IV) value. For 607 some symmetric encryption algorithms this may be referred to as a 608 nonce. As the IV is authenticated by the encryption process, it 609 can be placed in the unprotected header bucket. 611 Partial IV This parameter holds a part of the IV value. When using 612 the COSE_Encrypt0 structure, a portion of the IV can be part of 613 the context associated with the key. This field is used to carry 614 a value that causes the IV to be changed for each message. As the 615 IV is authenticated by the encryption process, this value can be 616 placed in the unprotected header bucket. The 'Initialization 617 Vector' and 'Partial Initialization Vector' parameters MUST NOT 618 both be present in the same security layer. 619 The message IV is generated by the following steps: 621 1. Left pad the partial IV with zeros to the length of IV. 623 2. XOR the padded partial IV with the context IV. 625 counter signature This parameter holds one or more counter signature 626 values. Counter signatures provide a method of having a second 627 party sign some data. The counter signature parameter can occur 628 as an unprotected attribute in any of the following structures: 629 COSE_Sign1, COSE_Signature, COSE_Encrypt, COSE_recipient, 630 COSE_Encrypt0, COSE_Mac and COSE_Mac0. These structures all have 631 the same beginning elements so that a consistent calculation of 632 the counter signature can be computed. Details on computing 633 counter signatures are found in Section 4.5. 635 +-----------+-------+----------------+-------------+----------------+ 636 | name | label | value type | value | description | 637 | | | | registry | | 638 +-----------+-------+----------------+-------------+----------------+ 639 | alg | 1 | int / tstr | COSE | Cryptographic | 640 | | | | Algorithms | algorithm to | 641 | | | | registry | use | 642 | | | | | | 643 | crit | 2 | [+ label] | COSE Header | Critical | 644 | | | | Labels | headers to be | 645 | | | | registry | understood | 646 | | | | | | 647 | content | 3 | tstr / uint | CoAP | Content type | 648 | type | | | Content- | of the payload | 649 | | | | Formats or | | 650 | | | | Media Types | | 651 | | | | registry | | 652 | | | | | | 653 | kid | 4 | bstr | | Key identifier | 654 | | | | | | 655 | IV | 5 | bstr | | Full | 656 | | | | | Initialization | 657 | | | | | Vector | 658 | | | | | | 659 | Partial | 6 | bstr | | Partial | 660 | IV | | | | Initialization | 661 | | | | | Vector | 662 | | | | | | 663 | counter | 7 | COSE_Signature | | CBOR encoded | 664 | signature | | / [+ | | signature | 665 | | | COSE_Signature | | structure | 666 | | | ] | | | 667 +-----------+-------+----------------+-------------+----------------+ 669 Table 2: Common Header Parameters 671 The CDDL fragment that represents the set of headers defined in this 672 section is given below. Each of the headers is tagged as optional 673 because they do not need to be in every map; headers required in 674 specific maps are discussed above. 676 Generic_Headers = ( 677 ? 1 => int / tstr, ; algorithm identifier 678 ? 2 => [+label], ; criticality 679 ? 3 => tstr / int, ; content type 680 ? 4 => bstr, ; key identifier 681 ? 5 => bstr, ; IV 682 ? 6 => bstr, ; Partial IV 683 ? 7 => COSE_Signature / [+COSE_Signature] ; Counter signature 684 ) 686 4. Signing Objects 688 COSE supports two different signature structures. COSE_Sign allows 689 for one or more signatures to be applied to the same content. 690 COSE_Sign1 is restricted to a single signer. The structures cannot 691 be converted between each other; as the signature computation 692 includes a parameter identifying which structure is being used, the 693 converted structure will fail signature validation. 695 4.1. Signing with One or More Signers 697 The COSE_Sign structure allows for one or more signatures to be 698 applied to a message payload. Parameters relating to the content and 699 parameters relating to the signature are carried along with the 700 signature itself. These parameters may be authenticated by the 701 signature, or just present. An example of a parameter about the 702 content is the content type. Examples of parameters about the 703 signature would be the algorithm and key used to create the signature 704 and counter signatures. 706 When more than one signature is present, the successful validation of 707 one signature associated with a given signer is usually treated as a 708 successful signature by that signer. However, there are some 709 application environments where other rules are needed. An 710 application that employs a rule other than one valid signature for 711 each signer must specify those rules. Also, where simple matching of 712 the signer identifier is not sufficient to determine whether the 713 signatures were generated by the same signer, the application 714 specification must describe how to determine which signatures were 715 generated by the same signer. Support for different communities of 716 recipients is the primary reason that signers choose to include more 717 than one signature. For example, the COSE_Sign structure might 718 include signatures generated with the Edwards Digital Signature 719 Algorithm (EdDSA) signature algorithm and with the Elliptic Curve 720 Digital Signature Algorithm (ECDSA) signature algorithm. This allows 721 recipients to verify the signature associated with one algorithm or 722 the other. (The original source of this text is [RFC5652].) More 723 detailed information on multiple signature evaluation can be found in 724 [RFC5752]. 726 The signature structure can be encoded either as tagged or untagged 727 depending on the context it will be used in. A tagged COSE_Sign 728 structure is identified by the CBOR tag TBD1. The CDDL fragment that 729 represents this is: 731 COSE_Sign_Tagged = #6.991(COSE_Sign) ; Replace 991 with TBD1 733 A COSE Signed Message is defined in two parts. The CBOR object that 734 carries the body and information about the body is called the 735 COSE_Sign structure. The CBOR object that carries the signature and 736 information about the signature is called the COSE_Signature 737 structure. Examples of COSE Signed Messages can be found in 738 Appendix C.1. 740 The COSE_Sign structure is a CBOR array. The fields of the array in 741 order are: 743 protected as described in Section 3. 745 unprotected as described in Section 3. 747 payload contains the serialized content to be signed. If the 748 payload is not present in the message, the application is required 749 to supply the payload separately. The payload is wrapped in a 750 bstr to ensure that it is transported without changes. If the 751 payload is transported separately ("detached content"), then a nil 752 CBOR object is placed in this location and it is the 753 responsibility of the application to ensure that it will be 754 transported without changes. 756 Note: When a signature with message recovery algorithm is used 757 (Section 8), the maximum number of bytes that can be recovered is 758 the length of the payload. The size of the payload is reduced by 759 the number of bytes that will be recovered. If all of the bytes 760 of the payload are consumed, then the payload is encoded as a zero 761 length binary string rather than as being absent. 763 signatures is an array of signatures. Each signature is represented 764 as a COSE_Signature structure. 766 The CDDL fragment that represents the above text for COSE_Sign 767 follows. 769 COSE_Sign = [ 770 Headers, 771 payload : bstr / nil, 772 signatures : [+ COSE_Signature] 773 ] 775 The COSE_Signature structure is a CBOR array. The fields of the 776 array in order are: 778 protected as described in Section 3. 780 unprotected as described in Section 3. 782 signature contains the computed signature value. The type of the 783 field is a bstr. 785 The CDDL fragment that represents the above text for COSE_Signature 786 follows. 788 COSE_Signature = [ 789 Headers, 790 signature : bstr 791 ] 793 4.2. Signing with One Signer 795 The COSE_Sign1 signature structure is used when only one signer is 796 going to be placed on a message. The parameters dealing with the 797 content and the signature are placed in the same pair of buckets 798 rather than having the separation of COSE_Sign. 800 The structure can be encoded either tagged or untagged depending on 801 the context it will be used in. A tagged COSE_Sign1 structure is 802 identified by the CBOR tag TBD7. The CDDL fragment that represents 803 this is: 805 COSE_Sign1_Tagged = #6.997(COSE_Sign1) ; Replace 997 with TBD7 807 The CBOR object that carries the body, the signature, and the 808 information about the body and signature is called the COSE_Sign1 809 structure. Examples of COSE_Sign1 messages can be found in 810 Appendix C.2. 812 The COSE_Sign1 structure is a CBOR array. The fields of the array in 813 order are: 815 protected as described in Section 3. 817 unprotected as described in Section 3. 819 payload as described in Section 4.1. 821 signature contains the computed signature value. The type of the 822 field is a bstr. 824 The CDDL fragment that represents the above text for COSE_Sign1 825 follows. 827 COSE_Sign1 = [ 828 Headers, 829 payload : bstr / nil, 830 signature : bstr 831 ] 833 4.3. Externally Supplied Data 835 One of the features supplied in the COSE document is the ability for 836 applications to provide additional data to be authenticated, but that 837 is not carried as part of the COSE object. The primary reason for 838 supporting this can be seen by looking at the CoAP message structure 839 [RFC7252], where the facility exists for options to be carried before 840 the payload. Examples of data that can be placed in this location 841 would be the CoAP code or CoAP options. If the data is in the header 842 section, then it is available for proxies to help in performing its 843 operations. For example, the Accept Option can be used by a proxy to 844 determine if an appropriate value is in the Proxy's cache. But the 845 sender can prevent a proxy from changing the set of values that it 846 will accept by including that value in the resulting authentication 847 tag. However, it may also be desired to protect these values so that 848 if they are modified in transit, it can be detected. 850 This document describes the process for using a byte array of 851 externally supplied authenticated data; however, the method of 852 constructing the byte array is a function of the application. 853 Applications that use this feature need to define how the externally 854 supplied authenticated data is to be constructed. Such a 855 construction needs to take into account the following issues: 857 o If multiple items are included, care needs to be taken that data 858 cannot bleed between the items. This is usually addressed by 859 making fields fixed width and/or encoding the length of the field. 860 Using options from CoAP [RFC7252] as an example, these fields use 861 a TLV structure so they can be concatenated without any problems. 863 o If multiple items are included, an order for the items needs to be 864 defined. Using options from CoAP as an example, an application 865 could state that the fields are to be ordered by the option 866 number. 868 o Applications need to ensure that the byte stream is going to be 869 the same on both sides. Using options from CoAP might give a 870 problem if the same relative numbering is kept. An intermediate 871 node could insert or remove an option, changing how the relative 872 number is done. An application would need to specify that the 873 relative number must be re-encoded to be relative only to the 874 options that are in the external data. 876 4.4. Signing and Verification Process 878 In order to create a signature, a well-defined byte stream is needed. 879 This algorithm takes in the body information (COSE_Sign or 880 COSE_Sign1), the signer information (COSE_Signature), and the 881 application data (external source). A CBOR array is used to 882 construct the byte stream. The fields of the array in order are: 884 1. A text string identifying the context of the signature. The 885 context string is: 887 "Signature" for signatures using the COSE_Signature structure. 889 "Signature1" for signatures using the COSE_Sign1 structure. 891 "CounterSignature" for signatures used as counter signature 892 attributes. 894 2. The protected attributes from the body structure encoded in a 895 bstr type. If there are no protected attributes, a bstr of 896 length zero is used. 898 3. The protected attributes from the signer structure encoded in a 899 bstr type. If there are no protected attributes, a bstr of 900 length zero is used. This field is omitted for the COSE_Sign1 901 signature structure. 903 4. The protected attributes from the application encoded in a bstr 904 type. If this field is not supplied, it defaults to a zero 905 length binary string. (See Section 4.3 for application guidance 906 on constructing this field.) 908 5. The payload to be signed encoded in a bstr type. The payload is 909 placed here independent of how it is transported. 911 The CDDL fragment that describes the above text is. 913 Sig_structure = [ 914 context : "Signature" / "Signature1" / "CounterSignature", 915 body_protected : empty_or_serialized_map, 916 ? sign_protected : empty_or_serialized_map, 917 external_aad : bstr, 918 payload : bstr 919 ] 921 How to compute a signature: 923 1. Create a Sig_structure and populate it with the appropriate 924 fields. 926 2. Create the value ToBeSigned by encoding the Sig_structure to a 927 byte string, using the encoding described in Section 14. 929 3. Call the signature creation algorithm passing in K (the key to 930 sign with), alg (the algorithm to sign with), and ToBeSigned (the 931 value to sign). 933 4. Place the resulting signature value in the 'signature' field of 934 the array. 936 The steps for verifying a signature are: 938 1. Create a Sig_structure object and populate it with the 939 appropriate fields. 941 2. Create the value ToBeSigned by encoding the Sig_structure to a 942 byte string, using the encoding described in Section 14. 944 3. Call the signature verification algorithm passing in K (the key 945 to verify with), alg (the algorithm used sign with), ToBeSigned 946 (the value to sign), and sig (the signature to be verified). 948 In addition to performing the signature verification, one must also 949 perform the appropriate checks to ensure that the key is correctly 950 paired with the signing identity and that the signing identity is 951 authorized before performing actions. 953 4.5. Computing Counter Signatures 955 Counter signatures provide a method of having a different signature 956 occur on some piece of content. This is normally used to provide a 957 signature on a signature allowing for a proof that a signature 958 existed at a given time (i.e., a Timestamp). In this document, we 959 allow for counter signatures to exist in a greater number of 960 environments. As an example, it is possible to place a counter 961 signature in the unprotected attributes of a COSE_Encrypt object. 962 This would allow for an intermediary to either verify that the 963 encrypted byte stream has not been modified, without being able to 964 decrypt it, or for the intermediary to assert that an encrypted byte 965 stream either existed at a given time or passed through it in terms 966 of routing (i.e., a proxy signature). 968 An example of a counter signature on a signature can be found in 969 Appendix C.1.3. An example of a counter signature in an encryption 970 object can be found in Appendix C.3.3. 972 The creation and validation of counter signatures over the different 973 items relies on the fact that the structure of the objects have the 974 same structure. The elements are a set of protected attributes, a 975 set of unprotected attributes, and a body, in that order. This means 976 that the Sig_structure can be used in a uniform manner to get the 977 byte stream for processing a signature. If the counter signature is 978 going to be computed over a COSE_Encrypt structure, the 979 body_protected and payload items can be mapped into the Sig_structure 980 in the same manner as from the COSE_Sign structure. 982 It should be noted that only a signature algorithm with appendix (see 983 Section 8) can be used for counter signatures. This is because the 984 body should be able to be processed without having to evaluate the 985 counter signature, and this is not possible for signature schemes 986 with message recovery. 988 5. Encryption Objects 990 COSE supports two different encryption structures. COSE_Encrypt0 is 991 used when a recipient structure is not needed because the key to be 992 used is known implicitly. COSE_Encrypt is used the rest of the time. 993 This includes cases where there are multiple recipients or a 994 recipient algorithm other than direct is used. 996 5.1. Enveloped COSE Structure 998 The enveloped structure allows for one or more recipients of a 999 message. There are provisions for parameters about the content and 1000 parameters about the recipient information to be carried in the 1001 message. The protected parameters associated with the content are 1002 authenticated by the content encryption algorithm. The protected 1003 parameters associated with the recipient are authenticated by the 1004 recipient algorithm (when the algorithm supports it). Examples of 1005 parameters about the content are the type of the content and the 1006 content encryption algorithm. Examples of parameters about the 1007 recipient are the recipient's key identifier and the recipient's 1008 encryption algorithm. 1010 The same techniques and structures are used for encrypting both the 1011 plain text and the keys. This is different from the approach used by 1012 both CMS [RFC5652] and JSON Web Encryption (JWE) [RFC7516] where 1013 different structures are used for the content layer and for the 1014 recipient layer. Two structures are defined: COSE_Encrypt to hold 1015 the encrypted content and COSE_recipient to hold the encrypted keys 1016 for recipients. Examples of encrypted messages can be found in 1017 Appendix C.3. 1019 The COSE_Encrypt structure can be encoded either tagged or untagged 1020 depending on the context it will be used in. A tagged COSE_Encrypt 1021 structure is identified by the CBOR tag TBD2. The CDDL fragment that 1022 represents this is: 1024 COSE_Encrypt_Tagged = #6.992(COSE_Encrypt) ; Replace 992 with TBD2 1026 The COSE_Encrypt structure is a CBOR array. The fields of the array 1027 in order are: 1029 protected as described in Section 3. 1031 unprotected as described in Section 3. ' 1033 ciphertext contains the cipher text encoded as a bstr. If the 1034 cipher text is to be transported independently of the control 1035 information about the encryption process (i.e., detached content) 1036 then the field is encoded as a nil value. 1038 recipients contains an array of recipient information structures. 1039 The type for the recipient information structure is a 1040 COSE_recipient. 1042 The CDDL fragment that corresponds to the above text is: 1044 COSE_Encrypt = [ 1045 Headers, 1046 ciphertext : bstr / nil, 1047 recipients : [+COSE_recipient] 1048 ] 1050 The COSE_recipient structure is a CBOR array. The fields of the 1051 array in order are: 1053 protected as described in Section 3. 1055 unprotected as described in Section 3. 1057 ciphertext contains the encrypted key encoded as a bstr. All 1058 encoded keys are symetric keys, the binary value of the key is the 1059 content. If there is not an encrypted key, then this field is 1060 encoded as a nil value. 1062 recipients contains an array of recipient information structures. 1063 The type for the recipient information structure is a 1064 COSE_recipient. (An example of this can be found in Appendix B.) 1065 If there are no recipient information structures, this element is 1066 absent. 1068 The CDDL fragment that corresponds to the above text for 1069 COSE_recipient is: 1071 COSE_recipient = [ 1072 Headers, 1073 ciphertext : bstr / nil, 1074 ? recipients : [+COSE_recipient] 1075 ] 1077 5.1.1. Recipient Algorithm Classes 1079 An encrypted message consists of an encrypted content and an 1080 encrypted CEK for one or more recipients. The CEK is encrypted for 1081 each recipient, using a key specific to that recipient. The details 1082 of this encryption depend on which class the recipient algorithm 1083 falls into. Specific details on each of the classes can be found in 1084 Section 12. A short summary of the five recipient algorithm classes 1085 is: 1087 direct: The CEK is the same as the identified previously distributed 1088 symmetric key or derived from a previously distributed secret. No 1089 CEK is transported in the message. 1091 symmetric key-encryption keys: The CEK is encrypted using a 1092 previously distributed symmetric KEK. 1094 key agreement: The recipient's public key and a sender's private key 1095 are used to generate a pairwise secret, a KDF is applied to derive 1096 a key, and then the CEK is either the derived key or encrypted by 1097 the derived key. 1099 key transport: The CEK is encrypted with the recipient's public key. 1100 No key transport algorithms are defined in this document. 1102 passwords: The CEK is encrypted in a KEK that is derived from a 1103 password. No password algorithms are defined in this document. 1105 5.2. Single Recipient Encrypted 1107 The COSE_Encrypt0 encrypted structure does not have the ability to 1108 specify recipients of the message. The structure assumes that the 1109 recipient of the object will already know the identity of the key to 1110 be used in order to decrypt the message. If a key needs to be 1111 identified to the recipient, the enveloped structure ought to be 1112 used. 1114 Examples of encrypted messages can be found in Appendix C.3. 1116 The COSE_Encrypt0 structure can be encoded either tagged or untagged 1117 depending on the context it will be used in. A tagged COSE_Encrypt0 1118 structure is identified by the CBOR tag TBD3. The CDDL fragment that 1119 represents this is: 1121 COSE_Encrypt0_Tagged = #6.993(COSE_Encrypt0) ; Replace 993 with TBD3 1123 The COSE_Encrypt structure is a CBOR array. The fields of the array 1124 in order are: 1126 protected as described in Section 3. 1128 unprotected as described in Section 3. 1130 ciphertext as described in Section 5.1. 1132 The CDDL fragment for COSE_Encrypt0 that corresponds to the above 1133 text is: 1135 COSE_Encrypt0 = [ 1136 Headers, 1137 ciphertext : bstr / nil, 1138 ] 1140 5.3. How to encrypt and decrypt for AEAD Algorithms 1142 The encryption algorithm for AEAD algorithms is fairly simple. The 1143 first step is to create a consistent byte stream for the 1144 authenticated data structure. For this purpose, we use a CBOR array. 1145 The fields of the array in order are: 1147 1. A text string identifying the context of the authenticated data 1148 structure. The context string is: 1150 "Encrypt0" for the content encryption of a COSE_Encrypt0 data 1151 structure. 1153 "Encrypt" for the first layer of a COSE_Encrypt data structure 1154 (i.e., for content encryption). 1156 "Enc_Recipient" for a recipient encoding to be placed in an 1157 COSE_Encrypt data structure. 1159 "Mac_Recipient" for a recipient encoding to be placed in a MACed 1160 message structure. 1162 "Rec_Recipient" for a recipient encoding to be placed in a 1163 recipient structure. 1165 2. The protected attributes from the body structure encoded in a 1166 bstr type. If there are no protected attributes, a bstr of 1167 length zero is used. 1169 3. The protected attributes from the application encoded in a bstr 1170 type. If this field is not supplied, it defaults to a zero 1171 length bstr. (See Section 4.3 for application guidance on 1172 constructing this field.) 1174 The CDDL fragment that describes the above text is: 1176 Enc_structure = [ 1177 context : "Encrypt" / "Encrypt0" / "Enc_Recipient" / 1178 "Mac_Recipient" / "Rec_Recipient", 1179 protected : empty_or_serialized_map, 1180 external_aad : bstr 1181 ] 1183 How to encrypt a message: 1185 1. Create an Enc_structure and populate it with the appropriate 1186 fields. 1188 2. Encode the Enc_structure to a byte stream (AAD), using the 1189 encoding described in Section 14. 1191 3. Determine the encryption key (K). This step is dependent on the 1192 class of recipient algorithm being used. For: 1194 No Recipients: The key to be used is determined by the algorithm 1195 and key at the current layer. Examples are key transport keys 1196 Section 12.3, key wrap keys Section 12.2.1 or pre-shared 1197 secrets. 1199 Direct Encryption and Direct Key Agreement: The key is 1200 determined by the key and algorithm in the recipient 1201 structure. The encryption algorithm and size of the key to be 1202 used are inputs into the KDF used for the recipient. (For 1203 direct, the KDF can be thought of as the identity operation.) 1204 Examples of these algorithms are found in Section 12.1.2 and 1205 Section 12.4.1. 1207 Other: The key is randomly generated. 1209 4. Call the encryption algorithm with K (the encryption key), P (the 1210 plain text) and AAD. Place the returned cipher text into the 1211 'ciphertext' field of the structure. 1213 5. For recipients of the message, recursively perform the encryption 1214 algorithm for that recipient, using K (the encryption key) as the 1215 plain text. 1217 How to decrypt a message: 1219 1. Create a Enc_structure and populate it with the appropriate 1220 fields. 1222 2. Encode the Enc_structure to a byte stream (AAD), using the 1223 encoding described in Section 14. 1225 3. Determine the decryption key. This step is dependent on the 1226 class of recipient algorithm being used. For: 1228 No Recipients: The key to be used is determined by the algorithm 1229 and key at the current layer. Examples are key transport keys 1230 Section 12.3, key wrap keys Section 12.2.1 or pre-shared 1231 secrets. 1233 Direct Encryption and Direct Key Agreement: The key is 1234 determined by the key and algorithm in the recipient 1235 structure. The encryption algorithm and size of the key to be 1236 used are inputs into the KDF used for the recipient. (For 1237 direct, the KDF can be thought of as the identity operation.) 1238 Examples of these algorithms are found in Section 12.1.2 and 1239 Section 12.4.1. 1241 Other: The key is determined by decoding and decrypting one of 1242 the recipient structures. 1244 4. Call the decryption algorithm with K (the decryption key to use), 1245 C (the cipher text) and AAD. 1247 5.4. How to encrypt and decrypt for AE Algorithms 1249 How to encrypt a message: 1251 1. Verify that the 'protected' field is empty. 1253 2. Verify that there was no external additional authenticated data 1254 supplied for this operation. 1256 3. Determine the encryption key. This step is dependent on the 1257 class of recipient algorithm being used. For: 1259 No Recipients: The key to be used is determined by the algorithm 1260 and key at the current layer. Examples are key transport keys 1261 Section 12.3, key wrap keys Section 12.2.1 or pre-shared 1262 secrets. 1264 Direct Encryption and Direct Key Agreement: The key is 1265 determined by the key and algorithm in the recipient 1266 structure. The encryption algorithm and size of the key to be 1267 used are inputs into the KDF used for the recipient. (For 1268 direct, the KDF can be thought of as the identity operation.) 1269 Examples of these algorithms are found in Section 12.1.2 and 1270 Section 12.4.1. 1272 Other: The key is randomly generated. 1274 4. Call the encryption algorithm with K (the encryption key to use) 1275 and the P (the plain text). Place the returned cipher text into 1276 the 'ciphertext' field of the structure. 1278 5. For recipients of the message, recursively perform the encryption 1279 algorithm for that recipient, using K (the encryption key) as the 1280 plain text. 1282 How to decrypt a message: 1284 1. Verify that the 'protected' field is empty. 1286 2. Verify that there was no external additional authenticated data 1287 supplied for this operation. 1289 3. Determine the decryption key. This step is dependent on the 1290 class of recipient algorithm being used. For: 1292 No Recipients: The key to be used is determined by the algorithm 1293 and key at the current layer. Examples are key transport keys 1294 Section 12.3, key wrap keys Section 12.2.1 or pre-shared 1295 secrets. 1297 Direct Encryption and Direct Key Agreement: The key is 1298 determined by the key and algorithm in the recipient 1299 structure. The encryption algorithm and size of the key to be 1300 used are inputs into the KDF used for the recipient. (For 1301 direct, the KDF can be thought of as the identity operation.) 1302 Examples of these algorithms are found in Section 12.1.2 and 1303 Section 12.4.1. 1305 Other: The key is determined by decoding and decrypting one of 1306 the recipient structures. 1308 4. Call the decryption algorithm with K (the decryption key to use), 1309 and C (the cipher text). 1311 6. MAC Objects 1313 COSE supports two different MAC structures. COSE_MAC0 is used when a 1314 recipient structure is not needed because the key to be used is 1315 implicitly known. COSE_MAC is used for all other cases. These 1316 include a requirement for multiple recipients, the key being unknown, 1317 and a recipient algorithm of other than direct. 1319 In this section, we describe the structure and methods to be used 1320 when doing MAC authentication in COSE. This document allows for the 1321 use of all of the same classes of recipient algorithms as are allowed 1322 for encryption. 1324 When using MAC operations, there are two modes in which they can be 1325 used. The first is just a check that the content has not been 1326 changed since the MAC was computed. Any class of recipient algorithm 1327 can be used for this purpose. The second mode is to both check that 1328 the content has not been changed since the MAC was computed, and to 1329 use the recipient algorithm to verify who sent it. The classes of 1330 recipient algorithms that support this are those that use a pre- 1331 shared secret or do static-static key agreement (without the key wrap 1332 step). In both of these cases, the entity that created and sent the 1333 message MAC can be validated. (This knowledge of sender assumes that 1334 there are only two parties involved and you did not send the message 1335 yourself.) The origination property can be obtained with both of the 1336 MAC message structures. 1338 6.1. MACed Message with Recipients 1340 The multiple recipient MACed message uses two structures, the 1341 COSE_Mac structure defined in this section for carrying the body and 1342 the COSE_recipient structure (Section 5.1) to hold the key used for 1343 the MAC computation. Examples of MACed messages can be found in 1344 Appendix C.5. 1346 The MAC structure can be encoded either tagged or untagged depending 1347 on the context it will be used in. A tagged COSE_Mac structure is 1348 identified by the CBOR tag TBD4. The CDDL fragment that represents 1349 this is: 1351 COSE_Mac_Tagged = #6.994(COSE_Mac) ; Replace 994 with TBD4 1353 The COSE_Mac structure is a CBOR array. The fields of the array in 1354 order are: 1356 protected as described in Section 3. 1358 unprotected as described in Section 3. 1360 payload contains the serialized content to be MACed. If the payload 1361 is not present in the message, the application is required to 1362 supply the payload separately. The payload is wrapped in a bstr 1363 to ensure that it is transported without changes. If the payload 1364 is transported separately (i.e., detached content), then a nil 1365 CBOR value is placed in this location and it is the responsibility 1366 of the application to ensure that it will be transported without 1367 changes. 1369 tag contains the MAC value. 1371 recipients as described in Section 5.1. 1373 The CDDL fragment that represents the above text for COSE_Mac 1374 follows. 1376 COSE_Mac = [ 1377 Headers, 1378 payload : bstr / nil, 1379 tag : bstr, 1380 recipients :[+COSE_recipient] 1381 ] 1383 6.2. MACed Messages with Implicit Key 1385 In this section, we describe the structure and methods to be used 1386 when doing MAC authentication for those cases where the recipient is 1387 implicitly known. 1389 The MACed message uses the COSE_Mac0 structure defined in this 1390 section for carrying the body. Examples of MACed messages with an 1391 implicit key can be found in Appendix C.6. 1393 The MAC structure can be encoded either tagged or untagged depending 1394 on the context it will be used in. A tagged COSE_Mac0 structure is 1395 identified by the CBOR tag TBD6. The CDDL fragment that represents 1396 this is: 1398 COSE_Mac0_Tagged = #6.996(COSE_Mac0) ; Replace 996 with TBD6 1400 The COSE_Mac0 structure is a CBOR array. The fields of the array in 1401 order are: 1403 protected as described in Section 3. 1405 unprotected as described in Section 3. 1407 payload as described in Section 6.1. 1409 tag contains the MAC value. 1411 The CDDL fragment that corresponds to the above text is: 1413 COSE_Mac0 = [ 1414 Headers, 1415 payload : bstr / nil, 1416 tag : bstr, 1417 ] 1419 6.3. How to compute and verify a MAC 1421 In order to get a consistent encoding of the data to be 1422 authenticated, the MAC_structure is used to have a canonical form. 1423 The MAC_structure is a CBOR array. The fields of the MAC_structure 1424 in order are: 1426 1. A text string that identifies the structure that is being 1427 encoded. This string is "MAC" for the COSE_Mac structure. This 1428 string is "MAC0" for the COSE_Mac0 structure. 1430 2. The protected attributes from the COSE_MAC structure. If there 1431 are no protected attributes, a zero length bstr is used. 1433 3. The protected attributes from the application encoded as a bstr 1434 type. If this field is not supplied, it defaults to a zero 1435 length binary string. (See Section 4.3 for application guidance 1436 on constructing this field.) 1438 4. The payload to be MAC-ed encoded in a bstr type. The payload is 1439 placed here independent of how it is transported. 1441 The CDDL fragment that corresponds to the above text is: 1443 MAC_structure = [ 1444 context : "MAC" / "MAC0", 1445 protected : empty_or_serialized_map, 1446 external_aad : bstr, 1447 payload : bstr 1448 ] 1450 The steps to compute a MAC are: 1452 1. Create a MAC_structure and populate it with the appropriate 1453 fields. 1455 2. Create the value ToBeMaced by encoding the MAC_structure to a 1456 byte stream, using the encoding described in Section 14. 1458 3. Call the MAC creation algorithm passing in K (the key to use), 1459 alg (the algorithm to MAC with) and ToBeMaced (the value to 1460 compute the MAC on). 1462 4. Place the resulting MAC in the 'tag' field of the COSE_Mac or 1463 COSE_Mac0 structure. 1465 5. Encrypt and encode the MAC key for each recipient of the message. 1467 The steps to verify a MAC are: 1469 1. Create a MAC_structure object and populate it with the 1470 appropriate 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. Obtain the cryptographic key from one of the recipients of the 1476 message. 1478 4. Call the MAC creation algorithm passing in K (the key to use), 1479 alg (the algorithm to MAC with) and ToBeMaced (the value to 1480 compute the MAC on). 1482 5. Compare the MAC value to the 'tag' field of the COSE_Mac or 1483 COSE_Mac0 structure. 1485 7. Key Objects 1487 A COSE Key structure is built on a CBOR map object. The set of 1488 common parameters that can appear in a COSE Key can be found in the 1489 IANA "COSE Key Common Parameters" registry (Section 16.5). 1490 Additional parameters defined for specific key types can be found in 1491 the IANA "COSE Key Type Parameters" registry (Section 16.6). 1493 A COSE Key Set uses a CBOR array object as its underlying type. The 1494 values of the array elements are COSE Keys. A Key Set MUST have at 1495 least one element in the array. Examples of Key Sets can be found in 1496 Appendix C.7. 1498 Each element in a key set MUST be processed independently. If one 1499 element in a key set is either malformed or uses a key that is not 1500 understood by an application, that key is ignored and the other keys 1501 are processed normally. 1503 The element "kty" is a required element in a COSE_Key map. 1505 The CDDL grammar describing COSE_Key and COSE_KeySet is: 1507 COSE_Key = { 1508 1 => tstr / int, ; kty 1509 ? 2 => bstr, ; kid 1510 ? 3 => tstr / int, ; alg 1511 ? 4 => [+ (tstr / int) ], ; key_ops 1512 ? 5 => bstr, ; Base IV 1513 * label => values 1514 } 1516 COSE_KeySet = [+COSE_Key] 1518 7.1. COSE Key Common Parameters 1520 This document defines a set of common parameters for a COSE Key 1521 object. Table 3 provides a summary of the parameters defined in this 1522 section. There are also parameters that are defined for specific key 1523 types. Key type specific parameters can be found in Section 13. 1525 +---------+-------+----------------+------------+-------------------+ 1526 | name | label | CBOR type | registry | description | 1527 +---------+-------+----------------+------------+-------------------+ 1528 | kty | 1 | tstr / int | COSE Key | Identification of | 1529 | | | | Common | the key type | 1530 | | | | Parameters | | 1531 | | | | | | 1532 | alg | 3 | tstr / int | COSE | Key usage | 1533 | | | | Algorithm | restriction to | 1534 | | | | Values | this algorithm | 1535 | | | | | | 1536 | kid | 2 | bstr | | Key | 1537 | | | | | Identification | 1538 | | | | | value - match to | 1539 | | | | | kid in message | 1540 | | | | | | 1541 | key_ops | 4 | [+ (tstr/int)] | | Restrict set of | 1542 | | | | | permissible | 1543 | | | | | operations | 1544 | | | | | | 1545 | Base IV | 5 | bstr | | Base IV to be | 1546 | | | | | xor-ed with | 1547 | | | | | Partial IVs | 1548 +---------+-------+----------------+------------+-------------------+ 1550 Table 3: Key Map Labels 1552 kty: This parameter is used to identify the family of keys for this 1553 structure, and thus the set of key type specific parameters to be 1554 found. The set of values defined in this document can be found in 1555 Table 21. This parameter MUST be present in a key object. 1556 Implementations MUST verify that the key type is appropriate for 1557 the algorithm being processed. The key type MUST be included as 1558 part of the trust decision process. 1560 alg: This parameter is used to restrict the algorithm that is used 1561 with the key. If this parameter is present in the key structure, 1562 the application MUST verify that this algorithm matches the 1563 algorithm for which the key is being used. If the algorithms do 1564 not match, then this key object MUST NOT be used to perform the 1565 cryptographic operation. Note that the same key can be in a 1566 different key structure with a different or no algorithm 1567 specified, however this is considered to be a poor security 1568 practice. 1570 kid: This parameter is used to give an identifier for a key. The 1571 identifier is not structured and can be anything from a user 1572 provided string to a value computed on the public portion of the 1573 key. This field is intended for matching against a 'kid' 1574 parameter in a message in order to filter down the set of keys 1575 that need to be checked. 1577 key_ops: This parameter is defined to restrict the set of operations 1578 that a key is to be used for. The value of the field is an array 1579 of values from Table 4. Algorithms define the values of key ops 1580 that are permitted to appear and are required for specific 1581 operations. 1583 Base IV: This parameter is defined to carry the base portion of an 1584 IV. It is designed to be used with the partial IV header 1585 parameter defined in Section 3.1. This field provides the ability 1586 to associate a partial IV with a key that is then modified on a 1587 per message basis with the partial IV. 1589 Extreme care needs to be taken when using a Base IV in an 1590 application. Many encryption algorithms lose security if the same 1591 IV is used twice. 1593 If different keys are derived for each sender, starting at the 1594 same base IV is likely to satisfy this condition. If the same key 1595 is used for multiple senders, then the application needs to 1596 provide for a method of dividing the IV space up between the 1597 senders. This could be done by providing a different base point 1598 to start from or a different partial IV to start with and 1599 restricting the number of messages to be sent before re-keying. 1601 +---------+-------+-------------------------------------------------+ 1602 | name | value | description | 1603 +---------+-------+-------------------------------------------------+ 1604 | sign | 1 | The key is used to create signatures. Requires | 1605 | | | private key fields. | 1606 | | | | 1607 | verify | 2 | The key is used for verification of signatures. | 1608 | | | | 1609 | encrypt | 3 | The key is used for key transport encryption. | 1610 | | | | 1611 | decrypt | 4 | The key is used for key transport decryption. | 1612 | | | Requires private key fields. | 1613 | | | | 1614 | wrap | 5 | The key is used for key wrapping. | 1615 | key | | | 1616 | | | | 1617 | unwrap | 6 | The key is used for key unwrapping. Requires | 1618 | key | | private key fields. | 1619 | | | | 1620 | derive | 7 | The key is used for deriving keys. Requires | 1621 | key | | private key fields. | 1622 | | | | 1623 | derive | 8 | The key is used for deriving bits. Requires | 1624 | bits | | private key fields. | 1625 | | | | 1626 | MAC | 9 | The key is used for creating MACs. | 1627 | create | | | 1628 | | | | 1629 | MAC | 10 | The key is used for validating MACs. | 1630 | verify | | | 1631 +---------+-------+-------------------------------------------------+ 1633 Table 4: Key Operation Values 1635 8. Signature Algorithms 1637 There are two signature algorithm schemes. The first is signature 1638 with appendix. In this scheme, the message content is processed and 1639 a signature is produced, the signature is called the appendix. This 1640 is the scheme used by algorithms such as ECDSA and RSASSA-PSS. (In 1641 fact the SSA in RSASSA-PSS stands for Signature Scheme with 1642 Appendix.) 1644 The signature functions for this scheme are: 1646 signature = Sign(message content, key) 1648 valid = Verification(message content, key, signature) 1649 The second scheme is signature with message recovery. (An example of 1650 such an algorithm is [PVSig].) In this scheme, the message content 1651 is processed, but part of it is included in the signature. Moving 1652 bytes of the message content into the signature allows for smaller 1653 signatures, the signature size is still potentially large, but the 1654 message content has shrunk. This has implications for systems 1655 implementing these algorithms and for applications that use them. 1656 The first is that the message content is not fully available until 1657 after a signature has been validated. Until that point the part of 1658 the message contained inside of the signature is unrecoverable. The 1659 second is that the security analysis of the strength of the signature 1660 is very much based on the structure of the message content. Messages 1661 that are highly predictable require additional randomness to be 1662 supplied as part of the signature process. In the worst case, it 1663 becomes the same as doing a signature with appendix. Finally, in the 1664 event that multiple signatures are applied to a message, all of the 1665 signature algorithms are going to be required to consume the same 1666 number of bytes of message content. This means that mixing of the 1667 different schemes in a single message is not supported, and if a 1668 recovery signature scheme is used, then the same amount of content 1669 needs to be consumed by all of the signatures. 1671 The signature functions for this scheme are: 1673 signature, message sent = Sign(message content, key) 1675 valid, message content = Verification(message sent, key, signature) 1677 Signature algorithms are used with the COSE_Signature and COSE_Sign1 1678 structures. At this time, only signatures with appendixes are 1679 defined for use with COSE, however considerable interest has been 1680 expressed in using a signature with message recovery algorithm due to 1681 the effective size reduction that is possible. Implementations will 1682 need to keep this in mind for later possible integration. 1684 8.1. ECDSA 1686 ECDSA [DSS] defines a signature algorithm using ECC. 1688 The ECDSA signature algorithm is parameterized with a hash function 1689 (h). In the event that the length of the hash function output is 1690 greater than the group of the key, the left-most bytes of the hash 1691 output are used. 1693 The algorithms defined in this document can be found in Table 5. 1695 +-------+-------+---------+------------------+ 1696 | name | value | hash | description | 1697 +-------+-------+---------+------------------+ 1698 | ES256 | -7 | SHA-256 | ECDSA w/ SHA-256 | 1699 | | | | | 1700 | ES384 | -35 | SHA-384 | ECDSA w/ SHA-384 | 1701 | | | | | 1702 | ES512 | -36 | SHA-512 | ECDSA w/ SHA-512 | 1703 +-------+-------+---------+------------------+ 1705 Table 5: ECDSA Algorithm Values 1707 This document defines ECDSA to work only with the curves P-256, P-384 1708 and P-521. This document requires that the curves be encoded using 1709 the 'EC2' key type. Implementations need to check that the key type 1710 and curve are correct when creating and verifying a signature. Other 1711 documents can define it to work with other curves and points in the 1712 future. 1714 In order to promote interoperability, it is suggested that SHA-256 be 1715 used only with curve P-256, SHA-384 be used only with curve P-384 and 1716 SHA-512 be used with curve P-521. This is aligned with the 1717 recommendation in Section 4 of [RFC5480]. 1719 The signature algorithm results in a pair of integers (R, S). These 1720 integers will the same length as length of the key used for the 1721 signature process. The signature is encoded by converting the 1722 integers into byte strings of the same length as the key size. The 1723 length is rounded up to the nearest byte and is left padded with zero 1724 bits to get to the correct length. The two integers are then 1725 concatenated together to form a byte string that is the resulting 1726 signature. 1728 Using the function defined in [RFC3447] the signature is: 1729 Signature = I2OSP(R, n) | I2OSP(S, n) 1730 where n = ceiling(key_length / 8) 1732 When using a COSE key for this algorithm, the following checks are 1733 made: 1735 o The 'kty' field MUST be present and it MUST be 'EC2'. 1737 o If the 'alg' field is present, it MUST match the ECDSA signature 1738 algorithm being used. 1740 o If the 'key_ops' field is present, it MUST include 'sign' when 1741 creating an ECDSA signature. 1743 o If the 'key_ops' field is present, it MUST include 'verify' when 1744 verifying an ECDSA signature. 1746 8.1.1. Security Considerations 1748 The security strength of the signature is no greater than the minimum 1749 of the security strength associated with the bit length of the key 1750 and the security strength of the hash function. 1752 Systems that have poor random number generation can leak their keys 1753 by signing two different messages with the same value 'k' (the per- 1754 message random value). [RFC6979] provides a method to deal with this 1755 problem by making 'k' be deterministic based on the message content 1756 rather than randomly generated. Applications that specify ECDSA 1757 should evaluate the ability to get good random number generation and 1758 require deterministic signatures where poor random number generation 1759 exists. 1761 Note: Use of this technique is a good idea even when good random 1762 number generation exists. Doing so both reduces the possibility of 1763 having the same value of 'k' in two signature operations and allows 1764 for reproducible signature values, which helps testing. 1766 There are two substitution attacks that can theoretically be mounted 1767 against the ECDSA signature algorithm. 1769 o Changing the curve used to validate the signature: If one changes 1770 the curve used to validate the signature, then potentially one 1771 could have a two messages with the same signature each computed 1772 under a different curve. The only requirement on the new curve is 1773 that its order be the same as the old one and it be acceptable to 1774 the client. An example would be to change from using the curve 1775 secp256r1 (aka P-256) to using secp256k1. (Both are 256 bit 1776 curves.) We current do not have any way to deal with this version 1777 of the attack except to restrict the overall set of curves that 1778 can be used. 1780 o Change the hash function used to validate the signature: If one 1781 has either two different hash functions of the same length, or one 1782 can truncate a hash function down, then one could potentially find 1783 collisions between the hash functions rather than within a single 1784 hash function. (For example, truncating SHA-512 to 256 bits might 1785 collide with a SHA-256 bit hash value.) As the hash algorithm is 1786 part of the signature algorithm identifier, this attack is 1787 mitigated by including signature algorithm identifier in the 1788 protected header. 1790 8.2. Edwards-curve Digital Signature Algorithms (EdDSA) 1792 [I-D.irtf-cfrg-eddsa] describes the elliptic curve signature scheme 1793 Edwards-curve Digital Signature Algorithm (EdDSA). In that document, 1794 the signature algorithm is instantiated using parameters for 1795 edwards25519 and edwards448 curves. The document additionally 1796 describes two variants of the EdDSA algorithm: Pure EdDSA, where no 1797 hash function is applied to the content before signing and, HashEdDSA 1798 where a hash function is applied to the content before signing and 1799 the result of that hash function is signed. For the EdDSA, the 1800 content to be signed (either the message or the pre-hash value) is 1801 processed twice inside of the signature algorithm. For use with 1802 COSE, only the pure EdDSA version is used. This is because it is not 1803 expected that extremely large contents are going to be needed and, 1804 based on the arrangement of the message structure, the entire message 1805 is going to need to be held in memory in order to create or verify a 1806 signature. This means that there does not appear to be a need to be 1807 able to do block updates of the hash, followed by eliminating the 1808 message from memory. Applications can provide the same features by 1809 defining the content of the message as a hash value and transporting 1810 the COSE object (with the hash value) and the content as separate 1811 items. 1813 The algorithms defined in this document can be found in Table 6. A 1814 single signature algorithm is defined, which can be used for multiple 1815 curves. 1817 +-------+-------+-------------+ 1818 | name | value | description | 1819 +-------+-------+-------------+ 1820 | EdDSA | -8 | EdDSA | 1821 +-------+-------+-------------+ 1823 Table 6: EdDSA Algorithm Values 1825 [I-D.irtf-cfrg-eddsa] describes the method of encoding the signature 1826 value. 1828 When using a COSE key for this algorithm the following checks are 1829 made: 1831 o The 'kty' field MUST be present and it MUST be 'OKP'. 1833 o The 'crv' field MUST be present, and it MUST be a curve defined 1834 for this signature algorithm. 1836 o If the 'alg' field is present, it MUST match 'EdDSA'. 1838 o If the 'key_ops' field is present, it MUST include 'sign' when 1839 creating an EdDSA signature. 1841 o If the 'key_ops' field is present, it MUST include 'verify' when 1842 verifying an EdDSA signature. 1844 8.2.1. Security Considerations 1846 The Edwards curves for EdDSA and ECDH are distinct and should not be 1847 used for the other algorithm. 1849 If batch signature verification is performed, a well-seeded 1850 cryptographic random number generator is REQUIRED. Signing and non- 1851 batch signature verification are deterministic operations and do not 1852 need random numbers of any kind. 1854 9. Message Authentication (MAC) Algorithms 1856 Message Authentication Codes (MACs) provide data authentication and 1857 integrity protection. They provide either no or very limited data 1858 origination. A MAC, for example, be used to prove the identity of 1859 the sender to a third party. 1861 MACs use the same scheme as signature with appendix algorithms. The 1862 message content is processed and an authentication code is produced. 1863 The authentication code is frequently called a tag. 1865 The MAC functions are: 1867 tag = MAC_Create(message content, key) 1869 valid = MAC_Verify(message content, key, tag) 1871 MAC algorithms can be based on either a block cipher algorithm (i.e., 1872 AES-MAC) or a hash algorithm (i.e., HMAC). This document defines a 1873 MAC algorithm using each of these constructions. 1875 MAC algorithms are used in the COSE_Mac and COSE_Mac0 structures. 1877 9.1. Hash-based Message Authentication Codes (HMAC) 1879 The Hash-based Message Authentication Code algorithm (HMAC) 1880 [RFC2104][RFC4231] was designed to deal with length extension 1881 attacks. The algorithm was also designed to allow for new hash 1882 algorithms to be directly plugged in without changes to the hash 1883 function. The HMAC design process has been shown as solid since, 1884 while the security of hash algorithms such as MD5 has decreased over 1885 time, the security of HMAC combined with MD5 has not yet been shown 1886 to be compromised [RFC6151]. 1888 The HMAC algorithm is parameterized by an inner and outer padding, a 1889 hash function (h), and an authentication tag value length. For this 1890 specification, the inner and outer padding are fixed to the values 1891 set in [RFC2104]. The length of the authentication tag corresponds 1892 to the difficulty of producing a forgery. For use in constrained 1893 environments, we define a set of HMAC algorithms that are truncated. 1894 There are currently no known issues with truncation, however the 1895 security strength of the message tag is correspondingly reduced in 1896 strength. When truncating, the left-most tag length bits are kept 1897 and transmitted. 1899 The algorithms defined in this document can be found in Table 7. 1901 +-----------+-------+---------+----------+--------------------------+ 1902 | name | value | Hash | Tag | description | 1903 | | | | Length | | 1904 +-----------+-------+---------+----------+--------------------------+ 1905 | HMAC | 4 | SHA-256 | 64 | HMAC w/ SHA-256 | 1906 | 256/64 | | | | truncated to 64 bits | 1907 | | | | | | 1908 | HMAC | 5 | SHA-256 | 256 | HMAC w/ SHA-256 | 1909 | 256/256 | | | | | 1910 | | | | | | 1911 | HMAC | 6 | SHA-384 | 384 | HMAC w/ SHA-384 | 1912 | 384/384 | | | | | 1913 | | | | | | 1914 | HMAC | 7 | SHA-512 | 512 | HMAC w/ SHA-512 | 1915 | 512/512 | | | | | 1916 +-----------+-------+---------+----------+--------------------------+ 1918 Table 7: HMAC Algorithm Values 1920 Some recipient algorithms carry the key while others derive a key 1921 from secret data. For those algorithms that carry the key (such as 1922 AES-KeyWrap), the size of the HMAC key SHOULD be the same size as the 1923 underlying hash function. For those algorithms that derive the key 1924 (such as ECDH), the derived key MUST be the same size as the 1925 underlying hash function. 1927 When using a COSE key for this algorithm, the following checks are 1928 made: 1930 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 1932 o If the 'alg' field is present, it MUST match the HMAC algorithm 1933 being used. 1935 o If the 'key_ops' field is present, it MUST include 'MAC create' 1936 when creating an HMAC authentication tag. 1938 o If the 'key_ops' field is present, it MUST include 'MAC verify' 1939 when verifying an HMAC authentication tag. 1941 Implementations creating and validating MAC values MUST validate that 1942 the key type, key length, and algorithm are correct and appropriate 1943 for the entities involved. 1945 9.1.1. Security Considerations 1947 HMAC has proved to be resistant to attack even when used with 1948 weakened hash algorithms. The current best known attack appears is 1949 to brute force the key. This means that key size is going to be 1950 directly related to the security of an HMAC operation. 1952 9.2. AES Message Authentication Code (AES-CBC-MAC) 1954 AES-CBC-MAC is defined in [MAC]. (Note this is not the same 1955 algorithm as AES-CMAC [RFC4493]). 1957 AES-CBC-MAC is parameterized by the key length, the authentication 1958 tag length and the IV used. For all of these algorithms, the IV is 1959 fixed to all zeros. We provide an array of algorithms for various 1960 key lengths and tag lengths. The algorithms defined in this document 1961 are found in Table 8. 1963 +-------------+-------+----------+----------+-----------------------+ 1964 | name | value | key | tag | description | 1965 | | | length | length | | 1966 +-------------+-------+----------+----------+-----------------------+ 1967 | AES-MAC | 14 | 128 | 64 | AES-MAC 128 bit key, | 1968 | 128/64 | | | | 64-bit tag | 1969 | | | | | | 1970 | AES-MAC | 15 | 256 | 64 | AES-MAC 256 bit key, | 1971 | 256/64 | | | | 64-bit tag | 1972 | | | | | | 1973 | AES-MAC | 25 | 128 | 128 | AES-MAC 128 bit key, | 1974 | 128/128 | | | | 128-bit tag | 1975 | | | | | | 1976 | AES-MAC | 26 | 256 | 128 | AES-MAC 256 bit key, | 1977 | 256/128 | | | | 128-bit tag | 1978 +-------------+-------+----------+----------+-----------------------+ 1980 Table 8: AES-MAC Algorithm Values 1982 Keys may be obtained either from a key structure or from a recipient 1983 structure. Implementations creating and validating MAC values MUST 1984 validate that the key type, key length and algorithm are correct and 1985 appropriate for the entities involved. 1987 When using a COSE key for this algorithm, the following checks are 1988 made: 1990 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 1992 o If the 'alg' field is present, it MUST match the AES-MAC algorithm 1993 being used. 1995 o If the 'key_ops' field is present, it MUST include 'MAC create' 1996 when creating an AES-MAC authentication tag. 1998 o If the 'key_ops' field is present, it MUST include 'MAC verify' 1999 when verifying an AES-MAC authentication tag. 2001 9.2.1. Security Considerations 2003 A number of attacks exist against CBC-MAC that need to be considered. 2004 - 2006 o A single key must only be used for messages of a fixed and known 2007 length. If this is not the case, an attacker will be able to 2008 generate a message with a valid tag given two message and tag 2009 pairs. This can be addressed by using different keys for 2010 different length messages. The current structure mitigates this 2011 problem, as a specific encoding structure that includes lengths is 2012 built and signed. (CMAC also addresses this issue.) 2014 o When using CBC mode, if the same key is used for both encryption 2015 and authentication operations, an attacker can produce messages 2016 with a valid authentication code. 2018 o If the IV can be modified, then messages can be forged. This is 2019 addressed by fixing the IV to all zeros. 2021 10. Content Encryption Algorithms 2023 Content Encryption Algorithms provide data confidentiality for 2024 potentially large blocks of data using a symmetric key. They provide 2025 integrity on the data that was encrypted, however they provide either 2026 no or very limited data origination. (One cannot, for example, be 2027 used to prove the identity of the sender to a third party.) The 2028 ability to provide data origination is linked to how the CEK is 2029 obtained. 2031 COSE restricts the set of legal content encryption algorithms to 2032 those that support authentication both of the content and additional 2033 data. The encryption process will generate some type of 2034 authentication value, but that value may be either explicit or 2035 implicit in terms of the algorithm definition. For simplicity sake, 2036 the authentication code will normally be defined as being appended to 2037 the cipher text stream. The encryption functions are: 2039 ciphertext = Encrypt(message content, key, additional data) 2041 valid, message content = Decrypt(cipher text, key, additional data) 2043 Most AEAD algorithms are logically defined as returning the message 2044 content only if the decryption is valid. Many but not all 2045 implementations will follow this convention. The message content 2046 MUST NOT be used if the decryption does not validate. 2048 These algorithms are used in COSE_Encrypt and COSE_Encrypt0. 2050 10.1. AES GCM 2052 The GCM mode is a generic authenticated encryption block cipher mode 2053 defined in [AES-GCM]. The GCM mode is combined with the AES block 2054 encryption algorithm to define an AEAD cipher. 2056 The GCM mode is parameterized by the size of the authentication tag 2057 and the size of the nonce. This document fixes the size of the nonce 2058 at 96 bits. The size of the authentication tag is limited to a small 2059 set of values. For this document however, the size of the 2060 authentication tag is fixed at 128 bits. 2062 The set of algorithms defined in this document are in Table 9. 2064 +---------+-------+------------------------------------------+ 2065 | name | value | description | 2066 +---------+-------+------------------------------------------+ 2067 | A128GCM | 1 | AES-GCM mode w/ 128-bit key, 128-bit tag | 2068 | | | | 2069 | A192GCM | 2 | AES-GCM mode w/ 192-bit key, 128-bit tag | 2070 | | | | 2071 | A256GCM | 3 | AES-GCM mode w/ 256-bit key, 128-bit tag | 2072 +---------+-------+------------------------------------------+ 2074 Table 9: Algorithm Value for AES-GCM 2076 Keys may be obtained either from a key structure or from a recipient 2077 structure. Implementations encrypting and decrypting MUST validate 2078 that the key type, key length and algorithm are correct and 2079 appropriate for the entities involved. 2081 When using a COSE key for this algorithm, the following checks are 2082 made: 2084 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2086 o If the 'alg' field is present, it MUST match the AES-GCM algorithm 2087 being used. 2089 o If the 'key_ops' field is present, it MUST include 'encrypt' or 2090 'wrap key' when encrypting. 2092 o If the 'key_ops' field is present, it MUST include 'decrypt' or 2093 'unwrap key' when decrypting. 2095 10.1.1. Security Considerations 2097 When using AES-GCM, the following restrictions MUST be enforced: 2099 o The key and nonce pair MUST be unique for every message encrypted. 2101 o The total amount of data encrypted for a single key MUST NOT 2102 exceed 2^39 - 256 bits. An explicit check is required only in 2103 environments where it is expected that it might be exceeded. 2105 Consideration was given to supporting smaller tag values; the 2106 constrained community would desire tag sizes in the 64-bit range. 2108 Doing so drastically changes both the maximum messages size 2109 (generally not an issue) and the number of times that a key can be 2110 used. Given that CCM is the usual mode for constrained environments, 2111 restricted modes are not supported. 2113 10.2. AES CCM 2115 Counter with CBC-MAC (CCM) is a generic authentication encryption 2116 block cipher mode defined in [RFC3610]. The CCM mode is combined 2117 with the AES block encryption algorithm to define a commonly used 2118 content encryption algorithm used in constrained devices. 2120 The CCM mode has two parameter choices. The first choice is M, the 2121 size of the authentication field. The choice of the value for M 2122 involves a trade-off between message growth (from the tag) and the 2123 probably that an attacker can undetectably modify a message. The 2124 second choice is L, the size of the length field. This value 2125 requires a trade-off between the maximum message size and the size of 2126 the Nonce. 2128 It is unfortunate that the specification for CCM specified L and M as 2129 a count of bytes rather than a count of bits. This leads to possible 2130 misunderstandings where AES-CCM-8 is frequently used to refer to a 2131 version of CCM mode where the size of the authentication is 64 bits 2132 and not 8 bits. These values have traditionally been specified as 2133 bit counts rather than byte counts. This document will follow the 2134 convention of using bit counts so that it is easier to compare the 2135 different algorithms presented in this document. 2137 We define a matrix of algorithms in this document over the values of 2138 L and M. Constrained devices are usually operating in situations 2139 where they use short messages and want to avoid doing recipient 2140 specific cryptographic operations. This favors smaller values of 2141 both L and M. Less constrained devices will want to be able to use 2142 larger messages and are more willing to generate new keys for every 2143 operation. This favors larger values of L and M. 2145 The following values are used for L: 2147 16 bits (2) limits messages to 2^16 bytes (64 KiB) in length. This 2148 is sufficiently long for messages in the constrained world. The 2149 nonce length is 13 bytes allowing for 2^(13*8) possible values of 2150 the nonce without repeating. 2152 64 bits (8) limits messages to 2^64 bytes in length. The nonce 2153 length is 7 bytes allowing for 2^56 possible values of the nonce 2154 without repeating. 2156 The following values are used for M: 2158 64 bits (8) produces a 64-bit authentication tag. This implies that 2159 there is a 1 in 2^64 chance that a modified message will 2160 authenticate. 2162 128 bits (16) produces a 128-bit authentication tag. This implies 2163 that there is a 1 in 2^128 chance that a modified message will 2164 authenticate. 2166 +--------------------+-------+----+-----+-----+---------------------+ 2167 | name | value | L | M | k | description | 2168 +--------------------+-------+----+-----+-----+---------------------+ 2169 | AES-CCM-16-64-128 | 10 | 16 | 64 | 128 | AES-CCM mode | 2170 | | | | | | 128-bit key, 64-bit | 2171 | | | | | | tag, 13-byte nonce | 2172 | | | | | | | 2173 | AES-CCM-16-64-256 | 11 | 16 | 64 | 256 | AES-CCM mode | 2174 | | | | | | 256-bit key, 64-bit | 2175 | | | | | | tag, 13-byte nonce | 2176 | | | | | | | 2177 | AES-CCM-64-64-128 | 12 | 64 | 64 | 128 | AES-CCM mode | 2178 | | | | | | 128-bit key, 64-bit | 2179 | | | | | | tag, 7-byte nonce | 2180 | | | | | | | 2181 | AES-CCM-64-64-256 | 13 | 64 | 64 | 256 | AES-CCM mode | 2182 | | | | | | 256-bit key, 64-bit | 2183 | | | | | | tag, 7-byte nonce | 2184 | | | | | | | 2185 | AES-CCM-16-128-128 | 30 | 16 | 128 | 128 | AES-CCM mode | 2186 | | | | | | 128-bit key, | 2187 | | | | | | 128-bit tag, | 2188 | | | | | | 13-byte nonce | 2189 | | | | | | | 2190 | AES-CCM-16-128-256 | 31 | 16 | 128 | 256 | AES-CCM mode | 2191 | | | | | | 256-bit key, | 2192 | | | | | | 128-bit tag, | 2193 | | | | | | 13-byte nonce | 2194 | | | | | | | 2195 | AES-CCM-64-128-128 | 32 | 64 | 128 | 128 | AES-CCM mode | 2196 | | | | | | 128-bit key, | 2197 | | | | | | 128-bit tag, 7-byte | 2198 | | | | | | nonce | 2199 | | | | | | | 2200 | AES-CCM-64-128-256 | 33 | 64 | 128 | 256 | AES-CCM mode | 2201 | | | | | | 256-bit key, | 2202 | | | | | | 128-bit tag, 7-byte | 2203 | | | | | | nonce | 2204 +--------------------+-------+----+-----+-----+---------------------+ 2206 Table 10: Algorithm Values for AES-CCM 2208 Keys may be obtained either from a key structure or from a recipient 2209 structure. Implementations encrypting and decrypting MUST validate 2210 that the key type, key length and algorithm are correct and 2211 appropriate for the entities involved. 2213 When using a COSE key for this algorithm, the following checks are 2214 made: 2216 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2218 o If the 'alg' field is present, it MUST match the AES-CCM algorithm 2219 being used. 2221 o If the 'key_ops' field is present, it MUST include 'encrypt' or 2222 'wrap key' when encrypting. 2224 o If the 'key_ops' field is present, it MUST include 'decrypt' or 2225 'unwrap key' when decrypting. 2227 10.2.1. Security Considerations 2229 When using AES-CCM, the following restrictions MUST be enforced: 2231 o The key and nonce pair MUST be unique for every message encrypted. 2232 Note that the value of L influences the number of unique nonces. 2234 o The total number of times the AES block cipher is used MUST NOT 2235 exceed 2^61 operations. This limitation is the sum of times the 2236 block cipher is used in computing the MAC value and in performing 2237 stream encryption operations. An explicit check is required only 2238 in environments where it is expected that it might be exceeded. 2240 [RFC3610] additionally calls out one other consideration of note. It 2241 is possible to do a pre-computation attack against the algorithm in 2242 cases where portions of the plaintext are highly predictable. This 2243 reduces the security of the key size by half. Ways to deal with this 2244 attack include adding a random portion to the nonce value and/or 2245 increasing the key size used. Using a portion of the nonce for a 2246 random value will decrease the number of messages that a single key 2247 can be used for. Increasing the key size may require more resources 2248 in the constrained device. See sections 5 and 10 of [RFC3610] for 2249 more information. 2251 10.3. ChaCha20 and Poly1305 2253 ChaCha20 and Poly1305 combined together is an AEAD mode that is 2254 defined in [RFC7539]. This is an algorithm defined to be a cipher 2255 that is not AES and thus would not suffer from any future weaknesses 2256 found in AES. These cryptographic functions are designed to be fast 2257 in software-only implementations. 2259 The ChaCha20/Poly1305 AEAD construction defined in [RFC7539] has no 2260 parameterization. It takes a 256-bit key and a 96-bit nonce, as well 2261 as the plain text and additional data as inputs and produces the 2262 cipher text as an option. We define one algorithm identifier for 2263 this algorithm in Table 11. 2265 +-------------------+-------+---------------------------------------+ 2266 | name | value | description | 2267 +-------------------+-------+---------------------------------------+ 2268 | ChaCha20/Poly1305 | 24 | ChaCha20/Poly1305 w/ 256-bit key, | 2269 | | | 128-bit tag | 2270 +-------------------+-------+---------------------------------------+ 2272 Table 11: Algorithm Value for AES-GCM 2274 Keys may be obtained either from a key structure or from a recipient 2275 structure. Implementations encrypting and decrypting MUST validate 2276 that the key type, key length and algorithm are correct and 2277 appropriate for the entities involved. 2279 When using a COSE key for this algorithm, the following checks are 2280 made: 2282 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2284 o If the 'alg' field is present, it MUST match the ChaCha20/Poly1305 2285 algorithm being used. 2287 o If the 'key_ops' field is present, it MUST include 'encrypt' or 2288 'wrap key' when encrypting. 2290 o If the 'key_ops' field is present, it MUST include 'decrypt' or 2291 'unwrap key' when decrypting. 2293 10.3.1. Security Considerations 2295 The pair of key, nonce MUST be unique for every invocation of the 2296 algorithm. Nonce counters are considered to be an acceptable way of 2297 ensuring that they are unique. 2299 11. Key Derivation Functions (KDF) 2301 Key Derivation Functions (KDFs) are used to take some secret value 2302 and generate a different one. The secret value comes in three 2303 flavors: 2305 o Secrets that are uniformly random: This is the type of secret that 2306 is created by a good random number generator. 2308 o Secrets that are not uniformly random: This is type of secret that 2309 is created by operations like key agreement. 2311 o Secrets that are not random: This is the type of secret that 2312 people generate for things like passwords. 2314 General KDF functions work well with the first type of secret, can do 2315 reasonably well with the second type of secret, and generally do 2316 poorly with the last type of secret. None of the KDF functions in 2317 this section are designed to deal with the type of secrets that are 2318 used for passwords. Functions like PBES2 [RFC2898] need to be used 2319 for that type of secret. 2321 The same KDF function can be setup to deal with the first two types 2322 of secrets in a different way. The KDF function defined in 2323 Section 11.1 is such a function. This is reflected in the set of 2324 algorithms defined for HKDF. 2326 When using KDF functions, one component that is included is context 2327 information. Context information is used to allow for different 2328 keying information to be derived from the same secret. The use of 2329 context based keying material is considered to be a good security 2330 practice. 2332 This document defines a single context structure and a single KDF 2333 function. These elements are used for all of the recipient 2334 algorithms defined in this document that require a KDF process. 2335 These algorithms are defined in Section 12.1.2, Section 12.4.1, and 2336 Section 12.5.1. 2338 11.1. HMAC-based Extract-and-Expand Key Derivation Function (HKDF) 2340 The HKDF key derivation algorithm is defined in [RFC5869]. 2342 The HKDF algorithm takes these inputs: 2344 secret - a shared value that is secret. Secrets may be either 2345 previously shared or derived from operations like a DH key 2346 agreement. 2348 salt - an optional value that is used to change the generation 2349 process. The salt value can be either public or private. If the 2350 salt is public and carried in the message, then the 'salt' 2351 algorithm header parameter defined in Table 13 is used. While 2352 [RFC5869] suggests that the length of the salt be the same as the 2353 length of the underlying hash value, any amount of salt will 2354 improve the security as different key values will be generated. 2355 This parameter is protected by being included in the key 2356 computation and does not need to be separately authenticated. The 2357 salt value does not need to be unique for every message sent. 2359 length - the number of bytes of output that need to be generated. 2361 context information - Information that describes the context in 2362 which the resulting value will be used. Making this information 2363 specific to the context in which the material is going to be used 2364 ensures that the resulting material will always be tied to that 2365 usage. The context structure defined in Section 11.2 is used by 2366 the KDF functions in this document. 2368 PRF - The underlying pseudo-random function to be used in the HKDF 2369 algorithm. The PRF is encoded into the HKDF algorithm selection. 2371 HKDF is defined to use HMAC as the underlying PRF. However, it is 2372 possible to use other functions in the same construct to provide a 2373 different KDF function that is more appropriate in the constrained 2374 world. Specifically, one can use AES-CBC-MAC as the PRF for the 2375 expand step, but not for the extract step. When using a good random 2376 shared secret of the correct length, the extract step can be skipped. 2377 For the AES algorithm versions, the extract step is always skipped. 2379 The extract step cannot be skipped if the secret is not uniformly 2380 random, for example, if it is the result of an ECDH key agreement 2381 step. (This implies that the AES HKDF version cannot be used with 2382 ECDH.) If the extract step is skipped, the 'salt' value is not used 2383 as part of the HKDF functionality. 2385 The algorithms defined in this document are found in Table 12. 2387 +---------------+-----------------+---------------------------------+ 2388 | name | PRF | description | 2389 +---------------+-----------------+---------------------------------+ 2390 | HKDF SHA-256 | HMAC with | HKDF using HMAC SHA-256 as the | 2391 | | SHA-256 | PRF | 2392 | | | | 2393 | HKDF SHA-512 | HMAC with | HKDF using HMAC SHA-512 as the | 2394 | | SHA-512 | PRF | 2395 | | | | 2396 | HKDF AES- | AES-CBC-MAC-128 | HKDF using AES-MAC as the PRF | 2397 | MAC-128 | | w/ 128-bit key | 2398 | | | | 2399 | HKDF AES- | AES-CBC-MAC-256 | HKDF using AES-MAC as the PRF | 2400 | MAC-256 | | w/ 256-bit key | 2401 +---------------+-----------------+---------------------------------+ 2403 Table 12: HKDF algorithms 2405 +------+-------+------+-------------+ 2406 | name | label | type | description | 2407 +------+-------+------+-------------+ 2408 | salt | -20 | bstr | Random salt | 2409 +------+-------+------+-------------+ 2411 Table 13: HKDF Algorithm Parameters 2413 11.2. Context Information Structure 2415 The context information structure is used to ensure that the derived 2416 keying material is "bound" to the context of the transaction. The 2417 context information structure used here is based on that defined in 2418 [SP800-56A]. By using CBOR for the encoding of the context 2419 information structure, we automatically get the same type and length 2420 separation of fields that is obtained by the use of ASN.1. This 2421 means that there is no need to encode the lengths for the base 2422 elements as it is done by the encoding used in JOSE (Section 4.6.2 of 2423 [RFC7518]). 2425 The context information structure refers to PartyU and PartyV as the 2426 two parties that are doing the key derivation. Unless the 2427 application protocol defines differently, we assign PartyU to the 2428 entity that is creating the message and PartyV to the entity that is 2429 receiving the message. By doing this association, different keys 2430 will be derived for each direction as the context information is 2431 different in each direction. 2433 The context structure is built from information that is known to both 2434 entities. This information can be obtained from a variety of 2435 sources: 2437 o Fields can be defined by the application. This is commonly used 2438 to assign fixed names to parties, but can be used for other items 2439 such as nonces. 2441 o Fields can be defined by usage of the output. Examples of this 2442 are the algorithm and key size that are being generated. 2444 o Fields can be defined by parameters from the message. We define a 2445 set of parameters in Table 14 that can be used to carry the values 2446 associated with the context structure. Examples of this are 2447 identities and nonce values. These parameters are designed to be 2448 placed in the unprotected bucket of the recipient structure. 2449 (They do not need to be in the protected bucket since they already 2450 are included in the cryptographic computation by virtue of being 2451 included in the context structure.) 2453 +---------------+-------+-----------+-------------------------------+ 2454 | name | label | type | description | 2455 +---------------+-------+-----------+-------------------------------+ 2456 | PartyU | -21 | bstr | Party U identity Information | 2457 | identity | | | | 2458 | | | | | 2459 | PartyU nonce | -22 | bstr / | Party U provided nonce | 2460 | | | int | | 2461 | | | | | 2462 | PartyU other | -23 | bstr | Party U other provided | 2463 | | | | information | 2464 | | | | | 2465 | PartyV | -24 | bstr | Party V identity Information | 2466 | identity | | | | 2467 | | | | | 2468 | PartyV nonce | -25 | bstr / | Party V provided nonce | 2469 | | | int | | 2470 | | | | | 2471 | PartyV other | -26 | bstr | Party V other provided | 2472 | | | | information | 2473 +---------------+-------+-----------+-------------------------------+ 2475 Table 14: Context Algorithm Parameters 2477 We define a CBOR object to hold the context information. This object 2478 is referred to as CBOR_KDF_Context. The object is based on a CBOR 2479 array type. The fields in the array are: 2481 AlgorithmID This field indicates the algorithm for which the key 2482 material will be used. This normally is either a Key Wrap 2483 algorithm identifier or a Content Encryption algorithm identifier. 2484 The values are from the "COSE Algorithm Value" registry. This 2485 field is required to be present. The field exists in the context 2486 information so that if the same environment is used for different 2487 algorithms, then completely different keys will be generated for 2488 each of those algorithms. (This practice means if algorithm A is 2489 broken and thus is easier to find, the key derived for algorithm B 2490 will not be the same as the key derived for algorithm A.) 2492 PartyUInfo This field holds information about party U. The 2493 PartyUInfo is encoded as a CBOR array. The elements of PartyUInfo 2494 are encoded in the order presented, however if the element does 2495 not exist no element is placed in the array. The elements of the 2496 PartyUInfo array are: 2498 identity This contains the identity information for party U. The 2499 identities can be assigned in one of two manners. Firstly, a 2500 protocol can assign identities based on roles. For example, 2501 the roles of "client" and "server" may be assigned to different 2502 entities in the protocol. Each entity would then use the 2503 correct label for the data they send or receive. The second 2504 way for a protocol to assign identities is to use a name based 2505 on a naming system (i.e., DNS, X.509 names). 2506 We define an algorithm parameter 'PartyU identity' that can be 2507 used to carry identity information in the message. However, 2508 identity information is often known as part of the protocol and 2509 can thus be inferred rather than made explicit. If identity 2510 information is carried in the message, applications SHOULD have 2511 a way of validating the supplied identity information. The 2512 identity information does not need to be specified and is set 2513 to nil in that case. 2515 nonce This contains a nonce value. The nonce can either be 2516 implicit from the protocol or carried as a value in the 2517 unprotected headers. 2518 We define an algorithm parameter 'PartyU nonce' that can be 2519 used to carry this value in the message However, the nonce 2520 value could be determined by the application and the value 2521 determined from elsewhere. 2522 This option does not need to be specified and is set to nil in 2523 that case 2525 other This contains other information that is defined by the 2526 protocol. 2527 This option does not need to be specified and is set to nil in 2528 that case 2530 PartyVInfo This field holds information about party V. The content 2531 of the structure are the same as for the PartyUInfo but for party 2532 V. 2534 SuppPubInfo This field contains public information that is mutually 2535 known to both parties. 2537 keyDataLength This is set to the number of bits of the desired 2538 output value. (This practice means if algorithm A can use two 2539 different key lengths, the key derived for longer key size will 2540 not contain the key for shorter key size as a prefix.) 2542 protected This field contains the protected parameter field. If 2543 there are no elements in the protected field, then use a zero 2544 length bstr. 2546 other This field is for free form data defined by the 2547 application. An example is that an application could define 2548 two different strings to be placed here to generate different 2549 keys for a data stream vs a control stream. This field is 2550 optional and will only be present if the application defines a 2551 structure for this information. Applications that define this 2552 SHOULD use CBOR to encode the data so that types and lengths 2553 are correctly included. 2555 SuppPrivInfo This field contains private information that is 2556 mutually known private information. An example of this 2557 information would be a pre-existing shared secret. (This could, 2558 for example, be used in combination with an ECDH key agreement to 2559 provide a secondary proof of identity.) The field is optional and 2560 will only be present if the application defines a structure for 2561 this information. Applications that define this SHOULD use CBOR 2562 to encode the data so that types and lengths are correctly 2563 included. 2565 The following CDDL fragment corresponds to the text above. 2567 PartyInfo = ( 2568 identity : bstr / nil, 2569 nonce : bstr / int / nil, 2570 other : bstr / nil, 2571 ) 2573 COSE_KDF_Context = [ 2574 AlgorithmID : int / tstr, 2575 PartyUInfo : [ PartyInfo ], 2576 PartyVInfo : [ PartyInfo ], 2577 SuppPubInfo : [ 2578 keyDataLength : uint, 2579 protected : empty_or_serialized_map, 2580 ? other : bstr 2581 ], 2582 ? SuppPrivInfo : bstr 2583 ] 2585 12. Recipient Algorithm Classes 2587 Recipient algorithms can be defined into a number of different 2588 classes. COSE has the ability to support many classes of recipient 2589 algorithms. In this section, a number of classes are listed and then 2590 a set of algorithms are specified for each of the classes. The names 2591 of the recipient algorithm classes used here are the same as are 2592 defined in [RFC7516]. Other specifications use different terms for 2593 the recipient algorithm classes or do not support some of the 2594 recipient algorithm classes. 2596 12.1. Direct Encryption 2598 The direct encryption class algorithms share a secret between the 2599 sender and the recipient that is used either directly or after 2600 manipulation as the CEK. When direct encryption mode is used, it 2601 MUST be the only mode used on the message. 2603 The COSE_Encrypt structure for the recipient is organized as follows: 2605 o The 'protected' field MUST be a zero length item unless it is used 2606 in the computation of the content key. 2608 o The 'alg' parameter MUST be present. 2610 o A parameter identifying the shared secret SHOULD be present. 2612 o The 'ciphertext' field MUST be a zero length item. 2614 o The 'recipients' field MUST be absent. 2616 12.1.1. Direct Key 2618 This recipient algorithm is the simplest; the identified key is 2619 directly used as the key for the next layer down in the message. 2620 There are no algorithm parameters defined for this algorithm. The 2621 algorithm identifier value is assigned in Table 15. 2623 When this algorithm is used, the protected field MUST be zero length. 2624 The key type MUST be 'Symmetric'. 2626 +--------+-------+-------------------+ 2627 | name | value | description | 2628 +--------+-------+-------------------+ 2629 | direct | -6 | Direct use of CEK | 2630 +--------+-------+-------------------+ 2632 Table 15: Direct Key 2634 12.1.1.1. Security Considerations 2636 This recipient algorithm has several potential problems that need to 2637 be considered: 2639 o These keys need to have some method to be regularly updated over 2640 time. All of the content encryption algorithms specified in this 2641 document have limits on how many times a key can be used without 2642 significant loss of security. 2644 o These keys need to be dedicated to a single algorithm. There have 2645 been a number of attacks developed over time when a single key is 2646 used for multiple different algorithms. One example of this is 2647 the use of a single key both for CBC encryption mode and CBC-MAC 2648 authentication mode. 2650 o Breaking one message means all messages are broken. If an 2651 adversary succeeds in determining the key for a single message, 2652 then the key for all messages is also determined. 2654 12.1.2. Direct Key with KDF 2656 These recipient algorithms take a common shared secret between the 2657 two parties and applies the HKDF function (Section 11.1), using the 2658 context structure defined in Section 11.2 to transform the shared 2659 secret into the CEK. The 'protected' field can be of non-zero 2660 length. Either the 'salt' parameter of HKDF or the partyU 'nonce' 2661 parameter of the context structure MUST be present. The salt/nonce 2662 parameter can be generated either randomly or deterministically. The 2663 requirement is that it be a unique value for the shared secret in 2664 question. 2666 If the salt/nonce value is generated randomly, then it is suggested 2667 that the length of the random value be the same length as the hash 2668 function underlying HKDF. While there is no way to guarantee that it 2669 will be unique, there is a high probability that it will be unique. 2670 If the salt/nonce value is generated deterministically, it can be 2671 guaranteed to be unique and thus there is no length requirement. 2673 A new IV must be used for each message if the same key is used. The 2674 IV can be modified in a predictable manner, a random manner or an 2675 unpredictable manner (i.e., encrypting a counter). 2677 The IV used for a key can also be generated from the same HKDF 2678 functionality as the key is generated. If HKDF is used for 2679 generating the IV, the algorithm identifier is set to "IV- 2680 GENERATION". 2682 When these algorithms are used, the key type MUST be 'symmetric'. 2684 The set of algorithms defined in this document can be found in 2685 Table 16. 2687 +---------------------+-------+-------------+-----------------------+ 2688 | name | value | KDF | description | 2689 +---------------------+-------+-------------+-----------------------+ 2690 | direct+HKDF-SHA-256 | -10 | HKDF | Shared secret w/ HKDF | 2691 | | | SHA-256 | and SHA-256 | 2692 | | | | | 2693 | direct+HKDF-SHA-512 | -11 | HKDF | Shared secret w/ HKDF | 2694 | | | SHA-512 | and SHA-512 | 2695 | | | | | 2696 | direct+HKDF-AES-128 | -12 | HKDF AES- | Shared secret w/ AES- | 2697 | | | MAC-128 | MAC 128-bit key | 2698 | | | | | 2699 | direct+HKDF-AES-256 | -13 | HKDF AES- | Shared secret w/ AES- | 2700 | | | MAC-256 | MAC 256-bit key | 2701 +---------------------+-------+-------------+-----------------------+ 2703 Table 16: Direct Key with KDF 2705 When using a COSE key for this algorithm, the following checks are 2706 made: 2708 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2710 o If the 'alg' field is present, it MUST match the algorithm being 2711 used. 2713 o If the 'key_ops' field is present, it MUST include 'deriveKey' or 2714 'deriveBits'. 2716 12.1.2.1. Security Considerations 2718 The shared secret needs to have some method to be regularly updated 2719 over time. The shared secret forms the basis of trust. Although not 2720 used directly, it should still be subject to scheduled rotation. 2722 While these methods do not provide for perfect forward secrecy, as 2723 the same shared secret is used for all of the keys generated, if the 2724 key for any single message is discovered only the message (or series 2725 of messages) using that derived key are compromised. A new key 2726 derivation step will generate a new key which requires the same 2727 amount of work to get the key. 2729 12.2. Key Wrapping 2731 In key wrapping mode, the CEK is randomly generated and that key is 2732 then encrypted by a shared secret between the sender and the 2733 recipient. All of the currently defined key wrapping algorithms for 2734 COSE are AE algorithms. Key wrapping mode is considered to be 2735 superior to direct encryption if the system has any capability for 2736 doing random key generation. This is because the shared key is used 2737 to wrap random data rather than data that has some degree of 2738 organization and may in fact be repeating the same content. The use 2739 of Key Wrapping loses the weak data origination that is provided by 2740 the direct encryption algorithms. 2742 The COSE_Encrypt structure for the recipient is organized as follows: 2744 o The 'protected' field MUST be absent if the key wrap algorithm is 2745 an AE algorithm. 2747 o The 'recipients' field is normally absent, but can be used. 2748 Applications MUST deal with a recipient field being present, not 2749 being able to decrypt that recipient is an acceptable way of 2750 dealing with it. Failing to process the message is not an 2751 acceptable way of dealing with it. 2753 o The plain text to be encrypted is the key from next layer down 2754 (usually the content layer). 2756 o At a minimum, the 'unprotected' field MUST contain the 'alg' 2757 parameter and SHOULD contain a parameter identifying the shared 2758 secret. 2760 12.2.1. AES Key Wrapping 2762 The AES Key Wrapping algorithm is defined in [RFC3394]. This 2763 algorithm uses an AES key to wrap a value that is a multiple of 64 2764 bits. As such, it can be used to wrap a key for any of the content 2765 encryption algorithms defined in this document. The algorithm 2766 requires a single fixed parameter, the initial value. This is fixed 2767 to the value specified in Section 2.2.3.1 of [RFC3394]. There are no 2768 public parameters that vary on a per invocation basis. The protected 2769 header field MUST be empty. 2771 Keys may be obtained either from a key structure or from a recipient 2772 structure. Implementations encrypting and decrypting MUST validate 2773 that the key type, key length and algorithm are correct and 2774 appropriate for the entities involved. 2776 When using a COSE key for this algorithm, the following checks are 2777 made: 2779 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2781 o If the 'alg' field is present, it MUST match the AES Key Wrap 2782 algorithm being used. 2784 o If the 'key_ops' field is present, it MUST include 'encrypt' or 2785 'wrap key' when encrypting. 2787 o If the 'key_ops' field is present, it MUST include 'decrypt' or 2788 'unwrap key' when decrypting. 2790 +--------+-------+----------+-----------------------------+ 2791 | name | value | key size | description | 2792 +--------+-------+----------+-----------------------------+ 2793 | A128KW | -3 | 128 | AES Key Wrap w/ 128-bit key | 2794 | | | | | 2795 | A192KW | -4 | 192 | AES Key Wrap w/ 192-bit key | 2796 | | | | | 2797 | A256KW | -5 | 256 | AES Key Wrap w/ 256-bit key | 2798 +--------+-------+----------+-----------------------------+ 2800 Table 17: AES Key Wrap Algorithm Values 2802 12.2.1.1. Security Considerations for AES-KW 2804 The shared secret needs to have some method to be regularly updated 2805 over time. The shared secret is the basis of trust. 2807 12.3. Key Transport 2809 Key transport mode is also called key encryption mode in some 2810 standards. Key transport mode differs from key wrap mode in that it 2811 uses an asymmetric encryption algorithm rather than a symmetric 2812 encryption algorithm to protect the key. This document does not 2813 define any key transport mode algorithms. 2815 When using a key transport algorithm, the COSE_Encrypt structure for 2816 the recipient is organized as follows: 2818 o The 'protected' field MUST be absent. 2820 o The plain text to be encrypted is the key from next layer down 2821 (usually the content layer). 2823 o At a minimum, the 'unprotected' field MUST contain the 'alg' 2824 parameter and SHOULD contain a parameter identifying the 2825 asymmetric key. 2827 12.4. Direct Key Agreement 2829 The 'direct key agreement' class of recipient algorithms uses a key 2830 agreement method to create a shared secret. A KDF is then applied to 2831 the shared secret to derive a key to be used in protecting the data. 2833 This key is normally used as a CEK or MAC key, but could be used for 2834 other purposes if more than two layers are in use (see Appendix B). 2836 The most commonly used key agreement algorithm is Diffie-Hellman, but 2837 other variants exist. Since COSE is designed for a store and forward 2838 environment rather than an on-line environment, many of the DH 2839 variants cannot be used as the receiver of the message cannot provide 2840 any dynamic key material. One side-effect of this is that perfect 2841 forward secrecy (see [RFC4949]) is not achievable. A static key will 2842 always be used for the receiver of the COSE object. 2844 Two variants of DH that are supported are: 2846 Ephemeral-Static DH: where the sender of the message creates a 2847 one-time DH key and uses a static key for the recipient. The use 2848 of the ephemeral sender key means that no additional random input 2849 is needed as this is randomly generated for each message. 2851 Static-Static DH: where a static key is used for both the sender 2852 and the recipient. The use of static keys allows for recipient to 2853 get a weak version of data origination for the message. When 2854 static-static key agreement is used, then some piece of unique 2855 data for the KDF is required to ensure that a different key is 2856 created for each message. 2858 When direct key agreement mode is used, there MUST be only one 2859 recipient in the message. This method creates the key directly and 2860 that makes it difficult to mix with additional recipients. If 2861 multiple recipients are needed, then the version with key wrap needs 2862 to be used. 2864 The COSE_Encrypt structure for the recipient is organized as follows: 2866 o At a minimum, headers MUST contain the 'alg' parameter and SHOULD 2867 contain a parameter identifying the recipient's asymmetric key. 2869 o The headers SHOULD identify the sender's key for the static-static 2870 versions and MUST contain the sender's ephemeral key for the 2871 ephemeral-static versions. 2873 12.4.1. ECDH 2875 The mathematics for Elliptic Curve Diffie-Hellman can be found in 2876 [RFC6090]. In this document, the algorithm is extended to be used 2877 with the two curves defined in [RFC7748]. 2879 ECDH is parameterized by the following: 2881 o Curve Type/Curve: The curve selected controls not only the size of 2882 the shared secret, but the mathematics for computing the shared 2883 secret. The curve selected also controls how a point in the curve 2884 is represented and what happens for the identity points on the 2885 curve. In this specification, we allow for a number of different 2886 curves to be used. A set of curves are defined in Table 22. 2887 The math used to obtain the computed secret is based on the curve 2888 selected and not on the ECDH algorithm. For this reason, a new 2889 algorithm does not need to be defined for each of the curves. 2891 o Computed Secret to Shared Secret: Once the computed secret is 2892 known, the resulting value needs to be converted to a byte string 2893 to run the KDF function. The X coordinate is used for all of the 2894 curves defined in this document. For curves X25519 and X448, the 2895 resulting value is used directly as it is a byte string of a known 2896 length. For the P-256, P-384 and P-521 curves, the X coordinate 2897 is run through the I2OSP function defined in [RFC3447], using the 2898 same computation for n as is defined in Section 8.1. 2900 o Ephemeral-static or static-static: The key agreement process may 2901 be done using either a static or an ephemeral key for the sender's 2902 side. When using ephemeral keys, the sender MUST generate a new 2903 ephemeral key for every key agreement operation. The ephemeral 2904 key is placed in the 'ephemeral key' parameter and MUST be present 2905 for all algorithm identifiers that use ephemeral keys. When using 2906 static keys, the sender MUST either generate a new random value or 2907 otherwise create a unique value. For the KDF functions used, this 2908 means either in the 'salt' parameter for HKDF (Table 13) or in the 2909 'PartyU nonce' parameter for the context structure (Table 14) MUST 2910 be present. (Both may be present if desired.) The value in the 2911 parameter MUST be unique for the pair of keys being used. It is 2912 acceptable to use a global counter that is incremented for every 2913 static-static operation and use the resulting value. When using 2914 static keys, the static key should be identified to the recipient. 2915 The static key can be identified either by providing the key 2916 ('static key') or by providing a key identifier for the static key 2917 ('static key id'). Both of these parameters are defined in 2918 Table 19. 2920 o Key derivation algorithm: The result of an ECDH key agreement 2921 process does not provide a uniformly random secret. As such, it 2922 needs to be run through a KDF in order to produce a usable key. 2923 Processing the secret through a KDF also allows for the 2924 introduction of context material: how the key is going to be used, 2925 and one-time material for static-static key agreement. All of the 2926 algorithms defined in this document use one of the HKDF algorithms 2927 defined in Section 11.1 with the context structure defined in 2928 Section 11.2. 2930 o Key Wrap algorithm: No key wrap algorithm is used. This is 2931 represented in Table 18 as 'none'. The key size for the context 2932 structure is the content layer encryption algorithm size. 2934 The set of direct ECDH algorithms defined in this document are found 2935 in Table 18. 2937 +-----------+-------+---------+------------+--------+---------------+ 2938 | name | value | KDF | Ephemeral- | Key | description | 2939 | | | | Static | Wrap | | 2940 +-----------+-------+---------+------------+--------+---------------+ 2941 | ECDH-ES + | -25 | HKDF - | yes | none | ECDH ES w/ | 2942 | HKDF-256 | | SHA-256 | | | HKDF - | 2943 | | | | | | generate key | 2944 | | | | | | directly | 2945 | | | | | | | 2946 | ECDH-ES + | -26 | HKDF - | yes | none | ECDH ES w/ | 2947 | HKDF-512 | | SHA-512 | | | HKDF - | 2948 | | | | | | generate key | 2949 | | | | | | directly | 2950 | | | | | | | 2951 | ECDH-SS + | -27 | HKDF - | no | none | ECDH SS w/ | 2952 | HKDF-256 | | SHA-256 | | | HKDF - | 2953 | | | | | | generate key | 2954 | | | | | | directly | 2955 | | | | | | | 2956 | ECDH-SS + | -28 | HKDF - | no | none | ECDH SS w/ | 2957 | HKDF-512 | | SHA-512 | | | HKDF - | 2958 | | | | | | generate key | 2959 | | | | | | directly | 2960 +-----------+-------+---------+------------+--------+---------------+ 2962 Table 18: ECDH Algorithm Values 2964 +-----------+-------+----------+-----------+------------------------+ 2965 | name | label | type | algorithm | description | 2966 +-----------+-------+----------+-----------+------------------------+ 2967 | ephemeral | -1 | COSE_Key | ECDH-ES | Ephemeral Public key | 2968 | key | | | | for the sender | 2969 | | | | | | 2970 | static | -2 | COSE_Key | ECDH-SS | Static Public key for | 2971 | key | | | | the sender | 2972 | | | | | | 2973 | static | -3 | bstr | ECDH-SS | Static Public key | 2974 | key id | | | | identifier for the | 2975 | | | | | sender | 2976 +-----------+-------+----------+-----------+------------------------+ 2978 Table 19: ECDH Algorithm Parameters 2980 This document defines these algorithms to be used with the curves 2981 P-256, P-384, P-521, X25519, and X448. Implementations MUST verify 2982 that the key type and curve are correct. Different curves are 2983 restricted to different key types. Implementations MUST verify that 2984 the curve and algorithm are appropriate for the entities involved. 2986 When using a COSE key for this algorithm, the following checks are 2987 made: 2989 o The 'kty' field MUST be present and it MUST be 'EC2' or 'OKP'. 2991 o If the 'alg' field is present, it MUST match the Key Agreement 2992 algorithm being used. 2994 o If the 'key_ops' field is present, it MUST include 'derive key' or 2995 'derive bits' for the private key. 2997 o If the 'key_ops' field is present, it MUST be empty for the public 2998 key. 3000 12.4.2. Security Considerations 3002 Some method of checking that points provided from external entities 3003 are valid. For the 'EC2' key format, this can be done by checking 3004 that the x and y values form a point on the curve. For the 'OKP' 3005 format, there is no simple way to do point validation. 3007 Consideration was given to requiring that the public keys of both 3008 entities be provided as part of the key derivation process. (As 3009 recommended in section 6.1 of [RFC7748].) This was not done as COSE 3010 is used in a store and forward format rather than in on line key 3011 exchange. In order for this to be a problem, either the receiver 3012 public key has to be chosen maliciously or the sender has to be 3013 malicious. In either case, all security evaporates anyway. 3015 A proof of possession of the private key associated with the public 3016 key is recommended when a key is moved from untrusted to trusted. 3017 (Either by the end user or by the entity that is responsible for 3018 making trust statements on keys.) 3020 12.5. Key Agreement with Key Wrap 3022 Key Agreement with Key Wrapping uses a randomly generated CEK. The 3023 CEK is then encrypted using a Key Wrapping algorithm and a key 3024 derived from the shared secret computed by the key agreement 3025 algorithm. 3027 The COSE_Encrypt structure for the recipient is organized as follows: 3029 o The 'protected' field is fed into the KDF context structure. 3031 o The plain text to be encrypted is the key from next layer down 3032 (usually the content layer). 3034 o The 'alg' parameter MUST be present in the layer. 3036 o A parameter identifying the recipient's key SHOULD be present. A 3037 parameter identifying the sender's key SHOULD be present. 3039 12.5.1. ECDH 3041 These algorithms are defined in Table 20. 3043 ECDH with Key Agreement is parameterized by the same parameters as 3044 for ECDH Section 12.4.1 with the following modifications: 3046 o Key Wrap Algorithm: Any of the key wrap algorithms defined in 3047 Section 12.2.1 are supported. The size of the key used for the 3048 key wrap algorithm is fed into the KDF function. The set of 3049 identifiers are found in Table 20. 3051 +-----------+-------+---------+------------+--------+---------------+ 3052 | name | value | KDF | Ephemeral- | Key | description | 3053 | | | | Static | Wrap | | 3054 +-----------+-------+---------+------------+--------+---------------+ 3055 | ECDH-ES + | -29 | HKDF - | yes | A128KW | ECDH ES w/ | 3056 | A128KW | | SHA-256 | | | Concat KDF | 3057 | | | | | | and AES Key | 3058 | | | | | | wrap w/ 128 | 3059 | | | | | | bit key | 3060 | | | | | | | 3061 | ECDH-ES + | -30 | HKDF - | yes | A192KW | ECDH ES w/ | 3062 | A192KW | | SHA-256 | | | Concat KDF | 3063 | | | | | | and AES Key | 3064 | | | | | | wrap w/ 192 | 3065 | | | | | | bit key | 3066 | | | | | | | 3067 | ECDH-ES + | -31 | HKDF - | yes | A256KW | ECDH ES w/ | 3068 | A256KW | | SHA-256 | | | Concat KDF | 3069 | | | | | | and AES Key | 3070 | | | | | | wrap w/ 256 | 3071 | | | | | | bit key | 3072 | | | | | | | 3073 | ECDH-SS + | -32 | HKDF - | no | A128KW | ECDH SS w/ | 3074 | A128KW | | SHA-256 | | | Concat KDF | 3075 | | | | | | and AES Key | 3076 | | | | | | wrap w/ 128 | 3077 | | | | | | bit key | 3078 | | | | | | | 3079 | ECDH-SS + | -33 | HKDF - | no | A192KW | ECDH SS w/ | 3080 | A192KW | | SHA-256 | | | Concat KDF | 3081 | | | | | | and AES Key | 3082 | | | | | | wrap w/ 192 | 3083 | | | | | | bit key | 3084 | | | | | | | 3085 | ECDH-SS + | -34 | HKDF - | no | A256KW | ECDH SS w/ | 3086 | A256KW | | SHA-256 | | | Concat KDF | 3087 | | | | | | and AES Key | 3088 | | | | | | wrap w/ 256 | 3089 | | | | | | bit key | 3090 +-----------+-------+---------+------------+--------+---------------+ 3092 Table 20: ECDH Algorithm Values with Key Wrap 3094 When using a COSE key for this algorithm, the following checks are 3095 made: 3097 o The 'kty' field MUST be present and it MUST be 'EC2' or 'OKP'. 3099 o If the 'alg' field is present, it MUST match the Key Agreement 3100 algorithm being used. 3102 o If the 'key_ops' field is present, it MUST include 'derive key' or 3103 'derive bits' for the private key. 3105 o If the 'key_ops' field is present, it MUST be empty for the public 3106 key. 3108 13. Key Object Parameters 3110 The COSE_Key object defines a way to hold a single key object. It is 3111 still required that the members of individual key types be defined. 3112 This section of the document is where we define an initial set of 3113 members for specific key types. 3115 For each of the key types, we define both public and private members. 3116 The public members are what is transmitted to others for their usage. 3117 Private members allow for the archival of keys by individuals. 3118 However, there are some circumstances in which private keys may be 3119 distributed to entities in a protocol. Examples include: entities 3120 that have poor random number generation, centralized key creation for 3121 multi-cast type operations, and protocols in which a shared secret is 3122 used as a bearer token for authorization purposes. 3124 Key types are identified by the 'kty' member of the COSE_Key object. 3125 In this document, we define four values for the member: 3127 +-----------+-------+--------------------------------------------+ 3128 | name | value | description | 3129 +-----------+-------+--------------------------------------------+ 3130 | OKP | 1 | Octet Key Pair | 3131 | | | | 3132 | EC2 | 2 | Elliptic Curve Keys w/ X,Y Coordinate pair | 3133 | | | | 3134 | Symmetric | 4 | Symmetric Keys | 3135 | | | | 3136 | Reserved | 0 | This value is reserved | 3137 +-----------+-------+--------------------------------------------+ 3139 Table 21: Key Type Values 3141 13.1. Elliptic Curve Keys 3143 Two different key structures could be defined for Elliptic Curve 3144 keys. One version uses both an x and a y coordinate, potentially 3145 with point compression ('EC2'). This is the traditional EC point 3146 representation that is used in [RFC5480]. The other version uses 3147 only the x coordinate as the y coordinate is either to be recomputed 3148 or not needed for the key agreement operation ('OKP'). 3150 Applications MUST check that the curve and the key type are 3151 consistent and reject a key if they are not. 3153 +---------+----------+-------+------------------------------------+ 3154 | name | key type | value | description | 3155 +---------+----------+-------+------------------------------------+ 3156 | P-256 | EC2 | 1 | NIST P-256 also known as secp256r1 | 3157 | | | | | 3158 | P-384 | EC2 | 2 | NIST P-384 also known as secp384r1 | 3159 | | | | | 3160 | P-521 | EC2 | 3 | NIST P-521 also known as secp521r1 | 3161 | | | | | 3162 | X25519 | OKP | 4 | X25519 for use w/ ECDH only | 3163 | | | | | 3164 | X448 | OKP | 5 | X448 for use w/ ECDH only | 3165 | | | | | 3166 | Ed25519 | OKP | 6 | Ed25519 for use w/ EdDSA only | 3167 | | | | | 3168 | Ed448 | OKP | 7 | Ed448 for use w/ EdDSA only | 3169 +---------+----------+-------+------------------------------------+ 3171 Table 22: EC Curves 3173 13.1.1. Double Coordinate Curves 3175 The traditional way of sending EC curves has been to send either both 3176 the x and y coordinates, or the x coordinate and a sign bit for the y 3177 coordinate. The latter encoding has not been recommended in the IETF 3178 due to potential IPR issues. However, for operations in constrained 3179 environments, the ability to shrink a message by not sending the y 3180 coordinate is potentially useful. 3182 For EC keys with both coordinates, the 'kty' member is set to 2 3183 (EC2). The key parameters defined in this section are summarized in 3184 Table 23. The members that are defined for this key type are: 3186 crv contains an identifier of the curve to be used with the key. 3187 The curves defined in this document for this key type can be found 3188 in Table 22. Other curves may be registered in the future and 3189 private curves can be used as well. 3191 x contains the x coordinate for the EC point. The integer is 3192 converted to an octet string as defined in [SEC1]. Leading zero 3193 octets MUST be preserved. 3195 y contains either the sign bit or the value of y coordinate for the 3196 EC point. When encoding the value y, the integer is converted to 3197 an octet string (as defined in [SEC1]) and encoded as a CBOR bstr. 3198 Leading zero octets MUST be preserved. The compressed point 3199 encoding is also supported. Compute the sign bit as laid out in 3200 the Elliptic-Curve-Point-to-Octet-String Conversion function of 3201 [SEC1]. If the sign bit is zero, then encode y as a CBOR false 3202 value, otherwise encode y as a CBOR true value. The encoding of 3203 the infinity point is not supported. 3205 d contains the private key. 3207 For public keys, it is REQUIRED that 'crv', 'x' and 'y' be present in 3208 the structure. For private keys, it is REQUIRED that 'crv' and 'd' 3209 be present in the structure. For private keys, it is RECOMMENDED 3210 that 'x' and 'y' also be present, but they can be recomputed from the 3211 required elements and omitting them saves on space. 3213 +------+-------+-------+---------+----------------------------------+ 3214 | name | key | value | type | description | 3215 | | type | | | | 3216 +------+-------+-------+---------+----------------------------------+ 3217 | crv | 2 | -1 | int / | EC Curve identifier - Taken from | 3218 | | | | tstr | the COSE Curves registry | 3219 | | | | | | 3220 | x | 2 | -2 | bstr | X Coordinate | 3221 | | | | | | 3222 | y | 2 | -3 | bstr / | Y Coordinate | 3223 | | | | bool | | 3224 | | | | | | 3225 | d | 2 | -4 | bstr | Private key | 3226 +------+-------+-------+---------+----------------------------------+ 3228 Table 23: EC Key Parameters 3230 13.2. Octet Key Pair 3232 A new key type is defined for Octet Key Pairs (OKP). Do not assume 3233 that keys using this type are elliptic curves. This key type could 3234 be used for other curve types (for example, mathematics based on 3235 hyper-elliptic surfaces). 3237 The key parameters defined in this section are summarized in 3238 Table 24. The members that are defined for this key type are: 3240 crv contains an identifier of the curve to be used with the key. 3241 The curves defined in this document for this key type can be found 3242 in Table 22. Other curves may be registered in the future and 3243 private curves can be used as well. 3245 x contains the x coordinate for the EC point. The octet string 3246 represents a little-endian encoding of x. 3248 d contains the private key. 3250 For public keys, it is REQUIRED that 'crv' and 'x' be present in the 3251 structure. For private keys, it is REQUIRED that 'crv' and 'd' be 3252 present in the structure. For private keys, it is RECOMMENDED that 3253 'x' also be present, but it can be recomputed from the required 3254 elements and omitting it saves on space. 3256 +------+------+-------+-------+-------------------------------------+ 3257 | name | key | value | type | description | 3258 | | type | | | | 3259 +------+------+-------+-------+-------------------------------------+ 3260 | crv | 1 | -1 | int / | EC Curve identifier - Taken from | 3261 | | | | tstr | the COSE Key Common Parameters | 3262 | | | | | registry | 3263 | | | | | | 3264 | x | 1 | -2 | bstr | X Coordinate | 3265 | | | | | | 3266 | d | 1 | -4 | bstr | Private key | 3267 +------+------+-------+-------+-------------------------------------+ 3269 Table 24: Octet Key Pair Parameters 3271 13.3. Symmetric Keys 3273 Occasionally it is required that a symmetric key be transported 3274 between entities. This key structure allows for that to happen. 3276 For symmetric keys, the 'kty' member is set to 3 (Symmetric). The 3277 member that is defined for this key type is: 3279 k contains the value of the key. 3281 This key structure does not have a form that contains only public 3282 members. As it is expected that this key structure is going to be 3283 transmitted, care must be taking that it is never transmitted 3284 accidentally or insecurely. For symmetric keys, it is REQUIRED that 3285 'k' be present in the structure. 3287 +------+----------+-------+------+-------------+ 3288 | name | key type | value | type | description | 3289 +------+----------+-------+------+-------------+ 3290 | k | 4 | -1 | bstr | Key Value | 3291 +------+----------+-------+------+-------------+ 3293 Table 25: Symmetric Key Parameters 3295 14. CBOR Encoder Restrictions 3297 There has been an attempt to limit the number of places where the 3298 document needs to impose restrictions on how the CBOR Encoder needs 3299 to work. We have managed to narrow it down to the following 3300 restrictions: 3302 o The restriction applies to the encoding the Sig_structure, the 3303 Enc_structure, and the MAC_structure. 3305 o The rules for Canonical CBOR (Section 3.9 of RFC 7049) MUST be 3306 used in these locations. The main rule that needs to be enforced 3307 is that all lengths in these structures MUST be encoded such that 3308 they are encoded using definite lengths and the minimum length 3309 encoding is used. 3311 o Applications MUST NOT generate messages with the same label used 3312 twice as a key in a single map. Applications MUST NOT parse and 3313 process messages with the same label used twice as a key in a 3314 single map. Applications can enforce the parse and process 3315 requirement by using parsers that will fail the parse step or by 3316 using parsers that will pass all keys to the application and the 3317 application can perform the check for duplicate keys. 3319 15. Application Profiling Considerations 3321 This document is designed to provide a set of security services, but 3322 not to provide implementation requirements for specific usage. The 3323 interoperability requirements are provided for how each of the 3324 individual services are used and how the algorithms are to be used 3325 for interoperability. The requirements about which algorithms and 3326 which services are needed are deferred to each application. 3328 It is intended that a profile of this document be created that 3329 defines the interopability requirements for that specific 3330 application. This section provides a set of guidelines and topics 3331 that need to be considered when profiling this document. 3333 o Applications need to determine the set of messages defined in this 3334 document that they will be using. The set of messages corresponds 3335 fairly directly to the set of security services that are needed 3336 and to the security levels needed. 3338 o Applications may define new header parameters for a specific 3339 purpose. Applications will often times select specific header 3340 parameters to use or not to use. For example, an application 3341 would normally state a preference for using either the IV or the 3342 partial IV parameter. If the partial IV parameter is specified, 3343 then the application would also need to define how the fixed 3344 portion of the IV would be determined. 3346 o When applications use externally defined authenticated data, they 3347 need to define how that data is encoded. This document assumes 3348 that the data will be provided as a byte stream. More information 3349 can be found in Section 4.3. 3351 o Applications need to determine the set of security algorithms that 3352 are to be used. When selecting the algorithms to be used as the 3353 mandatory to implement set, consideration should be given to 3354 choosing different types of algorithms when two are chosen for a 3355 specific purpose. An example of this would be choosing HMAC- 3356 SHA512 and AES-CMAC as different MAC algorithms; the construction 3357 is vastly different between these two algorithms. This means that 3358 a weakening of one algorithm would be unlikely to lead to a 3359 weakening of the other algorithms. Of course, these algorithms do 3360 not provide the same level of security and thus may not be 3361 comparable for the desired security functionality. 3363 o Applications may need to provide some type of negotiation or 3364 discovery method if multiple algorithms or message structures are 3365 permitted. The method can be as simple as requiring 3366 preconfiguration of the set of algorithms to providing a discovery 3367 method built into the protocol. S/MIME provided a number of 3368 different ways to approach the problem that applications could 3369 follow: 3371 * Advertising in the message (S/MIME capabilities) [RFC5751]. 3373 * Advertising in the certificate (capabilities extension) 3374 [RFC4262]. 3376 * Minimum requirements for the S/MIME, which have been updated 3377 over time [RFC2633][RFC5751]. 3379 16. IANA Considerations 3381 16.1. CBOR Tag assignment 3383 It is requested that IANA assign the following tags from the "CBOR 3384 Tags" registry. It is requested that the tags for COSE_Sign1, 3385 COSE_Encrypt0, and COSE_Mac0 be assigned in the 1 to 23 value range 3386 (one byte long when encoded). It is requested that the tags for 3387 COSE_Sign, COSE_Encrypt and COSE_MAC be assigned in the 24 to 255 3388 value range (two bytes long when encoded). 3390 The tags to be assigned are in Table 1. 3392 16.2. COSE Header Parameters Registry 3394 It is requested that IANA create a new registry entitled "COSE Header 3395 Parameters". The registry should be created as Expert Review 3396 Required. Guidelines for the experts is provided Section 16.11. It 3397 should be noted that in additional to the expert review, some 3398 portions of the registry require a specification, potentially on 3399 standards track, be supplied as well. 3401 The columns of the registry are: 3403 name The name is present to make it easier to refer to and discuss 3404 the registration entry. The value is not used in the protocol. 3405 Names are to be unique in the table. 3407 label This is the value used for the label. The label can be either 3408 an integer or a string. Registration in the table is based on the 3409 value of the label requested. Integer values between 1 and 255 3410 and strings of length 1 are designated as Standards Track Document 3411 required. Integer values from 256 to 65535 and strings of length 3412 2 are designated as Specification Required. Integer values of 3413 greater than 65535 and strings of length greater than 2 are 3414 designated as expert review. Integer values in the range -1 to 3415 -65536 are delegated to the "COSE Header Algorithm Parameters" 3416 registry. Integer values less than -65536 are marked as private 3417 use. 3419 value This contains the CBOR type for the value portion of the 3420 label. 3422 value registry This contains a pointer to the registry used to 3423 contain values where the set is limited. 3425 description This contains a brief description of the header field. 3427 specification This contains a pointer to the specification defining 3428 the header field (where public). 3430 The initial contents of the registry can be found in Table 2 and 3431 Table 27. The specification column for all rows in that table should 3432 be this document. 3434 Additionally, the label of 0 is to be marked as 'Reserved'. 3436 16.3. COSE Header Algorithm Parameters Registry 3438 It is requested that IANA create a new registry entitled "COSE Header 3439 Algorithm Parameters". The registry is to be created as Expert 3440 Review Required. Expert review guidelines are provided in 3441 Section 16.11. 3443 The columns of the registry are: 3445 name The name is present to make it easier to refer to and discuss 3446 the registration entry. The value is not used in the protocol. 3448 algorithm The algorithm(s) that this registry entry is used for. 3449 This value is taken from the "COSE Algorithm Values" registry. 3450 Multiple algorithms can be specified in this entry. For the 3451 table, the algorithm, label pair MUST be unique. 3453 label This is the value used for the label. The label is an integer 3454 in the range of -1 to -65536. 3456 value This contains the CBOR type for the value portion of the 3457 label. 3459 value registry This contains a pointer to the registry used to 3460 contain values where the set is limited. 3462 description This contains a brief description of the header field. 3464 specification This contains a pointer to the specification defining 3465 the header field (where public). 3467 The initial contents of the registry can be found in Table 13, 3468 Table 14, and Table 19. The specification column for all rows in 3469 that table should be this document. 3471 16.4. COSE Algorithms Registry 3473 It is requested that IANA create a new registry entitled "COSE 3474 Algorithms Registry". The registry is to be created as Expert Review 3475 Required. Guidelines for the experts is provided Section 16.11. It 3476 should be noted that in additional to the expert review, some 3477 portions of the registry require a specification, potentially on 3478 standards track, be supplied as well. 3480 The columns of the registry are: 3482 value The value to be used to identify this algorithm. Algorithm 3483 values MUST be unique. The value can be a positive integer, a 3484 negative integer or a string. Integer values between -256 and 255 3485 and strings of length 1 are designated as Standards Track Document 3486 required. Integer values from -65536 to 65535 and strings of 3487 length 2 are designated as Specification Required. Integer values 3488 of greater than 65535 and strings of length greater than 2 are 3489 designated as expert review. Integer values less than -65536 are 3490 marked as private use. 3492 description A short description of the algorithm. 3494 specification A document where the algorithm is defined (if publicly 3495 available). 3497 The initial contents of the registry can be found in Table 10, 3498 Table 9, Table 11, Table 5, Table 7, Table 8, Table 15, Table 16, 3499 Table 17, Table 6, Table 20 and Table 18. The specification column 3500 for all rows in that table should be this document. 3502 NOTE: The assignment of algorithm identifiers in this document was 3503 done so that positive numbers were used for the first layer objects 3504 (COSE_Sign, COSE_Sign1, COSE_Encrypt, COSE_Encrypt0, COSE_Mac, and 3505 COSE_Mac0). Negative numbers were used for second layer objects 3506 (COSE_Signature and COSE_recipient). Expert reviewers should 3507 consider this practice, but are not expected to be restricted by this 3508 precedent. 3510 16.5. COSE Key Common Parameters Registry 3512 It is requested that IANA create a new registry entitled "COSE Key 3513 Common Parameters" registry. The registry is to be created as Expert 3514 Review Required. Guidelines for the experts is provided 3515 Section 16.11. It should be noted that in additional to the expert 3516 review, some portions of the registry require a specification, 3517 potentially on standards track, be supplied as well. 3519 The columns of the registry are: 3521 name This is a descriptive name that enables easier reference to the 3522 item. It is not used in the encoding. 3524 label The value to be used to identify this algorithm. Key map 3525 labels MUST be unique. The label can be a positive integer, a 3526 negative integer or a string. Integer values between 0 and 255 3527 and strings of length 1 are designated as Standards Track Document 3528 required. Integer values from 256 to 65535 and strings of length 3529 2 are designated as Specification Required. Integer values of 3530 greater than 65535 and strings of length greater than 2 are 3531 designated as expert review. Integer values in the range -1 to 3532 -65536 are used for key parameters specific to a single algorithm 3533 delegated to the "COSE Key Type Parameter Labels" registry. 3534 Integer values less than -65536 are marked as private use. 3536 CBOR Type This field contains the CBOR type for the field. 3538 registry This field denotes the registry that values come from, if 3539 one exists. 3541 description This field contains a brief description for the field. 3543 specification This contains a pointer to the public specification 3544 for the field if one exists 3546 This registry will be initially populated by the values in Table 3. 3547 The specification column for all of these entries will be this 3548 document. 3550 16.6. COSE Key Type Parameters Registry 3552 It is requested that IANA create a new registry "COSE Key Type 3553 Parameters". The registry is to be created as Expert Review 3554 Required. Expert review guidelines are provided in Section 16.11. 3556 The columns of the table are: 3558 key type This field contains a descriptive string of a key type. 3559 This should be a value that is in the COSE Key Common Parameters 3560 table and is placed in the 'kty' field of a COSE Key structure. 3562 name This is a descriptive name that enables easier reference to the 3563 item. It is not used in the encoding. 3565 label The label is to be unique for every value of key type. The 3566 range of values is from -256 to -1. Labels are expected to be 3567 reused for different keys. 3569 CBOR type This field contains the CBOR type for the field. 3571 description This field contains a brief description for the field. 3573 specification This contains a pointer to the public specification 3574 for the field if one exists. 3576 This registry will be initially populated by the values in Table 23, 3577 Table 24, and Table 25. The specification column for all of these 3578 entries will be this document. 3580 16.7. COSE Key Type Registry 3582 It is requested that IANA create a new registry "COSE Key Type 3583 Registry". The registry is to be created as Expert Review Required. 3584 Expert review guidelines are provided in Section 16.11. 3586 The columns of this table are: 3588 name This is a descriptive name that enables easier reference to the 3589 item. The name MUST be unique. It is not used in the encoding. 3591 value This is the value used to identify the curve. These values 3592 MUST be unique. The value can be a positive integer, a negative 3593 integer or a string. 3595 description This field contains a brief description of the curve. 3597 specification This contains a pointer to the public specification 3598 for the curve if one exists. 3600 This registry will be initially populated by the values in Table 21. 3601 The specification column for all of these entries will be this 3602 document. 3604 16.8. COSE Elliptic Curve Parameters Registry 3606 It is requested that IANA create a new registry "COSE Elliptic Curve 3607 Parameters". The registry is to be created as Expert Review 3608 Required. Guidelines for the experts is provided Section 16.11. It 3609 should be noted that in additional to the expert review, some 3610 portions of the registry require a specification, potentially on 3611 standards track, be supplied as well. 3613 The columns of the table are: 3615 name This is a descriptive name that enables easier reference to the 3616 item. It is not used in the encoding. 3618 value This is the value used to identify the curve. These values 3619 MUST be unique. The integer values from -256 to 255 are 3620 designated as Standards Track Document Required. The integer 3621 values from 256 to 65535 and -65536 to -257 are designated as 3622 Specification Required. Integer values over 65535 are designated 3623 as expert review. Integer values less than -65536 are marked as 3624 private use. 3626 key type This designates the key type(s) that can be used with this 3627 curve. 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 22. 3635 The specification column for all of these entries will be this 3636 document. 3638 16.9. Media Type Registrations 3640 16.9.1. COSE Security Message 3642 This section registers the "application/cose" media type in the 3643 "Media Types" registry. These media types are used to indicate that 3644 the content is a COSE message. 3646 Type name: application 3648 Subtype name: cose 3650 Required parameters: N/A 3652 Optional parameters: cose-type 3654 Encoding considerations: binary 3656 Security considerations: See the Security Considerations section 3657 of RFC TBD. 3659 Interoperability considerations: N/A 3660 Published specification: RFC TBD 3662 Applications that use this media type: To be identified 3664 Fragment identifier considerations: N/A 3666 Additional information: 3668 * Magic number(s): N/A 3670 * File extension(s): cbor 3672 * Macintosh file type code(s): N/A 3674 Person & email address to contact for further information: 3675 iesg@ietf.org 3677 Intended usage: COMMON 3679 Restrictions on usage: N/A 3681 Author: Jim Schaad, ietf@augustcellars.com 3683 Change Controller: IESG 3685 Provisional registration? No 3687 16.9.2. COSE Key media type 3689 This section registers the "application/cose-key" and "application/ 3690 cose-key-set" media types in the "Media Types" registry. These media 3691 types are used to indicate, respectively, that content is a COSE_Key 3692 or COSE_KeySet object. 3694 The template for registering "application/cose-key" is: 3696 Type name: application 3698 Subtype name: cose-key 3700 Required parameters: N/A 3702 Optional parameters: N/A 3704 Encoding considerations: binary 3706 Security considerations: See the Security Considerations section 3707 of RFC TBD. 3709 Interoperability considerations: N/A 3711 Published specification: RFC TBD 3713 Applications that use this media type: To be identified 3715 Fragment identifier considerations: N/A 3717 Additional information: 3719 * Magic number(s): N/A 3721 * File extension(s): cbor 3723 * Macintosh file type code(s): N/A 3725 Person & email address to contact for further information: 3726 iesg@ietf.org 3728 Intended usage: COMMON 3730 Restrictions on usage: N/A 3732 Author: Jim Schaad, ietf@augustcellars.com 3734 Change Controller: IESG 3736 Provisional registration? No 3738 The template for registering "application/cose-key-set" is: 3740 Type name: application 3742 Subtype name: cose-key-set 3744 Required parameters: N/A 3746 Optional parameters: N/A 3748 Encoding considerations: binary 3750 Security considerations: See the Security Considerations section 3751 of RFC TBD. 3753 Interoperability considerations: N/A 3755 Published specification: RFC TBD 3756 Applications that use this media type: To be identified 3758 Fragment identifier considerations: N/A 3760 Additional information: 3762 * Magic number(s): N/A 3764 * File extension(s): cbor 3766 * Macintosh file type code(s): N/A 3768 Person & email address to contact for further information: 3769 iesg@ietf.org 3771 Intended usage: COMMON 3773 Restrictions on usage: N/A 3775 Author: Jim Schaad, ietf@augustcellars.com 3777 Change Controller: IESG 3779 Provisional registration? No 3781 16.10. CoAP Content-Format Registrations 3783 IANA is requested to add the following entries to the "CoAP Content- 3784 Format" registry. ID assignment in the 24-255 range is requested. 3786 +---------------------------------+----------+-------+--------------+ 3787 | Media Type | Encoding | ID | Reference | 3788 +---------------------------------+----------+-------+--------------+ 3789 | application/cose; cose-type | | TBD10 | [This | 3790 | ="cose-sign" | | | Document] | 3791 | | | | | 3792 | application/cose; cose-type | | TBD11 | [This | 3793 | ="cose-sign1" | | | Document] | 3794 | | | | | 3795 | application/cose; cose-type | | TBD12 | [This | 3796 | ="cose-encrypt" | | | Document] | 3797 | | | | | 3798 | application/cose; cose-type | | TBD13 | [This | 3799 | ="cose-encrypt0" | | | Document] | 3800 | | | | | 3801 | application/cose; cose-type | | TBD14 | [This | 3802 | ="cose-mac" | | | Document] | 3803 | | | | | 3804 | application/cose; cose-type | | TBD15 | [This | 3805 | ="cose-mac0" | | | Document] | 3806 | | | | | 3807 | application/cose-key | | TBD16 | [This | 3808 | | | | Document] | 3809 | | | | | 3810 | application/cose-key-set | | TBD17 | [This | 3811 | | | | Document | 3812 +---------------------------------+----------+-------+--------------+ 3814 Table 26 3816 16.11. Expert Review Instructions 3818 All of the IANA registries established in this document are defined 3819 as expert review. This section gives some general guidelines for 3820 what the experts should be looking for, but they are being designated 3821 as experts for a reason so they should be given substantial latitude. 3823 Expert reviewers should take into consideration the following points: 3825 o Point squatting should be discouraged. Reviewers are encouraged 3826 to get sufficient information for registration requests to ensure 3827 that the usage is not going to duplicate one that is already 3828 registered and that the point is likely to be used in deployments. 3829 The zones tagged as private use are intended for testing purposes 3830 and closed environments, code points in other ranges should not be 3831 assigned for testing. 3833 o Specifications are required for the standards track range of point 3834 assignment. Specifications should exist for specification 3835 required ranges, but early assignment before a specification is 3836 available is considered to be permissible. Specifications are 3837 needed for the first-come, first-serve range if they are expected 3838 to be used outside of closed environments in an interoperable way. 3839 When specifications are not provided, the description provided 3840 needs to have sufficient information to identify what the point is 3841 being used for. 3843 o Experts should take into account the expected usage of fields when 3844 approving point assignment. The fact that there is a range for 3845 standards track documents does not mean that a standards track 3846 document cannot have points assigned outside of that range. The 3847 length of the encoded value should be weighed against how many 3848 code points of that length are left, the size of device it will be 3849 used on, and the number of code points left that encode to that 3850 size. 3852 o When algorithms are registered, vanity registrations should be 3853 discouraged. One way to do this is to require registrations to 3854 provide additional documentation on security analysis of the 3855 algorithm. Another thing that should be considered is to request 3856 for an opinion on the algorithm from the Crypto Forum Research 3857 Group (CFRG). Algorithms that do not meet the security 3858 requirements of the community and the messages structures should 3859 not be registered. 3861 17. Implementation Status 3863 This section records the status of known implementations of the 3864 protocol defined by this specification at the time of posting of this 3865 Internet-Draft, and is based on a proposal described in [RFC7942]. 3866 The description of implementations in this section is intended to 3867 assist the IETF in its decision processes in progressing drafts to 3868 RFCs. Please note that the listing of any individual implementation 3869 here does not imply endorsement by the IETF. Furthermore, no effort 3870 has been spent to verify the information presented here that was 3871 supplied by IETF contributors. This is not intended as, and must not 3872 be construed to be, a catalog of available implementations or their 3873 features. Readers are advised to note that other implementations may 3874 exist. 3876 According to [RFC7942], "this will allow reviewers and working groups 3877 to assign due consideration to documents that have the benefit of 3878 running code, which may serve as evidence of valuable experimentation 3879 and feedback that have made the implemented protocols more mature. 3881 It is up to the individual working groups to use this information as 3882 they see fit". 3884 17.1. Author's Versions 3886 There are three different implementations that have been created by 3887 the author of the document both to create the examples that are 3888 included in the document and to validate the structures and 3889 methodology used in the design of COSE. 3891 Implementation Location: https://github.com/cose-wg 3893 Primary Maintainer: Jim Schaad 3895 Languages: There are three different languages that are currently 3896 supported: Java, C# and C. 3898 Cryptography: The Java and C# libraries use Bouncy Castle to 3899 provide the required cryptography. The C version uses OPENSSL 3900 Version 1.0 for the cryptography. 3902 Coverage: The libraries currently do not have full support for 3903 counter signatures of either variety. They do have support to 3904 allow for implicit algorithm support as they allow for the 3905 application to set attributes that are not to be sent in the 3906 message. 3908 Testing: All of the examples in the example library are generated 3909 by the C# library and then validated using the Java and C 3910 libraries. All three libraries have tests to allow for the 3911 creating of the same messages that are in the example library 3912 followed by validating them. These are not compared against the 3913 example library. The Java and C# libraries have unit testing 3914 included. Not all of the MUST statements in the document have 3915 been implemented as part of the libraries. One such statement is 3916 the requirement that unique labels be present. 3918 Licensing: Revised BSD License 3920 17.2. COSE Testing Library 3922 Implementation Location: https://github.com/cose-wg/Examples 3924 Primary Maintainer: Jim Schaad 3926 Description: A set of tests for the COSE library is provided as 3927 part of the implementation effort. Both success and fail tests 3928 have been provided. All of the examples in this document are part 3929 of this example set. 3931 Coverage: An attempt has been made to have test cases for every 3932 message type and algorithm in the document. Currently examples 3933 dealing with counter signatures, EdDSA, and ECDH with Curve24459 3934 and Goldilocks are missing. 3936 Licensing: Public Domain 3938 18. Security Considerations 3940 There are a number of security considerations that need to be taken 3941 into account by implementers of this specification. The security 3942 considerations that are specific to an individual algorithm are 3943 placed next to the description of the algorithm. While some 3944 considerations have been highlighted here, additional considerations 3945 may be found in the documents listed in the references. 3947 Implementations need to protect the private key material for any 3948 individuals. There are some cases in this document that need to be 3949 highlighted on this issue. 3951 o Using the same key for two different algorithms can leak 3952 information about the key. It is therefore recommended that keys 3953 be restricted to a single algorithm. 3955 o Use of 'direct' as a recipient algorithm combined with a second 3956 recipient algorithm, exposes the direct key to the second 3957 recipient. 3959 o Several of the algorithms in this document have limits on the 3960 number of times that a key can be used without leaking information 3961 about the key. 3963 The use of ECDH and direct plus KDF (with no key wrap) will not 3964 directly lead to the private key being leaked; the one way function 3965 of the KDF will prevent that. There is however, a different issue 3966 that needs to be addressed. Having two recipients requires that the 3967 CEK be shared between two recipients. The second recipient therefore 3968 has a CEK that was derived from material that can be used for the 3969 weak proof of origin. The second recipient could create a message 3970 using the same CEK and send it to the first recipient, the first 3971 recipient would, for either static-static ECDH or direct plus KDF, 3972 make an assumption that the CEK could be used for proof of origin 3973 even though it is from the wrong entity. If the key wrap step is 3974 added, then no proof of origin is implied and this is not an issue. 3976 Although it has been mentioned before, the use of a single key for 3977 multiple algorithms has been demonstrated in some cases to leak 3978 information about a key, provide for attackers to forge integrity 3979 tags, or gain information about encrypted content. Binding a key to 3980 a single algorithm prevents these problems. Key creators and key 3981 consumers are strongly encouraged not only to create new keys for 3982 each different algorithm, but to include that selection of algorithm 3983 in any distribution of key material and strictly enforce the matching 3984 of algorithms in the key structure to algorithms in the message 3985 structure. In addition to checking that algorithms are correct, the 3986 key form needs to be checked as well. Do not use an 'EC2' key where 3987 an 'OKP' key is expected. 3989 Before using a key for transmission, or before acting on information 3990 received, a trust decision on a key needs to be made. Is the data or 3991 action something that the entity associated with the key has a right 3992 to see or a right to request? A number of factors are associated 3993 with this trust decision. Some of the ones that are highlighted here 3994 are: 3996 o What are the permissions associated with the key owner? 3998 o Is the cryptographic algorithm acceptable in the current context? 4000 o Have the restrictions associated with the key, such as algorithm 4001 or freshness, been checked and are correct? 4003 o Is the request something that is reasonable, given the current 4004 state of the application? 4006 o Have any security considerations that are part of the message been 4007 enforced (as specified by the application or 'crit' parameter)? 4009 There are a large number of algorithms presented in this document 4010 that use nonce values. For all of the nonces defined in this 4011 document, there is some type of restriction on the nonce being a 4012 unique value either for a key or for some other conditions. In all 4013 of these cases, there is no known requirement on the nonce being both 4014 unique and unpredictable, under these circumstances it reasonable to 4015 use a counter for creation of the nonce. In cases where one wants 4016 the pattern of the nonce to be unpredictable as well as unique, one 4017 can use a key created for that purpose and encrypt the counter to 4018 produce the nonce value. 4020 One area that has been starting to get exposure is doing traffic 4021 analysis of encrypted messages based on the length of the message. 4022 This specification does not provide for a uniform method of providing 4023 padding as part of the message structure. An observer can 4024 distinguish between two different strings (for example, 'YES' and 4025 'NO') based on length for all of the content encryption algorithms 4026 that are defined in this document. This means that it is up to 4027 applications to document how content padding is to be done in order 4028 to prevent or discourage such analysis. (For example, the strings 4029 could be defined as 'YES' and 'NO '.) 4031 19. References 4033 19.1. Normative References 4035 [AES-GCM] Dworkin, M., "NIST Special Publication 800-38D: 4036 Recommendation for Block Cipher Modes of Operation: 4037 Galois/Counter Mode (GCM) and GMAC.", Nov 2007. 4039 [DSS] U.S. National Institute of Standards and Technology, 4040 "Digital Signature Standard (DSS)", July 2013. 4042 [MAC] NiST, N., "FIPS PUB 113: Computer Data Authentication", 4043 May 1985. 4045 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 4046 Hashing for Message Authentication", RFC 2104, 4047 DOI 10.17487/RFC2104, February 1997, 4048 . 4050 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 4051 Requirement Levels", BCP 14, RFC 2119, 4052 DOI 10.17487/RFC2119, March 1997, 4053 . 4055 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 4056 (AES) Key Wrap Algorithm", RFC 3394, DOI 10.17487/RFC3394, 4057 September 2002, . 4059 [RFC3610] Whiting, D., Housley, R., and N. Ferguson, "Counter with 4060 CBC-MAC (CCM)", RFC 3610, DOI 10.17487/RFC3610, September 4061 2003, . 4063 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 4064 Key Derivation Function (HKDF)", RFC 5869, 4065 DOI 10.17487/RFC5869, May 2010, 4066 . 4068 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 4069 Curve Cryptography Algorithms", RFC 6090, 4070 DOI 10.17487/RFC6090, February 2011, 4071 . 4073 [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object 4074 Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, 4075 October 2013, . 4077 [RFC7539] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 4078 Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015, 4079 . 4081 [SEC1] Standards for Efficient Cryptography Group, "SEC 1: 4082 Elliptic Curve Cryptography", May 2009. 4084 19.2. Informative References 4086 [I-D.greevenbosch-appsawg-cbor-cddl] 4087 Vigano, C. and H. Birkholz, "CBOR data definition language 4088 (CDDL): a notational convention to express CBOR data 4089 structures", draft-greevenbosch-appsawg-cbor-cddl-08 (work 4090 in progress), March 2016. 4092 [I-D.irtf-cfrg-eddsa] 4093 Josefsson, S. and I. Liusvaara, "Edwards-curve Digital 4094 Signature Algorithm (EdDSA)", draft-irtf-cfrg-eddsa-08 4095 (work in progress), August 2016. 4097 [PVSig] Brown, D. and D. Johnson, "Formal Security Proofs for a 4098 Signature Scheme with Partial Message Recover", February 4099 2000. 4101 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 4102 Extensions (MIME) Part One: Format of Internet Message 4103 Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996, 4104 . 4106 [RFC2633] Ramsdell, B., Ed., "S/MIME Version 3 Message 4107 Specification", RFC 2633, DOI 10.17487/RFC2633, June 1999, 4108 . 4110 [RFC2898] Kaliski, B., "PKCS #5: Password-Based Cryptography 4111 Specification Version 2.0", RFC 2898, 4112 DOI 10.17487/RFC2898, September 2000, 4113 . 4115 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 4116 Standards (PKCS) #1: RSA Cryptography Specifications 4117 Version 2.1", RFC 3447, DOI 10.17487/RFC3447, February 4118 2003, . 4120 [RFC4231] Nystrom, M., "Identifiers and Test Vectors for HMAC-SHA- 4121 224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512", 4122 RFC 4231, DOI 10.17487/RFC4231, December 2005, 4123 . 4125 [RFC4262] Santesson, S., "X.509 Certificate Extension for Secure/ 4126 Multipurpose Internet Mail Extensions (S/MIME) 4127 Capabilities", RFC 4262, DOI 10.17487/RFC4262, December 4128 2005, . 4130 [RFC4493] Song, JH., Poovendran, R., Lee, J., and T. Iwata, "The 4131 AES-CMAC Algorithm", RFC 4493, DOI 10.17487/RFC4493, June 4132 2006, . 4134 [RFC4949] Shirey, R., "Internet Security Glossary, Version 2", 4135 FYI 36, RFC 4949, DOI 10.17487/RFC4949, August 2007, 4136 . 4138 [RFC5480] Turner, S., Brown, D., Yiu, K., Housley, R., and T. Polk, 4139 "Elliptic Curve Cryptography Subject Public Key 4140 Information", RFC 5480, DOI 10.17487/RFC5480, March 2009, 4141 . 4143 [RFC5652] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70, 4144 RFC 5652, DOI 10.17487/RFC5652, September 2009, 4145 . 4147 [RFC5751] Ramsdell, B. and S. Turner, "Secure/Multipurpose Internet 4148 Mail Extensions (S/MIME) Version 3.2 Message 4149 Specification", RFC 5751, DOI 10.17487/RFC5751, January 4150 2010, . 4152 [RFC5752] Turner, S. and J. Schaad, "Multiple Signatures in 4153 Cryptographic Message Syntax (CMS)", RFC 5752, 4154 DOI 10.17487/RFC5752, January 2010, 4155 . 4157 [RFC5990] Randall, J., Kaliski, B., Brainard, J., and S. Turner, 4158 "Use of the RSA-KEM Key Transport Algorithm in the 4159 Cryptographic Message Syntax (CMS)", RFC 5990, 4160 DOI 10.17487/RFC5990, September 2010, 4161 . 4163 [RFC6151] Turner, S. and L. Chen, "Updated Security Considerations 4164 for the MD5 Message-Digest and the HMAC-MD5 Algorithms", 4165 RFC 6151, DOI 10.17487/RFC6151, March 2011, 4166 . 4168 [RFC6979] Pornin, T., "Deterministic Usage of the Digital Signature 4169 Algorithm (DSA) and Elliptic Curve Digital Signature 4170 Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, August 4171 2013, . 4173 [RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data 4174 Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 4175 2014, . 4177 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 4178 Application Protocol (CoAP)", RFC 7252, 4179 DOI 10.17487/RFC7252, June 2014, 4180 . 4182 [RFC7515] Jones, M., Bradley, J., and N. Sakimura, "JSON Web 4183 Signature (JWS)", RFC 7515, DOI 10.17487/RFC7515, May 4184 2015, . 4186 [RFC7516] Jones, M. and J. Hildebrand, "JSON Web Encryption (JWE)", 4187 RFC 7516, DOI 10.17487/RFC7516, May 2015, 4188 . 4190 [RFC7517] Jones, M., "JSON Web Key (JWK)", RFC 7517, 4191 DOI 10.17487/RFC7517, May 2015, 4192 . 4194 [RFC7518] Jones, M., "JSON Web Algorithms (JWA)", RFC 7518, 4195 DOI 10.17487/RFC7518, May 2015, 4196 . 4198 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 4199 for Security", RFC 7748, DOI 10.17487/RFC7748, January 4200 2016, . 4202 [RFC7942] Sheffer, Y. and A. Farrel, "Improving Awareness of Running 4203 Code: The Implementation Status Section", BCP 205, 4204 RFC 7942, DOI 10.17487/RFC7942, July 2016, 4205 . 4207 [SP800-56A] 4208 Barker, E., Chen, L., Roginsky, A., and M. Smid, "NIST 4209 Special Publication 800-56A: Recommendation for Pair-Wise 4210 Key Establishment Schemes Using Discrete Logarithm 4211 Cryptography", May 2013. 4213 Appendix A. Making Mandatory Algorithm Header Optional 4215 There has been a portion of the working group who have expressed a 4216 strong desire to relax the rule that the algorithm identifier be 4217 required to appear in each level of a COSE object. There are two 4218 basic reasons that have been advanced to support this position. 4219 First, the resulting message will be smaller if the algorithm 4220 identifier is omitted from the most common messages in a CoAP 4221 environment. Second, there is a potential bug that will arise if 4222 full checking is not done correctly between the different places that 4223 an algorithm identifier could be placed (the message itself, an 4224 application statement, the key structure that the sender possesses 4225 and the key structure the recipient possesses). 4227 This appendix lays out how such a change can be made and the details 4228 that an application needs to specify in order to use this option. 4229 Two different sets of details are specified: Those needed to omit an 4230 algorithm identifier and those needed to use a variant on the counter 4231 signature attribute that contains no attributes about itself. 4233 A.1. Algorithm Identification 4235 In this section are laid out three sets of recommendations. The 4236 first set of recommendations apply to having an implicit algorithm 4237 identified for a single layer of a COSE object. The second set of 4238 recommendations apply to having multiple implicit algorithms 4239 identified for multiple layers of a COSE object. The third set of 4240 recommendations apply to having implicit algorithms for multiple COSE 4241 object constructs. 4243 RFC 2119 language is deliberately not used here. This specification 4244 can provide recommendations, but it cannot enforce them. 4246 This set of recommendations applies to the case where an application 4247 is distributing a fixed algorithm along with the key information for 4248 use in a single COSE object. This normally applies to the smallest 4249 of the COSE objects, specifically COSE_Sign1, COSE_Mac0, and 4250 COSE_Encrypt0, but could apply to the other structures as well. 4252 The following items should be taken into account: 4254 o Applications need to list the set of COSE structures that implicit 4255 algorithms are to be used in. Applications need to require that 4256 the receipt of an explicit algorithm identifier in one of these 4257 structures will lead to the message being rejected. This 4258 requirement is stated so that there will never be a case where 4259 there is any ambiguity about the question of which algorithm 4260 should be used, the implicit or the explicit one. This applies 4261 even if the transported algorithm identifier is a protected 4262 attribute. This applies even if the transported algorithm is the 4263 same as the implicit algorithm. 4265 o Applications need to define the set of information that is to be 4266 considered to be part of a context when omitting algorithm 4267 identifiers. At a minimum, this would be the key identifier (if 4268 needed), the key, the algorithm, and the COSE structure it is used 4269 with. Applications should restrict the use of a single key to a 4270 single algorithm. As noted for some of the algorithms in this 4271 document, the use of the same key in different related algorithms 4272 can lead to leakage of information about the key, leakage about 4273 the data or the ability to perform forgeries. 4275 o In many cases, applications that make the algorithm identifier 4276 implicit will also want to make the context identifier implicit 4277 for the same reason. That is, omitting the context identifier 4278 will decrease the message size (potentially significantly 4279 depending on the length of the identifier). Applications that do 4280 this will need to describe the circumstances where the context 4281 identifier is to be omitted and how the context identifier is to 4282 be inferred in these cases. (Exhaustive search over all of the 4283 keys would normally not be considered to be acceptable.) An 4284 example of how this can be done is to tie the context to a 4285 transaction identifier. Both would be sent on the original 4286 message, but only the transaction identifier would need to be sent 4287 after that point as the context is tied into the transaction 4288 identifier. Another way would be to associate a context with a 4289 network address. All messages coming from a single network 4290 address can be assumed to be associated with a specific context. 4291 (In this case the address would normally be distributed as part of 4292 the context.) 4294 o Applications cannot rely on key identifiers being unique unless 4295 they take significant efforts to ensure that they are computed in 4296 such a way as to create this guarantee. Even when an application 4297 does this, the uniqueness might be violated if the application is 4298 run in different contexts (i.e., with a different context 4299 provider) or if the system combines the security contexts from 4300 different applications together into a single store. 4302 o Applications should continue the practice of protecting the 4303 algorithm identifier. Since this is not done by placing it in the 4304 protected attributes field, applications should define an 4305 application specific external data structure that includes this 4306 value. This external data field can be used as such for content 4307 encryption, MAC, and signature algorithms. It can be used in the 4308 SuppPrivInfo field for those algorithms which use a KDF function 4309 to derive a key value. Applications may also want to protect 4310 other information that is part of the context structure as well. 4311 It should be noted that those fields, such as the key or a base 4312 IV, are protected by virtue of being used in the cryptographic 4313 computation and do not need to be included in the external data 4314 field. 4316 The second case is having multiple implicit algorithm identifiers 4317 specified for a multiple layer COSE object. An example of how this 4318 would work is the encryption context that an application specifies 4319 contains a content encryption algorithm, a key wrap algorithm, a key 4320 identifier, and a shared secret. The sender omits sending the 4321 algorithm identifier for both the content layer and the recipient 4322 layer leaving only the key identifier. The receiver then uses the 4323 key identifier to get the implicit algorithm identifiers. 4325 The following additional items need to be taken into consideration: 4327 o Applications that want to support this will need to define a 4328 structure that allows for, and clearly identifies, both the COSE 4329 structure to be used with a given key and the structure and 4330 algorithm to be used for the secondary layer. The key for the 4331 secondary layer is computed per normal from the recipient layer. 4333 The third case is having multiple implicit algorithm identifiers, but 4334 targeted at potentially unrelated layers or different COSE objects. 4335 There are a number of different scenarios where this might be 4336 applicable. Some of these scenarios are: 4338 o Two contexts are distributed as a pair. Each of the contexts is 4339 for use with a COSE_Encrypt message. Each context will consist of 4340 distinct secret keys and IVs and potentially even different 4341 algorithms. One context is for sending messages from party A to 4342 party B, the second context is for sending messages from party B 4343 to party A. This means that there is no chance for a reflection 4344 attack to occur as each party uses different secret keys to send 4345 its messages, a message that is reflected back to it would fail to 4346 decrypt. 4348 o Two contexts are distributed as a pair. The first context is used 4349 for encryption of the message; the second context is used to place 4350 a counter signature on the message. The intention is that the 4351 second context can be distributed to other entities independently 4352 of the first context. This allows these entities to validate that 4353 the message came from an individual without being able to decrypt 4354 the message and see the content. 4356 o Two contexts are distributed as a pair. The first context 4357 contains a key for dealing with MACed messages, the second context 4358 contains a key for dealing with encrypted messages. This allows 4359 for a unified distribution of keys to participants for different 4360 types of messages that have different keys, but where the keys may 4361 be used in coordinated manner. 4363 For these cases, the following additional items need to be 4364 considered: 4366 o Applications need to ensure that the multiple contexts stay 4367 associated. If one of the contexts is invalidated for any reason, 4368 all of the contexts associated with it should also be invalidated. 4370 A.2. Counter Signature Without Headers 4372 There is a group of people who want to have a counter signature 4373 parameter that is directly tied to the value being signed and thus 4374 the authenticated and unauthenticated buckets can be removed from the 4375 message being sent. The focus on this is an even smaller size, as 4376 all of the information on the process of creating the counter 4377 signature is implicit rather than being explicitly carried in the 4378 message. This includes not only the algorithm identifier as 4379 presented above, but also items such as the key identification is 4380 always external to the signature structure. This means that the 4381 entities that are doing the validation of the counter signature are 4382 required to infer which key is to be used from context rather than 4383 being explicit. One way of doing this would be to presume that all 4384 data coming from a specific port (or to a specific URL) is to be 4385 validated by a specific key. (Note that this does not require that 4386 the key identifier be part of the value signed as it does not serve a 4387 cryptographic purpose. If the key validates the counter signature, 4388 then it should be presumed that the entity associated with that key 4389 produced the signature.) 4391 When computing the signature for the bare counter signature header, 4392 the same Sig_structure defined in Section 4.4 is used. The 4393 sign_protected field is omitted, as there is no protected header 4394 field in in this counter signature header. The value of 4395 "CounterSignature0" is placed in the context field of the 4396 Sig_stucture. 4398 +-------------------+-------+--------+------------------------------+ 4399 | name | label | value | description | 4400 | | | type | | 4401 +-------------------+-------+--------+------------------------------+ 4402 | CounterSignature0 | 9 | bstr | Counter signature with | 4403 | | | | implied signer and headers | 4404 +-------------------+-------+--------+------------------------------+ 4406 Table 27 4408 Appendix B. Two Layers of Recipient Information 4410 All of the currently defined recipient algorithms classes only use 4411 two layers of the COSE_Encrypt structure. The first layer is the 4412 message content and the second layer is the content key encryption. 4413 However, if one uses a recipient algorithm such as RSA-KEM (see 4414 Appendix A of RSA-KEM [RFC5990]), then it makes sense to have three 4415 layers of the COSE_Encrypt structure. 4417 These layers would be: 4419 o Layer 0: The content encryption layer. This layer contains the 4420 payload of the message. 4422 o Layer 1: The encryption of the CEK by a KEK. 4424 o Layer 2: The encryption of a long random secret using an RSA key 4425 and a key derivation function to convert that secret into the KEK. 4427 This is an example of what a triple layer message would look like. 4428 The message has the following layers: 4430 o Layer 0: Has a content encrypted with AES-GCM using a 128-bit key. 4432 o Layer 1: Uses the AES Key wrap algorithm with a 128-bit key. 4434 o Layer 2: Uses ECDH Ephemeral-Static direct to generate the layer 1 4435 key. 4437 In effect, this example is a decomposed version of using the ECDH- 4438 ES+A128KW algorithm. 4440 Size of binary file is 184 bytes 4441 992( 4442 [ 4443 / protected / h'a10101' / { 4444 \ alg \ 1:1 \ AES-GCM 128 \ 4445 } / , 4446 / unprotected / { 4447 / iv / 5:h'02d1f7e6f26c43d4868d87ce' 4448 }, 4449 / ciphertext / h'64f84d913ba60a76070a9a48f26e97e863e2852948658f0 4450 811139868826e89218a75715b', 4451 / recipients / [ 4452 [ 4453 / protected / h'', 4454 / unprotected / { 4455 / alg / 1:-3 / A128KW / 4456 }, 4457 / ciphertext / h'dbd43c4e9d719c27c6275c67d628d493f090593db82 4458 18f11', 4459 / recipients / [ 4460 [ 4461 / protected / h'a1013818' / { 4462 \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ 4463 } / , 4464 / unprotected / { 4465 / ephemeral / -1:{ 4466 / kty / 1:2, 4467 / crv / -1:1, 4468 / x / -2:h'b2add44368ea6d641f9ca9af308b4079aeb519f11 4469 e9b8a55a600b21233e86e68', 4470 / y / -3:false 4471 }, 4472 / kid / 4:'meriadoc.brandybuck@buckland.example' 4473 }, 4474 / ciphertext / h'' 4475 ] 4476 ] 4477 ] 4478 ] 4479 ] 4480 ) 4482 Appendix C. Examples 4484 This appendix includes a set of examples that show the different 4485 features and message types that have been defined in this document. 4486 To make the examples easier to read, they are presented using the 4487 extended CBOR diagnostic notation (defined in 4488 [I-D.greevenbosch-appsawg-cbor-cddl]) rather than as a binary dump. 4490 A GitHub project has been created at https://github.com/cose-wg/ 4491 Examples that contains not only the examples presented in this 4492 document, but a more complete set of testing examples as well. Each 4493 example is found in a JSON file that contains the inputs used to 4494 create the example, some of the intermediate values that can be used 4495 in debugging the example and the output of the example presented in 4496 both a hex and a CBOR diagnostic notation format. Some of the 4497 examples at the site are designed failure testing cases; these are 4498 clearly marked as such in the JSON file. If errors in the examples 4499 in this document are found, the examples on github will be updated 4500 and a note to that effect will be placed in the JSON file. 4502 As noted, the examples are presented using the CBOR's diagnostic 4503 notation. A Ruby based tool exists that can convert between the 4504 diagnostic notation and binary. This tool can be installed with the 4505 command line: 4507 gem install cbor-diag 4509 The diagnostic notation can be converted into binary files using the 4510 following command line: 4512 diag2cbor.rb < inputfile > outputfile 4514 The examples can be extracted from the XML version of this document 4515 via an XPath expression as all of the artwork is tagged with the 4516 attribute type='CBORdiag'. (Depending on the XPath evaluator one is 4517 using, it may be necessary to deal with > as an entity.) 4519 //artwork[@type='CDDL']/text() 4521 C.1. Examples of Signed Message 4523 C.1.1. Single Signature 4525 This example uses the following: 4527 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4529 Size of binary file is 104 bytes 4530 991( 4531 [ 4532 / protected / h'', 4533 / unprotected / {}, 4534 / payload / 'This is the content.', 4535 / signatures / [ 4536 [ 4537 / protected / h'a10126' / { 4538 \ alg \ 1:-7 \ ECDSA 256 \ 4539 } / , 4540 / unprotected / { 4541 / kid / 4:'11' 4542 }, 4543 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5 4544 51ce5705b793914348e14eea4aee6e0c9f09db4ef3ddeca8f3506cd1a98a8fb64327 4545 be470355c9657ce0' 4546 ] 4547 ] 4548 ] 4549 ) 4551 C.1.2. Multiple Signers 4553 This example uses the following: 4555 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4557 o Signature Algorithm: ECDSA w/ SHA-512, Curve P-521 4559 Size of binary file is 278 bytes 4560 991( 4561 [ 4562 / protected / h'', 4563 / unprotected / {}, 4564 / payload / 'This is the content.', 4565 / signatures / [ 4566 [ 4567 / protected / h'a10126' / { 4568 \ alg \ 1:-7 \ ECDSA 256 \ 4569 } / , 4570 / unprotected / { 4571 / kid / 4:'11' 4572 }, 4573 / signature / h'0dc1c5e62719d8f3cce1468b7c881eee6a8088b46bf8 4574 36ae956dd38fe93199199951a6a5e02a24aed5edde3509748366b1c539aaef7dea34 4575 f2cd618fe19fe55d' 4576 ], 4577 [ 4578 / protected / h'a1013823' / { 4579 \ alg \ 1:-36 4580 } / , 4581 / unprotected / { 4582 / kid / 4:'bilbo.baggins@hobbiton.example' 4583 }, 4584 / signature / h'012ce5b1dfe8b5aa6eaa09a54c58a84ad0900e4fdf27 4585 59ec22d1c861cccd75c7e1c4025a2da35e512fc2874d6ac8fd862d09ad07ed2deac2 4586 97b897561e04a8d42476017c11a4a34e26c570c9eff22c1dc84d56cdf6e03ed34bc9 4587 e934c5fdf676c7948d79e97dfe161730217c57748aadb364a0207cee811e9dde65ae 4588 37942e8a8348cc91' 4589 ] 4590 ] 4591 ] 4592 ) 4594 C.1.3. Counter Signature 4596 This example uses the following: 4598 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4600 o The same parameters are used for both the signature and the 4601 counter signature. 4603 Size of binary file is 181 bytes 4604 991( 4605 [ 4606 / protected / h'', 4607 / unprotected / { 4608 / countersign / 7:[ 4609 / protected / h'a10126' / { 4610 \ alg \ 1:-7 \ ECDSA 256 \ 4611 } / , 4612 / unprotected / { 4613 / kid / 4:'11' 4614 }, 4615 / signature / h'c9d3402485aa585cee3efc69b14496c0b00714584b26 4616 0f8e05764b7dbc70ae2b23b89812f5895b805f07a792f7ce77ef6d63875dc37d6a78 4617 ef4d175da45c9a51' 4618 ] 4619 }, 4620 / payload / 'This is the content.', 4621 / signatures / [ 4622 [ 4623 / protected / h'a10126' / { 4624 \ alg \ 1:-7 \ ECDSA 256 \ 4625 } / , 4626 / unprotected / { 4627 / kid / 4:'11' 4628 }, 4629 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5 4630 51ce5705b793914348e14eea4aee6e0c9f09db4ef3ddeca8f3506cd1a98a8fb64327 4631 be470355c9657ce0' 4632 ] 4633 ] 4634 ] 4635 ) 4637 C.1.4. Signature w/ Criticality 4639 This example uses the following: 4641 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4643 o There is a criticality marker on the "reserved" header parameter 4645 Size of binary file is 126 bytes 4646 991( 4647 [ 4648 / protected / h'a2687265736572766564f40281687265736572766564' / 4649 { 4650 "reserved":false, 4651 \ crit \ 2:[ 4652 "reserved" 4653 ] 4654 } / , 4655 / unprotected / {}, 4656 / payload / 'This is the content.', 4657 / signatures / [ 4658 [ 4659 / protected / h'a10126' / { 4660 \ alg \ 1:-7 \ ECDSA 256 \ 4661 } / , 4662 / unprotected / { 4663 / kid / 4:'11' 4664 }, 4665 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5 4666 51ce5705b793914348e1ff259ead2c38d8a7d8a9c87c2ce534d762dab059773115a6 4667 176fa780e85b6b25' 4668 ] 4669 ] 4670 ] 4671 ) 4673 C.2. Single Signer Examples 4675 C.2.1. Single ECDSA signature 4677 This example uses the following: 4679 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4681 Size of binary file is 100 bytes 4682 997( 4683 [ 4684 / protected / h'a10126' / { 4685 \ alg \ 1:-7 \ ECDSA 256 \ 4686 } / , 4687 / unprotected / { 4688 / kid / 4:'11' 4689 }, 4690 / payload / 'This is the content.', 4691 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a551ce 4692 5705b793914348e19f43d6c6ba654472da301b645b293c9ba939295b97c4bdb84778 4693 2bff384c5794' 4694 ] 4695 ) 4697 C.3. Examples of Enveloped Messages 4699 C.3.1. Direct ECDH 4701 This example uses the following: 4703 o CEK: AES-GCM w/ 128-bit key 4705 o Recipient class: ECDH Ephemeral-Static, Curve P-256 4707 Size of binary file is 152 bytes 4708 992( 4709 [ 4710 / protected / h'a10101' / { 4711 \ alg \ 1:1 \ AES-GCM 128 \ 4712 } / , 4713 / unprotected / { 4714 / iv / 5:h'c9cf4df2fe6c632bf7886413' 4715 }, 4716 / ciphertext / h'7adbe2709ca818fb415f1e5df66f4e1a51053ba6d65a1a0 4717 c52a357da7a644b8070a151b0', 4718 / recipients / [ 4719 [ 4720 / protected / h'a1013818' / { 4721 \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ 4722 } / , 4723 / unprotected / { 4724 / ephemeral / -1:{ 4725 / kty / 1:2, 4726 / crv / -1:1, 4727 / x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf 4728 bf054e1c7b4d91d6280', 4729 / y / -3:true 4730 }, 4731 / kid / 4:'meriadoc.brandybuck@buckland.example' 4732 }, 4733 / ciphertext / h'' 4734 ] 4735 ] 4736 ] 4737 ) 4739 C.3.2. Direct plus Key Derivation 4741 This example uses the following: 4743 o CEK: AES-CCM w/128-bit key, truncate the tag to 64 bits 4745 o Recipient class: Use HKDF on a shared secret with the following 4746 implicit fields as part of the context. 4748 * salt: "aabbccddeeffgghh" 4750 * APU identity: "lighting-client" 4752 * APV identity: "lighting-server" 4754 * Supplementary Public Other: "Encryption Example 02" 4756 Size of binary file is 92 bytes 4758 992( 4759 [ 4760 / protected / h'a1010a' / { 4761 \ alg \ 1:10 \ AES-CCM-16-64-128 \ 4762 } / , 4763 / unprotected / { 4764 / iv / 5:h'89f52f65a1c580933b5261a76c' 4765 }, 4766 / ciphertext / h'753548a19b1307084ca7b2056924ed95f2e3b17006dfe93 4767 1b687b847', 4768 / recipients / [ 4769 [ 4770 / protected / h'a10129' / { 4771 \ alg \ 1:-10 4772 } / , 4773 / unprotected / { 4774 / salt / -20:'aabbccddeeffgghh', 4775 / kid / 4:'our-secret' 4776 }, 4777 / ciphertext / h'' 4778 ] 4779 ] 4780 ] 4781 ) 4783 C.3.3. Counter Signature on Encrypted Content 4785 This example uses the following: 4787 o CEK: AES-GCM w/ 128-bit key 4789 o Recipient class: ECDH Ephemeral-Static, Curve P-256 4791 Size of binary file is 327 bytes 4792 992( 4793 [ 4794 / protected / h'a10101' / { 4795 \ alg \ 1:1 \ AES-GCM 128 \ 4796 } / , 4797 / unprotected / { 4798 / iv / 5:h'c9cf4df2fe6c632bf7886413', 4799 / countersign / 7:[ 4800 / protected / h'a1013823' / { 4801 \ alg \ 1:-36 4802 } / , 4803 / unprotected / { 4804 / kid / 4:'bilbo.baggins@hobbiton.example' 4805 }, 4806 / signature / h'00aa98cbfd382610a375d046a275f30266e8d0faacb9 4807 069fde06e37825ae7825419c474f416ded0c8e3e7b55bff68f2a704135bdf99186f6 4808 6659461c8cf929cc7fb300f5e2b33c3b433655042ff719804ff73b0be3e988ecebc0 4809 c70ef6616996809c6eb59a918dbe0a5edb0d15137ece0aba2a0b0f68ad2631cb62f2 4810 ea4d7099804218b0' 4811 ] 4812 }, 4813 / ciphertext / h'7adbe2709ca818fb415f1e5df66f4e1a51053ba6d65a1a0 4814 c52a357da7a644b8070a151b0', 4815 / recipients / [ 4816 [ 4817 / protected / h'a1013818' / { 4818 \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ 4819 } / , 4820 / unprotected / { 4821 / ephemeral / -1:{ 4822 / kty / 1:2, 4823 / crv / -1:1, 4824 / x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf 4825 bf054e1c7b4d91d6280', 4826 / y / -3:true 4827 }, 4828 / kid / 4:'meriadoc.brandybuck@buckland.example' 4829 }, 4830 / ciphertext / h'' 4831 ] 4832 ] 4833 ] 4834 ) 4836 C.3.4. Encrypted Content with External Data 4838 This example uses the following: 4840 o CEK: AES-GCM w/ 128-bit key 4842 o Recipient class: ECDH static-Static, Curve P-256 with AES Key Wrap 4844 o Externally Supplied AAD: h'0011bbcc22dd44ee55ff660077' 4846 Size of binary file is 174 bytes 4848 992( 4849 [ 4850 / protected / h'a10101' / { 4851 \ alg \ 1:1 \ AES-GCM 128 \ 4852 } / , 4853 / unprotected / { 4854 / iv / 5:h'02d1f7e6f26c43d4868d87ce' 4855 }, 4856 / ciphertext / h'64f84d913ba60a76070a9a48f26e97e863e28529d8f5335 4857 e5f0165eee976b4a5f6c6f09d', 4858 / recipients / [ 4859 [ 4860 / protected / h'a101381f' / { 4861 \ alg \ 1:-32 \ ECHD-SS+A128KW \ 4862 } / , 4863 / unprotected / { 4864 / static kid / -3:'peregrin.took@tuckborough.example', 4865 / kid / 4:'meriadoc.brandybuck@buckland.example', 4866 / U nonce / -22:h'0101' 4867 }, 4868 / ciphertext / h'41e0d76f579dbd0d936a662d54d8582037de2e366fd 4869 e1c62' 4870 ] 4871 ] 4872 ] 4873 ) 4875 C.4. Examples of Encrypted Messages 4877 C.4.1. Simple Encrypted Message 4879 This example uses the following: 4881 o CEK: AES-CCM w/ 128-bit key and a 64-bit tag 4883 Size of binary file is 54 bytes 4884 993( 4885 [ 4886 / protected / h'a1010a' / { 4887 \ alg \ 1:10 \ AES-CCM-16-64-128 \ 4888 } / , 4889 / unprotected / { 4890 / iv / 5:h'89f52f65a1c580933b5261a78c' 4891 }, 4892 / ciphertext / h'5974e1b99a3a4cc09a659aa2e9e7fff161d38ce7edd5617 4893 388e77baf' 4894 ] 4895 ) 4897 C.4.2. Encrypted Message w/ a Partial IV 4899 This example uses the following: 4901 o CEK: AES-CCM w/ 128-bit key and a 64-bit tag 4903 o Prefix for IV is 89F52F65A1C580933B52 4905 Size of binary file is 43 bytes 4907 993( 4908 [ 4909 / protected / h'a1010a' / { 4910 \ alg \ 1:10 \ AES-CCM-16-64-128 \ 4911 } / , 4912 / unprotected / { 4913 / partial iv / 6:h'61a7' 4914 }, 4915 / ciphertext / h'252a8911d465c125b6764739700f0141ed09192da5c69e5 4916 33abf852b' 4917 ] 4918 ) 4920 C.5. Examples of MACed messages 4922 C.5.1. Shared Secret Direct MAC 4924 This example uses the following: 4926 o MAC: AES-CMAC, 256-bit key, truncated to 64 bits 4928 o Recipient class: direct shared secret 4930 Size of binary file is 58 bytes 4931 994( 4932 [ 4933 / protected / h'a1010f' / { 4934 \ alg \ 1:15 \ AES-CBC-MAC-256//64 \ 4935 } / , 4936 / unprotected / {}, 4937 / payload / 'This is the content.', 4938 / tag / h'9e1226ba1f81b848', 4939 / recipients / [ 4940 [ 4941 / protected / h'', 4942 / unprotected / { 4943 / alg / 1:-6 / direct /, 4944 / kid / 4:'our-secret' 4945 }, 4946 / ciphertext / h'' 4947 ] 4948 ] 4949 ] 4950 ) 4952 C.5.2. ECDH Direct MAC 4954 This example uses the following: 4956 o MAC: HMAC w/SHA-256, 256-bit key 4958 o Recipient class: ECDH key agreement, two static keys, HKDF w/ 4959 context structure 4961 Size of binary file is 215 bytes 4962 994( 4963 [ 4964 / protected / h'a10105' / { 4965 \ alg \ 1:5 \ HMAC 256//256 \ 4966 } / , 4967 / unprotected / {}, 4968 / payload / 'This is the content.', 4969 / tag / h'81a03448acd3d305376eaa11fb3fe416a955be2cbe7ec96f012c99 4970 4bc3f16a41', 4971 / recipients / [ 4972 [ 4973 / protected / h'a101381a' / { 4974 \ alg \ 1:-27 \ ECDH-SS + HKDF-256 \ 4975 } / , 4976 / unprotected / { 4977 / static kid / -3:'peregrin.took@tuckborough.example', 4978 / kid / 4:'meriadoc.brandybuck@buckland.example', 4979 / U nonce / -22:h'4d8553e7e74f3c6a3a9dd3ef286a8195cbf8a23d 4980 19558ccfec7d34b824f42d92bd06bd2c7f0271f0214e141fb779ae2856abf585a583 4981 68b017e7f2a9e5ce4db5' 4982 }, 4983 / ciphertext / h'' 4984 ] 4985 ] 4986 ] 4987 ) 4989 C.5.3. Wrapped MAC 4991 This example uses the following: 4993 o MAC: AES-MAC, 128-bit key, truncated to 64 bits 4995 o Recipient class: AES keywrap w/ a pre-shared 256-bit key 4997 Size of binary file is 110 bytes 4998 994( 4999 [ 5000 / protected / h'a1010e' / { 5001 \ alg \ 1:14 \ AES-CBC-MAC-128//64 \ 5002 } / , 5003 / unprotected / {}, 5004 / payload / 'This is the content.', 5005 / tag / h'36f5afaf0bab5d43', 5006 / recipients / [ 5007 [ 5008 / protected / h'', 5009 / unprotected / { 5010 / alg / 1:-5 / A256KW /, 5011 / kid / 4:'018c0ae5-4d9b-471b-bfd6-eef314bc7037' 5012 }, 5013 / ciphertext / h'711ab0dc2fc4585dce27effa6781c8093eba906f227 5014 b6eb0' 5015 ] 5016 ] 5017 ] 5018 ) 5020 C.5.4. Multi-recipient MACed message 5022 This example uses the following: 5024 o MAC: HMAC w/ SHA-256, 128-bit key 5026 o Recipient class: Uses three different methods 5028 1. ECDH Ephemeral-Static, Curve P-521, AES-Key Wrap w/ 128-bit 5029 key 5031 2. AES-Key Wrap w/ 256-bit key 5033 Size of binary file is 310 bytes 5034 994( 5035 [ 5036 / protected / h'a10105' / { 5037 \ alg \ 1:5 \ HMAC 256//256 \ 5038 } / , 5039 / unprotected / {}, 5040 / payload / 'This is the content.', 5041 / tag / h'bf48235e809b5c42e995f2b7d5fa13620e7ed834e337f6aa43df16 5042 1e49e9323e', 5043 / recipients / [ 5044 [ 5045 / protected / h'a101381c' / { 5046 \ alg \ 1:-29 \ ECHD-ES+A128KW \ 5047 } / , 5048 / unprotected / { 5049 / ephemeral / -1:{ 5050 / kty / 1:2, 5051 / crv / -1:3, 5052 / x / -2:h'0043b12669acac3fd27898ffba0bcd2e6c366d53bc4db 5053 71f909a759304acfb5e18cdc7ba0b13ff8c7636271a6924b1ac63c02688075b55ef2 5054 d613574e7dc242f79c3', 5055 / y / -3:true 5056 }, 5057 / kid / 4:'bilbo.baggins@hobbiton.example' 5058 }, 5059 / ciphertext / h'339bc4f79984cdc6b3e6ce5f315a4c7d2b0ac466fce 5060 a69e8c07dfbca5bb1f661bc5f8e0df9e3eff5' 5061 ], 5062 [ 5063 / protected / h'', 5064 / unprotected / { 5065 / alg / 1:-5 / A256KW /, 5066 / kid / 4:'018c0ae5-4d9b-471b-bfd6-eef314bc7037' 5067 }, 5068 / ciphertext / h'0b2c7cfce04e98276342d6476a7723c090dfdd15f9a 5069 518e7736549e998370695e6d6a83b4ae507bb' 5070 ] 5071 ] 5072 ] 5073 ) 5075 C.6. Examples of MAC0 messages 5077 C.6.1. Shared Secret Direct MAC 5079 This example uses the following: 5081 o MAC: AES-CMAC, 256-bit key, truncated to 64 bits 5082 o Recipient class: direct shared secret 5084 Size of binary file is 39 bytes 5086 996( 5087 [ 5088 / protected / h'a1010f' / { 5089 \ alg \ 1:15 \ AES-CBC-MAC-256//64 \ 5090 } / , 5091 / unprotected / {}, 5092 / payload / 'This is the content.', 5093 / tag / h'726043745027214f' 5094 ] 5095 ) 5097 Note that this example uses the same inputs as Appendix C.5.1. 5099 C.7. COSE Keys 5101 C.7.1. Public Keys 5103 This is an example of a COSE Key set. This example includes the 5104 public keys for all of the previous examples. 5106 In order the keys are: 5108 o An EC key with a kid of "meriadoc.brandybuck@buckland.example" 5110 o An EC key with a kid of "peregrin.took@tuckborough.example" 5112 o An EC key with a kid of "bilbo.baggins@hobbiton.example" 5114 o An EC key with a kid of "11" 5116 Size of binary file is 481 bytes 5118 [ 5119 { 5120 -1:1, 5121 -2:h'65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c0 5122 8551d', 5123 -3:h'1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd008 5124 4d19c', 5125 1:2, 5126 2:'meriadoc.brandybuck@buckland.example' 5127 }, 5128 { 5129 -1:1, 5130 -2:h'bac5b11cad8f99f9c72b05cf4b9e26d244dc189f745228255a219a86d6a 5131 09eff', 5132 -3:h'20138bf82dc1b6d562be0fa54ab7804a3a64b6d72ccfed6b6fb6ed28bbf 5133 c117e', 5134 1:2, 5135 2:'11' 5136 }, 5137 { 5138 -1:3, 5139 -2:h'0072992cb3ac08ecf3e5c63dedec0d51a8c1f79ef2f82f94f3c737bf5de 5140 7986671eac625fe8257bbd0394644caaa3aaf8f27a4585fbbcad0f2457620085e5c8 5141 f42ad', 5142 -3:h'01dca6947bce88bc5790485ac97427342bc35f887d86d65a089377e247e 5143 60baa55e4e8501e2ada5724ac51d6909008033ebc10ac999b9d7f5cc2519f3fe1ea1 5144 d9475', 5145 1:2, 5146 2:'bilbo.baggins@hobbiton.example' 5147 }, 5148 { 5149 -1:1, 5150 -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbfbf054e1c7b4d91 5151 d6280', 5152 -3:h'f01400b089867804b8e9fc96c3932161f1934f4223069170d924b7e03bf 5153 822bb', 5154 1:2, 5155 2:'peregrin.took@tuckborough.example' 5156 } 5157 ] 5159 C.7.2. Private Keys 5161 This is an example of a COSE Key set. This example includes the 5162 private 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 A shared-secret key with a kid of "our-secret" 5170 o An EC key with a kid of "peregrin.took@tuckborough.example" 5172 o A shared-secret key with a kid of "018c0ae5-4d9b-471b- 5173 bfd6-eef314bc7037" 5175 o An EC key with a kid of "bilbo.baggins@hobbiton.example" 5177 o An EC key with a kid of "11" 5179 Size of binary file is 816 bytes 5181 [ 5182 { 5183 1:2, 5184 2:'meriadoc.brandybuck@buckland.example', 5185 -1:1, 5186 -2:h'65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c0 5187 8551d', 5188 -3:h'1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd008 5189 4d19c', 5190 -4:h'aff907c99f9ad3aae6c4cdf21122bce2bd68b5283e6907154ad911840fa 5191 208cf' 5192 }, 5193 { 5194 1:2, 5195 2:'11', 5196 -1:1, 5197 -2:h'bac5b11cad8f99f9c72b05cf4b9e26d244dc189f745228255a219a86d6a 5198 09eff', 5199 -3:h'20138bf82dc1b6d562be0fa54ab7804a3a64b6d72ccfed6b6fb6ed28bbf 5200 c117e', 5201 -4:h'57c92077664146e876760c9520d054aa93c3afb04e306705db609030850 5202 7b4d3' 5203 }, 5204 { 5205 1:2, 5206 2:'bilbo.baggins@hobbiton.example', 5207 -1:3, 5208 -2:h'0072992cb3ac08ecf3e5c63dedec0d51a8c1f79ef2f82f94f3c737bf5de 5209 7986671eac625fe8257bbd0394644caaa3aaf8f27a4585fbbcad0f2457620085e5c8 5210 f42ad', 5211 -3:h'01dca6947bce88bc5790485ac97427342bc35f887d86d65a089377e247e 5212 60baa55e4e8501e2ada5724ac51d6909008033ebc10ac999b9d7f5cc2519f3fe1ea1 5213 d9475', 5214 -4:h'00085138ddabf5ca975f5860f91a08e91d6d5f9a76ad4018766a476680b 5215 55cd339e8ab6c72b5facdb2a2a50ac25bd086647dd3e2e6e99e84ca2c3609fdf177f 5216 eb26d' 5217 }, 5218 { 5219 1:4, 5220 2:'our-secret', 5221 -1:h'849b57219dae48de646d07dbb533566e976686457c1491be3a76dcea6c4 5222 27188' 5223 }, 5224 { 5225 1:2, 5226 -1:1, 5227 2:'peregrin.took@tuckborough.example', 5228 -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbfbf054e1c7b4d91 5229 d6280', 5230 -3:h'f01400b089867804b8e9fc96c3932161f1934f4223069170d924b7e03bf 5231 822bb', 5232 -4:h'02d1f7e6f26c43d4868d87ceb2353161740aacf1f7163647984b522a848 5233 df1c3' 5234 }, 5235 { 5236 1:4, 5237 2:'our-secret2', 5238 -1:h'849b5786457c1491be3a76dcea6c4271' 5239 }, 5240 { 5241 1:4, 5242 2:'018c0ae5-4d9b-471b-bfd6-eef314bc7037', 5243 -1:h'849b57219dae48de646d07dbb533566e976686457c1491be3a76dcea6c4 5244 27188' 5245 } 5246 ] 5248 Acknowledgments 5250 This document is a product of the COSE working group of the IETF. 5252 The following individuals are to blame for getting me started on this 5253 project in the first place: Richard Barnes, Matt Miller, and Martin 5254 Thomson. 5256 The initial version of the draft was based to some degree on the 5257 outputs of the JOSE and S/MIME working groups. 5259 The following individuals provided input into the final form of the 5260 document: Carsten Bormann, John Bradley, Brain Campbell, Michael B. 5262 Jones, Ilari Liusvaara, Francesca Palombini, Goran Selander, and 5263 Ludwig Seitz. 5265 Author's Address 5267 Jim Schaad 5268 August Cellars 5270 Email: ietf@augustcellars.com