Q&A's, tips, howto's
cormullion
Posts: 2038 Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:
Post
by cormullion » 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:
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))
I don't know what the problem was, but it currently appears to work on my Mac... :)
Lutz
Posts: 5289 Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:
Post
by Lutz » Sat Mar 01, 2014 10:15 pm
Thanks, I will change crypto:hmac accordingly.
cormullion
Posts: 2038 Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:
Post
by cormullion » Sat Mar 01, 2014 11:54 pm
By the way, the error appeared when using OAuth authentication for the Twitter API - I think the authentication keys supplied by Twitter are longer and so triggered the if clause...