34 struct lc_sym_ctx sym;
35 struct lc_hmac_ctx auth_ctx;
38#define LC_SH_STATE_SIZE(sym) (LC_SYM_STATE_SIZE(sym) + LC_HMAC_STATE_SIZE)
39#define LC_SH_CTX_SIZE(sym) \
40 (sizeof(struct lc_aead) + sizeof(struct lc_sh_cryptor) + \
41 LC_SH_STATE_SIZE(sym))
44extern const struct lc_aead *lc_symhmac_aead;
46#define _LC_SH_SET_CTX(name, symalgo, hash) \
47 _LC_SYM_SET_CTX((&name->sym), symalgo, name, \
48 (sizeof(struct lc_sh_cryptor))); \
50 (&name->auth_ctx), hash, name, \
51 (sizeof(struct lc_sh_cryptor) + LC_SYM_STATE_SIZE(symalgo)))
53#define LC_SH_SET_CTX(name, sym, hash) \
54 LC_AEAD_CTX(name, lc_symhmac_aead); \
55 _LC_SH_SET_CTX(((struct lc_sh_cryptor *)name->aead_state), sym, hash)
310 struct lc_aead_ctx **ctx);
321#define LC_SH_CTX_ON_STACK(name, sym, hash) \
322 _Pragma("GCC diagnostic push") \
323 _Pragma("GCC diagnostic ignored \"-Wvla\"") _Pragma( \
324 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
325 LC_ALIGNED_BUFFER(name##_ctx_buf, LC_SH_CTX_SIZE(sym), \
326 LC_HASH_COMMON_ALIGNMENT); \
327 struct lc_aead_ctx *name = (struct lc_aead_ctx *)name##_ctx_buf; \
328 LC_SH_SET_CTX(name, sym, hash); \
329 lc_aead_zero(name); \
330 _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_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.