78#define SHA256_BLOCK_SIZE 64
79#define SHA512_BLOCK_SIZE 128
82typedef enum cx_md_e cx_md_t;
88#define CX_HASH_MAX_BLOCK_COUNT 65535
91typedef struct cx_hash_header_s cx_hash_t;
101 cx_err_t (*init_func)(cx_hash_t *ctx);
102 cx_err_t (*update_func)(cx_hash_t *ctx,
105 cx_err_t (*finish_func)(cx_hash_t *ctx, uint8_t *digest);
106 cx_err_t (*init_ex_func)(
109 size_t (*output_size_func)(
const cx_hash_t *ctx);
115struct cx_hash_header_s {
116 const cx_hash_info_t *info;
120size_t cx_hash_get_size(
const cx_hash_t *ctx);
150WARN_UNUSED_RESULT cx_err_t cx_hash_no_throw(cx_hash_t *hash,
161DEPRECATED
static inline size_t cx_hash(cx_hash_t *hash,
163 const unsigned char *in,
166 unsigned int out_len)
168 CX_THROW(cx_hash_no_throw(hash, mode, in, len, out, out_len));
169 return cx_hash_get_size(hash);
184WARN_UNUSED_RESULT cx_err_t cx_hash_init(cx_hash_t *hash, cx_md_t hash_id);
206WARN_UNUSED_RESULT cx_err_t cx_hash_init_ex(cx_hash_t *hash, cx_md_t hash_id,
size_t output_size);
225WARN_UNUSED_RESULT cx_err_t cx_hash_update(cx_hash_t *hash,
const uint8_t *in,
size_t in_len);
240WARN_UNUSED_RESULT cx_err_t cx_hash_final(cx_hash_t *hash, uint8_t *digest);
248const cx_hash_info_t *cx_hash_get_info(cx_md_t md_type);
261void cx_hkdf_extract(
const cx_md_t hash_id,
262 const unsigned char *ikm,
263 unsigned int ikm_len,
265 unsigned int salt_len,
279void cx_hkdf_expand(
const cx_md_t hash_id,
280 const unsigned char *prk,
281 unsigned int prk_len,
283 unsigned int info_len,
285 unsigned int okm_len);