28 for (
size_t i = 0; i < key_len; i++)
35 block[i] = (uint8_t)(k[i] ^ pad_byte);
43 build_key_block(key, key_len, ikey, 0x36u);
44 build_key_block(key, key_len, ctx->
okey, 0x5cu);
65void pc_hmac_sha512(
const uint8_t *key,
size_t key_len,
const uint8_t *data,
size_t len,
Per-translation-unit optimization override for hot, pure-integer crypto.
void pc_hmac_sha512_final(pc_hmac_sha512_ctx *ctx, uint8_t mac[PC_HMAC_SHA512_LEN])
Finish, writing the 64-byte MAC.
void pc_hmac_sha512_init(pc_hmac_sha512_ctx *ctx, const uint8_t *key, size_t key_len)
Begin an HMAC-SHA2-512 over key (keys > 128 bytes are pre-hashed per RFC 2104).
void pc_hmac_sha512(const uint8_t *key, size_t key_len, const uint8_t *data, size_t len, uint8_t mac[PC_HMAC_SHA512_LEN])
One-shot HMAC-SHA2-512 over a single buffer.
void pc_hmac_sha512_update(pc_hmac_sha512_ctx *ctx, const uint8_t *data, size_t len)
Feed len message bytes.
HMAC-SHA2-512 (RFC 2104 + FIPS 198-1) - streaming context and one-shot API.
#define PC_HMAC_SHA512_LEN
HMAC-SHA2-512 output length in bytes.
void build_key_block(const uint8_t *key, size_t key_len, uint8_t block[64], uint8_t pad_byte, uint8_t scratch[64])
void pc_sha512_update(pc_sha512_ctx *ctx, const uint8_t *data, size_t len)
Feed len bytes of data into the running hash.
void pc_sha512(const uint8_t *data, size_t len, uint8_t digest[PC_SHA512_DIGEST_LEN])
One-shot SHA-512: hash len bytes of data into digest (64 bytes).
PC_CRYPTO_HOT void pc_sha512_init(pc_sha512_ctx *ctx)
Initialize a streaming SHA-512 context (ctx must not be NULL).
void pc_sha512_final(pc_sha512_ctx *ctx, uint8_t digest[PC_SHA512_DIGEST_LEN])
Finalize the hash and write the 64-byte digest. The context is undefined afterwards; call init() agai...
#define PC_SHA512_DIGEST_LEN
SHA-512 digest length in bytes.
#define PC_SHA512_BLOCK_LEN
SHA-512 block size in bytes.
Streaming HMAC-SHA2-512 context (stores the opad key block + inner hash state).
uint8_t okey[PC_SHA512_BLOCK_LEN]
(key XOR opad), applied in the final step
pc_sha512_ctx inner
inner hash: H((key XOR ipad) || message)
Streaming SHA-512 context.