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 $
10 .\" $DragonFly: src/lib/libmd/mdX.3,v 1.4 2008/09/11 20:25:34 swildner Exp $
24 .Nd calculate the RSA Data Security, Inc., ``MDX'' message digest
31 .Fn MDXInit "MDX_CTX *context"
33 .Fn MDXUpdate "MDX_CTX *context" "const void *data" "unsigned int len"
35 .Fn MDXPad "MDX_CTX *context"
37 .Fn MDXFinal "unsigned char digest[16]" "MDX_CTX *context"
39 .Fn MDXEnd "MDX_CTX *context" "char *buf"
41 .Fn MDXFile "const char *filename" "char *buf"
43 .Fn MDXFileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
45 .Fn MDXData "const void *data" "unsigned int len" "char *buf"
47 The MDX functions calculate a 128-bit cryptographic checksum (digest)
48 for any number of input bytes.
49 A cryptographic checksum is a one-way
50 hash-function, that is, you cannot find (except by exhaustive search)
51 the input corresponding to a particular output.
54 of the input-data, which does not disclose the actual input.
56 MD2 is the slowest, MD4 is the fastest and MD5 is somewhere in the middle.
57 MD2 can only be used for Privacy-Enhanced Mail.
58 MD4 has now been broken; it should only be used where necessary for
59 backward compatibility.
60 MD5 has not yet (1999-02-11) been broken, but sufficient attacks have been
61 made that its security is in some doubt.
62 The attacks on both MD4 and MD5
63 are both in the nature of finding
67 inputs which hash to the same value; it is still unlikely for an attacker
68 to be able to determine the exact original input given a hash value.
75 functions are the core functions.
80 run over the data with
82 and finally extract the result using
87 function can be used to pad message data in same way
90 without terminating calculation.
94 function is a wrapper for
96 which converts the return value to a 33-character
97 (including the terminating '\e0')
99 string which represents the 128 bits in hexadecimal.
103 function 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.
109 function is similar to
111 but it only calculates the digest over a byte-range of the file specified,
119 parameter is specified as 0, or more than the length of the remaining part
122 calculates the digest from
127 function calculates the digest of a chunk of data in memory, and uses
129 to return the result.
138 argument can be a null pointer, in which case the returned string
141 and subsequently must be explicitly deallocated using
146 argument is non-null it must point to at least 33 characters of buffer space.
154 .%T The MD2 Message-Digest Algorithm
159 .%T The MD4 Message-Digest Algorithm
164 .%T The MD5 Message-Digest Algorithm
169 .%T Frequently Asked Questions About today's Cryptography
170 .%O \&<http://www.rsa.com/rsalabs/faq/>
181 .%T On Recent Results for MD2, MD4 and MD5
182 .%J RSA Laboratories Bulletin
184 .%D November 12, 1996
187 These functions appeared in
190 The original MDX routines were developed by
192 Data Security, Inc., and published in the above references.
193 This code is derived directly from these implementations by
194 .An Poul-Henning Kamp Aq phk@FreeBSD.org
198 No method is known to exist which finds two files having the same hash value,
199 nor to find a file with a specific hash value.
200 There is on the other hand no guarantee that such a method does not exist.
202 MD2 has only been licensed for use in Privacy Enhanced Mail.
203 Use MD4 or MD5 if that is not what you are doing.