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 $
11 .\" $DragonFly: src/lib/libmd/sha256.3,v 1.2 2008/09/11 20:25:34 swildner Exp $
22 .Nm SHA256_FileChunk ,
24 .Nd calculate the FIPS 180-2 ``SHA-256'' message digest
31 .Fn SHA256_Init "SHA256_CTX *context"
33 .Fn SHA256_Update "SHA256_CTX *context" "const unsigned char *data" "size_t len"
35 .Fn SHA256_Final "unsigned char digest[32]" "SHA256_CTX *context"
37 .Fn SHA256_End "SHA256_CTX *context" "char *buf"
39 .Fn SHA256_File "const char *filename" "char *buf"
41 .Fn SHA256_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
43 .Fn SHA256_Data "const unsigned char *data" "unsigned int len" "char *buf"
47 functions calculate a 256-bit cryptographic checksum (digest)
48 for any number of input bytes.
49 A cryptographic checksum is a one-way
50 hash function; that is, it is computationally impractical to find
51 the input corresponding to a particular output.
55 of the input-data, which does not disclose the actual input.
62 functions are the core functions.
67 run over the data with
69 and finally extract the result using
75 which converts the return value to a 65-character
76 (including the terminating '\e0')
78 string which represents the 256 bits in hexadecimal.
81 calculates the digest of a file, and uses
84 If the file cannot be opened, a null pointer is returned.
88 but it only calculates the digest over a byte-range of the file specified,
96 parameter is specified as 0, or more than the length of the remaining part
99 calculates the digest from
103 calculates the digest of a chunk of data in memory, and uses
105 to return the result.
114 argument can be a null pointer, in which case the returned string
117 and subsequently must be explicitly deallocated using
122 argument is non-null it must point to at least 65 characters of buffer space.
130 These functions appeared in
133 The core hash routines were implemented by Colin Percival based on
138 No method is known to exist which finds two files having the same hash value,
139 nor to find a file with a specific hash value.
140 There is on the other hand no guarantee that such a method does not exist.