libhasha 2.2.2
|
Header file for the SHA-1 cryptographic hash algorithm. More...
#include "internal/internal.h"
Go to the source code of this file.
Classes | |
struct | ha_sha1_context |
SHA-1 context structure used to store the internal state during hashing. More... |
Macros | |
#define | HA_SHA1_BLOCK_SIZE 64 |
The block size used in SHA-1 (in bytes). | |
#define | HA_SHA1_DIGEST_SIZE ha_bB(160) |
The size of the SHA-1 hash output (in bytes). |
Typedefs | |
typedef struct ha_sha1_context | ha_sha1_context |
Functions | |
HA_PUBFUN void | ha_sha1_transform (ha_sha1_context *ctx, const uint8_t *block) |
Performs the SHA-1 transformation step on a 512-bit data block. | |
HA_PUBFUN void | ha_sha1_init (ha_sha1_context *ctx) |
Initializes the SHA-1 context for a new hash computation. | |
HA_PUBFUN void | ha_sha1_update (ha_sha1_context *ctx, ha_inbuf_t data, size_t len) |
Updates the SHA-1 context with new data. | |
HA_PUBFUN void | ha_sha1_final (ha_sha1_context *ctx, ha_digest_t digest) |
Finalizes the SHA-1 context and produces the resulting hash digest. | |
HA_PUBFUN void | ha_sha1_hash (ha_inbuf_t data, size_t len, ha_digest_t digest) |
Computes the SHA-1 hash for the given input data in one-shot mode. |
Header file for the SHA-1 cryptographic hash algorithm.
This header file defines the interface for the SHA-1 hash function, including the context structure, constants, and function declarations required for computing a SHA-1 hash. SHA-1 is a widely-used cryptographic hash function that produces a 160-bit (20-byte) hash value, and is commonly used for data integrity verification.
The functions provided in this file allow for incremental hashing via context initialization, data updating, and finalization, as well as a one-shot function for computing the hash of an entire input in a single call.
Definition in file sha1.h.
#define HA_SHA1_BLOCK_SIZE 64 |
#define HA_SHA1_DIGEST_SIZE ha_bB(160) |
typedef struct ha_sha1_context ha_sha1_context |
HA_PUBFUN void ha_sha1_final | ( | ha_sha1_context * | ctx, |
ha_digest_t | digest ) |
Finalizes the SHA-1 context and produces the resulting hash digest.
This function finals the hash computation, pads the data if necessary, and produces the final 160-bit (20-byte) hash digest in the provided output buffer.
ctx | Pointer to the SHA-1 context structure. |
digest | Pointer to the output buffer where the 160-bit hash digest will be stored. |
HA_PUBFUN void ha_sha1_hash | ( | ha_inbuf_t | data, |
size_t | len, | ||
ha_digest_t | digest ) |
Computes the SHA-1 hash for the given input data in one-shot mode.
This function computes the SHA-1 hash for the entire input data in a single call, without requiring separate initialization, update, or final steps.
data | Pointer to the input data. |
len | The length of the input data. |
digest | Pointer to the output buffer where the 160-bit hash digest will be stored. |
HA_PUBFUN void ha_sha1_init | ( | ha_sha1_context * | ctx | ) |
Initializes the SHA-1 context for a new hash computation.
This function initializes the SHA-1 context to its starting state with the default initial hash values (SHA1_H0) and prepares the context for the hashing process.
ctx | Pointer to the SHA-1 context structure. |
HA_PUBFUN void ha_sha1_transform | ( | ha_sha1_context * | ctx, |
const uint8_t * | block ) |
Performs the SHA-1 transformation step on a 512-bit data block.
This function processes the given data block and updates the internal state of the SHA-1 context with the result.
ctx | Pointer to the SHA-1 context structure. |
block | Pointer to the 512-bit (64-byte) input data block. |
HA_PUBFUN void ha_sha1_update | ( | ha_sha1_context * | ctx, |
ha_inbuf_t | data, | ||
size_t | len ) |
Updates the SHA-1 context with new data.
This function updates the SHA-1 context with a portion of the input data. It processes the input data in 512-bit blocks and handles the internal state updates.
ctx | Pointer to the SHA-1 context structure. |
data | Pointer to the input data. |
len | The length of the input data. |