rfc9054v2.txt   rfc9054.txt 
skipping to change at line 15 skipping to change at line 15
ISSN: 2070-1721 ISSN: 2070-1721
CBOR Object Signing and Encryption (COSE): Hash Algorithms CBOR Object Signing and Encryption (COSE): Hash Algorithms
Abstract Abstract
The CBOR Object Signing and Encryption (COSE) syntax (see RFC 9052) The CBOR Object Signing and Encryption (COSE) syntax (see RFC 9052)
does not define any direct methods for using hash algorithms. There does not define any direct methods for using hash algorithms. There
are, however, circumstances where hash algorithms are used, such as are, however, circumstances where hash algorithms are used, such as
indirect signatures, where the hash of one or more contents are indirect signatures, where the hash of one or more contents are
signed, and an X.509 certificate or other object identification by signed, and identification of an X.509 certificate or other object by
the use of a fingerprint. This document defines hash algorithms that the use of a fingerprint. This document defines hash algorithms that
are identified by COSE algorithm identifiers. are identified by COSE algorithm identifiers.
Status of This Memo Status of This Memo
This document is not an Internet Standards Track specification; it is This document is not an Internet Standards Track specification; it is
published for informational purposes. published for informational purposes.
This document is a product of the Internet Engineering Task Force This document is a product of the Internet Engineering Task Force
(IETF). It represents the consensus of the IETF community. It has (IETF). It represents the consensus of the IETF community. It has
skipping to change at line 69 skipping to change at line 69
3.3. SHAKE Algorithms 3.3. SHAKE Algorithms
4. IANA Considerations 4. IANA Considerations
4.1. COSE Algorithm Registry 4.1. COSE Algorithm Registry
5. Security Considerations 5. Security Considerations
6. Normative References 6. Normative References
7. Informative References 7. Informative References
Author's Address Author's Address
1. Introduction 1. Introduction
The CBOR Object Signing and Encryption (COSE) syntax does not define The CBOR Object Signing and Encryption (COSE) syntax [RFC9052] does
any direct methods for the use of hash algorithms. It also does not not define any direct methods for the use of hash algorithms. It
define a structure syntax that is used to encode a digested object also does not define a structure syntax that is used to encode a
structure along the lines of the DigestedData ASN.1 structure in digested object structure along the lines of the DigestedData ASN.1
[CMS]. This omission was intentional, as a structure consisting of structure in [CMS]. This omission was intentional, as a structure
just a digest identifier, the content, and a digest value does not, consisting of just a digest identifier, the content, and a digest
by itself, provide any strong security service. Additionally, an value does not, by itself, provide any strong security service.
application is going to be better off defining this type of structure Additionally, an application is going to be better off defining this
so that it can include any additional data that needs to be hashed, type of structure so that it can include any additional data that
as well as methods of obtaining the data. needs to be hashed, as well as methods of obtaining the data.
While the above is true, there are some cases where having some While the above is true, there are some cases where having some
standard hash algorithms defined for COSE with a common identifier standard hash algorithms defined for COSE with a common identifier
makes a great deal of sense. Two of the cases where these are going makes a great deal of sense. Two of the cases where these are going
to be used are: to be used are:
* Indirect signing of content, and * Indirect signing of content, and
* Object identification. * Object identification.
skipping to change at line 131 skipping to change at line 131
indirect signatures -- that is, using the hash as part of the indirect signatures -- that is, using the hash as part of the
signature or using the hash as part of the body to be signed. Other signature or using the hash as part of the body to be signed. Other
uses of hash functions may not require the same level of strength. uses of hash functions may not require the same level of strength.
This document contains some hash functions that are not designed to This document contains some hash functions that are not designed to
be used for cryptographic operations. An application that is using a be used for cryptographic operations. An application that is using a
hash function needs to carefully evaluate exactly what hash hash function needs to carefully evaluate exactly what hash
properties are needed and which hash functions are going to provide properties are needed and which hash functions are going to provide
them. Applications should also make sure that the ability to change them. Applications should also make sure that the ability to change
hash functions is part of the base design, as cryptographic advances hash functions is part of the base design, as cryptographic advances
are sure to reduce the strength of a hash function [BCP201]. are sure to reduce the strength of any given hash function [BCP201].
A hash function is a map from one, normally large, bit string to a A hash function is a map from one, normally large, bit string to a
second, usually smaller, bit string. As the number of possible input second, usually smaller, bit string. As the number of possible input
values is far greater than the number of possible output values, it values is far greater than the number of possible output values, it
is inevitable that there are going to be collisions. The trick is to is inevitable that there are going to be collisions. The trick is to
make sure that it is difficult to find two values that are going to make sure that it is difficult to find two values that are going to
map to the same output value. A "Collision Attack" is one where an map to the same output value. A "Collision Attack" is one where an
attacker can find two different messages that have the same hash attacker can find two different messages that have the same hash
value. A hash function that is susceptible to practical collision value. A hash function that is susceptible to practical collision
attacks SHOULD NOT be used for a cryptographic purpose. The attacks SHOULD NOT be used for a cryptographic purpose. The
skipping to change at line 164 skipping to change at line 164
collection of values to find a set of possible candidates; the collection of values to find a set of possible candidates; the
candidates can then be checked to see if they can successfully be candidates can then be checked to see if they can successfully be
used. A simple example of this is the classic fingerprint of a used. A simple example of this is the classic fingerprint of a
certificate. If the fingerprint is used to verify that it is the certificate. If the fingerprint is used to verify that it is the
correct certificate, then that usage is a cryptographic one and is correct certificate, then that usage is a cryptographic one and is
subject to the warning above about collision attack. If, however, subject to the warning above about collision attack. If, however,
the fingerprint is used to sort through a collection of certificates the fingerprint is used to sort through a collection of certificates
to find those that might be used for the purpose of verifying a to find those that might be used for the purpose of verifying a
signature, a simple filter capability is sufficient. In this case, signature, a simple filter capability is sufficient. In this case,
one still needs to confirm that the public key validates the one still needs to confirm that the public key validates the
signature (and the certificate is trusted), and all certificates that signature (and that the certificate is trusted), and all certificates
don't contain a key that validates the signature can be discarded as that don't contain a key that validates the signature can be
false positives. discarded as false positives.
To distinguish between these two cases, a new value in the To distinguish between these two cases, a new value in the
Recommended column of the "COSE Algorithms" registry has been added. Recommended column of the "COSE Algorithms" registry has been added.
"Filter Only" indicates that the only purpose of a hash function "Filter Only" indicates that the only purpose of a hash function
should be to filter results; it is not intended for applications that should be to filter results; it is not intended for applications that
require a cryptographically strong algorithm. require a cryptographically strong algorithm.
2.1. Example CBOR Hash Structure 2.1. Example CBOR Hash Structure
[COSE] did not provide a default structure for holding a hash value [COSE] did not provide a default structure for holding a hash value
skipping to change at line 199 skipping to change at line 199
specific. specific.
* Additional data. This can be something as simple as a random * Additional data. This can be something as simple as a random
value (i.e., salt) to make finding hash collisions slightly harder value (i.e., salt) to make finding hash collisions slightly harder
(because the payload handed to the application could have been (because the payload handed to the application could have been
selected to have a collision), or as complicated as a set of selected to have a collision), or as complicated as a set of
processing instructions that is used with the object that is processing instructions that is used with the object that is
pointed to. The additional data can be dealt with in a number of pointed to. The additional data can be dealt with in a number of
ways, prepending or appending to the content, but it is strongly ways, prepending or appending to the content, but it is strongly
suggested that either it be a fixed known size, or the lengths of suggested that either it be a fixed known size, or the lengths of
the pieces being hashed be included. (Encoding as a CBOR array the pieces being hashed be included so that the resulting byte
accomplishes this requirement.) string has a unique interpretation as the additional data.
(Encoding as a CBOR array accomplishes this requirement.)
An example of a structure that permits all of the above fields to An example of a structure that permits all of the above fields to
exist would look like the following: exist would look like the following:
COSE_Hash_V = ( COSE_Hash_V = (
1 : int / tstr, # Algorithm identifier 1 : int / tstr, # Algorithm identifier
2 : bstr, # Hash value 2 : bstr, # Hash value
? 3 : tstr, # Location of object that was hashed ? 3 : tstr, # Location of object that was hashed
? 4 : any # object containing other details and things ? 4 : any # object containing other details and things
) )
skipping to change at line 252 skipping to change at line 253
longer be used, the algorithm will be registered with the longer be used, the algorithm will be registered with the
recommendation of "Filter Only". This provides guidance about when recommendation of "Filter Only". This provides guidance about when
the algorithm is safe for use, while discouraging usage where it is the algorithm is safe for use, while discouraging usage where it is
not safe. not safe.
The COSE capabilities for this algorithm is an empty array. The COSE capabilities for this algorithm is an empty array.
+=====+======+=============+==============+===========+=============+ +=====+======+=============+==============+===========+=============+
|Name |Value | Description | Capabilities | Reference | Recommended | |Name |Value | Description | Capabilities | Reference | Recommended |
+=====+======+=============+==============+===========+=============+ +=====+======+=============+==============+===========+=============+
|SHA-1|-14 | SHA-1 Hash | [kty] | RFC 9054 | Filter Only | |SHA-1|-14 | SHA-1 Hash | [] | RFC 9054 | Filter Only |
+-----+------+-------------+--------------+-----------+-------------+ +-----+------+-------------+--------------+-----------+-------------+
Table 1: SHA-1 Hash Algorithm Table 1: SHA-1 Hash Algorithm
3.2. SHA-2 Hash Algorithms 3.2. SHA-2 Hash Algorithms
The family of SHA-2 hash algorithms [FIPS-180-4] was designed by the The family of SHA-2 hash algorithms [FIPS-180-4] was designed by the
United States National Security Agency and published in 2001. Since United States National Security Agency and published in 2001. Since
that time, some additional algorithms have been added to the original that time, some additional algorithms have been added to the original
set to deal with length-extension attacks and some performance set to deal with length-extension attacks and some performance
skipping to change at line 276 skipping to change at line 277
There are a number of different parameters for the SHA-2 hash There are a number of different parameters for the SHA-2 hash
functions. The set of hash functions that has been chosen for functions. The set of hash functions that has been chosen for
inclusion in this document is based on those different parameters and inclusion in this document is based on those different parameters and
some of the trade-offs involved. some of the trade-offs involved.
* *SHA-256/64* provides a truncated hash. The length of the * *SHA-256/64* provides a truncated hash. The length of the
truncation is designed to allow for smaller transmission size. truncation is designed to allow for smaller transmission size.
The trade-off is that the odds that a collision will occur The trade-off is that the odds that a collision will occur
increase proportionally. Use of this hash function requires increase proportionally. Use of this hash function requires
analysis of the potential problems that could result from a analysis of the potential problems that could result from a
collision, or it must be limited to where the function of the hash collision, or it must be limited to where the purpose of the hash
is noncryptographic. is noncryptographic.
The latter is the case for [COSE-x509]. The hash value is used to The latter is the case for some of the scenarios identified in
select possible certificates; if there are multiple choices [COSE-x509], specifically, for the cases when the hash value is
remaining, then each choice can be tested by using the public key. used to select among possible certificates: if there are multiple
choices remaining, then each choice can be tested by using the
public key.
* *SHA-256* is probably the most common hash function used * *SHA-256* is probably the most common hash function used
currently. SHA-256 is an efficient hash algorithm for 32-bit currently. SHA-256 is an efficient hash algorithm for 32-bit
hardware. hardware.
* *SHA-384* and *SHA-512* hash functions are efficient for 64-bit * *SHA-384* and *SHA-512* hash functions are efficient for 64-bit
hardware. hardware.
* *SHA-512/256* provides a hash function that runs more efficiently * *SHA-512/256* provides a hash function that runs more efficiently
on 64-bit hardware but offers the same security levels as SHA-256. on 64-bit hardware but offers the same security level as SHA-256.
The COSE capabilities array for these algorithms is empty. The COSE capabilities array for these algorithms is empty.
+===========+=====+===========+==============+=========+============+ +===========+=====+===========+==============+=========+============+
|Name |Value|Description| Capabilities |Reference|Recommended | |Name |Value|Description| Capabilities |Reference|Recommended |
+===========+=====+===========+==============+=========+============+ +===========+=====+===========+==============+=========+============+
|SHA-256/64 |-15 |SHA-2 | [kty] |RFC 9054 |Filter Only | |SHA-256/64 |-15 |SHA-2 | [] |RFC 9054 |Filter Only |
| | |256-bit | | | | | | |256-bit | | | |
| | |Hash | | | | | | |Hash | | | |
| | |truncated | | | | | | |truncated | | | |
| | |to 64-bits | | | | | | |to 64-bits | | | |
+-----------+-----+-----------+--------------+---------+------------+ +-----------+-----+-----------+--------------+---------+------------+
|SHA-256 |-16 |SHA-2 | [kty] |RFC 9054 |Yes | |SHA-256 |-16 |SHA-2 | [] |RFC 9054 |Yes |
| | |256-bit | | | | | | |256-bit | | | |
| | |Hash | | | | | | |Hash | | | |
+-----------+-----+-----------+--------------+---------+------------+ +-----------+-----+-----------+--------------+---------+------------+
|SHA-384 |-43 |SHA-2 | [kty] |RFC 9054 |Yes | |SHA-384 |-43 |SHA-2 | [] |RFC 9054 |Yes |
| | |384-bit | | | | | | |384-bit | | | |
| | |Hash | | | | | | |Hash | | | |
+-----------+-----+-----------+--------------+---------+------------+ +-----------+-----+-----------+--------------+---------+------------+
|SHA-512 |-44 |SHA-2 | [kty] |RFC 9054 |Yes | |SHA-512 |-44 |SHA-2 | [] |RFC 9054 |Yes |
| | |512-bit | | | | | | |512-bit | | | |
| | |Hash | | | | | | |Hash | | | |
+-----------+-----+-----------+--------------+---------+------------+ +-----------+-----+-----------+--------------+---------+------------+
|SHA-512/256|-17 |SHA-2 | [kty] |RFC 9054 |Yes | |SHA-512/256|-17 |SHA-2 | [] |RFC 9054 |Yes |
| | |512-bit | | | | | | |512-bit | | | |
| | |Hash | | | | | | |Hash | | | |
| | |truncated | | | | | | |truncated | | | |
| | |to 256-bits| | | | | | |to 256-bits| | | |
+-----------+-----+-----------+--------------+---------+------------+ +-----------+-----+-----------+--------------+---------+------------+
Table 2: SHA-2 Hash Algorithms Table 2: SHA-2 Hash Algorithms
3.3. SHAKE Algorithms 3.3. SHAKE Algorithms
skipping to change at line 345 skipping to change at line 348
Unlike the SHA-2 hash functions, no algorithm identifier is created Unlike the SHA-2 hash functions, no algorithm identifier is created
for shorter lengths. The length of the hash value stored is 256 bits for shorter lengths. The length of the hash value stored is 256 bits
for SHAKE-128 and 512 bits for SHAKE-256. for SHAKE-128 and 512 bits for SHAKE-256.
The COSE capabilities array for these algorithms is empty. The COSE capabilities array for these algorithms is empty.
+========+=====+=============+==============+=========+=============+ +========+=====+=============+==============+=========+=============+
|Name |Value|Description | Capabilities |Reference| Recommended | |Name |Value|Description | Capabilities |Reference| Recommended |
+========+=====+=============+==============+=========+=============+ +========+=====+=============+==============+=========+=============+
|SHAKE128|-18 |SHAKE-128 | [kty] |RFC 9054 | Yes | |SHAKE128|-18 |SHAKE-128 | [] |RFC 9054 | Yes |
| | |256-bit Hash | | | | | | |256-bit Hash | | | |
| | |Value | | | | | | |Value | | | |
+--------+-----+-------------+--------------+---------+-------------+ +--------+-----+-------------+--------------+---------+-------------+
|SHAKE256|-45 |SHAKE-256 | [kty] |RFC 9054 | Yes | |SHAKE256|-45 |SHAKE-256 | [] |RFC 9054 | Yes |
| | |512-bit Hash | | | | | | |512-bit Hash | | | |
| | |Value | | | | | | |Value | | | |
+--------+-----+-------------+--------------+---------+-------------+ +--------+-----+-------------+--------------+---------+-------------+
Table 3: SHAKE Hash Functions Table 3: SHAKE Hash Functions
4. IANA Considerations 4. IANA Considerations
4.1. COSE Algorithm Registry 4.1. COSE Algorithm Registry
skipping to change at line 387 skipping to change at line 390
require collision resistance. As a result of this addition, IANA has require collision resistance. As a result of this addition, IANA has
added this document as a reference for the "COSE Algorithms" added this document as a reference for the "COSE Algorithms"
registry. registry.
5. Security Considerations 5. Security Considerations
Protocols need to perform a careful analysis of the properties of a Protocols need to perform a careful analysis of the properties of a
hash function that are needed and how they map onto the possible hash function that are needed and how they map onto the possible
attacks. In particular, one needs to distinguish between those uses attacks. In particular, one needs to distinguish between those uses
that need the cryptographic properties, such as collision resistance, that need the cryptographic properties, such as collision resistance,
and properties that correspond to possible object identification. and uses that only need properties that correspond to possible object
The different attacks correspond to who or what is being protected: identification. The different attacks correspond to who or what is
is it the originator that is the attacker or a third party? This is being protected: is it the originator that is the attacker or a third
the difference between collision resistance and second pre-image party? This is the difference between collision resistance and
resistance. As a general rule, longer hash values are "better" than second pre-image resistance. As a general rule, longer hash values
short ones, but trade-offs of transmission size, timeliness, and are "better" than short ones, but trade-offs of transmission size,
security all need to be included as part of this analysis. In many timeliness, and security all need to be included as part of this
cases, the value being hashed is a public value and, as such, pre- analysis. In many cases, the value being hashed is a public value
image resistance is not part of this analysis. and, as such, (first) pre-image resistance is not part of this
analysis.
Algorithm agility needs to be considered a requirement for any use of Algorithm agility needs to be considered a requirement for any use of
hash functions [BCP201]. As with any cryptographic function, hash hash functions [BCP201]. As with any cryptographic function, hash
functions are under constant attack, and the cryptographic strength functions are under constant attack, and the cryptographic strength
of hash algorithms will be reduced over time. of hash algorithms will be reduced over time.
6. Normative References 6. Normative References
[FIPS-180-4] [FIPS-180-4]
NIST, "Secure Hash Standard", FIPS PUB 180-4, NIST, "Secure Hash Standard", FIPS PUB 180-4,
skipping to change at line 427 skipping to change at line 431
<https://www.rfc-editor.org/info/rfc2119>. <https://www.rfc-editor.org/info/rfc2119>.
[RFC3174] Eastlake 3rd, D. and P. Jones, "US Secure Hash Algorithm 1 [RFC3174] Eastlake 3rd, D. and P. Jones, "US Secure Hash Algorithm 1
(SHA1)", RFC 3174, DOI 10.17487/RFC3174, September 2001, (SHA1)", RFC 3174, DOI 10.17487/RFC3174, September 2001,
<https://www.rfc-editor.org/info/rfc3174>. <https://www.rfc-editor.org/info/rfc3174>.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
May 2017, <https://www.rfc-editor.org/info/rfc8174>. May 2017, <https://www.rfc-editor.org/info/rfc8174>.
[RFC9052] Schaad, J., "CBOR Object Signing and Encryption (COSE):
Structures and Process", RFC 9052, DOI 10.17487/RFC9052,
March 2022, <https://www.rfc-editor.org/info/rfc9052>.
7. Informative References 7. Informative References
[BCP201] Housley, R., "Guidelines for Cryptographic Algorithm [BCP201] Housley, R., "Guidelines for Cryptographic Algorithm
Agility and Selecting Mandatory-to-Implement Algorithms", Agility and Selecting Mandatory-to-Implement Algorithms",
BCP 201, RFC 7696, November 2015, BCP 201, RFC 7696, November 2015,
<https://www.rfc-editor.org/info/bcp201>. <https://www.rfc-editor.org/info/bcp201>.
[CMS] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70, [CMS] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70,
RFC 5652, DOI 10.17487/RFC5652, September 2009, RFC 5652, DOI 10.17487/RFC5652, September 2009,
<https://www.rfc-editor.org/info/rfc5652>. <https://www.rfc-editor.org/info/rfc5652>.
 End of changes. 18 change blocks. 
39 lines changed or deleted 47 lines changed or added

This html diff was produced by rfcdiff 1.48. The latest version is available from http://tools.ietf.org/tools/rfcdiff/

mirror server hosted at Truenetwork, Russian Federation.