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

Header file for SHA3 cryptographic hash functions. More...

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

Go to the source code of this file.

Macros

#define HA_SHA3_224_DIGEST_SIZE   ha_bB(224)
 The digest size (in bytes) for the SHA3-224 algorithm (224 bits).
#define HA_SHA3_256_DIGEST_SIZE   ha_bB(256)
 The digest size (in bytes) for the SHA3-256 algorithm (256 bits).
#define HA_SHA3_384_DIGEST_SIZE   ha_bB(384)
 The digest size (in bytes) for the SHA3-384 algorithm (384 bits).
#define HA_SHA3_512_DIGEST_SIZE   ha_bB(512)
 The digest size (in bytes) for the SHA3-512 algorithm (512 bits).

Typedefs

typedef struct ha_keccak_context ha_sha3_context
typedef ha_sha3_context ha_sha3_224_context
typedef ha_sha3_context ha_sha3_256_context
typedef ha_sha3_context ha_sha3_384_context
typedef ha_sha3_context ha_sha3_512_context

Functions

HA_PUBFUN void ha_sha3_224_init (ha_sha3_224_context *ctx)
 Initializes the SHA3-224 context.
HA_PUBFUN void ha_sha3_224_update (ha_sha3_224_context *ctx, ha_inbuf_t data, size_t length)
 Absorbs data into the SHA3-224 context.
HA_PUBFUN void ha_sha3_224_final (ha_sha3_224_context *ctx, ha_digest_t digest)
 Finalizes the SHA3-224 computation.
HA_PUBFUN void ha_sha3_224_hash (ha_inbuf_t data, size_t length, ha_digest_t digest)
 Computes the SHA3-224 hash in a one-shot operation.
HA_PUBFUN void ha_sha3_256_init (ha_sha3_256_context *ctx)
 Initializes the SHA3-256 context.
HA_PUBFUN void ha_sha3_256_update (ha_sha3_256_context *ctx, ha_inbuf_t data, size_t length)
 Absorbs data into the SHA3-256 context.
HA_PUBFUN void ha_sha3_256_final (ha_sha3_256_context *ctx, ha_digest_t digest)
 Finalizes the SHA3-256 computation.
HA_PUBFUN void ha_sha3_256_hash (ha_inbuf_t data, size_t length, ha_digest_t digest)
 Computes the SHA3-256 hash in a one-shot operation.
HA_PUBFUN void ha_sha3_384_init (ha_sha3_384_context *ctx)
 Initializes the SHA3-384 context.
HA_PUBFUN void ha_sha3_384_update (ha_sha3_384_context *ctx, ha_inbuf_t data, size_t length)
 Absorbs data into the SHA3-384 context.
HA_PUBFUN void ha_sha3_384_final (ha_sha3_384_context *ctx, ha_digest_t digest)
 Finalizes the SHA3-384 computation.
HA_PUBFUN void ha_sha3_384_hash (ha_inbuf_t data, size_t length, ha_digest_t digest)
 Computes the SHA3-384 hash in a one-shot operation.
HA_PUBFUN void ha_sha3_512_init (ha_sha3_512_context *ctx)
 Initializes the SHA3-512 context.
HA_PUBFUN void ha_sha3_512_update (ha_sha3_512_context *ctx, ha_inbuf_t data, size_t length)
 Absorbs data into the SHA3-512 context.
HA_PUBFUN void ha_sha3_512_final (ha_sha3_512_context *ctx, ha_digest_t digest)
 Finalizes the SHA3-512 computation.
HA_PUBFUN void ha_sha3_512_hash (ha_inbuf_t data, size_t length, ha_digest_t digest)
 Computes the SHA3-512 hash in a one-shot operation.

Detailed Description

Header file for SHA3 cryptographic hash functions.

This header file defines the interface for the SHA3 family of hash functions, including SHA3-224, SHA3-256, SHA3-384, and SHA3-512. It provides macro definitions for the rate and digest sizes of each variant, a common context structure for holding the internal state during the hashing process, and function declarations for initializing, absorbing data, finalizing, squeezing the digest, and performing one-shot hash computations.

The SHA3 functions utilize the Keccak-f[1600] permutation (see keccak1600.h) as the core transformation. The library processes input data in chunks and generates a hash digest according to the variant's specification.

Note
The rate and digest sizes are defined in accordance with the SHA3 standard.
See also
https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf for further details on the SHA3 standard.

Definition in file sha3.h.

Macro Definition Documentation

◆ HA_SHA3_224_DIGEST_SIZE

#define HA_SHA3_224_DIGEST_SIZE   ha_bB(224)

The digest size (in bytes) for the SHA3-224 algorithm (224 bits).

Definition at line 35 of file sha3.h.

◆ HA_SHA3_256_DIGEST_SIZE

#define HA_SHA3_256_DIGEST_SIZE   ha_bB(256)

The digest size (in bytes) for the SHA3-256 algorithm (256 bits).

Definition at line 41 of file sha3.h.

◆ HA_SHA3_384_DIGEST_SIZE

#define HA_SHA3_384_DIGEST_SIZE   ha_bB(384)

The digest size (in bytes) for the SHA3-384 algorithm (384 bits).

Definition at line 47 of file sha3.h.

◆ HA_SHA3_512_DIGEST_SIZE

#define HA_SHA3_512_DIGEST_SIZE   ha_bB(512)

The digest size (in bytes) for the SHA3-512 algorithm (512 bits).

Definition at line 53 of file sha3.h.

Typedef Documentation

◆ ha_sha3_224_context

Definition at line 66 of file sha3.h.

◆ ha_sha3_256_context

Definition at line 66 of file sha3.h.

◆ ha_sha3_384_context

Definition at line 67 of file sha3.h.

◆ ha_sha3_512_context

Definition at line 67 of file sha3.h.

◆ ha_sha3_context

typedef struct ha_keccak_context ha_sha3_context

Definition at line 64 of file sha3.h.

Function Documentation

◆ ha_sha3_224_final()

HA_PUBFUN void ha_sha3_224_final ( ha_sha3_224_context * ctx,
ha_digest_t digest )

Finalizes the SHA3-224 computation.

This function finals the SHA3-224 hash calculation.

Parameters
ctxPointer to the SHA3-224 context structure.
digestPointer to the output buffer where the final hash will be stored.

◆ ha_sha3_224_hash()

HA_PUBFUN void ha_sha3_224_hash ( ha_inbuf_t data,
size_t length,
ha_digest_t digest )

Computes the SHA3-224 hash in a one-shot operation.

This function computes the SHA3-224 hash of the provided data in a single call. It initializes, absorbs, finals, and squeezes the result internally.

Parameters
dataPointer to the input data to process.
lengthLength of the input data in bytes.
digestPointer to the output buffer to store the final SHA3-224 digest.

◆ ha_sha3_224_init()

HA_PUBFUN void ha_sha3_224_init ( ha_sha3_224_context * ctx)

Initializes the SHA3-224 context.

This function initializes the SHA3-224 context to start a new hash computation.

Parameters
ctxPointer to the SHA3-224 context structure to initialize.

◆ ha_sha3_224_update()

HA_PUBFUN void ha_sha3_224_update ( ha_sha3_224_context * ctx,
ha_inbuf_t data,
size_t length )

Absorbs data into the SHA3-224 context.

This function processes the provided data and updates the SHA3-224 context state.

Parameters
ctxPointer to the SHA3-224 context structure.
dataPointer to the input data to process.
lengthLength of the input data in bytes.

◆ ha_sha3_256_final()

HA_PUBFUN void ha_sha3_256_final ( ha_sha3_256_context * ctx,
ha_digest_t digest )

Finalizes the SHA3-256 computation.

This function finals the SHA3-256 hash calculation.

Parameters
ctxPointer to the SHA3-256 context structure.
digestPointer to the output buffer where the final hash will be stored.

◆ ha_sha3_256_hash()

HA_PUBFUN void ha_sha3_256_hash ( ha_inbuf_t data,
size_t length,
ha_digest_t digest )

Computes the SHA3-256 hash in a one-shot operation.

This function computes the SHA3-256 hash of the provided data in a single call. It initializes, absorbs, finals, and squeezes the result internally.

Parameters
dataPointer to the input data to process.
lengthLength of the input data in bytes.
digestPointer to the output buffer to store the final SHA3-256 digest.

◆ ha_sha3_256_init()

HA_PUBFUN void ha_sha3_256_init ( ha_sha3_256_context * ctx)

Initializes the SHA3-256 context.

This function initializes the SHA3-256 context to start a new hash computation.

Parameters
ctxPointer to the SHA3-256 context structure to initialize.

◆ ha_sha3_256_update()

HA_PUBFUN void ha_sha3_256_update ( ha_sha3_256_context * ctx,
ha_inbuf_t data,
size_t length )

Absorbs data into the SHA3-256 context.

This function processes the provided data and updates the SHA3-256 context state.

Parameters
ctxPointer to the SHA3-256 context structure.
dataPointer to the input data to process.
lengthLength of the input data in bytes.

◆ ha_sha3_384_final()

HA_PUBFUN void ha_sha3_384_final ( ha_sha3_384_context * ctx,
ha_digest_t digest )

Finalizes the SHA3-384 computation.

This function finals the SHA3-384 hash calculation.

Parameters
ctxPointer to the SHA3-384 context structure.
digestPointer to the output buffer where the final hash will be stored.

◆ ha_sha3_384_hash()

HA_PUBFUN void ha_sha3_384_hash ( ha_inbuf_t data,
size_t length,
ha_digest_t digest )

Computes the SHA3-384 hash in a one-shot operation.

This function computes the SHA3-384 hash of the provided data in a single call. It initializes, absorbs, finals, and squeezes the result internally.

Parameters
dataPointer to the input data to process.
lengthLength of the input data in bytes.
digestPointer to the output buffer to store the final SHA3-384 digest.

◆ ha_sha3_384_init()

HA_PUBFUN void ha_sha3_384_init ( ha_sha3_384_context * ctx)

Initializes the SHA3-384 context.

This function initializes the SHA3-384 context to start a new hash computation.

Parameters
ctxPointer to the SHA3-384 context structure to initialize.

◆ ha_sha3_384_update()

HA_PUBFUN void ha_sha3_384_update ( ha_sha3_384_context * ctx,
ha_inbuf_t data,
size_t length )

Absorbs data into the SHA3-384 context.

This function processes the provided data and updates the SHA3-384 context state.

Parameters
ctxPointer to the SHA3-384 context structure.
dataPointer to the input data to process.
lengthLength of the input data in bytes.

◆ ha_sha3_512_final()

HA_PUBFUN void ha_sha3_512_final ( ha_sha3_512_context * ctx,
ha_digest_t digest )

Finalizes the SHA3-512 computation.

This function finals the SHA3-512 hash calculation.

Parameters
ctxPointer to the SHA3-512 context structure.
digestPointer to the output buffer where the final hash will be stored.

◆ ha_sha3_512_hash()

HA_PUBFUN void ha_sha3_512_hash ( ha_inbuf_t data,
size_t length,
ha_digest_t digest )

Computes the SHA3-512 hash in a one-shot operation.

This function computes the SHA3-512 hash of the provided data in a single call. It initializes, absorbs, finals, and squeezes the result internally.

Parameters
dataPointer to the input data to process.
lengthLength of the input data in bytes.
digestPointer to the output buffer to store the final SHA3-512 digest.

◆ ha_sha3_512_init()

HA_PUBFUN void ha_sha3_512_init ( ha_sha3_512_context * ctx)

Initializes the SHA3-512 context.

This function initializes the SHA3-512 context to start a new hash computation.

Parameters
ctxPointer to the SHA3-512 context structure to initialize.

◆ ha_sha3_512_update()

HA_PUBFUN void ha_sha3_512_update ( ha_sha3_512_context * ctx,
ha_inbuf_t data,
size_t length )

Absorbs data into the SHA3-512 context.

This function processes the provided data and updates the SHA3-512 context state.

Parameters
ctxPointer to the SHA3-512 context structure.
dataPointer to the input data to process.
lengthLength of the input data in bytes.