wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
hmac.h File Reference

FIPS 198-1 HMAC-SHA-256 and HMAC-SHA-384. More...

#include "common/bytes/span/span.h"
#include "crypto/symmetric/hash/hash/sha256.h"
#include "crypto/symmetric/hash/hash/sha384.h"

Go to the source code of this file.

Functions

void quic_hmac_sha256 (quic_span key, quic_span msg, u8 out[QUIC_SHA256_DIGEST])
 Compute HMAC-SHA-256(key, msg).
void quic_hmac_sha256_truncated (quic_span key, quic_span msg, u8 *out, usz out_len)
 Compute HMAC-SHA-256(key, msg) truncated to its leftmost out_len bytes (FIPS 198-1 5, "Truncation of HMAC Output": MAC = leftmost Tlen bytes of HMAC(K, text)).
void quic_hmac_sha384 (quic_span key, quic_span msg, u8 out[QUIC_SHA384_DIGEST])
 Compute HMAC-SHA-384(key, msg) (RFC 2104, FIPS 180-4 SHA-384).

Detailed Description

FIPS 198-1 HMAC-SHA-256 and HMAC-SHA-384.

Outputs are 32-byte and 48-byte MACs respectively.

Function Documentation

◆ quic_hmac_sha256()

void quic_hmac_sha256 ( quic_span key,
quic_span msg,
u8 out[QUIC_SHA256_DIGEST] )

Compute HMAC-SHA-256(key, msg).

Parameters
keyMAC key (any length; keys longer than one block are hashed)
msgmessage to authenticate
outreceives the 32-byte MAC

◆ quic_hmac_sha256_truncated()

void quic_hmac_sha256_truncated ( quic_span key,
quic_span msg,
u8 * out,
usz out_len )

Compute HMAC-SHA-256(key, msg) truncated to its leftmost out_len bytes (FIPS 198-1 5, "Truncation of HMAC Output": MAC = leftmost Tlen bytes of HMAC(K, text)).

Parameters
keyMAC key (any length; keys longer than one block are hashed)
msgmessage to authenticate
outreceives the truncated MAC
out_lennumber of leftmost bytes to keep (0..QUIC_SHA256_DIGEST)

◆ quic_hmac_sha384()

void quic_hmac_sha384 ( quic_span key,
quic_span msg,
u8 out[QUIC_SHA384_DIGEST] )

Compute HMAC-SHA-384(key, msg) (RFC 2104, FIPS 180-4 SHA-384).

Parameters
keyMAC key (any length; keys longer than one block are hashed)
msgmessage to authenticate
outreceives the 48-byte MAC