Problem in crypto.lsp?

Started by cormullion, March 01, 2014, 10:05:03 AM

Previous topic - Next topic

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:


(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 "00" (- 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

#1
Thanks, I will change crypto:hmac accordingly.

cormullion

#2
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...