25#ifndef BR_BEARSSL_HASH_H__
26#define BR_BEARSSL_HASH_H__
269 void (*
init)(
const br_hash_class **ctx);
285 void (*
update)(
const br_hash_class **ctx,
const void *data,
size_t len);
300 void (*
out)(
const br_hash_class *
const *ctx,
void *dst);
316 uint64_t (*
state)(
const br_hash_class *
const *ctx,
void *dst);
328 const void *stb, uint64_t count);
331#ifndef BR_DOXYGEN_IGNORE
332#define BR_HASHDESC_ID(id) ((uint32_t)(id) << BR_HASHDESC_ID_OFF)
333#define BR_HASHDESC_ID_OFF 0
334#define BR_HASHDESC_ID_MASK 0xFF
336#define BR_HASHDESC_OUT(size) ((uint32_t)(size) << BR_HASHDESC_OUT_OFF)
337#define BR_HASHDESC_OUT_OFF 8
338#define BR_HASHDESC_OUT_MASK 0x7F
340#define BR_HASHDESC_STATE(size) ((uint32_t)(size) << BR_HASHDESC_STATE_OFF)
341#define BR_HASHDESC_STATE_OFF 15
342#define BR_HASHDESC_STATE_MASK 0xFF
344#define BR_HASHDESC_LBLEN(ls) ((uint32_t)(ls) << BR_HASHDESC_LBLEN_OFF)
345#define BR_HASHDESC_LBLEN_OFF 23
346#define BR_HASHDESC_LBLEN_MASK 0x0F
348#define BR_HASHDESC_MD_PADDING ((uint32_t)1 << 28)
349#define BR_HASHDESC_MD_PADDING_128 ((uint32_t)1 << 29)
350#define BR_HASHDESC_MD_PADDING_BE ((uint32_t)1 << 30)
376#define br_md5_SIZE 16
394#ifndef BR_DOXYGEN_IGNORE
395 unsigned char buf[64];
471#define br_sha1_SIZE 20
489#ifndef BR_DOXYGEN_IGNORE
490 unsigned char buf[64];
561#define br_sha224_ID 3
566#define br_sha224_SIZE 28
584#ifndef BR_DOXYGEN_IGNORE
585 unsigned char buf[64];
652 const void *stb, uint64_t count);
657#define br_sha256_ID 4
662#define br_sha256_SIZE 32
669#ifdef BR_DOXYGEN_IGNORE
696#ifdef BR_DOXYGEN_IGNORE
710#define br_sha256_update br_sha224_update
742#define br_sha256_state br_sha224_state
756 const void *stb, uint64_t count);
758#define br_sha256_set_state br_sha224_set_state
764#define br_sha384_ID 5
769#define br_sha384_SIZE 48
787#ifndef BR_DOXYGEN_IGNORE
788 unsigned char buf[128];
855 const void *stb, uint64_t count);
860#define br_sha512_ID 6
865#define br_sha512_SIZE 64
872#ifdef BR_DOXYGEN_IGNORE
899#ifdef BR_DOXYGEN_IGNORE
913#define br_sha512_update br_sha384_update
930#ifdef BR_DOXYGEN_IGNORE
945#define br_sha512_state br_sha384_state
948#ifdef BR_DOXYGEN_IGNORE
959 const void *stb, uint64_t count);
961#define br_sha512_set_state br_sha384_set_state
977#define br_md5sha1_ID 0
982#define br_md5sha1_SIZE 36
1000#ifndef BR_DOXYGEN_IGNORE
1001 unsigned char buf[64];
1003 uint32_t val_md5[4];
1004 uint32_t val_sha1[5];
1069 const void *stb, uint64_t count);
1108#ifndef BR_DOXYGEN_IGNORE
1109 unsigned char buf[128];
1111 uint32_t val_32[25];
1112 uint64_t val_64[16];
1113 const br_hash_class *impl[6];
1143 int id,
const br_hash_class *impl)
1149 ctx->impl[
id - 1] = impl;
1163static inline const br_hash_class *
1166 return ctx->impl[
id - 1];
1191 const void *data,
size_t len);
1239typedef void (*
br_ghash)(
void *y,
const void *h,
const void *data,
size_t len);
Class type for hash function implementations.
Definition bearssl_hash.h:222
void(* init)(const br_hash_class **ctx)
Initialisation method.
Definition bearssl_hash.h:269
uint32_t desc
Descriptor word that contains information about the hash function.
Definition bearssl_hash.h:257
uint64_t(* state)(const br_hash_class *const *ctx, void *dst)
Get running state.
Definition bearssl_hash.h:316
void(* out)(const br_hash_class *const *ctx, void *dst)
Produce hash output.
Definition bearssl_hash.h:300
void(* set_state)(const br_hash_class **ctx, const void *stb, uint64_t count)
Set running state.
Definition bearssl_hash.h:327
size_t context_size
Size (in bytes) of the context structure appropriate for computing this hash function.
Definition bearssl_hash.h:227
void(* update)(const br_hash_class **ctx, const void *data, size_t len)
Data injection method.
Definition bearssl_hash.h:285
MD5 context.
Definition bearssl_hash.h:389
const br_hash_class * vtable
Pointer to vtable for this context.
Definition bearssl_hash.h:393
MD5+SHA-1 context.
Definition bearssl_hash.h:995
const br_hash_class * vtable
Pointer to vtable for this context.
Definition bearssl_hash.h:999
Multi-hasher context structure.
Definition bearssl_hash.h:1107
SHA-1 context.
Definition bearssl_hash.h:484
const br_hash_class * vtable
Pointer to vtable for this context.
Definition bearssl_hash.h:488
SHA-224 context.
Definition bearssl_hash.h:579
const br_hash_class * vtable
Pointer to vtable for this context.
Definition bearssl_hash.h:583
SHA-256 context.
Definition bearssl_hash.h:676
const br_hash_class * vtable
Pointer to vtable for this context.
Definition bearssl_hash.h:680
SHA-384 context.
Definition bearssl_hash.h:782
const br_hash_class * vtable
Pointer to vtable for this context.
Definition bearssl_hash.h:786
SHA-512 context.
Definition bearssl_hash.h:879
const br_hash_class * vtable
Pointer to vtable for this context.
Definition bearssl_hash.h:883
Aggregate context for configurable hash function support.
Definition bearssl_hash.h:1077
br_sha256_context sha256
Definition bearssl_hash.h:1082
br_sha384_context sha384
Definition bearssl_hash.h:1083
br_sha224_context sha224
Definition bearssl_hash.h:1081
br_sha512_context sha512
Definition bearssl_hash.h:1084
br_md5sha1_context md5sha1
Definition bearssl_hash.h:1085
br_md5_context md5
Definition bearssl_hash.h:1079
const br_hash_class * vtable
Definition bearssl_hash.h:1078
br_sha1_context sha1
Definition bearssl_hash.h:1080