20#ifndef LC_HASH_CRYPT_H
21#define LC_HASH_CRYPT_H
42#define LC_HC_KEYSTREAM_BLOCK 64
45 struct lc_rng_ctx drbg;
46 uint8_t drbg_state[LC_DRBG_HASH_STATE_SIZE];
47 struct lc_hmac_ctx auth_ctx;
49 uint8_t keystream[LC_HC_KEYSTREAM_BLOCK];
52#define LC_HC_CTX_SIZE(x) \
53 (sizeof(struct lc_aead) + sizeof(struct lc_hc_cryptor) + \
54 LC_HMAC_STATE_SIZE(x))
57extern const struct lc_aead *lc_hash_aead;
59#define _LC_HC_SET_CTX(name, hashname) \
60 LC_DRBG_HASH_RNG_CTX((&name->drbg)); \
61 _LC_HMAC_SET_CTX((&name->auth_ctx), hashname, name, \
62 (sizeof(struct lc_hc_cryptor)))
64#define LC_HC_SET_CTX(name, hashname) \
65 LC_AEAD_CTX(name, lc_hash_aead); \
66 _LC_HC_SET_CTX(((struct lc_hc_cryptor *)name->aead_state), hashname)
78 struct lc_hmac_ctx *auth_ctx = &hc->auth_ctx;
101#define LC_HC_CTX_ON_STACK(name, hash) \
102 _Pragma("GCC diagnostic push") \
103 _Pragma("GCC diagnostic ignored \"-Wvla\"") _Pragma( \
104 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
105 LC_ALIGNED_BUFFER(name##_ctx_buf, \
106 LC_HC_CTX_SIZE(hash), \
107 LC_HASH_COMMON_ALIGNMENT); \
108 struct lc_aead_ctx *name = (struct lc_aead_ctx *)name##_ctx_buf; \
109 LC_HC_SET_CTX(name, hash); \
110 lc_aead_zero(name); \
111 _Pragma("GCC diagnostic pop")
static size_t lc_hmac_macsize(struct lc_hmac_ctx *hmac_ctx)
Return the MAC size.
void lc_hash(const struct lc_hash *hash, const uint8_t *in, size_t inlen, uint8_t *digest)
Calculate message digest - one-shot.
static size_t lc_hc_get_tagsize(struct lc_hc_cryptor *hc)
Return maximum size of authentication tag.
int lc_hc_alloc(const struct lc_hash *hash, struct lc_aead_ctx **ctx)
Allocate Hash cryptor context on heap.