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 .\" $Id: mdX.3,v 1.12 1998/03/19 07:34:12 charnier Exp $
22 .Nd calculate the RSA Data Security, Inc., ``MDX'' message digest
24 .Fd #include <sys/types.h>
27 .Fn MDXInit "MDX_CTX *context"
29 .Fn MDXUpdate "MDX_CTX *context" "const unsigned char *data" "unsigned int len"
31 .Fn MDXPad "MDX_CTX *context"
33 .Fn MDXFinal "unsigned char digest[16]" "MDX_CTX *context"
35 .Fn MDXEnd "MDX_CTX *context" "char *buf"
37 .Fn MDXFile "const char *filename" "char *buf"
39 .Fn MDXData "const unsigned char *data" "unsigned int len" "char *buf"
41 The MDX functions calculate a 128-bit cryptographic checksum (digest)
42 for any number of input bytes. A cryptographic checksum is a one-way
43 hash-function, that is, you cannot find (except by exhaustive search)
44 the input corresponding to a particular output. This net result is
45 a ``fingerprint'' of the input-data, which doesn't disclose the actual
48 MD2 is the slowest, MD4 is the fastest and MD5 is somewhere in the middle.
49 MD2 can only be used for Privacy-Enhanced Mail.
50 MD4 has been criticized for being too weak, so MD5 was developed in
51 response as ``MD4 with safety-belts''. When in doubt, use MD5.
58 functions are the core functions. Allocate an MDX_CTX, initialize it with
60 run over the data with
62 and finally extract the result using
66 can be used to pad message data in same way
69 without terminating calculation.
74 which converts the return value to a 33-character
75 (including the terminating '\e0')
77 string which represents the 128 bits in hexadecimal.
80 calculates the digest of a file, and uses
83 If the file cannot be opened, a null pointer is returned.
85 calculates the digest of a chunk of data in memory, and uses
96 argument can be a null pointer, in which case the returned string
99 and subsequently must be explicitly deallocated using
104 argument is non-null it must point to at least 33 characters of buffer space.
111 .%T The MD2 Message-Digest Algorithm
116 .%T The MD4 Message-Digest Algorithm
121 .%T The MD5 Message-Digest Algorithm
126 .%T Frequently Asked Questions About today's Cryptography
129 The original MDX routines were developed by
131 Data Security, Inc., and published in the above references.
132 This code is derived directly from these implementations by
133 .An Poul-Henning Kamp Aq phk@login.dkuug.dk
137 These functions appeared in
140 No method is known to exist which finds two files having the same hash value,
141 nor to find a file with a specific hash value.
142 There is on the other hand no guarantee that such a method doesn't exist.
144 MD2 has only been licensed for use in Privacy Enhanced Mail.
145 Use MD4 or MD5 if that isn't what you're doing.