idnits 2.17.1 draft-ietf-cose-msg-15.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 726 has weird spacing: '...otected as de...' == Line 728 has weird spacing: '...otected as de...' == Line 730 has weird spacing: '...payload conta...' == Line 746 has weird spacing: '...natures is an...' == Line 761 has weird spacing: '...otected as de...' == (28 more instances...) -- The document date (July 25, 2016) is 2832 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 == Outdated reference: A later version (-08) exists of draft-irtf-cfrg-eddsa-05 -- 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 6982 (Obsoleted by RFC 7942) -- Obsolete informational reference (is this intentional?): RFC 7159 (Obsoleted by RFC 8259) Summary: 7 errors (**), 0 flaws (~~), 9 warnings (==), 11 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 July 25, 2016 5 Expires: January 26, 2017 7 CBOR Object Signing and Encryption (COSE) 8 draft-ietf-cose-msg-15 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 the basic security services defined for this data 15 format. This document defines the CBOR Object Signing and Encryption 16 (COSE) 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 January 26, 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 . . . . . . . . . . . . . . . . . . 7 69 2. Basic COSE Structure . . . . . . . . . . . . . . . . . . . . 8 70 3. Header Parameters . . . . . . . . . . . . . . . . . . . . . . 10 71 3.1. Common COSE Headers Parameters . . . . . . . . . . . . . 11 72 4. Signing Objects . . . . . . . . . . . . . . . . . . . . . . . 15 73 4.1. Signing with One or More Signers . . . . . . . . . . . . 15 74 4.2. Signing with One Signer . . . . . . . . . . . . . . . . . 17 75 4.3. Externally Supplied Data . . . . . . . . . . . . . . . . 18 76 4.4. Signing and Verification Process . . . . . . . . . . . . 19 77 4.5. Computing Counter Signatures . . . . . . . . . . . . . . 20 78 5. Encryption Objects . . . . . . . . . . . . . . . . . . . . . 21 79 5.1. Enveloped COSE Structure . . . . . . . . . . . . . . . . 21 80 5.1.1. Recipient Algorithm Classes . . . . . . . . . . . . . 23 81 5.2. Single Recipient Encrypted . . . . . . . . . . . . . . . 24 82 5.3. Encryption Algorithm for AEAD algorithms . . . . . . . . 24 83 5.4. Encryption algorithm for AE algorithms . . . . . . . . . 27 84 6. MAC Objects . . . . . . . . . . . . . . . . . . . . . . . . . 28 85 6.1. MACed Message with Recipients . . . . . . . . . . . . . . 28 86 6.2. MACed Messages with Implicit Key . . . . . . . . . . . . 29 87 6.3. How to compute and verify a MAC . . . . . . . . . . . . . 30 88 7. Key Objects . . . . . . . . . . . . . . . . . . . . . . . . . 32 89 7.1. COSE Key Common Parameters . . . . . . . . . . . . . . . 32 90 8. Signature Algorithms . . . . . . . . . . . . . . . . . . . . 35 91 8.1. ECDSA . . . . . . . . . . . . . . . . . . . . . . . . . . 36 92 8.1.1. Security Considerations . . . . . . . . . . . . . . . 38 93 8.2. Edwards-curve Digital Signature Algorithms (EdDSA) . . . 39 94 8.2.1. Security Considerations . . . . . . . . . . . . . . . 40 95 9. Message Authentication (MAC) Algorithms . . . . . . . . . . . 40 96 9.1. Hash-based Message Authentication Codes (HMAC) . . . . . 40 97 9.1.1. Security Considerations . . . . . . . . . . . . . . . 42 98 9.2. AES Message Authentication Code (AES-CBC-MAC) . . . . . . 42 99 9.2.1. Security Considerations . . . . . . . . . . . . . . . 43 100 10. Content Encryption Algorithms . . . . . . . . . . . . . . . . 44 101 10.1. AES GCM . . . . . . . . . . . . . . . . . . . . . . . . 44 102 10.1.1. Security Considerations . . . . . . . . . . . . . . 45 103 10.2. AES CCM . . . . . . . . . . . . . . . . . . . . . . . . 46 104 10.2.1. Security Considerations . . . . . . . . . . . . . . 49 105 10.3. ChaCha20 and Poly1305 . . . . . . . . . . . . . . . . . 49 106 10.3.1. Security Considerations . . . . . . . . . . . . . . 50 107 11. Key Derivation Functions (KDF) . . . . . . . . . . . . . . . 50 108 11.1. HMAC-based Extract-and-Expand Key Derivation Function 109 (HKDF) . . . . . . . . . . . . . . . . . . . . . . . . . 51 110 11.2. Context Information Structure . . . . . . . . . . . . . 53 111 12. Recipient Algorithm Classes . . . . . . . . . . . . . . . . . 56 112 12.1. Direct Encryption . . . . . . . . . . . . . . . . . . . 57 113 12.1.1. Direct Key . . . . . . . . . . . . . . . . . . . . . 57 114 12.1.2. Direct Key with KDF . . . . . . . . . . . . . . . . 58 115 12.2. Key Wrapping . . . . . . . . . . . . . . . . . . . . . . 59 116 12.2.1. AES Key Wrapping . . . . . . . . . . . . . . . . . . 60 117 12.3. Key Transport . . . . . . . . . . . . . . . . . . . . . 61 118 12.4. Direct Key Agreement . . . . . . . . . . . . . . . . . . 61 119 12.4.1. ECDH . . . . . . . . . . . . . . . . . . . . . . . . 62 120 12.4.2. Security Considerations . . . . . . . . . . . . . . 65 121 12.5. Key Agreement with KDF . . . . . . . . . . . . . . . . . 66 122 12.5.1. ECDH . . . . . . . . . . . . . . . . . . . . . . . . 66 123 13. Key Object Parameters . . . . . . . . . . . . . . . . . . . . 68 124 13.1. Elliptic Curve Keys . . . . . . . . . . . . . . . . . . 68 125 13.1.1. Double Coordinate Curves . . . . . . . . . . . . . . 69 126 13.2. Octet Key Pair . . . . . . . . . . . . . . . . . . . . . 70 127 13.3. Symmetric Keys . . . . . . . . . . . . . . . . . . . . . 71 128 14. CBOR Encoder Restrictions . . . . . . . . . . . . . . . . . . 72 129 15. Application Profiling Considerations . . . . . . . . . . . . 72 130 16. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 74 131 16.1. CBOR Tag assignment . . . . . . . . . . . . . . . . . . 74 132 16.2. COSE Header Parameters Registry . . . . . . . . . . . . 74 133 16.3. COSE Header Algorithm Parameters Registry . . . . . . . 75 134 16.4. COSE Algorithms Registry . . . . . . . . . . . . . . . . 75 135 16.5. COSE Key Common Parameters Registry . . . . . . . . . . 76 136 16.6. COSE Key Type Parameters Registry . . . . . . . . . . . 77 137 16.7. COSE Key Type Registry . . . . . . . . . . . . . . . . . 78 138 16.8. COSE Elliptic Curve Parameters Registry . . . . . . . . 78 139 16.9. Media Type Registrations . . . . . . . . . . . . . . . . 79 140 16.9.1. COSE Security Message . . . . . . . . . . . . . . . 79 141 16.9.2. COSE Key media type . . . . . . . . . . . . . . . . 80 143 16.10. CoAP Content-Format Registrations . . . . . . . . . . . 82 144 16.11. Expert Review Instructions . . . . . . . . . . . . . . . 82 145 17. Implementation Status . . . . . . . . . . . . . . . . . . . . 83 146 17.1. Author's Versions . . . . . . . . . . . . . . . . . . . 84 147 17.2. COSE Testing Library . . . . . . . . . . . . . . . . . . 85 148 18. Security Considerations . . . . . . . . . . . . . . . . . . . 85 149 19. References . . . . . . . . . . . . . . . . . . . . . . . . . 87 150 19.1. Normative References . . . . . . . . . . . . . . . . . . 87 151 19.2. Informative References . . . . . . . . . . . . . . . . . 88 152 Appendix A. Making Mandatory Algorithm Header Optional . . . . . 91 153 A.1. Algorithm Identification . . . . . . . . . . . . . . . . 91 154 A.2. Counter Signature Without Headers . . . . . . . . . . . . 94 155 Appendix B. Two Layers of Recipient Information . . . . . . . . 95 156 Appendix C. Examples . . . . . . . . . . . . . . . . . . . . . . 96 157 C.1. Examples of Signed Message . . . . . . . . . . . . . . . 97 158 C.1.1. Single Signature . . . . . . . . . . . . . . . . . . 97 159 C.1.2. Multiple Signers . . . . . . . . . . . . . . . . . . 98 160 C.1.3. Counter Signature . . . . . . . . . . . . . . . . . . 99 161 C.1.4. Signature w/ Criticality . . . . . . . . . . . . . . 100 162 C.2. Single Signer Examples . . . . . . . . . . . . . . . . . 101 163 C.2.1. Single ECDSA signature . . . . . . . . . . . . . . . 101 164 C.3. Examples of Enveloped Messages . . . . . . . . . . . . . 102 165 C.3.1. Direct ECDH . . . . . . . . . . . . . . . . . . . . . 102 166 C.3.2. Direct plus Key Derivation . . . . . . . . . . . . . 103 167 C.3.3. Counter Signature on Encrypted Content . . . . . . . 104 168 C.3.4. Encrypted Content with External Data . . . . . . . . 106 169 C.4. Examples of Encrypted Messages . . . . . . . . . . . . . 106 170 C.4.1. Simple Encrypted Message . . . . . . . . . . . . . . 106 171 C.4.2. Encrypted Message w/ a Partial IV . . . . . . . . . . 107 172 C.5. Examples of MACed messages . . . . . . . . . . . . . . . 107 173 C.5.1. Shared Secret Direct MAC . . . . . . . . . . . . . . 107 174 C.5.2. ECDH Direct MAC . . . . . . . . . . . . . . . . . . . 108 175 C.5.3. Wrapped MAC . . . . . . . . . . . . . . . . . . . . . 109 176 C.5.4. Multi-recipient MACed message . . . . . . . . . . . . 110 177 C.6. Examples of MAC0 messages . . . . . . . . . . . . . . . . 111 178 C.6.1. Shared Secret Direct MAC . . . . . . . . . . . . . . 111 179 C.7. COSE Keys . . . . . . . . . . . . . . . . . . . . . . . . 112 180 C.7.1. Public Keys . . . . . . . . . . . . . . . . . . . . . 112 181 C.7.2. Private Keys . . . . . . . . . . . . . . . . . . . . 113 182 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 115 183 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 116 185 1. Introduction 187 There has been an increased focus on the small, constrained devices 188 that make up the Internet of Things (IoT). One of the standards that 189 has come out of this process is the Concise Binary Object 190 Representation (CBOR) [RFC7049]. CBOR extended the data model of the 191 JavaScript Object Notation (JSON) [RFC7159] by allowing for binary 192 data, among other changes. CBOR is being adopted by several of the 193 IETF working groups dealing with the IoT world as their encoding of 194 data structures. CBOR was designed specifically to be both small in 195 terms of messages transport and implementation size, as well having a 196 schema free decoder. A need exists to provide message security 197 services for IoT and using CBOR as the message encoding format makes 198 sense. 200 The JOSE working group produced a set of documents 201 [RFC7515][RFC7516][RFC7517][RFC7518] using JSON that specified how to 202 process encryption, signatures and message authentication (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 identified and still have a 223 consistent view. 225 o Signed messages separate the concept of protected and unprotected 226 parameters that are for the content and the signature. 228 o MACed messages are separated from signed messages. 230 o MACed messages have the ability to use the same set of recipient 231 algorithms as enveloped messages for obtaining the MAC 232 authentication key. 234 o Use binary encodings for binary data rather than base64url 235 encodings. 237 o Combine the authentication tag for encryption algorithms with the 238 cipher text. 240 o The set of cryptographic algorithms has been expanded in some 241 directions, and trimmed in others. 243 1.2. Requirements Terminology 245 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 246 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 247 "OPTIONAL" in this document are to be interpreted as described in 248 [RFC2119]. 250 When the words appear in lower case, their natural language meaning 251 is used. 253 1.3. CBOR Grammar 255 There currently is no standard CBOR grammar available for use by 256 specifications. We therefore describe the CBOR structures in prose. 258 The document was developed by first working on the grammar and then 259 developing the prose to go with it. An artifact of this is that the 260 prose was written using the primitive type strings defined by CBOR 261 Data Definition Language (CDDL) [I-D.greevenbosch-appsawg-cbor-cddl]. 262 In this specification, the following primitive types are used: 264 any - non-specific value that permits all CBOR values to be placed 265 here. 267 bool - a boolean value (true: major type 7, value 21; false: major 268 type 7, value 20). 270 bstr - byte string (major type 2). 272 int - an unsigned integer or a negative integer. 274 nil - a null value (major type 7, value 22). 276 nint - a negative integer (major type 1). 278 tstr - a UTF-8 text string (major type 3). 280 uint - an unsigned integer (major type 0). 282 As well as the prose description, a version of a CBOR grammar is 283 presented in CDDL. Since CDDL has not been published as an RFC, this 284 grammar may not work with the final version of CDDL. The CDDL 285 grammar is informational, the prose description is normative. 287 The collected CDDL can be extracted from the XML version of this 288 document via the following XPath expression below. (Depending on the 289 XPath evaluator one is using, it may be necessary to deal with > 290 as an entity.) 292 //artwork[@type='CDDL']/text() 294 CDDL expects the initial non-terminal symbol to be the first symbol 295 in the file. For this, reason the first fragment of CDDL is 296 presented here. 298 start = COSE_Messages / COSE_Key / COSE_KeySet / Internal_Types 300 ; This is defined to make the tool quieter: 301 Internal_Types = Sig_structure / Enc_structure / MAC_structure / 302 COSE_KDF_Context 304 The non-terminal Internal_Types is defined for dealing with the 305 automated validation tools used during the writing of this document. 306 It references those non-terminals that are used for security 307 computations, but are not emitted for transport. 309 1.4. CBOR Related Terminology 311 In JSON, maps are called objects and only have one kind of map key: a 312 string. In COSE, we use strings, negative integers and unsigned 313 integers as map keys. The integers are used for compactness of 314 encoding and easy comparison. Since the word "key" is mainly used in 315 its other meaning, as a cryptographic key, we use the term "label" 316 for this usage as a map key. 318 The presence of a label in a COSE map which is not a string or an 319 integer is an error. Applications can either fail processing or 320 process messages with incorrect labels, however they MUST NOT create 321 messages with incorrect labels. 323 A CDDL grammar fragment is defined that defines the non-terminals 324 'label', as in the previous paragraph and 'values', which permits any 325 value to be used. 327 label = int / tstr 328 values = any 330 1.5. Document Terminology 332 In this document, we use the following terminology: 334 Byte is a synonym for octet. 336 Constrained Application Protocol (CoAP) is a specialized web transfer 337 protocol for use in constrained systems. It is defined in [RFC7252]. 339 Authenticated Encryption (AE) algorithms are those encryption 340 algorithms which provide an authentication check of the contents 341 algorithm with the encryption service. 343 Authenticated Encryption with Authenticated Data (AEAD) algorithms 344 provide the same content authentication service as AE algorithms, but 345 additionally provide for authentication of non-encrypted data as 346 well. 348 2. Basic COSE Structure 350 The COSE object structure is designed so that there can be a large 351 amount of common code when parsing and processing the different 352 security messages. All of the message structures are built on the 353 CBOR array type. The first three elements of the array always 354 contain the same information: 356 1. The set of protected header parameters wrapped in a bstr. 358 2. The set of unprotected header parameters as a map. 360 3. The content of the message. The content is either the plain text 361 or the cipher text as appropriate. The content may be detached, 362 but the location is still used. The content is wrapped in a bstr 363 when present and is a nil value when detached. 365 Elements after this point are dependent on the specific message type. 367 Identification of which type of message has been presented is done by 368 the following method: 370 1. The specific message type is known from the context. This may be 371 defined by a marker in the containing structure or by 372 restrictions specified by the application protocol. 374 2. The message type is identified by a CBOR tag. Messages with a 375 CBOR tag are known in this specification as tagged messages, 376 while those without the CBOR tag are known as untagged messages. 377 This document defines a CBOR tag for each of the message 378 structures. These tags can be found in Table 1. 380 3. When a COSE object is carried in a media type of application/ 381 cose, the optional parameter 'cose-type' can be used to identify 382 the embedded object. The parameter is OPTIONAL if the tagged 383 version of the structure is used. The parameter is REQUIRED if 384 the untagged version of the structure is used. The value to use 385 with the parameter for each of the structures can be found in 386 Table 1. 388 4. When a COSE object is carried as a CoAP payload, the CoAP 389 Content-Format Option can be used to identify the message 390 content. The CoAP Content-Format values can be found in 391 Table 26. The CBOR tag for the message structure is not required 392 as each security message is uniquely identified. 394 +-------+---------------+---------------+---------------------------+ 395 | CBOR | cose-type | Data Item | Semantics | 396 | Tag | | | | 397 +-------+---------------+---------------+---------------------------+ 398 | TBD1 | cose-sign | COSE_Sign | COSE Signed Data Object | 399 | | | | | 400 | TBD7 | cose-sign1 | COSE_Sign1 | COSE Single Signer Data | 401 | | | | Object | 402 | | | | | 403 | TBD2 | cose-encrypt | COSE_Encrypt | COSE Encrypted Data | 404 | | | | Object | 405 | | | | | 406 | TBD3 | cose-encrypt0 | COSE_Encrypt0 | COSE Single Recipient | 407 | | | | Encrypted Data Object | 408 | | | | | 409 | TBD4 | cose-mac | COSE_Mac | COSE Mac-ed Data Object | 410 | | | | | 411 | TBD6 | cose-mac0 | COSE_Mac0 | COSE Mac w/o Recipients | 412 | | | | Object | 413 +-------+---------------+---------------+---------------------------+ 415 Table 1: COSE Message Identification 417 The following CDDL fragment identifies all of the top messages 418 defined in this document. Separate non-terminals are defined for the 419 tagged and the untagged versions of the messages. 421 COSE_Messages = COSE_Untagged_Message / COSE_Tagged_Message 423 COSE_Untagged_Message = COSE_Sign / COSE_Sign1 / 424 COSE_Encrypt / COSE_Encrypt0 / 425 COSE_Mac / COSE_Mac0 427 COSE_Tagged_Message = COSE_Sign_Tagged / COSE_Sign1_Tagged / 428 COSE_Encrypt_Tagged / COSE_Encrypt0_Tagged / 429 COSE_Mac_Tagged / COSE_Mac0_Tagged 431 3. Header Parameters 433 The structure of COSE has been designed to have two buckets of 434 information that are not considered to be part of the payload itself, 435 but are used for holding information about content, algorithms, keys, 436 or evaluation hints for the processing of the layer. These two 437 buckets are available for use in all of the structures except for 438 keys. While these buckets are present, they may not all be usable in 439 all instances. For example, while the protected bucket is defined as 440 part of the recipient structure, some of the algorithms used for 441 recipient structures do not provide for authenticated data. If this 442 is the case, the protected bucket is left empty. 444 Both buckets are implemented as CBOR maps. The map key is a 'label' 445 (Section 1.4). The value portion is dependent on the definition for 446 the label. Both maps use the same set of label/value pairs. The 447 integer and string values for labels has been divided into several 448 sections with a standard range, a private range, and a range that is 449 dependent on the algorithm selected. The defined labels can be found 450 in the "COSE Header Parameters" IANA registry (Section 16.2). 452 Two buckets are provided for each layer: 454 protected: Contains parameters about the current layer that are to 455 be cryptographically protected. This bucket MUST be empty if it 456 is not going to be included in a cryptographic computation. This 457 bucket is encoded in the message as a binary object. This value 458 is obtained by CBOR encoding the protected map and wrapping it in 459 a bstr object. Senders SHOULD encode an empty protected map as a 460 zero length binary object (i.e., the byte string h'a0'). This 461 encoding is used because it is both shorter and the version used 462 in the serialization structures for cryptographic computation. 463 Recipients MUST accept both a zero length binary value and a zero 464 length map encoded in the binary value. The wrapping allows for 465 the encoding of the protected map to be transported with a greater 466 chance that it will not be altered in transit. (Badly behaved 467 intermediates could decode and re-encode, but this will result in 468 a failure to verify unless the re-encoded byte string is identical 469 to the decoded byte string.) This avoids the problem of all 470 parties needing to be able to do a common canonical encoding. 472 unprotected: Contains parameters about the current layer that are 473 not cryptographically protected. 475 Only parameters that deal with the current layer are to be placed at 476 that layer. As an example of this, the parameter 'content type' 477 describes the content of the message being carried in the message. 478 As such, this parameter is placed only in the content layer and is 479 not placed in the recipient or signature layers. In principle, one 480 should be able to process any given layer without reference to any 481 other layer. (With the exception of the COSE_Sign structure, the 482 only data that needs to cross layers is the cryptographic key.) 484 The buckets are present in all of the security objects defined in 485 this document. The fields in order are the 'protected' bucket (as a 486 CBOR 'bstr' type) and then the 'unprotected' bucket (as a CBOR 'map' 487 type). The presence of both buckets is required. The parameters 488 that go into the buckets come from the IANA "COSE Header Parameters" 489 registry (Section 16.2). Some common parameters are defined in the 490 next section, but a number of parameters are defined throughout this 491 document. 493 Labels in each of the maps MUST be unique. When processing messages, 494 if a label appears multiple times, the message MUST be rejected as 495 malformed. Applications SHOULD perform the same checks that the same 496 label does not occur in both the protected and unprotected headers. 497 If the message is not rejected as malformed, attributes MUST be 498 obtained from the protected bucket before they are obtained from the 499 unprotected bucket. 501 The following CDDL fragment represents the two header buckets. A 502 group Headers is defined in CDDL that represents the two buckets in 503 which attributes are placed. This group is used to provide these two 504 fields consistently in all locations. A type is also defined which 505 represents the map of common headers. 507 Headers = ( 508 protected : empty_or_serialized_map, 509 unprotected : header_map 510 ) 512 header_map = { 513 Generic_Headers, 514 * label => values 515 } 517 empty_or_serialized_map = bstr .cbor header_map / bstr .size 0 519 3.1. Common COSE Headers Parameters 521 This section defines a set of common header parameters. A summary of 522 these parameters can be found in Table 2. This table should be 523 consulted to determine the value of label, and the type of the value. 525 The set of header parameters defined in this section are: 527 alg This parameter is used to indicate the algorithm used for the 528 security processing. This parameter MUST be present in the 529 COSE_Signature, COSE_Sign1, COSE_Encrypt, COSE_Encrypt0, COSE_Mac, 530 and COSE_Mac0 structures. When the algorithm supports 531 authenticating associated data, this parameter MUST be in the 532 protected header bucket. The value is taken from the "COSE 533 Algorithms" Registry (see Section 16.4). 535 crit The parameter is used to indicate which protected header labels 536 an application that is processing a message is required to 537 understand. Parameters defined in this document do not need to be 538 included as they should be understood by all implementations. 539 When present, this parameter MUST be placed in the protected 540 header bucket. The array MUST have at least one value in it. 541 Not all labels need to be included in the 'crit' parameter. The 542 rules for deciding which header labels are placed in the array 543 are: 545 * Integer labels in the range of 0 to 8 SHOULD be omitted. 547 * Integer labels in the range -1 to -255 can be omitted as they 548 are algorithm dependent. If an application can correctly 549 process an algorithm, it can be assumed that it will correctly 550 process all of the common parameters associated with that 551 algorithm. (The algorithm range is -1 to -65536; the higher 552 end is for more optional algorithm specific items.) 554 * Labels for parameters required for an application MAY be 555 omitted. Applications should have a statement if the label can 556 be omitted. 558 The header parameter values indicated by 'crit' can be processed 559 by either the security library code or by an application using a 560 security library; the only requirement is that the parameter is 561 processed. If the 'crit' value list includes a value for which 562 the parameter is not in the protected bucket, this is a fatal 563 error in processing the message. 565 content type This parameter is used to indicate the content type of 566 the data in the payload or cipher text fields. Integers are from 567 the "CoAP Content-Formats" IANA registry table. Text values 568 following the syntax of Content-Type defined in Section 5.1 of 569 [RFC2045] omitting the prefix string "Content-Type:". Leading and 570 trailing whitespace is also omitted. Textual content values along 571 with parameters and subparameters can be located using the IANA 572 "Media Types" registry. Applications SHOULD provide this 573 parameter if the content structure is potentially ambiguous. 575 kid This parameter identifies one piece of data that can be used as 576 input to find the needed cryptographic key. The value of this 577 parameter can be matched against the 'kid' member in a COSE_Key 578 structure. Other methods of key distribution can define an 579 equivalent field to be matched. Applications MUST NOT assume that 580 'kid' values are unique. There may be more than one key with the 581 same 'kid' value, so all of the keys may need to be checked to 582 find the correct one. The internal structure of 'kid' values is 583 not defined and cannot be relied on by applications. Key 584 identifier values are hints about which key to use. This is not a 585 security critical field. For this reason, it SHOULD be placed in 586 the unprotected headers bucket. 588 Initialization Vector This parameter holds the Initialization Vector 589 (IV) value. For some symmetric encryption algorithms this may be 590 referred to as a nonce. As the IV is authenticated by the 591 encryption process, it SHOULD be placed in the unprotected header 592 bucket. 594 Partial Initialization Vector This parameter holds a part of the IV 595 value. When using the COSE_Encrypt0 structure, a portion of the 596 IV can be part of the context associated with the key. This field 597 is used to carry a value that causes the IV to be changed for each 598 message. As the IV is authenticated by the encryption process, 599 this value can be placed in the unprotected header bucket. The 600 'Initialization Vector' and 'Partial Initialization Vector' 601 parameters MUST NOT both be present in the same security layer. 602 The message IV is generated by the following steps: 604 1. Left pad the partial IV with zeros to the length of IV. 606 2. XOR the padded partial IV with the context IV. 608 counter signature This parameter holds one or more counter signature 609 values. Counter signatures provide a method of having a second 610 party sign some data. The counter signature can occur as an 611 unprotected attribute in any of the following structures: 612 COSE_Sign, COSE_Sign1, COSE_Signature, COSE_Encrypt, 613 COSE_recipient, COSE_Encrypt0, COSE_Mac and COSE_Mac0. These 614 structures all have the same beginning elements so that a 615 consistent calculation of the counter signature can be computed. 616 Details on computing counter signatures are found in Section 4.5. 618 +-----------+-------+----------------+-------------+----------------+ 619 | name | label | value type | value | description | 620 | | | | registry | | 621 +-----------+-------+----------------+-------------+----------------+ 622 | alg | 1 | int / tstr | COSE | Cryptographic | 623 | | | | Algorithms | algorithm to | 624 | | | | registry | use | 625 | | | | | | 626 | crit | 2 | [+ label] | COSE Header | Critical | 627 | | | | Labels | headers to be | 628 | | | | registry | understood | 629 | | | | | | 630 | content | 3 | tstr / uint | CoAP | Content type | 631 | type | | | Content- | of the payload | 632 | | | | Formats or | | 633 | | | | Media Types | | 634 | | | | registry | | 635 | | | | | | 636 | kid | 4 | bstr | | Key identifier | 637 | | | | | | 638 | IV | 5 | bstr | | Full | 639 | | | | | Initialization | 640 | | | | | Vector | 641 | | | | | | 642 | Partial | 6 | bstr | | Partial | 643 | IV | | | | Initialization | 644 | | | | | Vector | 645 | | | | | | 646 | counter | 7 | COSE_Signature | | CBOR encoded | 647 | signature | | / [+ | | signature | 648 | | | COSE_Signature | | structure | 649 | | | ] | | | 650 +-----------+-------+----------------+-------------+----------------+ 652 Table 2: Common Header Parameters 654 The CDDL fragment that represents the set of headers defined in this 655 section is given below. Each of the headers is tagged as optional 656 because they do not need to be in every map; headers required in 657 specific maps are discussed above. 659 Generic_Headers = ( 660 ? 1 => int / tstr, ; algorithm identifier 661 ? 2 => [+label], ; criticality 662 ? 3 => tstr / int, ; content type 663 ? 4 => bstr, ; key identifier 664 ? 5 => bstr, ; IV 665 ? 6 => bstr, ; Partial IV 666 ? 7 => COSE_Signature / [+COSE_Signature] ; Counter signature 667 ) 669 4. Signing Objects 671 COSE supports two different signature structures. COSE_Sign allows 672 for one or more signers to be applied to a single content. 673 COSE_Sign1 is restricted to a single signer. The structures cannot 674 be converted between each other; as the signature computation 675 includes a parameter identifying which structure is being used, the 676 converted structure will fail signature validation. 678 4.1. Signing with One or More Signers 680 The COSE_Sign structure allows for one or more signatures to be 681 applied to a message payload. There are provisions for parameters 682 about the content and parameters about the signature to be carried 683 along with the signature itself. These parameters may be 684 authenticated by the signature, or just present. An example of a 685 parameter about the content is the content type. Examples of 686 parameters about the signature would be the algorithm and key used to 687 create the signature and counter signatures. 689 When more than one signature is present, the successful validation of 690 one signature associated with a given signer is usually treated as a 691 successful signature by that signer. However, there are some 692 application environments where other rules are needed. An 693 application that employs a rule other than one valid signature for 694 each signer must specify those rules. Also, where simple matching of 695 the signer identifier is not sufficient to determine whether the 696 signatures were generated by the same signer, the application 697 specification must describe how to determine which signatures were 698 generated by the same signer. Support of different communities of 699 recipients is the primary reason that signers choose to include more 700 than one signature. For example, the COSE_Sign structure might 701 include signatures generated with the Edwards Digital Signature 702 Algorithm (EdDSA) signature algorithm and with the Elliptic Curve 703 Digital Signature Algorithm (ECDSA) signature algorithm. This allows 704 recipients to verify the signature associated with one algorithm or 705 the other. (The original source of this text is [RFC5652].) More 706 detailed information on multiple signature evaluation can be found in 707 [RFC5752]. 709 The signature structure can be encoded either as tagged or untagged 710 depending on the context it will be used in. A tagged COSE_Sign 711 structure is identified by the CBOR tag TBD1. The CDDL fragment that 712 represents this is: 714 COSE_Sign_Tagged = #6.991(COSE_Sign) ; Replace 991 with TBD1 716 A COSE Signed Message is defined in two parts. The CBOR object that 717 carries the body and information about the body is called the 718 COSE_Sign structure. The CBOR object that carries the signature and 719 information about the signature is called the COSE_Signature 720 structure. Examples of COSE Signed Messages can be found in 721 Appendix C.1. 723 The COSE_Sign structure is a CBOR array. The fields of the array in 724 order are: 726 protected as described in Section 3. 728 unprotected as described in Section 3. 730 payload contains the serialized content to be signed. If the 731 payload is not present in the message, the application is required 732 to supply the payload separately. The payload is wrapped in a 733 bstr to ensure that it is transported without changes. If the 734 payload is transported separately ("detached content"), then a nil 735 CBOR object is placed in this location and it is the 736 responsibility of the application to ensure that it will be 737 transported without changes. 739 Note: When a signature with message recovery algorithm is used 740 (Section 8), the maximum number of bytes that can be recovered is 741 the length of the payload. The size of the payload is reduced by 742 the number of bytes that will be recovered. If all of the bytes 743 of the payload are consumed, then the payload is encoded as a zero 744 length binary string rather than as being absent. 746 signatures is an array of signatures. Each signature is represented 747 as a COSE_Signature structure. 749 The CDDL fragment that represents the above text for COSE_Sign 750 follows. 752 COSE_Sign = [ 753 Headers, 754 payload : bstr / nil, 755 signatures : [+ COSE_Signature] 756 ] 758 The COSE_Signature structure is a CBOR array. The fields of the 759 array in order are: 761 protected as described in Section 3. 763 unprotected as described in Section 3. 765 signature contains the computed signature value. The type of the 766 field is a bstr. 768 The CDDL fragment that represents the above text for COSE_Signature 769 follows. 771 COSE_Signature = [ 772 Headers, 773 signature : bstr 774 ] 776 4.2. Signing with One Signer 778 The COSE_Sign1 signature structure is used when only one signer is 779 going to be placed on a message. The parameters dealing with the 780 content and the signature are placed in the same pair of buckets 781 rather than having the separation of COSE_Sign. 783 The structure can be encoded either tagged or untagged depending on 784 the context it will be used in. A tagged COSE_Sign1 structure is 785 identified by the CBOR tag TBD7. The CDDL fragment that represents 786 this is: 788 COSE_Sign1_Tagged = #6.997(COSE_Sign1) ; Replace 997 with TBD7 790 The CBOR object that carries the body, the signature, and the 791 information about the body and signature is called the COSE_Sign1 792 structure. Examples of COSE_Sign1 messages can be found in 793 Appendix C.2. 795 The COSE_Sign1 structure is a CBOR array. The fields of the array in 796 order are: 798 protected as described in Section 3. 800 unprotected as described in Section 3. 802 payload as described in Section 4.1. 804 signature contains the computed signature value. The type of the 805 field is a bstr. 807 The CDDL fragment that represents the above text for COSE_Sign1 808 follows. 810 COSE_Sign1 = [ 811 Headers, 812 payload : bstr / nil, 813 signature : bstr 814 ] 816 4.3. Externally Supplied Data 818 One of the features supplied in the COSE document is the ability for 819 applications to provide additional data to be authenticated, but that 820 is not carried as part of the COSE object. The primary reason for 821 supporting this can be seen by looking at the CoAP message structure 822 [RFC7252], where the facility exists for options to be carried before 823 the payload. Examples of data that can be placed in this location 824 would be the CoAP code or CoAP options. If the data is in the header 825 section, then it is available for proxies to help in performing its 826 operations. For example, the Accept Option can be used by a proxy to 827 determine if an appropriate value is in the Proxy's cache. But the 828 sender can prevent a proxy from changing the set of values that it 829 will accept by including that value in the resulting authentication 830 tag. However, it may also be desired to protect these values so that 831 if they are modified in transit, it can be detected. 833 This document describes the process for using a byte array of 834 externally supplied authenticated data; however, the method of 835 constructing the byte array is a function of the application. 836 Applications that use this feature need to define how the externally 837 supplied authenticated data is to be constructed. Such a 838 construction needs to take into account the following issues: 840 o If multiple items are included, care needs to be taken that data 841 cannot bleed between the items. This is usually addressed by 842 making fields fixed width and/or encoding the length of the field. 843 Using options from CoAP [RFC7252] as an example, these fields use 844 a TLV structure so they can be concatenated without any problems. 846 o If multiple items are included, an order for the items needs to be 847 defined. Using options from CoAP as an example, an application 848 could state that the fields are to be ordered by the option 849 number. 851 o Applications need to ensure that the byte stream is going to be 852 the same on both sides. Using options from CoAP might give a 853 problem if the same relative numbering is kept. An intermediate 854 node could insert or remove an option, changing how the relative 855 number is done. An application would need to specify that the 856 relative number must be re-encoded to be relative only to the 857 options that are in the external data. 859 4.4. Signing and Verification Process 861 In order to create a signature, a well-defined byte stream is needed. 862 This algorithm takes in the body information (COSE_Sign or 863 COSE_Sign1), the signer information (COSE_Signature), and the 864 application data (external source). A CBOR array is used to 865 construct the byte stream. The fields of the array in order are: 867 1. A text string identifying the context of the signature. The 868 context string is: 870 "Signature" for signatures using the COSE_Signature structure. 872 "Signature1" for signatures using the COSE_Sign1 structure. 874 "CounterSignature" for signatures used as counter signature 875 attributes. 877 2. The protected attributes from the body structure encoded in a 878 bstr type. If there are no protected attributes, a bstr of 879 length zero is used. 881 3. The protected attributes from the signer structure encoded in a 882 bstr type. If there are no protected attributes, a bstr of 883 length zero is used. This field is omitted for the COSE_Sign1 884 signature structure. 886 4. The protected attributes from the application encoded in a bstr 887 type. If this field is not supplied, it defaults to a zero 888 length binary string. (See Section 4.3 for application guidance 889 on constructing this field.) 891 5. The payload to be signed encoded in a bstr type. The payload is 892 placed here independent of how it is transported. 894 The CDDL fragment that describes the above text is. 896 Sig_structure = [ 897 context : "Signature" / "Signature1" / "CounterSignature", 898 body_protected : empty_or_serialized_map, 899 ? sign_protected : empty_or_serialized_map, 900 external_aad : bstr, 901 payload : bstr 902 ] 904 How to compute a signature: 906 1. Create a Sig_structure and populate it with the appropriate 907 fields. 909 2. Create the value ToBeSigned by encoding the Sig_structure to a 910 byte string, using the encoding described in Section 14. 912 3. Call the signature creation algorithm passing in K (the key to 913 sign with), alg (the algorithm to sign with), and ToBeSigned (the 914 value to sign). 916 4. Place the resulting signature value in the 'signature' field of 917 the array. 919 How to verify a signature: 921 1. Create a Sig_structure object and populate it with the 922 appropriate fields. 924 2. Create the value ToBeSigned by encoding the Sig_structure to a 925 byte string, using the encoding described in Section 14. 927 3. Call the signature verification algorithm passing in K (the key 928 to verify with), alg (the algorithm used sign with), ToBeSigned 929 (the value to sign), and sig (the signature to be verified). 931 In addition to performing the signature verification, one must also 932 perform the appropriate checks to ensure that the key is correctly 933 paired with the signing identity and that the signing identity is 934 authorized before performing actions. 936 4.5. Computing Counter Signatures 938 Counter signatures provide a method of having a different signature 939 occur on some piece of content. This is normally used to provide a 940 signature on a signature allowing for a proof that a signature 941 existed at a given time (i.e., a Timestamp). In this document, we 942 allow for counter signatures to exist in a greater number of 943 environments. As an example, it is possible to place a counter 944 signature in the unprotected attributes of a COSE_Encrypt object. 945 This would allow for an intermediary to either verify that the 946 encrypted byte stream has not been modified, without being able to 947 decrypt it, or for the intermediary to assert that an encrypted byte 948 stream either existed at a given time or passed through it in terms 949 of routing (i.e., a proxy signature). 951 An example of a counter signature on a signature can be found in 952 Appendix C.1.3. An example of a counter signature in an encryption 953 object can be found in Appendix C.3.3. 955 The creation and validation of counter signatures over the different 956 items relies on the fact that the structure of the objects have the 957 same structure. The elements are a set of protected attributes, a 958 set of unprotected attributes, and a body, in that order. This means 959 that the Sig_structure can be used in a uniform manner to get the 960 byte stream for processing a signature. If the counter signature is 961 going to be computed over a COSE_Encrypt structure, the 962 body_protected and payload items can be mapped into the Sig_structure 963 in the same manner as from the COSE_Sign structure. 965 It should be noted that only a signature algorithm with appendix (see 966 Section 8) can be used for counter signatures. This is because the 967 body should be able to be processed without having to evaluate the 968 counter signature, and this is not possible for signature schemes 969 with message recovery. 971 5. Encryption Objects 973 COSE supports two different encryption structures. COSE_Encrypt0 is 974 used when a recipient structure is not needed because the key to be 975 used is known implicitly. COSE_Encrypt is used the rest of the time. 976 This includes cases where there are multiple recipients or a 977 recipient algorithm other than direct is used. 979 5.1. Enveloped COSE Structure 981 The enveloped structure allows for one or more recipients of a 982 message. There are provisions for parameters about the content and 983 parameters about the recipient information to be carried in the 984 message. The protected parameters associated with the content are 985 authenticated by the content encryption algorithm. The protected 986 parameters associated with the recipient are authenticated by the 987 recipient algorithm (when the algorithm supports it). Examples of 988 parameters about the content are the type of the content and the 989 content encryption algorithm. Examples of parameters about the 990 recipient are the recipient's key identifier and the recipient's 991 encryption algorithm. 993 The same techniques and structures are used for encrypting both the 994 plain text and the keys. This is different from the approach used by 995 both CMS [RFC5652] and JSON Web Encryption (JWE) [RFC7516] where 996 different structures are used for the content layer and for the 997 recipient layer. Two structures are defined: COSE_Encrypt to hold 998 the encrypted content and COSE_recipient to hold the encrypted keys 999 for recipients. Examples of encrypted messages can be found in 1000 Appendix C.3. 1002 The COSE_Encrypt structure can be encoded either tagged or untagged 1003 depending on the context it will be used in. A tagged COSE_Encrypt 1004 structure is identified by the CBOR tag TBD2. The CDDL fragment that 1005 represents this is: 1007 COSE_Encrypt_Tagged = #6.992(COSE_Encrypt) ; Replace 992 with TBD2 1009 The COSE_Encrypt structure is a CBOR array. The fields of the array 1010 in order are: 1012 protected as described in Section 3. 1014 unprotected as described in Section 3. ' 1016 ciphertext contains the cipher text encoded as a bstr. If the 1017 cipher text is to be transported independently of the control 1018 information about the encryption process (i.e., detached content) 1019 then the field is encoded as a nil value. 1021 recipients contains an array of recipient information structures. 1022 The type for the recipient information structure is a 1023 COSE_recipient. 1025 The CDDL fragment that corresponds to the above text is: 1027 COSE_Encrypt = [ 1028 Headers, 1029 ciphertext : bstr / nil, 1030 recipients : [+COSE_recipient] 1031 ] 1033 The COSE_recipient structure is a CBOR array. The fields of the 1034 array in order are: 1036 protected as described in Section 3. 1038 unprotected as described in Section 3. 1040 ciphertext contains the encrypted key encoded as a bstr. If there 1041 is not an encrypted key, then this field is encoded as a nil 1042 value. 1044 recipients contains an array of recipient information structures. 1045 The type for the recipient information structure is a 1046 COSE_recipient. (An example of this can be found in Appendix B.) 1047 If there are no recipient information structures, this element is 1048 absent. 1050 The CDDL fragment that corresponds to the above text for 1051 COSE_recipient is: 1053 COSE_recipient = [ 1054 Headers, 1055 ciphertext : bstr / nil, 1056 ? recipients : [+COSE_recipient] 1057 ] 1059 5.1.1. Recipient Algorithm Classes 1061 An encrypted message consists of an encrypted content and an 1062 encrypted CEK for one or more recipients. The CEK is encrypted for 1063 each recipient, using a key specific to that recipient. The details 1064 of this encryption depend on which class the recipient algorithm 1065 falls into. Specific details on each of the classes can be found in 1066 Section 12. A short summary of the five recipient algorithm classes 1067 is: 1069 direct: The CEK is the same as the identified previously distributed 1070 symmetric key or derived from a previously distributed secret. No 1071 CEK is transported in the message. 1073 symmetric key-encryption keys: The CEK is encrypted using a 1074 previously distributed symmetric KEK. 1076 key agreement: The recipient's public key and a sender's private key 1077 are used to generate a pairwise secret, a KDF is applied to derive 1078 a key, and then the CEK is either the derived key or encrypted by 1079 the derived key. 1081 key transport: The CEK is encrypted with the recipient's public key. 1082 No key transport algorithms are defined in this document. 1084 passwords: The CEK is encrypted in a KEK that is derived from a 1085 password. No password algorithms are defined in this document. 1087 5.2. Single Recipient Encrypted 1089 The COSE_Encrypt0 encrypted structure does not have the ability to 1090 specify recipients of the message. The structure assumes that the 1091 recipient of the object will already know the identity of the key to 1092 be used in order to decrypt the message. If a key needs to be 1093 identified to the recipient, the enveloped structure ought to be 1094 used. 1096 Examples of encrypted messages can be found in Appendix C.3. 1098 The COSE_Encrypt0 structure can be encoded either tagged or untagged 1099 depending on the context it will be used in. A tagged COSE_Encrypt0 1100 structure is identified by the CBOR tag TBD3. The CDDL fragment that 1101 represents this is: 1103 COSE_Encrypt0_Tagged = #6.993(COSE_Encrypt0) ; Replace 993 with TBD3 1105 The COSE_Encrypt structure is a CBOR array. The fields of the array 1106 in order are: 1108 protected as described in Section 3. 1110 unprotected as described in Section 3. 1112 ciphertext as described in Section 5.1. 1114 The CDDL fragment for COSE_Encrypt0 that corresponds to the above 1115 text is: 1117 COSE_Encrypt0 = [ 1118 Headers, 1119 ciphertext : bstr / nil, 1120 ] 1122 5.3. Encryption Algorithm for AEAD algorithms 1124 The encryption algorithm for AEAD algorithms is fairly simple. The 1125 first step is to create a consistent byte stream for the 1126 authenticated data structure. For this purpose, we use a CBOR array. 1127 The fields of the array in order are: 1129 1. A text string identifying the context of the authenticated data 1130 structure. The context string is: 1132 "Encrypt0" for the content encryption of a COSE_Encrypt0 data 1133 structure. 1135 "Encrypt" for the first layer of a COSE_Encrypt data structure 1136 (i.e., for content encryption). 1138 "Enc_Recipient" for a recipient encoding to be placed in an 1139 COSE_Encrypt data structure. 1141 "Mac_Recipient" for a recipient encoding to be placed in a MACed 1142 message structure. 1144 "Rec_Recipient" for a recipient encoding to be placed in a 1145 recipient structure. 1147 2. The protected attributes from the body structure encoded in a 1148 bstr type. If there are no protected attributes, a bstr of 1149 length zero is used. 1151 3. The protected attributes from the application encoded in a bstr 1152 type. If this field is not supplied, it defaults to a zero 1153 length bstr. (See Section 4.3 for application guidance on 1154 constructing this field.) 1156 The CDDL fragment that describes the above text is: 1158 Enc_structure = [ 1159 context : "Encrypt" / "Encrypt0" / "Enc_Recipient" / 1160 "Mac_Recipient" / "Rec_Recipient", 1161 protected : empty_or_serialized_map, 1162 external_aad : bstr 1163 ] 1165 How to encrypt a message: 1167 1. Create an Enc_structure and populate it with the appropriate 1168 fields. 1170 2. Encode the Enc_structure to a byte stream (AAD), using the 1171 encoding described in Section 14. 1173 3. Determine the encryption key (K). This step is dependent on the 1174 class of recipient algorithm being used. For: 1176 No Recipients: The key to be used is determined by the algorithm 1177 and key at the current layer. Examples are key transport keys 1178 Section 12.3, key wrap keys Section 12.2.1 or pre-shared 1179 secrets. 1181 Direct and Direct Key Agreement: The key is determined by the 1182 key and algorithm in the recipient structure. The encryption 1183 algorithm and size of the key to be used are inputs into the 1184 KDF used for the recipient. (For direct, the KDF can be 1185 thought of as the identity operation.) Examples of these 1186 algorithms are found in Section 12.1.2 and Section 12.4.1. 1188 Other: The key is randomly generated. 1190 4. Call the encryption algorithm with K (the encryption key), P (the 1191 plain text) and AAD. Place the returned cipher text into the 1192 'ciphertext' field of the structure. 1194 5. For recipients of the message, recursively perform the encryption 1195 algorithm for that recipient, using K (the encryption key) as the 1196 plain text. 1198 How to decrypt a message: 1200 1. Create a Enc_structure and populate it with the appropriate 1201 fields. 1203 2. Encode the Enc_structure to a byte stream (AAD), using the 1204 encoding described in Section 14. 1206 3. Determine the decryption key. This step is dependent on the 1207 class of recipient algorithm being used. For: 1209 No Recipients: The key to be used is determined by the algorithm 1210 and key at the current layer. Examples are key transport keys 1211 Section 12.3, key wrap keys Section 12.2.1 or pre-shared 1212 secrets. 1214 Direct and Direct Key Agreement: The key is determined by the 1215 key and algorithm in the recipient structure. The encryption 1216 algorithm and size of the key to be used are inputs into the 1217 KDF used for the recipient. (For direct, the KDF can be 1218 thought of as the identity operation.) Examples of these 1219 algorithms are found in Section 12.1.2 and Section 12.4.1. 1221 Other: The key is determined by decoding and decrypting one of 1222 the recipient structures. 1224 4. Call the decryption algorithm with K (the decryption key to use), 1225 C (the cipher text) and AAD. 1227 5.4. Encryption algorithm for AE algorithms 1229 How to encrypt a message: 1231 1. Verify that the 'protected' field is empty. 1233 2. Verify that there was no external additional authenticated data 1234 supplied for this operation. 1236 3. Determine the encryption key. This step is dependent on the 1237 class of recipient algorithm being used. For: 1239 No Recipients: The key to be used is determined by the algorithm 1240 and key at the current layer. Examples are key transport keys 1241 Section 12.3, key wrap keys Section 12.2.1 or pre-shared 1242 secrets. 1244 Direct and Direct Key Agreement: The key is determined by the 1245 key and algorithm in the recipient structure. The encryption 1246 algorithm and size of the key to be used are inputs into the 1247 KDF used for the recipient. (For direct, the KDF can be 1248 thought of as the identity operation.) Examples of these 1249 algorithms are found in Section 12.1.2 and Section 12.4.1. 1251 Other: The key is randomly generated. 1253 4. Call the encryption algorithm with K (the encryption key to use) 1254 and the P (the plain text). Place the returned cipher text into 1255 the 'ciphertext' field of the structure. 1257 5. For recipients of the message, recursively perform the encryption 1258 algorithm for that recipient, using K (the encryption key) as the 1259 plain text. 1261 How to decrypt a message: 1263 1. Verify that the 'protected' field is empty. 1265 2. Verify that there was no external additional authenticated data 1266 supplied for this operation. 1268 3. Determine the decryption key. This step is dependent on the 1269 class of recipient algorithm being used. For: 1271 No Recipients: The key to be used is determined by the algorithm 1272 and key at the current layer. Examples are key transport keys 1273 Section 12.3, key wrap keys Section 12.2.1 or pre-shared 1274 secrets. 1276 Direct and Direct Key Agreement: The key is determined by the 1277 key and algorithm in the recipient structure. The encryption 1278 algorithm and size of the key to be used are inputs into the 1279 KDF used for the recipient. (For direct, the KDF can be 1280 thought of as the identity operation.) Examples of these 1281 algorithms are found in Section 12.1.2 and Section 12.4.1. 1283 Other: The key is determined by decoding and decrypting one of 1284 the recipient structures. 1286 4. Call the decryption algorithm with K (the decryption key to use), 1287 and C (the cipher text). 1289 6. MAC Objects 1291 COSE supports two different MAC structures. COSE_MAC0 is used when a 1292 recipient structure is not needed because the key to be used is 1293 implicitly known. COSE_MAC is used for all other cases. These 1294 include a requirement for multiple recipients, the key being unknown, 1295 and a recipient algorithm of other than direct. 1297 In this section, we describe the structure and methods to be used 1298 when doing MAC authentication in COSE. This document allows for the 1299 use of all of the same classes of recipient algorithms as are allowed 1300 for encryption. 1302 When using MAC operations, there are two modes in which they can be 1303 used. The first is just a check that the content has not been 1304 changed since the MAC was computed. Any class of recipient algorithm 1305 can be used for this purpose. The second mode is to both check that 1306 the content has not been changed since the MAC was computed, and to 1307 use the recipient algorithm to verify who sent it. The classes of 1308 recipient algorithms that support this are those that use a pre- 1309 shared secret or do static-static key agreement (without the key wrap 1310 step). In both of these cases, the entity that created and sent the 1311 message MAC can be validated. (This knowledge of sender assumes that 1312 there are only two parties involved and you did not send the message 1313 yourself.) The origination property can be obtained with both of the 1314 MAC message structures. 1316 6.1. MACed Message with Recipients 1318 The multiple recipient MACed message uses two structures, the 1319 COSE_Mac structure defined in this section for carrying the body and 1320 the COSE_recipient structure (Section 5.1) to hold the key used for 1321 the MAC computation. Examples of MACed messages can be found in 1322 Appendix C.5. 1324 The MAC structure can be encoded either tagged or untagged depending 1325 on the context it will be used in. A tagged COSE_Mac structure is 1326 identified by the CBOR tag TBD4. The CDDL fragment that represents 1327 this is: 1329 COSE_Mac_Tagged = #6.994(COSE_Mac) ; Replace 994 with TBD4 1331 The COSE_Mac structure is a CBOR array. The fields of the array in 1332 order are: 1334 protected as described in Section 3. 1336 unprotected as described in Section 3. 1338 payload contains the serialized content to be MACed. If the payload 1339 is not present in the message, the application is required to 1340 supply the payload separately. The payload is wrapped in a bstr 1341 to ensure that it is transported without changes. If the payload 1342 is transported separately (i.e., detached content), then a nil 1343 CBOR value is placed in this location and it is the responsibility 1344 of the application to ensure that it will be transported without 1345 changes. 1347 tag contains the MAC value. 1349 recipients as described in Section 5.1. 1351 The CDDL fragment that represents the above text for COSE_Mac 1352 follows. 1354 COSE_Mac = [ 1355 Headers, 1356 payload : bstr / nil, 1357 tag : bstr, 1358 recipients :[+COSE_recipient] 1359 ] 1361 6.2. MACed Messages with Implicit Key 1363 In this section, we describe the structure and methods to be used 1364 when doing MAC authentication for those cases where the recipient is 1365 implicitly known. 1367 The MACed message uses the COSE_Mac0 structure defined in this 1368 section for carrying the body. Examples of MACed messages with an 1369 implicit key can be found in Appendix C.6. 1371 The MAC structure can be encoded either tagged or untagged depending 1372 on the context it will be used in. A tagged COSE_Mac0 structure is 1373 identified by the CBOR tag TBD6. The CDDL fragment that represents 1374 this is: 1376 COSE_Mac0_Tagged = #6.996(COSE_Mac0) ; Replace 996 with TBD6 1378 The COSE_Mac0 structure is a CBOR array. The fields of the array in 1379 order are: 1381 protected as described in Section 3. 1383 unprotected as described in Section 3. 1385 payload as described in Section 6.1. 1387 tag contains the MAC value. 1389 The CDDL fragment that corresponds to the above text is: 1391 COSE_Mac0 = [ 1392 Headers, 1393 payload : bstr / nil, 1394 tag : bstr, 1395 ] 1397 6.3. How to compute and verify a MAC 1399 In order to get a consistent encoding of the data to be 1400 authenticated, the MAC_structure is used to have a canonical form. 1401 The MAC_structure is a CBOR array. The fields of the MAC_structure 1402 in order are: 1404 1. A text string that identifies the structure that is being 1405 encoded. This string is "MAC" for the COSE_Mac structure. This 1406 string is "MAC0" for the COSE_Mac0 structure. 1408 2. The protected attributes from the COSE_MAC structure. If there 1409 are no protected attributes, a zero length bstr is used. 1411 3. The protected attributes from the application encoded as a bstr 1412 type. If this field is not supplied, it defaults to a zero 1413 length binary string. (See Section 4.3 for application guidance 1414 on constructing this field.) 1416 4. The payload to be MAC-ed encoded in a bstr type. The payload is 1417 placed here independent of how it is transported. 1419 The CDDL fragment that corresponds to the above text is: 1421 MAC_structure = [ 1422 context : "MAC" / "MAC0", 1423 protected : empty_or_serialized_map, 1424 external_aad : bstr, 1425 payload : bstr 1426 ] 1428 The steps to compute a MAC are: 1430 1. Create a MAC_structure and populate it with the appropriate 1431 fields. 1433 2. Create the value ToBeMaced by encoding the MAC_structure to a 1434 byte stream, using the encoding described in Section 14. 1436 3. Call the MAC creation algorithm passing in K (the key to use), 1437 alg (the algorithm to MAC with) and ToBeMaced (the value to 1438 compute the MAC on). 1440 4. Place the resulting MAC in the 'tag' field of the COSE_Mac or 1441 COSE_Mac0 structure. 1443 5. Encrypt and encode the MAC key for each recipient of the message. 1445 How to verify a MAC are: 1447 1. Create a MAC_structure object and populate it with the 1448 appropriate fields. 1450 2. Create the value ToBeMaced by encoding the MAC_structure to a 1451 byte stream, using the encoding described in Section 14. 1453 3. Obtain the cryptographic key from one of the recipients of the 1454 message. 1456 4. Call the MAC creation algorithm passing in K (the key to use), 1457 alg (the algorithm to MAC with) and ToBeMaced (the value to 1458 compute the MAC on). 1460 5. Compare the MAC value to the 'tag' field of the COSE_Mac or 1461 COSE_Mac0 structure. 1463 7. Key Objects 1465 A COSE Key structure is built on a CBOR map object. The set of 1466 common parameters that can appear in a COSE Key can be found in the 1467 IANA "COSE Key Common Parameters" registry (Section 16.5). 1468 Additional parameters defined for specific key types can be found in 1469 the IANA "COSE Key Type Parameters" registry (Section 16.6). 1471 A COSE Key Set uses a CBOR array object as its underlying type. The 1472 values of the array elements are COSE Keys. A Key Set MUST have at 1473 least one element in the array. 1475 Each element in a key set MUST be processed independently. If one 1476 element in a key set is either malformed or uses a key that is not 1477 understood by an application, that key is ignored and the other keys 1478 are processed normally. 1480 The element "kty" is a required element in a COSE_Key map. 1482 The CDDL grammar describing COSE_Key and COSE_KeySet is: 1484 COSE_Key = { 1485 1 => tstr / int, ; kty 1486 ? 2 => bstr, ; kid 1487 ? 3 => tstr / int, ; alg 1488 ? 4 => [+ (tstr / int) ], ; key_ops 1489 ? 5 => bstr, ; Base IV 1490 * label => values 1491 } 1493 COSE_KeySet = [+COSE_Key] 1495 7.1. COSE Key Common Parameters 1497 This document defines a set of common parameters for a COSE Key 1498 object. Table 3 provides a summary of the parameters defined in this 1499 section. There are also parameters that are defined for specific key 1500 types. Key type specific parameters can be found in Section 13. 1502 +---------+-------+----------------+------------+-------------------+ 1503 | name | label | CBOR type | registry | description | 1504 +---------+-------+----------------+------------+-------------------+ 1505 | kty | 1 | tstr / int | COSE Key | Identification of | 1506 | | | | Common | the key type | 1507 | | | | Parameters | | 1508 | | | | | | 1509 | alg | 3 | tstr / int | COSE | Key usage | 1510 | | | | Algorithm | restriction to | 1511 | | | | Values | this algorithm | 1512 | | | | | | 1513 | kid | 2 | bstr | | Key | 1514 | | | | | Identification | 1515 | | | | | value - match to | 1516 | | | | | kid in message | 1517 | | | | | | 1518 | key_ops | 4 | [+ (tstr/int)] | | Restrict set of | 1519 | | | | | permissible | 1520 | | | | | operations | 1521 | | | | | | 1522 | Base IV | 5 | bstr | | Base IV to be | 1523 | | | | | xor-ed with | 1524 | | | | | Partial IVs | 1525 +---------+-------+----------------+------------+-------------------+ 1527 Table 3: Key Map Labels 1529 kty: This parameter is used to identify the family of keys for this 1530 structure, and thus the set of key type specific parameters to be 1531 found. The set of values defined in this document can be found in 1532 Table 21. This parameter MUST be present in a key object. 1533 Implementations MUST verify that the key type is appropriate for 1534 the algorithm being processed. The key type MUST be included as 1535 part of the trust decision process. 1537 alg: This parameter is used to restrict the algorithm that is used 1538 with the key. If this parameter is present in the key structure, 1539 the application MUST verify that this algorithm matches the 1540 algorithm for which the key is being used. If the algorithms do 1541 not match, then this key object MUST NOT be used to perform the 1542 cryptographic operation. Note that the same key can be in a 1543 different key structure with a different or no algorithm 1544 specified, however this is considered to be a poor security 1545 practice. 1547 kid: This parameter is used to give an identifier for a key. The 1548 identifier is not structured and can be anything from a user 1549 provided string to a value computed on the public portion of the 1550 key. This field is intended for matching against a 'kid' 1551 parameter in a message in order to filter down the set of keys 1552 that need to be checked. 1554 key_ops: This parameter is defined to restrict the set of operations 1555 that a key is to be used for. The value of the field is an array 1556 of values from Table 4. Algorithms define the values of key ops 1557 that are permitted to appear and are required for specific 1558 operations. 1560 Base IV: This parameter is defined to carry the base portion of an 1561 IV. It is designed to be used with the partial IV header 1562 parameter defined in Section 3.1. This field provides the ability 1563 to associate a partial IV with a key that is then modified on a 1564 per message basis with the partial IV. 1566 Extreme care needs to be taken when using a Base IV in an 1567 application. Many encryption algorithms lose security if the same 1568 IV is used twice. 1570 If different keys are derived for each sender, starting at the 1571 same base IV is likely to satisfy this condition. If the same key 1572 is used for multiple senders, then the application needs to 1573 provide for a method of dividing the IV space up between the 1574 senders. This could be done by providing a different base point 1575 to start from or a different partial IV to start with and 1576 restricting the number of messages to be sent before re-keying. 1578 +---------+-------+-------------------------------------------------+ 1579 | name | value | description | 1580 +---------+-------+-------------------------------------------------+ 1581 | sign | 1 | The key is used to create signatures. Requires | 1582 | | | private key fields. | 1583 | | | | 1584 | verify | 2 | The key is used for verification of signatures. | 1585 | | | | 1586 | encrypt | 3 | The key is used for key transport encryption. | 1587 | | | | 1588 | decrypt | 4 | The key is used for key transport decryption. | 1589 | | | Requires private key fields. | 1590 | | | | 1591 | wrap | 5 | The key is used for key wrapping. | 1592 | key | | | 1593 | | | | 1594 | unwrap | 6 | The key is used for key unwrapping. Requires | 1595 | key | | private key fields. | 1596 | | | | 1597 | derive | 7 | The key is used for deriving keys. Requires | 1598 | key | | private key fields. | 1599 | | | | 1600 | derive | 8 | The key is used for deriving bits. Requires | 1601 | bits | | private key fields. | 1602 | | | | 1603 | MAC | 9 | The key is used for creating MACs. | 1604 | create | | | 1605 | | | | 1606 | MAC | 10 | The key is used for validating MACs. | 1607 | verify | | | 1608 +---------+-------+-------------------------------------------------+ 1610 Table 4: Key Operation Values 1612 8. Signature Algorithms 1614 There are two signature algorithm schemes. The first is signature 1615 with appendix. In this scheme, the message content is processed and 1616 a signature is produced, the signature is called the appendix. This 1617 is the scheme used by algorithms such as ECDSA and RSASSA-PSS. (In 1618 fact the SSA in RSASSA-PSS stands for Signature Scheme with 1619 Appendix.) 1621 The signature functions for this scheme are: 1623 signature = Sign(message content, key) 1625 valid = Verification(message content, key, signature) 1626 The second scheme is signature with message recovery. (An example of 1627 such an algorithm is [PVSig].) In this scheme, the message content 1628 is processed, but part of it is included in the signature. Moving 1629 bytes of the message content into the signature allows for smaller 1630 signatures, the signature size is still potentially large, but the 1631 message content has shrunk. This has implications for systems 1632 implementing these algorithms and for applications that use them. 1633 The first is that the message content is not fully available until 1634 after a signature has been validated. Until that point the part of 1635 the message contained inside of the signature is unrecoverable. The 1636 second is that the security analysis of the strength of the signature 1637 is very much based on the structure of the message content. Messages 1638 that are highly predictable require additional randomness to be 1639 supplied as part of the signature process. In the worst case, it 1640 becomes the same as doing a signature with appendix. Finally, in the 1641 event that multiple signatures are applied to a message, all of the 1642 signature algorithms are going to be required to consume the same 1643 number of bytes of message content. This means that mixing of the 1644 different schemes in a single message is not supported, and if a 1645 recovery signature scheme is used, then the same amount of content 1646 needs to be consumed by all of the signatures. 1648 The signature functions for this scheme are: 1650 signature, message sent = Sign(message content, key) 1652 valid, message content = Verification(message sent, key, signature) 1654 Signature algorithms are used with the COSE_Signature and COSE_Sign1 1655 structures. At this time, only signatures with appendixes are 1656 defined for use with COSE, however considerable interest has been 1657 expressed in using a signature with message recovery algorithm due to 1658 the effective size reduction that is possible. Implementations will 1659 need to keep this in mind for later possible integration. 1661 8.1. ECDSA 1663 ECDSA [DSS] defines a signature algorithm using ECC. 1665 The ECDSA signature algorithm is parameterized with a hash function 1666 (h). In the event that the length of the hash function output is 1667 greater than the group of the key, the left-most bytes of the hash 1668 output are used. 1670 The algorithms defined in this document can be found in Table 5. 1672 +-------+-------+---------+------------------+ 1673 | name | value | hash | description | 1674 +-------+-------+---------+------------------+ 1675 | ES256 | -7 | SHA-256 | ECDSA w/ SHA-256 | 1676 | | | | | 1677 | ES384 | -35 | SHA-384 | ECDSA w/ SHA-384 | 1678 | | | | | 1679 | ES512 | -36 | SHA-512 | ECDSA w/ SHA-512 | 1680 +-------+-------+---------+------------------+ 1682 Table 5: ECDSA Algorithm Values 1684 This document defines ECDSA to work only with the curves P-256, P-384 1685 and P-521. This document requires that the curves be encoded using 1686 the 'EC2' key type. Implementations need to check that the key type 1687 and curve are correct when creating and verifying a signature. Other 1688 documents can define it to work with other curves and points in the 1689 future. 1691 In order to promote interoperability, it is suggested that SHA-256 be 1692 used only with curve P-256, SHA-384 be used only with curve P-384 and 1693 SHA-512 be used with curve P-521. This is aligned with the 1694 recommendation in Section 4 of [RFC5480]. 1696 The signature algorithm results in a pair of integers (R, S). These 1697 integers will the same length as length of the key used for the 1698 signature process. The signature is encoded by converting the 1699 integers into byte strings of the same length as the key size. The 1700 length is rounded up to the nearest byte and is left padded with zero 1701 bits to get to the correct length. The two integers are then 1702 concatenated together to form a byte string that is the resulting 1703 signature. 1705 Using the function defined in [RFC3447] the signature is: 1706 Signature = I2OSP(R, n) | I2OSP(S, n) 1707 where n = ceiling(key_length / 8) 1709 When using a COSE key for this algorithm, the following checks are 1710 made: 1712 o The 'kty' field MUST be present and it MUST be 'EC2'. 1714 o If the 'alg' field is present, it MUST match the ECDSA signature 1715 algorithm being used. 1717 o If the 'key_ops' field is present, it MUST include 'sign' when 1718 creating an ECDSA signature. 1720 o If the 'key_ops' field is present, it MUST include 'verify' when 1721 verifying an ECDSA signature. 1723 8.1.1. Security Considerations 1725 The security strength of the signature is no greater than the minimum 1726 of the security strength associated with the bit length of the key 1727 and the security strength of the hash function. 1729 Systems that have poor random number generation can leak their keys 1730 by signing two different messages with the same value 'k' (the per- 1731 message random value). [RFC6979] provides a method to deal with this 1732 problem by making 'k' be deterministic based on the message content 1733 rather than randomly generated. Applications that specify ECDSA 1734 should evaluate the ability to get good random number generation and 1735 require deterministic signatures where poor random number generation 1736 exists. 1738 Note: Use of this technique is a good idea even when good random 1739 number generation exists. Doing so both reduces the possibility of 1740 having the same value of 'k' in two signature operations and allows 1741 for reproducible signature values, which helps testing. 1743 There are two substitution attacks that can theoretically be mounted 1744 against the ECDSA signature algorithm. 1746 o Changing the curve used to validate the signature: If one changes 1747 the curve used to validate the signature, then potentially one 1748 could have a two messages with the same signature each computed 1749 under a different curve. The only requirement on the new curve is 1750 that its order be the same as the old one and it be acceptable to 1751 the client. An example would be to change from using the curve 1752 secp256r1 (aka P-256) to using secp256k1. (Both are 256 bit 1753 curves.) We current do not have any way to deal with this version 1754 of the attack except to restrict the overall set of curves that 1755 can be used. 1757 o Change the hash function used to validate the signature: If one 1758 has either two different hash functions of the same length, or one 1759 can truncate a hash function down, then one could potentially find 1760 collisions between the hash functions rather than within a single 1761 hash function. (For example, truncating SHA-512 to 256 bits might 1762 collide with a SHA-256 bit hash value.) As the hash algorithm is 1763 part of the signature algorithm identifier, this attack is 1764 mitigated by including signature algorithm identifier in the 1765 protected header. 1767 8.2. Edwards-curve Digital Signature Algorithms (EdDSA) 1769 [I-D.irtf-cfrg-eddsa] describes the elliptic curve signature scheme 1770 Edwards-curve Digital Signature Algorithm (EdDSA). In that document, 1771 the signature algorithm is instantiated using parameters for 1772 edwards25519 and edwards448 curves. The document additionally 1773 describes two variants of the EdDSA algorithm: Pure EdDSA, where no 1774 hash function is applied to the content before signing and, HashEdDSA 1775 where a hash function is applied to the content before signing and 1776 the result of that hash function is signed. For the EdDSA, the 1777 content to be signed (either the message or the pre-hash value) is 1778 processed twice inside of the signature algorithm. For use with 1779 COSE, only the pure EdDSA version is used. This is because it is not 1780 expected that extremely large contents are going to be needed and, 1781 based on the arrangement of the message structure, the entire message 1782 is going to need to be held in memory in order to create or verify a 1783 signature. This means that there does not appear to be a need to be 1784 able to do block updates of the hash, followed by eliminating the 1785 message from memory. Applications can provide the same features by 1786 defining the content of the message as a hash value and transporting 1787 the COSE object (with the hash value) and the content as separate 1788 items. 1790 The algorithms defined in this document can be found in Table 6. A 1791 single signature algorithm is defined, which can be used for multiple 1792 curves. 1794 +-------+-------+-------------+ 1795 | name | value | description | 1796 +-------+-------+-------------+ 1797 | EdDSA | -8 | EdDSA | 1798 +-------+-------+-------------+ 1800 Table 6: EdDSA Algorithm Values 1802 [I-D.irtf-cfrg-eddsa] describes the method of encoding the signature 1803 value. 1805 When using a COSE key for this algorithm the following checks are 1806 made: 1808 o The 'kty' field MUST be present and it MUST be 'OKP'. 1810 o The 'crv' field MUST be present, and it MUST be a curve defined 1811 for this signature algorithm. 1813 o If the 'alg' field is present, it MUST match 'EdDSA'. 1815 o If the 'key_ops' field is present, it MUST include 'sign' when 1816 creating an EdDSA signature. 1818 o If the 'key_ops' field is present, it MUST include 'verify' when 1819 verifying an EdDSA signature. 1821 8.2.1. Security Considerations 1823 The Edwards curves for EdDSA and ECDH are distinct and should not be 1824 used for the other algorithm. 1826 If batch signature verification is performed, a well-seeded 1827 cryptographic random number generator is REQUIRED. Signing and non- 1828 batch signature verification are deterministic operations and do not 1829 need random numbers of any kind. 1831 9. Message Authentication (MAC) Algorithms 1833 Message Authentication Codes (MACs) provide data authentication and 1834 integrity protection. They provide either no or very limited data 1835 origination. (One cannot, for example, be used to prove the identity 1836 of the sender to a third party.) 1838 MACs use the same scheme as signature with appendix algorithms. The 1839 message content is processed and an authentication code is produced. 1840 The authentication code is frequently called a tag. 1842 The MAC functions are: 1844 tag = MAC_Create(message content, key) 1846 valid = MAC_Verify(message content, key, tag) 1848 MAC algorithms can be based on either a block cipher algorithm (i.e., 1849 AES-MAC) or a hash algorithm (i.e., HMAC). This document defines a 1850 MAC algorithm using each of these constructions. 1852 MAC algorithms are used in the COSE_Mac and COSE_Mac0 structures. 1854 9.1. Hash-based Message Authentication Codes (HMAC) 1856 The Hash-based Message Authentication Code algorithm (HMAC) 1857 [RFC2104][RFC4231] was designed to deal with length extension 1858 attacks. The algorithm was also designed to allow for new hash 1859 algorithms to be directly plugged in without changes to the hash 1860 function. The HMAC design process has been shown as solid since, 1861 while the security of hash algorithms such as MD5 has decreased over 1862 time, the security of HMAC combined with MD5 has not yet been shown 1863 to be compromised [RFC6151]. 1865 The HMAC algorithm is parameterized by an inner and outer padding, a 1866 hash function (h), and an authentication tag value length. For this 1867 specification, the inner and outer padding are fixed to the values 1868 set in [RFC2104]. The length of the authentication tag corresponds 1869 to the difficulty of producing a forgery. For use in constrained 1870 environments, we define a set of HMAC algorithms that are truncated. 1871 There are currently no known issues with truncation, however the 1872 security strength of the message tag is correspondingly reduced in 1873 strength. When truncating, the left-most tag length bits are kept 1874 and transmitted. 1876 The algorithms defined in this document can be found in Table 7. 1878 +-----------+-------+---------+----------+--------------------------+ 1879 | name | value | Hash | Tag | description | 1880 | | | | Length | | 1881 +-----------+-------+---------+----------+--------------------------+ 1882 | HMAC | 4 | SHA-256 | 64 | HMAC w/ SHA-256 | 1883 | 256/64 | | | | truncated to 64 bits | 1884 | | | | | | 1885 | HMAC | 5 | SHA-256 | 256 | HMAC w/ SHA-256 | 1886 | 256/256 | | | | | 1887 | | | | | | 1888 | HMAC | 6 | SHA-384 | 384 | HMAC w/ SHA-384 | 1889 | 384/384 | | | | | 1890 | | | | | | 1891 | HMAC | 7 | SHA-512 | 512 | HMAC w/ SHA-512 | 1892 | 512/512 | | | | | 1893 +-----------+-------+---------+----------+--------------------------+ 1895 Table 7: HMAC Algorithm Values 1897 Some recipient algorithms carry the key while others derive a key 1898 from secret data. For those algorithms that carry the key (such as 1899 AES-KeyWrap), the size of the HMAC key SHOULD be the same size as the 1900 underlying hash function. For those algorithms that derive the key 1901 (such as ECDH), the derived key MUST be the same size as the 1902 underlying hash function. 1904 When using a COSE key for this algorithm, the following checks are 1905 made: 1907 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 1909 o If the 'alg' field present, it MUST match the HMAC algorithm being 1910 used. 1912 o If the 'key_ops' field is present, it MUST include 'MAC create' 1913 when creating an HMAC authentication tag. 1915 o If the 'key_ops' field is present, it MUST include 'MAC verify' 1916 when verifying an HMAC authentication tag. 1918 Implementations creating and validating MAC values MUST validate that 1919 the key type, key length, and algorithm are correct and appropriate 1920 for the entities involved. 1922 9.1.1. Security Considerations 1924 HMAC has proved to be resistant to attack even when used with 1925 weakened hash algorithms. The current best method appears to be a 1926 brute force attack on the key. This means that key size is going to 1927 be directly related to the security of an HMAC operation. 1929 9.2. AES Message Authentication Code (AES-CBC-MAC) 1931 AES-CBC-MAC is defined in [MAC]. (Note this is not the same 1932 algorithm as AES-CMAC [RFC4493]). 1934 AES-CBC-MAC is parameterized by the key length, the authentication 1935 tag length and the IV used. For all of these algorithms, the IV is 1936 fixed to all zeros. We provide an array of algorithms for various 1937 key lengths and tag lengths. The algorithms defined in this document 1938 are found in Table 8. 1940 +-------------+-------+----------+----------+-----------------------+ 1941 | name | value | key | tag | description | 1942 | | | length | length | | 1943 +-------------+-------+----------+----------+-----------------------+ 1944 | AES-MAC | 14 | 128 | 64 | AES-MAC 128 bit key, | 1945 | 128/64 | | | | 64-bit tag | 1946 | | | | | | 1947 | AES-MAC | 15 | 256 | 64 | AES-MAC 256 bit key, | 1948 | 256/64 | | | | 64-bit tag | 1949 | | | | | | 1950 | AES-MAC | 25 | 128 | 128 | AES-MAC 128 bit key, | 1951 | 128/128 | | | | 128-bit tag | 1952 | | | | | | 1953 | AES-MAC | 26 | 256 | 128 | AES-MAC 256 bit key, | 1954 | 256/128 | | | | 128-bit tag | 1955 +-------------+-------+----------+----------+-----------------------+ 1957 Table 8: AES-MAC Algorithm Values 1959 Keys may be obtained either from a key structure or from a recipient 1960 structure. Implementations creating and validating MAC values MUST 1961 validate that the key type, key length and algorithm are correct and 1962 appropriate for the entities involved. 1964 When using a COSE key for this algorithm, the following checks are 1965 made: 1967 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 1969 o If the 'alg' field present, it MUST match the AES-MAC algorithm 1970 being used. 1972 o If the 'key_ops' field is present, it MUST include 'MAC create' 1973 when creating an AES-MAC authentication tag. 1975 o If the 'key_ops' field is present, it MUST include 'MAC verify' 1976 when verifying an AES-MAC authentication tag. 1978 9.2.1. Security Considerations 1980 A number of attacks exist against CBC-MAC that need to be considered. 1982 o A single key must only be used for messages of a fixed and known 1983 length. If this is not the case, an attacker will be able to 1984 generate a message with a valid tag given two message, tag pairs. 1985 This can be addressed by using different keys for different length 1986 messages. The current structure mitigates this problem, as a 1987 specific encoding structure that includes lengths is built and 1988 signed. (CMAC also addresses this issue.) 1990 o If the same key is used for both encryption and authentication 1991 operations, using CBC modes an attacker can produce messages with 1992 a valid authentication code. 1994 o If the IV can be modified, then messages can be forged. This is 1995 addressed by fixing the IV to all zeros. 1997 10. Content Encryption Algorithms 1999 Content Encryption Algorithms provide data confidentiality for 2000 potentially large blocks of data using a symmetric key. They provide 2001 integrity on the data that was encrypted, however they provide either 2002 no or very limited data origination. (One cannot, for example, be 2003 used to prove the identity of the sender to a third party.) The 2004 ability to provide data origination is linked to how the CEK is 2005 obtained. 2007 COSE restricts the set of legal content encryption algorithms to 2008 those that support authentication both of the content and additional 2009 data. The encryption process will generate some type of 2010 authentication value, but that value may be either explicit or 2011 implicit in terms of the algorithm definition. For simplicity sake, 2012 the authentication code will normally be defined as being appended to 2013 the cipher text stream. The encryption functions are: 2015 ciphertext = Encrypt(message content, key, additional data) 2017 valid, message content = Decrypt(cipher text, key, additional data) 2019 Most AEAD algorithms are logically defined as returning the message 2020 content only if the decryption is valid. Many but not all 2021 implementations will follow this convention. The message content 2022 MUST NOT be used if the decryption does not validate. 2024 These algorithms are used in COSE_Encrypt and COSE_Encrypt0. 2026 10.1. AES GCM 2028 The GCM mode is a generic authenticated encryption block cipher mode 2029 defined in [AES-GCM]. The GCM mode is combined with the AES block 2030 encryption algorithm to define an AEAD cipher. 2032 The GCM mode is parameterized by the size of the authentication tag 2033 and the size of the nonce. This document fixes the size of the nonce 2034 at 96 bits. The size of the authentication tag is limited to a small 2035 set of values. For this document however, the size of the 2036 authentication tag is fixed at 128 bits. 2038 The set of algorithms defined in this document are in Table 9. 2040 +---------+-------+------------------------------------------+ 2041 | name | value | description | 2042 +---------+-------+------------------------------------------+ 2043 | A128GCM | 1 | AES-GCM mode w/ 128-bit key, 128-bit tag | 2044 | | | | 2045 | A192GCM | 2 | AES-GCM mode w/ 192-bit key, 128-bit tag | 2046 | | | | 2047 | A256GCM | 3 | AES-GCM mode w/ 256-bit key, 128-bit tag | 2048 +---------+-------+------------------------------------------+ 2050 Table 9: Algorithm Value for AES-GCM 2052 Keys may be obtained either from a key structure or from a recipient 2053 structure. Implementations encrypting and decrypting MUST validate 2054 that the key type, key length and algorithm are correct and 2055 appropriate for the entities involved. 2057 When using a COSE key for this algorithm, the following checks are 2058 made: 2060 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2062 o If the 'alg' field present, it MUST match the AES-GCM algorithm 2063 being used. 2065 o If the 'key_ops' field is present, it MUST include 'encrypt' or 2066 'wrap key' when encrypting. 2068 o If the 'key_ops' field is present, it MUST include 'decrypt' or 2069 'unwrap key' when decrypting. 2071 10.1.1. Security Considerations 2073 When using AES-GCM, the following restrictions MUST be enforced: 2075 o The key and nonce pair MUST be unique for every message encrypted. 2077 o The total amount of data encrypted for a single key MUST NOT 2078 exceed 2^39 - 256 bits. An explicit check is required only in 2079 environments where it is expected that it might be exceeded. 2081 Consideration was given to supporting smaller tag values; the 2082 constrained community would desire tag sizes in the 64-bit range. 2084 Doing so drastically changes both the maximum messages size 2085 (generally not an issue) and the number of times that a key can be 2086 used. Given that CCM is the usual mode for constrained environments, 2087 restricted modes are not supported. 2089 10.2. AES CCM 2091 Counter with CBC-MAC (CCM) is a generic authentication encryption 2092 block cipher mode defined in [RFC3610]. The CCM mode is combined 2093 with the AES block encryption algorithm to define a commonly used 2094 content encryption algorithm used in constrained devices. 2096 The CCM mode has two parameter choices. The first choice is M, the 2097 size of the authentication field. The choice of the value for M 2098 involves a trade-off between message growth (from the tag) and the 2099 probably that an attacker can undetectably modify a message. The 2100 second choice is L, the size of the length field. This value 2101 requires a trade-off between the maximum message size and the size of 2102 the Nonce. 2104 It is unfortunate that the specification for CCM specified L and M as 2105 a count of bytes rather than a count of bits. This leads to possible 2106 misunderstandings where AES-CCM-8 is frequently used to refer to a 2107 version of CCM mode where the size of the authentication is 64 bits 2108 and not 8 bits. These values have traditionally been specified as 2109 bit counts rather than byte counts. This document will follow the 2110 convention of using bit counts so that it is easier to compare the 2111 different algorithms presented in this document. 2113 We define a matrix of algorithms in this document over the values of 2114 L and M. Constrained devices are usually operating in situations 2115 where they use short messages and want to avoid doing recipient 2116 specific cryptographic operations. This favors smaller values of 2117 both L and M. Less constrained devices will want to be able to user 2118 larger messages and are more willing to generate new keys for every 2119 operation. This favors larger values of L and M. 2121 The following values are used for L: 2123 16 bits (2) limits messages to 2^16 bytes (64 KiB) in length. This 2124 is sufficiently long for messages in the constrained world. The 2125 nonce length is 13 bytes allowing for 2^(13*8) possible values of 2126 the nonce without repeating. 2128 64 bits (8) limits messages to 2^64 bytes in length. The nonce 2129 length is 7 bytes allowing for 2^56 possible values of the nonce 2130 without repeating. 2132 The following values are used for M: 2134 64 bits (8) produces a 64-bit authentication tag. This implies that 2135 there is a 1 in 2^64 chance that a modified message will 2136 authenticate. 2138 128 bits (16) produces a 128-bit authentication tag. This implies 2139 that there is a 1 in 2^128 chance that a modified message will 2140 authenticate. 2142 +--------------------+-------+----+-----+-----+---------------------+ 2143 | name | value | L | M | k | description | 2144 +--------------------+-------+----+-----+-----+---------------------+ 2145 | AES-CCM-16-64-128 | 10 | 16 | 64 | 128 | AES-CCM mode | 2146 | | | | | | 128-bit key, 64-bit | 2147 | | | | | | tag, 13-byte nonce | 2148 | | | | | | | 2149 | AES-CCM-16-64-256 | 11 | 16 | 64 | 256 | AES-CCM mode | 2150 | | | | | | 256-bit key, 64-bit | 2151 | | | | | | tag, 13-byte nonce | 2152 | | | | | | | 2153 | AES-CCM-64-64-128 | 12 | 64 | 64 | 128 | AES-CCM mode | 2154 | | | | | | 128-bit key, 64-bit | 2155 | | | | | | tag, 7-byte nonce | 2156 | | | | | | | 2157 | AES-CCM-64-64-256 | 13 | 64 | 64 | 256 | AES-CCM mode | 2158 | | | | | | 256-bit key, 64-bit | 2159 | | | | | | tag, 7-byte nonce | 2160 | | | | | | | 2161 | AES-CCM-16-128-128 | 30 | 16 | 128 | 128 | AES-CCM mode | 2162 | | | | | | 128-bit key, | 2163 | | | | | | 128-bit tag, | 2164 | | | | | | 13-byte nonce | 2165 | | | | | | | 2166 | AES-CCM-16-128-256 | 31 | 16 | 128 | 256 | AES-CCM mode | 2167 | | | | | | 256-bit key, | 2168 | | | | | | 128-bit tag, | 2169 | | | | | | 13-byte nonce | 2170 | | | | | | | 2171 | AES-CCM-64-128-128 | 32 | 64 | 128 | 128 | AES-CCM mode | 2172 | | | | | | 128-bit key, | 2173 | | | | | | 128-bit tag, 7-byte | 2174 | | | | | | nonce | 2175 | | | | | | | 2176 | AES-CCM-64-128-256 | 33 | 64 | 128 | 256 | AES-CCM mode | 2177 | | | | | | 256-bit key, | 2178 | | | | | | 128-bit tag, 7-byte | 2179 | | | | | | nonce | 2180 +--------------------+-------+----+-----+-----+---------------------+ 2182 Table 10: Algorithm Values for AES-CCM 2184 Keys may be obtained either from a key structure or from a recipient 2185 structure. Implementations encrypting and decrypting MUST validate 2186 that the key type, key length and algorithm are correct and 2187 appropriate for the entities involved. 2189 When using a COSE key for this algorithm, the following checks are 2190 made: 2192 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2194 o If the 'alg' field present, it MUST match the AES-CCM algorithm 2195 being used. 2197 o If the 'key_ops' field is present, it MUST include 'encrypt' or 2198 'wrap key' when encrypting. 2200 o If the 'key_ops' field is present, it MUST include 'decrypt' or 2201 'unwrap key' when decrypting. 2203 10.2.1. Security Considerations 2205 When using AES-CCM, the following restrictions MUST be enforced: 2207 o The key and nonce pair MUST be unique for every message encrypted. 2208 Note that the value of L influences the number of unique nonces. 2210 o The total number of times the AES block cipher is used MUST NOT 2211 exceed 2^61 operations. This limitation is the sum of times the 2212 block cipher is used in computing the MAC value and in performing 2213 stream encryption operations. An explicit check is required only 2214 in environments where it is expected that it might be exceeded. 2216 [RFC3610] additionally calls out one other consideration of note. It 2217 is possible to do a pre-computation attack against the algorithm in 2218 cases where portions of the plaintext are highly predictable. This 2219 reduces the security of the key size by half. Ways to deal with this 2220 attack include adding a random portion to the nonce value and/or 2221 increasing the key size used. Using a portion of the nonce for a 2222 random value will decrease the number of messages that a single key 2223 can be used for. Increasing the key size may require more resources 2224 in the constrained device. See sections 5 and 10 of [RFC3610] for 2225 more information. 2227 10.3. ChaCha20 and Poly1305 2229 ChaCha20 and Poly1305 combined together is an AEAD mode that is 2230 defined in [RFC7539]. This is an algorithm defined to be a cipher 2231 that is not AES and thus would not suffer from any future weaknesses 2232 found in AES. These cryptographic functions are designed to be fast 2233 in software-only implementations. 2235 The ChaCha20/Poly1305 AEAD construction defined in [RFC7539] has no 2236 parameterization. It takes a 256-bit key and a 96-bit nonce, as well 2237 as the plain text and additional data as inputs and produces the 2238 cipher text as an option. We define one algorithm identifier for 2239 this algorithm in Table 11. 2241 +-------------------+-------+---------------------------------------+ 2242 | name | value | description | 2243 +-------------------+-------+---------------------------------------+ 2244 | ChaCha20/Poly1305 | 24 | ChaCha20/Poly1305 w/ 256-bit key, | 2245 | | | 128-bit tag | 2246 +-------------------+-------+---------------------------------------+ 2248 Table 11: Algorithm Value for AES-GCM 2250 Keys may be obtained either from a key structure or from a recipient 2251 structure. Implementations encrypting and decrypting MUST validate 2252 that the key type, key length and algorithm are correct and 2253 appropriate for the entities involved. 2255 When using a COSE key for this algorithm, the following checks are 2256 made: 2258 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2260 o If the 'alg' field present, it MUST match the ChaCha20/Poly1305 2261 algorithm being used. 2263 o If the 'key_ops' field is present, it MUST include 'encrypt' or 2264 'wrap key' when encrypting. 2266 o If the 'key_ops' field is present, it MUST include 'decrypt' or 2267 'unwrap key' when decrypting. 2269 10.3.1. Security Considerations 2271 The pair of key, nonce MUST be unique for every invocation of the 2272 algorithm. Nonce counters are considered to be an acceptable way of 2273 ensuring that they are unique. 2275 11. Key Derivation Functions (KDF) 2277 Key Derivation Functions (KDFs) are used to take some secret value 2278 and generate a different one. The secret value comes in three 2279 flavors: 2281 o Secrets that are uniformly random: This is the type of secret that 2282 is created by a good random number generator. 2284 o Secrets that are not uniformly random: This is type of secret that 2285 is created by operations like key agreement. 2287 o Secrets that are not random: This is the type of secret that 2288 people generate for things like passwords. 2290 General KDF functions work well with the first type of secret, can do 2291 reasonably well with the second type of secret, and generally do 2292 poorly with the last type of secret. None of the KDF functions in 2293 this section are designed to deal with the type of secrets that are 2294 used for passwords. Functions like PBES2 [RFC2898] need to be used 2295 for that type of secret. 2297 The same KDF function can be setup to deal with the first two types 2298 of secrets in a different way. The KDF function defined in 2299 Section 11.1 is such a function. This is reflected in the set of 2300 algorithms defined for HKDF. 2302 When using KDF functions, one component that is included is context 2303 information. Context information is used to allow for different 2304 keying information to be derived from the same secret. The use of 2305 context based keying material is considered to be a good security 2306 practice. 2308 This document defines a single context structure and a single KDF 2309 function. These elements are used for all of the recipient 2310 algorithms defined in this document that require a KDF process. 2311 These algorithms are defined in Section 12.1.2, Section 12.4.1, and 2312 Section 12.5.1. 2314 11.1. HMAC-based Extract-and-Expand Key Derivation Function (HKDF) 2316 The HKDF key derivation algorithm is defined in [RFC5869]. 2318 The HKDF algorithm takes these inputs: 2320 secret - a shared value that is secret. Secrets may be either 2321 previously shared or derived from operations like a DH key 2322 agreement. 2324 salt - an optional value that is used to change the generation 2325 process. The salt value can be either public or private. If the 2326 salt is public and carried in the message, then the 'salt' 2327 algorithm header parameter defined in Table 13 is used. While 2328 [RFC5869] suggests that the length of the salt be the same as the 2329 length of the underlying hash value, any amount of salt will 2330 improve the security as different key values will be generated. 2331 This parameter is protected by being included in the key 2332 computation and does not need to be separately authenticated. The 2333 salt value does not need to be unique for every message sent. 2335 length - the number of bytes of output that need to be generated. 2337 context information - Information that describes the context in 2338 which the resulting value will be used. Making this information 2339 specific to the context in which the material is going to be used 2340 ensures that the resulting material will always be tied to that 2341 usage. The context structure defined in Section 11.2 is used by 2342 the KDF functions in this document. 2344 PRF - The underlying pseudo-random function to be used in the HKDF 2345 algorithm. The PRF is encoded into the HKDF algorithm selection. 2347 HKDF is defined to use HMAC as the underlying PRF. However, it is 2348 possible to use other functions in the same construct to provide a 2349 different KDF function that is more appropriate in the constrained 2350 world. Specifically, one can use AES-CBC-MAC as the PRF for the 2351 expand step, but not for the extract step. When using a good random 2352 shared secret of the correct length, the extract step can be skipped. 2353 For the AES algorithm versions, the extract step is always skipped. 2355 The extract step cannot be skipped if the secret is not uniformly 2356 random, for example, if it is the result of an ECDH key agreement 2357 step. (This implies that the AES HKDF version cannot be used with 2358 ECDH.) If the extract step is skipped, the 'salt' value is not used 2359 as part of the HKDF functionality. 2361 The algorithms defined in this document are found in Table 12. 2363 +---------------+-----------------+---------------------------------+ 2364 | name | PRF | description | 2365 +---------------+-----------------+---------------------------------+ 2366 | HKDF SHA-256 | HMAC with | HKDF using HMAC SHA-256 as the | 2367 | | SHA-256 | PRF | 2368 | | | | 2369 | HKDF SHA-512 | HMAC with | HKDF using HMAC SHA-512 as the | 2370 | | SHA-512 | PRF | 2371 | | | | 2372 | HKDF AES- | AES-CBC-MAC-128 | HKDF using AES-MAC as the PRF | 2373 | MAC-128 | | w/ 128-bit key | 2374 | | | | 2375 | HKDF AES- | AES-CBC-MAC-256 | HKDF using AES-MAC as the PRF | 2376 | MAC-256 | | w/ 256-bit key | 2377 +---------------+-----------------+---------------------------------+ 2379 Table 12: HKDF algorithms 2381 +------+-------+------+-------------+ 2382 | name | label | type | description | 2383 +------+-------+------+-------------+ 2384 | salt | -20 | bstr | Random salt | 2385 +------+-------+------+-------------+ 2387 Table 13: HKDF Algorithm Parameters 2389 11.2. Context Information Structure 2391 The context information structure is used to ensure that the derived 2392 keying material is "bound" to the context of the transaction. The 2393 context information structure used here is based on that defined in 2394 [SP800-56A]. By using CBOR for the encoding of the context 2395 information structure, we automatically get the same type and length 2396 separation of fields that is obtained by the use of ASN.1. This 2397 means that there is no need to encode the lengths for the base 2398 elements as it is done by the encoding used in JOSE (Section 4.6.2 of 2399 [RFC7518]). 2401 The context information structure refers to PartyU and PartyV as the 2402 two parties that are doing the key derivation. Unless the 2403 application protocol defines differently, we assign PartyU to the 2404 entity that is creating the message and PartyV to the entity that is 2405 receiving the message. By doing this association, different keys 2406 will be derived for each direction as the context information is 2407 different in each direction. 2409 The context structure is built from information that is known to both 2410 entities. This information can be obtained from a variety of 2411 sources: 2413 o Fields can be defined by the application. This is commonly used 2414 to assign fixed names to parties, but can be used for other items 2415 such as nonces. 2417 o Fields can be defined by usage of the output. Examples of this 2418 are the algorithm and key size that are being generated. 2420 o Fields can be defined by parameters from the message. We define a 2421 set of parameters in Table 14 that can be used to carry the values 2422 associated with the context structure. Examples of this are 2423 identities and nonce values. These parameters are designed to be 2424 placed in the unprotected bucket of the recipient structure. 2425 (They do not need to be in the protected bucket since they already 2426 are included in the cryptographic computation by virtue of being 2427 included in the context structure.) 2429 +---------------+-------+-----------+-------------------------------+ 2430 | name | label | type | description | 2431 +---------------+-------+-----------+-------------------------------+ 2432 | PartyU | -21 | bstr | Party U identity Information | 2433 | identity | | | | 2434 | | | | | 2435 | PartyU nonce | -22 | bstr / | Party U provided nonce | 2436 | | | int | | 2437 | | | | | 2438 | PartyU other | -23 | bstr | Party U other provided | 2439 | | | | information | 2440 | | | | | 2441 | PartyV | -24 | bstr | Party V identity Information | 2442 | identity | | | | 2443 | | | | | 2444 | PartyV nonce | -25 | bstr / | Party V provided nonce | 2445 | | | int | | 2446 | | | | | 2447 | PartyV other | -26 | bstr | Party V other provided | 2448 | | | | information | 2449 +---------------+-------+-----------+-------------------------------+ 2451 Table 14: Context Algorithm Parameters 2453 We define a CBOR object to hold the context information. This object 2454 is referred to as CBOR_KDF_Context. The object is based on a CBOR 2455 array type. The fields in the array are: 2457 AlgorithmID This field indicates the algorithm for which the key 2458 material will be used. This normally is either a Key Wrap 2459 algorithm identifier or a Content Encryption algorithm identifier. 2460 The values are from the "COSE Algorithm Value" registry. This 2461 field is required to be present. The field exists in the context 2462 information so that if the same environment is used for different 2463 algorithms, then completely different keys will be generated for 2464 each of those algorithms. (This practice means if algorithm A is 2465 broken and thus is easier to find, the key derived for algorithm B 2466 will not be the same as the key derived for algorithm A.) 2468 PartyUInfo This field holds information about party U. The 2469 PartyUInfo is encoded as a CBOR array. The elements of PartyUInfo 2470 are encoded in the order presented, however if the element does 2471 not exist no element is placed in the array. The elements of the 2472 PartyUInfo array are: 2474 identity This contains the identity information for party U. The 2475 identities can be assigned in one of two manners. Firstly, a 2476 protocol can assign identities based on roles. For example, 2477 the roles of "client" and "server" may be assigned to different 2478 entities in the protocol. Each entity would then use the 2479 correct label for the data they send or receive. The second 2480 way for a protocol to assign identities is to use a name based 2481 on a naming system (i.e., DNS, X.509 names). 2482 We define an algorithm parameter 'PartyU identity' that can be 2483 used to carry identity information in the message. However, 2484 identity information is often known as part of the protocol and 2485 can thus be inferred rather than made explicit. If identity 2486 information is carried in the message, applications SHOULD have 2487 a way of validating the supplied identity information. The 2488 identity information does not need to be specified and is set 2489 to nil in that case. 2491 nonce This contains a nonce value. The nonce can either be 2492 implicit from the protocol or carried as a value in the 2493 unprotected headers. 2494 We define an algorithm parameter 'PartyU nonce' that can be 2495 used to carry this value in the message However, the nonce 2496 value could be determined by the application and the value 2497 determined from elsewhere. 2498 This option does not need to be specified and is set to nil in 2499 that case 2501 other This contains other information that is defined by the 2502 protocol. 2503 This option does not need to be specified and is set to nil in 2504 that case 2506 PartyVInfo This field holds information about party V. The content 2507 of the structure are the same as for the PartyUInfo but for party 2508 V. 2510 SuppPubInfo This field contains public information that is mutually 2511 known to both parties. 2513 keyDataLength This is set to the number of bits of the desired 2514 output value. (This practice means if algorithm A can use two 2515 different key lengths, the key derived for longer key size will 2516 not contain the key for shorter key size as a prefix.) 2518 protected This field contains the protected parameter field. If 2519 there are no elements in the protected field, then use a zero 2520 length bstr. 2522 other This field is for free form data defined by the 2523 application. An example is that an application could define 2524 two different strings to be placed here to generate different 2525 keys for a data stream vs a control stream. This field is 2526 optional and will only be present if the application defines a 2527 structure for this information. Applications that define this 2528 SHOULD use CBOR to encode the data so that types and lengths 2529 are correctly included. 2531 SuppPrivInfo This field contains private information that is 2532 mutually known private information. An example of this 2533 information would be a pre-existing shared secret. (This could, 2534 for example, be used in combination with an ECDH key agreement to 2535 provide a secondary proof of identity.) The field is optional and 2536 will only be present if the application defines a structure for 2537 this information. Applications that define this SHOULD use CBOR 2538 to encode the data so that types and lengths are correctly 2539 included. 2541 The following CDDL fragment corresponds to the text above. 2543 PartyInfo = ( 2544 identity : bstr / nil, 2545 nonce : bstr / int / nil, 2546 other : bstr / nil, 2547 ) 2549 COSE_KDF_Context = [ 2550 AlgorithmID : int / tstr, 2551 PartyUInfo : [ PartyInfo ], 2552 PartyVInfo : [ PartyInfo ], 2553 SuppPubInfo : [ 2554 keyDataLength : uint, 2555 protected : empty_or_serialized_map, 2556 ? other : bstr 2557 ], 2558 ? SuppPrivInfo : bstr 2559 ] 2561 12. Recipient Algorithm Classes 2563 Recipient algorithms can be defined into a number of different 2564 classes. COSE has the ability to support many classes of recipient 2565 algorithms. In this section, a number of classes are listed and then 2566 a set of algorithms are specified for each of the classes. The names 2567 of the recipient algorithm classes used here are the same as are 2568 defined in [RFC7516]. Other specifications use different terms for 2569 the recipient algorithm classes or do not support some of the 2570 recipient algorithm classes. 2572 12.1. Direct Encryption 2574 The direct encryption class algorithms share a secret between the 2575 sender and the recipient that is used either directly or after 2576 manipulation as the CEK. When direct encryption mode is used, it 2577 MUST be the only mode used on the message. 2579 The COSE_Encrypt structure for the recipient is organized as follows: 2581 o The 'protected' field MUST be a zero length item unless it is used 2582 in the computation of the content key. 2584 o The 'alg' parameter MUST be present. 2586 o A parameter identifying the shared secret SHOULD be present. 2588 o The 'ciphertext' field MUST be a zero length item. 2590 o The 'recipients' field MUST be absent. 2592 12.1.1. Direct Key 2594 This recipient algorithm is the simplest; the identified key is 2595 directly used as the key for the next layer down in the message. 2596 There are no algorithm parameters defined for this algorithm. The 2597 algorithm identifier value is assigned in Table 15. 2599 When this algorithm is used, the protected field MUST be zero length. 2600 The key type MUST be 'Symmetric'. 2602 +--------+-------+-------------------+ 2603 | name | value | description | 2604 +--------+-------+-------------------+ 2605 | direct | -6 | Direct use of CEK | 2606 +--------+-------+-------------------+ 2608 Table 15: Direct Key 2610 12.1.1.1. Security Considerations 2612 This recipient algorithm has several potential problems that need to 2613 be considered: 2615 o These keys need to have some method to be regularly updated over 2616 time. All of the content encryption algorithms specified in this 2617 document have limits on how many times a key can be used without 2618 significant loss of security. 2620 o These keys need to be dedicated to a single algorithm. There have 2621 been a number of attacks developed over time when a single key is 2622 used for multiple different algorithms. One example of this is 2623 the use of a single key both for CBC encryption mode and CBC-MAC 2624 authentication mode. 2626 o Breaking one message means all messages are broken. If an 2627 adversary succeeds in determining the key for a single message, 2628 then the key for all messages is also determined. 2630 12.1.2. Direct Key with KDF 2632 These recipient algorithms take a common shared secret between the 2633 two parties and applies the HKDF function (Section 11.1), using the 2634 context structure defined in Section 11.2 to transform the shared 2635 secret into the CEK. The 'protected' field can be of non-zero 2636 length. Either the 'salt' parameter of HKDF or the partyU 'nonce' 2637 parameter of the context structure MUST be present. The salt/nonce 2638 parameter can be generated either randomly or deterministically. The 2639 requirement is that it be a unique value for the shared secret in 2640 question. 2642 If the salt/nonce value is generated randomly, then it is suggested 2643 that the length of the random value be the same length as the hash 2644 function underlying HKDF. While there is no way to guarantee that it 2645 will be unique, there is a high probability that it will be unique. 2646 If the salt/nonce value is generated deterministically, it can be 2647 guaranteed to be unique and thus there is no length requirement. 2649 A new IV must be used for each message if the same key is used. The 2650 IV can be modified in a predictable manner, a random manner or an 2651 unpredictable manner (i.e., encrypting a counter). 2653 The IV used for a key can also be generated from the same HKDF 2654 functionality as the key is generated. If HKDF is used for 2655 generating the IV, the algorithm identifier is set to "IV- 2656 GENERATION". 2658 When these algorithms are used, the key type MUST be 'symmetric'. 2660 The set of algorithms defined in this document can be found in 2661 Table 16. 2663 +---------------------+-------+-------------+-----------------------+ 2664 | name | value | KDF | description | 2665 +---------------------+-------+-------------+-----------------------+ 2666 | direct+HKDF-SHA-256 | -10 | HKDF | Shared secret w/ HKDF | 2667 | | | SHA-256 | and SHA-256 | 2668 | | | | | 2669 | direct+HKDF-SHA-512 | -11 | HKDF | Shared secret w/ HKDF | 2670 | | | SHA-512 | and SHA-512 | 2671 | | | | | 2672 | direct+HKDF-AES-128 | -12 | HKDF AES- | Shared secret w/ AES- | 2673 | | | MAC-128 | MAC 128-bit key | 2674 | | | | | 2675 | direct+HKDF-AES-256 | -13 | HKDF AES- | Shared secret w/ AES- | 2676 | | | MAC-256 | MAC 256-bit key | 2677 +---------------------+-------+-------------+-----------------------+ 2679 Table 16: Direct Key with KDF 2681 When using a COSE key for this algorithm, the following checks are 2682 made: 2684 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2686 o If the 'alg' field present, it MUST match the algorithm being 2687 used. 2689 o If the 'key_ops' field is present, it MUST include 'deriveKey' or 2690 'deriveBits'. 2692 12.1.2.1. Security Considerations 2694 The shared secret needs to have some method to be regularly updated 2695 over time. The shared secret forms the basis of trust. Although not 2696 used directly, it should still be subject to scheduled rotation. 2698 While these methods do not provide for PFS, as the same shared secret 2699 is used for all of the keys generated, if the key for any single 2700 message is discovered only the message (or series of messages) using 2701 that derived key are compromised. A new key derivation step will 2702 generate a new key which requires the same amount of work to get the 2703 key. 2705 12.2. Key Wrapping 2707 In key wrapping mode, the CEK is randomly generated and that key is 2708 then encrypted by a shared secret between the sender and the 2709 recipient. All of the currently defined key wrapping algorithms for 2710 COSE are AE algorithms. Key wrapping mode is considered to be 2711 superior to direct encryption if the system has any capability for 2712 doing random key generation. This is because the shared key is used 2713 to wrap random data rather than data that has some degree of 2714 organization and may in fact be repeating the same content. The use 2715 of Key Wrapping loses the weak data origination that is provided by 2716 the direct encryption algorithms. 2718 The COSE_Encrypt structure for the recipient is organized as follows: 2720 o The 'protected' field MUST be absent if the key wrap algorithm is 2721 an AE algorithm. 2723 o The 'recipients' field is normally absent, but can be used. 2724 Applications MUST deal with a recipient field present, not being 2725 able to decrypt that recipient is an acceptable way of dealing 2726 with it. Failing to process the message is not an acceptable way 2727 of dealing with it. 2729 o The plain text to be encrypted is the key from next layer down 2730 (usually the content layer). 2732 o At a minimum, the 'unprotected' field MUST contain the 'alg' 2733 parameter and SHOULD contain a parameter identifying the shared 2734 secret. 2736 12.2.1. AES Key Wrapping 2738 The AES Key Wrapping algorithm is defined in [RFC3394]. This 2739 algorithm uses an AES key to wrap a value that is a multiple of 64 2740 bits. As such, it can be used to wrap a key for any of the content 2741 encryption algorithms defined in this document. The algorithm 2742 requires a single fixed parameter, the initial value. This is fixed 2743 to the value specified in Section 2.2.3.1 of [RFC3394]. There are no 2744 public parameters that vary on a per invocation basis. The protected 2745 header field MUST be empty. 2747 Keys may be obtained either from a key structure or from a recipient 2748 structure. Implementations encrypting and decrypting MUST validate 2749 that the key type, key length and algorithm are correct and 2750 appropriate for the entities involved. 2752 When using a COSE key for this algorithm, the following checks are 2753 made: 2755 o The 'kty' field MUST be present and it MUST be 'Symmetric'. 2757 o If the 'alg' field is present, it MUST match the AES Key Wrap 2758 algorithm being used. 2760 o If the 'key_ops' field is present, it MUST include 'encrypt' or 2761 'wrap key' when encrypting. 2763 o If the 'key_ops' field is present, it MUST include 'decrypt' or 2764 'unwrap key' when decrypting. 2766 +--------+-------+----------+-----------------------------+ 2767 | name | value | key size | description | 2768 +--------+-------+----------+-----------------------------+ 2769 | A128KW | -3 | 128 | AES Key Wrap w/ 128-bit key | 2770 | | | | | 2771 | A192KW | -4 | 192 | AES Key Wrap w/ 192-bit key | 2772 | | | | | 2773 | A256KW | -5 | 256 | AES Key Wrap w/ 256-bit key | 2774 +--------+-------+----------+-----------------------------+ 2776 Table 17: AES Key Wrap Algorithm Values 2778 12.2.1.1. Security Considerations for AES-KW 2780 The shared secret needs to have some method to be regularly updated 2781 over time. The shared secret is the basis of trust. 2783 12.3. Key Transport 2785 Key transport mode is also called key encryption mode in some 2786 standards. Key transport mode differs from key wrap mode in that it 2787 uses an asymmetric encryption algorithm rather than a symmetric 2788 encryption algorithm to protect the key. This document does not 2789 define any key transport mode algorithms. 2791 When using a key transport algorithm, the COSE_Encrypt structure for 2792 the recipient is organized as follows: 2794 o The 'protected' field MUST be absent. 2796 o The plain text to be encrypted is the key from next layer down 2797 (usually the content layer). 2799 o At a minimum, the 'unprotected' field MUST contain the 'alg' 2800 parameter and SHOULD contain a parameter identifying the 2801 asymmetric key. 2803 12.4. Direct Key Agreement 2805 The 'direct key agreement' class of recipient algorithms uses a key 2806 agreement method to create a shared secret. A KDF is then applied to 2807 the shared secret to derive a key to be used in protecting the data. 2809 This key is normally used as a CEK or MAC key, but could be used for 2810 other purposes if more than two layers are in use (see Appendix B). 2812 The most commonly used key agreement algorithm is Diffie-Hellman, but 2813 other variants exist. Since COSE is designed for a store and forward 2814 environment rather than an on-line environment, many of the DH 2815 variants cannot be used as the receiver of the message cannot provide 2816 any dynamic key material. One side-effect of this is that perfect 2817 forward secrecy (see [RFC4949]) is not achievable. A static key will 2818 always be used for the receiver of the COSE object. 2820 Two variants of DH that are supported are: 2822 Ephemeral-Static DH: where the sender of the message creates a 2823 one-time DH key and uses a static key for the recipient. The use 2824 of the ephemeral sender key means that no additional random input 2825 is needed as this is randomly generated for each message. 2827 Static-Static DH: where a static key is used for both the sender 2828 and the recipient. The use of static keys allows for recipient to 2829 get a weak version of data origination for the message. When 2830 static-static key agreement is used, then some piece of unique 2831 data for the KDF is required to ensure that a different key is 2832 created for each message. 2834 When direct key agreement mode is used, there MUST be only one 2835 recipient in the message. This method creates the key directly and 2836 that makes it difficult to mix with additional recipients. If 2837 multiple recipients are needed, then the version with key wrap needs 2838 to be used. 2840 The COSE_Encrypt structure for the recipient is organized as follows: 2842 o At a minimum, headers MUST contain the 'alg' parameter and SHOULD 2843 contain a parameter identifying the recipient's asymmetric key. 2845 o The headers SHOULD identify the sender's key for the static-static 2846 versions and MUST contain the sender's ephemeral key for the 2847 ephemeral-static versions. 2849 12.4.1. ECDH 2851 The mathematics for Elliptic Curve Diffie-Hellman can be found in 2852 [RFC6090]. In this document, the algorithm is extended to be used 2853 with the two curves defined in [RFC7748]. 2855 ECDH is parameterized by the following: 2857 o Curve Type/Curve: The curve selected controls not only the size of 2858 the shared secret, but the mathematics for computing the shared 2859 secret. The curve selected also controls how a point in the curve 2860 is represented and what happens for the identity points on the 2861 curve. In this specification, we allow for a number of different 2862 curves to be used. A set of curves are defined in Table 22. 2863 The math used to obtain the computed secret is based on the curve 2864 selected and not on the ECDH algorithm. For this reason, a new 2865 algorithm does not need to be defined for each of the curves. 2867 o Computed Secret to Shared Secret: Once the computed secret is 2868 known, the resulting value needs to be converted to a byte string 2869 to run the KDF function. The X coordinate is used for all of the 2870 curves defined in this document. For curves X25519 and X448, the 2871 resulting value is used directly as it is a byte string of a known 2872 length. For the P-256, P-384 and P-521 curves, the X coordinate 2873 is run through the I2OSP function defined in [RFC3447], using the 2874 same computation for n as is defined in Section 8.1. 2876 o Ephemeral-static or static-static: The key agreement process may 2877 be done using either a static or an ephemeral key for the sender's 2878 side. When using ephemeral keys, the sender MUST generate a new 2879 ephemeral key for every key agreement operation. The ephemeral 2880 key is placed in the 'ephemeral key' parameter and MUST be present 2881 for all algorithm identifiers that use ephemeral keys. When using 2882 static keys, the sender MUST either generate a new random value or 2883 otherwise create a unique value. For the KDF functions used, this 2884 means either in the 'salt' parameter for HKDF (Table 13) or in the 2885 'PartyU nonce' parameter for the context structure (Table 14) MUST 2886 be present. (Both may be present if desired.) The value in the 2887 parameter MUST be unique for the pair of keys being used. It is 2888 acceptable to use a global counter that is incremented for every 2889 static-static operation and use the resulting value. When using 2890 static keys, the static key should be identified to the recipient. 2891 The static key can be identified either by providing the key 2892 ('static key') or by providing a key identifier for the static key 2893 ('static key id'). Both of these parameters are defined in 2894 Table 19. 2896 o Key derivation algorithm: The result of an ECDH key agreement 2897 process does not provide a uniformly random secret. As such, it 2898 needs to be run through a KDF in order to produce a usable key. 2899 Processing the secret through a KDF also allows for the 2900 introduction of context material: how the key is going to be used, 2901 and one-time material for static-static key agreement. All of the 2902 algorithms defined in this document use one of the HKDF algorithms 2903 defined in Section 11.1 with the context structure defined in 2904 Section 11.2. 2906 o Key Wrap algorithm: No key wrap algorithm is used. This is 2907 represented in Table 18 as 'none'. The key size for the context 2908 structure is the content layer encryption algorithm size. 2910 The set of direct ECDH algorithms defined in this document are found 2911 in Table 18. 2913 +-----------+-------+---------+------------+--------+---------------+ 2914 | name | value | KDF | Ephemeral- | Key | description | 2915 | | | | Static | Wrap | | 2916 +-----------+-------+---------+------------+--------+---------------+ 2917 | ECDH-ES + | -25 | HKDF - | yes | none | ECDH ES w/ | 2918 | HKDF-256 | | SHA-256 | | | HKDF - | 2919 | | | | | | generate key | 2920 | | | | | | directly | 2921 | | | | | | | 2922 | ECDH-ES + | -26 | HKDF - | yes | none | ECDH ES w/ | 2923 | HKDF-512 | | SHA-512 | | | HKDF - | 2924 | | | | | | generate key | 2925 | | | | | | directly | 2926 | | | | | | | 2927 | ECDH-SS + | -27 | HKDF - | no | none | ECDH SS w/ | 2928 | HKDF-256 | | SHA-256 | | | HKDF - | 2929 | | | | | | generate key | 2930 | | | | | | directly | 2931 | | | | | | | 2932 | ECDH-SS + | -28 | HKDF - | no | none | ECDH SS w/ | 2933 | HKDF-512 | | SHA-512 | | | HKDF - | 2934 | | | | | | generate key | 2935 | | | | | | directly | 2936 +-----------+-------+---------+------------+--------+---------------+ 2938 Table 18: ECDH Algorithm Values 2940 +-----------+-------+----------+-----------+------------------------+ 2941 | name | label | type | algorithm | description | 2942 +-----------+-------+----------+-----------+------------------------+ 2943 | ephemeral | -1 | COSE_Key | ECDH-ES | Ephemeral Public key | 2944 | key | | | | for the sender | 2945 | | | | | | 2946 | static | -2 | COSE_Key | ECDH-SS | Static Public key for | 2947 | key | | | | the sender | 2948 | | | | | | 2949 | static | -3 | bstr | ECDH-SS | Static Public key | 2950 | key id | | | | identifier for the | 2951 | | | | | sender | 2952 +-----------+-------+----------+-----------+------------------------+ 2954 Table 19: ECDH Algorithm Parameters 2956 This document defines these algorithms to be used with the curves 2957 P-256, P-384, P-521, X25519, and X448. Implementations MUST verify 2958 that the key type and curve are correct. Different curves are 2959 restricted to different key types. Implementations MUST verify that 2960 the curve and algorithm are appropriate for the entities involved. 2962 When using a COSE key for this algorithm, the following checks are 2963 made: 2965 o The 'kty' field MUST be present and it MUST be 'EC2' or 'OKP'. 2967 o If the 'alg' field present, it MUST match the Key Agreement 2968 algorithm being used. 2970 o If the 'key_ops' field is present, it MUST include 'derive key' or 2971 'derive bits' for the private key. 2973 o If the 'key_ops' field is present, it MUST be empty for the public 2974 key. 2976 12.4.2. Security Considerations 2978 Some method of checking that points provided from external entities 2979 are valid. For the 'EC2' key format, this can be done by checking 2980 that the x and y values form a point on the curve. For the 'OKP' 2981 format, there is no simple way to do point validation. 2983 Consideration was given to requiring that the public keys of both 2984 entities be provided as part of the key derivation process. (As 2985 recommended in section 6.1 of [RFC7748].) This was not done as COSE 2986 is used in a store and forward format rather than in on line key 2987 exchange. In order for this to be a problem, either the receiver 2988 public key has to be chosen maliciously or the sender has to be 2989 malicious. In either case, all security evaporates anyway. 2991 A proof of possession of the private key associated with the public 2992 key is recommended when a key is moved from untrusted to trusted. 2993 (Either by the end user or by the entity that is responsible for 2994 making trust statements on keys.) 2996 12.5. Key Agreement with KDF 2998 Key Agreement with Key Wrapping uses a randomly generated CEK. The 2999 CEK is then encrypted using a Key Wrapping algorithm and a key 3000 derived from the shared secret computed by the key agreement 3001 algorithm. 3003 The COSE_Encrypt structure for the recipient is organized as follows: 3005 o The 'protected' field is fed into the KDF context structure. 3007 o The plain text to be encrypted is the key from next layer down 3008 (usually the content layer). 3010 o The 'alg' parameter MUST be present in the layer. 3012 o A parameter identifying the recipient's key SHOULD be present. A 3013 parameter identifying the sender's key SHOULD be present. 3015 12.5.1. ECDH 3017 These algorithms are defined in Table 20. 3019 ECDH with Key Agreement is parameterized by the same parameters as 3020 for ECDH Section 12.4.1 with the following modifications: 3022 o Key Wrap Algorithm: Any of the key wrap algorithms defined in 3023 Section 12.2.1 are supported. The size of the key used for the 3024 key wrap algorithm is fed into the KDF function. The set of 3025 identifiers are found in Table 20. 3027 +-----------+-------+---------+------------+--------+---------------+ 3028 | name | value | KDF | Ephemeral- | Key | description | 3029 | | | | Static | Wrap | | 3030 +-----------+-------+---------+------------+--------+---------------+ 3031 | ECDH-ES + | -29 | HKDF - | yes | A128KW | ECDH ES w/ | 3032 | A128KW | | SHA-256 | | | Concat KDF | 3033 | | | | | | and AES Key | 3034 | | | | | | wrap w/ 128 | 3035 | | | | | | bit key | 3036 | | | | | | | 3037 | ECDH-ES + | -30 | HKDF - | yes | A192KW | ECDH ES w/ | 3038 | A192KW | | SHA-256 | | | Concat KDF | 3039 | | | | | | and AES Key | 3040 | | | | | | wrap w/ 192 | 3041 | | | | | | bit key | 3042 | | | | | | | 3043 | ECDH-ES + | -31 | HKDF - | yes | A256KW | ECDH ES w/ | 3044 | A256KW | | SHA-256 | | | Concat KDF | 3045 | | | | | | and AES Key | 3046 | | | | | | wrap w/ 256 | 3047 | | | | | | bit key | 3048 | | | | | | | 3049 | ECDH-SS + | -32 | HKDF - | no | A128KW | ECDH SS w/ | 3050 | A128KW | | SHA-256 | | | Concat KDF | 3051 | | | | | | and AES Key | 3052 | | | | | | wrap w/ 128 | 3053 | | | | | | bit key | 3054 | | | | | | | 3055 | ECDH-SS + | -33 | HKDF - | no | A192KW | ECDH SS w/ | 3056 | A192KW | | SHA-256 | | | Concat KDF | 3057 | | | | | | and AES Key | 3058 | | | | | | wrap w/ 192 | 3059 | | | | | | bit key | 3060 | | | | | | | 3061 | ECDH-SS + | -34 | HKDF - | no | A256KW | ECDH SS w/ | 3062 | A256KW | | SHA-256 | | | Concat KDF | 3063 | | | | | | and AES Key | 3064 | | | | | | wrap w/ 256 | 3065 | | | | | | bit key | 3066 +-----------+-------+---------+------------+--------+---------------+ 3068 Table 20: ECDH Algorithm Values with Key Wrap 3070 When using a COSE key for this algorithm, the following checks are 3071 made: 3073 o The 'kty' field MUST be present and it MUST be 'EC2' or 'OKP'. 3075 o If the 'alg' field present, it MUST match the Key Agreement 3076 algorithm being used. 3078 o If the 'key_ops' field is present, it MUST include 'derive key' or 3079 'derive bits' for the private key. 3081 o If the 'key_ops' field is present, it MUST be empty for the public 3082 key. 3084 13. Key Object Parameters 3086 The COSE_Key object defines a way to hold a single key object. It is 3087 still required that the members of individual key types be defined. 3088 This section of the document is where we define an initial set of 3089 members for specific key types. 3091 For each of the key types, we define both public and private members. 3092 The public members are what is transmitted to others for their usage. 3093 Private members allow for the archival of keys by individuals. 3094 However, there are some circumstances in which private keys may be 3095 distributed to entities in a protocol. Examples include: entities 3096 that have poor random number generation, centralized key creation for 3097 multi-cast type operations, and protocols in which a shared secret is 3098 used as a bearer token for authorization purposes. 3100 Key types are identified by the 'kty' member of the COSE_Key object. 3101 In this document, we define four values for the member: 3103 +-----------+-------+--------------------------------------------+ 3104 | name | value | description | 3105 +-----------+-------+--------------------------------------------+ 3106 | OKP | 1 | Octet Key Pair | 3107 | | | | 3108 | EC2 | 2 | Elliptic Curve Keys w/ X,Y Coordinate pair | 3109 | | | | 3110 | Symmetric | 4 | Symmetric Keys | 3111 | | | | 3112 | Reserved | 0 | This value is reserved | 3113 +-----------+-------+--------------------------------------------+ 3115 Table 21: Key Type Values 3117 13.1. Elliptic Curve Keys 3119 Two different key structures could be defined for Elliptic Curve 3120 keys. One version uses both an x and a y coordinate, potentially 3121 with point compression ('EC2'). This is the traditional EC point 3122 representation that is used in [RFC5480]. The other version uses 3123 only the x coordinate as the y coordinate is either to be recomputed 3124 or not needed for the key agreement operation ('OKP'). 3126 Applications MUST check that the curve and the key type are 3127 consistent and reject a key if they are not. 3129 +---------+----------+-------+------------------------------------+ 3130 | name | key type | value | description | 3131 +---------+----------+-------+------------------------------------+ 3132 | P-256 | EC2 | 1 | NIST P-256 also known as secp256r1 | 3133 | | | | | 3134 | P-384 | EC2 | 2 | NIST P-384 also known as secp384r1 | 3135 | | | | | 3136 | P-521 | EC2 | 3 | NIST P-521 also known as secp521r1 | 3137 | | | | | 3138 | X25519 | OKP | 4 | X25519 for use w/ ECDH only | 3139 | | | | | 3140 | X448 | OKP | 5 | X448 for use w/ ECDH only | 3141 | | | | | 3142 | Ed25519 | OKP | 6 | Ed25519 for use w/ EdDSA only | 3143 | | | | | 3144 | Ed448 | OKP | 7 | Ed448 for use w/ EdDSA only | 3145 +---------+----------+-------+------------------------------------+ 3147 Table 22: EC Curves 3149 13.1.1. Double Coordinate Curves 3151 The traditional way of sending EC curves has been to send either both 3152 the x and y coordinates, or the x coordinate and a sign bit for the y 3153 coordinate. The latter encoding has not been recommended in the IETF 3154 due to potential IPR issues. However, for operations in constrained 3155 environments, the ability to shrink a message by not sending the y 3156 coordinate is potentially useful. 3158 For EC keys with both coordinates, the 'kty' member is set to 2 3159 (EC2). The key parameters defined in this section are summarized in 3160 Table 23. The members that are defined for this key type are: 3162 crv contains an identifier of the curve to be used with the key. 3163 The curves defined in this document for this key type can be found 3164 in Table 22. Other curves may be registered in the future and 3165 private curves can be used as well. 3167 x contains the x coordinate for the EC point. The integer is 3168 converted to an octet string as defined in [SEC1]. Leading zero 3169 octets MUST be preserved. 3171 y contains either the sign bit or the value of y coordinate for the 3172 EC point. When encoding the value y, the integer is converted to 3173 an octet string (as defined in [SEC1]) and encoded as a CBOR bstr. 3174 Leading zero octets MUST be preserved. The compressed point 3175 encoding is also supported. Compute the sign bit as laid out in 3176 the Elliptic-Curve-Point-to-Octet-String Conversion function of 3177 [SEC1]. If the sign bit is zero, then encode y as a CBOR false 3178 value, otherwise encode y as a CBOR true value. The encoding of 3179 the infinity point is not supported. 3181 d contains the private key. 3183 For public keys, it is REQUIRED that 'crv', 'x' and 'y' be present in 3184 the structure. For private keys, it is REQUIRED that 'crv' and 'd' 3185 be present in the structure. For private keys, it is RECOMMENDED 3186 that 'x' and 'y' also be present, but they can be recomputed from the 3187 required elements and omitting them saves on space. 3189 +------+-------+-------+---------+----------------------------------+ 3190 | name | key | value | type | description | 3191 | | type | | | | 3192 +------+-------+-------+---------+----------------------------------+ 3193 | crv | 2 | -1 | int / | EC Curve identifier - Taken from | 3194 | | | | tstr | the COSE Curves registry | 3195 | | | | | | 3196 | x | 2 | -2 | bstr | X Coordinate | 3197 | | | | | | 3198 | y | 2 | -3 | bstr / | Y Coordinate | 3199 | | | | bool | | 3200 | | | | | | 3201 | d | 2 | -4 | bstr | Private key | 3202 +------+-------+-------+---------+----------------------------------+ 3204 Table 23: EC Key Parameters 3206 13.2. Octet Key Pair 3208 A new key type is defined for Octet Key Pairs (OKP). Do not assume 3209 that keys using this type are elliptic curves. This key type could 3210 be used for other curve types (for example, mathematics based on 3211 hyper-elliptic surfaces). 3213 The key parameters defined in this section are summarized in 3214 Table 24. The members that are defined for this key type are: 3216 crv contains an identifier of the curve to be used with the key. 3217 The curves defined in this document for this key type can be found 3218 in Table 22. Other curves may be registered in the future and 3219 private curves can be used as well. 3221 x contains the x coordinate for the EC point. The octet string 3222 represents a little-endian encoding of x. 3224 d contains the private key. 3226 For public keys, it is REQUIRED that 'crv' and 'x' be present in the 3227 structure. For private keys, it is REQUIRED that 'crv' and 'd' be 3228 present in the structure. For private keys, it is RECOMMENDED that 3229 'x' also be present, but it can be recomputed from the required 3230 elements and omitting it saves on space. 3232 +------+------+-------+-------+-------------------------------------+ 3233 | name | key | value | type | description | 3234 | | type | | | | 3235 +------+------+-------+-------+-------------------------------------+ 3236 | crv | 1 | -1 | int / | EC Curve identifier - Taken from | 3237 | | | | tstr | the COSE Key Common Parameters | 3238 | | | | | registry | 3239 | | | | | | 3240 | x | 1 | -2 | bstr | X Coordinate | 3241 | | | | | | 3242 | d | 1 | -4 | bstr | Private key | 3243 +------+------+-------+-------+-------------------------------------+ 3245 Table 24: Octet Key Pair Parameters 3247 13.3. Symmetric Keys 3249 Occasionally it is required that a symmetric key be transported 3250 between entities. This key structure allows for that to happen. 3252 For symmetric keys, the 'kty' member is set to 3 (Symmetric). The 3253 member that is defined for this key type is: 3255 k contains the value of the key. 3257 This key structure does not have a form that contains only public 3258 members. As it is expected that this key structure is going to be 3259 transmitted, care must be taking that it is never transmitted 3260 accidentally or insecurely. For symmetric keys, it is REQUIRED that 3261 'k' be present in the structure. 3263 +------+----------+-------+------+-------------+ 3264 | name | key type | value | type | description | 3265 +------+----------+-------+------+-------------+ 3266 | k | 4 | -1 | bstr | Key Value | 3267 +------+----------+-------+------+-------------+ 3269 Table 25: Symmetric Key Parameters 3271 14. CBOR Encoder Restrictions 3273 There has been an attempt to limit the number of places where the 3274 document needs to impose restrictions on how the CBOR Encoder needs 3275 to work. We have managed to narrow it down to the following 3276 restrictions: 3278 o The restriction applies to the encoding the Sig_structure, the 3279 Enc_structure, and the MAC_structure. 3281 o The rules for Canonical CBOR (Section 3.9 of RFC 7049) MUST be 3282 used in these locations. The main rule that needs to be enforced 3283 is that all lengths in these structures MUST be encoded such that 3284 they are encoded using definite lengths and the minimum length 3285 encoding is used. 3287 o Applications MUST NOT generate messages with the same label used 3288 twice as a key in a single map. Applications MUST NOT parse and 3289 process messages with the same label used twice as a key in a 3290 single map. Applications can enforce the parse and process 3291 requirement by using parsers that will fail the parse step or by 3292 using parsers that will pass all keys to the application and the 3293 application can perform the check for duplicate keys. 3295 15. Application Profiling Considerations 3297 This document is designed to provide a set of security services, but 3298 not to provide implementation requirements for specific usage. The 3299 interoperability requirements are provided for how each of the 3300 individual services are used and how the algorithms are to be used 3301 for interoperability. The requirements about which algorithms and 3302 which services are needed are deferred to each application. 3304 Applications are therefore intended to profile the usage of this 3305 document. This section provides a set of guidelines and topics that 3306 applications need to consider when using this document. 3308 o Applications need to determine the set of messages defined in this 3309 document that they will be using. The set of messages corresponds 3310 fairly directly to the set of security services that are needed 3311 and to the security levels needed. 3313 o Applications may define new header parameters for a specific 3314 purpose. Applications will often times select specific header 3315 parameters to use or not to use. For example, an application 3316 would normally state a preference for using either the IV or the 3317 partial IV parameter. If the partial IV parameter is specified, 3318 then the application would also need to define how the fixed 3319 portion of the IV would be determined. 3321 o When applications use externally defined authenticated data, they 3322 need to define how that data is encoded. This document assumes 3323 that the data will be provided as a byte stream. More information 3324 can be found in Section 4.3. 3326 o Applications need to determine the set of security algorithms that 3327 are to be used. When selecting the algorithms to be used as the 3328 mandatory to implement set, consideration should be given to 3329 choosing different types of algorithms when two are chosen for a 3330 specific purpose. An example of this would be choosing HMAC- 3331 SHA512 and AES-CMAC as different MAC algorithms; the construction 3332 is vastly different between these two algorithms. This means that 3333 a weakening of one algorithm would be unlikely to lead to a 3334 weakening of the other algorithms. Of course, these algorithms do 3335 not provide the same level of security and thus may not be 3336 comparable for the desired security functionality. 3338 o Applications may need to provide some type of negotiation or 3339 discovery method if multiple algorithms or message structures are 3340 permitted. The method can be as simple as requiring 3341 preconfiguration of the set of algorithms to providing a discovery 3342 method built into the protocol. S/MIME provided a number of 3343 different ways to approach the problem that applications could 3344 follow: 3346 * Advertising in the message (S/MIME capabilities) [RFC5751]. 3348 * Advertising in the certificate (capabilities extension) 3349 [RFC4262]. 3351 * Minimum requirements for the S/MIME, which have been updated 3352 over time [RFC2633][RFC5751]. 3354 16. IANA Considerations 3356 16.1. CBOR Tag assignment 3358 It is requested that IANA assign the following tags from the "CBOR 3359 Tags" registry. It is requested that the tags for COSE_Sign1, 3360 COSE_Encrypt0, and COSE_Mac0 be assigned in the 1 to 23 value range 3361 (one byte long when encoded). It is requested that the tags for 3362 COSE_Sign, COSE_Encrypt and COSE_MAC be assigned in the 24 to 255 3363 value range (two bytes long when encoded). 3365 The tags to be assigned are in Table 1. 3367 16.2. COSE Header Parameters Registry 3369 It is requested that IANA create a new registry entitled "COSE Header 3370 Parameters". The registry is to be created as Expert Review 3371 Required. Expert review guidelines are provided in Section 16.11. 3373 The columns of the registry are: 3375 name The name is present to make it easier to refer to and discuss 3376 the registration entry. The value is not used in the protocol. 3377 Names are to be unique in the table. 3379 label This is the value used for the label. The label can be either 3380 an integer or a string. Registration in the table is based on the 3381 value of the label requested. Integer values between 1 and 255 3382 and strings of length 1 are designated as Standards Track Document 3383 required. Integer values from 256 to 65535 and strings of length 3384 2 are designated as Specification Required. Integer values of 3385 greater than 65535 and strings of length greater than 2 are 3386 designated as expert review. Integer values in the range -1 to 3387 -65536 are delegated to the "COSE Header Algorithm Parameters" 3388 registry. Integer values less than -65536 are marked as private 3389 use. 3391 value This contains the CBOR type for the value portion of the 3392 label. 3394 value registry This contains a pointer to the registry used to 3395 contain values where the set is limited. 3397 description This contains a brief description of the header field. 3399 specification This contains a pointer to the specification defining 3400 the header field (where public). 3402 The initial contents of the registry can be found in Table 2 and 3403 Table 27. The specification column for all rows in that table should 3404 be this document. 3406 Additionally, the label of 0 is to be marked as 'Reserved'. 3408 16.3. COSE Header Algorithm Parameters Registry 3410 It is requested that IANA create a new registry entitled "COSE Header 3411 Algorithm Parameters". The registry is to be created as Expert 3412 Review Required. Expert review guidelines are provided in 3413 Section 16.11. 3415 The columns of the registry are: 3417 name The name is present to make it easier to refer to and discuss 3418 the registration entry. The value is not used in the protocol. 3420 algorithm The algorithm(s) that this registry entry is used for. 3421 This value is taken from the "COSE Algorithm Values" registry. 3422 Multiple algorithms can be specified in this entry. For the 3423 table, the algorithm, label pair MUST be unique. 3425 label This is the value used for the label. The label is an integer 3426 in the range of -1 to -65536. 3428 value This contains the CBOR type for the value portion of the 3429 label. 3431 value registry This contains a pointer to the registry used to 3432 contain values where the set is limited. 3434 description This contains a brief description of the header field. 3436 specification This contains a pointer to the specification defining 3437 the header field (where public). 3439 The initial contents of the registry can be found in Table 13, 3440 Table 14, and Table 19. The specification column for all rows in 3441 that table should be this document. 3443 16.4. COSE Algorithms Registry 3445 It is requested that IANA create a new registry entitled "COSE 3446 Algorithms Registry". The registry is to be created as Expert Review 3447 Required. Expert review guidelines are provided in Section 16.11. 3449 The columns of the registry are: 3451 value The value to be used to identify this algorithm. Algorithm 3452 values MUST be unique. The value can be a positive integer, a 3453 negative integer or a string. Integer values between -256 and 255 3454 and strings of length 1 are designated as Standards Track Document 3455 required. Integer values from -65536 to 65535 and strings of 3456 length 2 are designated as Specification Required. Integer values 3457 of greater than 65535 and strings of length greater than 2 are 3458 designated as expert review. Integer values less than -65536 are 3459 marked as private use. 3461 description A short description of the algorithm. 3463 specification A document where the algorithm is defined (if publicly 3464 available). 3466 The initial contents of the registry can be found in Table 10, 3467 Table 9, Table 11, Table 5, Table 7, Table 8, Table 15, Table 16, 3468 Table 17, Table 6, Table 20 and Table 18. The specification column 3469 for all rows in that table should be this document. 3471 NOTE: The assignment of algorithm identifiers in this document was 3472 done so that positive numbers were used for the first layer objects 3473 (COSE_Sign, COSE_Sign1, COSE_Encrypt, COSE_Encrypt0, COSE_Mac, and 3474 COSE_Mac0). Negative numbers were used for second layer objects 3475 (COSE_Signature and COSE_recipient). Expert reviewers should 3476 consider this practice, but are not expected to be restricted by this 3477 precedent. 3479 16.5. COSE Key Common Parameters Registry 3481 It is requested that IANA create a new registry entitled "COSE Key 3482 Common Parameters" registry. The registry is to be created as Expert 3483 Review Required. Expert review guidelines are provided in 3484 Section 16.11. 3486 The columns of the registry are: 3488 name This is a descriptive name that enables easier reference to the 3489 item. It is not used in the encoding. 3491 label The value to be used to identify this algorithm. Key map 3492 labels MUST be unique. The label can be a positive integer, a 3493 negative integer or a string. Integer values between 0 and 255 3494 and strings of length 1 are designated as Standards Track Document 3495 required. Integer values from 256 to 65535 and strings of length 3496 2 are designated as Specification Required. Integer values of 3497 greater than 65535 and strings of length greater than 2 are 3498 designated as expert review. Integer values in the range -1 to 3499 -65536 are used for key parameters specific to a single algorithm 3500 delegated to the "COSE Key Type Parameter Labels" registry. 3501 Integer values less than -65536 are marked as private use. 3503 CBOR Type This field contains the CBOR type for the field. 3505 registry This field denotes the registry that values come from, if 3506 one exists. 3508 description This field contains a brief description for the field. 3510 specification This contains a pointer to the public specification 3511 for the field if one exists 3513 This registry will be initially populated by the values in Table 3. 3514 The specification column for all of these entries will be this 3515 document. 3517 16.6. COSE Key Type Parameters Registry 3519 It is requested that IANA create a new registry "COSE Key Type 3520 Parameters". The registry is to be created as Expert Review 3521 Required. Expert review guidelines are provided in Section 16.11. 3523 The columns of the table are: 3525 key type This field contains a descriptive string of a key type. 3526 This should be a value that is in the COSE Key Common Parameters 3527 table and is placed in the 'kty' field of a COSE Key structure. 3529 name This is a descriptive name that enables easier reference to the 3530 item. It is not used in the encoding. 3532 label The label is to be unique for every value of key type. The 3533 range of values is from -256 to -1. Labels are expected to be 3534 reused for different keys. 3536 CBOR type This field contains the CBOR type for the field. 3538 description This field contains a brief description for the field. 3540 specification This contains a pointer to the public specification 3541 for the field if one exists. 3543 This registry will be initially populated by the values in Table 23, 3544 Table 24, and Table 25. The specification column for all of these 3545 entries will be this document. 3547 16.7. COSE Key Type Registry 3549 It is requested that IANA create a new registry "COSE Key Type 3550 Registry"> The registry is to be created as Expert Review Required. 3551 Expert review guidelines are provided in Section 16.11. 3553 The columns of this table are: 3555 name This is a descriptive name that enables easier reference to the 3556 item. The name MUST be unique. It is not used in the encoding. 3558 value This is the value used to identify the curve. These values 3559 MUST be unique. The value can be a positive integer, a negative 3560 integer or a string. 3562 description This field contains a brief description of the curve. 3564 specification This contains a pointer to the public specification 3565 for the curve if one exists. 3567 This registry will be initially populated by the values in Table 21. 3568 The specification column for all of these entries will be this 3569 document. 3571 16.8. COSE Elliptic Curve Parameters Registry 3573 It is requested that IANA create a new registry "COSE Elliptic Curve 3574 Parameters". The registry is to be created as Expert Review 3575 Required. Expert review guidelines are provided in Section 16.11. 3577 The columns of the table are: 3579 name This is a descriptive name that enables easier reference to the 3580 item. It is not used in the encoding. 3582 value This is the value used to identify the curve. These values 3583 MUST be unique. The integer values from -256 to 255 are 3584 designated as Standards Track Document Required. The integer 3585 values from 256 to 65535 and -65536 to -257 are designated as 3586 Specification Required. Integer values over 65535 are designated 3587 as expert review. Integer values less than -65536 are marked as 3588 private use. 3590 key type This designates the key type(s) that can be used with this 3591 curve. 3593 description This field contains a brief description of the curve. 3595 specification This contains a pointer to the public specification 3596 for the curve if one exists. 3598 This registry will be initially populated by the values in Table 22. 3599 The specification column for all of these entries will be this 3600 document. 3602 16.9. Media Type Registrations 3604 16.9.1. COSE Security Message 3606 This section registers the "application/cose" media type in the 3607 "Media Types" registry. These media types are used to indicate that 3608 the content is a COSE message. 3610 Type name: application 3612 Subtype name: cose 3614 Required parameters: N/A 3616 Optional parameters: cose-type 3618 Encoding considerations: binary 3620 Security considerations: See the Security Considerations section 3621 of RFC TBD. 3623 Interoperability considerations: N/A 3625 Published specification: RFC TBD 3627 Applications that use this media type: To be identified 3629 Fragment identifier considerations: N/A 3631 Additional information: 3633 * Magic number(s): N/A 3635 * File extension(s): cbor 3637 * Macintosh file type code(s): N/A 3639 Person & email address to contact for further information: 3640 iesg@ietf.org 3642 Intended usage: COMMON 3643 Restrictions on usage: N/A 3645 Author: Jim Schaad, ietf@augustcellars.com 3647 Change Controller: IESG 3649 Provisional registration? No 3651 16.9.2. COSE Key media type 3653 This section registers the "application/cose-key" and "application/ 3654 cose-key-set" media types in the "Media Types" registry. These media 3655 types are used to indicate, respectively, that content is a COSE_Key 3656 or COSE_KeySet object. 3658 The template for registering "application/cose-key" is: 3660 Type name: application 3662 Subtype name: cose-key 3664 Required parameters: N/A 3666 Optional parameters: N/A 3668 Encoding considerations: binary 3670 Security considerations: See the Security Considerations section 3671 of RFC TBD. 3673 Interoperability considerations: N/A 3675 Published specification: RFC TBD 3677 Applications that use this media type: To be identified 3679 Fragment identifier considerations: N/A 3681 Additional information: 3683 * Magic number(s): N/A 3685 * File extension(s): cbor 3687 * Macintosh file type code(s): N/A 3689 Person & email address to contact for further information: 3690 iesg@ietf.org 3691 Intended usage: COMMON 3693 Restrictions on usage: N/A 3695 Author: Jim Schaad, ietf@augustcellars.com 3697 Change Controller: IESG 3699 Provisional registration? No 3701 The template for registering "application/cose-key-set" is: 3703 Type name: application 3705 Subtype name: cose-key-set 3707 Required parameters: N/A 3709 Optional parameters: N/A 3711 Encoding considerations: binary 3713 Security considerations: See the Security Considerations section 3714 of RFC TBD. 3716 Interoperability considerations: N/A 3718 Published specification: RFC TBD 3720 Applications that use this media type: To be identified 3722 Fragment identifier considerations: N/A 3724 Additional information: 3726 * Magic number(s): N/A 3728 * File extension(s): cbor 3730 * Macintosh file type code(s): N/A 3732 Person & email address to contact for further information: 3733 iesg@ietf.org 3735 Intended usage: COMMON 3737 Restrictions on usage: N/A 3738 Author: Jim Schaad, ietf@augustcellars.com 3740 Change Controller: IESG 3742 Provisional registration? No 3744 16.10. CoAP Content-Format Registrations 3746 IANA is requested to add the following entries to the "CoAP Content- 3747 Format" registry. ID assignment in the 24-255 range is requested. 3749 +---------------------------------+----------+-------+--------------+ 3750 | Media Type | Encoding | ID | Reference | 3751 +---------------------------------+----------+-------+--------------+ 3752 | application/cose; cose-type | | TBD10 | [This | 3753 | ="cose-sign" | | | Document] | 3754 | | | | | 3755 | application/cose; cose-type | | TBD11 | [This | 3756 | ="cose-sign1" | | | Document] | 3757 | | | | | 3758 | application/cose; cose-type | | TBD12 | [This | 3759 | ="cose-encrypt" | | | Document] | 3760 | | | | | 3761 | application/cose; cose-type | | TBD13 | [This | 3762 | ="cose-encrypt0" | | | Document] | 3763 | | | | | 3764 | application/cose; cose-type | | TBD14 | [This | 3765 | ="cose-mac" | | | Document] | 3766 | | | | | 3767 | application/cose; cose-type | | TBD15 | [This | 3768 | ="cose-mac0" | | | Document] | 3769 | | | | | 3770 | application/cose-key | | TBD16 | [This | 3771 | | | | Document] | 3772 | | | | | 3773 | application/cose-key-set | | TBD17 | [This | 3774 | | | | Document | 3775 +---------------------------------+----------+-------+--------------+ 3777 Table 26 3779 16.11. Expert Review Instructions 3781 All of the IANA registries established in this document are defined 3782 as expert review. This section gives some general guidelines for 3783 what the experts should be looking for, but they are being designated 3784 as experts for a reason so they should be given substantial latitude. 3786 Expert reviewers should take into consideration the following points: 3788 o Point squatting should be discouraged. Reviewers are encouraged 3789 to get sufficient information for registration requests to ensure 3790 that the usage is not going to duplicate one that is already 3791 registered and that the point is likely to be used in deployments. 3792 The zones tagged as private use are intended for testing purposes 3793 and closed environments, code points in other ranges should not be 3794 assigned for testing. 3796 o Specifications are required for the standards track range of point 3797 assignment. Specifications should exist for specification 3798 required ranges, but early assignment before a specification is 3799 available is considered to be permissible. Specifications are 3800 needed for the first-come, first-serve range if they are expected 3801 to be used outside of closed environments in an interoperable way. 3802 When specifications are not provided, the description provided 3803 needs to have sufficient information to identify what the point is 3804 being used for. 3806 o Experts should take into account the expected usage of fields when 3807 approving point assignment. The fact that there is a range for 3808 standards track documents does not mean that a standards track 3809 document cannot have points assigned outside of that range. Some 3810 of the ranges are restricted in range, items that are not expected 3811 to be common or are not expected to be used in constrained 3812 environments should be assigned to values which will encode to 3813 longer byte strings. 3815 o When algorithms are registered, vanity registrations should be 3816 discouraged. One way to do this is to require registrations to 3817 provide additional documentation on security analysis of the 3818 algorithm. Another thing that should be considered is to request 3819 for an opinion on the algorithm from the Crypto Forum Research 3820 Group (CFRG). Algorithms that do not meet the security 3821 requirements of the community and the messages structures should 3822 not be registered. 3824 17. Implementation Status 3826 This section records the status of known implementations of the 3827 protocol defined by this specification at the time of posting of this 3828 Internet-Draft, and is based on a proposal described in [RFC6982]. 3829 The description of implementations in this section is intended to 3830 assist the IETF in its decision processes in progressing drafts to 3831 RFCs. Please note that the listing of any individual implementation 3832 here does not imply endorsement by the IETF. Furthermore, no effort 3833 has been spent to verify the information presented here that was 3834 supplied by IETF contributors. This is not intended as, and must not 3835 be construed to be, a catalog of available implementations or their 3836 features. Readers are advised to note that other implementations may 3837 exist. 3839 According to [RFC6982], "this will allow reviewers and working groups 3840 to assign due consideration to documents that have the benefit of 3841 running code, which may serve as evidence of valuable experimentation 3842 and feedback that have made the implemented protocols more mature. 3843 It is up to the individual working groups to use this information as 3844 they see fit". 3846 17.1. Author's Versions 3848 There are three different implementations that have been created by 3849 the author of the document both to create the examples that are 3850 included in the document and to validate the structures and 3851 methodology used in the design of COSE. 3853 Implementation Location: https://github.com/cose-wg 3855 Primary Maintainer: Jim Schaad 3857 Languages: There are three different languages that are currently 3858 supported: Java, C# and C. 3860 Cryptography: The Java and C# libraries use Bouncy Castle to 3861 provide the required cryptography. The C version uses OPENSSL 3862 Version 1.0 for the cryptography. 3864 Coverage: The libraries currently do not have full support for 3865 counter signatures of either variety. They do have support to 3866 allow for implicit algorithm support as they allow for the 3867 application to set attributes that are not to be sent in the 3868 message. 3870 Testing: All of the examples in the example library are generated 3871 by the C# library and then validated using the Java and C 3872 libraries. All three libraries have tests to allow for the 3873 creating of the same messages that are in the example library 3874 followed by validating them. These are not compared against the 3875 example library. The Java and C# libraries have unit testing 3876 included. Not all of the MUST statements in the document have 3877 been implemented as part of the libraries. One such statement is 3878 the requirement that unique labels be present. 3880 Licensing: Revised BSD License 3882 17.2. COSE Testing Library 3884 Implementation Location: https://github.com/cose-wg/Examples 3886 Primary Maintainer: Jim Schaad 3888 Description: A set of tests for the COSE library is provided as 3889 part of the implementation effort. Both success and fail tests 3890 have been provided. All of the examples in this document are part 3891 of this example set. 3893 Coverage: An attempt has been made to have test cases for every 3894 message type and algorithm in the document. Currently examples 3895 dealing with counter signatures, EdDSA, and ECDH with Curve24459 3896 and Goldilocks are missing. 3898 Licensing: Public Domain 3900 18. Security Considerations 3902 There are a number of security considerations that need to be taken 3903 into account by implementers of this specification. The security 3904 considerations that are specific to an individual algorithm are 3905 placed next to the description of the algorithm. While some 3906 considerations have been highlighted here, additional considerations 3907 may be found in the documents listed in the references. 3909 Implementations need to protect the private key material for any 3910 individuals. There are some cases in this document that need to be 3911 highlighted on this issue. 3913 o Using the same key for two different algorithms can leak 3914 information about the key. It is therefore recommended that keys 3915 be restricted to a single algorithm. 3917 o Use of 'direct' as a recipient algorithm combined with a second 3918 recipient algorithm, either directly in a separate message, 3919 exposes the direct key to the second recipient. 3921 o Several of the algorithms in this document have limits on the 3922 number of times that a key can be used without leaking information 3923 about the key. 3925 The use of ECDH and direct plus KDF (with no key wrap) will not 3926 directly lead to the private key being leaked; the one way function 3927 of the KDF will prevent that. There is however, a different issue 3928 that needs to be addressed. Having two recipients requires that the 3929 CEK be shared between two recipients. The second recipient therefore 3930 has a CEK that was derived from material that can be used for the 3931 weak proof of origin. The second recipient could create a message 3932 using the same CEK and send it to the first recipient, the first 3933 recipient would, for either static-static ECDH or direct plus KDF, 3934 make an assumption that the CEK could be used for proof of origin 3935 even though it is from the wrong entity. If the key wrap step is 3936 added, then no proof of origin is implied and this is not an issue. 3938 Although it has been mentioned before, the use of a single key for 3939 multiple algorithms has been demonstrated in some cases to leak 3940 information about a key, provide for attackers to forge integrity 3941 tags, or gain information about encrypted content. Binding a key to 3942 a single algorithm prevents these problems. Key creators and key 3943 consumers are strongly encouraged not only to create new keys for 3944 each different algorithm, but to include that selection of algorithm 3945 in any distribution of key material and strictly enforce the matching 3946 of algorithms in the key structure to algorithms in the message 3947 structure. In addition to checking that algorithms are correct, the 3948 key form needs to be checked as well. Do not use an 'EC2' key where 3949 an 'OKP' key is expected. 3951 Before using a key for transmission, or before acting on information 3952 received, a trust decision on a key needs to be made. Is the data or 3953 action something that the entity associated with the key has a right 3954 to see or a right to request? A number of factors are associated 3955 with this trust decision. Some of the ones that are highlighted here 3956 are: 3958 o What are the permissions associated with the key owner? 3960 o Is the cryptographic algorithm acceptable in the current context? 3962 o Have the restrictions associated with the key, such as algorithm 3963 or freshness, been checked and are correct? 3965 o Is the request something that is reasonable, given the current 3966 state of the application? 3968 o Have any security considerations that are part of the message been 3969 enforced (as specified by the application or 'crit' parameter)? 3971 There are a large number of algorithms presented in this document 3972 that use nonce values. For all of the nonces defined in this 3973 document, there is some type of restriction on the nonce being a 3974 unique value either for a key or for some other conditions. In all 3975 of these cases, there is no known requirement on the nonce being both 3976 unique and unpredictable, under these circumstances it reasonable to 3977 use a counter for creation of the nonce. In cases where one wants 3978 the pattern of the nonce to be unpredictable as well as unique, one 3979 can use a key created for that purpose and encrypt the counter to 3980 produce the nonce value. 3982 One area that has been starting to get exposure is doing traffic 3983 analysis of encrypted messages based on the length of the message. 3984 This specification does not provide for a uniform method of providing 3985 padding as part of the message structure. An observer can 3986 distinguish between two different strings (for example, 'YES' and 3987 'NO') based on length for all of the content encryption algorithms 3988 that are defined in this document. This means that it is up to 3989 applications to document how content padding is to be done in order 3990 to prevent or discourage such analysis. (For example, the strings 3991 could be defined as 'YES' and 'NO '.) 3993 19. References 3995 19.1. Normative References 3997 [AES-GCM] Dworkin, M., "NIST Special Publication 800-38D: 3998 Recommendation for Block Cipher Modes of Operation: 3999 Galois/Counter Mode (GCM) and GMAC.", Nov 2007. 4001 [DSS] U.S. National Institute of Standards and Technology, 4002 "Digital Signature Standard (DSS)", July 2013. 4004 [MAC] NiST, N., "FIPS PUB 113: Computer Data Authentication", 4005 May 1985. 4007 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 4008 Hashing for Message Authentication", RFC 2104, 4009 DOI 10.17487/RFC2104, February 1997, 4010 . 4012 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 4013 Requirement Levels", BCP 14, RFC 2119, 4014 DOI 10.17487/RFC2119, March 1997, 4015 . 4017 [RFC3394] Schaad, J. and R. Housley, "Advanced Encryption Standard 4018 (AES) Key Wrap Algorithm", RFC 3394, DOI 10.17487/RFC3394, 4019 September 2002, . 4021 [RFC3610] Whiting, D., Housley, R., and N. Ferguson, "Counter with 4022 CBC-MAC (CCM)", RFC 3610, DOI 10.17487/RFC3610, September 4023 2003, . 4025 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 4026 Key Derivation Function (HKDF)", RFC 5869, 4027 DOI 10.17487/RFC5869, May 2010, 4028 . 4030 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 4031 Curve Cryptography Algorithms", RFC 6090, 4032 DOI 10.17487/RFC6090, February 2011, 4033 . 4035 [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object 4036 Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, 4037 October 2013, . 4039 [RFC7539] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 4040 Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015, 4041 . 4043 [SEC1] Standards for Efficient Cryptography Group, "SEC 1: 4044 Elliptic Curve Cryptography", May 2009. 4046 19.2. Informative References 4048 [I-D.greevenbosch-appsawg-cbor-cddl] 4049 Vigano, C. and H. Birkholz, "CBOR data definition language 4050 (CDDL): a notational convention to express CBOR data 4051 structures", draft-greevenbosch-appsawg-cbor-cddl-08 (work 4052 in progress), March 2016. 4054 [I-D.irtf-cfrg-eddsa] 4055 Josefsson, S. and I. Liusvaara, "Edwards-curve Digital 4056 Signature Algorithm (EdDSA)", draft-irtf-cfrg-eddsa-05 4057 (work in progress), March 2016. 4059 [PVSig] Brown, D. and D. Johnson, "Formal Security Proofs for a 4060 Signature Scheme with Partial Message Recover", February 4061 2000. 4063 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 4064 Extensions (MIME) Part One: Format of Internet Message 4065 Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996, 4066 . 4068 [RFC2633] Ramsdell, B., Ed., "S/MIME Version 3 Message 4069 Specification", RFC 2633, DOI 10.17487/RFC2633, June 1999, 4070 . 4072 [RFC2898] Kaliski, B., "PKCS #5: Password-Based Cryptography 4073 Specification Version 2.0", RFC 2898, 4074 DOI 10.17487/RFC2898, September 2000, 4075 . 4077 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 4078 Standards (PKCS) #1: RSA Cryptography Specifications 4079 Version 2.1", RFC 3447, DOI 10.17487/RFC3447, February 4080 2003, . 4082 [RFC4231] Nystrom, M., "Identifiers and Test Vectors for HMAC-SHA- 4083 224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512", 4084 RFC 4231, DOI 10.17487/RFC4231, December 2005, 4085 . 4087 [RFC4262] Santesson, S., "X.509 Certificate Extension for Secure/ 4088 Multipurpose Internet Mail Extensions (S/MIME) 4089 Capabilities", RFC 4262, DOI 10.17487/RFC4262, December 4090 2005, . 4092 [RFC4493] Song, JH., Poovendran, R., Lee, J., and T. Iwata, "The 4093 AES-CMAC Algorithm", RFC 4493, DOI 10.17487/RFC4493, June 4094 2006, . 4096 [RFC4949] Shirey, R., "Internet Security Glossary, Version 2", 4097 FYI 36, RFC 4949, DOI 10.17487/RFC4949, August 2007, 4098 . 4100 [RFC5480] Turner, S., Brown, D., Yiu, K., Housley, R., and T. Polk, 4101 "Elliptic Curve Cryptography Subject Public Key 4102 Information", RFC 5480, DOI 10.17487/RFC5480, March 2009, 4103 . 4105 [RFC5652] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70, 4106 RFC 5652, DOI 10.17487/RFC5652, September 2009, 4107 . 4109 [RFC5751] Ramsdell, B. and S. Turner, "Secure/Multipurpose Internet 4110 Mail Extensions (S/MIME) Version 3.2 Message 4111 Specification", RFC 5751, DOI 10.17487/RFC5751, January 4112 2010, . 4114 [RFC5752] Turner, S. and J. Schaad, "Multiple Signatures in 4115 Cryptographic Message Syntax (CMS)", RFC 5752, 4116 DOI 10.17487/RFC5752, January 2010, 4117 . 4119 [RFC5990] Randall, J., Kaliski, B., Brainard, J., and S. Turner, 4120 "Use of the RSA-KEM Key Transport Algorithm in the 4121 Cryptographic Message Syntax (CMS)", RFC 5990, 4122 DOI 10.17487/RFC5990, September 2010, 4123 . 4125 [RFC6151] Turner, S. and L. Chen, "Updated Security Considerations 4126 for the MD5 Message-Digest and the HMAC-MD5 Algorithms", 4127 RFC 6151, DOI 10.17487/RFC6151, March 2011, 4128 . 4130 [RFC6979] Pornin, T., "Deterministic Usage of the Digital Signature 4131 Algorithm (DSA) and Elliptic Curve Digital Signature 4132 Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, August 4133 2013, . 4135 [RFC6982] Sheffer, Y. and A. Farrel, "Improving Awareness of Running 4136 Code: The Implementation Status Section", RFC 6982, 4137 DOI 10.17487/RFC6982, July 2013, 4138 . 4140 [RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data 4141 Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 4142 2014, . 4144 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 4145 Application Protocol (CoAP)", RFC 7252, 4146 DOI 10.17487/RFC7252, June 2014, 4147 . 4149 [RFC7515] Jones, M., Bradley, J., and N. Sakimura, "JSON Web 4150 Signature (JWS)", RFC 7515, DOI 10.17487/RFC7515, May 4151 2015, . 4153 [RFC7516] Jones, M. and J. Hildebrand, "JSON Web Encryption (JWE)", 4154 RFC 7516, DOI 10.17487/RFC7516, May 2015, 4155 . 4157 [RFC7517] Jones, M., "JSON Web Key (JWK)", RFC 7517, 4158 DOI 10.17487/RFC7517, May 2015, 4159 . 4161 [RFC7518] Jones, M., "JSON Web Algorithms (JWA)", RFC 7518, 4162 DOI 10.17487/RFC7518, May 2015, 4163 . 4165 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 4166 for Security", RFC 7748, DOI 10.17487/RFC7748, January 4167 2016, . 4169 [SP800-56A] 4170 Barker, E., Chen, L., Roginsky, A., and M. Smid, "NIST 4171 Special Publication 800-56A: Recommendation for Pair-Wise 4172 Key Establishment Schemes Using Discrete Logarithm 4173 Cryptography", May 2013. 4175 Appendix A. Making Mandatory Algorithm Header Optional 4177 There has been a portion of the working group who have expressed a 4178 strong desire to relax the rule that the algorithm identifier be 4179 required to appear in each level of a COSE object. There are two 4180 basic reasons that have been advanced to support this position. 4181 First, the resulting message will be smaller if the algorithm 4182 identifier is omitted from the most common messages in a CoAP 4183 environment. Second, there is a potential bug that will arise if 4184 full checking is not done correctly between the different places that 4185 an algorithm identifier could be placed (the message itself, an 4186 application statement, the key structure that the sender possesses 4187 and the key structure the recipient possesses). 4189 This appendix lays out how such a change can be made and the details 4190 that an application needs to specify in order to use this option. 4191 Two different sets of details are specified: Those needed to omit an 4192 algorithm identifier and those needed to use a variant on the counter 4193 signature attribute that contains no attributes about itself. 4195 A.1. Algorithm Identification 4197 In this section are laid out three sets of recommendations. The 4198 first set of recommendations apply to having an implicit algorithm 4199 identified for a single layer of a COSE object. The second set of 4200 recommendations apply to having multiple implicit algorithms 4201 identified for multiple layers of a COSE object. The third set of 4202 recommendations apply to having implicit algorithms for multiple COSE 4203 object constructs. 4205 RFC 2119 language is deliberately not used here. This specification 4206 can provide recommendations, but it cannot enforce them. 4208 This set of recommendations applies to the case where an application 4209 is distributing a fixed algorithm along with the key information for 4210 use in a single COSE object. This normally applies to the smallest 4211 of the COSE objects, specifically COSE_Sign1, COSE_Mac0, and 4212 COSE_Encrypt0, but could apply to the other structures as well. 4214 The following items should be taken into account: 4216 o Applications need to list the set of COSE structures that implicit 4217 algorithms are to be used in. Applications need to require that 4218 the receipt of an explicit algorithm identifier in one of these 4219 structures will lead to the message being rejected. This 4220 requirement is stated so that there will never be a case where 4221 there is any ambiguity about the question of which algorithm 4222 should be used, the implicit or the explicit one. This applies 4223 even if the transported algorithm identifier is a protected 4224 attribute. This applies even if the transported algorithm is the 4225 same as the implicit algorithm. 4227 o Applications need to define the set of information that is to be 4228 considered to be part of a context when omitting algorithm 4229 identifiers. At a minimum, this would be the key identifier (if 4230 needed), the key, the algorithm, and the COSE structure it is used 4231 with. Applications should restrict the use of a single key to a 4232 single algorithm. As noted for some of the algorithms in this 4233 document, the use of the same key in different related algorithms 4234 can lead to leakage of information about the key, leakage about 4235 the data or the ability to perform forgeries. 4237 o In many cases, applications that make the algorithm identifier 4238 implicit will also want to make the context identifier implicit 4239 for the same reason. That is, omitting the context identifier 4240 will decrease the message size (potentially significantly 4241 depending on the length of the identifier). Applications that do 4242 this will need to describe the circumstances where the context 4243 identifier is to be omitted and how the context identifier is to 4244 be inferred in these cases. (Exhaustive search over all of the 4245 keys would normally not be considered to be acceptable.) An 4246 example of how this can be done is to tie the context to a 4247 transaction identifier. Both would be sent on the original 4248 message, but only the transaction identifier would need to be sent 4249 after that point as the context is tied into the transaction 4250 identifier. Another way would be to associate a context with a 4251 network address. All messages coming from a single network 4252 address can be assumed to be associated with a specific context. 4253 (In this case the address would normally be distributed as part of 4254 the context.) 4256 o Applications cannot rely on key identifiers being unique unless 4257 they take significant efforts to ensure that they are computed in 4258 such a way as to create this guarantee. Even when an application 4259 does this, the uniqueness might be violated if the application is 4260 run in different contexts (i.e., with a different context 4261 provider) or if the system combines the security contexts from 4262 different applications together into a single store. 4264 o Applications should continue the practice of protecting the 4265 algorithm identifier. Since this is not done by placing it in the 4266 protected attributes field, applications should define an 4267 application specific external data structure that includes this 4268 value. This external data field can be used as such for content 4269 encryption, MAC, and signature algorithms. It can be used in the 4270 SuppPrivInfo field for those algorithms which use a KDF function 4271 to derive a key value. Applications may also want to protect 4272 other information that is part of the context structure as well. 4273 It should be noted that those fields, such as the key or a base 4274 IV, are protected by virtue of being used in the cryptographic 4275 computation and do not need to be included in the external data 4276 field. 4278 The second case is having multiple implicit algorithm identifiers 4279 specified for a multiple layer COSE object. An example of how this 4280 would work is the encryption context that an application specifies 4281 contains a content encryption algorithm, a key wrap algorithm, a key 4282 identifier, and a shared secret. The sender omits sending the 4283 algorithm identifier for both the content layer and the recipient 4284 layer leaving only the key identifier. The receiver then uses the 4285 key identifier to get the implicit algorithm identifiers. 4287 The following additional items need to be taken into consideration: 4289 o Applications that want to support this will need to define a 4290 structure that allows for, and clearly identifies, both the COSE 4291 structure to be used with a given key and the structure and 4292 algorithm to be used for the secondary layer. The key for the 4293 secondary layer is computed per normal from the recipient layer. 4295 The third case is having multiple implicit algorithm identifiers, but 4296 targeted at potentially unrelated layers or different COSE objects. 4297 There are a number of different scenarios where this might be 4298 applicable. Some of these scenarios are: 4300 o Two contexts are distributed as a pair. Each of the contexts is 4301 for use with a COSE_Encrypt message. Each context will consist of 4302 distinct secret keys and IVs and potentially even different 4303 algorithms. One context is for sending messages from party A to 4304 party B, the second context is for sending messages from party B 4305 to party A. This means that there is no chance for a reflection 4306 attack to occur as each party uses different secret keys to send 4307 its messages, a message that is reflected back to it would fail to 4308 decrypt. 4310 o Two contexts are distributed as a pair. The first context is used 4311 for encryption of the message; the second context is used to place 4312 a counter signature on the message. The intention is that the 4313 second context can be distributed to other entities independently 4314 of the first context. This allows these entities to validate that 4315 the message came from an individual without being able to decrypt 4316 the message and see the content. 4318 o Two contexts are distributed as a pair. The first context 4319 contains a key for dealing with MACed messages, the second context 4320 contains a key for dealing with encrypted messages. This allows 4321 for a unified distribution of keys to participants for different 4322 types of messages that have different keys, but where the keys may 4323 be used in coordinated manner. 4325 For these cases, the following additional items need to be 4326 considered: 4328 o Applications need to ensure that the multiple contexts stay 4329 associated. If one of the contexts is invalidated for any reason, 4330 all of the contexts associated with it should also be invalidated. 4332 A.2. Counter Signature Without Headers 4334 There is a group of people who want to have a counter signature 4335 parameter that is directly tied to the value being signed and thus 4336 the authenticated and unauthenticated buckets can be removed from the 4337 message being sent. The focus on this is an even smaller size, as 4338 all of the information on the process of creating the counter 4339 signature is implicit rather than being explicitly carried in the 4340 message. This includes not only the algorithm identifier as 4341 presented above, but also items such as the key identification is 4342 always external to the signature structure. This means that the 4343 entities that are doing the validation of the counter signature are 4344 required to infer which key is to be used from context rather than 4345 being explicit. One way of doing this would be to presume that all 4346 data coming from a specific port (or to a specific URL) is to be 4347 validated by a specific key. (Note that this does not require that 4348 the key identifier be part of the value signed as it does not serve a 4349 cryptographic purpose. If the key validates the counter signature, 4350 then it should be presumed that the entity associated with that key 4351 produced the signature.) 4353 When computing the signature for the bare counter signature header, 4354 the same Sig_structure defined in Section 4.4 is used. The 4355 sign_protected field is omitted, as there is no protected header 4356 field in in this counter signature header. The value of 4357 "CounterSignature0" is placed in the context field of the 4358 Sig_stucture. 4360 +-------------------+-------+--------+------------------------------+ 4361 | name | label | value | description | 4362 | | | type | | 4363 +-------------------+-------+--------+------------------------------+ 4364 | CounterSignature0 | 9 | bstr | Counter signature with | 4365 | | | | implied signer and headers | 4366 +-------------------+-------+--------+------------------------------+ 4368 Table 27 4370 Appendix B. Two Layers of Recipient Information 4372 All of the currently defined recipient algorithms classes only use 4373 two layers of the COSE_Encrypt structure. The first layer is the 4374 message content and the second layer is the content key encryption. 4375 However, if one uses a recipient algorithm such as RSA-KEM (see 4376 Appendix A of RSA-KEM [RFC5990]), then it makes sense to have three 4377 layers of the COSE_Encrypt structure. 4379 These layers would be: 4381 o Layer 0: The content encryption layer. This layer contains the 4382 payload of the message. 4384 o Layer 1: The encryption of the CEK by a KEK. 4386 o Layer 2: The encryption of a long random secret using an RSA key 4387 and a key derivation function to convert that secret into the KEK. 4389 This is an example of what a triple layer message would look like. 4390 The message has the following layers: 4392 o Layer 0: Has a content encrypted with AES-GCM using a 128-bit key. 4394 o Layer 1: Uses the AES Key wrap algorithm with a 128-bit key. 4396 o Layer 2: Uses ECDH Ephemeral-Static direct to generate the layer 1 4397 key. 4399 In effect, this example is a decomposed version of using the ECDH- 4400 ES+A128KW algorithm. 4402 Size of binary file is 184 bytes 4403 992( 4404 [ 4405 / protected / h'a10101' / { 4406 \ alg \ 1:1 \ AES-GCM 128 \ 4407 } / , 4408 / unprotected / { 4409 / iv / 5:h'02d1f7e6f26c43d4868d87ce' 4410 }, 4411 / ciphertext / h'64f84d913ba60a76070a9a48f26e97e863e2852948658f0 4412 811139868826e89218a75715b', 4413 / recipients / [ 4414 [ 4415 / protected / h'', 4416 / unprotected / { 4417 / alg / 1:-3 / A128KW / 4418 }, 4419 / ciphertext / h'dbd43c4e9d719c27c6275c67d628d493f090593db82 4420 18f11', 4421 / recipients / [ 4422 [ 4423 / protected / h'a1013818' / { 4424 \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ 4425 } / , 4426 / unprotected / { 4427 / ephemeral / -1:{ 4428 / kty / 1:2, 4429 / crv / -1:1, 4430 / x / -2:h'b2add44368ea6d641f9ca9af308b4079aeb519f11 4431 e9b8a55a600b21233e86e68', 4432 / y / -3:false 4433 }, 4434 / kid / 4:'meriadoc.brandybuck@buckland.example' 4435 }, 4436 / ciphertext / h'' 4437 ] 4438 ] 4439 ] 4440 ] 4441 ] 4442 ) 4444 Appendix C. Examples 4446 This appendix includes a set of examples that show the different 4447 features and message types that have been defined in this document. 4448 To make the examples easier to read, they are presented using the 4449 extended CBOR diagnostic notation (defined in 4450 [I-D.greevenbosch-appsawg-cbor-cddl]) rather than as a binary dump. 4452 A GitHub project has been created at https://github.com/cose-wg/ 4453 Examples that contains not only the examples presented in this 4454 document, but a more complete set of testing examples as well. Each 4455 example is found in a JSON file that contains the inputs used to 4456 create the example, some of the intermediate values that can be used 4457 in debugging the example and the output of the example presented in 4458 both a hex and a CBOR diagnostic notation format. Some of the 4459 examples at the site are designed failure testing cases; these are 4460 clearly marked as such in the JSON file. If errors in the examples 4461 in this document are found, the examples on github will be updated 4462 and a note to that effect will be placed in the JSON file. 4464 As noted, the examples are presented using the CBOR's diagnostic 4465 notation. A Ruby based tool exists that can convert between the 4466 diagnostic notation and binary. This tool can be installed with the 4467 command line: 4469 gem install cbor-diag 4471 The diagnostic notation can be converted into binary files using the 4472 following command line: 4474 diag2cbor.rb < inputfile > outputfile 4476 The examples can be extracted from the XML version of this document 4477 via an XPath expression as all of the artwork is tagged with the 4478 attribute type='CBORdiag'. (Depending on the XPath evaluator one is 4479 using, it may be necessary to deal with > as an entity.) 4481 //artwork[@type='CDDL']/text() 4483 C.1. Examples of Signed Message 4485 C.1.1. Single Signature 4487 This example uses the following: 4489 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4491 Size of binary file is 104 bytes 4492 991( 4493 [ 4494 / protected / h'', 4495 / unprotected / {}, 4496 / payload / 'This is the content.', 4497 / signatures / [ 4498 [ 4499 / protected / h'a10126' / { 4500 \ alg \ 1:-7 \ ECDSA 256 \ 4501 } / , 4502 / unprotected / { 4503 / kid / 4:'11' 4504 }, 4505 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5 4506 51ce5705b793914348e14eea4aee6e0c9f09db4ef3ddeca8f3506cd1a98a8fb64327 4507 be470355c9657ce0' 4508 ] 4509 ] 4510 ] 4511 ) 4513 C.1.2. Multiple Signers 4515 This example uses the following: 4517 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4519 o Signature Algorithm: ECDSA w/ SHA-512, Curve P-521 4521 Size of binary file is 278 bytes 4522 991( 4523 [ 4524 / protected / h'', 4525 / unprotected / {}, 4526 / payload / 'This is the content.', 4527 / signatures / [ 4528 [ 4529 / protected / h'a10126' / { 4530 \ alg \ 1:-7 \ ECDSA 256 \ 4531 } / , 4532 / unprotected / { 4533 / kid / 4:'11' 4534 }, 4535 / signature / h'0dc1c5e62719d8f3cce1468b7c881eee6a8088b46bf8 4536 36ae956dd38fe93199199951a6a5e02a24aed5edde3509748366b1c539aaef7dea34 4537 f2cd618fe19fe55d' 4538 ], 4539 [ 4540 / protected / h'a1013823' / { 4541 \ alg \ 1:-36 4542 } / , 4543 / unprotected / { 4544 / kid / 4:'bilbo.baggins@hobbiton.example' 4545 }, 4546 / signature / h'012ce5b1dfe8b5aa6eaa09a54c58a84ad0900e4fdf27 4547 59ec22d1c861cccd75c7e1c4025a2da35e512fc2874d6ac8fd862d09ad07ed2deac2 4548 97b897561e04a8d42476017c11a4a34e26c570c9eff22c1dc84d56cdf6e03ed34bc9 4549 e934c5fdf676c7948d79e97dfe161730217c57748aadb364a0207cee811e9dde65ae 4550 37942e8a8348cc91' 4551 ] 4552 ] 4553 ] 4554 ) 4556 C.1.3. Counter Signature 4558 This example uses the following: 4560 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4562 o The same parameters are used for both the signature and the 4563 counter signature. 4565 Size of binary file is 181 bytes 4566 991( 4567 [ 4568 / protected / h'', 4569 / unprotected / { 4570 / countersign / 7:[ 4571 / protected / h'a10126' / { 4572 \ alg \ 1:-7 \ ECDSA 256 \ 4573 } / , 4574 / unprotected / { 4575 / kid / 4:'11' 4576 }, 4577 / signature / h'c9d3402485aa585cee3efc69b14496c0b00714584b26 4578 0f8e05764b7dbc70ae2b23b89812f5895b805f07a792f7ce77ef6d63875dc37d6a78 4579 ef4d175da45c9a51' 4580 ] 4581 }, 4582 / payload / 'This is the content.', 4583 / signatures / [ 4584 [ 4585 / protected / h'a10126' / { 4586 \ alg \ 1:-7 \ ECDSA 256 \ 4587 } / , 4588 / unprotected / { 4589 / kid / 4:'11' 4590 }, 4591 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5 4592 51ce5705b793914348e14eea4aee6e0c9f09db4ef3ddeca8f3506cd1a98a8fb64327 4593 be470355c9657ce0' 4594 ] 4595 ] 4596 ] 4597 ) 4599 C.1.4. Signature w/ Criticality 4601 This example uses the following: 4603 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4605 o There is a criticality marker on the "reserved" header parameter 4607 Size of binary file is 126 bytes 4608 991( 4609 [ 4610 / protected / h'a2687265736572766564f40281687265736572766564' / 4611 { 4612 "reserved":false, 4613 \ crit \ 2:[ 4614 "reserved" 4615 ] 4616 } / , 4617 / unprotected / {}, 4618 / payload / 'This is the content.', 4619 / signatures / [ 4620 [ 4621 / protected / h'a10126' / { 4622 \ alg \ 1:-7 \ ECDSA 256 \ 4623 } / , 4624 / unprotected / { 4625 / kid / 4:'11' 4626 }, 4627 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5 4628 51ce5705b793914348e1ff259ead2c38d8a7d8a9c87c2ce534d762dab059773115a6 4629 176fa780e85b6b25' 4630 ] 4631 ] 4632 ] 4633 ) 4635 C.2. Single Signer Examples 4637 C.2.1. Single ECDSA signature 4639 This example uses the following: 4641 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 4643 Size of binary file is 100 bytes 4644 997( 4645 [ 4646 / protected / h'a10126' / { 4647 \ alg \ 1:-7 \ ECDSA 256 \ 4648 } / , 4649 / unprotected / { 4650 / kid / 4:'11' 4651 }, 4652 / payload / 'This is the content.', 4653 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a551ce 4654 5705b793914348e19f43d6c6ba654472da301b645b293c9ba939295b97c4bdb84778 4655 2bff384c5794' 4656 ] 4657 ) 4659 C.3. Examples of Enveloped Messages 4661 C.3.1. Direct ECDH 4663 This example uses the following: 4665 o CEK: AES-GCM w/ 128-bit key 4667 o Recipient class: ECDH Ephemeral-Static, Curve P-256 4669 Size of binary file is 152 bytes 4670 992( 4671 [ 4672 / protected / h'a10101' / { 4673 \ alg \ 1:1 \ AES-GCM 128 \ 4674 } / , 4675 / unprotected / { 4676 / iv / 5:h'c9cf4df2fe6c632bf7886413' 4677 }, 4678 / ciphertext / h'7adbe2709ca818fb415f1e5df66f4e1a51053ba6d65a1a0 4679 c52a357da7a644b8070a151b0', 4680 / recipients / [ 4681 [ 4682 / protected / h'a1013818' / { 4683 \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ 4684 } / , 4685 / unprotected / { 4686 / ephemeral / -1:{ 4687 / kty / 1:2, 4688 / crv / -1:1, 4689 / x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf 4690 bf054e1c7b4d91d6280', 4691 / y / -3:true 4692 }, 4693 / kid / 4:'meriadoc.brandybuck@buckland.example' 4694 }, 4695 / ciphertext / h'' 4696 ] 4697 ] 4698 ] 4699 ) 4701 C.3.2. Direct plus Key Derivation 4703 This example uses the following: 4705 o CEK: AES-CCM w/128-bit key, truncate the tag to 64 bits 4707 o Recipient class: Use HKDF on a shared secret with the following 4708 implicit fields as part of the context. 4710 * salt: "aabbccddeeffgghh" 4712 * APU identity: "lighting-client" 4714 * APV identity: "lighting-server" 4716 * Supplementary Public Other: "Encryption Example 02" 4718 Size of binary file is 92 bytes 4720 992( 4721 [ 4722 / protected / h'a1010a' / { 4723 \ alg \ 1:10 \ AES-CCM-16-64-128 \ 4724 } / , 4725 / unprotected / { 4726 / iv / 5:h'89f52f65a1c580933b5261a76c' 4727 }, 4728 / ciphertext / h'753548a19b1307084ca7b2056924ed95f2e3b17006dfe93 4729 1b687b847', 4730 / recipients / [ 4731 [ 4732 / protected / h'a10129' / { 4733 \ alg \ 1:-10 4734 } / , 4735 / unprotected / { 4736 / salt / -20:'aabbccddeeffgghh', 4737 / kid / 4:'our-secret' 4738 }, 4739 / ciphertext / h'' 4740 ] 4741 ] 4742 ] 4743 ) 4745 C.3.3. Counter Signature on Encrypted Content 4747 This example uses the following: 4749 o CEK: AES-GCM w/ 128-bit key 4751 o Recipient class: ECDH Ephemeral-Static, Curve P-256 4753 Size of binary file is 327 bytes 4754 992( 4755 [ 4756 / protected / h'a10101' / { 4757 \ alg \ 1:1 \ AES-GCM 128 \ 4758 } / , 4759 / unprotected / { 4760 / iv / 5:h'c9cf4df2fe6c632bf7886413', 4761 / countersign / 7:[ 4762 / protected / h'a1013823' / { 4763 \ alg \ 1:-36 4764 } / , 4765 / unprotected / { 4766 / kid / 4:'bilbo.baggins@hobbiton.example' 4767 }, 4768 / signature / h'00aa98cbfd382610a375d046a275f30266e8d0faacb9 4769 069fde06e37825ae7825419c474f416ded0c8e3e7b55bff68f2a704135bdf99186f6 4770 6659461c8cf929cc7fb300f5e2b33c3b433655042ff719804ff73b0be3e988ecebc0 4771 c70ef6616996809c6eb59a918dbe0a5edb0d15137ece0aba2a0b0f68ad2631cb62f2 4772 ea4d7099804218b0' 4773 ] 4774 }, 4775 / ciphertext / h'7adbe2709ca818fb415f1e5df66f4e1a51053ba6d65a1a0 4776 c52a357da7a644b8070a151b0', 4777 / recipients / [ 4778 [ 4779 / protected / h'a1013818' / { 4780 \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ 4781 } / , 4782 / unprotected / { 4783 / ephemeral / -1:{ 4784 / kty / 1:2, 4785 / crv / -1:1, 4786 / x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf 4787 bf054e1c7b4d91d6280', 4788 / y / -3:true 4789 }, 4790 / kid / 4:'meriadoc.brandybuck@buckland.example' 4791 }, 4792 / ciphertext / h'' 4793 ] 4794 ] 4795 ] 4796 ) 4798 C.3.4. Encrypted Content with External Data 4800 This example uses the following: 4802 o CEK: AES-GCM w/ 128-bit key 4804 o Recipient class: ECDH static-Static, Curve P-256 with AES Key Wrap 4806 o Externally Supplied AAD: h'0011bbcc22dd44ee55ff660077' 4808 Size of binary file is 174 bytes 4810 992( 4811 [ 4812 / protected / h'a10101' / { 4813 \ alg \ 1:1 \ AES-GCM 128 \ 4814 } / , 4815 / unprotected / { 4816 / iv / 5:h'02d1f7e6f26c43d4868d87ce' 4817 }, 4818 / ciphertext / h'64f84d913ba60a76070a9a48f26e97e863e28529d8f5335 4819 e5f0165eee976b4a5f6c6f09d', 4820 / recipients / [ 4821 [ 4822 / protected / h'a101381f' / { 4823 \ alg \ 1:-32 \ ECHD-SS+A128KW \ 4824 } / , 4825 / unprotected / { 4826 / static kid / -3:'peregrin.took@tuckborough.example', 4827 / kid / 4:'meriadoc.brandybuck@buckland.example', 4828 / U nonce / -22:h'0101' 4829 }, 4830 / ciphertext / h'41e0d76f579dbd0d936a662d54d8582037de2e366fd 4831 e1c62' 4832 ] 4833 ] 4834 ] 4835 ) 4837 C.4. Examples of Encrypted Messages 4839 C.4.1. Simple Encrypted Message 4841 This example uses the following: 4843 o CEK: AES-CCM w/ 128-bit key and a 64-bit tag 4845 Size of binary file is 54 bytes 4846 993( 4847 [ 4848 / protected / h'a1010a' / { 4849 \ alg \ 1:10 \ AES-CCM-16-64-128 \ 4850 } / , 4851 / unprotected / { 4852 / iv / 5:h'89f52f65a1c580933b5261a78c' 4853 }, 4854 / ciphertext / h'5974e1b99a3a4cc09a659aa2e9e7fff161d38ce7edd5617 4855 388e77baf' 4856 ] 4857 ) 4859 C.4.2. Encrypted Message w/ a Partial IV 4861 This example uses the following: 4863 o CEK: AES-CCM w/ 128-bit key and a 64-bit tag 4865 o Prefix for IV is 89F52F65A1C580933B52 4867 Size of binary file is 43 bytes 4869 993( 4870 [ 4871 / protected / h'a1010a' / { 4872 \ alg \ 1:10 \ AES-CCM-16-64-128 \ 4873 } / , 4874 / unprotected / { 4875 / partial iv / 6:h'61a7' 4876 }, 4877 / ciphertext / h'252a8911d465c125b6764739700f0141ed09192da5c69e5 4878 33abf852b' 4879 ] 4880 ) 4882 C.5. Examples of MACed messages 4884 C.5.1. Shared Secret Direct MAC 4886 This example uses the following: 4888 o MAC: AES-CMAC, 256-bit key, truncated to 64 bits 4890 o Recipient class: direct shared secret 4892 Size of binary file is 58 bytes 4893 994( 4894 [ 4895 / protected / h'a1010f' / { 4896 \ alg \ 1:15 \ AES-CBC-MAC-256//64 \ 4897 } / , 4898 / unprotected / {}, 4899 / payload / 'This is the content.', 4900 / tag / h'9e1226ba1f81b848', 4901 / recipients / [ 4902 [ 4903 / protected / h'', 4904 / unprotected / { 4905 / alg / 1:-6 / direct /, 4906 / kid / 4:'our-secret' 4907 }, 4908 / ciphertext / h'' 4909 ] 4910 ] 4911 ] 4912 ) 4914 C.5.2. ECDH Direct MAC 4916 This example uses the following: 4918 o MAC: HMAC w/SHA-256, 256-bit key 4920 o Recipient class: ECDH key agreement, two static keys, HKDF w/ 4921 context structure 4923 Size of binary file is 215 bytes 4924 994( 4925 [ 4926 / protected / h'a10105' / { 4927 \ alg \ 1:5 \ HMAC 256//256 \ 4928 } / , 4929 / unprotected / {}, 4930 / payload / 'This is the content.', 4931 / tag / h'81a03448acd3d305376eaa11fb3fe416a955be2cbe7ec96f012c99 4932 4bc3f16a41', 4933 / recipients / [ 4934 [ 4935 / protected / h'a101381a' / { 4936 \ alg \ 1:-27 \ ECDH-SS + HKDF-256 \ 4937 } / , 4938 / unprotected / { 4939 / static kid / -3:'peregrin.took@tuckborough.example', 4940 / kid / 4:'meriadoc.brandybuck@buckland.example', 4941 / U nonce / -22:h'4d8553e7e74f3c6a3a9dd3ef286a8195cbf8a23d 4942 19558ccfec7d34b824f42d92bd06bd2c7f0271f0214e141fb779ae2856abf585a583 4943 68b017e7f2a9e5ce4db5' 4944 }, 4945 / ciphertext / h'' 4946 ] 4947 ] 4948 ] 4949 ) 4951 C.5.3. Wrapped MAC 4953 This example uses the following: 4955 o MAC: AES-MAC, 128-bit key, truncated to 64 bits 4957 o Recipient class: AES keywrap w/ a pre-shared 256-bit key 4959 Size of binary file is 110 bytes 4960 994( 4961 [ 4962 / protected / h'a1010e' / { 4963 \ alg \ 1:14 \ AES-CBC-MAC-128//64 \ 4964 } / , 4965 / unprotected / {}, 4966 / payload / 'This is the content.', 4967 / tag / h'36f5afaf0bab5d43', 4968 / recipients / [ 4969 [ 4970 / protected / h'', 4971 / unprotected / { 4972 / alg / 1:-5 / A256KW /, 4973 / kid / 4:'018c0ae5-4d9b-471b-bfd6-eef314bc7037' 4974 }, 4975 / ciphertext / h'711ab0dc2fc4585dce27effa6781c8093eba906f227 4976 b6eb0' 4977 ] 4978 ] 4979 ] 4980 ) 4982 C.5.4. Multi-recipient MACed message 4984 This example uses the following: 4986 o MAC: HMAC w/ SHA-256, 128-bit key 4988 o Recipient class: Uses three different methods 4990 1. ECDH Ephemeral-Static, Curve P-521, AES-Key Wrap w/ 128-bit 4991 key 4993 2. AES-Key Wrap w/ 256-bit key 4995 Size of binary file is 310 bytes 4996 994( 4997 [ 4998 / protected / h'a10105' / { 4999 \ alg \ 1:5 \ HMAC 256//256 \ 5000 } / , 5001 / unprotected / {}, 5002 / payload / 'This is the content.', 5003 / tag / h'bf48235e809b5c42e995f2b7d5fa13620e7ed834e337f6aa43df16 5004 1e49e9323e', 5005 / recipients / [ 5006 [ 5007 / protected / h'a101381c' / { 5008 \ alg \ 1:-29 \ ECHD-ES+A128KW \ 5009 } / , 5010 / unprotected / { 5011 / ephemeral / -1:{ 5012 / kty / 1:2, 5013 / crv / -1:3, 5014 / x / -2:h'0043b12669acac3fd27898ffba0bcd2e6c366d53bc4db 5015 71f909a759304acfb5e18cdc7ba0b13ff8c7636271a6924b1ac63c02688075b55ef2 5016 d613574e7dc242f79c3', 5017 / y / -3:true 5018 }, 5019 / kid / 4:'bilbo.baggins@hobbiton.example' 5020 }, 5021 / ciphertext / h'339bc4f79984cdc6b3e6ce5f315a4c7d2b0ac466fce 5022 a69e8c07dfbca5bb1f661bc5f8e0df9e3eff5' 5023 ], 5024 [ 5025 / protected / h'', 5026 / unprotected / { 5027 / alg / 1:-5 / A256KW /, 5028 / kid / 4:'018c0ae5-4d9b-471b-bfd6-eef314bc7037' 5029 }, 5030 / ciphertext / h'0b2c7cfce04e98276342d6476a7723c090dfdd15f9a 5031 518e7736549e998370695e6d6a83b4ae507bb' 5032 ] 5033 ] 5034 ] 5035 ) 5037 C.6. Examples of MAC0 messages 5039 C.6.1. Shared Secret Direct MAC 5041 This example uses the following: 5043 o MAC: AES-CMAC, 256-bit key, truncated to 64 bits 5044 o Recipient class: direct shared secret 5046 Size of binary file is 39 bytes 5048 996( 5049 [ 5050 / protected / h'a1010f' / { 5051 \ alg \ 1:15 \ AES-CBC-MAC-256//64 \ 5052 } / , 5053 / unprotected / {}, 5054 / payload / 'This is the content.', 5055 / tag / h'726043745027214f' 5056 ] 5057 ) 5059 Note that this example uses the same inputs as Appendix C.5.1. 5061 C.7. COSE Keys 5063 C.7.1. Public Keys 5065 This is an example of a COSE Key set. This example includes the 5066 public keys for all of the previous examples. 5068 In order the keys are: 5070 o An EC key with a kid of "meriadoc.brandybuck@buckland.example" 5072 o An EC key with a kid of "peregrin.took@tuckborough.example" 5074 o An EC key with a kid of "bilbo.baggins@hobbiton.example" 5076 o An EC key with a kid of "11" 5078 Size of binary file is 481 bytes 5080 [ 5081 { 5082 -1:1, 5083 -2:h'65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c0 5084 8551d', 5085 -3:h'1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd008 5086 4d19c', 5087 1:2, 5088 2:'meriadoc.brandybuck@buckland.example' 5089 }, 5090 { 5091 -1:1, 5092 -2:h'bac5b11cad8f99f9c72b05cf4b9e26d244dc189f745228255a219a86d6a 5093 09eff', 5094 -3:h'20138bf82dc1b6d562be0fa54ab7804a3a64b6d72ccfed6b6fb6ed28bbf 5095 c117e', 5096 1:2, 5097 2:'11' 5098 }, 5099 { 5100 -1:3, 5101 -2:h'0072992cb3ac08ecf3e5c63dedec0d51a8c1f79ef2f82f94f3c737bf5de 5102 7986671eac625fe8257bbd0394644caaa3aaf8f27a4585fbbcad0f2457620085e5c8 5103 f42ad', 5104 -3:h'01dca6947bce88bc5790485ac97427342bc35f887d86d65a089377e247e 5105 60baa55e4e8501e2ada5724ac51d6909008033ebc10ac999b9d7f5cc2519f3fe1ea1 5106 d9475', 5107 1:2, 5108 2:'bilbo.baggins@hobbiton.example' 5109 }, 5110 { 5111 -1:1, 5112 -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbfbf054e1c7b4d91 5113 d6280', 5114 -3:h'f01400b089867804b8e9fc96c3932161f1934f4223069170d924b7e03bf 5115 822bb', 5116 1:2, 5117 2:'peregrin.took@tuckborough.example' 5118 } 5119 ] 5121 C.7.2. Private Keys 5123 This is an example of a COSE Key set. This example includes the 5124 private keys for all of the previous examples. 5126 In order the keys are: 5128 o An EC key with a kid of "meriadoc.brandybuck@buckland.example" 5130 o A shared-secret key with a kid of "our-secret" 5132 o An EC key with a kid of "peregrin.took@tuckborough.example" 5134 o A shared-secret key with a kid of "018c0ae5-4d9b-471b- 5135 bfd6-eef314bc7037" 5137 o An EC key with a kid of "bilbo.baggins@hobbiton.example" 5139 o An EC key with a kid of "11" 5141 Size of binary file is 816 bytes 5143 [ 5144 { 5145 1:2, 5146 2:'meriadoc.brandybuck@buckland.example', 5147 -1:1, 5148 -2:h'65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c0 5149 8551d', 5150 -3:h'1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd008 5151 4d19c', 5152 -4:h'aff907c99f9ad3aae6c4cdf21122bce2bd68b5283e6907154ad911840fa 5153 208cf' 5154 }, 5155 { 5156 1:2, 5157 2:'11', 5158 -1:1, 5159 -2:h'bac5b11cad8f99f9c72b05cf4b9e26d244dc189f745228255a219a86d6a 5160 09eff', 5161 -3:h'20138bf82dc1b6d562be0fa54ab7804a3a64b6d72ccfed6b6fb6ed28bbf 5162 c117e', 5163 -4:h'57c92077664146e876760c9520d054aa93c3afb04e306705db609030850 5164 7b4d3' 5165 }, 5166 { 5167 1:2, 5168 2:'bilbo.baggins@hobbiton.example', 5169 -1:3, 5170 -2:h'0072992cb3ac08ecf3e5c63dedec0d51a8c1f79ef2f82f94f3c737bf5de 5171 7986671eac625fe8257bbd0394644caaa3aaf8f27a4585fbbcad0f2457620085e5c8 5172 f42ad', 5173 -3:h'01dca6947bce88bc5790485ac97427342bc35f887d86d65a089377e247e 5174 60baa55e4e8501e2ada5724ac51d6909008033ebc10ac999b9d7f5cc2519f3fe1ea1 5175 d9475', 5176 -4:h'00085138ddabf5ca975f5860f91a08e91d6d5f9a76ad4018766a476680b 5177 55cd339e8ab6c72b5facdb2a2a50ac25bd086647dd3e2e6e99e84ca2c3609fdf177f 5178 eb26d' 5179 }, 5180 { 5181 1:4, 5182 2:'our-secret', 5183 -1:h'849b57219dae48de646d07dbb533566e976686457c1491be3a76dcea6c4 5184 27188' 5185 }, 5186 { 5187 1:2, 5188 -1:1, 5189 2:'peregrin.took@tuckborough.example', 5190 -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbfbf054e1c7b4d91 5191 d6280', 5192 -3:h'f01400b089867804b8e9fc96c3932161f1934f4223069170d924b7e03bf 5193 822bb', 5194 -4:h'02d1f7e6f26c43d4868d87ceb2353161740aacf1f7163647984b522a848 5195 df1c3' 5196 }, 5197 { 5198 1:4, 5199 2:'our-secret2', 5200 -1:h'849b5786457c1491be3a76dcea6c4271' 5201 }, 5202 { 5203 1:4, 5204 2:'018c0ae5-4d9b-471b-bfd6-eef314bc7037', 5205 -1:h'849b57219dae48de646d07dbb533566e976686457c1491be3a76dcea6c4 5206 27188' 5207 } 5208 ] 5210 Acknowledgments 5212 This document is a product of the COSE working group of the IETF. 5214 The following individuals are to blame for getting me started on this 5215 project in the first place: Richard Barnes, Matt Miller, and Martin 5216 Thomson. 5218 The initial version of the draft was based to some degree on the 5219 outputs of the JOSE and S/MIME working groups. 5221 The following individuals provided input into the final form of the 5222 document: Carsten Bormann, John Bradley, Brain Campbell, Michael B. 5224 Jones, Ilari Liusvaara, Francesca Palombini, Goran Selander, and 5225 Ludwig Seitz. 5227 Author's Address 5229 Jim Schaad 5230 August Cellars 5232 Email: ietf@augustcellars.com