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:

  • context Opaque context passed to the callback.
  • input Pointer to the payload to hash.
  • input_length Length of the payload in bytes.
  • customization Pointer to the hash customization string or NULL.
  • customization_length Length of the customization string in bytes.
  • buffer Output buffer for the hash.
  • buffer_size Size of the hash buffer in bytes.
  • output_length Receives resulting hash length written.

Return value:

  • 0 on success.
  • Non-zero on 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:

  • input Pointer to the payload to hash.
  • input_length Length of the payload in bytes.
  • customization Pointer to the hash customization string or NULL.
  • customization_length Length of the customization string in bytes.
  • hash Output buffer for the hash.
  • callback Callback function used to generate the hash.
  • context Opaque context passed to the callback.

Return value:

  • DRIP_SUCCESS if the hash was generated.
  • DRIP_ERROR_NULL_POINTER if input or hash or callback is NULL or if customization is NULL with customization_length > 0.
  • DRIP_ERROR_CALLBACK_FAILED if callback returned an error.
  • DRIP_ERROR_INVALID_LENGTH if 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