![]() |
wget2
1.0.0
|
Functions | |
wget_digest_algorithm_t | wget_hash_get_algorithm (const char *hashname) |
int | wget_hash_fast (wget_digest_algorithm_t algorithm, const void *text, size_t textlen, void *digest) |
int | wget_hash_get_len (wget_digest_algorithm_t algorithm) |
int | wget_hash_init (wget_hash_hd_t *handle, wget_digest_algorithm_t algorithm) |
int | wget_hash (wget_hash_hd_t *handle, const void *text, size_t textlen) |
void | wget_hash_deinit (wget_hash_hd_t *handle, void *digest) |
int | wget_hash_file_fd (const char *hashname, int fd, char *digest_hex, size_t digest_hex_size, off_t offset, off_t length) |
int | wget_hash_file_offset (const char *hashname, const char *fname, char *digest_hex, size_t digest_hex_size, off_t offset, off_t length) |
int | wget_hash_file (const char *hashname, const char *fname, char *digest_hex, size_t digest_hex_size) |
wget_digest_algorithm_t wget_hash_get_algorithm | ( | const char * | hashname | ) |
[in] | hashname | Name of the hashing algorithm (see table below) |
Get the hashing algorithms list item that corresponds to the named hashing algorithm.
This function returns a constant that uniquely identifies a known supported hashing algorithm within libwget. All the supported algorithms are listed in the ::wget_digest_algorithm_t enum.
Algorithm name | Constant |
---|---|
sha1 or sha-1 | WGET_DIGTYPE_SHA1 |
sha256 or sha-256 | WGET_DIGTYPE_SHA256 |
sha512 or sha-512 | WGET_DIGTYPE_SHA512 |
sha224 or sha-224 | WGET_DIGTYPE_SHA224 |
sha384 or sha-384 | WGET_DIGTYPE_SHA384 |
md5 | WGET_DIGTYPE_MD5 |
md2 | WGET_DIGTYPE_MD2 |
rmd160 | WGET_DIGTYPE_RMD160 |
int wget_hash_fast | ( | wget_digest_algorithm_t | algorithm, |
const void * | text, | ||
size_t | textlen, | ||
void * | digest | ||
) |
[in] | algorithm | One of the hashing algorithms returned by wget_hash_get_algorithm() |
[in] | text | Input data to hash |
[in] | textlen | Length of the input data |
[in] | digest | Caller-supplied buffer where the output hash will be placed |
Convenience function to hash the given data in a single call.
The caller must ensure that the provided output buffer digest
is large enough to store the hash. A particular hash algorithm is guaranteed to always generate the same amount of data (e.g. 512 bits) but different hash algorithms will output different lengths of data. To get the output length of the chosen algorithm algorithm
, call wget_hash_get_len().
int wget_hash_get_len | ( | wget_digest_algorithm_t | algorithm | ) |
[in] | algorithm | One of the hashing algorithms returned by wget_hash_get_algorithm() |
Determines the output length of the given hashing algorithm.
A particular hash algorithm is guaranteed to always generate the same amount of data (e.g. 512 bits) but different hash algorithms will output different lengths of data.
int wget_hash_init | ( | wget_hash_hd_t * | handle, |
wget_digest_algorithm_t | algorithm | ||
) |
[out] | handle | Caller-provided pointer to a ::wget_hash_hd_t structure where the handle to this hashing primitive will be stored, needed in subsequent calls to wget_hash() |
[in] | algorithm | One of the hashing algorithms returned by wget_hash_get_algorithm() |
Initialize the cryptographic engine to compute hashes with the given hashing algorithm, as well as the hashing algorithm itself.
After this function returns, wget_hash() might be called as many times as desired.
int wget_hash | ( | wget_hash_hd_t * | handle, |
const void * | text, | ||
size_t | textlen | ||
) |
[in] | handle | Handle to the hashing primitive returned by a subsequent call to wget_hash_init() |
[in] | text | Input data |
[in] | textlen | Length of the input data |
Update the digest by adding additional input data to it. This method can be called as many times as desired. Once finished, call wget_hash_deinit() to complete the computation and get the resulting hash.
void wget_hash_deinit | ( | wget_hash_hd_t * | handle, |
void * | digest | ||
) |
[in] | handle | Handle to the hashing primitive returned by a subsequent call to wget_hash_init() |
[out] | digest | Caller-supplied buffer where the output hash will be placed. |
Complete the hash computation by performing final operations, such as padding, and obtain the final result. The result will be placed in the caller-supplied buffer digest
. The caller must ensure that the provided output buffer digest
is large enough to store the hash. To get the output length of the chosen algorithm algorithm
, call wget_hash_get_len().
int wget_hash_file_fd | ( | const char * | hashname, |
int | fd, | ||
char * | digest_hex, | ||
size_t | digest_hex_size, | ||
off_t | offset, | ||
off_t | length | ||
) |
[in] | hashname | Name of the hashing algorithm. See wget_hash_get_algorithm() |
[in] | fd | File descriptor for the target file |
[out] | digest_hex | caller-supplied buffer that will contain the resulting hex string |
[in] | digest_hex_size | Length of digest_hex |
[in] | offset | File offset to start hashing at |
[in] | length | Number of bytes to hash, starting from offset . Zero will hash up to the end of the file |
Compute the hash of the contents of the target file and return its hex representation.
This function will encode the resulting hash in a string of hex digits, and place that string in the user-supplied buffer digest_hex
.
int wget_hash_file_offset | ( | const char * | hashname, |
const char * | fname, | ||
char * | digest_hex, | ||
size_t | digest_hex_size, | ||
off_t | offset, | ||
off_t | length | ||
) |
[in] | hashname | Name of the hashing algorithm. See wget_hash_get_algorithm() |
[in] | fname | Target file name |
[out] | digest_hex | Caller-supplied buffer that will contain the resulting hex string |
[in] | digest_hex_size | Length of digest_hex |
[in] | offset | File offset to start hashing at |
[in] | length | Number of bytes to hash, starting from offset . Zero will hash up to the end of the file |
Compute the hash of the contents of the target file starting from offset
and up to length
bytes and return its hex representation.
This function will encode the resulting hash in a string of hex digits, and place that string in the user-supplied buffer digest_hex
.
int wget_hash_file | ( | const char * | hashname, |
const char * | fname, | ||
char * | digest_hex, | ||
size_t | digest_hex_size | ||
) |
[in] | hashname | Name of the hashing algorithm. See wget_hash_get_algorithm() |
[in] | fname | Target file name |
[out] | digest_hex | Caller-supplied buffer that will contain the resulting hex string |
[in] | digest_hex_size | Length of digest_hex |
Compute the hash of the contents of the target file and return its hex representation.
This function will encode the resulting hash in a string of hex digits, and place that string in the user-supplied buffer digest_hex
.