Page 1 of 1

Problem in crypto.lsp?

Posted: Sat Mar 01, 2014 6:05 pm
by cormullion
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... :)

Re: Problem in crypto.lsp?

Posted: Sat Mar 01, 2014 10:15 pm
by Lutz
Thanks, I will change crypto:hmac accordingly.

Re: Problem in crypto.lsp?

Posted: Sat Mar 01, 2014 11:54 pm
by cormullion
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...