idnits 2.17.1 draft-ietf-cose-hash-algs-09.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 (September 14, 2020) is 1313 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-12 == 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 September 14, 2020 5 Expires: March 18, 2021 7 CBOR Object Signing and Encryption (COSE): Hash Algorithms 8 draft-ietf-cose-hash-algs-09 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 March 18, 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 protocol maintainers and users to do a review 156 of the continued suitability of the algorithm if alternatives are 157 available and migration is viable. The only reason why such a hash 158 function is used is when there is absolutely no other choice (e.g. a 159 Hardware Security Module (HSM) that cannot be replaced), and only 160 after looking at the possible security issues. Cryptographic 161 purposes would include the creation of signatures or the use of 162 hashes for indirect signatures. These functions may still be usable 163 for non-cryptographic purposes. 165 An example of a non-cryptographic use of a hash is for filtering from 166 a collection of values to find a set of possible candidates; the 167 candidates can then be checked to see if they can successfully be 168 used. A simple example of this is the classic fingerprint of a 169 certificate. If the fingerprint is used to verify that it is the 170 correct certificate, then that usage is a cryptographic one and is 171 subject to the warning above about collision attack. If, however, 172 the fingerprint is used to sort through a collection of certificates 173 to find those that might be used for the purpose of verifying a 174 signature, a simple filter capability is sufficient. In this case, 175 one still needs to confirm that the public key validates the 176 signature (and the certificate is trusted), and all certificates that 177 don't contain a key that validates the signature can be discarded as 178 false positives. 180 To distinguish between these two cases, a new value in the 181 recommended column of the COSE Algorithms registry is to be added. 182 "Filter Only" indicates that the only purpose of a hash function 183 should be to filter results and it is not intended for applications 184 which require a cryptographically strong algorithm. 186 2.1. Example CBOR hash structure 188 [COSE] did not provide a default structure for holding a hash value 189 not only because no separate hash algorithms were defined, but 190 because how the structure is setup is frequently application 191 specific. There are four fields that are often included as part of a 192 hash structure: 194 * The hash algorithm identifier. 196 * The hash value. 198 * A pointer to the value that was hashed. This could be a pointer 199 to a file, an object that can be obtained from the network, or a 200 pointer to someplace in the message, or something very application 201 specific. 203 * Additional data; this can be something as simple as a random value 204 (i.e. salt) to make finding hash collisions slightly harder (as 205 the payload handed to the application could have been selected to 206 have a collision), or as complicated as a set of processing 207 instructions that are used with the object that is pointed to. 208 The additional data can be dealt with in a number of ways, 209 prepending or appending to the content, but it is strongly 210 suggested that it either be a fixed known size, or the lengths of 211 the pieces being hashed be included. (Encoding as a CBOR array 212 accomplishes this requirement.) 214 An example of a structure which permits all of the above fields to 215 exist would look like the following. 217 COSE_Hash_V = ( 218 1 : int / tstr, # Algorithm identifier 219 2 : bstr, # Hash value 220 ? 3 : tstr, # Location of object that was hashed 221 ? 4 : any # object containing other details and things 222 ) 224 Below is an alternative structure that could be used in situations 225 where one is searching a group of objects for a matching hash value. 226 In this case, the location would not be needed and adding extra data 227 to the hash would be counterproductive. This results in a structure 228 that looks like this: 230 COSE_Hash_Find = [ 231 hashAlg : int / tstr, 232 hashValue : bstr 233 ] 235 3. Hash Algorithm Identifiers 236 3.1. SHA-1 Hash Algorithm 238 The SHA-1 hash algorithm [RFC3174] was designed by the United States 239 National Security Agency and published in 1995. Since that time a 240 large amount of cryptographic analysis has been applied to this 241 algorithm and a successful collision attack has been created 242 ([SHA-1-collision]). The IETF formally started discouraging the use 243 of SHA-1 with the publishing of [RFC6194]. 245 Despite the above, there are still times where SHA-1 needs to be used 246 and therefore it makes sense to assign a codepoint for the use of 247 this hash algorithm. Some of these situations are with historic HSMs 248 where only SHA-1 is implemented; other situations are where the SHA-1 249 value is used for the purpose of filtering and thus the collision 250 resistance property is not needed. 252 Because of the known issues for SHA-1 and the fact that it should no 253 longer be used, the algorithm will be registered with the 254 recommendation of "Filter Only". This provides guidance about when 255 the algorithm is safe for use, while discouraging usage where it is 256 not safe. 258 The COSE capabilities for this algorithm is an empty array. 260 +=====+======+=============+==============+===========+=============+ 261 |Name |Value | Description | Capabilities | Reference | Recommended | 262 +=====+======+=============+==============+===========+=============+ 263 |SHA-1| -14 | SHA-1 Hash | [] | [This | Filter Only | 264 | | | | | Document] | | 265 +-----+------+-------------+--------------+-----------+-------------+ 267 Table 1: SHA-1 Hash Algorithm 269 3.2. SHA-2 Hash Algorithms 271 The family of SHA-2 hash algorithms [FIPS-180-4] was designed by the 272 United States National Security Agency and published in 2001. Since 273 that time some additional algorithms have been added to the original 274 set to deal with length extension attacks and some performance 275 issues. While the SHA-3 hash algorithms have been published since 276 that time, the SHA-2 algorithms are still broadly used. 278 There are a number of different parameters for the SHA-2 hash 279 functions. The set of hash functions which have been chosen for 280 inclusion in this document are based on those different parameters 281 and some of the trade-offs involved. 283 * *SHA-256/64* provides a truncated hash. The length of the 284 truncation is designed to allow for smaller transmission size. 285 The trade-off is that the odds that a collision will occur 286 increase proportionally. Use of this hash function needs analysis 287 of the potential problems with having a collision occur, or must 288 be limited to where the function of the hash is non-cryptographic. 290 The latter is the case for [I-D.ietf-cose-x509]. The hash value 291 is used to select possible certificates and, if there are multiple 292 choices remaining then, each choice can be tested by using the 293 public key. 295 * *SHA-256* is probably the most common hash function used 296 currently. SHA-256 is an efficient hash algorithm for 32-bit 297 hardware. 299 * *SHA-384* and *SHA-512* hash functions are efficient for 64-bit 300 hardware. 302 * *SHA-512/256* provides a hash function that runs more efficiently 303 on 64-bit hardware, but offers the same security levels as SHA- 304 256. 306 The COSE capabilities array for these algorithms is empty. 308 +===========+=====+===========+==============+=========+============+ 309 | Name |Value|Description| Capabilities |Reference|Recommended | 310 +===========+=====+===========+==============+=========+============+ 311 |SHA-256/64 | -15 | SHA-2 | [] | [This |Filter Only | 312 | | | 256-bit | |Document]| | 313 | | | Hash | | | | 314 | | | truncated | | | | 315 | | |to 64-bits | | | | 316 +-----------+-----+-----------+--------------+---------+------------+ 317 | SHA-256 | -16 | SHA-2 | [] | [This | Yes | 318 | | | 256-bit | |Document]| | 319 | | | Hash | | | | 320 +-----------+-----+-----------+--------------+---------+------------+ 321 | SHA-384 | -43 | SHA-2 | [] | [This | Yes | 322 | | | 384-bit | |Document]| | 323 | | | Hash | | | | 324 +-----------+-----+-----------+--------------+---------+------------+ 325 | SHA-512 | -44 | SHA-2 | [] | [This | Yes | 326 | | | 512-bit | |Document]| | 327 | | | Hash | | | | 328 +-----------+-----+-----------+--------------+---------+------------+ 329 |SHA-512/256| -17 | SHA-2 | [] | [This | Yes | 330 | | | 512-bit | |Document]| | 331 | | | Hash | | | | 332 | | | truncated | | | | 333 | | |to 256-bits| | | | 334 +-----------+-----+-----------+--------------+---------+------------+ 336 Table 2: SHA-2 Hash Algorithms 338 3.3. SHAKE Algorithms 340 The family of SHA-3 hash algorithms [FIPS-202] was the result of a 341 competition run by NIST. The pair of algorithms known as SHAKE-128 342 and SHAKE-256 are the instances of SHA-3 that are currently being 343 standardized in the IETF. This is the reason for including these 344 algorithms in this document. 346 The SHA-3 hash algorithms have a significantly different structure 347 than the SHA-2 hash algorithms. 349 Unlike the SHA-2 hash functions, no algorithm identifier is created 350 for shorter lengths. The length of the hash value stored is 256-bits 351 for SHAKE-128 and 512-bits for SHAKE-256. 353 The COSE capabilities array for these algorithms is empty. 355 +========+=====+=============+==============+=========+=============+ 356 | Name |Value| Description | Capabilities |Reference| Recommended | 357 +========+=====+=============+==============+=========+=============+ 358 |SHAKE128| -18 | SHAKE-128 | [] | [This | Yes | 359 | | |256-bit Hash | |Document]| | 360 | | | Value | | | | 361 +--------+-----+-------------+--------------+---------+-------------+ 362 |SHAKE256| -45 | SHAKE-256 | [] | [This | Yes | 363 | | |512-bit Hash | |Document]| | 364 | | | Value | | | | 365 +--------+-----+-------------+--------------+---------+-------------+ 367 Table 3: SHAKE Hash Functions 369 4. IANA Considerations 371 The IANA actions in [I-D.ietf-cose-rfc8152bis-struct] and 372 [I-D.ietf-cose-rfc8152bis-algs] need to be executed before the 373 actions in this document. Where early allocation of codepoints has 374 been made, these should be preserved. 376 4.1. COSE Algorithm Registry 378 IANA is requested to register the following algorithms in the "COSE 379 Algorithms" registry. 381 * The SHA-1 hash function found in Table 1. 383 * The set of SHA-2 hash functions found in Table 2. 385 * The set of SHAKE hash functions found in Table 3. 387 Many of the hash values produced are relatively long and as such the 388 use of a two byte algorithm identifier seems reasonable. SHA-1 is 389 tagged as 'Filter Only' and thus a longer algorithm identifier is 390 appropriate even though it is a shorter hash value. 392 IANA is requested to add the value of 'Filter Only' to the set of 393 legal values for the 'Recommended' column. This value is only to be 394 used for hash functions and indicates that it is not to be used for 395 purposes which require collision resistance. IANA is requested to 396 add this document to the reference section for this table due to this 397 addition. 399 5. Security Considerations 401 Protocols need to perform a careful analysis of the properties of a 402 hash function that are needed and how they map onto the possible 403 attacks. In particular, one needs to distinguish between those uses 404 that need the cryptographic properties, such as collision resistance, 405 and properties that correspond to possible object identification. 406 The different attacks correspond to who or what is being protected: 407 is it the originator that is the attacker or a third party? This is 408 the difference between collision resistance and second pre-image 409 resistance. As a general rule, longer hash values are "better" than 410 short ones, but trade-offs of transmission size, timeliness, and 411 security all need to be included as part of this analysis. In many 412 cases the value being hashed is a public value and, as such, pre- 413 image resistance is not part of this analysis. 415 Algorithm agility needs to be considered a requirement for any use of 416 hash functions [BCP201]. As with any cryptographic function, hash 417 functions are under constant attack and the cryptographic strength of 418 hash algorithms will be reduced over time. 420 6. Normative References 422 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 423 Requirement Levels", BCP 14, RFC 2119, 424 DOI 10.17487/RFC2119, March 1997, 425 . 427 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 428 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 429 May 2017, . 431 [I-D.ietf-cose-rfc8152bis-struct] 432 Schaad, J., "CBOR Object Signing and Encryption (COSE): 433 Structures and Process", Work in Progress, Internet-Draft, 434 draft-ietf-cose-rfc8152bis-struct-12, August 24, 2020, 435 . 438 [FIPS-180-4] 439 National Institute of Standards and Technology, "Secure 440 Hash Standard", FIPS PUB 180-4, August 2015. 442 [FIPS-202] National Institute of Standards and Technology, "SHA-3 443 Standard: Permutation-Based Hash and Extendable-Output 444 Functions", FIPS PUB 202, August 2015. 446 [RFC3174] Eastlake 3rd, D. and P. Jones, "US Secure Hash Algorithm 1 447 (SHA1)", RFC 3174, DOI 10.17487/RFC3174, September 2001, 448 . 450 7. Informative References 452 [CMS] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70, 453 RFC 5652, DOI 10.17487/RFC5652, September 2009, 454 . 456 [ESS] Hoffman, P., Ed., "Enhanced Security Services for S/MIME", 457 RFC 2634, DOI 10.17487/RFC2634, June 1999, 458 . 460 [I-D.ietf-cose-x509] 461 Schaad, J., "CBOR Object Signing and Encryption (COSE): 462 Header parameters for carrying and referencing X.509 463 certificates", Work in Progress, Internet-Draft, draft- 464 ietf-cose-x509-06, March 9, 2020, 465 . 467 [RFC6194] Polk, T., Chen, L., Turner, S., and P. Hoffman, "Security 468 Considerations for the SHA-0 and SHA-1 Message-Digest 469 Algorithms", RFC 6194, DOI 10.17487/RFC6194, March 2011, 470 . 472 [I-D.ietf-cose-rfc8152bis-algs] 473 Schaad, J., "CBOR Object Signing and Encryption (COSE): 474 Initial Algorithms", Work in Progress, Internet-Draft, 475 draft-ietf-cose-rfc8152bis-algs-11, July 1, 2020, 476 . 479 [I-D.ietf-suit-manifest] 480 Moran, B., Tschofenig, H., Birkholz, H., and K. Zandberg, 481 "A Concise Binary Object Representation (CBOR)-based 482 Serialization Format for the Software Updates for Internet 483 of Things (SUIT) Manifest", Work in Progress, Internet- 484 Draft, draft-ietf-suit-manifest-09, July 13, 2020, 485 . 487 [BCP201] Housley, R., "Guidelines for Cryptographic Algorithm 488 Agility and Selecting Mandatory-to-Implement Algorithms", 489 BCP 201, RFC 7696, November 2015. 491 493 [SHA-1-collision] 494 Stevens, M., Bursztein, E., Karpman, P., Albertini, A., 495 and Y. Markov, "The first collision for full SHA-1", 496 February 2017, 497 . 499 [COSE] Schaad, J., "CBOR Object Signing and Encryption (COSE)", 500 RFC 8152, DOI 10.17487/RFC8152, July 2017, 501 . 503 Author's Address 505 Jim Schaad 506 August Cellars 508 Email: ietf@augustcellars.com