idnits 2.17.1 draft-ietf-cose-hash-algs-02.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 : ---------------------------------------------------------------------------- ** There is 1 instance of too long lines in the document, the longest one being 107 characters in excess of 72. ** 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 (4 November 2019) is 1635 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-06 ** Obsolete normative reference: RFC 8152 (ref. 'COSE') (Obsoleted by RFC 9052, RFC 9053) == Outdated reference: A later version (-09) exists of draft-ietf-cose-x509-04 Summary: 3 errors (**), 0 flaws (~~), 3 warnings (==), 1 comment (--). 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 4 November 2019 5 Expires: 7 May 2020 7 CBOR Object Signing and Encryption (COSE): Hash Algorithms 8 draft-ietf-cose-hash-algs-02 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: Indirect signatures where the hash of one 16 or more contents are signed. X.509 certificate or other object 17 identification by the use of a thumbprint. This document defines a 18 set of hash algorithms that are identified by COSE Algorithm 19 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 7 May 2020. 47 Copyright Notice 49 Copyright (c) 2019 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 1.2. Open Issues . . . . . . . . . . . . . . . . . . . . . . . 3 66 2. Hash Algorithm Usage . . . . . . . . . . . . . . . . . . . . 3 67 2.1. Example CBOR hash structure . . . . . . . . . . . . . . . 4 68 3. Hash Algorithm Identifiers . . . . . . . . . . . . . . . . . 5 69 3.1. SHA-1 Hash Algorithm . . . . . . . . . . . . . . . . . . 5 70 3.2. SHA-2 Hash Algorithms . . . . . . . . . . . . . . . . . . 6 71 3.3. SHAKE Algorithms . . . . . . . . . . . . . . . . . . . . 7 72 4. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 8 73 4.1. COSE Algorithm Registry . . . . . . . . . . . . . . . . . 8 74 5. Security Considerations . . . . . . . . . . . . . . . . . . . 8 75 6. Normative References . . . . . . . . . . . . . . . . . . . . 9 76 7. Informative References . . . . . . . . . . . . . . . . . . . 9 77 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 10 79 1. Introduction 81 The CBOR Object Signing and Encryption (COSE) syntax does not define 82 any direct methods for the use of hash algorithms. It also does not 83 define a structure syntax that is used to encode a digested object 84 structure along the lines of the DigestedData ASN.1 structure in 85 [CMS]. This omission was intentional as a structure consisting of 86 just a digest identifier, the content, and a digest value does not by 87 itself provide any strong security service. Additionally, an 88 application is going to be better off defining this type of structure 89 so that it can include any additional data that needs to be hashed, 90 as well as methods of obtaining the data. 92 While the above is true, there are some cases where having some 93 standard hash algorithms defined for COSE with a common identifier 94 makes a great deal of sense. Two of the cases where these are going 95 to be used are: 97 * Indirect signing of content, and 99 * Object identification. 101 Indirect signing of content is a paradigm where the content is not 102 directly signed, but instead a hash of the content is computed and 103 that hash value, along with the hash algorithm, is included in the 104 content that will be signed. Doing indirect signing allows for a 105 signature to be validated without first downloading all of the 106 content associated with the signature. This capability can be of 107 even greater importance in a constrained environment as not all of 108 the content signed may be needed by the device. 110 The use of hashes to identify objects is something that has been very 111 common. One of the primary things that has been identified by a hash 112 function for secure message is a certificate. Two examples of this 113 can be found in [ESS] and the newly defined COSE equivalents in 114 [I-D.ietf-cose-x509]. 116 1.1. Requirements Terminology 118 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 119 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 120 "OPTIONAL" in this document are to be interpreted as described in BCP 121 14 [RFC2119] [RFC8174] when, and only when, they appear in all 122 capitals, as shown here. 124 1.2. Open Issues 126 This section is to be removed before publishing as an RFC. 128 * No Open Issues 130 2. Hash Algorithm Usage 132 As noted in the previous section, hash functions can be used for a 133 variety of purposes. Some of these purposes require that a hash 134 function be cryptographically strong, these include direct and 135 indirect signatures. That is, using the hash as part of the 136 signature or using the hash as part of the body to be signed. Other 137 uses of hash functions do not require the same level of strength. 139 This document contains some hash functions that are not designed to 140 be used for cryptographic operations. An application that is using a 141 hash function needs to carefully evaluate exactly what hash 142 properties are needed and which hash functions are going to provide 143 them. Applications should also make sure that the ability to change 144 hash functions is part of the base design as cryptographic advances 145 are sure to reduce the strength of a hash function. 147 A hash function is a map from one, normally large, bit string to a 148 second, usually smaller, bit string. There are going to be 149 collisions by a hash function, the trick is to make sure that it is 150 difficult to find two values that are going to map to the same output 151 value. The standard "Collision Attack" is one where an attacker can 152 find two different messages that have the same hash value. If a 153 collision attack exists, then the function SHOULD NOT be used for a 154 cryptographic purpose. The only reason why such a hash function is 155 used is when there is absolutely no other choice (e.g. a Hardware 156 Security Module (HSM) that cannot be replaced), and only after 157 looking at the possible security issues. Cryptographic purposes 158 would include the creation of signatures or the use of hashes for 159 indirect signatures. These functions may still be usable for non- 160 cryptographic purposes. 162 An example of a non-cryptographic use of a hash is for filtering from 163 a collection of values to find possible candidates that can later be 164 checked to see if they are the correct one. A simple example of this 165 is the classic thumbprint of a certificate. If the thumbprint is 166 used to verify that it is the correct certificate, then that usage is 167 subject to a collision attack as above. If however, the thumbprint 168 is used to sort through a collection of certificates to find those 169 that might be used for the purpose of verifying a signature, a simple 170 filter capability is sufficient. In this case, one still needs to 171 validate that the public key validates the signature (and the 172 certificate is trusted), and all certificates that don't contain a 173 key that validates the signature can be discarded as false positives. 175 To distinguish between these two cases, a new value in the 176 recommended column of the COSE Algorithms registry is to be added. 177 "Filter Only" indicates that the only purpose of a hash function 178 should be to filter results and not those which require collision 179 resistance. 181 2.1. Example CBOR hash structure 183 [COSE] did not provide a default structure for holding a hash value 184 not only because no separate hash algorithms were defined, but 185 because how the structure is setup is frequently application 186 specific. There are four fields that are often included as part of a 187 hash structure: 189 * The hash algorithm identifier. 191 * The hash value. 193 * A pointer to the value that was hashed, this could be a pointer to 194 a file, an object that can be obtained from the network, or a 195 pointer to someplace in the message, or something very application 196 specific. 198 * Additional data, this can be something as simple as a random value 199 to make finding hash collisions slightly harder as the value 200 handed to the application cannot have been selected to have a 201 collision, or as complicated as a set of processing instructions 202 that are used with the object that is pointed to. The additional 203 data can be dealt with in a number of ways, prepending or 204 appending to the content, but it is strongly suggested to it 205 either be a fixed known size, or the lengths of the pieces being 206 hashed be included. (Encoding as a CBOR array accomplished this 207 requirement.) 209 An example of a structure which permits all of the above fields to 210 exist would look like the following. 212 COSE_Hash_V = ( 1 : int / tstr, # Algorithm identifier 2 : bstr, # Hash value 3 : tstr ?, # Location of object hashed 4 : any ? # object containing other details and things ) 214 An alternate structure that could be used for situations where one is 215 searching a group of objects for a match. In this case, the location 216 would not be needed and adding extra data to the hash would be 217 counterproductive. This results in a structure that looks like this: 219 COSE_Hash_Find = [ hashAlg : int / tstr, hashValue : bstr ] 221 3. Hash Algorithm Identifiers 223 3.1. SHA-1 Hash Algorithm 225 The SHA-1 hash algorithm [RFC3174] was designed by the United States 226 National Security Agency and published in 1995. Since that time a 227 large amount of cryptographic analysis has been applied to this 228 algorithm and a successful collision attack has been created 229 ([SHA-1-collision]). The IETF formally started discouraging the use 230 of SHA-1 with the publishing of [RFC6194]. 232 Despite the above, there are still times where SHA-1 needs to be used 233 and therefore it makes sense to assign a point for the use of this 234 hash algorithm. Some of these situations are with historic HSMs 235 where only SHA-1 is implemented or where the SHA-1 value is used for 236 the purpose of filtering and thus the collision resistance property 237 is not needed. 239 Because of the known issues for SHA-1 and the fact that is should no 240 longer be used, the algorithm will be registered with the 241 recommendation of "Filter Only". 243 +-------+-------+-------------+-----------------+-------------+ 244 | Name | Value | Description | Reference | Recommended | 245 +=======+=======+=============+=================+=============+ 246 | SHA-1 | TBD6 | SHA-1 Hash | [This Document] | Filter Only | 247 +-------+-------+-------------+-----------------+-------------+ 249 Table 1: SHA-1 Hash Algorithm 251 3.2. SHA-2 Hash Algorithms 253 The family of SHA-2 hash algorithms [FIPS-180-4] was designed by the 254 United States National Security Agency and published in 2001. Since 255 that time some additional algorithms have been added to the original 256 set to deal with length extension attacks and some performance 257 issues. While the SHA-3 hash algorithms have been published since 258 that time, the SHA-2 algorithms are still broadly used. 260 There are a number of different parameters for the SHA-2 hash 261 functions. The set of hash functions which have been chosen for 262 inclusion in this document are based on those different parameters 263 and some of the trade-offs involved. 265 * *SHA-256/64* provides a truncated hash. The length of the 266 truncation is designed to allow for smaller transmission size. 267 The trade-off is that the odds that a collision will occur 268 increase proportionally. Locations that use this hash function 269 need either to analysis the potential problems with having a 270 collision occur, or where the only function of the hash is to 271 narrow the possible choices. 273 The latter is the case for [I-D.ietf-cose-x509], the hash value is 274 used to select possible certificates and, if there are multiple 275 choices then, each choice can be tested by using the public key. 277 * *SHA-256* is probably the most common hash function used 278 currently. SHA-256 is an efficient hash algorithm for 32-bit 279 hardware. 281 * *SHA-384* and *SHA-512* hash functions are efficient for 64-bit 282 hardware. 284 * *SHA-512/256* provides a hash function that runs more efficiently 285 on 64-bit hardware, but offers the same security levels as SHA- 286 256. 288 +-------------+-------+----------------+-----------+-------------+ 289 | Name | Value | Description | Reference | Recommended | 290 +=============+=======+================+===========+=============+ 291 | SHA-256/64 | TBD1 | SHA-2 256-bit | [This | Filter Only | 292 | | | Hash truncated | Document] | | 293 | | | to 64-bits | | | 294 +-------------+-------+----------------+-----------+-------------+ 295 | SHA-256 | TBD2 | SHA-2 256-bit | [This | Yes | 296 | | | Hash | Document] | | 297 +-------------+-------+----------------+-----------+-------------+ 298 | SHA-384 | TBD3 | SHA-2 384-bit | [This | Yes | 299 | | | Hash | Document] | | 300 +-------------+-------+----------------+-----------+-------------+ 301 | SHA-512 | TBD4 | SHA-2 512-bit | [This | Yes | 302 | | | Hash | Document] | | 303 +-------------+-------+----------------+-----------+-------------+ 304 | SHA-512/256 | TBD5 | SHA-2 512-bit | [This | Yes | 305 | | | Hash truncated | Document] | | 306 | | | to 256-bits | | | 307 +-------------+-------+----------------+-----------+-------------+ 309 Table 2: SHA-2 Hash Algorithms 311 3.3. SHAKE Algorithms 313 The family SHA-3 hash algorithms [FIPS-202] was the result of a 314 competition run by NIST. The pair of algorithms known as SHAKE-128 315 and SHAKE-256 are the instances of SHA-3 that are currently being 316 standardized in the IETF. 318 The SHA-3 hash algorithms have a significantly different structure 319 than the SHA-2 hash algorithms. One of the benefits of this 320 differences is that when computing a shorter SHAKE hash value, the 321 value is not a prefix of the result of computing the longer hash. 323 Unlike the SHA-2 hash functions, no algorithm identifier is created 324 for shorter lengths. Applications can specify a minimum length for 325 any hash function. A validator can infer the actual length from the 326 hash value in these cases. 328 +----------+-------+---------------+-----------------+-------------+ 329 | Name | Value | Description | Reference | Recommended | 330 +==========+=======+===============+=================+=============+ 331 | SHAKE128 | TBD10 | 128-bit SHAKE | [This Document] | Yes | 332 +----------+-------+---------------+-----------------+-------------+ 333 | SHAKE256 | TBD11 | 256-bit SHAKE | [This Document] | Yes | 334 +----------+-------+---------------+-----------------+-------------+ 336 Table 3: SHAKE Hash Functions 338 4. IANA Considerations 340 4.1. COSE Algorithm Registry 342 IANA is requested to register the following algorithms in the "COSE 343 Algorithms" registry. 345 * The SHA-1 hash function found in Table 1. 347 * The set of SHA-2 hash functions found in Table 2. 349 * The set of SHAKE hash functions found in Table 3. 351 Many of the hash values produced are relatively long and as such the 352 use of a two byte algorithm identifier seems reasonable. SHA-1 is 353 tagged as deprecated and thus a longer algorithm identifier is 354 appropriate even though it is a shorter hash value. 356 In addition, IANA is to add the value of 'Filter Only' to the set of 357 legal values for the 'Recommended' column. This value is only to be 358 used for hash functions and indicates that it is not to be used for 359 purposes which require collision resistance. 361 5. Security Considerations 363 The security considerations have already been called out as part of 364 the previous text. The following issues need to be dealt with: 366 * Protocols need to perform a careful analysis of the properties of 367 a hash function that are needed and how they map onto the possible 368 attacks. In particular, one needs to distinguish between those 369 uses that need the cryptographic properties, i.e. collision 370 resistance, and properties that correspond to possible object 371 identification. The different attacks correspond to who or what 372 is being protected, is it the originator that is the attacker or a 373 third party? This is the difference between collision resistance 374 and second pre-image resistance. As a general rule, longer hash 375 values are "better" than short ones, but trade-offs of 376 transmission size, timeliness, and security all need to be 377 included as part of this analysis. In many cases the value being 378 hashed is a public value, as such pre-image resistance is not part 379 of this analysis. 381 * Algorithm agility needs to be considered a requirement for any use 382 of hash functions. As with any cryptographic function, hash 383 functions are under constant attack and the strength of hash 384 algorithms will be reduced over time. 386 6. Normative References 388 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 389 Requirement Levels", BCP 14, RFC 2119, 390 DOI 10.17487/RFC2119, March 1997, 391 . 393 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 394 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 395 May 2017, . 397 [I-D.ietf-cose-rfc8152bis-struct] 398 Schaad, J., "CBOR Object Signing and Encryption (COSE): 399 Structures and Process", Work in Progress, Internet-Draft, 400 draft-ietf-cose-rfc8152bis-struct-06, 11 September 2019, 401 . 404 [FIPS-180-4] 405 National Institute of Standards and Technology, "Secure 406 Hash Standard", FIPS PUB 180-4, August 2015. 408 [FIPS-202] National Institute of Standards and Technology, "SHA-3 409 Standard: Permutation-Based Hash and Extendable-Output 410 Functions", FIPS PUB 202, August 2015. 412 [COSE] Schaad, J., "CBOR Object Signing and Encryption (COSE)", 413 RFC 8152, DOI 10.17487/RFC8152, July 2017, 414 . 416 7. Informative References 418 [CMS] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70, 419 RFC 5652, DOI 10.17487/RFC5652, September 2009, 420 . 422 [ESS] Hoffman, P., Ed., "Enhanced Security Services for S/MIME", 423 RFC 2634, DOI 10.17487/RFC2634, June 1999, 424 . 426 [I-D.ietf-cose-x509] 427 Schaad, J., "CBOR Object Signing and Encryption (COSE): 428 Headers for carrying and referencing X.509 certificates", 429 Work in Progress, Internet-Draft, draft-ietf-cose-x509-04, 430 12 September 2019, 431 . 433 [RFC3174] Eastlake 3rd, D. and P. Jones, "US Secure Hash Algorithm 1 434 (SHA1)", RFC 3174, DOI 10.17487/RFC3174, September 2001, 435 . 437 [RFC6194] Polk, T., Chen, L., Turner, S., and P. Hoffman, "Security 438 Considerations for the SHA-0 and SHA-1 Message-Digest 439 Algorithms", RFC 6194, DOI 10.17487/RFC6194, March 2011, 440 . 442 [SHA-1-collision] 443 Stevens, M., Bursztein, E., Karpman, P., Albertini, A., 444 and Y. Markov, "The first collision for full SHA-1", 445 February 2017, 446 . 448 Author's Address 450 Jim Schaad 451 August Cellars 453 Email: ietf@augustcellars.com