From 8de24e9641bd8ebc6fbf54edc819ef8e29943073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Sun, 19 Jul 1998 23:58:51 +0200 Subject: [PATCH] Added testcases for hmac. Rev: src/modules/_Crypto/testsuite.in:1.11 --- src/modules/_Crypto/testsuite.in | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/modules/_Crypto/testsuite.in b/src/modules/_Crypto/testsuite.in index 75ae73e400..5b9a36a2ec 100644 --- a/src/modules/_Crypto/testsuite.in +++ b/src/modules/_Crypto/testsuite.in @@ -201,3 +201,20 @@ test_eq([[Crypto.sha()->update("abc")->digest()]], [[Crypto.hex_to_string("a9993e364706816aba3e25717850c26c9cd0d89d")]]) ]]) + +// HMAC +// Test vectors for md5 from RFC-2104 +test_eq([[Crypto.hmac(Crypto.md5)("\013" * 16)("Hi There")]], + [[Crypto.hex_to_string("9294727a3638bb1c13f48ef8158bfc9d")]]) +test_eq([[Crypto.hmac(Crypto.md5)("Jefe")("what do ya want for nothing?")]], + [[Crypto.hex_to_string("750c783e6ab0b503eaa86e310a5db738")]]) +test_eq([[Crypto.hmac(Crypto.md5)("\252" * 16)("\335" * 50)]], + [[Crypto.hex_to_string("56be34521d144c88dbb8c733f0e8b3f6")]]) + +// Similar test vectors for sha; not verified with other implementations +test_eq([[Crypto.hmac(Crypto.sha)("\013" * 16)("Hi There")]], + [[Crypto.hex_to_string("675b0b3a1b4ddf4e124872da6c2f632bfed957e9")]]) +test_eq([[Crypto.hmac(Crypto.sha)("Jefe")("what do ya want for nothing?")]], + [[Crypto.hex_to_string("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79")]]) +test_eq([[Crypto.hmac(Crypto.sha)("\252" * 16)("\335" * 50)]], + [[Crypto.hex_to_string("d730594d167e35d5956fd8003d0db3d3f46dc7bb")]]) -- GitLab