17void build_key_block(
const uint8_t *key,
size_t key_len, uint8_t block[
SSH_SHA512_BLOCK_LEN], uint8_t pad_byte)
26 for (
size_t i = 0; i < key_len; i++)
30 block[i] = (uint8_t)(k[i] ^ pad_byte);
37 build_key_block(key, key_len, ikey, 0x36u);
38 build_key_block(key, key_len, ctx->
okey, 0x5cu);
59void ssh_hmac_sha512(
const uint8_t *key,
size_t key_len,
const uint8_t *data,
size_t len,
void ssh_hmac_sha512_final(SshHmacSha512Ctx *ctx, uint8_t mac[SSH_HMAC_SHA512_LEN])
Finish, writing the 64-byte MAC.
void ssh_hmac_sha512(const uint8_t *key, size_t key_len, const uint8_t *data, size_t len, uint8_t mac[SSH_HMAC_SHA512_LEN])
One-shot HMAC-SHA2-512 over a single buffer.
void ssh_hmac_sha512_init(SshHmacSha512Ctx *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 ssh_hmac_sha512_update(SshHmacSha512Ctx *ctx, const uint8_t *data, size_t len)
Feed len message bytes.
HMAC-SHA2-512 (RFC 2104 + FIPS 198-1).
#define SSH_HMAC_SHA512_LEN
HMAC-SHA2-512 output length in bytes.
void ssh_sha512_final(SshSha512Ctx *ctx, uint8_t digest[SSH_SHA512_DIGEST_LEN])
Finalize the hash and write the 64-byte digest. The context is undefined afterwards; call init() agai...
void ssh_sha512_init(SshSha512Ctx *ctx)
Initialize a streaming SHA-512 context (ctx must not be NULL).
void ssh_sha512(const uint8_t *data, size_t len, uint8_t digest[SSH_SHA512_DIGEST_LEN])
One-shot SHA-512: hash len bytes of data into digest (64 bytes).
void ssh_sha512_update(SshSha512Ctx *ctx, const uint8_t *data, size_t len)
Feed len bytes of data into the running hash.
#define SSH_SHA512_DIGEST_LEN
SHA-512 digest length in bytes.
#define SSH_SHA512_BLOCK_LEN
SHA-512 block size in bytes.
Streaming HMAC-SHA2-512 context (stores the opad key block + inner hash state).
SshSha512Ctx inner
inner hash: H((key XOR ipad) || message)
uint8_t okey[SSH_SHA512_BLOCK_LEN]
(key XOR opad), applied in the final step
Streaming SHA-512 context.