rfc-4231

Identifiers and Test Vectors for HMAC-SHA-224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512

M. Nystrom
date2005-12 streamIETF wgnon working group statusPROPOSED STANDARD pages9 canonicalhttps://www.rfc-editor.org/rfc/rfc4231 doi10.17487/RFC4231 errataview
This document provides test vectors for the HMAC-SHA-224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512 message authentication schemes. It also provides ASN.1 object identifiers and Uniform Resource Identifiers (URIs) to identify use of these schemes in protocols. The test vectors provided in this document may be used for conformance testing. [STANDARDS-TRACK]

Extracted elements (15)

design-rationale §6

The test cases are derived from RFC 2202 (test cases for HMAC-MD5 and HMAC-SHA-1) but use slightly different keys and data, providing a consistent framework for validating SHA-2-based HMAC implementations analogous to the existing SHA-1 test suite.

crypto

interoperability-note §4.1

The test vectors were cross-verified by three independent implementations; an implementation that produces the results in this document should be interoperable with other similar implementations.

crypto

interoperability-note §3.2

When the HMAC-SHA-2 URIs are used in the XML Digital Signatures context, the <ds:HMACOutputLength> element may specify the truncated length of the scheme output.

crypto

normative-requirement §3.1 SHOULD

When the 'algorithm' component in an ASN.1 AlgorithmIdentifier value identifies one of these HMAC-SHA-2 schemes, the 'parameter' component SHOULD be present but have type NULL.

crypto

protocol-element §3.1

ASN.1 object identifiers are allocated for the four HMAC-SHA-2 schemes under the RSADSI digestAlgorithm arc: id-hmacWithSHA224 = {digestAlgorithm 8}, id-hmacWithSHA256 = {digestAlgorithm 9}, id-hmacWithSHA384 = {digestAlgorithm 10}, id-hmacWithSHA512 = {digestAlgorithm 11}.

crypto, registry

protocol-element §1

Four HMAC schemes are defined: HMAC-SHA-224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512, each being the realization of the HMAC message authentication code using the respective SHA-2 hash function as specified in FIPS 180-2.

crypto, security

protocol-element §4.2

Test Case 1 uses a 20-byte key (0x0b repeated) and data 'Hi There' (8 bytes). HMAC-SHA-256 output: b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7.

crypto

protocol-element §4.3

Test Case 2 tests with a key shorter than the HMAC output length: key is 'Jefe' (4 bytes), data is 'what do ya want for nothing?' (28 bytes). HMAC-SHA-256 output: 5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843.

crypto

protocol-element §4.4

Test Case 3 tests with combined key and data length larger than 64 bytes (block size of SHA-224/256): 20-byte key (0xaa repeated), 50-byte data (0xdd repeated). HMAC-SHA-256 output: 773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe.

crypto

protocol-element §4.5

Test Case 4 tests with combined key and data length larger than 64 bytes: 25-byte sequential key (0x01–0x19), 50-byte data (0xcd repeated). HMAC-SHA-256 output: 82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b.

crypto

protocol-element §4.6

Test Case 5 tests truncation of output to 128 bits: 20-byte key (0x0c repeated), data 'Test With Truncation' (20 bytes). HMAC-SHA-256 truncated output: a3b6167473100ee06e0c796c2955552b.

crypto

protocol-element §4.7

Test Case 6 tests with a key larger than 128 bytes (block size of SHA-384/512): 131-byte key (0xaa repeated), data 'Test Using Larger Than Block-Size Key - Hash Key First' (54 bytes). HMAC-SHA-512 output: 80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f352...

crypto

protocol-element §4.8

Test Case 7 tests with both key and data larger than 128 bytes: 131-byte key (0xaa repeated), 152-byte data describing a large-key HMAC scenario. HMAC-SHA-256 output: 9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2.

crypto

protocol-element §3.2

URIs are allocated for the four schemes under the RSA Security PKCS-5 schema namespace: pkcs-5#hmac-sha-224, pkcs-5#hmac-sha-256, pkcs-5#hmac-sha-384, and pkcs-5#hmac-sha-512. These are used in XML-based protocols such as XML Digital Signatures.

crypto, registry

security-consideration §5

The document makes no assertion of the security of the HMAC-SHA-2 schemes for any particular use. Readers are referred to RFC 2104 for a discussion of the general security of the HMAC construction.

crypto, security