For Gauche 0.9.5


Next: , Previous: , Up: Library modules - Utilities   [Contents][Index]

12.32 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 Message digester framework), such as <md5> (see MD5 message digest) or <sha256> (see 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 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.


Next: , Previous: , Up: Library modules - Utilities   [Contents][Index]