idnits 2.17.1 draft-ietf-cose-countersign-05.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- -- The draft header indicates that this document updates RFC8152, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 800 has weird spacing: '...otected h'a10...' -- The document date (23 June 2021) is 1037 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) ** Downref: Normative reference to an Informational draft: draft-ietf-cose-rfc8152bis-algs (ref. 'I-D.ietf-cose-rfc8152bis-algs') -- Obsolete informational reference (is this intentional?): RFC 8152 (Obsoleted by RFC 9052, RFC 9053) == Outdated reference: A later version (-21) exists of draft-ietf-core-oscore-groupcomm-11 Summary: 1 error (**), 0 flaws (~~), 3 warnings (==), 3 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 Updates: 8152 (if approved) R. Housley, Ed. 5 Intended status: Standards Track Vigil Security 6 Expires: 25 December 2021 23 June 2021 8 CBOR Object Signing and Encryption (COSE): Countersignatures 9 draft-ietf-cose-countersign-05 11 Abstract 13 Concise Binary Object Representation (CBOR) is a data format designed 14 for small code size and small message size. CBOR Object Signing and 15 Encryption (COSE) defines a set of security services for CBOR. This 16 document defines a countersignature algorithm along with the needed 17 header parameters and CBOR tags for COSE. 19 Contributing to this document 21 This note is to be removed before publishing as an RFC. 23 The source for this draft is being maintained in GitHub. Suggested 24 changes should be submitted as pull requests at https://github.com/ 25 cose-wg/countersign. 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 https://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 25 December 2021. 46 Copyright Notice 48 Copyright (c) 2021 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 (https://trustee.ietf.org/ 53 license-info) in effect on the date of publication of this document. 54 Please review these documents carefully, as they describe your rights 55 and restrictions with respect to this document. Code Components 56 extracted from this document must include Simplified BSD License text 57 as described in Section 4.e of the Trust Legal Provisions and are 58 provided without warranty as described in the Simplified BSD License. 60 Table of Contents 62 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 63 1.1. Requirements Terminology . . . . . . . . . . . . . . . . 4 64 1.2. CBOR Grammar . . . . . . . . . . . . . . . . . . . . . . 4 65 1.3. Document Terminology . . . . . . . . . . . . . . . . . . 4 66 2. Countersignature Header Parameters . . . . . . . . . . . . . 5 67 3. Version 2 Countersignatures . . . . . . . . . . . . . . . . . 6 68 3.1. Full Countersignatures . . . . . . . . . . . . . . . . . 7 69 3.2. Abbreviated Countersignatures . . . . . . . . . . . . . . 8 70 3.3. Signing and Verification Process . . . . . . . . . . . . 8 71 4. CBOR Encoding Restrictions . . . . . . . . . . . . . . . . . 10 72 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 10 73 5.1. CBOR Tag Assignment . . . . . . . . . . . . . . . . . . . 10 74 5.2. COSE Header Parameters Registry . . . . . . . . . . . . . 11 75 6. Security Considerations . . . . . . . . . . . . . . . . . . . 11 76 7. Implementation Status . . . . . . . . . . . . . . . . . . . . 13 77 7.1. Author's Versions . . . . . . . . . . . . . . . . . . . . 14 78 7.2. COSE Testing Library . . . . . . . . . . . . . . . . . . 14 79 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 15 80 8.1. Normative References . . . . . . . . . . . . . . . . . . 15 81 8.2. Informative References . . . . . . . . . . . . . . . . . 15 82 Appendix A. Examples . . . . . . . . . . . . . . . . . . . . . . 16 83 A.1. Use of Early Code Points . . . . . . . . . . . . . . . . 17 84 A.2. Examples of Signed Messages . . . . . . . . . . . . . . . 17 85 A.2.1. Countersignature . . . . . . . . . . . . . . . . . . 17 86 A.3. Examples of Signed1 Messages . . . . . . . . . . . . . . 18 87 A.3.1. Countersignature . . . . . . . . . . . . . . . . . . 18 88 A.4. Examples of Enveloped Messages . . . . . . . . . . . . . 19 89 A.4.1. Countersignature on Encrypted Content . . . . . . . . 19 90 A.5. Examples of Encrypted Messages . . . . . . . . . . . . . 20 91 A.5.1. Countersignature on Encrypted Content . . . . . . . . 21 92 A.6. Examples of MACed Messages . . . . . . . . . . . . . . . 21 93 A.6.1. Countersignature on MAC Content . . . . . . . . . . . 21 95 A.7. Examples of MAC0 Messages . . . . . . . . . . . . . . . . 22 96 A.7.1. Countersignature on MAC0 Content . . . . . . . . . . 22 97 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 23 98 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 23 100 1. Introduction 102 There has been an increased focus on small, constrained devices that 103 make up the Internet of Things (IoT). One of the standards that has 104 come out of this process is "Concise Binary Object Representation 105 (CBOR)" [RFC8949]. CBOR extended the data model of the JavaScript 106 Object Notation (JSON) [STD90] by allowing for binary data, among 107 other changes. CBOR has been adopted by several of the IETF working 108 groups dealing with the IoT world as their encoding of data 109 structures. CBOR was designed specifically both to be small in terms 110 of messages transported and implementation size and to be a schema- 111 free decoder. A need exists to provide message security services for 112 IoT, and using CBOR as the message-encoding format makes sense. 114 During the process of advancing COSE to an Internet Standard, it was 115 noticed the description of the security properties of 116 countersignatures was incorrect for the COSE_Sign1 structure. Since 117 the security properties that were described, those of a true 118 countersignature, were those that the working group desired, the 119 decision was made to remove all of the countersignature text from 120 [I-D.ietf-cose-rfc8152bis-struct] and create a new document to both 121 deprecate the old countersignature algorithm and to define a new one 122 with the desired security properties. 124 The problem with the previous countersignature algorithm was that the 125 cryptographically computed value was not always included. The 126 initial assumption that the cryptographic value was in the third slot 127 of the array was known not to be true at the time, but in the case of 128 the MAC structures this was not deemed to be an issue. The new 129 algorithm is more aggressive about the set of values included in the 130 countersignature computation so that the cryptographic computed 131 values is included. The exception to this is the COSE_Signature 132 structure where there is no cryptographic computed value. 134 The new algorithm is designed to produce the same countersignature 135 value in those cases where the cryptographic computed value was 136 already included. This means that for those structures the only 137 thing that would need to be done is to change the value of the header 138 parameter. 140 1.1. Requirements Terminology 142 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 143 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 144 "OPTIONAL" in this document are to be interpreted as described in BCP 145 14 [RFC2119] [RFC8174] when, and only when, they appear in all 146 capitals, as shown here. 148 1.2. CBOR Grammar 150 CBOR grammar in the document is presented using CBOR Data Definition 151 Language (CDDL) [RFC8610]. 153 The collected CDDL can be extracted from the XML version of this 154 document via the following XPath expression below. (Depending on the 155 XPath evaluator one is using, it may be necessary to deal with > 156 as an entity.) 158 //sourcecode[@type='CDDL']/text() 160 CDDL expects the initial non-terminal symbol to be the first symbol 161 in the file. For this reason, the first fragment of CDDL is 162 presented here. 164 start = COSE_Countersignature_Tagged / Internal_Types 166 ; This is defined to make the tool quieter: 167 Internal_Types = Countersign_structure / COSE_Countersignature0 169 The non-terminal Internal_Types is defined for dealing with the 170 automated validation tools used during the writing of this document. 171 It references those non-terminals that are used for security 172 computations but are not emitted for transport. 174 1.3. Document Terminology 176 In this document, we use the following terminology: 178 Byte is a synonym for octet. 180 Constrained Application Protocol (CoAP) is a specialized web transfer 181 protocol for use in constrained systems. It is defined in [RFC7252]. 183 Context is used throughout the document to represent information that 184 is not part of the COSE message. Information which is part of the 185 context can come from several different sources including: Protocol 186 interactions, associated key structures, and program configuration. 187 The context to use can be implicit, identified using the 'kid 188 context' header parameter defined in [RFC8613], or identified by a 189 protocol-specific identifier. Context should generally be included 190 in the cryptographic construction; for more details see Section 4.3 191 of [I-D.ietf-cose-rfc8152bis-struct]. 193 The term 'byte string' is used for sequences of bytes, while the term 194 'text string' is used for sequences of characters. 196 2. Countersignature Header Parameters 198 This section defines a set of common header parameters. A summary of 199 these header parameters can be found in Table 1. This table should 200 be consulted to determine the value of label and the type of the 201 value. 203 The set of header parameters defined in this section are: 205 V2 countersignature: This header parameter holds one or more 206 countersignature values. Countersignatures provide a method of 207 having a second party sign some data. The countersignature header 208 parameter can occur as an unprotected attribute in any of the 209 following structures: COSE_Sign1, COSE_Signature, COSE_Encrypt, 210 COSE_recipient, COSE_Encrypt0, COSE_Mac, and COSE_Mac0. Details 211 on version 2 countersignatures are found in Section 3. 213 +===========+=====+========================+==========+=============+ 214 |Name |Label|Value Type | Value | Description | 215 | | | | Registry | | 216 +===========+=====+========================+==========+=============+ 217 |counter |TBD10|COSE_Countersignature / | | V2 counter | 218 |signature | |[+ COSE_Countersignature| | signature | 219 |version 2 | |] | | attribute | 220 +-----------+-----+------------------------+----------+-------------+ 221 |counter |TBD11|COSE_Countersignature0 | | Abbreviated | 222 |signature 0| | | | Counter | 223 |version 2 | | | | signature | 224 | | | | | vesion 2 | 225 +-----------+-----+------------------------+----------+-------------+ 227 Table 1: Common Header Parameters 229 The CDDL fragment that represents the set of header parameters 230 defined in this section is given below. Each of the header 231 parameters is tagged as optional because they do not need to be in 232 every map; header parameters required in specific maps are discussed 233 above. 235 Generic_Headers /= ( 236 ? TBD10 => COSE_Countersignature / [+COSE_Countersignature] 237 ; V2 Countersignature 238 ? TBD11 => COSE_Countersignature0 ; V2 Countersignature0 239 ) 241 3. Version 2 Countersignatures 243 A countersignature is normally defined as a second signature that 244 confirms a primary signature. A normal example of a countersignature 245 is the signature that a notary public places on a document as 246 witnessing that you have signed the document. Thus applying a 247 countersignature to either the COSE_Signature or COSE_Sign1 objects 248 match this traditional definition. This document extends the context 249 of a countersignature to allow it to be applied to all of the 250 security structures defined. It needs to be noted that the 251 countersignature needs to be treated as a separate operation from the 252 initial operation even if it is applied by the same user as is done 253 in [I-D.ietf-core-oscore-groupcomm]. 255 COSE supports two different forms for countersignatures. Full 256 countersignatures use the structure COSE_Countersignature. This is 257 same structure as COSE_Signature and thus it can have protected and 258 unprotected attributes, including chained countersignatures. 259 Abbreviated countersignatures use the structure 260 COSE_Countersignature0. This structure only contains the signature 261 value and nothing else. The structures cannot be converted between 262 each other; as the signature computation includes a parameter 263 identifying which structure is being used, the converted structure 264 will fail signature validation. 266 The version 2 countersignature changes the algorithm used for 267 computing the signature from the original version Section 4.5 of 268 [RFC8152]. The new version now includes the cryptographic material 269 generated for all of the structures rather than just for a subset. 271 COSE was designed for uniformity in how the data structures are 272 specified. One result of this is that for COSE one can expand the 273 concept of countersignatures beyond just the idea of signing a 274 signature to being able to sign most of the structures without having 275 to create a new signing layer. When creating a countersignature, one 276 needs to be clear about the security properties that result. When 277 done on a COSE_Signature or COSE_Sign1, the normal countersignature 278 semantics are preserved. That is the countersignature makes a 279 statement about the existence of a signature and, when used as a 280 timestamp, a time point at which the signature exists. When done on 281 a COSE_Sign, this is the same as applying a second signature to the 282 payload and adding a parallel signature as a new COSE_Signature is 283 the preferred method. When done on a COSE_Mac or COSE_Mac0, the 284 payload is included as well as the MAC value. When done on a 285 COSE_Encrypt or COSE_Encrypt0, the existence of the encrypted data is 286 attested to. It should be noted that there is a big difference 287 between attesting to the encrypted data as opposed to attesting to 288 the plaintext data. Usually, the signer wishes to countersign the 289 plaintext data, and then encrypt the data along with the 290 countersignature. This approach prevents an attacker from stripping 291 countersignatures. In addition, this approach prevents an observer 292 from linking the public keys needed to verify the countersignatures 293 across different payloads. It is always possible to construct cases 294 where the use of two different keys will appear to result in a 295 successful decryption (the tag check success), but which produce two 296 completely different plaintexts. This situation is not detectable by 297 a countersignature on the encrypted data. 299 3.1. Full Countersignatures 301 The COSE_Countersignature structure allows for the same set of 302 capabilities as a COSE_Signature. This means that all of the 303 capabilities of a signature are duplicated with this structure. 304 Specifically, the countersigner does not need to be related to the 305 producer of what is being countersigned as key and algorithm 306 identification can be placed in the countersignature attributes. 307 This also means that the countersignature can itself be 308 countersigned. This is a feature required by protocols such as long- 309 term archiving services. More information on how countersignatures 310 is used can be found in the evidence record syntax described in 311 [RFC4998]. 313 The full countersignature structure can be encoded as either tagged 314 or untagged depending on the context it is used in. A tagged 315 COSE_Countersignature structure is identified by the CBOR tag TBD0. 316 The countersignature structure is the same as that used for a signer 317 on a signed object. The CDDL fragment for full countersignatures is: 319 COSE_Countersignature_Tagged = #6.9999(COSE_Countersignature) 320 COSE_Countersignature = COSE_Signature 322 The details of the fields of a countersignature can be found in 323 Section 4.1 of [I-D.ietf-cose-rfc8152bis-struct]. 325 An example of a countersignature on a signature can be found in 326 Appendix A.2.1. An example of a countersignature in an encryption 327 object can be found in Appendix A.4.1. 329 It should be noted that only a signature algorithm with appendix (see 330 Section 8 of [I-D.ietf-cose-rfc8152bis-struct]) can be used for 331 countersignatures. This is because the body should be able to be 332 processed without having to evaluate the countersignature, and this 333 is not possible for signature schemes with message recovery. 335 3.2. Abbreviated Countersignatures 337 Abbreviated countersignatures were designed primarily to deal with 338 the problem of encrypted group messaging, but where it is required to 339 know who originated the message. The objective was to keep the 340 countersignature as small as possible while still providing the 341 needed security. For abbreviated countersignatures, there is no 342 provision for any protected attributes related to the signing 343 operation. Instead, the parameters for computing or verifying the 344 abbreviated countersignature are provided by the same context used to 345 describe the encryption, signature, or MAC processing. 347 The CDDL fragment for the abbreviated countersignatures is: 349 COSE_Countersignature0 = bstr 351 The byte string representing the signature value is placed in the 352 Countersignature0 attribute. This attribute is then encoded as an 353 unprotected header parameter. The attribute is defined below. 355 3.3. Signing and Verification Process 357 In order to create a signature, a well-defined byte string is needed. 358 The Countersign_structure is used to create the canonical form. This 359 signing and verification process takes in countersignature target 360 structure, the signer information (COSE_Signature), and the 361 application data (external source). A Countersign_structure is a 362 CBOR array. The target structure of the countersignature needs to 363 have all of it's cryptographic functions finalized before the 364 computing the signature. The fields of the Countersign_structure in 365 order are: 367 1. A context text string identifying the context of the signature. 368 The context text string is: 370 "CounterSignature" for signatures using the 371 COSE_Countersignature structure when other_fields is absent. 373 "CounterSignature0" for signatures using the 374 COSE_Countersignature0 structure when other_fields is absent. 376 "CounterSignatureV2" for signatures using the 377 COSE_Countersignature structure when other_fields is present. 379 "CounterSignature0V2" for signatures using the 380 COSE_Countersignature0 structure when other_fields is present. 382 2. The protected attributes from the target structure encoded in a 383 bstr type. If there are no protected attributes, a zero-length 384 byte string is used. 386 3. The protected attributes from the signer structure encoded in a 387 bstr type. If there are no protected attributes, a zero-length 388 byte string is used. This field is omitted for the 389 Countersignature0V2 attribute. 391 4. The externally supplied data from the application encoded in a 392 bstr type. If this field is not supplied, it defaults to a zero- 393 length byte string. (See Section 4.3 of 394 [I-D.ietf-cose-rfc8152bis-struct] for application guidance on 395 constructing this field.) 397 5. The payload to be signed encoded in a bstr type. The payload is 398 placed here independent of how it is transported. 400 6. If there are only two bstr fields in the target structure, this 401 field is omitted. The field is an array of all bstr fields after 402 the second. As an example, this would be an array of one element 403 for the COSE_Sign1 structure containing the signature value. 405 The CDDL fragment that describes the above text is: 407 Countersign_structure = [ 408 context : "CounterSignature" / "CounterSignature0" / 409 "CounterSignatureV2" / "CounterSignature0V2" /, 410 body_protected : empty_or_serialized_map, 411 ? sign_protected : empty_or_serialized_map, 412 external_aad : bstr, 413 payload : bstr, 414 ? other_fields : [ + bstr ] 415 ] 417 How to compute a countersignature: 419 1. Create a Countersign_structure and populate it with the 420 appropriate fields. 422 2. Create the value ToBeSigned by encoding the Countersign_structure 423 to a byte string, using the encoding described in Section 4. 425 3. Call the signature creation algorithm passing in K (the key to 426 sign with), alg (the algorithm to sign with), and ToBeSigned (the 427 value to sign). 429 4. Place the resulting signature value in the correct location. 430 This is the 'signature' field of the COSE_Countersignature 431 structure. This is the value of the Countersignature0 attribute. 433 The steps for verifying a countersignature are: 435 1. Create a Countersign_structure and populate it with the 436 appropriate fields. 438 2. Create the value ToBeSigned by encoding the Countersign_structure 439 to a byte string, using the encoding described in Section 4. 441 3. Call the signature verification algorithm passing in K (the key 442 to verify with), alg (the algorithm used sign with), ToBeSigned 443 (the value to sign), and sig (the signature to be verified). 445 In addition to performing the signature verification, the application 446 performs the appropriate checks to ensure that the key is correctly 447 paired with the signing identity and that the signing identity is 448 authorized before performing actions. 450 4. CBOR Encoding Restrictions 452 In order to always regenerate the same byte string for the "to be 453 signed" value, the core deterministic encoding rules defined in 454 Section 4.2.1 of [RFC8949]. These rules match the ones laid out in 455 Section 9 of [I-D.ietf-cose-rfc8152bis-struct]. 457 5. IANA Considerations 459 The registries and registrations listed below were created during 460 processing of RFC 8152 [RFC8152]. The majority of the actions are to 461 update the references to point to this document. 463 5.1. CBOR Tag Assignment 465 IANA is requested to register a new tag for the CounterSignature 466 type. 468 * Tag: TBD0 470 * Data Item: COSE_Countersignature 472 * Semantics: COSE standalone V2 countersignature 473 * Reference: [[this document]] 475 5.2. COSE Header Parameters Registry 477 IANA created a registry titled "COSE Header Parameters" as part of 478 processing [RFC8152]. 480 IANA is requested to register the following new items in the 481 registry. For these entries, the Value Registry column will be blank 482 and the Reference column will be [[This Document]]. 484 +===================+=====+========================+================+ 485 | Name |Label|Value Type |Description | 486 +===================+=====+========================+================+ 487 | counter signature |TBD10|COSE_Countersignature / |V2 | 488 | version 2 | |[+ COSE_Countersignature|countersignature| 489 | | |] |attribute | 490 +-------------------+-----+------------------------+----------------+ 491 | Countersignature0 |TBD11|COSE_Countersignature0 |Abbreviated | 492 | version 2 | | |Counter | 493 | | | |signature vesion| 494 | | | |2 | 495 +-------------------+-----+------------------------+----------------+ 497 Table 2: New Common Header Parameters 499 IANA is requested to modify the Description field for "counter 500 signature" and "CounterSignature0" to include the words "(Deprecated 501 by [[This Document]]". 503 6. Security Considerations 505 There are a number of security considerations that need to be taken 506 into account by implementers of this specification. While some 507 considerations have been highlighted here, additional considerations 508 may be found in the documents listed in the references. 510 Implementations need to protect the private key material for any 511 individuals. There are some cases that need to be highlighted on 512 this issue. 514 * Using the same key for two different algorithms can leak 515 information about the key. It is therefore recommended that keys 516 be restricted to a single algorithm. 518 * Use of 'direct' as a recipient algorithm combined with a second 519 recipient algorithm exposes the direct key to the second 520 recipient. 522 * Several of the algorithms in [I-D.ietf-cose-rfc8152bis-algs] have 523 limits on the number of times that a key can be used without 524 leaking information about the key. 526 The use of ECDH and direct plus KDF (with no key wrap) will not 527 directly lead to the private key being leaked; the one way function 528 of the KDF will prevent that. There is, however, a different issue 529 that needs to be addressed. Having two recipients requires that the 530 CEK be shared between two recipients. The second recipient therefore 531 has a CEK that was derived from material that can be used for the 532 weak proof of origin. The second recipient could create a message 533 using the same CEK and send it to the first recipient; the first 534 recipient would, for either static-static ECDH or direct plus KDF, 535 make an assumption that the CEK could be used for proof of origin 536 even though it is from the wrong entity. If the key wrap step is 537 added, then no proof of origin is implied and this is not an issue. 539 Although it has been mentioned before, the use of a single key for 540 multiple algorithms has been demonstrated in some cases to leak 541 information about that key, provide the opportunity for attackers to 542 forge integrity tags, or gain information about encrypted content. 543 Binding a key to a single algorithm prevents these problems. 545 Key creators and key consumers are strongly encouraged not only to 546 create new keys for each different algorithm, but to include that 547 selection of algorithm in any distribution of key material and 548 strictly enforce the matching of algorithms in the key structure to 549 algorithms in the message structure. In addition to checking that 550 algorithms are correct, the key form needs to be checked as well. Do 551 not use an 'EC2' key where an 'OKP' key is expected. 553 Before using a key for transmission, or before acting on information 554 received, a trust decision on a key needs to be made. Is the data or 555 action something that the entity associated with the key has a right 556 to see or a right to request? A number of factors are associated 557 with this trust decision. Some of the ones that are highlighted here 558 are: 560 * What are the permissions associated with the key owner? 562 * Is the cryptographic algorithm acceptable in the current context? 564 * Have the restrictions associated with the key, such as algorithm 565 or freshness, been checked and are they correct? 567 * Is the request something that is reasonable, given the current 568 state of the application? 570 * Have any security considerations that are part of the message been 571 enforced (as specified by the application or 'crit' header 572 parameter)? 574 Analysis of the size of encrypted messages can provide information 575 about the plaintext messages. This specification does not provide a 576 uniform method for padding messages prior to encryption. An observer 577 can distinguish between two different messages (for example, 'YES' 578 and 'NO') based on the length for all of the content encryption 579 algorithms that are defined in [I-D.ietf-cose-rfc8152bis-algs]. This 580 means that it is up to the applications to specify how content 581 padding is to be done to prevent or discourage such analysis. (For 582 example, the text strings could be defined as 'YES' and 'NO '.) 584 When either COSE_Encrypt and COSE_Mac is used and more than two 585 parties share the key, data origin authentication is not provided. 586 Any party that knows the message-authentication key can compute a 587 valid authentication tag; therefore, the contents could originate 588 from any one of the parties that share the key. 590 Countersignatures of COSE_Encrypt and COSE_Mac with short 591 authentication tags do not provide the security properties associated 592 with the same algorithm used in COSE_Sign. To provide 128-bit 593 security against collision attacks, the tag length MUST be at least 594 256-bits. A countersignature of a COSE_Mac with AES-MAC 256/128 595 provides at most 64 bits of integrity protection. Similarly, a 596 countersignature of a COSE_Encrypt with AES-CCM-16-64-128 provides at 597 most 32 bits bits of integrity protection. 599 7. Implementation Status 601 This section is to be removed before publishing as an RFC. 603 This section records the status of known implementations of the 604 protocol defined by this specification at the time of posting of this 605 Internet-Draft, and is based on a proposal described in [RFC7942]. 606 The description of implementations in this section is intended to 607 assist the IETF in its decision processes in progressing drafts to 608 RFCs. Please note that the listing of any individual implementation 609 here does not imply endorsement by the IETF. Furthermore, no effort 610 has been spent to verify the information presented here that was 611 supplied by IETF contributors. This is not intended as, and must not 612 be construed to be, a catalog of available implementations or their 613 features. Readers are advised to note that other implementations may 614 exist. 616 According to [RFC7942], "this will allow reviewers and working groups 617 to assign due consideration to documents that have the benefit of 618 running code, which may serve as evidence of valuable experimentation 619 and feedback that have made the implemented protocols more mature. 620 It is up to the individual working groups to use this information as 621 they see fit". 623 7.1. Author's Versions 625 There are three different implementations that have been created by 626 the author of the document both to create the examples that are 627 included in the document and to validate the structures and 628 methodology used in the design of COSE. 630 * Implementation Location: https://github.com/cose-wg 632 * Primary Maintainer: Jim Schaad 634 * Languages: There are three different languages that are currently 635 supported: Java and C#. 637 * Cryptography: The Java and C# libraries use Bouncy Castle to 638 provide the required cryptography. 640 * Coverage: Both implementations can produce and consume both the 641 old and new countersignatures. 643 * Testing: All of the examples in the example library are generated 644 by the C# library and then validated using the Java and C 645 libraries. Both libraries have tests to allow for the creating of 646 the same messages that are in the example library followed by 647 validating them. These are not compared against the example 648 library. The Java and C# libraries have unit testing included. 649 Not all of the MUST statements in the document have been 650 implemented as part of the libraries. One such statement is the 651 requirement that unique labels be present. 653 * Licensing: Revised BSD License 655 7.2. COSE Testing Library 657 * Implementation Location: https://github.com/cose-wg/Examples 659 * Primary Maintainer: Jim Schaad 660 * Description: A set of tests for the COSE library is provided as 661 part of the implementation effort. Both success and fail tests 662 have been provided. All of the examples in this document are part 663 of this example set. 665 * Coverage: An attempt has been made to have test cases for every 666 message type and algorithm in the document. Currently examples 667 dealing with countersignatures, and ECDH with Curve25519 and 668 Goldilocks are missing. 670 * Licensing: Public Domain 672 8. References 674 8.1. Normative References 676 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 677 Requirement Levels", BCP 14, RFC 2119, 678 DOI 10.17487/RFC2119, March 1997, 679 . 681 [RFC8949] Bormann, C. and P. Hoffman, "Concise Binary Object 682 Representation (CBOR)", STD 94, RFC 8949, 683 DOI 10.17487/RFC8949, December 2020, 684 . 686 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 687 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 688 May 2017, . 690 [I-D.ietf-cose-rfc8152bis-algs] 691 Schaad, J., "CBOR Object Signing and Encryption (COSE): 692 Initial Algorithms", Work in Progress, Internet-Draft, 693 draft-ietf-cose-rfc8152bis-algs-12, 24 September 2020, 694 . 697 8.2. Informative References 699 [RFC8610] Birkholz, H., Vigano, C., and C. Bormann, "Concise Data 700 Definition Language (CDDL): A Notational Convention to 701 Express Concise Binary Object Representation (CBOR) and 702 JSON Data Structures", RFC 8610, DOI 10.17487/RFC8610, 703 June 2019, . 705 [RFC8152] Schaad, J., "CBOR Object Signing and Encryption (COSE)", 706 RFC 8152, DOI 10.17487/RFC8152, July 2017, 707 . 709 [STD90] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data 710 Interchange Format", STD 90, RFC 8259, December 2017. 712 714 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 715 Application Protocol (CoAP)", RFC 7252, 716 DOI 10.17487/RFC7252, June 2014, 717 . 719 [RFC7942] Sheffer, Y. and A. Farrel, "Improving Awareness of Running 720 Code: The Implementation Status Section", BCP 205, 721 RFC 7942, DOI 10.17487/RFC7942, July 2016, 722 . 724 [RFC4998] Gondrom, T., Brandner, R., and U. Pordesch, "Evidence 725 Record Syntax (ERS)", RFC 4998, DOI 10.17487/RFC4998, 726 August 2007, . 728 [I-D.ietf-core-oscore-groupcomm] 729 Tiloca, M., Selander, G., Palombini, F., Mattsson, J. P., 730 and J. Park, "Group OSCORE - Secure Group Communication 731 for CoAP", Work in Progress, Internet-Draft, draft-ietf- 732 core-oscore-groupcomm-11, 22 February 2021, 733 . 736 [I-D.ietf-cose-rfc8152bis-struct] 737 Schaad, J., "CBOR Object Signing and Encryption (COSE): 738 Structures and Process", Work in Progress, Internet-Draft, 739 draft-ietf-cose-rfc8152bis-struct-15, 1 February 2021, 740 . 743 [RFC8613] Selander, G., Mattsson, J., Palombini, F., and L. Seitz, 744 "Object Security for Constrained RESTful Environments 745 (OSCORE)", RFC 8613, DOI 10.17487/RFC8613, July 2019, 746 . 748 Appendix A. Examples 750 This appendix includes a set of examples that show the different 751 features and message types that have been defined in this document. 752 To make the examples easier to read, they are presented using the 753 extended CBOR diagnostic notation (defined in [RFC8610]) rather than 754 as a binary dump. 756 The examples are presented using the CBOR's diagnostic notation. A 757 Ruby-based tool exists that can convert between the diagnostic 758 notation and binary. This tool can be installed with the command 759 line: 761 gem install cbor-diag 763 The diagnostic notation can be converted into binary files using the 764 following command line: 766 diag2cbor.rb < inputfile > outputfile 768 The examples can be extracted from the XML version of this document 769 via an XPath expression as all of the sourcecode is tagged with the 770 attribute type='CBORdiag'. (Depending on the XPath evaluator one is 771 using, it may be necessary to deal with > as an entity.) 773 //sourcecode[@type='CDDL']/text() 775 A.1. Use of Early Code Points 777 This section is to be removed before publishing as an RFC. 779 The examples in this Appendix use code points proposed for early 780 allocation by IANA. When IANA makes the allocation, these examples 781 will be updated as needed. 783 A.2. Examples of Signed Messages 785 A.2.1. Countersignature 787 This example uses the following: 789 * Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 791 * The same header parameters are used for both the signature and the 792 countersignature. 794 Size of binary file is 180 bytes 795 98( 796 [ 797 / protected / h'', 798 / unprotected / { 799 / countersign / 11:[ 800 / protected h'a10126' / << { 801 / alg / 1:-7 / ECDSA 256 / 802 } >>, 803 / unprotected / { 804 / kid / 4:'11' 805 }, 806 / signature / h'5ac05e289d5d0e1b0a7f048a5d2b643813ded50bc9e4 807 9220f4f7278f85f19d4a77d655c9d3b51e805a74b099e1e085aacd97fc29d72f887e 808 8802bb6650cceb2c' 809 ] 810 }, 811 / payload / 'This is the content.', 812 / signatures / [ 813 [ 814 / protected h'a10126' / << { 815 / alg / 1:-7 / ECDSA 256 / 816 } >>, 817 / unprotected / { 818 / kid / 4:'11' 819 }, 820 / signature / h'e2aeafd40d69d19dfe6e52077c5d7ff4e408282cbefb 821 5d06cbf414af2e19d982ac45ac98b8544c908b4507de1e90b717c3d34816fe926a2b 822 98f53afd2fa0f30a' 823 ] 824 ] 825 ] 826 ) 828 A.3. Examples of Signed1 Messages 830 A.3.1. Countersignature 832 This example uses the following: 834 * Signature Algorithm: ECDSA w/ SHA-256, Curve P-256 836 * Countersignature Algorithm: ECDSA w/ SHA-512, Curve P-521 838 Size of binary file is 275 bytes 839 18( 840 [ 841 / protected h'A201260300' / << { 842 / alg / 1:-7, / ECDSA 256 / 843 / ctyp / 3:0 844 } >>, 845 / unprotected / { 846 / kid / 4: "11", 847 / countersign / 11: [ 848 / protected h'A1013823' / << { 849 / alg / 1:-36 / ECDSA 512 / 850 } >>, 851 / unprotected / { 852 / kid / 4: "bilbo.baggins@hobbiton.example" 853 }, 854 / signature / h'01B1291B0E60A79C459A4A9184A0D393E034B34AF069 855 A1CCA34F5A913AFFFF698002295FA9F8FCBFB6FDFF59132FC0C406E98754A98F1FBF 856 E81C03095F481856BC470170227206FA5BEE3C0431C56A66824E7AAF692985952E31 857 271434B2BA2E47A335C658B5E995AEB5D63CF2D0CED367D3E4CC8FFFD53B70D115BA 858 A9E86961FBD1A5CF' 859 ] 860 }, 861 / payload / 'This is the content.', 862 / signature / h'BB587D6B15F47BFD54D2CBFCECEF75451E92B08A514BD439 863 FA3AA65C6AC92DF0D7328C4A47529B32ADD3DD1B4E940071C021E9A8F2641F1D8E3B 864 053DDD65AE52' 865 ] 866 ) 868 A.4. Examples of Enveloped Messages 870 A.4.1. Countersignature on Encrypted Content 872 This example uses the following: 874 * CEK: AES-GCM w/ 128-bit key 876 * Recipient class: ECDH Ephemeral-Static, Curve P-256 878 * Countersignature Algorithm: ECDSA w/ SHA-512, Curve P-521 880 Size of binary file is 326 bytes 881 96( 882 [ 883 / protected h'a10101' / << { 884 / alg / 1:1 / AES-GCM 128 / 885 } >>, 886 / unprotected / { 887 / iv / 5:h'c9cf4df2fe6c632bf7886413', 888 / countersign / 11:[ 889 / protected h'a1013823' / << { 890 / alg / 1:-36 / ES512 / 891 } >> , 892 / unprotected / { 893 / kid / 4:'bilbo.baggins@hobbiton.example' 894 }, 895 / signature / h'00929663c8789bb28177ae28467e66377da12302d7f9 896 594d2999afa5dfa531294f8896f2b6cdf1740014f4c7f1a358e3a6cf57f4ed6fb02f 897 cf8f7aa989f5dfd07f0700a3a7d8f3c604ba70fa9411bd10c2591b483e1d2c31de00 898 3183e434d8fba18f17a4c7e3dfa003ac1cf3d30d44d2533c4989d3ac38c38b71481c 899 c3430c9d65e7ddff' 900 ] 901 }, 902 / ciphertext / h'7adbe2709ca818fb415f1e5df66f4e1a51053ba6d65a1a0 903 c52a357da7a644b8070a151b0', 904 / recipients / [ 905 [ 906 / protected h'a1013818' / << { 907 / alg / 1:-25 / ECDH-ES + HKDF-256 / 908 } >> , 909 / unprotected / { 910 / ephemeral / -1:{ 911 / kty / 1:2, 912 / crv / -1:1, 913 / x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf 914 bf054e1c7b4d91d6280', 915 / y / -3:true 916 }, 917 / kid / 4:'meriadoc.brandybuck@buckland.example' 918 }, 919 / ciphertext / h'' 920 ] 921 ] 922 ] 923 ) 925 A.5. Examples of Encrypted Messages 926 A.5.1. Countersignature on Encrypted Content 928 This example uses the following: 930 * CEK: AES-GCM w/ 128-bit key 932 * Countersignature algorithm: EdDSA with Curve Ed25519 934 Size of binary file is 136 bytes 936 16( 937 [ 938 / protected h'A10101' / << { 939 / alg / 1:1 / AES-GCM 128 / 940 } >>, 941 / unprotected / { 942 / iv / 5: h'02D1F7E6F26C43D4868D87CE', 943 / countersign / 11: [ 944 / protected h'A10127' / << { 945 / alg / 1:-8 / EdDSA with Ed25519 / 946 } >>, 947 / unprotected / { 948 / kid / 4: '11' 949 }, 950 / signature / h'E10439154CC75C7A3A5391491F88651E0292FD0FE0E0 951 2CF740547EAF6677B4A4040B8ECA16DB592881262F77B14C1A086C02268B17171CA1 952 6BE4B8595F8C0A08' 953 ] 954 }, 955 / ciphertext / h'60973A94BB2898009EE52ECFD9AB1DD25867374B162E2C0 956 3568B41F57C3CC16F9166250A' 957 ] 958 ) 960 A.6. Examples of MACed Messages 962 A.6.1. Countersignature on MAC Content 964 This example uses the following: 966 * MAC algorithm: HMAC/SHA-256 with 256-bit key 968 * Countersignature algorithm: EdDSA with Curve Ed25519 970 Size of binary file is 159 bytes 971 97( 972 [ 973 / protected h'A10105' / << { 974 / alg / 1:5 / HS256 / 975 } >>, 976 / unprotected / { 977 / countersign / 11: [ 978 / protected h'A10127' / << { 979 / alg / 1:-8 / EdDSA / 980 } >>, 981 / unprotected / { 982 / kid / 4: '11' 983 }, 984 / signature / h'602566F4A311DC860740D2DF54D4864555E85BC036EA 985 5A6CF7905B96E499C5F66B01C4997F6A20C37C37543ADEA1D705347D38A5B13594B2 986 9583DD741F455101' 987 ] 988 }, 989 / payload / 'This is the content.', 990 / tag / h'2BDCC89F058216B8A208DDC6D8B54AA91F48BD63484986565105C9 991 AD5A6682F6', 992 / recipients / [ 993 [ 994 / protected / h'', 995 / unprotected / { 996 / alg / 1: -6, / direct / 997 / kid / 4: 'our-secret' 998 }, 999 / ciphertext / h'' 1000 ] 1001 ] 1002 ] 1003 ) 1005 A.7. Examples of MAC0 Messages 1007 A.7.1. Countersignature on MAC0 Content 1009 This example uses the following: 1011 * MAC algorithm: HMAC/SHA-256 with 256-bit key 1013 * Countersignature algorithm: EdDSA with Curve Ed25519 1015 Size of binary file is 159 bytes 1016 17( 1017 [ 1018 / protected h'A10105' / << { 1019 / alg / 1:5 / HS256 / 1020 } >>, 1021 / unprotected / { 1022 / countersign / 11: [ 1023 / protected h'A10127' / << { 1024 / alg / 1:-8 / EdDSA / 1025 } >>, 1026 / unprotected / { 1027 / kid / 4: '11' 1028 }, 1029 / signature / h'968A315DF6B4F26362E11F4CFD2F2F4E76232F39657B 1030 F1598837FF9332CDDD7581E248116549451F81EF823DA5974F885B681D3D6E38FC41 1031 42D8F8E9E7DC8F0D' 1032 ] 1033 }, 1034 / payload / 'This is the content.', 1035 / tag / h'A1A848D3471F9D61EE49018D244C824772F223AD4F935293F1789F 1036 C3A08D8C58' 1037 ] 1038 ) 1040 Acknowledgments 1042 This document is a product of the COSE working group of the IETF. 1044 The initial version of the specification was based to some degree on 1045 the outputs of the JOSE and S/MIME working groups. 1047 Jim Schaad passed on 3 October 2020. This document is primarily his 1048 work. Russ Housley served as the document editor after Jim's 1049 untimely death, mostly helping with the approval and publication 1050 processes. Jim deserves all credit for the technical content. 1052 Jim Schaad and Jonathan Hammell provided the examples in the 1053 Appendix. 1055 {{{ RFC EDITOR: Please remove Russ Housley as an author of this 1056 document at publication. Jim Schaad should be listed as the sole 1057 author. }}} 1059 Authors' Addresses 1061 Jim Schaad 1062 August Cellars 1063 Email: ietf@augustcellars.com 1065 Russ Housley (editor) 1066 Vigil Security, LLC 1068 Email: housley@vigilsec.com