Hash
include/drip/hash.h
Structures and Types
| Type | Name |
|---|---|
| typedef int(* | drip_hash_cb_t Callback function type for producing hashes. |
| typedef uint8_t | drip_hash_t |
Functions
| Type | Name |
|---|---|
| int | drip_hash (const uint8_t *input, size_t input_length, const uint8_t *customization, size_t customization_length, drip_hash_t *hash, drip_hash_cb_t callback, void *context) Hash input using a caller supplied callback. |
| int | drip_hash_to_hex (const drip_hash_t *hash, char *hex, size_t hex_size) |
Macros
| Type | Name |
|---|---|
| define | DRIP_AUTH_HASH_CUSTOMIZATION "Remote ID Auth Hash" RFC 9575 hash customization string for Remote ID authentication hashes. |
| define | DRIP_HASH_SIZE 8 |
Structures and Types Documentation
typedef drip_hash_cb_t
Callback function type for producing hashes.
typedef int(* drip_hash_cb_t) (void *context, const uint8_t *input, size_t input_length, const uint8_t *customization, size_t customization_length, uint8_t *buffer, size_t buffer_size, size_t *output_length);
Called by drip_hash() to perform the actual hashing of the payload.
Parameters:
contextOpaque context passed to the callback.inputPointer to the payload to hash.input_lengthLength of the payload in bytes.customizationPointer to the hash customization string or NULL.customization_lengthLength of the customization string in bytes.bufferOutput buffer for the hash.buffer_sizeSize of the hash buffer in bytes.output_lengthReceives resulting hash length written.
Return value:
0on success.Non-zeroon hashing failure.
typedef drip_hash_t
typedef uint8_t drip_hash_t[8];
Functions Documentation
function drip_hash
Hash input using a caller supplied callback.
int drip_hash (
const uint8_t *input,
size_t input_length,
const uint8_t *customization,
size_t customization_length,
drip_hash_t *hash,
drip_hash_cb_t callback,
void *context
)
Parameters:
inputPointer to the payload to hash.input_lengthLength of the payload in bytes.customizationPointer to the hash customization string or NULL.customization_lengthLength of the customization string in bytes.hashOutput buffer for the hash.callbackCallback function used to generate the hash.contextOpaque context passed to the callback.
Return value:
DRIP_SUCCESSif the hash was generated.DRIP_ERROR_NULL_POINTERif input or hash or callback is NULL or if customization is NULL with customization_length > 0.DRIP_ERROR_CALLBACK_FAILEDif callback returned an error.DRIP_ERROR_INVALID_LENGTHif resulting hash size does not match DRIP_HASH_SIZE.
function drip_hash_to_hex
int drip_hash_to_hex (
const drip_hash_t *hash,
char *hex,
size_t hex_size
)
Macros Documentation
define DRIP_AUTH_HASH_CUSTOMIZATION
RFC 9575 hash customization string for Remote ID authentication hashes.
#define DRIP_AUTH_HASH_CUSTOMIZATION "Remote ID Auth Hash"
define DRIP_HASH_SIZE
#define DRIP_HASH_SIZE 8