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
10 .\" $FreeBSD: src/lib/libmd/sha256.3,v 1.4 2005/11/17 13:00:00 ru Exp $
21 .Nm SHA256_FileChunk ,
23 .Nd calculate the FIPS 180-2 ``SHA-256'' message digest
30 .Fn SHA256_Init "SHA256_CTX *context"
32 .Fn SHA256_Update "SHA256_CTX *context" "const void *data" "size_t len"
34 .Fn SHA256_Final "unsigned char digest[32]" "SHA256_CTX *context"
36 .Fn SHA256_End "SHA256_CTX *context" "char *buf"
38 .Fn SHA256_File "const char *filename" "char *buf"
40 .Fn SHA256_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
42 .Fn SHA256_Data "const void *data" "unsigned int len" "char *buf"
46 functions calculate a 256-bit cryptographic checksum (digest)
47 for any number of input bytes.
48 A cryptographic checksum is a one-way
49 hash function; that is, it is computationally impractical to find
50 the input corresponding to a particular output.
54 of the input-data, which does not disclose the actual input.
61 functions are the core functions.
66 run over the data with
68 and finally extract the result using
74 which converts the return value to a 65-character
75 (including the terminating '\e0')
77 string which represents the 256 bits in hexadecimal.
80 calculates the digest of a file, and uses
83 If the file cannot be opened, a null pointer is returned.
87 but it only calculates the digest over a byte-range of the file specified,
95 parameter is specified as 0, or more than the length of the remaining part
98 calculates the digest from
102 calculates the digest of a chunk of data in memory, and uses
104 to return the result.
113 argument can be a null pointer, in which case the returned string
116 and subsequently must be explicitly deallocated using
121 argument is non-null it must point to at least 65 characters of buffer space.
129 These functions appeared in
132 The core hash routines were implemented by Colin Percival based on
137 No method is known to exist which finds two files having the same hash value,
138 nor to find a file with a specific hash value.
139 There is on the other hand no guarantee that such a method does not exist.