23#include "ext_headers.h"
66 size_t labellen, uint8_t *dst,
size_t dlen);
85 const uint8_t *label,
size_t labellen, uint8_t *dst,
101struct lc_kdf_ctr_ctx {
103 uint8_t rng_initialized : 1;
104 struct lc_hmac_ctx hmac_ctx;
107#define LC_CTR_KDF_STATE_SIZE (LC_HMAC_CTX_SIZE)
108#define LC_CTR_KDF_CTX_SIZE \
109 (sizeof(struct lc_kdf_ctr_ctx) + LC_CTR_KDF_STATE_SIZE)
111#define _LC_CTR_KDF_SET_CTX(name, hashname, ctx, offset) \
112 _LC_HMAC_SET_CTX((&(name)->hmac_ctx), hashname, ctx, offset)
114#define LC_CTR_KDF_SET_CTX(name, hashname) \
115 _LC_CTR_KDF_SET_CTX(name, hashname, name, sizeof(struct lc_kdf_ctr_ctx))
118extern const struct lc_rng *lc_kdf_ctr_rng;
120#define LC_CTR_KDF_DRNG_CTX_SIZE \
121 (sizeof(struct lc_rng_ctx) + LC_CTR_KDF_CTX_SIZE)
123#define LC_CTR_KDF_DRNG_SET_CTX(name, hashname) \
124 LC_CTR_KDF_SET_CTX(name, hashname)
126#define LC_CTR_KDF_RNG_CTX(name, hashname) \
127 LC_RNG_CTX(name, lc_kdf_ctr_rng); \
128 LC_CTR_KDF_DRNG_SET_CTX(((struct lc_kdf_ctr_ctx *)(name->rng_state)), \
142#define LC_CTR_KDF_DRNG_CTX_ON_STACK(name, hashname) \
143 _Pragma("GCC diagnostic push") _Pragma( \
144 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
145 LC_ALIGNED_BUFFER(name##_ctx_buf, LC_CTR_KDF_DRNG_CTX_SIZE, \
146 LC_HASH_COMMON_ALIGNMENT); \
147 struct lc_rng_ctx *name = (struct lc_rng_ctx *)name##_ctx_buf; \
148 LC_CTR_KDF_RNG_CTX(name, hashname); \
149 _Pragma("GCC diagnostic pop")
int lc_hash(const struct lc_hash *hash, const uint8_t *in, size_t inlen, uint8_t *digest)
Calculate message digest - one-shot.
int lc_kdf_ctr_generate(struct lc_hmac_ctx *hmac_ctx, const uint8_t *label, size_t labellen, uint8_t *dst, size_t dlen)
Key-based Key Derivation in Counter Mode - SP800-108 - data generation.
int lc_kdf_ctr_init(struct lc_hmac_ctx *hmac_ctx, const uint8_t *key, size_t keylen)
Key-based Key Derivation in Counter Mode - SP800-108 - initialization.
int lc_kdf_ctr(const struct lc_hash *hash, const uint8_t *key, size_t keylen, const uint8_t *label, size_t labellen, uint8_t *dst, size_t dlen)
One-shot Key-based Key Derivation in Counter Mode - SP800-108.
enum lc_alg_status_val lc_kdf_ctr_alg_status(const struct lc_hash *hash)
Obtain algorithm status.
int lc_kdf_ctr_rng_alloc(struct lc_rng_ctx **state, const struct lc_hash *hash)
Allocation of a Counter KDF DRNG context.