DI Management Home > Cryptography > Test vectors for HMAC-SHA-3

Test vectors for HMAC-SHA-3


This page provides provisional test vectors for the HMAC-SHA-3 family of message authentication schemes using the new SHA-3 secure hash algorithm (Keccak).

Contents: Technical Details | Test Vectors | References | See Also | Contact us

Technical Details

The HMAC algorithm is described in RFC 2104. It is designed to work with any iterative cryptographic hash function.

These tests use the same test cases from RFC 4231, plus some extra tests with key sizes greater than the longest block size for SHA-3 (144 bytes).

We assume that the block lengths (B) to be used in the HMAC algorithm are as follows, based on The Keccak Reference document, where H denotes the cryptographic hash function, L is the byte-length of the hash output and B is the byte-length of the digest input block.

HLB
SHA-3-22428144
SHA-3-25632136
SHA-3-38448104
SHA-3-5126472

The test vectors here were produced using our own implementation (no warranties, etc). Each test case has a link to a file which details the intermediate values used in the computations.

Test Vectors

Test Case 1: Key 20 bytes, Data "Hi There" (8 bytes): testcase1.txt
Key =            0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
                 0b0b0b0b
Data =           4869205468657265
HMAC-SHA-3-224 = b73d595a2ba9af815e9f2b4e53e78581
                 ebd34a80b3bbaac4e702c4cc
HMAC-SHA-3-256 = 9663d10c73ee294054dc9faf95647cb9
                 9731d12210ff7075fb3d3395abfb9821
HMAC-SHA-3-384 = 892dfdf5d51e4679bf320cd16d4c9dc6
                 f749744608e003add7fba894acff8736
                 1efa4e5799be06b6461f43b60ae97048
HMAC-SHA-3-512 = 8852c63be8cfc21541a4ee5e5a9a852f
                 c2f7a9adec2ff3a13718ab4ed81aaea0
                 b87b7eb397323548e261a64e7fc75198
                 f6663a11b22cd957f7c8ec858a1c7755
Test Case 2: Test with a key shorter than the length of the HMAC output. Key: "Jefe" (4 bytes), Data: "what do ya want for nothing?" (28 bytes): testcase2.txt
Key =            4a656665
Data =           7768617420646f2079612077616e7420
                 666f72206e6f7468696e673f
HMAC-SHA-3-224 = e824fec96c074f22f99235bb942da198
                 2664ab692ca8501053cbd414
HMAC-SHA-3-256 = aa9aed448c7abc8b5e326ffa6a01cded
                 f7b4b831881468c044ba8dd4566369a1
HMAC-SHA-3-384 = 5af5c9a77a23a6a93d80649e562ab77f
                 4f3552e3c5caffd93bdf8b3cfc6920e3
                 023fc26775d9df1f3c94613146ad2c9d
HMAC-SHA-3-512 = c2962e5bbe1238007852f79d814dbbec
                 d4682e6f097d37a363587c03bfa2eb08
                 59d8d9c701e04cececfd3dd7bfd438f2
                 0b8b648e01bf8c11d26824b96cebbdcb
Test Case 3: Test with a combined length of key and data that is larger than 64 bytes (= block-size of SHA-224 and SHA-256). Key 20 bytes, Data 50 bytes: testcase3.txt
Key =            aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaa
Data =           dddddddddddddddddddddddddddddddd
                 dddddddddddddddddddddddddddddddd
                 dddddddddddddddddddddddddddddddd
                 dddd
HMAC-SHA-3-224 = 770df38c99d6e2bacd68056dcfe07d4c
                 89ae20b2686a6185e1faa449
HMAC-SHA-3-256 = 95f43e50f8df80a21977d51a8db3ba57
                 2dcd71db24687e6f86f47c1139b26260
HMAC-SHA-3-384 = 4243c29f2201992ff96441e3b91ff81d
                 8c601d706fbc83252684a4bc51101ca9
                 b2c06ddd03677303c502ac5331752a3c
HMAC-SHA-3-512 = eb0ed9580e0ec11fc66cbb646b1be904
                 eaff6da4556d9334f65ee4b2c8573915
                 7bae9027c51505e49d1bb81cfa55e682
                 2db55262d5a252c088a29a5e95b84a66
Test Case 4: Test with a combined length of key and data that is larger than 64 bytes (= block-size of SHA-224 and SHA-256). Key 25 bytes, Data 50 bytes: testcase4.txt
Key =            0102030405060708090a0b0c0d0e0f10
                 111213141516171819
Data =           cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd
                 cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd
                 cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd
                 cdcd
HMAC-SHA-3-224 = 305a8f2dfb94bad28861a03cbc4d590f
                 ebe775c58cb4961c28428a0b
HMAC-SHA-3-256 = 6331ba9b4af5804a68725b3663eb7481
                 4494b63c6093e35fb320a85d507936fd
HMAC-SHA-3-384 = b730724d3d4090cda1be799f63acbbe3
                 89fef7792fc18676fa5453aab3986646
                 50ed029c3498bbe8056f06c658e1e693
HMAC-SHA-3-512 = b46193bb59f4f696bf702597616da91e
                 2a4558a593f4b015e69141ba81e1e50e
                 a580834c2b87f87baa25a3a03bfc9bb3
                 89847f2dc820beae69d30c4bb75369cb
Test Case 5: Test with a truncation of output to 128 bits. Key 20 bytes, Data "Test With Truncation" (20 bytes): testcase5.txt
Key =            0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
                 0c0c0c0c
Data =           546573742057697468205472756e6361
                 74696f6e
HMAC-SHA-3-224 = f52bbcfd654264e7133085c5e69b72c3
HMAC-SHA-3-256 = 745e7e687f8335280d54202ef13cecc6
HMAC-SHA-3-384 = fa9aea2bc1e181e47cbb8c3df243814d
HMAC-SHA-3-512 = 04c929fead434bba190dacfa554ce3f5
Test Case 6: Test with a key larger than 128 bytes (= block-size of SHA-384 and SHA-512). Key 131 bytes, Data 54 bytes: testcase6.txt
Key =            aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaa
Data =           54657374205573696e67204c61726765
                 72205468616e20426c6f636b2d53697a
                 65204b6579202d2048617368204b6579
                 204669727374
HMAC-SHA-3-224 = e7a52dfa45f95a217c100066b239aa8a
                 d519be9b35d667268b1b57ff
HMAC-SHA-3-256 = b4d0cdee7ec2ba81a88b869189583123
                 00a15622377929a054a9ce3ae1fac2b6
HMAC-SHA-3-384 = d62482ef601d7847439b55236e967938
                 8ffcd53c62cd126f39be6ea63de762e2
                 6cd5974cb9a8de401b786b5555040f6f
HMAC-SHA-3-512 = d05888a6ebf8460423ea7bc85ea4ffda
                 847b32df32291d2ce115fd187707325c
                 7ce4f71880d91008084ce24a38795d20
                 e6a28328a0f0712dc38253370da3ebb5
Test Case 6a: Test with a key larger than 144 bytes (= block-size of SHA-3-224). Key 147 bytes, Data 54 bytes: testcase6a.txt
Key =            aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaa
Data =           54657374205573696e67204c61726765
                 72205468616e20426c6f636b2d53697a
                 65204b6579202d2048617368204b6579
                 204669727374
HMAC-SHA-3-224 = 4dc9ce183281ce751bfc55667c074a07
                 7e0751bf40c53f9e6a83250f
HMAC-SHA-3-256 = ea68d6571dcb4669fd97c5953269c741
                 26a102b1f97af6bdba5533cde51e8acc
HMAC-SHA-3-384 = 0c0817f74b182baeb933e4e7074a0cb1
                 c619dce7f11549ec9505d2d6c82959d4
                 51bd31654f58ebd569ac6323dc62d408
HMAC-SHA-3-512 = 0f01da58d52a7e4ef3386bf7edb66625
                 ff5c25385c3887d3ac9918c0828ba80c
                 0db2de5bca3398f9694f7fd51535203a
                 9e1f73ac4d9019383b5520bc26d2d654
Test Case 7: Test with a key and data that is larger than 128 bytes (= block-size of SHA-384 and SHA-512). Key 131 bytes, Data 152 bytes: testcase7.txt
Key =            aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaa
Data =           54686973206973206120746573742075
                 73696e672061206c6172676572207468
                 616e20626c6f636b2d73697a65206b65
                 7920616e642061206c61726765722074
                 68616e20626c6f636b2d73697a652064
                 6174612e20546865206b6579206e6565
                 647320746f2062652068617368656420
                 6265666f7265206265696e6720757365
                 642062792074686520484d414320616c
                 676f726974686d2e
HMAC-SHA-3-224 = ba13009405a929f398b348885caa5419
                 191bb948ada32194afc84104
HMAC-SHA-3-256 = 1fdc8cb4e27d07c10d897dec39c21779
                 2a6e64fa9c63a77ce42ad106ef284e02
HMAC-SHA-3-384 = 4860ea191ac34994cf88957afe5a836e
                 f36e4cc1a66d75bf77defb7576122d75
                 f60660e4cf731c6effac06402787e2b9
HMAC-SHA-3-512 = 2c6b9748d35c4c8db0b4407dd2ed2381
                 f133bdbd1dfaa69e30051eb6badfcca6
                 4299b88ae05fdbd3dd3dd7fe627e42e3
                 9e48b0fe8c7f1e85f2dbd52c2d753572
Test Case 7a: Test with a key larger than 144 bytes (= block-size of SHA-3-224). Key 147 bytes, Data 152 bytes: testcase7a.txt
Key =            aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                 aaaaaa
Data =           54686973206973206120746573742075
                 73696e672061206c6172676572207468
                 616e20626c6f636b2d73697a65206b65
                 7920616e642061206c61726765722074
                 68616e20626c6f636b2d73697a652064
                 6174612e20546865206b6579206e6565
                 647320746f2062652068617368656420
                 6265666f7265206265696e6720757365
                 642062792074686520484d414320616c
                 676f726974686d2e
HMAC-SHA-3-224 = 92649468be236c3c72c189909c063b13
                 f994be05749dc91310db639e
HMAC-SHA-3-256 = fdaa10a0299aecff9bb411cf2d7748a4
                 022e4a26be3fb5b11b33d8c2b7ef5484
HMAC-SHA-3-384 = fe9357e3cfa538eb0373a2ce8f1e26ad
                 6590afdaf266f1300522e8896d27e73f
                 654d0631c8fa598d4bb82af6b744f4f5
HMAC-SHA-3-512 = 6adc502f14e27812402fc81a807b28bf
                 8a53c87bea7a1df6256bf66f5de1a4cb
                 741407ad15ab8abc136846057f881969
                 fbb159c321c904bfb557b77afb7778c8

References

See Also

Test vectors for SHA-1, SHA-2 and SHA-3: which summarises useful test vectors for the secure hash algorithms SHA-1, SHA-2 and the new SHA-3.

CryptoSys API, a developer's toolkit of cryptographic functions, now with SHA-3.

Wolfgang Ehrhardt's preliminary Pascal/Delphi Keccak implementation.

Contact

For more information, or to comment on this page, or to tell us we have made a mistake, please send us a message.

This page first published 2 November 2012. Last updated 15 November 2012.