Ordo
0.3.4
Symmetric Cryptography Library
|
Module. More...
#include "ordo/primitives/hash_functions.h"
Go to the source code of this file.
Macros | |
#define | ordo_digest_init |
#define | ordo_digest_update |
#define | ordo_digest_final |
#define | ordo_digest_bsize |
Functions | |
ORDO_PUBLIC size_t | digest_length (prim_t hash) |
Module.
Module to compute cryptographic digests, using cryptographic hash function primitives.
The advantage of using this digest module instead of the hash function abstraction layer is this keeps track of the hash function primitive for you within an opaque DIGEST_CTX
context structure, simplifying code and making it less error-prone.
Usage snippet:
#define ordo_digest_init |
Initializes a digest context.
[in,out] | ctx | A digest context. |
[in] | primitive | A hash function primitive. |
[in] | params | Hash function parameters. |
ORDO_SUCCESS
on success, else an error code.0
into params
if you don't want to use special features offered by a specific hash function.digest_final()
, this is because some algorithms may allocate additional memory depending on the parameters given. #define ordo_digest_update |
Feeds data into a digest context.
[in,out] | ctx | An initialized digest context. |
[in] | in | The data to feed into the context. |
[in] | in_len | The length, in bytes, of the data. |
hash_update()
, in that it will concatenate the input buffers of successive calls.in_len == 0
), which will do nothing (if this is the case, in
may be 0
). #define ordo_digest_final |
Finalizes a digest context, returning the digest of all the data fed into it through successive digest_update()
calls.
[in,out] | ctx | An initialized digest context. |
[out] | digest | The output buffer for the digest. |
digest
buffer should be large enough to accomodate the digest - you can query the hash function's default digest length in bytes by the digest_length()
function.digest_init()
is valid and will return the so-called "zero-length" digest, which is the digest of the input of length zero.digest_update()
again until you reinitialize the context using digest_init()
. #define ordo_digest_bsize |
Gets the size in bytes of a DIGEST_CTX
.
ORDO_PUBLIC size_t digest_length | ( | prim_t | hash | ) |
Returns the default digest length of a hash function.
[in] | hash | A hash function primitive. |
digest
parameter of digest_final()
.