1 ;;; hmac-sha1.el --- Compute HMAC-SHA1.
3 ;; Copyright (C) 1999 Shuhei KOBAYASHI
5 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
6 ;; Keywords: HMAC, RFC 2104, HMAC-SHA1, SHA1, Cancel-Lock
8 ;; This program is free software; you can redistribute it and/or
9 ;; modify it under the terms of the GNU General Public License as
10 ;; published by the Free Software Foundation; either version 2, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
25 ;; Test cases from RFC 2202, "Test Cases for HMAC-MD5 and HMAC-SHA-1".
27 ;; (hmac-hex-string (hmac-sha1 "Hi There" (make-string 20 ?\x0b)))
28 ;; => "b617318655057264e28bc0b6fb378c8ef146be00"
30 ;; (hmac-hex-string (hmac-sha1 "what do ya want for nothing?" "Jefe"))
31 ;; => "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79"
33 ;; (hmac-hex-string (hmac-sha1 (make-string 50 ?\xdd) (make-string 20 ?\xaa)))
34 ;; => "125d7342b9ac11cd91a39af48aa17b4f63f175d3"
38 ;; (make-string 50 ?\xcd)
39 ;; (hmac-unhex-string "0102030405060708090a0b0c0d0e0f10111213141516171819")))
40 ;; => "4c9007f4026250c6bc8414f9bf50c86c2d7235da"
43 ;; (hmac-sha1 "Test With Truncation" (make-string 20 ?\x0c)))
44 ;; => "4c1a03424b55e07fe7f27be1d58bb9324a9a5a04"
46 ;; (hmac-sha1-96 "Test With Truncation" (make-string 20 ?\x0c)))
47 ;; => "4c1a03424b55e07fe7f27be1"
51 ;; "Test Using Larger Than Block-Size Key - Hash Key First"
52 ;; (make-string 80 ?\xaa)))
53 ;; => "aa4ae5e15272d00e95705637ce8a3b55ed402112"
57 ;; "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"
58 ;; (make-string 80 ?\xaa)))
59 ;; => "e8e99d0f45237d786d6bbaa7965c7808bbff1a91"
63 (eval-when-compile (require 'hmac-def))
64 (require 'sha1) ; expects (sha1 STRING)
66 (define-hmac-function hmac-sha1 sha1 64 20) ; => (hmac-sha1 TEXT KEY)
67 ;; (define-hmac-function hmac-sha1-96 sha1 64 20 96)
68 ;; => (hmac-sha1-96 TEXT KEY)
72 ;;; hmac-sha1.el ends here.