26#define ha_ctx(hash) ha_##hash##_context
32#define ha_init_fun(hash) ha_##hash##_init
33#define ha_update_fun(hash) ha_##hash##_update
34#define ha_final_fun(hash) ha_##hash##_final
35#define ha_hash_fun(hash) ha_##hash##_hash
40#define ha_init(hash, ctx) ha_##hash##_init(ctx)
45#define ha_update(hash, ctx, buf, buflen) \
46 ha_##hash##_update(ctx, buf, buflen)
51#define ha_final(hash, ctx, ...) ha_##hash##_final(ctx, ##__VA_ARGS__)
56#define ha_hash(hash, buf, buflen, digest, ...) \
57 ha_##hash##_hash(buf, buflen, digest, ##__VA_ARGS__)
63#define ha_ada_hash(hash, buf, len, digest, ...) \
66 ha_init(hash, &ctx); \
67 ha_update(hash, &ctx, buf, len); \
68 ha_final(hash, &ctx, digest, ##__VA_ARGS__); \
74#define ha_ada_stream_hash(hash, stream, size, chunksize, buffer, digest, \
78 ha_init(hash, &ctx); \
80 while ((bytes = fread((buffer), (size), (chunksize), (stream))) > 0) \
82 ha_update(hash, &ctx, buffer, bytes); \
84 ha_final(hash, &ctx, digest, ##__VA_ARGS__); \
90#ifdef HA_ADA_COMPATIBILITY
91#define ha_buffer_digest(...) ha_ada_hash(__VA_ARGS__)
92#define ha_stream_digest(...) ha_ada_stream_hash(__VA_ARGS__)
96#if ha_has_feature(EVP)
122 HA_EVPTY_SIZE_DYNAMIC = -1,
207 enum ha_evp_hashty hashty);
255 enum ha_evp_hashty hashty,
279 enum ha_evp_hashty hashty,
HA_PUBFUN void ha_evp_fput(struct ha_evp_hasher *hasher, FILE *stream, ha_cdigest_t digest, const char *end)
Put hash to FILE *.
HA_PUBFUN void ha_evp_init(struct ha_evp_hasher *hasher)
Initializes the EVP hash. ( like ha_init(hash, ctx) )
HA_PUBFUN enum ha_evp_hashty ha_evp_hasher_hashty(struct ha_evp_hasher *hasher)
Getter for ha_evp_hasher ctx_hashty field.
HA_PUBFUN struct ha_evp_hasher * ha_evp_hasher_new(void)
Creates a new EVP hasher. ( malloc(g_ha_evp_hasher_size) )
HA_PUBFUN size_t ha_evp_hasher_ctxsize(struct ha_evp_hasher *hasher)
Getter for ha_evp_hasher ctx_size field.
HA_PUBFUN void ha_evp_hasher_set_keccak_custom(struct ha_evp_hasher *hasher, bool custom)
Setter for ha_evp_hasher kustom field.
HA_PUBFUN void ha_evp_hasher_cleanup(struct ha_evp_hasher *hasher)
Cleans up the internal state of the EVP hasher.
HA_PUBFUN void ha_evp_hasher_set_hashty(struct ha_evp_hasher *hasher, enum ha_evp_hashty hashty)
Setter for ha_evp_hasher ctx_hashty field.
HA_PUBFUN void ha_evp_hasher_delete(struct ha_evp_hasher *ptr)
Frees the memory of an EVP hasher.
const size_t g_ha_evp_hasher_size
Size of the EVP hasher structure.
HA_PUBFUN size_t ha_evp_hasher_keccak_rate(struct ha_evp_hasher *hasher)
Getter for ha_evp_hasher krate field.
HA_PUBFUN void ha_evp_hasher_set_digestlen(struct ha_evp_hasher *hasher, size_t digestlen)
Setter for ha_evp_hasher ctx_digestlen field.
HA_PUBFUN void ha_evp_hasher_set_keccak_rate(struct ha_evp_hasher *hasher, uint16_t rate)
Setter for ha_evp_hasher krate field.
HA_PUBFUN void ha_evp_hasher_init(struct ha_evp_hasher *hasher, enum ha_evp_hashty hashty, size_t digestlen)
Initializes the EVP hasher for a specific algorithm and digest length.
HA_PUBFUN void ha_evp_digest(struct ha_evp_hasher *hasher, ha_inbuf_t buf, size_t len, ha_digest_t digest)
Computes the EVP hash in a init, update, final operation. ( like ha_ada_hash(hash,...
HA_PUBFUN bool ha_evp_hasher_keccak_custom(struct ha_evp_hasher *hasher)
Getter for ha_evp_hasher kustom field.
HA_PUBFUN const char * ha_evp_hashty_tostr(enum ha_evp_hashty hashty)
Returns g_ha_evp_hashty_strings[hashty] (with error handling)
HA_PUBFUN void ha_evp_hash(struct ha_evp_hasher *hasher, ha_inbuf_t buf, size_t len, ha_digest_t digest)
Computes the EVP hash in a single (hash) operation. ( like ha_hash(hash, buf, len,...
HA_PUBFUN void ha_evp_hasher_commit(struct ha_evp_hasher *hasher)
Reinitializes the EVP hasher.
HA_EXTERN_C_BEG HA_PUBFUN void ha_evp_put(struct ha_evp_hasher *hasher, ha_cdigest_t digest, const char *end)
Put hash to stdout.
HA_PUBFUN signed long ha_evp_hashty_get_digestlen(enum ha_evp_hashty hashty)
Get fixed hash size.
HA_PUBFUN void ha_evp_update(struct ha_evp_hasher *hasher, ha_inbuf_t buf, size_t len)
Updates the EVP hash with input data. ( like ha_update(hash, ctx, buf, len) )
HA_PUBFUN void ha_evp_hasher_reinit(struct ha_evp_hasher *hasher, enum ha_evp_hashty hashty, size_t digestlen)
Reinitializes the EVP hasher with a new algorithm and digest length.
struct ha_evp_hasher * ha_evp_phasher_t
HA_PUBFUN void ha_evp_final(struct ha_evp_hasher *hasher, ha_digest_t digest)
Finalizes the EVP hash and produces the output digest. ( like ha_final(hash, ctx, digest,...
HA_PUBFUN size_t ha_evp_hasher_digestlen(struct ha_evp_hasher *hasher)
Getter for ha_evp_hasher ctx_digestlen field.
struct ha_evp_hasher ha_evp_hasher_t
Opaque structure for the EVP hasher state.
const __ha_out_buf_type ha_cdigest_t
__ha_out_buf_type ha_digest_t
__ha_in_buf_type ha_inbuf_t