.TH "libwget-hash" 3 "Mon Aug 7 2017" "Version 1.0.0" "wget2" \" -*- nroff -*- .ad l .nh .SH NAME libwget-hash .SH SYNOPSIS .br .PP .SS "Typedefs" .in +1c .ti -1c .RI "typedef struct _wget_hash_hd_st \fBwget_hash_hd_t\fP" .br .RI "Type for hash / digest routines\&. " .in -1c .SS "Enumerations" .in +1c .ti -1c .RI "enum \fBwget_digest_algorithm_t\fP { \fBWGET_DIGTYPE_UNKNOWN\fP, \fBWGET_DIGTYPE_MD5\fP, \fBWGET_DIGTYPE_SHA1\fP, \fBWGET_DIGTYPE_RMD160\fP, \fBWGET_DIGTYPE_MD2\fP, \fBWGET_DIGTYPE_SHA256\fP, \fBWGET_DIGTYPE_SHA384\fP, \fBWGET_DIGTYPE_SHA512\fP, \fBWGET_DIGTYPE_SHA224\fP } .RI "Enumeration of different hash digest algorithms\&. "" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "\fBwget_digest_algorithm_t\fP \fBwget_hash_get_algorithm\fP (const char *hashname)" .br .ti -1c .RI "int \fBwget_hash_fast\fP (\fBwget_digest_algorithm_t\fP algorithm, const void *text, size_t textlen, void *digest)" .br .ti -1c .RI "int \fBwget_hash_get_len\fP (\fBwget_digest_algorithm_t\fP algorithm)" .br .ti -1c .RI "int \fBwget_hash_init\fP (\fBwget_hash_hd_t\fP *handle, \fBwget_digest_algorithm_t\fP algorithm)" .br .ti -1c .RI "int \fBwget_hash\fP (\fBwget_hash_hd_t\fP *handle, const void *text, size_t textlen)" .br .ti -1c .RI "void \fBwget_hash_deinit\fP (\fBwget_hash_hd_t\fP *handle, void *digest)" .br .ti -1c .RI "int \fBwget_hash_file_fd\fP (const char *hashname, int fd, char *digest_hex, size_t digest_hex_size, off_t offset, off_t length)" .br .ti -1c .RI "int \fBwget_hash_file_offset\fP (const char *hashname, const char *fname, char *digest_hex, size_t digest_hex_size, off_t offset, off_t length)" .br .ti -1c .RI "int \fBwget_hash_file\fP (const char *hashname, const char *fname, char *digest_hex, size_t digest_hex_size)" .br .in -1c .SH "Detailed Description" .PP .SH "Enumeration Type Documentation" .PP .SS "enum \fBwget_digest_algorithm_t\fP" .PP Enumeration of different hash digest algorithms\&. .PP \fBEnumerator\fP .in +1c .TP \fB\fIWGET_DIGTYPE_UNKNOWN \fP\fP Indicates 'Unknown hash algorithm', returned by \fBwget_hash_get_algorithm()\fP .TP \fB\fIWGET_DIGTYPE_MD5 \fP\fP Type 'MD5' digest .TP \fB\fIWGET_DIGTYPE_SHA1 \fP\fP Type SHA1 digest .TP \fB\fIWGET_DIGTYPE_RMD160 \fP\fP Type RMD160 digest .TP \fB\fIWGET_DIGTYPE_MD2 \fP\fP Type 'MD2' digest .TP \fB\fIWGET_DIGTYPE_SHA256 \fP\fP Type 'SHA256' digest .TP \fB\fIWGET_DIGTYPE_SHA384 \fP\fP Type 'SHA384' digest .TP \fB\fIWGET_DIGTYPE_SHA512 \fP\fP Type 'SHA512' digest .TP \fB\fIWGET_DIGTYPE_SHA224 \fP\fP Type 'SHA224' digest .SH "Function Documentation" .PP .SS "\fBwget_digest_algorithm_t\fP wget_hash_get_algorithm (const char * hashname)" .PP \fBParameters:\fP .RS 4 \fIhashname\fP Name of the hashing algorithm (see table below) .RE .PP \fBReturns:\fP .RS 4 A constant to be used by libwget hashing functions .RE .PP Get the hashing algorithms list item that corresponds to the named hashing algorithm\&. .PP This function returns a constant that uniquely identifies a known supported hashing algorithm within libwget\&. All the supported algorithms are listed in the \fBwget_digest_algorithm_t\fP enum\&. .PP Algorithm name Constant sha1 or sha-1WGET_DIGTYPE_SHA1 sha256 or sha-256WGET_DIGTYPE_SHA256 sha512 or sha-512WGET_DIGTYPE_SHA512 sha224 or sha-224WGET_DIGTYPE_SHA224 sha384 or sha-384WGET_DIGTYPE_SHA384 md5WGET_DIGTYPE_MD5 md2WGET_DIGTYPE_MD2 rmd160WGET_DIGTYPE_RMD160 .SS "int wget_hash_fast (\fBwget_digest_algorithm_t\fP algorithm, const void * text, size_t textlen, void * digest)" .PP \fBParameters:\fP .RS 4 \fIalgorithm\fP One of the hashing algorithms returned by \fBwget_hash_get_algorithm()\fP .br \fItext\fP Input data to hash .br \fItextlen\fP Length of the input data .br \fIdigest\fP Caller-supplied buffer where the output hash will be placed .RE .PP \fBReturns:\fP .RS 4 Zero on success or a negative value on error .RE .PP Convenience function to hash the given data in a single call\&. .PP The caller must ensure that the provided output buffer \fCdigest\fP 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 \fCalgorithm\fP, call \fBwget_hash_get_len()\fP\&. .PP \fBNote:\fP .RS 4 This function's behavior depends on the underlying cryptographic engine libwget was compiled with\&. .RE .PP .SS "int wget_hash_get_len (\fBwget_digest_algorithm_t\fP algorithm)" .PP \fBParameters:\fP .RS 4 \fIalgorithm\fP One of the hashing algorithms returned by \fBwget_hash_get_algorithm()\fP .RE .PP \fBReturns:\fP .RS 4 The length of the output data generated by the algorithm .RE .PP Determines the output length of the given hashing algorithm\&. .PP 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\&. .SS "int wget_hash_init (\fBwget_hash_hd_t\fP * handle, \fBwget_digest_algorithm_t\fP algorithm)" .PP \fBParameters:\fP .RS 4 \fIhandle\fP Caller-provided pointer to a \fBwget_hash_hd_t\fP structure where the handle to this hashing primitive will be stored, needed in subsequent calls to \fBwget_hash()\fP .br \fIalgorithm\fP One of the hashing algorithms returned by \fBwget_hash_get_algorithm()\fP .RE .PP \fBReturns:\fP .RS 4 Zero on success or a negative value on error .RE .PP Initialize the cryptographic engine to compute hashes with the given hashing algorithm, as well as the hashing algorithm itself\&. .PP After this function returns, \fBwget_hash()\fP might be called as many times as desired\&. .SS "int wget_hash (\fBwget_hash_hd_t\fP * handle, const void * text, size_t textlen)" .PP \fBParameters:\fP .RS 4 \fIhandle\fP Handle to the hashing primitive returned by a subsequent call to \fBwget_hash_init()\fP .br \fItext\fP Input data .br \fItextlen\fP Length of the input data .RE .PP \fBReturns:\fP .RS 4 Zero on success or a negative value on error .RE .PP Update the digest by adding additional input data to it\&. This method can be called as many times as desired\&. Once finished, call \fBwget_hash_deinit()\fP to complete the computation and get the resulting hash\&. .SS "void wget_hash_deinit (\fBwget_hash_hd_t\fP * handle, void * digest)" .PP \fBParameters:\fP .RS 4 \fIhandle\fP Handle to the hashing primitive returned by a subsequent call to \fBwget_hash_init()\fP .br \fIdigest\fP Caller-supplied buffer where the output hash will be placed\&. .RE .PP 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 \fCdigest\fP\&. The caller must ensure that the provided output buffer \fCdigest\fP is large enough to store the hash\&. To get the output length of the chosen algorithm \fCalgorithm\fP, call \fBwget_hash_get_len()\fP\&. .SS "int wget_hash_file_fd (const char * hashname, int fd, char * digest_hex, size_t digest_hex_size, off_t offset, off_t length)" .PP \fBParameters:\fP .RS 4 \fIhashname\fP Name of the hashing algorithm\&. See \fBwget_hash_get_algorithm()\fP .br \fIfd\fP File descriptor for the target file .br \fIdigest_hex\fP caller-supplied buffer that will contain the resulting hex string .br \fIdigest_hex_size\fP Length of \fCdigest_hex\fP .br \fIoffset\fP File offset to start hashing at .br \fIlength\fP Number of bytes to hash, starting from \fCoffset\fP\&. Zero will hash up to the end of the file .RE .PP \fBReturns:\fP .RS 4 0 on success or -1 in case of failure .RE .PP Compute the hash of the contents of the target file and return its hex representation\&. .PP This function will encode the resulting hash in a string of hex digits, and place that string in the user-supplied buffer \fCdigest_hex\fP\&. .SS "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)" .PP \fBParameters:\fP .RS 4 \fIhashname\fP Name of the hashing algorithm\&. See \fBwget_hash_get_algorithm()\fP .br \fIfname\fP Target file name .br \fIdigest_hex\fP Caller-supplied buffer that will contain the resulting hex string .br \fIdigest_hex_size\fP Length of \fCdigest_hex\fP .br \fIoffset\fP File offset to start hashing at .br \fIlength\fP Number of bytes to hash, starting from \fCoffset\fP\&. Zero will hash up to the end of the file .RE .PP \fBReturns:\fP .RS 4 0 on success or -1 in case of failure .RE .PP Compute the hash of the contents of the target file starting from \fCoffset\fP and up to \fClength\fP bytes and return its hex representation\&. .PP This function will encode the resulting hash in a string of hex digits, and place that string in the user-supplied buffer \fCdigest_hex\fP\&. .SS "int wget_hash_file (const char * hashname, const char * fname, char * digest_hex, size_t digest_hex_size)" .PP \fBParameters:\fP .RS 4 \fIhashname\fP Name of the hashing algorithm\&. See \fBwget_hash_get_algorithm()\fP .br \fIfname\fP Target file name .br \fIdigest_hex\fP Caller-supplied buffer that will contain the resulting hex string .br \fIdigest_hex_size\fP Length of \fCdigest_hex\fP .RE .PP \fBReturns:\fP .RS 4 0 on success or -1 in case of failure .RE .PP Compute the hash of the contents of the target file and return its hex representation\&. .PP This function will encode the resulting hash in a string of hex digits, and place that string in the user-supplied buffer \fCdigest_hex\fP\&. .SH "Author" .PP Generated automatically by Doxygen for wget2 from the source code\&.