2 .\" ----------------------------------------------------------------------------
3 .\" "THE BEER-WARE LICENSE" (Revision 42):
4 .\" <phk@login.dkuug.dk> 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.16.2.5 2001/12/17 10:08:31 ru Exp $
10 .\" $DragonFly: src/lib/libmd/mdX.3,v 1.3 2006/02/17 19:35:07 swildner 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 unsigned char *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 MDXData "const unsigned char *data" "unsigned int len" "char *buf"
44 The MDX functions calculate a 128-bit cryptographic checksum (digest)
45 for any number of input bytes. A cryptographic checksum is a one-way
46 hash-function, that is, you cannot find (except by exhaustive search)
47 the input corresponding to a particular output. This net result is
48 a ``fingerprint'' of the input-data, which doesn't disclose the actual
51 MD2 is the slowest, MD4 is the fastest and MD5 is somewhere in the middle.
52 MD2 can only be used for Privacy-Enhanced Mail.
53 MD4 has now been broken; it should only be used where necessary for
54 backward compatibility.
55 MD5 has not yet (1999-02-11) been broken, but sufficient attacks have been
56 made that its security is in some doubt. The attacks on both MD4 and MD5
57 are both in the nature of finding ``collisions'' \- that is, multiple
58 inputs which hash to the same value; it is still unlikely for an attacker
59 to be able to determine the exact original input given a hash value.
66 functions are the core functions. Allocate an MDX_CTX, initialize it with
68 run over the data with
70 and finally extract the result using
74 can be used to pad message data in same way
77 without terminating calculation.
82 which converts the return value to a 33-character
83 (including the terminating '\e0')
85 string which represents the 128 bits in hexadecimal.
88 calculates the digest of a file, and uses
91 If the file cannot be opened, a null pointer is returned.
93 calculates the digest of a chunk of data in memory, and uses
104 argument can be a null pointer, in which case the returned string
107 and subsequently must be explicitly deallocated using
112 argument is non-null it must point to at least 33 characters of buffer space.
120 .%T The MD2 Message-Digest Algorithm
125 .%T The MD4 Message-Digest Algorithm
130 .%T The MD5 Message-Digest Algorithm
135 .%T Frequently Asked Questions About today's Cryptography
136 .%O \&<http://www.rsa.com/rsalabs/faq/>
147 .%T On Recent Results for MD2, MD4 and MD5
148 .%J RSA Laboratories Bulletin
150 .%D November 12, 1996
153 These functions appeared in
156 The original MDX routines were developed by
158 Data Security, Inc., and published in the above references.
159 This code is derived directly from these implementations by
160 .An Poul-Henning Kamp Aq phk@login.dkuug.dk
164 No method is known to exist which finds two files having the same hash value,
165 nor to find a file with a specific hash value.
166 There is on the other hand no guarantee that such a method doesn't exist.
168 MD2 has only been licensed for use in Privacy Enhanced Mail.
169 Use MD4 or MD5 if that isn't what you're doing.