idnits 2.17.1 draft-ietf-cose-hash-algs-08.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The abstract seems to contain references ([I-D.ietf-cose-RFC8152bis-struct]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (29 July 2020) is 1366 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- == Outdated reference: A later version (-15) exists of draft-ietf-cose-rfc8152bis-struct-11 == Outdated reference: A later version (-09) exists of draft-ietf-cose-x509-06 == Outdated reference: A later version (-12) exists of draft-ietf-cose-rfc8152bis-algs-11 == Outdated reference: A later version (-25) exists of draft-ietf-suit-manifest-09 -- Obsolete informational reference (is this intentional?): RFC 8152 (ref. 'COSE') (Obsoleted by RFC 9052, RFC 9053) Summary: 1 error (**), 0 flaws (~~), 5 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group J. Schaad 3 Internet-Draft August Cellars 4 Intended status: Informational 29 July 2020 5 Expires: 30 January 2021 7 CBOR Object Signing and Encryption (COSE): Hash Algorithms 8 draft-ietf-cose-hash-algs-08 10 Abstract 12 The CBOR Object Signing and Encryption (COSE) syntax 13 [I-D.ietf-cose-rfc8152bis-struct] does not define any direct methods 14 for using hash algorithms. There are, however, circumstances where 15 hash algorithms are used, such as indirect signatures where the hash 16 of one or more contents are signed, and X.509 certificate or other 17 object identification by the use of a fingerprint. This document 18 defines a set of hash algorithms that are identified by COSE 19 Algorithm Identifiers. 21 Contributing to this document 23 This note is to be removed before publishing as an RFC. 25 The source for this draft is being maintained in GitHub. Suggested 26 changes should be submitted as pull requests at https://github.com/ 27 cose-wg/X509 Editorial changes can be managed in GitHub, but any 28 substantial issues need to be discussed on the COSE mailing list. 30 Status of This Memo 32 This Internet-Draft is submitted in full conformance with the 33 provisions of BCP 78 and BCP 79. 35 Internet-Drafts are working documents of the Internet Engineering 36 Task Force (IETF). Note that other groups may also distribute 37 working documents as Internet-Drafts. The list of current Internet- 38 Drafts is at https://datatracker.ietf.org/drafts/current/. 40 Internet-Drafts are draft documents valid for a maximum of six months 41 and may be updated, replaced, or obsoleted by other documents at any 42 time. It is inappropriate to use Internet-Drafts as reference 43 material or to cite them other than as "work in progress." 45 This Internet-Draft will expire on 30 January 2021. 47 Copyright Notice 49 Copyright (c) 2020 IETF Trust and the persons identified as the 50 document authors. All rights reserved. 52 This document is subject to BCP 78 and the IETF Trust's Legal 53 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 54 license-info) in effect on the date of publication of this document. 55 Please review these documents carefully, as they describe your rights 56 and restrictions with respect to this document. Code Components 57 extracted from this document must include Simplified BSD License text 58 as described in Section 4.e of the Trust Legal Provisions and are 59 provided without warranty as described in the Simplified BSD License. 61 Table of Contents 63 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 64 1.1. Requirements Terminology . . . . . . . . . . . . . . . . 3 65 2. Hash Algorithm Usage . . . . . . . . . . . . . . . . . . . . 3 66 2.1. Example CBOR hash structure . . . . . . . . . . . . . . . 4 67 3. Hash Algorithm Identifiers . . . . . . . . . . . . . . . . . 5 68 3.1. SHA-1 Hash Algorithm . . . . . . . . . . . . . . . . . . 6 69 3.2. SHA-2 Hash Algorithms . . . . . . . . . . . . . . . . . . 6 70 3.3. SHAKE Algorithms . . . . . . . . . . . . . . . . . . . . 8 71 4. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 9 72 4.1. COSE Algorithm Registry . . . . . . . . . . . . . . . . . 9 73 5. Security Considerations . . . . . . . . . . . . . . . . . . . 10 74 6. Normative References . . . . . . . . . . . . . . . . . . . . 10 75 7. Informative References . . . . . . . . . . . . . . . . . . . 11 76 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 12 78 1. Introduction 80 The CBOR Object Signing and Encryption (COSE) syntax does not define 81 any direct methods for the use of hash algorithms. It also does not 82 define a structure syntax that is used to encode a digested object 83 structure along the lines of the DigestedData ASN.1 structure in 84 [CMS]. This omission was intentional, as a structure consisting of 85 just a digest identifier, the content, and a digest value does not, 86 by itself, provide any strong security service. Additionally, an 87 application is going to be better off defining this type of structure 88 so that it can include any additional data that needs to be hashed, 89 as well as methods of obtaining the data. 91 While the above is true, there are some cases where having some 92 standard hash algorithms defined for COSE with a common identifier 93 makes a great deal of sense. Two of the cases where these are going 94 to be used are: 96 * Indirect signing of content, and 98 * Object identification. 100 Indirect signing of content is a paradigm where the content is not 101 directly signed, but instead a hash of the content is computed and 102 that hash value, along with an identifier for the hash algorithm, is 103 included in the content that will be signed. Doing indirect signing 104 allows for a signature to be validated without first downloading all 105 of the content associated with the signature. Rather the signature 106 can be validated on all of the hash values and pointers to the 107 associated contents, then those associated parts can be downloaded, 108 the hash value of that part computed, and then compared to the hash 109 value in the signed content. This capability can be of even greater 110 importance in a constrained environment as not all of the content 111 signed may be needed by the device. An example of how this is used 112 can be found in [I-D.ietf-suit-manifest]. 114 The use of hashes to identify objects is something that has been very 115 common. One of the primary things that has been identified by a hash 116 function in a secure message is a certificate. Two examples of this 117 can be found in [ESS] and the COSE equivalents in 118 [I-D.ietf-cose-x509]. 120 1.1. Requirements Terminology 122 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 123 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 124 "OPTIONAL" in this document are to be interpreted as described in BCP 125 14 [RFC2119] [RFC8174] when, and only when, they appear in all 126 capitals, as shown here. 128 2. Hash Algorithm Usage 130 As noted in the previous section, hash functions can be used for a 131 variety of purposes. Some of these purposes require that a hash 132 function be cryptographically strong. These include direct and 133 indirect signatures. That is, using the hash as part of the 134 signature or using the hash as part of the body to be signed. Other 135 uses of hash functions may not require the same level of strength. 137 This document contains some hash functions that are not designed to 138 be used for cryptographic operations. An application that is using a 139 hash function needs to carefully evaluate exactly what hash 140 properties are needed and which hash functions are going to provide 141 them. Applications should also make sure that the ability to change 142 hash functions is part of the base design, as cryptographic advances 143 are sure to reduce the strength of a hash function [BCP201]. 145 A hash function is a map from one, normally large, bit string to a 146 second, usually smaller, bit string. As the number of possible input 147 values is far greater than the number of possible output values, it 148 is inevitable that there are going to be collisions. The trick is to 149 make sure that it is difficult to find two values that are going to 150 map to the same output value. A "Collision Attack" is one where an 151 attacker can find two different messages that have the same hash 152 value. A hash function that is susceptible to practical collision 153 attacks, SHOULD NOT be used for a cryptographic purpose. The 154 discovery of theoretical collision attacks against a given hash 155 function SHOULD trigger a review of the continued suitability of the 156 algorithm if alternatives are available and migration is viable. The 157 only reason why such a hash function is used is when there is 158 absolutely no other choice (e.g. a Hardware Security Module (HSM) 159 that cannot be replaced), and only after looking at the possible 160 security issues. Cryptographic purposes would include the creation 161 of signatures or the use of hashes for indirect signatures. These 162 functions may still be usable for non-cryptographic purposes. 164 An example of a non-cryptographic use of a hash is for filtering from 165 a collection of values to find a set of possible candidates, the 166 candidates can then be check to see if they can successfully be used. 167 A simple example of this is the classic fingerprint of a certificate. 168 If the fingerprint is used to verify that it is the correct 169 certificate, then that usage is a cryptographic one and is subject to 170 the warning above about collision attack. If, however, the 171 fingerprint is used to sort through a collection of certificates to 172 find those that might be used for the purpose of verifying a 173 signature, a simple filter capability is sufficient. In this case, 174 one still needs to confirm that the public key validates the 175 signature (and the certificate is trusted), and all certificates that 176 don't contain a key that validates the signature can be discarded as 177 false positives. 179 To distinguish between these two cases, a new value in the 180 recommended column of the COSE Algorithms registry is to be added. 181 "Filter Only" indicates that the only purpose of a hash function 182 should be to filter results and it is not intended for applications 183 which require a cryptographically strong algorithm. 185 2.1. Example CBOR hash structure 187 [COSE] did not provide a default structure for holding a hash value 188 not only because no separate hash algorithms were defined, but 189 because how the structure is setup is frequently application 190 specific. There are four fields that are often included as part of a 191 hash structure: 193 * The hash algorithm identifier. 195 * The hash value. 197 * A pointer to the value that was hashed. This could be a pointer 198 to a file, an object that can be obtained from the network, or a 199 pointer to someplace in the message, or something very application 200 specific. 202 * Additional data; this can be something as simple as a random value 203 (i.e. salt) to make finding hash collisions slightly harder (as 204 the payload handed to the application could have been selected to 205 have a collision), or as complicated as a set of processing 206 instructions that are used with the object that is pointed to. 207 The additional data can be dealt with in a number of ways, 208 prepending or appending to the content, but it is strongly 209 suggested that it either be a fixed known size, or the lengths of 210 the pieces being hashed be included. (Encoding as a CBOR array 211 accomplishes this requirement.) 213 An example of a structure which permits all of the above fields to 214 exist would look like the following. 216 COSE_Hash_V = ( 217 1 : int / tstr, # Algorithm identifier 218 2 : bstr, # Hash value 219 ? 3 : tstr, # Location of object that was hashed 220 ? 4 : any # object containing other details and things 221 ) 223 Below is an alternative structure that could be used in situations 224 where one is searching a group of objects for a matching hash value. 225 In this case, the location would not be needed and adding extra data 226 to the hash would be counterproductive. This results in a structure 227 that looks like this: 229 COSE_Hash_Find = [ 230 hashAlg : int / tstr, 231 hashValue : bstr 232 ] 234 3. Hash Algorithm Identifiers 235 3.1. SHA-1 Hash Algorithm 237 The SHA-1 hash algorithm [RFC3174] was designed by the United States 238 National Security Agency and published in 1995. Since that time a 239 large amount of cryptographic analysis has been applied to this 240 algorithm and a successful collision attack has been created 241 ([SHA-1-collision]). The IETF formally started discouraging the use 242 of SHA-1 with the publishing of [RFC6194]. 244 Despite the above, there are still times where SHA-1 needs to be used 245 and therefore it makes sense to assign a codepoint for the use of 246 this hash algorithm. Some of these situations are with historic HSMs 247 where only SHA-1 is implemented, other situations are where the SHA-1 248 value is used for the purpose of filtering and thus the collision 249 resistance property is not needed. 251 Because of the known issues for SHA-1 and the fact that it should no 252 longer be used, the algorithm will be registered with the 253 recommendation of "Filter Only". This provides guidance about when 254 the algorithm is safe for use, while discouraging usage where it is 255 not safe. 257 The COSE capabilities for these algorithms is an empty array. 259 +=====+======+=============+==============+===========+=============+ 260 |Name |Value | Description | Capabilities | Reference | Recommended | 261 +=====+======+=============+==============+===========+=============+ 262 |SHA-1| TBD6 | SHA-1 Hash | [] | [This | Filter Only | 263 | | | | | Document] | | 264 +-----+------+-------------+--------------+-----------+-------------+ 266 Table 1: SHA-1 Hash Algorithm 268 3.2. SHA-2 Hash Algorithms 270 The family of SHA-2 hash algorithms [FIPS-180-4] was designed by the 271 United States National Security Agency and published in 2001. Since 272 that time some additional algorithms have been added to the original 273 set to deal with length extension attacks and some performance 274 issues. While the SHA-3 hash algorithms have been published since 275 that time, the SHA-2 algorithms are still broadly used. 277 There are a number of different parameters for the SHA-2 hash 278 functions. The set of hash functions which have been chosen for 279 inclusion in this document are based on those different parameters 280 and some of the trade-offs involved. 282 * *SHA-256/64* provides a truncated hash. The length of the 283 truncation is designed to allow for smaller transmission size. 284 The trade-off is that the odds that a collision will occur 285 increase proportionally. Use of this hash function needs analyze 286 of the potential problems with having a collision occur, or must 287 be limited to where the function of the hash is non-cryptographic. 289 The latter is the case for [I-D.ietf-cose-x509]. The hash value 290 is used to select possible certificates and, if there are multiple 291 choices remaining then, each choice can be tested by using the 292 public key. 294 * *SHA-256* is probably the most common hash function used 295 currently. SHA-256 is an efficient hash algorithm for 32-bit 296 hardware. 298 * *SHA-384* and *SHA-512* hash functions are efficient for 64-bit 299 hardware. 301 * *SHA-512/256* provides a hash function that runs more efficiently 302 on 64-bit hardware, but offers the same security levels as SHA- 303 256. 305 The COSE capabilities array for these algorithms is empty. 307 +===========+=====+===========+==============+=========+============+ 308 | Name |Value|Description| Capabilities |Reference|Recommended | 309 +===========+=====+===========+==============+=========+============+ 310 |SHA-256/64 |TBD1 | SHA-2 | [] | [This |Filter Only | 311 | | | 256-bit | |Document]| | 312 | | | Hash | | | | 313 | | | truncated | | | | 314 | | |to 64-bits | | | | 315 +-----------+-----+-----------+--------------+---------+------------+ 316 | SHA-256 |TBD2 | SHA-2 | [] | [This | Yes | 317 | | | 256-bit | |Document]| | 318 | | | Hash | | | | 319 +-----------+-----+-----------+--------------+---------+------------+ 320 | SHA-384 |TBD3 | SHA-2 | [] | [This | Yes | 321 | | | 384-bit | |Document]| | 322 | | | Hash | | | | 323 +-----------+-----+-----------+--------------+---------+------------+ 324 | SHA-512 |TBD4 | SHA-2 | [] | [This | Yes | 325 | | | 512-bit | |Document]| | 326 | | | Hash | | | | 327 +-----------+-----+-----------+--------------+---------+------------+ 328 |SHA-512/256|TBD5 | SHA-2 | [] | [This | Yes | 329 | | | 512-bit | |Document]| | 330 | | | Hash | | | | 331 | | | truncated | | | | 332 | | |to 256-bits| | | | 333 +-----------+-----+-----------+--------------+---------+------------+ 335 Table 2: SHA-2 Hash Algorithms 337 3.3. SHAKE Algorithms 339 The family of SHA-3 hash algorithms [FIPS-202] was the result of a 340 competition run by NIST. The pair of algorithms known as SHAKE-128 341 and SHAKE-256 are the instances of SHA-3 that are currently being 342 standardized in the IETF. This is the reason for including these 343 algorithms in this document. 345 The SHA-3 hash algorithms have a significantly different structure 346 than the SHA-2 hash algorithms. One of the benefits of this 347 difference is that when computing a shorter SHAKE hash value, the 348 value is not a prefix of the result of computing the longer hash. 350 Unlike the SHA-2 hash functions, no algorithm identifier is created 351 for shorter lengths. The length of the hash value stored is 256-bits 352 for SHAKE-128 and 512-bits for SHAKE-256. 354 The COSE capabilities array for these algorithms is empty. 356 +========+=====+=============+==============+=========+=============+ 357 | Name |Value| Description | Capabilities |Reference| Recommended | 358 +========+=====+=============+==============+=========+=============+ 359 |SHAKE128|TBD10| SHAKE-128 | [] | [This | Yes | 360 | | |256-bit Hash | |Document]| | 361 | | | Value | | | | 362 +--------+-----+-------------+--------------+---------+-------------+ 363 |SHAKE256|TBD11| SHAKE-256 | [] | [This | Yes | 364 | | |512-bit Hash | |Document]| | 365 | | | Value | | | | 366 +--------+-----+-------------+--------------+---------+-------------+ 368 Table 3: SHAKE Hash Functions 370 4. IANA Considerations 372 The IANA actions in [I-D.ietf-cose-rfc8152bis-struct] and 373 [I-D.ietf-cose-rfc8152bis-algs] need to be executed before the 374 actions in this document. Where early allocation of codepoints has 375 been made, these should be preserved. 377 4.1. COSE Algorithm Registry 379 IANA is requested to register the following algorithms in the "COSE 380 Algorithms" registry. 382 * The SHA-1 hash function found in Table 1. 384 * The set of SHA-2 hash functions found in Table 2. 386 * The set of SHAKE hash functions found in Table 3. 388 Many of the hash values produced are relatively long and as such the 389 use of a two byte algorithm identifier seems reasonable. SHA-1 is 390 tagged as deprecated and thus a longer algorithm identifier is 391 appropriate even though it is a shorter hash value. 393 In addition, IANA is to add the value of 'Filter Only' to the set of 394 legal values for the 'Recommended' column. This value is only to be 395 used for hash functions and indicates that it is not to be used for 396 purposes which require collision resistance. IANA is requested to 397 add this document to the reference section for this table due to this 398 addition. 400 5. Security Considerations 402 Protocols need to perform a careful analysis of the properties of a 403 hash function that are needed and how they map onto the possible 404 attacks. In particular, one needs to distinguish between those uses 405 that need the cryptographic properties, such as collision resistance, 406 and properties that correspond to possible object identification. 407 The different attacks correspond to who or what is being protected: 408 is it the originator that is the attacker or a third party? This is 409 the difference between collision resistance and second pre-image 410 resistance. As a general rule, longer hash values are "better" than 411 short ones, but trade-offs of transmission size, timeliness, and 412 security all need to be included as part of this analysis. In many 413 cases the value being hashed is a public value and, as such, pre- 414 image resistance is not part of this analysis. 416 Algorithm agility needs to be considered a requirement for any use of 417 hash functions [BCP201]. As with any cryptographic function, hash 418 functions are under constant attack and the cryptographic strength of 419 hash algorithms will be reduced over time. 421 6. Normative References 423 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 424 Requirement Levels", BCP 14, RFC 2119, 425 DOI 10.17487/RFC2119, March 1997, 426 . 428 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 429 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 430 May 2017, . 432 [I-D.ietf-cose-rfc8152bis-struct] 433 Schaad, J., "CBOR Object Signing and Encryption (COSE): 434 Structures and Process", Work in Progress, Internet-Draft, 435 draft-ietf-cose-rfc8152bis-struct-11, 1 July 2020, 436 . 439 [FIPS-180-4] 440 National Institute of Standards and Technology, "Secure 441 Hash Standard", FIPS PUB 180-4, August 2015. 443 [FIPS-202] National Institute of Standards and Technology, "SHA-3 444 Standard: Permutation-Based Hash and Extendable-Output 445 Functions", FIPS PUB 202, August 2015. 447 [RFC3174] Eastlake 3rd, D. and P. Jones, "US Secure Hash Algorithm 1 448 (SHA1)", RFC 3174, DOI 10.17487/RFC3174, September 2001, 449 . 451 7. Informative References 453 [CMS] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70, 454 RFC 5652, DOI 10.17487/RFC5652, September 2009, 455 . 457 [ESS] Hoffman, P., Ed., "Enhanced Security Services for S/MIME", 458 RFC 2634, DOI 10.17487/RFC2634, June 1999, 459 . 461 [I-D.ietf-cose-x509] 462 Schaad, J., "CBOR Object Signing and Encryption (COSE): 463 Header parameters for carrying and referencing X.509 464 certificates", Work in Progress, Internet-Draft, draft- 465 ietf-cose-x509-06, 9 March 2020, 466 . 468 [RFC6194] Polk, T., Chen, L., Turner, S., and P. Hoffman, "Security 469 Considerations for the SHA-0 and SHA-1 Message-Digest 470 Algorithms", RFC 6194, DOI 10.17487/RFC6194, March 2011, 471 . 473 [I-D.ietf-cose-rfc8152bis-algs] 474 Schaad, J., "CBOR Object Signing and Encryption (COSE): 475 Initial Algorithms", Work in Progress, Internet-Draft, 476 draft-ietf-cose-rfc8152bis-algs-11, 1 July 2020, 477 . 480 [I-D.ietf-suit-manifest] 481 Moran, B., Tschofenig, H., Birkholz, H., and K. Zandberg, 482 "A Concise Binary Object Representation (CBOR)-based 483 Serialization Format for the Software Updates for Internet 484 of Things (SUIT) Manifest", Work in Progress, Internet- 485 Draft, draft-ietf-suit-manifest-09, 13 July 2020, 486 . 488 [BCP201] Housley, R., "Guidelines for Cryptographic Algorithm 489 Agility and Selecting Mandatory-to-Implement Algorithms", 490 BCP 201, RFC 7696, November 2015. 492 494 [SHA-1-collision] 495 Stevens, M., Bursztein, E., Karpman, P., Albertini, A., 496 and Y. Markov, "The first collision for full SHA-1", 497 February 2017, 498 . 500 [COSE] Schaad, J., "CBOR Object Signing and Encryption (COSE)", 501 RFC 8152, DOI 10.17487/RFC8152, July 2017, 502 . 504 Author's Address 506 Jim Schaad 507 August Cellars 509 Email: ietf@augustcellars.com