[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.24 rfc.hmac - HMAC keyed-hashing

Module: rfc.hmac

This module implements HMAC algorithm, Keyed-hashing for message authentication, defined in RFC 2104.

For simple batched keyed hashing, you can use high-level API hmac-digest and hmac-digest-string. Or you can create <hmac> object and update its state as the data coming in.

Class: <hmac>

Keeps state information of HMAC algorithm. Key and the hashing algorithm should be given at the construction time, using :key and :hasher keyword-arguments respectively. You can pass any class object that implements message digest interface (See section util.digest - Message digester framework), such as <md5> (See section rfc.md5 - MD5 message digest) or <sha256> (See section rfc.sha - SHA message digest).

Example:

 
(make <hmac> :key (make-byte-string 16 #x0b) :hasher <md5>)
Method: hmac-update! (hmac <hmac>) data

Updates the internal state of hmac by data, which must be represented by a (possibly incomplete) string.

Method: hmac-final! (hmac <hmac>)

Finalizes the internal state of hmac and returns the hashed string in incomplete string. You can use digest-hexify (See section util.digest - Message digester framework) to obtain "hexified" result. Once finalized, you can’t call hmac-update! or hmac-final! on hmac.

Method: hmac-digest :key key hasher

Creates an <hmac> object and hash the data stream from the current input port, then returns the hashed result in an incomplete string.

Method: hmac-digest-string string :key key hasher

Creates an <hmac> object and hash the data in string, then returns the hashed result in an incomplete string.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated on July 19, 2014 using texi2html 1.82.