|
ProtoCore v0.0.2
Deterministic, zero-heap network stack for embedded targets
|
SP800-108 counter-mode key derivation (HMAC-SHA256 PRF). More...
#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Functions | |
| bool | pc_kdf_ctr_hmac_sha256 (const uint8_t *ki, size_t ki_len, const uint8_t *fixed, size_t fixed_len, uint8_t *out, size_t out_len) |
| SP800-108 KDF in counter mode with HMAC-SHA256 as the PRF (NIST SP800-108 §5.1; r = 32-bit counter placed before the fixed input). | |
SP800-108 counter-mode key derivation (HMAC-SHA256 PRF).
The shared NIST SP800-108 §5.1 counter-mode KDF. SMB 3.x uses it to derive its signing and encryption keys (MS-SMB2 §3.1.4.2); the caller assembles the fixed input, keeping this independent of any protocol's label/context choices. Verified against the NIST CAVP KBKDF (KDFCTR) vectors.
Definition in file kdf.h.
| bool pc_kdf_ctr_hmac_sha256 | ( | const uint8_t * | ki, |
| size_t | ki_len, | ||
| const uint8_t * | fixed, | ||
| size_t | fixed_len, | ||
| uint8_t * | out, | ||
| size_t | out_len | ||
| ) |
SP800-108 KDF in counter mode with HMAC-SHA256 as the PRF (NIST SP800-108 §5.1; r = 32-bit counter placed before the fixed input).
K(i) = HMAC-SHA256(Ki, [i]_32be || fixed); the blocks are concatenated for i = 1, 2, ... and the result truncated to out_len bytes. The caller assembles fixed as Label || 0x00 || Context || [L] (L = the output length in bits, 32-bit big-endian) and passes it whole.
| ki | the key-derivation key (e.g. the SMB 3.x session key). |
| ki_len | length of ki in bytes. |
| fixed | the fixed input (Label || 0x00 || Context || [L]). |
| fixed_len | length of fixed in bytes. |
| out | receives out_len derived bytes. |
| out_len | number of output bytes (>= 1); the caller must encode L = out_len * 8 into fixed. |
out_len == 0. Definition at line 20 of file kdf.cpp.
References pc_sha256(), pc_sha256_final(), pc_sha256_init(), pc_sha256_update(), and pc_wr32be().