ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
hmac_sha384.h File Reference

HMAC-SHA2-384 (RFC 2104 + FIPS 198-1) - streaming context and one-shot API. More...

#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  HmacSha384Ns
 Dispatch table. Addressed by offset, so the layout is asserted below. More...
 

Macros

#define PROTOCORE_HMAC_SHA384_LEN   48
 HMAC-SHA2-384 output length in bytes.
 

Functions

 PROTOCORE_NS_LAYOUT (HmacSha384Ns, init, update, final, mac)
 
proto_bool protocore_hmac_sha384_init (uint8_t *work, const uint8_t *key, size_t key_len)
 Start a MAC under HmacSha384Ns::key_args.
 
proto_bool protocore_hmac_sha384_update (uint8_t *work, const uint8_t *data, size_t len)
 Feed the running MAC a chunk.
 
proto_bool protocore_hmac_sha384_final (uint8_t *work, uint8_t *out)
 Finish, writing the 48 bytes out.
 
proto_bool protocore_hmac_sha384_mac (uint8_t *work, const uint8_t *key, size_t key_len, const uint8_t *data, size_t len, uint8_t *out)
 Init, update and final in one call, for a message already whole.
 

Variables

PROTOCORE_NS HmacSha384Ns HmacSha384 PROTOCORE_UNUSED
 Module namespace.
 

Detailed Description

HMAC-SHA2-384 (RFC 2104 + FIPS 198-1) - streaming context and one-shot API.

The shared HMAC-SHA384 primitive. Backs the HKDF the TLS 1.3 SHA-384 cipher suites run their key schedule on, and the Finished MAC under them. Built over the Sha384Ns entries, so which arm compresses the inner hash is not visible here. TLS 1.3 keys a Finished MAC with a 48-byte secret (<= the 128-byte block), so the key is zero-padded, not pre-hashed.

RFC 2104 construction: HMAC(K, m) = H((K XOR opad) || H((K XOR ipad) || m)), H = SHA-384. The block is SHA-512's 128 octets, not the 48-octet digest, so the pads are 128 wide (RFC 4231 sec 2 tabulates the published HMAC-SHA-384 vectors on that block).

SECURITY NOTE - a MAC must be verified before the covered plaintext is acted upon; that ordering guarantee lives in each protocol's packet layer, not here. These functions are pure crypto.

For a MAC assembled from separate pieces - an HKDF-Expand block over (T(i-1) || info || i):

work is PROTOCORE_HMAC_SHA384_BORROW secure bytes the CALLER took, at an address it knows. It is not held past the call, so nothing here aliases it. The caller releases it, and the pool wipes on release; this module neither takes it, holds it, releases it, nor wipes it. A connection takes those bytes once for its slot and passes them on every record.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file hmac_sha384.h.

Macro Definition Documentation

◆ PROTOCORE_HMAC_SHA384_LEN

#define PROTOCORE_HMAC_SHA384_LEN   48

HMAC-SHA2-384 output length in bytes.

Definition at line 39 of file hmac_sha384.h.

Function Documentation

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( HmacSha384Ns  ,
init  ,
update  ,
final  ,
mac   
)

◆ protocore_hmac_sha384_init()

proto_bool protocore_hmac_sha384_init ( uint8_t *  work,
const uint8_t *  key,
size_t  key_len 
)

Start a MAC under HmacSha384Ns::key_args.

Parameters
workPROTOCORE_HMAC_SHA384_BORROW bytes the caller took. Not held past the call.
keyMAC key bytes
key_lenkey length; > 128 is pre-hashed (RFC 2104), shorter is zero-padded to the block
Returns
PROTO_TRUE on success.

◆ protocore_hmac_sha384_update()

proto_bool protocore_hmac_sha384_update ( uint8_t *  work,
const uint8_t *  data,
size_t  len 
)

Feed the running MAC a chunk.

Parameters
workPROTOCORE_HMAC_SHA384_BORROW bytes the caller took. Not held past the call.
datathe bytes
lenhow many
Returns
PROTO_TRUE on success.

◆ protocore_hmac_sha384_final()

proto_bool protocore_hmac_sha384_final ( uint8_t *  work,
uint8_t *  out 
)

Finish, writing the 48 bytes out.

Parameters
workPROTOCORE_HMAC_SHA384_BORROW bytes the caller took. Not held past the call.
outPROTOCORE_HMAC_SHA384_LEN bytes
Returns
PROTO_TRUE on success.

◆ protocore_hmac_sha384_mac()

proto_bool protocore_hmac_sha384_mac ( uint8_t *  work,
const uint8_t *  key,
size_t  key_len,
const uint8_t *  data,
size_t  len,
uint8_t *  out 
)

Init, update and final in one call, for a message already whole.

Parameters
workPROTOCORE_HMAC_SHA384_BORROW bytes the caller took. Not held past the call.
keyMAC key bytes
key_lenkey length
datathe message
lenits length
outPROTOCORE_HMAC_SHA384_LEN bytes
Returns
PROTO_TRUE on success.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS HmacSha384Ns HmacSha384 PROTOCORE_UNUSED
Initial value:
proto_bool protocore_hmac_sha384_mac(uint8_t *work, const uint8_t *key, size_t key_len, const uint8_t *data, size_t len, uint8_t *out)
Init, update and final in one call, for a message already whole.
proto_bool protocore_hmac_sha384_update(uint8_t *work, const uint8_t *data, size_t len)
Feed the running MAC a chunk.
proto_bool protocore_hmac_sha384_init(uint8_t *work, const uint8_t *key, size_t key_len)
Start a MAC under HmacSha384Ns::key_args.
proto_bool protocore_hmac_sha384_final(uint8_t *work, uint8_t *out)
Finish, writing the 48 bytes out.

Module namespace.

Definition at line 88 of file hmac_sha384.h.