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
29 .Nd calculate the FIPS 160 and 160-1 ``SHA'' message digests
36 .Fn SHA_Init "SHA_CTX *context"
38 .Fn SHA_Update "SHA_CTX *context" "const unsigned char *data" "size_t len"
40 .Fn SHA_Final "unsigned char digest[20]" "SHA_CTX *context"
42 .Fn SHA_End "SHA_CTX *context" "char *buf"
44 .Fn SHA_File "const char *filename" "char *buf"
46 .Fn SHA_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
48 .Fn SHA_Data "const unsigned char *data" "unsigned int len" "char *buf"
50 .Fn SHA1_Init "SHA_CTX *context"
52 .Fn SHA1_Update "SHA_CTX *context" "const unsigned char *data" "size_t len"
54 .Fn SHA1_Final "unsigned char digest[20]" "SHA_CTX *context"
56 .Fn SHA1_End "SHA_CTX *context" "char *buf"
58 .Fn SHA1_File "const char *filename" "char *buf"
60 .Fn SHA1_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
62 .Fn SHA1_Data "const unsigned char *data" "unsigned int len" "char *buf"
68 functions calculate a 160-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.
78 SHA (or SHA-0) is the original Secure Hash Algorithm specified in FIPS 160.
79 It was quickly proven insecure, and has been superseded by SHA-1.
80 SHA-0 is included for compatibility purposes only.
87 functions are the core functions.
92 run over the data with
94 and finally extract the result using
96 which will also erase the
102 which converts the return value to a 41-character
103 (including the terminating '\e0')
104 ASCII string which represents the 160 bits in hexadecimal.
107 calculates the digest of a file, and uses
109 to return the result.
110 If the file cannot be opened, a null pointer is returned.
114 but it only calculates the digest over a byte-range of the file specified,
122 parameter is specified as 0, or more than the length of the remaining part
125 calculates the digest from
129 calculates the digest of a chunk of data in memory, and uses
131 to return the result.
140 argument can be a null pointer, in which case the returned string
143 and subsequently must be explicitly deallocated using
148 argument is non-null it must point to at least 41 characters of buffer space.
152 function called with a null buf argument may fail and return NULL if:
155 Insufficient storage space is available.
162 may return NULL when underlying
177 These functions appeared in
180 The core hash routines were implemented by Eric Young based on the
184 The SHA1 algorithm has been proven to be vulnerable to practical collision
185 attacks and should not be relied upon to produce unique outputs,
186 .Em nor should it be used as part of a new cryptographic signature scheme.