ISARA Quantum Resistant Toolkit  Version 1.1
Quantum resistant cryptographic primitives and algorithms.
iqr_HashCallbacks Struct Reference

#include <iqr_hash.h>

Data Fields

iqr_retval(* initialize )(void **state)
 
iqr_retval(* begin )(void *state)
 
iqr_retval(* update )(void *state, const uint8_t *data, size_t size)
 
iqr_retval(* end )(void *state, uint8_t *digest, size_t size)
 
iqr_retval(* cleanup )(void **state)
 

Field Documentation

§ begin

iqr_retval(* begin) (void *state)

Begin a hashing operation.

Called when hashing is about to begin. If the algorithm needs state, begin() must allocate and initialize the state data.

Parameters
[in]stateHash state, maintained by the implementation.
Returns
IQR_OK or a suitable error value.

§ cleanup

iqr_retval(* cleanup) (void **state)

Clean up the Hash.

Perform any clean up required before the Hash is destroyed, including zeroing and deallocating any state.

If cleanup() returns an error value, the Hash object will be zeroed and deallocated; be sure that your cleanup() deallocates any memory allocated by your initialize().

Parameters
[in,out]stateHash state, maintained by the implementation.
Returns
IQR_OK or a suitable error value.

§ end

iqr_retval(* end) (void *state, uint8_t *digest, size_t size)

End the hashing operation and retrieve the digest.

Called to finalize hashing and retrieve the digest. The digest and size parameters are optional and can be NULL.

Parameters
[in,out]stateHash state, maintained by the implementation.
[in]digestBuffer to receive the digest.
[in]sizeThe size of the digest buffer in bytes.
See also
iqr_HashGetDigestSize().
Returns
IQR_OK or a suitable error value.

§ initialize

iqr_retval(* initialize) (void **state)

Initialize the Hash.

Called to initialize the Hash object. Allocate any necessary state here.

If initialize() returns an error value, the call to iqr_HashCreate() will return the failure value without allocating memory.

Parameters
[out]statePointer to Hash state, maintained by the implementation.
Returns
IQR_OK or a suitable error value.

§ update

iqr_retval(* update) (void *state, const uint8_t *data, size_t size)

Add data to the hashing operation.

Called when data needs to be hashed.

Parameters
[in]stateHash state.
[in]dataBuffer containing bytes to hash.
[in]sizeThe size of data in bytes.
Returns
IQR_OK or a suitable error value.

Detailed Description

Callbacks required for Hash implementations.

You can supply your own SHA-2 or SHA-3 by implementing these functions; for example, you could take advantage of OpenSSL's hand-tuned assembly versions. See the Developer's Guide for details.