1c9502b53SPoul-Henning Kamp.\" 2c9502b53SPoul-Henning Kamp.\" ---------------------------------------------------------------------------- 3c9502b53SPoul-Henning Kamp.\" "THE BEER-WARE LICENSE" (Revision 42): 4c9502b53SPoul-Henning Kamp.\" <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you 5c9502b53SPoul-Henning Kamp.\" can do whatever you want with this stuff. If we meet some day, and you think 6c9502b53SPoul-Henning Kamp.\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 7c9502b53SPoul-Henning Kamp.\" ---------------------------------------------------------------------------- 8c9502b53SPoul-Henning Kamp.\" 9c9502b53SPoul-Henning Kamp.\" $FreeBSD$ 10c9502b53SPoul-Henning Kamp.\" 11c9502b53SPoul-Henning Kamp.Dd July 14, 1994 12c9502b53SPoul-Henning Kamp.Dt MDX 3 13c9502b53SPoul-Henning Kamp.Os FreeBSD 2 14c9502b53SPoul-Henning Kamp.Sh NAME 15c9502b53SPoul-Henning Kamp.Nm MDXInit , 16c9502b53SPoul-Henning Kamp.Nm MDXUpdate , 17c9502b53SPoul-Henning Kamp.Nm MDXFinal , 18c9502b53SPoul-Henning Kamp.Nm MDXEnd , 19c9502b53SPoul-Henning Kamp.Nm MDXFile , 20c9502b53SPoul-Henning Kamp.Nm MDXData . 21c9502b53SPoul-Henning Kamp.Nd calculate ``MDX'' cryptographic checksum 22c9502b53SPoul-Henning Kamp.Sh SYNOPSIS 23c9502b53SPoul-Henning Kamp.Fd #include <mdX.h> 24c9502b53SPoul-Henning Kamp.Ft void 25c9502b53SPoul-Henning Kamp.Fn MDXInit "MDX_CTX *context" 26c9502b53SPoul-Henning Kamp.Ft void 27c9502b53SPoul-Henning Kamp.Fn MDXUpdate "MDX_CTX *context" "unsigned char *data" "unsigned int len" 28c9502b53SPoul-Henning Kamp.Ft void 29c9502b53SPoul-Henning Kamp.Fn MDXFinal "unsigned char digest[16]" "MDX_CTX *context" 30c9502b53SPoul-Henning Kamp.Ft "char *" 31c9502b53SPoul-Henning Kamp.Fn MDXEnd "MDX_CTX *context" 32c9502b53SPoul-Henning Kamp.Ft "char *" 33c9502b53SPoul-Henning Kamp.Fn MDXFile "char *filename" 34c9502b53SPoul-Henning Kamp.Ft "char *" 35c9502b53SPoul-Henning Kamp.Fn MDXData "unsigned char *data" "unsigned int len" 36c9502b53SPoul-Henning Kamp.Sh DESCRIPTION 37c9502b53SPoul-Henning KampThe MDX functions calculate a 128-bit cryptographic checksum (digest) 38c9502b53SPoul-Henning Kampfor any number of input bytes. A cryptographic checksum is a one-way 39c9502b53SPoul-Henning Kamphash-function, that is, you cannot find (except by exhaustive search) 40c9502b53SPoul-Henning Kampthe input corresponding to a particular output. This net result is 41c9502b53SPoul-Henning Kampa ``fingerprint'' of the input-data, which doesn't disclose the actual 42c9502b53SPoul-Henning Kampinput. 43c9502b53SPoul-Henning Kamp 44c9502b53SPoul-Henning KampMD2 is the slowest, MD4 is the fastest and MD5 is somewhere in the middle. 45c9502b53SPoul-Henning KampMD2 can only be used for Privacy-Enhanced Mail. 46c9502b53SPoul-Henning KampMD4 has been critizised for being to weak, and MD5 was developed as a 47c9502b53SPoul-Henning Kampresponse to this as ``MD4 with safety-belts''. If in doubt, use MD5. 48c9502b53SPoul-Henning Kamp 49c9502b53SPoul-Henning KampThe 50c9502b53SPoul-Henning Kamp.Fn MDXInit , 51c9502b53SPoul-Henning Kamp.Fn MDXUpdate 52c9502b53SPoul-Henning Kampand 53c9502b53SPoul-Henning Kamp.Fn MDXFinal 54c9502b53SPoul-Henning Kampfunctions are the core functions. Allocate a MDX_CTX, initialize it with 55c9502b53SPoul-Henning Kamp.Fn MDXInit 56c9502b53SPoul-Henning Kamprun over the data with 57c9502b53SPoul-Henning Kamp.Fn MDXUpdate 58c9502b53SPoul-Henning Kampand finally extract the result using 59c9502b53SPoul-Henning Kamp.Fn MDXFinal . 60c9502b53SPoul-Henning Kamp 61c9502b53SPoul-Henning Kamp.Fn MDXEnd 62c9502b53SPoul-Henning Kampis identical to 63c9502b53SPoul-Henning Kamp.Fn MDXFinal , 64c9502b53SPoul-Henning Kampexcept the return is in ASCII-HEX in a 65c9502b53SPoul-Henning Kampstring allocated with 66c9502b53SPoul-Henning Kamp.Xr malloc 3 . 67c9502b53SPoul-Henning Kamp 68c9502b53SPoul-Henning Kamp.Fn MDXFile 69c9502b53SPoul-Henning Kampcalculates the digest of a file, and returns the ASCII-HEX result. 70c9502b53SPoul-Henning KampIn case the file cannot be opened, NULL is returned. 71c9502b53SPoul-Henning Kamp 72c9502b53SPoul-Henning Kamp.Fn MDXData 73c9502b53SPoul-Henning Kampcalculates the digest of a chunk of data in memory, and returns the ASCII-HEX 74c9502b53SPoul-Henning Kampresult. 75c9502b53SPoul-Henning Kamp 76c9502b53SPoul-Henning KampWhen using 77c9502b53SPoul-Henning Kamp.Fn MDXEnd , 78c9502b53SPoul-Henning Kamp.Fn MDXFile 79c9502b53SPoul-Henning Kampand 80c9502b53SPoul-Henning Kamp.Fn MDXData , 81c9502b53SPoul-Henning Kampthe returned string must be explicitly deallocated using 82c9502b53SPoul-Henning Kamp.Xr free 3 83c9502b53SPoul-Henning Kampafter use. 84c9502b53SPoul-Henning Kamp.Sh SEE ALSO 85c9502b53SPoul-Henning Kamp.Xr md2 3 , 86c9502b53SPoul-Henning Kamp.Xr md4 3 , 87c9502b53SPoul-Henning Kamp.Xr md5 3 88c9502b53SPoul-Henning Kamp.Pp 89c9502b53SPoul-Henning KampISOC 90c9502b53SPoul-Henning KampInternet Request For Comments 91c9502b53SPoul-Henning Kamp.%T RFC1319 , 92c9502b53SPoul-Henning Kamp.%T RFC1320 93c9502b53SPoul-Henning Kampand 94c9502b53SPoul-Henning Kamp.%T RFC1321 . 95c9502b53SPoul-Henning Kamp.Pp 96c9502b53SPoul-Henning KampRSA Laboratories 97c9502b53SPoul-Henning Kamp.%T Frequently Asked Questions About today's Cryptography . 98c9502b53SPoul-Henning Kamp.Sh AUTHOR 99c9502b53SPoul-Henning KampThe MD2, MD4 and MD5 is designed and written by Ron Rivest and published in 100c9502b53SPoul-Henning Kampthe above RFC's, including a reference implementation of each algorithm. 101c9502b53SPoul-Henning Kamp 102c9502b53SPoul-Henning KampThis code is derived directly from these implementations by Poul-Henning Kamp 103c9502b53SPoul-Henning Kamp<phk@login.dkuug.dk> 104c9502b53SPoul-Henning Kamp 105c9502b53SPoul-Henning KampPhk ristede runen. 106c9502b53SPoul-Henning Kamp.Sh HISTORY 107c9502b53SPoul-Henning KampThese functions appeared in 108c9502b53SPoul-Henning Kamp.Em FreeBSD-2.0 109c9502b53SPoul-Henning Kamp.Sh BUGS 110c9502b53SPoul-Henning KampNo method is known to exist which finds two files having the same hash value, 111c9502b53SPoul-Henning Kampnor to find a file with a specific hash value. 112c9502b53SPoul-Henning KampThere is on the other hand no guarantee that such a method doesn't exist. 113c9502b53SPoul-Henning Kamp 114c9502b53SPoul-Henning KampMD2 can only be used for Privacy Enhanced Mail. 115c9502b53SPoul-Henning KampUse MD4 or MD5 if that isn't what you're doing. 116c9502b53SPoul-Henning Kamp.Sh COPYRIGHT 117