Changeset View
Changeset View
Standalone View
Standalone View
lib/libmd/sha512.3
.\" | .\" | ||||
.\" ---------------------------------------------------------------------------- | .\" ---------------------------------------------------------------------------- | ||||
.\" "THE BEER-WARE LICENSE" (Revision 42): | .\" "THE BEER-WARE LICENSE" (Revision 42): | ||||
.\" <phk@FreeBSD.org> wrote this file. As long as you retain this notice you | .\" <phk@FreeBSD.org> wrote this file. As long as you retain this notice you | ||||
.\" can do whatever you want with this stuff. If we meet some day, and you think | .\" can do whatever you want with this stuff. If we meet some day, and you think | ||||
.\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp | .\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp | ||||
.\" ---------------------------------------------------------------------------- | .\" ---------------------------------------------------------------------------- | ||||
.\" | .\" | ||||
.\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp | .\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd October 17, 2015 | .Dd April 22, 2016 | ||||
.Dt SHA512 3 | .Dt SHA512 3 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm SHA512_Init , | .Nm SHA512_Init , | ||||
.Nm SHA512_Update , | .Nm SHA512_Update , | ||||
.Nm SHA512_Final , | .Nm SHA512_Final , | ||||
.Nm SHA512_End , | .Nm SHA512_End , | ||||
.Nm SHA512_File , | .Nm SHA512_File , | ||||
.Nm SHA512_FileChunk , | .Nm SHA512_FileChunk , | ||||
.Nm SHA512_Data , | .Nm SHA512_Data , | ||||
.Nm SHA384_Init , | .Nm SHA384_Init , | ||||
.Nm SHA384_Update , | .Nm SHA384_Update , | ||||
.Nm SHA384_Final , | .Nm SHA384_Final , | ||||
.Nm SHA384_End , | .Nm SHA384_End , | ||||
.Nm SHA384_File , | .Nm SHA384_File , | ||||
.Nm SHA384_FileChunk , | .Nm SHA384_FileChunk , | ||||
.Nm SHA384_Data | .Nm SHA384_Data, | ||||
.Nm SHA512_256_Init , | |||||
.Nm SHA512_256_Update , | |||||
.Nm SHA512_256_Final , | |||||
.Nm SHA512_256_End , | |||||
.Nm SHA512_256_File , | |||||
.Nm SHA512_256_FileChunk , | |||||
.Nm SHA512_256_Data | |||||
.Nd calculate the FIPS 180-4 ``SHA-512'' family of message digests | .Nd calculate the FIPS 180-4 ``SHA-512'' family of message digests | ||||
.Sh LIBRARY | .Sh LIBRARY | ||||
.Lb libmd | .Lb libmd | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.In sys/types.h | .In sys/types.h | ||||
.In sha512.h | .In sha512.h | ||||
.Ft void | .Ft void | ||||
.Fn SHA512_Init "SHA512_CTX *context" | .Fn SHA512_Init "SHA512_CTX *context" | ||||
.Ft void | .Ft void | ||||
.Fn SHA512_Update "SHA512_CTX *context" "const unsigned char *data" "size_t len" | .Fn SHA512_Update "SHA512_CTX *context" "const unsigned char *data" "size_t len" | ||||
.Ft void | .Ft void | ||||
.Fn SHA512_Final "unsigned char digest[64]" "SHA512_CTX *context" | .Fn SHA512_Final "unsigned char digest[64]" "SHA512_CTX *context" | ||||
.Ft "char *" | .Ft "char *" | ||||
.Fn SHA512_End "SHA512_CTX *context" "char *buf" | .Fn SHA512_End "SHA512_CTX *context" "char *buf" | ||||
.Ft "char *" | .Ft "char *" | ||||
.Fn SHA512_File "const char *filename" "char *buf" | .Fn SHA512_File "const char *filename" "char *buf" | ||||
.Ft "char *" | .Ft "char *" | ||||
.Fn SHA512_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length" | .Fn SHA512_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length" | ||||
.Ft "char *" | .Ft "char *" | ||||
.Fn SHA512_Data "const unsigned char *data" "unsigned int len" "char *buf" | .Fn SHA512_Data "const unsigned char *data" "unsigned int len" "char *buf" | ||||
.In sha384.h | |||||
.Ft void | .Ft void | ||||
.Fn SHA384_Init "SHA384_CTX *context" | .Fn SHA384_Init "SHA384_CTX *context" | ||||
.Ft void | .Ft void | ||||
.Fn SHA384_Update "SHA384_CTX *context" "const unsigned char *data" "size_t len" | .Fn SHA384_Update "SHA384_CTX *context" "const unsigned char *data" "size_t len" | ||||
.Ft void | .Ft void | ||||
.Fn SHA384_Final "unsigned char digest[48]" "SHA384_CTX *context" | .Fn SHA384_Final "unsigned char digest[48]" "SHA384_CTX *context" | ||||
.Ft "char *" | .Ft "char *" | ||||
.Fn SHA384_End "SHA384_CTX *context" "char *buf" | .Fn SHA384_End "SHA384_CTX *context" "char *buf" | ||||
.Ft "char *" | .Ft "char *" | ||||
.Fn SHA384_File "const char *filename" "char *buf" | .Fn SHA384_File "const char *filename" "char *buf" | ||||
.Ft "char *" | .Ft "char *" | ||||
.Fn SHA384_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length" | .Fn SHA384_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length" | ||||
.Ft "char *" | .Ft "char *" | ||||
.Fn SHA384_Data "const unsigned char *data" "unsigned int len" "char *buf" | .Fn SHA384_Data "const unsigned char *data" "unsigned int len" "char *buf" | ||||
.In sha512t.h | |||||
.Ft void | |||||
.Fn SHA512_256_Init "SHA512_CTX *context" | |||||
.Ft void | |||||
.Fn SHA512_256_Update "SHA512_CTX *context" "const unsigned char *data" "size_t len" | |||||
.Ft void | |||||
.Fn SHA512_256_Final "unsigned char digest[32]" "SHA512_CTX *context" | |||||
.Ft "char *" | |||||
.Fn SHA512_256_End "SHA512_CTX *context" "char *buf" | |||||
.Ft "char *" | |||||
.Fn SHA512_256_File "const char *filename" "char *buf" | |||||
.Ft "char *" | |||||
.Fn SHA512_256_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length" | |||||
.Ft "char *" | |||||
.Fn SHA512_256_Data "const unsigned char *data" "unsigned int len" "char *buf" | |||||
.Sh DESCRIPTION | .Sh DESCRIPTION | ||||
The | The | ||||
.Li SHA512_ | .Li SHA512_ | ||||
functions calculate a 512-bit cryptographic checksum (digest) | functions calculate a 512-bit cryptographic checksum (digest) | ||||
for any number of input bytes. | for any number of input bytes. | ||||
A cryptographic checksum is a one-way | A cryptographic checksum is a one-way | ||||
hash function; that is, it is computationally impractical to find | hash function; that is, it is computationally impractical to find | ||||
the input corresponding to a particular output. | the input corresponding to a particular output. | ||||
Show All 15 Lines | |||||
run over the data with | run over the data with | ||||
.Fn SHA512_Update , | .Fn SHA512_Update , | ||||
and finally extract the result using | and finally extract the result using | ||||
.Fn SHA512_Final . | .Fn SHA512_Final . | ||||
.Pp | .Pp | ||||
.Fn SHA512_End | .Fn SHA512_End | ||||
is a wrapper for | is a wrapper for | ||||
.Fn SHA512_Final | .Fn SHA512_Final | ||||
which converts the return value to a 65-character | which converts the return value to a 129-character | ||||
(including the terminating '\e0') | (including the terminating '\e0') | ||||
.Tn ASCII | .Tn ASCII | ||||
string which represents the 512 bits in hexadecimal. | string which represents the 512 bits in hexadecimal. | ||||
.Pp | .Pp | ||||
.Fn SHA512_File | .Fn SHA512_File | ||||
calculates the digest of a file, and uses | calculates the digest of a file, and uses | ||||
.Fn SHA512_End | .Fn SHA512_End | ||||
to return the result. | to return the result. | ||||
Show All 30 Lines | |||||
argument can be a null pointer, in which case the returned string | argument can be a null pointer, in which case the returned string | ||||
is allocated with | is allocated with | ||||
.Xr malloc 3 | .Xr malloc 3 | ||||
and subsequently must be explicitly deallocated using | and subsequently must be explicitly deallocated using | ||||
.Xr free 3 | .Xr free 3 | ||||
after use. | after use. | ||||
If the | If the | ||||
.Fa buf | .Fa buf | ||||
argument is non-null it must point to at least 65 characters of buffer space. | argument is non-null it must point to at least 129 characters of buffer space. | ||||
.Pp | .Pp | ||||
The | The | ||||
.Li SHA384_ | .Li SHA384_ | ||||
and | |||||
.Li SHA512_256_ | |||||
functions are identical to the | functions are identical to the | ||||
.Li SHA512_ | .Li SHA512_ | ||||
functions except they use a different initial hash value and the output is | functions except they use a different initial hash value and the output is | ||||
truncated to 384 bits. | truncated to 384 bits and 256 bits respectively. | ||||
.Pp | .Pp | ||||
.Fn SHA384_End | .Fn SHA384_End | ||||
is a wrapper for | is a wrapper for | ||||
.Fn SHA384_Final | .Fn SHA384_Final | ||||
which converts the return value to a 49-character | which converts the return value to a 97-character | ||||
(including the terminating '\e0') | (including the terminating '\e0') | ||||
.Tn ASCII | .Tn ASCII | ||||
string which represents the 384 bits in hexadecimal. | string which represents the 384 bits in hexadecimal. | ||||
.Pp | |||||
.Fn SHA512_256_End | |||||
is a wrapper for | |||||
.Fn SHA512_Final | |||||
which converts the return value to a 65-character | |||||
(including the terminating '\e0') | |||||
.Tn ASCII | |||||
string which represents the 256 bits in hexadecimal. | |||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr md4 3 , | .Xr md4 3 , | ||||
.Xr md5 3 , | .Xr md5 3 , | ||||
.Xr ripemd 3 , | .Xr ripemd 3 , | ||||
.Xr sha 3 | .Xr sha 3 | ||||
.Sh HISTORY | .Sh HISTORY | ||||
These functions appeared in | These functions appeared in | ||||
.Fx 9.0 . | .Fx 9.0 . | ||||
Show All 9 Lines |