My Project
Classes | Functions
HMAC

HMAC instantiated with SHA-3 hash functions, as specified in section 7 of FIPS 202, RFC 2104, and FIPS 198-1. More...

Classes

struct  hmac_sha3_t
 HMAC-SHA3 (Hash-based Message Authentication Code) context. More...
 

Functions

void hmac_sha3_224 (const uint8_t *k, const size_t k_len, const uint8_t *m, const size_t m_len, uint8_t dst[28])
 Calculat HMAC-SHA3-224 of given key and data. More...
 
void hmac_sha3_256 (const uint8_t *k, const size_t k_len, const uint8_t *m, const size_t m_len, uint8_t dst[32])
 Calculate HMAC-SHA3-256 given key and data. More...
 
void hmac_sha3_384 (const uint8_t *k, const size_t k_len, const uint8_t *m, const size_t m_len, uint8_t dst[48])
 
void hmac_sha3_512 (const uint8_t *k, const size_t k_len, const uint8_t *m, const size_t m_len, uint8_t dst[64])
 Calculate HMAC-SHA3-512 of given key and data. More...
 
void hmac_sha3_224_init (hmac_sha3_t *hmac, const uint8_t *k, const size_t k_len)
 Initialize HMAC-SHA3-224 (FIPS 202, Section 7) context. More...
 
_Bool hmac_sha3_224_absorb (hmac_sha3_t *hmac, const uint8_t *src, const size_t len)
 Absorb data into HMAC-SHA3-224 context. More...
 
void hmac_sha3_224_final (hmac_sha3_t *hmac, uint8_t dst[28])
 Finalize HMAC-SHA3-224 hash context and write 28 bytes of output to destination buffer dst. More...
 
void hmac_sha3_256_init (hmac_sha3_t *hmac, const uint8_t *k, const size_t k_len)
 Initialize HMAC-SHA3-256 (FIPS 202, Section 7) context. More...
 
_Bool hmac_sha3_256_absorb (hmac_sha3_t *hmac, const uint8_t *src, const size_t len)
 Absorb data into HMAC-SHA3-256 context. More...
 
void hmac_sha3_256_final (hmac_sha3_t *hmac, uint8_t dst[32])
 Finalize HMAC-SHA3-256 hash context and write 32 bytes of output to destination buffer dst. More...
 
void hmac_sha3_384_init (hmac_sha3_t *hmac, const uint8_t *k, const size_t k_len)
 Initialize HMAC-SHA3-384 (FIPS 202, Section 7) context. More...
 
_Bool hmac_sha3_384_absorb (hmac_sha3_t *hmac, const uint8_t *src, const size_t len)
 Absorb data into HMAC-SHA3-384 context. More...
 
void hmac_sha3_384_final (hmac_sha3_t *hmac, uint8_t dst[48])
 Finalize HMAC-SHA3-384 hash context and write 48 bytes of output to destination buffer dst. More...
 
void hmac_sha3_512_init (hmac_sha3_t *hmac, const uint8_t *k, const size_t k_len)
 Initialize HMAC-SHA3-512 (FIPS 202, Section 7) context. More...
 
_Bool hmac_sha3_512_absorb (hmac_sha3_t *hmac, const uint8_t *src, const size_t len)
 Absorb data into HMAC-SHA3-512 context. More...
 
void hmac_sha3_512_final (hmac_sha3_t *hmac, uint8_t dst[64])
 Finalize HMAC-SHA3-512 hash context and write 64 bytes of output to destination buffer dst. More...
 

Detailed Description

HMAC instantiated with SHA-3 hash functions, as specified in section 7 of FIPS 202, RFC 2104, and FIPS 198-1.

Function Documentation

◆ hmac_sha3_224()

void hmac_sha3_224 ( const uint8_t *  k,
const size_t  k_len,
const uint8_t *  m,
const size_t  m_len,
uint8_t  dst[28] 
)

Calculat HMAC-SHA3-224 of given key and data.

Calculate HMAC-SHA3-224 (FIPS 202, Section 7) of key in buffer k of length k_len and input message in buffer m of length m_len bytes and write 28 bytes of output to destination buffer dst.

Parameters
[in]kKey.
[in]k_lenKey length, in bytes.
[in]mInput message.
[in]m_lenInput message length, in bytes.
[out]dstDestination array. Must be at least 28 bytes in length.

◆ hmac_sha3_224_absorb()

_Bool hmac_sha3_224_absorb ( hmac_sha3_t hmac,
const uint8_t *  src,
const size_t  len 
)

Absorb data into HMAC-SHA3-224 context.

Absorb input data in src of length len bytes into HMAC-SHA3-224 context hmac. Can be called iteratively to absorb input data in chunks.

Parameters
[in,out]hmacHMAC-SHA3-224 context.
[in]srcInput data.
[in]lenInput data length, in bytes.
Returns
True if data was absorbed, and false otherwise (e.g., if context has already been finalized).

◆ hmac_sha3_224_final()

void hmac_sha3_224_final ( hmac_sha3_t hmac,
uint8_t  dst[28] 
)

Finalize HMAC-SHA3-224 hash context and write 28 bytes of output to destination buffer dst.

Parameters
[in,out]hmacHMAC-SHA3-224 hash context.
[out]dstDestination buffer. Must be at least 28 bytes in length.

◆ hmac_sha3_224_init()

void hmac_sha3_224_init ( hmac_sha3_t hmac,
const uint8_t *  k,
const size_t  k_len 
)

Initialize HMAC-SHA3-224 (FIPS 202, Section 7) context.

Parameters
[out]hmacHMAC-SHA3-224 context.
[in]kKey.
[in]k_lenKey length, in bytes.

◆ hmac_sha3_256()

void hmac_sha3_256 ( const uint8_t *  k,
const size_t  k_len,
const uint8_t *  m,
const size_t  m_len,
uint8_t  dst[32] 
)

Calculate HMAC-SHA3-256 given key and data.

Calculate HMAC-SHA3-256 (FIPS 202, Section 7) of key in buffer k of length k_len and input message in buffer m of length m_len bytes and write 32 bytes of output to destination buffer dst.

Parameters
[in]kKey.
[in]k_lenKey length, in bytes.
[in]mInput message.
[in]m_lenInput message length, in bytes.
[out]dstDestination array. Must be at least 32 bytes in length.

◆ hmac_sha3_256_absorb()

_Bool hmac_sha3_256_absorb ( hmac_sha3_t hmac,
const uint8_t *  src,
const size_t  len 
)

Absorb data into HMAC-SHA3-256 context.

Absorb input data in src of length len bytes into HMAC-SHA3-256 context hmac. Can be called iteratively to absorb input data in chunks.

Parameters
[in,out]hmacHMAC-SHA3-256 context.
[in]srcInput data.
[in]lenInput data length, in bytes.
Returns
True if data was absorbed, and false otherwise (e.g., if context has already been finalized).

◆ hmac_sha3_256_final()

void hmac_sha3_256_final ( hmac_sha3_t hmac,
uint8_t  dst[32] 
)

Finalize HMAC-SHA3-256 hash context and write 32 bytes of output to destination buffer dst.

Parameters
[in,out]hmacHMAC-SHA3-256 hash context.
[out]dstDestination buffer. Must be at least 32 bytes in length.

◆ hmac_sha3_256_init()

void hmac_sha3_256_init ( hmac_sha3_t hmac,
const uint8_t *  k,
const size_t  k_len 
)

Initialize HMAC-SHA3-256 (FIPS 202, Section 7) context.

Parameters
[out]hmacHMAC-SHA3-256 context.
[in]kKey.
[in]k_lenKey length, in bytes.

◆ hmac_sha3_384()

void hmac_sha3_384 ( const uint8_t *  k,
const size_t  k_len,
const uint8_t *  m,
const size_t  m_len,
uint8_t  dst[48] 
)

Calculate HMAC-SHA3-384 of given key and data.

Calculate HMAC-SHA3-384 (FIPS 202, Section 7) of key in buffer k of length k_len and input message in buffer m of length m_len bytes and write 48 bytes of output to destination buffer dst.

Parameters
[in]kKey.
[in]k_lenKey length, in bytes.
[in]mInput message.
[in]m_lenInput message length, in bytes.
[out]dstDestination array. Must be at least 48 bytes in length.

◆ hmac_sha3_384_absorb()

_Bool hmac_sha3_384_absorb ( hmac_sha3_t hmac,
const uint8_t *  src,
const size_t  len 
)

Absorb data into HMAC-SHA3-384 context.

Absorb input data in src of length len bytes into HMAC-SHA3-384 context hmac. Can be called iteratively to absorb input data in chunks.

Parameters
[in,out]hmacHMAC-SHA3-384 context.
[in]srcInput data.
[in]lenInput data length, in bytes.
Returns
True if data was absorbed, and false otherwise (e.g., if context has already been finalized).

◆ hmac_sha3_384_final()

void hmac_sha3_384_final ( hmac_sha3_t hmac,
uint8_t  dst[48] 
)

Finalize HMAC-SHA3-384 hash context and write 48 bytes of output to destination buffer dst.

Parameters
[in,out]hmacHMAC-SHA3-384 hash context.
[out]dstDestination buffer. Must be at least 48 bytes in length.

◆ hmac_sha3_384_init()

void hmac_sha3_384_init ( hmac_sha3_t hmac,
const uint8_t *  k,
const size_t  k_len 
)

Initialize HMAC-SHA3-384 (FIPS 202, Section 7) context.

Parameters
[out]hmacHMAC-SHA3-384 context.
[in]kKey.
[in]k_lenKey length, in bytes.

◆ hmac_sha3_512()

void hmac_sha3_512 ( const uint8_t *  k,
const size_t  k_len,
const uint8_t *  m,
const size_t  m_len,
uint8_t  dst[64] 
)

Calculate HMAC-SHA3-512 of given key and data.

Calculate HMAC-SHA3-512 (FIPS 202, Section 7) of key in buffer k of length k_len and input message in buffer m of length m_len bytes and write 64 bytes of output to destination buffer dst.

Parameters
[in]kKey.
[in]k_lenKey length, in bytes.
[in]mInput message.
[in]m_lenInput message length, in bytes.
[out]dstDestination array. Must be at least 64 bytes in length.

◆ hmac_sha3_512_absorb()

_Bool hmac_sha3_512_absorb ( hmac_sha3_t hmac,
const uint8_t *  src,
const size_t  len 
)

Absorb data into HMAC-SHA3-512 context.

Absorb input data in src of length len bytes into HMAC-SHA3-512 context hmac. Can be called iteratively to absorb input data in chunks.

Parameters
[in,out]hmacHMAC-SHA3-512 context.
[in]srcInput data.
[in]lenInput data length, in bytes.
Returns
True if data was absorbed, and false otherwise (e.g., if context has already been finalized).

◆ hmac_sha3_512_final()

void hmac_sha3_512_final ( hmac_sha3_t hmac,
uint8_t  dst[64] 
)

Finalize HMAC-SHA3-512 hash context and write 64 bytes of output to destination buffer dst.

Parameters
[in,out]hmacHMAC-SHA3-512 hash context.
[out]dstDestination buffer. Must be at least 64 bytes in length.

◆ hmac_sha3_512_init()

void hmac_sha3_512_init ( hmac_sha3_t hmac,
const uint8_t *  k,
const size_t  k_len 
)

Initialize HMAC-SHA3-512 (FIPS 202, Section 7) context.

Parameters
[out]hmacHMAC-SHA3-512 context.
[in]kKey.
[in]k_lenKey length, in bytes.