hmac-sha1.ss
(module hmac-sha1 mzscheme
  (require (lib "foreign.ss"))
  (unsafe!)
  
  (define openssl-crypto (ffi-lib "libcrypto"))
  (define EVP_SHA1
    (get-ffi-obj 'EVP_sha1 openssl-crypto 
                 (_fun -> _fpointer)))
    
  (define HMAC-SHA1
    (get-ffi-obj 'HMAC openssl-crypto
                 (_fun [EVP_MD : _fpointer = (EVP_SHA1)]
                       [key : _bytes]
                       [key_len : _int = (bytes-length key)]
                       [data : _bytes]
                       [data_len : _int = (bytes-length data)]
                       [md : _int = 0]
                       [md_len : _int = 0]
                       ->
                       _bytes)))
  
  (provide HMAC-SHA1))