File syn_hmac.h¶
FileList > src > syntropic > util > syn_hmac.h
Go to the source code of this file
HMAC-SHA256 — keyed-hash message authentication code. More...
#include "syn_sha256.h"#include <stddef.h>#include <stdint.h>#include <string.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_HMAC_SHA256 HMAC-SHA256 context — caller-owned. |
Public Static Functions¶
| Type | Name |
|---|---|
| void | syn_hmac_sha256 (const void * key, size_t key_len, const void * data, size_t data_len, uint8_t mac) Compute HMAC-SHA256 in one shot. |
| void | syn_hmac_sha256_final (SYN_HMAC_SHA256 * ctx, uint8_t mac) Finalize and produce the 32-byte HMAC. |
| void | syn_hmac_sha256_init (SYN_HMAC_SHA256 * ctx, const void * key, size_t key_len) Initialize HMAC-SHA256 with a key. |
| void | syn_hmac_sha256_update (SYN_HMAC_SHA256 * ctx, const void * data, size_t len) Feed message data into the HMAC. |
Macros¶
| Type | Name |
|---|---|
| define | SYN_HMAC_SHA256_SIZE [**SYN\_SHA256\_DIGEST\_SIZE**](syn__sha256_8h.md#define-syn_sha256_digest_size)HMAC-SHA256 output size in bytes. |
Detailed Description¶
Built on top of syn_sha256. Provides the same streaming pattern: init (with key) → update → final
The context wraps two SHA-256 contexts (~224 bytes caller-owned). No heap, no external dependencies.
** **
// One-shot:
uint8_t mac[32];
syn_hmac_sha256(key, key_len, message, msg_len, mac);
// Streaming:
SYN_HMAC_SHA256 ctx;
syn_hmac_sha256_init(&ctx, key, key_len);
syn_hmac_sha256_update(&ctx, chunk1, len1);
syn_hmac_sha256_update(&ctx, chunk2, len2);
syn_hmac_sha256_final(&ctx, mac);
Public Static Functions Documentation¶
function syn_hmac_sha256¶
Compute HMAC-SHA256 in one shot.
static inline void syn_hmac_sha256 (
const void * key,
size_t key_len,
const void * data,
size_t data_len,
uint8_t mac
)
Parameters:
keySecret key.key_lenKey length in bytes.dataMessage data.data_lenMessage length in bytes.macOutput buffer (must be at least 32 bytes).
function syn_hmac_sha256_final¶
Finalize and produce the 32-byte HMAC.
Parameters:
ctxHMAC context.macOutput buffer (must be at least 32 bytes).
function syn_hmac_sha256_init¶
Initialize HMAC-SHA256 with a key.
If key_len > 64, the key is first hashed with SHA-256.
Parameters:
ctxHMAC context.keySecret key.key_lenKey length in bytes.
function syn_hmac_sha256_update¶
Feed message data into the HMAC.
Parameters:
ctxHMAC context.dataMessage data.lenLength in bytes.
Macro Definition Documentation¶
define SYN_HMAC_SHA256_SIZE¶
HMAC-SHA256 output size in bytes.
The documentation for this class was generated from the following file src/syntropic/util/syn_hmac.h