34 struct lc_sym_ctx sym;
35 struct lc_hmac_ctx auth_ctx;
38#define LC_SH_STATE_SIZE(sym, hash) \
39 (LC_SYM_STATE_SIZE(sym) + LC_HMAC_STATE_SIZE(hash))
40#define LC_SH_CTX_SIZE(sym, hash) \
41 (sizeof(struct lc_aead) + sizeof(struct lc_sh_cryptor) + \
42 LC_SH_STATE_SIZE(sym, hash))
45extern const struct lc_aead *lc_symhmac_aead;
47#define _LC_SH_SET_CTX(name, symalgo, hash) \
48 _LC_SYM_SET_CTX((&name->sym), symalgo, name, \
49 (sizeof(struct lc_sh_cryptor))); \
51 (&name->auth_ctx), hash, name, \
52 (sizeof(struct lc_sh_cryptor) + LC_SYM_STATE_SIZE(symalgo)))
54#define LC_SH_SET_CTX(name, sym, hash) \
55 LC_AEAD_CTX(name, lc_symhmac_aead); \
56 _LC_SH_SET_CTX(((struct lc_sh_cryptor *)name->aead_state), sym, hash)
311 struct lc_aead_ctx **ctx);
322#define LC_SH_CTX_ON_STACK(name, sym, hash) \
323 _Pragma("GCC diagnostic push") \
324 _Pragma("GCC diagnostic ignored \"-Wvla\"") _Pragma( \
325 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
326 LC_ALIGNED_BUFFER(name##_ctx_buf, \
327 LC_SH_CTX_SIZE(sym, hash), \
328 LC_HASH_COMMON_ALIGNMENT); \
329 struct lc_aead_ctx *name = (struct lc_aead_ctx *)name##_ctx_buf; \
330 LC_SH_SET_CTX(name, sym, hash); \
331 lc_aead_zero(name); \
332 _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_sh_alloc(const struct lc_sym *sym, const struct lc_hash *hash, struct lc_aead_ctx **ctx)
Allocate symmetric algorithm with HMAC cryptor context on heap.