std1.0.0-beta-7 SafeC docs

Module crypto::hmac

#include <std/crypto/hmac.h> source

HMAC (RFC 2104) over any hash.

Hmac<H> is the HMAC construction written once over hash.h's BlockHash, so HMAC-SHA1 / -SHA224 / -SHA256 / -SHA384 / -SHA512 are the same code with a different hash context. It streams like a hash, and is a Hasher itself (update / finish / digest_size): hash_bytes and any generic<H: Hasher> code take it.

struct Hmac<Sha512Ctx> mac = Hmac::new(Sha512Ctx::new(), key, keyLen);
mac.update(msg, msgLen);
mac.finish(&tag[0]);                       // 64 bytes: mac.digest_size()

hmac_sha256 is the one-shot form for HMAC-SHA256.

Structs

Hmac

Functions

hmac_sha256Writes the 32-byte HMAC-SHA256 of 'data' (length 'dataLen') keyed by 'key' (length 'keyLen') into 'out' (must be >= 32 bytes).

Macros

HMAC_SHA256_SIZEbytes