Problem in crypto.lsp?

Q&A's, tips, howto's

Problem in crypto.lsp?

Postby 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... :)
cormullion
 
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W

Re: Problem in crypto.lsp?

Postby Lutz » Sat Mar 01, 2014 10:15 pm

Thanks, I will change crypto:hmac accordingly.
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: Problem in crypto.lsp?

Postby 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...
cormullion
 
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 2 guests