Hash#

EverCrypt provides multiple hash algorithms, i.e., …

  • Blake2B,

  • Blake2S,

  • SHA2-224,

  • SHA2-256,

  • SHA2-384,

  • SHA2-512,

  • SHA1, and

  • MD5

… via a unified interface.

Typedefs#

Spec_Hash_Definitions_SHA2_224#
Spec_Hash_Definitions_SHA2_256#
Spec_Hash_Definitions_SHA2_384#
Spec_Hash_Definitions_SHA2_512#
Spec_Hash_Definitions_SHA1#
Spec_Hash_Definitions_MD5#
Spec_Hash_Definitions_Blake2S#
Spec_Hash_Definitions_Blake2B#
typedef struct EverCrypt_Hash_Incremental_state_t_s EverCrypt_Hash_Incremental_state_t#

Functions#

void EverCrypt_Hash_Incremental_hash(Spec_Hash_Definitions_hash_alg a, uint8_t *output, uint8_t *input, uint32_t input_len)#

Hash input, of len input_len, into output, an array whose length is determined by your choice of algorithm a (see Hacl_Spec.h). You can use the macros defined earlier in this file to allocate a destination buffer of the right length. This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before.

a Algorithm to use. dst Pointer to digest. input Pointer to message. len Length of message.


EverCrypt_Hash_Incremental_state_t *EverCrypt_Hash_Incremental_malloc(Spec_Hash_Definitions_hash_alg a)#

Allocate initial state for the agile hash. The argument a stands for the choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most efficient implementation, provided you have called EverCrypt_AutoConfig2_init() before. The state is to be freed by calling free.

Create a hash state.

a Algorithm to use.

void EverCrypt_Hash_Incremental_reset(EverCrypt_Hash_Incremental_state_t *state)#

Reset an existing state to the initial hash state with empty data.

Reset hash state).

s The hash state.

EverCrypt_Error_error_code EverCrypt_Hash_Incremental_update(EverCrypt_Hash_Incremental_state_t *state, uint8_t *chunk, uint32_t chunk_len)#

Feed an arbitrary amount of data into the hash. This function returns EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if the combined length of all of the data passed to update (since the last call to init) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of algorithm. Both limits are unlikely to be attained in practice.

Feed the next chunk of the message that will be hashed.

p The hash state. data Pointer to the next chunk of the message that will be hashed. len Length of the next chunk of the message that will be hashed.

void EverCrypt_Hash_Incremental_digest(EverCrypt_Hash_Incremental_state_t *state, uint8_t *output)#

Write the resulting hash into output, an array whose length is algorithm-specific. You can use the macros defined earlier in this file to allocate a destination buffer of the right length. The state remains valid after a call to digest, meaning the user may feed more data into the hash via update. (The finish function operates on an internal copy of the state and therefore does not invalidate the client-held state.)

Finish the hash calculation and write the digest to dst.

s The hash state. dst Pointer to digest.

void EverCrypt_Hash_Incremental_free(EverCrypt_Hash_Incremental_state_t *state)#

Free a state previously allocated with create_in.

Cleanup the hash state.

s The hash state.

uint32_t EverCrypt_Hash_Incremental_hash_len(Spec_Hash_Definitions_hash_alg a)#
Spec_Hash_Definitions_hash_alg EverCrypt_Hash_Incremental_alg_of_state(EverCrypt_Hash_Incremental_state_t *s)#

Perform a run-time test to determine which algorithm was chosen for the given piece of state.