Problem in crypto.lsp?
Posted: Sat Mar 01, 2014 6:05 pm
Hi Lutz! I ran into a few problems using crypto.lsp. I eventually solved it by editing the hmac function to look like this:
I don't know what the problem was, but it currently appears to work on my Mac... :)
Code: Select all
(define (hmac hash_fn msg_str key_str , blocksize opad ipad)
(set 'blocksize 64)
(set 'opad (dup "\x5c" blocksize))
(set 'ipad (dup "\x36" blocksize))
(if (> (length key_str) blocksize)
(set 'key_str (hash_fn key_str true))) ; <----------------
(set 'key_str (append key_str (dup "\000" (- blocksize (length key_str))))) ;; padding key with binary zeros
(set 'opad (encrypt opad key_str))
(set 'ipad (encrypt ipad key_str))
(hash_fn (append opad (hash_fn (append ipad msg_str) true)) true))