xref: /freebsd/lib/libmd/mdX.3 (revision 0c43d89a0d8e976ca494d4837f4c1f3734d2c300)
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"
32.Ft "char *"
33.Fn MDXFile "char *filename"
34.Ft "char *"
35.Fn MDXData "unsigned char *data" "unsigned int len"
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 identical to
63.Fn MDXFinal ,
64except the return is in ASCII-HEX in a
65string allocated with
66.Xr malloc 3 .
67
68.Fn MDXFile
69calculates the digest of a file, and returns the ASCII-HEX result.
70In case the file cannot be opened, NULL is returned.
71
72.Fn MDXData
73calculates the digest of a chunk of data in memory, and returns the ASCII-HEX
74result.
75
76When using
77.Fn MDXEnd ,
78.Fn MDXFile
79and
80.Fn MDXData ,
81the returned string must be explicitly deallocated using
82.Xr free 3
83after use.
84.Sh SEE ALSO
85.Xr md2 3 ,
86.Xr md4 3 ,
87.Xr md5 3
88.Pp
89ISOC
90Internet Request For Comments
91.%T RFC1319 ,
92.%T RFC1320
93and
94.%T RFC1321 .
95.Pp
96RSA Laboratories
97.%T Frequently Asked Questions About today's Cryptography .
98.Sh AUTHOR
99The MD2, MD4 and MD5 is designed and written by Ron Rivest and published in
100the above RFC's, including a reference implementation of each algorithm.
101
102This code is derived directly from these implementations by Poul-Henning Kamp
103<phk@login.dkuug.dk>
104
105Phk ristede runen.
106.Sh HISTORY
107These functions appeared in
108.Em FreeBSD-2.0
109.Sh BUGS
110No method is known to exist which finds two files having the same hash value,
111nor to find a file with a specific hash value.
112There is on the other hand no guarantee that such a method doesn't exist.
113
114MD2 can only be used for Privacy Enhanced Mail.
115Use MD4 or MD5 if that isn't what you're doing.
116.Sh COPYRIGHT
117