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 .\" $FreeBSD: src/lib/libmd/mdX.3,v 1.30 2006/01/17 15:35:56 phk Exp $
23 .Nd calculate the RSA Data Security, Inc., ``MDX'' message digest
30 .Fn MDXInit "MDX_CTX *context"
32 .Fn MDXUpdate "MDX_CTX *context" "const void *data" "unsigned int len"
34 .Fn MDXPad "MDX_CTX *context"
36 .Fn MDXFinal "unsigned char digest[16]" "MDX_CTX *context"
38 .Fn MDXEnd "MDX_CTX *context" "char *buf"
40 .Fn MDXFile "const char *filename" "char *buf"
42 .Fn MDXFileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
44 .Fn MDXData "const void *data" "unsigned int len" "char *buf"
46 The MDX functions calculate a 128-bit cryptographic checksum (digest)
47 for any number of input bytes.
48 A cryptographic checksum is a one-way
49 hash-function, that is, you cannot find (except by exhaustive search)
50 the input corresponding to a particular output.
53 of the input-data, which does not disclose the actual input.
55 MD2 is the slowest, MD4 is the fastest and MD5 is somewhere in the middle.
56 MD2 can only be used for Privacy-Enhanced Mail.
57 MD4 has now been broken; it should only be used where necessary for
58 backward compatibility.
59 MD5 has not yet (1999-02-11) been broken, but sufficient attacks have been
60 made that its security is in some doubt.
61 The attacks on both MD4 and MD5
62 are both in the nature of finding
66 inputs which hash to the same value; it is still unlikely for an attacker
67 to be able to determine the exact original input given a hash value.
74 functions are the core functions.
79 run over the data with
81 and finally extract the result using
86 function can be used to pad message data in same way
89 without terminating calculation.
93 function is a wrapper for
95 which converts the return value to a 33-character
96 (including the terminating '\e0')
98 string which represents the 128 bits in hexadecimal.
102 function calculates the digest of a file, and uses
104 to return the result.
105 If the file cannot be opened, a null pointer is returned.
108 function is similar to
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
126 function calculates the digest of a chunk of data in memory, and uses
128 to return the result.
137 argument can be a null pointer, in which case the returned string
140 and subsequently must be explicitly deallocated using
145 argument is non-null it must point to at least 33 characters of buffer space.
153 .%T The MD2 Message-Digest Algorithm
158 .%T The MD4 Message-Digest Algorithm
163 .%T The MD5 Message-Digest Algorithm
168 .%T Frequently Asked Questions About today's Cryptography
169 .%O \&<http://www.rsa.com/rsalabs/faq/>
180 .%T On Recent Results for MD2, MD4 and MD5
181 .%J RSA Laboratories Bulletin
183 .%D November 12, 1996
186 These functions appeared in
189 The original MDX routines were developed by
191 Data Security, Inc., and published in the above references.
192 This code is derived directly from these implementations by
193 .An Poul-Henning Kamp Aq Mt phk@FreeBSD.org
197 No method is known to exist which finds two files having the same hash value,
198 nor to find a file with a specific hash value.
199 There is on the other hand no guarantee that such a method does not exist.
201 MD2 has only been licensed for use in Privacy Enhanced Mail.
202 Use MD4 or MD5 if that is not what you are doing.