libhasha 2.2.2
|
Header file for Keccak-based hash functions. More...
#include "internal/internal.h"
Go to the source code of this file.
Classes | |
struct | ha_keccak_context |
Keccak hash state context. More... |
Macros | |
#define | HA_KECCAK_224_DIGEST_SIZE ha_bB(224) |
The digest size for the Keccak-224 hash function. | |
#define | HA_KECCAK_256_DIGEST_SIZE ha_bB(256) |
The digest size for the Keccak-256 hash function. | |
#define | HA_KECCAK_384_DIGEST_SIZE ha_bB(384) |
The digest size for the Keccak-384 hash function. | |
#define | HA_KECCAK_512_DIGEST_SIZE ha_bB(512) |
The digest size for the Keccak-512 hash function. |
Typedefs | |
typedef struct ha_keccak_context | ha_keccak_context |
typedef ha_keccak_context | ha_keccak_224_context |
typedef ha_keccak_context | ha_keccak_256_context |
typedef ha_keccak_context | ha_keccak_384_context |
typedef ha_keccak_context | ha_keccak_512_context |
Functions | |
enum ha_pb | ha_enum_base (uint8_t) |
HA_PUBFUN void | ha_keccak_init (ha_keccak_context *ctx, size_t rate) |
Initializes the Keccak-Based context. | |
HA_PUBFUN void | ha_keccak_update (ha_keccak_context *ctx, ha_inbuf_t buf, size_t len) |
Absorbs data into the Keccak-Based context. | |
HA_PUBFUN void | ha_keccak_final (ha_keccak_context *ctx, enum ha_pb padbyte, ha_digest_t digest, size_t digestlen) |
Finalizes the Keccak-Based computation. | |
HA_PUBFUN void | ha_keccak_hash (size_t rate, enum ha_pb padbyte, ha_inbuf_t buf, size_t len, ha_digest_t digest, size_t digestlen) |
Computes the Keccak-Based hash in a one-shot operation. | |
HA_PUBFUN void | ha_keccak_224_init (ha_keccak_224_context *ctx) |
Initializes the Keccak-224 context. | |
HA_PUBFUN void | ha_keccak_224_update (ha_keccak_224_context *ctx, ha_inbuf_t data, size_t length) |
Absorbs input data for Keccak-224. | |
HA_PUBFUN void | ha_keccak_224_final (ha_keccak_224_context *ctx, ha_digest_t digest) |
Finalizes the Keccak-224 context. | |
HA_PUBFUN void | ha_keccak_224_hash (ha_inbuf_t data, size_t length, ha_digest_t digest) |
Computes the Keccak-224 hash in a single operation. | |
HA_PUBFUN void | ha_keccak_256_init (ha_keccak_256_context *ctx) |
Initializes the Keccak-256 context. | |
HA_PUBFUN void | ha_keccak_256_update (ha_keccak_256_context *ctx, ha_inbuf_t data, size_t length) |
Absorbs input data for Keccak-256. | |
HA_PUBFUN void | ha_keccak_256_final (ha_keccak_256_context *ctx, ha_digest_t digest) |
Finalizes the Keccak-256 context. | |
HA_PUBFUN void | ha_keccak_256_hash (ha_inbuf_t data, size_t length, ha_digest_t digest) |
Computes the Keccak-256 hash in a single operation. | |
HA_PUBFUN void | ha_keccak_384_init (ha_keccak_384_context *ctx) |
Initializes the Keccak-384 context. | |
HA_PUBFUN void | ha_keccak_384_update (ha_keccak_384_context *ctx, ha_inbuf_t data, size_t length) |
Absorbs input data for Keccak-384. | |
HA_PUBFUN void | ha_keccak_384_final (ha_keccak_384_context *ctx, ha_digest_t digest) |
Finalizes the Keccak-384 context. | |
HA_PUBFUN void | ha_keccak_384_hash (ha_inbuf_t data, size_t length, ha_digest_t digest) |
Computes the Keccak-384 hash in a single operation. | |
HA_PUBFUN void | ha_keccak_512_init (ha_keccak_512_context *ctx) |
Initializes the Keccak-512 context. | |
HA_PUBFUN void | ha_keccak_512_update (ha_keccak_512_context *ctx, ha_inbuf_t data, size_t length) |
Absorbs input data for Keccak-512. | |
HA_PUBFUN void | ha_keccak_512_final (ha_keccak_512_context *ctx, ha_digest_t digest) |
Finalizes the Keccak-512 context. | |
HA_PUBFUN void | ha_keccak_512_hash (ha_inbuf_t data, size_t length, ha_digest_t digest) |
Computes the Keccak-512 hash in a single operation. |
Header file for Keccak-based hash functions.
This header file defines the interface for various Keccak hash functions, including Keccak-224, Keccak-256, Keccak-384, and Keccak-512. It provides macro definitions for the rate and digest sizes of each variant, as well as a common context structure for holding the internal state of the hash computation.
The functions declared in this file include those for initializing the context, absorbing input data, finalizing the hash computation, and squeezing out the final digest. Additionally, one-shot operations are provided for convenience.
The core transformation is based on the Keccak-f[1600] permutation (see keccak1600.h) and adheres to the specifications set forth in the SHA-3 standard.
Definition in file keccak.h.
#define HA_KECCAK_224_DIGEST_SIZE ha_bB(224) |
#define HA_KECCAK_256_DIGEST_SIZE ha_bB(256) |
#define HA_KECCAK_384_DIGEST_SIZE ha_bB(384) |
#define HA_KECCAK_512_DIGEST_SIZE ha_bB(512) |
typedef struct ha_keccak_context ha_keccak_context |
enum ha_pb ha_enum_base | ( | uint8_t | ) |
HA_PUBFUN void ha_keccak_224_final | ( | ha_keccak_224_context * | ctx, |
ha_digest_t | digest ) |
Finalizes the Keccak-224 context.
This function finals the Keccak-224 context after all data has been absorbed, preparing the context for squeezing the hash output.
ctx | Pointer to the Keccak-224 context. |
HA_PUBFUN void ha_keccak_224_hash | ( | ha_inbuf_t | data, |
size_t | length, | ||
ha_digest_t | digest ) |
Computes the Keccak-224 hash in a single operation.
This function combines the initialization, absorption, finalization, and squeezing steps into a single operation for convenience.
data | Pointer to the input data to be hashed. |
length | The length of the input data in bytes. |
digest | Pointer to the buffer where the resulting hash will be stored. |
HA_PUBFUN void ha_keccak_224_init | ( | ha_keccak_224_context * | ctx | ) |
Initializes the Keccak-224 context.
This function initializes the context for the Keccak-224 hash function, setting the internal state to the default values.
ctx | Pointer to the Keccak-224 context to be initialized. |
HA_PUBFUN void ha_keccak_224_update | ( | ha_keccak_224_context * | ctx, |
ha_inbuf_t | data, | ||
size_t | length ) |
Absorbs input data for Keccak-224.
This function absorbs the input data into the Keccak-224 context. It processes the input in chunks and updates the internal state.
ctx | Pointer to the Keccak-224 context. |
data | Pointer to the input data to be absorbed. |
length | The length of the input data in bytes. |
HA_PUBFUN void ha_keccak_256_final | ( | ha_keccak_256_context * | ctx, |
ha_digest_t | digest ) |
Finalizes the Keccak-256 context.
This function finals the Keccak-256 context after all data has been absorbed.
ctx | Pointer to the Keccak-256 context. |
HA_PUBFUN void ha_keccak_256_hash | ( | ha_inbuf_t | data, |
size_t | length, | ||
ha_digest_t | digest ) |
Computes the Keccak-256 hash in a single operation.
This function combines the initialization, absorption, finalization, and squeezing steps into a single operation for convenience.
data | Pointer to the input data to be hashed. |
length | The length of the input data in bytes. |
digest | Pointer to the buffer where the resulting hash will be stored. |
HA_PUBFUN void ha_keccak_256_init | ( | ha_keccak_256_context * | ctx | ) |
Initializes the Keccak-256 context.
This function initializes the context for the Keccak-256 hash function.
ctx | Pointer to the Keccak-256 context to be initialized. |
HA_PUBFUN void ha_keccak_256_update | ( | ha_keccak_256_context * | ctx, |
ha_inbuf_t | data, | ||
size_t | length ) |
Absorbs input data for Keccak-256.
This function absorbs the input data into the Keccak-256 context.
ctx | Pointer to the Keccak-256 context. |
data | Pointer to the input data to be absorbed. |
length | The length of the input data in bytes. |
HA_PUBFUN void ha_keccak_384_final | ( | ha_keccak_384_context * | ctx, |
ha_digest_t | digest ) |
Finalizes the Keccak-384 context.
This function finals the Keccak-384 context after all data has been absorbed.
HA_PUBFUN void ha_keccak_384_hash | ( | ha_inbuf_t | data, |
size_t | length, | ||
ha_digest_t | digest ) |
Computes the Keccak-384 hash in a single operation.
This function combines the initialization, absorption, finalization, and squeezing steps into a single operation for convenience.
HA_PUBFUN void ha_keccak_384_init | ( | ha_keccak_384_context * | ctx | ) |
Initializes the Keccak-384 context.
This function initializes the context for the Keccak-384 hash function.
HA_PUBFUN void ha_keccak_384_update | ( | ha_keccak_384_context * | ctx, |
ha_inbuf_t | data, | ||
size_t | length ) |
Absorbs input data for Keccak-384.
This function absorbs the input data into the Keccak-384 context.
HA_PUBFUN void ha_keccak_512_final | ( | ha_keccak_512_context * | ctx, |
ha_digest_t | digest ) |
Finalizes the Keccak-512 context.
This function finals the Keccak-512 context after all data has been absorbed.
HA_PUBFUN void ha_keccak_512_hash | ( | ha_inbuf_t | data, |
size_t | length, | ||
ha_digest_t | digest ) |
Computes the Keccak-512 hash in a single operation.
This function combines the initialization, absorption, finalization, and squeezing steps into a single operation for convenience.
HA_PUBFUN void ha_keccak_512_init | ( | ha_keccak_512_context * | ctx | ) |
Initializes the Keccak-512 context.
This function initializes the context for the Keccak-512 hash function.
HA_PUBFUN void ha_keccak_512_update | ( | ha_keccak_512_context * | ctx, |
ha_inbuf_t | data, | ||
size_t | length ) |
Absorbs input data for Keccak-512.
This function absorbs the input data into the Keccak-512 context.
HA_PUBFUN void ha_keccak_final | ( | ha_keccak_context * | ctx, |
enum ha_pb | padbyte, | ||
ha_digest_t | digest, | ||
size_t | digestlen ) |
Finalizes the Keccak-Based computation.
This function finals the Keccak-Based hash calculation.
ctx | Pointer to the Keccak-Based context structure. |
digest | Pointer to the output buffer where the final hash will be stored. |
digestlen | The length of the final hash (in bytes). |
HA_PUBFUN void ha_keccak_hash | ( | size_t | rate, |
enum ha_pb | padbyte, | ||
ha_inbuf_t | buf, | ||
size_t | len, | ||
ha_digest_t | digest, | ||
size_t | digestlen ) |
Computes the Keccak-Based hash in a one-shot operation.
This function computes the SHA3 hash of the provided data in a single call. It initializes, absorbs, finals, and squeezes the result internally.
rate | The rate of the Keccak-Based algorithm (in bytes) |
padbyte | The padding byte of the Keccak-Based algorithm |
data | Pointer to the input data to process. |
length | Length of the input data in bytes. |
digest | Pointer to the output buffer to store the final Keccak-Based digest. |
HA_PUBFUN void ha_keccak_init | ( | ha_keccak_context * | ctx, |
size_t | rate ) |
Initializes the Keccak-Based context.
This function initializes the Keccak-Based context to start a new hash computation.
ctx | Pointer to the Keccak-Based context structure to initialize. |
rate | The rate of the Keccak-Based algorithm (in bytes) |
HA_PUBFUN void ha_keccak_update | ( | ha_keccak_context * | ctx, |
ha_inbuf_t | buf, | ||
size_t | len ) |
Absorbs data into the Keccak-Based context.
This function processes the provided data and updates the Keccak-Based context state.
ctx | Pointer to the Keccak-Based context structure. |
data | Pointer to the input data to process. |
length | Length of the input data in bytes. |