1.\" 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.\" ---------------------------------------------------------------------------- 8.\" 9.\" $FreeBSD$ 10.\" 11.Dd July 14, 1994 12.Dt MDX 3 13.Os FreeBSD 2 14.Sh NAME 15.Nm MDXInit , 16.Nm MDXUpdate , 17.Nm MDXFinal , 18.Nm MDXEnd , 19.Nm MDXFile , 20.Nm MDXData 21.Nd calculate ``MDX'' cryptographic checksum 22.Sh SYNOPSIS 23.Fd #include <mdX.h> 24.Ft void 25.Fn MDXInit "MDX_CTX *context" 26.Ft void 27.Fn MDXUpdate "MDX_CTX *context" "unsigned char *data" "unsigned int len" 28.Ft void 29.Fn MDXFinal "unsigned char digest[16]" "MDX_CTX *context" 30.Ft "char *" 31.Fn MDXEnd "MDX_CTX *context" "char *buf" 32.Ft "char *" 33.Fn MDXFile "char *filename" "char *buf" 34.Ft "char *" 35.Fn MDXData "unsigned char *data" "unsigned int len" "char *buf" 36.Sh DESCRIPTION 37The MDX functions calculate a 128-bit cryptographic checksum (digest) 38for any number of input bytes. A cryptographic checksum is a one-way 39hash-function, that is, you cannot find (except by exhaustive search) 40the input corresponding to a particular output. This net result is 41a ``fingerprint'' of the input-data, which doesn't disclose the actual 42input. 43 44MD2 is the slowest, MD4 is the fastest and MD5 is somewhere in the middle. 45MD2 can only be used for Privacy-Enhanced Mail. 46MD4 has been critizised for being to weak, and MD5 was developed as a 47response to this as ``MD4 with safety-belts''. If in doubt, use MD5. 48 49The 50.Fn MDXInit , 51.Fn MDXUpdate 52and 53.Fn MDXFinal 54functions are the core functions. Allocate a MDX_CTX, initialize it with 55.Fn MDXInit 56run over the data with 57.Fn MDXUpdate 58and finally extract the result using 59.Fn MDXFinal . 60 61.Fn MDXEnd 62is a wrapper for 63.Fn MDXFinal , 64which converts the return value to a 33 character (incl terminating NULL) 65ascii string which represents the 128 bits in hexadecimal. 66 67.Fn MDXFile 68calculates the digest of a file, and uses 69.Fn MDXEnd 70to return the result. 71In case the file cannot be opened, NULL is returned. 72 73.Fn MDXData 74calculates the digest of a chunk of data in memory, and uses 75.Fn MDXEnd 76to return the result. 77 78When using 79.Fn MDXEnd , 80.Fn MDXFile 81or 82.Fn MDXData , 83the 84.Ar buf 85argument can be NULL, in which case the returned string is allocated with 86.Xr malloc 3 87and subsequently must be explicitly deallocated using 88.Xr free 3 89after use. 90If the 91.Ar buf 92argument isn't NULL it must point to at least 33 characters of buffer space. 93.Sh SEE ALSO 94.Xr md2 3 , 95.Xr md4 3 , 96.Xr md5 3 97.Pp 98ISOC 99Internet Request For Comments 100.%T RFC1319 , 101.%T RFC1320 102and 103.%T RFC1321 . 104.Pp 105RSA Laboratories 106.%T Frequently Asked Questions About today's Cryptography . 107.Sh AUTHOR 108The MD2, MD4 and MD5 is designed and written by Ron Rivest and published in 109the above RFC's, including a reference implementation of each algorithm. 110 111This code is derived directly from these implementations by Poul-Henning Kamp 112<phk@login.dkuug.dk> 113 114Phk ristede runen. 115.Sh HISTORY 116These functions appeared in 117.Fx 2.0 . 118.Sh BUGS 119No method is known to exist which finds two files having the same hash value, 120nor to find a file with a specific hash value. 121There is on the other hand no guarantee that such a method doesn't exist. 122 123MD2 has only been released for use in Privacy Enhanced eMail. 124Use MD4 or MD5 if that isn't what you're doing. 125.Sh COPYRIGHT 126