1 .\" $NetBSD: mdX.3,v 1.10 2003/06/13 01:28:41 lukem Exp $
3 .\" ----------------------------------------------------------------------------
4 .\" "THE BEER-WARE LICENSE" (Revision 42):
5 .\" <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
6 .\" can do whatever you want with this stuff. If we meet some day, and you think
7 .\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
8 .\" ----------------------------------------------------------------------------
10 .\" from FreeBSD Id: mdX.3,v 1.7 1996/10/22 16:28:56 phk Exp
22 .Nd calculate the RSA Data Security, Inc.,
31 .Fn MDXInit "MDX_CTX *context"
33 .Fn MDXUpdate "MDX_CTX *context" "const unsigned char *data" "unsigned int len"
35 .Fn MDXFinal "unsigned char digest[16]" "MDX_CTX *context"
37 .Fn MDXEnd "MDX_CTX *context" "char *buf"
39 .Fn MDXFile "const char *filename" "char *buf"
41 .Fn MDXData "const unsigned char *data" "unsigned int len" "char *buf"
43 The MDX functions calculate a 128-bit cryptographic checksum (digest)
44 for any number of input bytes.
45 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.
49 a ``fingerprint'' of the input-data, which doesn't disclose the actual
52 MD2 is the slowest, MD4 is the fastest and MD5 is somewhere in the middle.
53 MD2 can only be used for Privacy-Enhanced Mail.
54 MD4 has been criticized for being too weak, so MD5 was developed in
55 response as ``MD4 with safety-belts''.
56 When in doubt, use MD5.
63 functions are the core functions.
64 Allocate an MDX_CTX, initialize it with
66 run over the data with
68 and finally extract the result using
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 These functions appeared in
132 The original MDX routines were developed by
134 Data Security, Inc., and published in the above references.
135 This code is derived directly from these implementations by Poul-Henning Kamp
136 .Aq Li phk@login.dkuug.dk
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.