File syn_sha512.h¶
FileList > crypto > syn_sha512.h
Go to the source code of this file
SHA-512 & SHA-384 cryptographic hash and HMAC — pure C99, zero dependencies. More...
#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_HMAC_SHA384 HMAC-SHA384 context — caller-owned. |
| struct | SYN_HMAC_SHA512 HMAC-SHA512 context — caller-owned. |
| struct | SYN_SHA512 SHA-512 / SHA-384 hash context — caller-owned. |
Public Functions¶
| Type | Name |
|---|---|
| void | syn_hmac_sha384 (const void * key, size_t key_len, const void * data, size_t data_len, uint8_t mac) Compute HMAC-SHA384 over data using secret key (RFC 4231). |
| void | syn_hmac_sha384_final (SYN_HMAC_SHA384 * ctx, uint8_t mac) Finalize HMAC-SHA384 computation and retrieve 48-byte MAC. |
| void | syn_hmac_sha384_init (SYN_HMAC_SHA384 * ctx, const void * key, size_t key_len) Initialize HMAC-SHA384 context with a key. |
| void | syn_hmac_sha384_update (SYN_HMAC_SHA384 * ctx, const void * data, size_t len) Feed data chunk into HMAC-SHA384 computation. |
| void | syn_hmac_sha512 (const void * key, size_t key_len, const void * data, size_t data_len, uint8_t mac) Compute HMAC-SHA512 over data using secret key (RFC 4231). |
| void | syn_hmac_sha512_final (SYN_HMAC_SHA512 * ctx, uint8_t mac) Finalize HMAC-SHA512 computation and retrieve 64-byte MAC. |
| void | syn_hmac_sha512_init (SYN_HMAC_SHA512 * ctx, const void * key, size_t key_len) Initialize HMAC-SHA512 context with a key. |
| void | syn_hmac_sha512_update (SYN_HMAC_SHA512 * ctx, const void * data, size_t len) Feed data chunk into HMAC-SHA512 computation. |
| void | syn_sha384 (const void * data, size_t len, uint8_t hash) One-shot SHA-384 calculation. |
| void | syn_sha384_final (SYN_SHA512 * ctx, uint8_t hash) Finalize SHA-384 hash and produce 48-byte digest. |
| void | syn_sha384_init (SYN_SHA512 * ctx) Initialize context for SHA-384 hashing. |
| void | syn_sha512 (const void * data, size_t len, uint8_t hash) One-shot SHA-512 calculation. |
| void | syn_sha512_final (SYN_SHA512 * ctx, uint8_t hash) Finalize SHA-512 hash and produce 64-byte digest. |
| void | syn_sha512_init (SYN_SHA512 * ctx) Initialize context for SHA-512 hashing. |
| void | syn_sha512_update (SYN_SHA512 * ctx, const void * data, size_t len) Feed data into the SHA-512 / SHA-384 hash. |
Macros¶
| Type | Name |
|---|---|
| define | SYN_SHA384_DIGEST_SIZE 48USHA-384 digest size in bytes (48). |
| define | SYN_SHA512_BLOCK_SIZE 128USHA-512 / SHA-384 block size in bytes (128). |
| define | SYN_SHA512_DIGEST_SIZE 64USHA-512 digest size in bytes (64). |
Detailed Description¶
Implements FIPS 180-4 compliant SHA-512 and SHA-384 secure hash algorithms and RFC 4231 HMAC-SHA512 / HMAC-SHA384 message authentication.
Follows the streaming pattern: init → update (repeated) → final
The context struct is caller-owned (~216 bytes on 32-bit/64-bit targets). Zero heap allocation, zero floating point.
** **
// One-shot SHA-512:
uint8_t hash512[64];
syn_sha512("abc", 3, hash512);
// One-shot SHA-384:
uint8_t hash384[48];
syn_sha384("abc", 3, hash384);
// Streaming SHA-512:
SYN_SHA512 ctx;
syn_sha512_init(&ctx);
syn_sha512_update(&ctx, chunk1, len1);
syn_sha512_update(&ctx, chunk2, len2);
syn_sha512_final(&ctx, hash512);
Public Functions Documentation¶
function syn_hmac_sha384¶
Compute HMAC-SHA384 over data using secret key (RFC 4231).
void syn_hmac_sha384 (
const void * key,
size_t key_len,
const void * data,
size_t data_len,
uint8_t mac
)
Parameters:
keySecret key buffer.key_lenSecret key length in bytes.dataData buffer to authenticate.data_lenData length in bytes.macOutput 48-byte MAC buffer.
function syn_hmac_sha384_final¶
Finalize HMAC-SHA384 computation and retrieve 48-byte MAC.
Parameters:
ctxHMAC-SHA384 context.macOutput 48-byte MAC buffer.
function syn_hmac_sha384_init¶
Initialize HMAC-SHA384 context with a key.
Parameters:
ctxHMAC-SHA384 context.keySecret key buffer.key_lenSecret key length in bytes.
function syn_hmac_sha384_update¶
Feed data chunk into HMAC-SHA384 computation.
Parameters:
ctxHMAC-SHA384 context.dataData buffer to authenticate.lenLength in bytes.
function syn_hmac_sha512¶
Compute HMAC-SHA512 over data using secret key (RFC 4231).
void syn_hmac_sha512 (
const void * key,
size_t key_len,
const void * data,
size_t data_len,
uint8_t mac
)
Parameters:
keySecret key buffer.key_lenSecret key length in bytes.dataData buffer to authenticate.data_lenData length in bytes.macOutput 64-byte MAC buffer.
function syn_hmac_sha512_final¶
Finalize HMAC-SHA512 computation and retrieve 64-byte MAC.
Parameters:
ctxHMAC-SHA512 context.macOutput 64-byte MAC buffer.
function syn_hmac_sha512_init¶
Initialize HMAC-SHA512 context with a key.
Parameters:
ctxHMAC-SHA512 context.keySecret key buffer.key_lenSecret key length in bytes.
function syn_hmac_sha512_update¶
Feed data chunk into HMAC-SHA512 computation.
Parameters:
ctxHMAC-SHA512 context.dataData buffer to authenticate.lenLength in bytes.
function syn_sha384¶
One-shot SHA-384 calculation.
Parameters:
dataData to hash.lenLength in bytes.hashOutput 48-byte digest buffer.
function syn_sha384_final¶
Finalize SHA-384 hash and produce 48-byte digest.
Parameters:
ctxSHA-512 context initialized with syn_sha384_init().hashOutput buffer (must be at least 48 bytes).
function syn_sha384_init¶
Initialize context for SHA-384 hashing.
Parameters:
ctxContext to initialize.
function syn_sha512¶
One-shot SHA-512 calculation.
Parameters:
dataData to hash.lenLength in bytes.hashOutput 64-byte digest buffer.
function syn_sha512_final¶
Finalize SHA-512 hash and produce 64-byte digest.
Parameters:
ctxSHA-512 context.hashOutput buffer (must be at least 64 bytes).
function syn_sha512_init¶
Initialize context for SHA-512 hashing.
Parameters:
ctxContext to initialize.
function syn_sha512_update¶
Feed data into the SHA-512 / SHA-384 hash.
Parameters:
ctxSHA-512 context.dataData buffer to hash.lenLength in bytes.
Macro Definition Documentation¶
define SYN_SHA384_DIGEST_SIZE¶
SHA-384 digest size in bytes (48).
define SYN_SHA512_BLOCK_SIZE¶
SHA-512 / SHA-384 block size in bytes (128).
define SYN_SHA512_DIGEST_SIZE¶
SHA-512 digest size in bytes (64).
The documentation for this class was generated from the following file src/syntropic/crypto/syn_sha512.h