From 544db619f024d8624368281b15b6b147a483175b Mon Sep 17 00:00:00 2001 From: Thomas Hintz Date: Sat, 16 Apr 2011 18:51:01 -0400 Subject: [PATCH] First commit. --- hmac.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 hmac.scm diff --git a/hmac.scm b/hmac.scm new file mode 100644 index 0000000..c884d16 --- /dev/null +++ b/hmac.scm @@ -0,0 +1,11 @@ +(use sha1 srfi-4 srfi-4-utils) + +; taken from example at http://wiki.call-cc.org/drupal-xml-rpc +(define (sha1-hmac key) + (when (> (string-length key) 64) (set! key (sha1-binary-digest key))) + (set! key (string-pad-right key 64 (integer->char 0))) + (set! key (blob->u8vector (string->blob key))) + (let ((ipad (blob->string (u8vector->blob (u8vector-map (lambda (v) (bitwise-xor v #x36)) key)))) + (opad (blob->string (u8vector->blob (u8vector-map (lambda (v) (bitwise-xor v #x5c)) key))))) + (lambda (message) + (sha1-binary-digest (string-append opad (sha1-binary-digest (string-append ipad message))))))) \ No newline at end of file