crypto::hmac+x86_64 +linux

The hmac module computes the HMAC message authentication code algorithm defined by RFC 2104.

This is a low-level module which implements cryptographic primitives. Direct use of cryptographic primitives is not recommended for non-experts, as incorrect use of these primitives can easily lead to the introduction of security vulnerabilities. Non-experts are advised to use the high-level operations available in the top-level crypto:: module.

Be advised that Hare's cryptography implementations have not been audited.

Index

Types

// Undocumented types:
type sha1state = struct {
	mac::mac,
	h: sha1::state,
	keypad: [sha1::BLOCKSZ]u8,
};
type sha256state = struct {
	mac::mac,
	h: sha256::state,
	keypad: [sha256::BLOCKSZ]u8,
};
type state = struct {
	mac::mac,
	h: *hash::hash,
	keypad: []u8,
};

Functions

fn hmac(h: *hash::hash, key: const []u8, buf: []u8) state;
fn sha1(key: []u8) sha1state;
fn sha256(key: []u8) sha256state;

Types

type sha1state[link]

Show undocumented member
type sha1state = struct {
	mac::mac,
	h: sha1::state,
	keypad: [sha1::BLOCKSZ]u8,
};

type sha256state[link]

Show undocumented member
type sha256state = struct {
	mac::mac,
	h: sha256::state,
	keypad: [sha256::BLOCKSZ]u8,
};

type state[link]

Show undocumented member
type state = struct {
	mac::mac,
	h: *hash::hash,
	keypad: []u8,
};

Functions

fn hmac[link]

fn hmac(h: *hash::hash, key: const []u8, buf: []u8) state;

Creates a crypto::mac::mac that computes an HMAC using the provided hash function 'h' with given 'key'. The caller must provide a 'buf' of hash::bsz bytes. Use the BLOCKSZ constant of the given hash function to allocate the memory statically.

The caller must take extra care to call crypto::mac::finish when they are finished using the MAC function, which, in addition to freeing state associated with the MAC, will securely erase state which contains secret information.

fn sha1[link]

fn sha1(key: []u8) sha1state;

Creates a crypto::mac::mac that computes an HMAC with given 'key' using SHA1 as underlying hash function.

The caller must take extra care to call crypto::mac::finish when they are finished using the MAC function, which, in addition to freeing state associated with the MAC, will securely erase state which contains secret information.

fn sha256[link]

fn sha256(key: []u8) sha256state;

Creates a crypto::mac::mac that computes an HMAC with given 'key' using SHA256 as underlying hash function.

The caller must take extra care to call crypto::mac::finish when they are finished using the MAC function, which, in addition to freeing state associated with the MAC, will securely erase state which contains secret information.