2 .\" ----------------------------------------------------------------------------
3 .\" "THE BEER-WARE LICENSE" (Revision 42):
4 .\" <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
5 .\" can do whatever you want with this stuff. If we meet some day, and you think
6 .\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 .\" ----------------------------------------------------------------------------
9 .\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
21 .Nm SHA224_FileChunk ,
28 .Nm SHA256_FileChunk ,
30 .Nd calculate the FIPS 180-2 ``SHA-256'' (or SHA-224) message digest
37 .Fn SHA224_Init "SHA224_CTX *context"
39 .Fn SHA224_Update "SHA224_CTX *context" "const unsigned char *data" "size_t len"
41 .Fn SHA224_Final "unsigned char digest[32]" "SHA224_CTX *context"
43 .Fn SHA224_End "SHA224_CTX *context" "char *buf"
45 .Fn SHA224_File "const char *filename" "char *buf"
47 .Fn SHA224_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
49 .Fn SHA224_Data "const unsigned char *data" "unsigned int len" "char *buf"
52 .Fn SHA256_Init "SHA256_CTX *context"
54 .Fn SHA256_Update "SHA256_CTX *context" "const unsigned char *data" "size_t len"
56 .Fn SHA256_Final "unsigned char digest[32]" "SHA256_CTX *context"
58 .Fn SHA256_End "SHA256_CTX *context" "char *buf"
60 .Fn SHA256_File "const char *filename" "char *buf"
62 .Fn SHA256_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
64 .Fn SHA256_Data "const unsigned char *data" "unsigned int len" "char *buf"
68 functions calculate a 256-bit cryptographic checksum (digest)
69 for any number of input bytes.
70 A cryptographic checksum is a one-way
71 hash function; that is, it is computationally impractical to find
72 the input corresponding to a particular output.
76 of the input-data, which does not disclose the actual input.
83 functions are the core functions.
88 run over the data with
90 and finally extract the result using
92 which will also erase the
98 which converts the return value to a 65-character
99 (including the terminating '\e0')
100 ASCII string which represents the 256 bits in hexadecimal.
103 calculates the digest of a file, and uses
105 to return the result.
106 If the file cannot be opened, a null pointer is returned.
110 but it only calculates the digest over a byte-range of the file specified,
118 parameter is specified as 0, or more than the length of the remaining part
121 calculates the digest from
125 calculates the digest of a chunk of data in memory, and uses
127 to return the result.
136 argument can be a null pointer, in which case the returned string
139 and subsequently must be explicitly deallocated using
144 argument is non-null it must point to at least 65 characters of buffer space.
146 SHA224 is identical SHA256, except it has slightly different initialization
147 vectors, and is truncated to a shorter digest.
151 function called with a null buf argument may fail and return NULL if:
154 Insufficient storage space is available.
161 may return NULL when underlying
176 These functions appeared in
179 The core hash routines were implemented by Colin Percival based on
180 the published FIPS 180-2 standard.
182 No method is known to exist which finds two files having the same hash value,
183 nor to find a file with a specific hash value.
184 There is on the other hand no guarantee that such a method does not exist.