libhasha 2.2.2
Loading...
Searching...
No Matches
blake3.h File Reference

Header file for the BLAKE3 hashing algorithm. More...

Include dependency graph for blake3.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ha_blake3_context
 BLAKE3 hash state context. More...

Typedefs

typedef HA_EXTERN_C_BEG struct ha_blake3_context ha_blake3_context
 BLAKE3 hash state context.

Functions

HA_PUBFUN void ha_blake3_init (ha_blake3_context *ctx)
 Initializes the BLAKE3 context for hashing.
HA_PUBFUN void ha_blake3_update (ha_blake3_context *ctx, ha_inbuf_t data, size_t length)
 Updates the BLAKE3 hash with more input data.
HA_PUBFUN void ha_blake3_final (ha_blake3_context *ctx, ha_digest_t digest, size_t length)
 Finalizes the BLAKE3 hash and produces the final digest.
HA_PUBFUN void ha_blake3_hash (ha_inbuf_t data, size_t length, ha_digest_t digest, size_t digest_length)
 Computes the BLAKE3 hash in a single operation.

Detailed Description

Header file for the BLAKE3 hashing algorithm.

This file provides the interface for the BLAKE3 cryptographic hash function, including the definition of the hash state context and function declarations for initializing, updating, finalizing, and computing the hash in a one-shot operation.

The BLAKE3 algorithm is designed for high performance and security, processing data in chunks and producing variable-length digests. This header is part of the libhasha library.

Note
The implementation assumes that the target system supports the necessary integer types and that sufficient memory is allocated for the digest.
See also
https://github.com/BLAKE3-team/BLAKE3 for further details on the BLAKE3 algorithm.

Definition in file blake3.h.

Typedef Documentation

◆ ha_blake3_context

typedef HA_EXTERN_C_BEG struct ha_blake3_context ha_blake3_context

BLAKE3 hash state context.

This structure holds the internal state of the BLAKE3 hashing algorithm. It includes buffers for input data, the current hash state, and other necessary variables for processing the data in chunks.

Function Documentation

◆ ha_blake3_final()

HA_PUBFUN void ha_blake3_final ( ha_blake3_context * ctx,
ha_digest_t digest,
size_t length )

Finalizes the BLAKE3 hash and produces the final digest.

This function finishes the hash computation, producing the final digest from the data that has been passed to blake3_update. The length of the resulting digest is specified by the caller.

Parameters
ctxPointer to the BLAKE3 context structure.
digestPointer to a buffer where the resulting digest will be stored.
lengthThe length of the digest to be produced, in bytes.

◆ ha_blake3_hash()

HA_PUBFUN void ha_blake3_hash ( ha_inbuf_t data,
size_t length,
ha_digest_t digest,
size_t digest_length )

Computes the BLAKE3 hash in a single operation.

This function combines the initialization, update, and finalization steps into a single call. It processes the input data and immediately produces the digest. This is a more convenient alternative when only a single input is available.

Parameters
dataPointer to the input data to be hashed.
lengthThe length of the input data in bytes.
digestPointer to a buffer where the resulting digest will be stored.
digest_lengthThe length of the digest to be produced, in bytes.

◆ ha_blake3_init()

HA_PUBFUN void ha_blake3_init ( ha_blake3_context * ctx)

Initializes the BLAKE3 context for hashing.

This function sets up the initial state of the BLAKE3 context by clearing the internal state and preparing it to receive input data.

Parameters
ctxPointer to a BLAKE3 context structure to be initialized.

◆ ha_blake3_update()

HA_PUBFUN void ha_blake3_update ( ha_blake3_context * ctx,
ha_inbuf_t data,
size_t length )

Updates the BLAKE3 hash with more input data.

This function adds additional data to the ongoing hash computation. It can be called multiple times with chunks of data until all data has been processed.

Parameters
ctxPointer to the BLAKE3 context structure.
dataPointer to the input data to be hashed.
lengthThe length of the input data in bytes.