| 1 |
(require 'lunit) |
| 2 |
(require 'hmac-sha1) |
| 3 |
|
| 4 |
(luna-define-class test-hmac-sha1 (lunit-test-case)) |
| 5 |
|
| 6 |
(luna-define-method test-hmac-sha1-1 ((case test-hmac-sha1)) |
| 7 |
(lunit-assert |
| 8 |
(string= |
| 9 |
(encode-hex-string (hmac-sha1 "Hi There" (make-string 20 ?\x0b))) |
| 10 |
"b617318655057264e28bc0b6fb378c8ef146be00"))) |
| 11 |
|
| 12 |
(luna-define-method test-hmac-sha1-2 ((case test-hmac-sha1)) |
| 13 |
(lunit-assert |
| 14 |
(string= |
| 15 |
(encode-hex-string (hmac-sha1 "what do ya want for nothing?" "Jefe")) |
| 16 |
"effcdf6ae5eb2fa2d27416d5f184df9c259a7c79"))) |
| 17 |
|
| 18 |
(luna-define-method test-hmac-sha1-3 ((case test-hmac-sha1)) |
| 19 |
(lunit-assert |
| 20 |
(string= |
| 21 |
(encode-hex-string (hmac-sha1 (make-string 50 ?\xdd) (make-string 20 ?\xaa))) |
| 22 |
"125d7342b9ac11cd91a39af48aa17b4f63f175d3"))) |
| 23 |
|
| 24 |
(luna-define-method test-hmac-sha1-4 ((case test-hmac-sha1)) |
| 25 |
(lunit-assert |
| 26 |
(string= |
| 27 |
(encode-hex-string |
| 28 |
(hmac-sha1 |
| 29 |
(make-string 50 ?\xcd) |
| 30 |
(decode-hex-string "0102030405060708090a0b0c0d0e0f10111213141516171819"))) |
| 31 |
"4c9007f4026250c6bc8414f9bf50c86c2d7235da"))) |
| 32 |
|
| 33 |
(luna-define-method test-hmac-sha1-5 ((case test-hmac-sha1)) |
| 34 |
(lunit-assert |
| 35 |
(string= |
| 36 |
(encode-hex-string |
| 37 |
(hmac-sha1 "Test With Truncation" (make-string 20 ?\x0c))) |
| 38 |
"4c1a03424b55e07fe7f27be1d58bb9324a9a5a04"))) |
| 39 |
|
| 40 |
(luna-define-method test-hmac-sha1-6 ((case test-hmac-sha1)) |
| 41 |
(lunit-assert |
| 42 |
(string= |
| 43 |
(encode-hex-string |
| 44 |
(hmac-sha1-96 "Test With Truncation" (make-string 20 ?\x0c))) |
| 45 |
"4c1a03424b55e07fe7f27be1"))) |
| 46 |
|
| 47 |
(luna-define-method test-hmac-sha1-7 ((case test-hmac-sha1)) |
| 48 |
(lunit-assert |
| 49 |
(string= |
| 50 |
(encode-hex-string |
| 51 |
(hmac-sha1 |
| 52 |
"Test Using Larger Than Block-Size Key - Hash Key First" |
| 53 |
(make-string 80 ?\xaa))) |
| 54 |
"aa4ae5e15272d00e95705637ce8a3b55ed402112"))) |
| 55 |
|
| 56 |
(luna-define-method test-hmac-sha1-8 ((case test-hmac-sha1)) |
| 57 |
(lunit-assert |
| 58 |
(string= |
| 59 |
(encode-hex-string |
| 60 |
(hmac-sha1 |
| 61 |
"Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data" |
| 62 |
(make-string 80 ?\xaa))) |
| 63 |
"e8e99d0f45237d786d6bbaa7965c7808bbff1a91"))) |