31static void build_key_block(
const uint8_t *key,
size_t key_len, uint8_t block[64], uint8_t pad_byte)
42 for (
size_t i = 0; i < key_len; i++)
45 for (
int i = 0; i < 64; i++)
46 block[i] = k[i] ^ pad_byte;
56 build_key_block(key, key_len, ikey, 0x36u);
57 build_key_block(key, key_len, ctx->
okey, 0x5cu);
85void ssh_hmac_sha256(
const uint8_t *key,
size_t key_len,
const uint8_t *data,
size_t len,
void ssh_hmac_sha256_final(SshHmacCtx *ctx, uint8_t mac[SSH_HMAC_SHA256_LEN])
Finalize and write the 32-byte MAC.
void ssh_hmac_sha256_init(SshHmacCtx *ctx, const uint8_t *key, size_t key_len)
Initialize a streaming HMAC-SHA2-256 context.
void ssh_hmac_sha256_update(SshHmacCtx *ctx, const uint8_t *data, size_t len)
Feed len bytes into the running HMAC.
void ssh_hmac_sha256(const uint8_t *key, size_t key_len, const uint8_t *data, size_t len, uint8_t mac[SSH_HMAC_SHA256_LEN])
Compute HMAC-SHA2-256 over a single contiguous buffer.
HMAC-SHA2-256 (RFC 2104 + FIPS 198-1).
#define SSH_HMAC_SHA256_LEN
HMAC-SHA2-256 output length in bytes.
void ssh_sha256(const uint8_t *data, size_t len, uint8_t digest[SSH_SHA256_DIGEST_LEN])
One-shot SHA-256: hash len bytes and write the digest.
void ssh_sha256_init(SshSha256Ctx *ctx)
Initialize a streaming SHA-256 context.
void ssh_sha256_update(SshSha256Ctx *ctx, const uint8_t *data, size_t len)
Feed len bytes of data into the running hash.
void ssh_sha256_final(SshSha256Ctx *ctx, uint8_t digest[SSH_SHA256_DIGEST_LEN])
Finalize the hash and write the 32-byte digest.
#define SSH_SHA256_DIGEST_LEN
SHA-256 digest length in bytes.
Streaming HMAC-SHA2-256 context.
SshSha256Ctx inner
Inner hash context (key XOR ipad prepended).
uint8_t okey[64]
Outer key block (key XOR opad), stored for final step.
Streaming SHA-256 context.