Network Working Group J. Kapp Request for Comments: 2286 Reaper Technologies Category: Informational February 1998
Test Cases for HMAC-RIPEMD160 and HMAC-RIPEMD128
Status of this Memo
This memo provides information for the Internet community. It does not specify an Internet standard of any kind. Distribution of this memo is unlimited.
Copyright Notice
Copyright (C) The Internet Society (1998). All Rights Reserved.
Abstract
This document provides two sets of test cases for HMAC-RIPEMD160 and HMAC-RIPEMD128, respectively. HMAC-RIPEMD160 and HMAC-RIPEMD128 are two constructs of the HMAC [HMAC] message authentication function using the RIPEMD-160 and RIPEMD-128 [RIPE] hash functions. The test cases and results provided in this document are meant to be used as a conformance test for HMAC-RIPEMD160 and HMAC-RIPEMD128 implementations.
The general method for constructing a HMAC message authentication function using a particular hash function is described in section 2 of [HMAC].
In sections 2 and 3 test cases for HMAC-RIPEMD160 and HMAC-RIPEMD128, respectively are provided. Each case includes the key, the data, and the result. The values of keys and data are either hexadecimal numbers (prefixed by "0x") or ASCII character strings in double quotes. If a value is an ASCII character string, then the HMAC computation for the corresponding test case DOES NOT include the trailing null character ('\0') in the string.
The C source code of the functions used to generate HMAC-RIPEMD160 and HMAC-RIPEMD128 results is listed in the Appendix. Please Note that the functions provided are implemented in such a way as to be simple and easy to understand as a result they are not optimized in any way. The C source code for computing HMAC-MD5 can be found in [MD5].
Kapp Informational [Page 1]
RFC 2286 Test Cases: HMAC-RIPEMD160, HMAC-RIPEMD128 February 1998
test_case = 6 key = 0xaa repeated 80 times key_len = 80 data = "Test Using Larger Than Block-Size Key - Hash Key First" data_len = 54 digest = 0x6466ca07ac5eac29e1bd523e5ada7605b791fd8b
test_case = 7 key = 0xaa repeated 80 times
Kapp Informational [Page 2]
RFC 2286 Test Cases: HMAC-RIPEMD160, HMAC-RIPEMD128 February 1998
key_len = 80 data = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data" data_len = 73 digest = 0x69ea60798d71616cce5fd0871e23754cd75d5a0a
test_case = 7 key = 0xaa repeated 80 times key_len = 80 data = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data" data_len = 73 digest = 0x5c6bec96793e16d40690c237635f30c5
This document raises no security issues. Discussion on the strength of the HMAC construction can be found in [HMAC].
References
[HMAC] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed-Hashing for Message Authentication", RFC 2104, February 1997.
[MD5] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, April 1992.
[OG] Oehler, M., and R. Glenn, "HMAC-MD5 IP Authentication with Replay Prevention", RFC 2085, February 1997
[CG] Chang, S., and R. Glenn, "Test Cases for HMAC-MD5 and HMAC-SHA-1", RFC 2202, September 1997.
[RIPE] Dobbertin, H., Bosselaers A., and Preneel, B. "RIPEMD-160: A Strengthened Version of RIPEMD" April 1996
Author's Address
Justin S. Kapp Reaper Technologies The Post Office, Dunsop Bridge Clitheroe, Lancashire. BB7 3BB. United Kingdom
EMail: skapp@reapertech.com
Kapp Informational [Page 4]
RFC 2286 Test Cases: HMAC-RIPEMD160, HMAC-RIPEMD128 February 1998
Appendix
This code which implements HMAC-RIPEMD160 using an existing RIPEMD- 160 library. It assumes that the RIPEMD-160 library has similar API's as those of the MD5 code described in RFC 1321. The code for HMAC-MD5, is similar, this HMAC-MD5 code is also listed in RFC 2104. To adapt this example to produce the HMAC-RIPEMD128 then replace each occurance of 'RMD160' with 'RMD128'.
RFC 2286 Test Cases: HMAC-RIPEMD160, HMAC-RIPEMD128 February 1998
where K is an n byte key ipad is the byte 0x36 repeated 64 times opad is the byte 0x5c repeated 64 times and text is the data being protected */
/* start out by storing key in pads */ memset(k_ipad, 0x36, sizeof(k_ipad)); memset(k_opad, 0x5c, sizeof(k_opad));
/* XOR key with ipad and opad values */ for (i=0; i<keylen; i++) { k_ipad[i] ^= key[i]; k_opad[i] ^= key[i]; }
/* perform inner RIPEMD-160 */
RMD160Init(&context); /* init context for 1st pass */ RMD160Update(&context, k_ipad, 64); /* start with inner pad */ RMD160Update(&context, input, len); /* then text of datagram */ RMD160Final(digest, &context); /* finish up 1st pass */
/* perform outer RIPEMD-160 */ RMD160Init(&context); /* init context for 2nd pass */ RMD160Update(&context, k_opad, 64); /* start with outer pad */ /* then results of 1st hash */ RMD160Update(&context, digest, RMD160_DIGESTSIZE); RMD160Final(digest, &context); /* finish up 2nd pass */
RFC 2286 Test Cases: HMAC-RIPEMD160, HMAC-RIPEMD128 February 1998
Full Copyright Statement
Copyright (C) The Internet Society (1998). All Rights Reserved.
This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.
The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.
This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.