std.digest.hmac

This package implements the hash-based message authentication code (_HMAC) algorithm as defined in RFC2104. See also the corresponding Wikipedia article.

struct HMAC

Types 1

structHMAC(H, size_t hashBlockSize) if (hashBlockSize % 8 == 0)

Overload of HMAC to be used if H doesn't provide information about its block size.

Fields
hashBlockSize blockSize
private H digest
private ubyte[blockSize / 8] key
Methods
HMAC!(H, blockSize) start() ref returnReinitializes the digest, making it ready for reuse.
HMAC!(H, blockSize) put(in ubyte[] data...) ref returnFeeds a piece of data into the hash computation. This method allows the type to be used as an OutputRange.
DigestType!H finish()Resets the digest and returns the finished hash.
Constructors
this(scope const(ubyte)[] secret)Constructs the HMAC digest using the specified secret.

Templates 3

tmplHMAC(H) if (isDigest!H && hasBlockSize!H)
tmplhmac(H) if (isDigest!H && hasBlockSize!H)

ditto

tmplhmac(H, size_t blockSize) if (isDigest!H)

ditto

Functions
auto hmac(scope const(ubyte)[] secret)

Constructs an HMAC digest with the specified secret.

Returns

An instance of HMAC that can be fed data as desired, and finished

to compute the final hash when done.

DigestType!H hmac(T...)(scope T data, scope const(ubyte)[] secret) if (allSatisfy!(isDigestibleRange, typeof(data)))

Computes an _HMAC digest over the given range of data with the specified secret.

Returns

The final _HMAC hash.