Ordo
0.3.4
Symmetric Cryptography Library
|
Abstraction Layer. More...
#include "ordo/primitives/hash_functions/hash_params.h"
Go to the source code of this file.
Functions | |
ORDO_PUBLIC int | hash_init (struct HASH_STATE *state, prim_t primitive, const void *params) |
ORDO_PUBLIC void | hash_update (struct HASH_STATE *state, const void *buffer, size_t len) |
ORDO_PUBLIC void | hash_final (struct HASH_STATE *state, void *digest) |
ORDO_PUBLIC size_t | hash_query (prim_t primitive, int query, size_t value) |
ORDO_PUBLIC size_t | hash_bsize (void) |
Abstraction Layer.
This abstraction layer declares all the hash functions and also makes them available to higher level modules - for a slightly more convenient wrapper to this interface, you can use digest.h
.
ORDO_PUBLIC int hash_init | ( | struct HASH_STATE * | state, |
prim_t | primitive, | ||
const void * | params | ||
) |
Initializes a hash function state.
[in,out] | state | A hash function state. |
[in] | primitive | A hash function primitive. |
[in] | params | Hash function specific parameters. |
ORDO_SUCCESS
on success, else an error code. ORDO_PUBLIC void hash_update | ( | struct HASH_STATE * | state, |
const void * | buffer, | ||
size_t | len | ||
) |
Updates a hash function state by appending a buffer to the message this state is to calculate the cryptographic digest of.
[in,out] | state | An initialized hash function state. |
[in] | buffer | A buffer to append to the message. |
[in] | len | The length, in bytes, of the buffer. |
update(x)
followed by update(y)
is equivalent to update(x || y)
, where ||
denotes concatenation.ORDO_PUBLIC void hash_final | ( | struct HASH_STATE * | state, |
void * | digest | ||
) |
Finalizes a hash function state, outputting the final digest.
[in,out] | state | An initialized hash function state. |
[out] | digest | A buffer in which to write the digest. |
digest
buffer should be as large as the hash function's digest length (unless you changed it via custom parameters). ORDO_PUBLIC size_t hash_query | ( | prim_t | primitive, |
int | query, | ||
size_t | value | ||
) |
Queries a hash function for suitable parameters.
[in] | primitive | A hash function primitive. |
[in] | query | A query code. |
[in] | value | A suggested value. |
query
based on value
.ORDO_PUBLIC size_t hash_bsize | ( | void | ) |
Gets the size in bytes of a HASH_STATE
.