34 struct lc_sym_ctx sym;
35 struct lc_kmac_ctx auth_ctx;
38#define LC_KH_STATE_SIZE(sym, hash) \
39 (LC_SYM_STATE_SIZE(sym) + LC_KMAC_STATE_SIZE(hash))
40#define LC_KH_CTX_SIZE(sym, hash) \
41 (sizeof(struct lc_aead) + sizeof(struct lc_kh_cryptor) + \
42 LC_KH_STATE_SIZE(sym, hash))
45extern const struct lc_aead *lc_symkmac_aead;
47#define _LC_KH_SET_CTX(name, symalgo, hash) \
48 _LC_SYM_SET_CTX((&name->sym), symalgo, name, \
49 (sizeof(struct lc_kh_cryptor))); \
51 (&name->auth_ctx), hash, name, \
52 (sizeof(struct lc_kh_cryptor) + LC_SYM_STATE_SIZE(symalgo)))
54#define LC_KH_SET_CTX(name, sym, hash) \
55 LC_AEAD_CTX(name, lc_symkmac_aead); \
56 _LC_KH_SET_CTX(((struct lc_kh_cryptor *)name->aead_state), sym, hash)
298 struct lc_aead_ctx **ctx);
311#define LC_KH_CTX_ON_STACK(name, sym, hash) \
312 _Pragma("GCC diagnostic push") \
313 _Pragma("GCC diagnostic ignored \"-Wvla\"") _Pragma( \
314 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
315 LC_ALIGNED_BUFFER(name##_ctx_buf, \
316 LC_KH_CTX_SIZE(sym, hash), \
317 LC_HASH_COMMON_ALIGNMENT); \
318 struct lc_aead_ctx *name = (struct lc_aead_ctx *)name##_ctx_buf; \
319 LC_KH_SET_CTX(name, sym, hash); \
320 lc_aead_zero(name); \
321 _Pragma("GCC diagnostic pop")
void lc_hash(const struct lc_hash *hash, const uint8_t *in, size_t inlen, uint8_t *digest)
Calculate message digest - one-shot.
int lc_kh_alloc(const struct lc_sym *sym, const struct lc_hash *hash, struct lc_aead_ctx **ctx)
Allocate symmetric algorithm with KMAC cryptor context on heap.