xref: /minix3/lib/libc/hash/md2/md2.3 (revision 2fe8fb192fe7e8720e3e7a77f928da545e872a6a)
1*2fe8fb19SBen Gras.\" $NetBSD: md2.3,v 1.1 2005/09/24 20:51:14 elad Exp $
2*2fe8fb19SBen Gras.\"
3*2fe8fb19SBen Gras.\" ----------------------------------------------------------------------------
4*2fe8fb19SBen Gras.\" "THE BEER-WARE LICENSE" (Revision 42):
5*2fe8fb19SBen Gras.\" <phk@login.dkuug.dk> wrote this file.  As long as you retain this notice you
6*2fe8fb19SBen Gras.\" can do whatever you want with this stuff. If we meet some day, and you think
7*2fe8fb19SBen Gras.\" this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
8*2fe8fb19SBen Gras.\" ----------------------------------------------------------------------------
9*2fe8fb19SBen Gras.\"
10*2fe8fb19SBen Gras.\"	from FreeBSD Id: mdX.3,v 1.7 1996/10/22 16:28:56 phk Exp
11*2fe8fb19SBen Gras.\"
12*2fe8fb19SBen Gras.Dd September 24, 2005
13*2fe8fb19SBen Gras.Dt MD2 3
14*2fe8fb19SBen Gras.Os
15*2fe8fb19SBen Gras.Sh NAME
16*2fe8fb19SBen Gras.Nm MD2Init ,
17*2fe8fb19SBen Gras.Nm MD2Update ,
18*2fe8fb19SBen Gras.Nm MD2Final ,
19*2fe8fb19SBen Gras.Nm MD2End ,
20*2fe8fb19SBen Gras.Nm MD2File ,
21*2fe8fb19SBen Gras.Nm MD2Data
22*2fe8fb19SBen Gras.Nd calculate the RSA Data Security, Inc.,
23*2fe8fb19SBen Gras.Dq MD2
24*2fe8fb19SBen Grasmessage digest
25*2fe8fb19SBen Gras.Sh LIBRARY
26*2fe8fb19SBen Gras.Lb libc
27*2fe8fb19SBen Gras.Sh SYNOPSIS
28*2fe8fb19SBen Gras.In sys/types.h
29*2fe8fb19SBen Gras.In mdX.h
30*2fe8fb19SBen Gras.Ft void
31*2fe8fb19SBen Gras.Fn MD2Init "MD2_CTX *context"
32*2fe8fb19SBen Gras.Ft void
33*2fe8fb19SBen Gras.Fn MD2Update "MD2_CTX *context" "const unsigned char *data" "unsigned int len"
34*2fe8fb19SBen Gras.Ft void
35*2fe8fb19SBen Gras.Fn MD2Final "unsigned char digest[16]" "MD2_CTX *context"
36*2fe8fb19SBen Gras.Ft "char *"
37*2fe8fb19SBen Gras.Fn MD2End "MD2_CTX *context" "char *buf"
38*2fe8fb19SBen Gras.Ft "char *"
39*2fe8fb19SBen Gras.Fn MD2File "const char *filename" "char *buf"
40*2fe8fb19SBen Gras.Ft "char *"
41*2fe8fb19SBen Gras.Fn MD2Data "const unsigned char *data" "unsigned int len" "char *buf"
42*2fe8fb19SBen Gras.Sh DESCRIPTION
43*2fe8fb19SBen GrasThe MD2 functions calculate a 128-bit cryptographic checksum (digest)
44*2fe8fb19SBen Grasfor any number of input bytes.
45*2fe8fb19SBen GrasA cryptographic checksum is a one-way
46*2fe8fb19SBen Grashash-function, that is, you cannot find (except by exhaustive search)
47*2fe8fb19SBen Grasthe input corresponding to a particular output.
48*2fe8fb19SBen GrasThis net result is
49*2fe8fb19SBen Grasa ``fingerprint'' of the input-data, which doesn't disclose the actual
50*2fe8fb19SBen Grasinput.
51*2fe8fb19SBen Gras.Pp
52*2fe8fb19SBen GrasThe MD2 routines should not be used for any security-related purpose.
53*2fe8fb19SBen Gras.Pp
54*2fe8fb19SBen GrasThe
55*2fe8fb19SBen Gras.Fn MD2Init ,
56*2fe8fb19SBen Gras.Fn MD2Update ,
57*2fe8fb19SBen Grasand
58*2fe8fb19SBen Gras.Fn MD2Final
59*2fe8fb19SBen Grasfunctions are the core functions.
60*2fe8fb19SBen GrasAllocate an MD2_CTX, initialize it with
61*2fe8fb19SBen Gras.Fn MD2Init ,
62*2fe8fb19SBen Grasrun over the data with
63*2fe8fb19SBen Gras.Fn MD2Update ,
64*2fe8fb19SBen Grasand finally extract the result using
65*2fe8fb19SBen Gras.Fn MD2Final .
66*2fe8fb19SBen Gras.Pp
67*2fe8fb19SBen Gras.Fn MD2End
68*2fe8fb19SBen Grasis a wrapper for
69*2fe8fb19SBen Gras.Fn MD2Final
70*2fe8fb19SBen Graswhich converts the return value to a 33-character
71*2fe8fb19SBen Gras(including the terminating '\e0')
72*2fe8fb19SBen Gras.Tn ASCII
73*2fe8fb19SBen Grasstring which represents the 128 bits in hexadecimal.
74*2fe8fb19SBen Gras.Pp
75*2fe8fb19SBen Gras.Fn MD2File
76*2fe8fb19SBen Grascalculates the digest of a file, and uses
77*2fe8fb19SBen Gras.Fn MD2End
78*2fe8fb19SBen Grasto return the result.
79*2fe8fb19SBen GrasIf the file cannot be opened, a null pointer is returned.
80*2fe8fb19SBen Gras.Fn MD2Data
81*2fe8fb19SBen Grascalculates the digest of a chunk of data in memory, and uses
82*2fe8fb19SBen Gras.Fn MD2End
83*2fe8fb19SBen Grasto return the result.
84*2fe8fb19SBen Gras.Pp
85*2fe8fb19SBen GrasWhen using
86*2fe8fb19SBen Gras.Fn MD2End ,
87*2fe8fb19SBen Gras.Fn MD2File ,
88*2fe8fb19SBen Grasor
89*2fe8fb19SBen Gras.Fn MD2Data ,
90*2fe8fb19SBen Grasthe
91*2fe8fb19SBen Gras.Ar buf
92*2fe8fb19SBen Grasargument can be a null pointer, in which case the returned string
93*2fe8fb19SBen Grasis allocated with
94*2fe8fb19SBen Gras.Xr malloc 3
95*2fe8fb19SBen Grasand subsequently must be explicitly deallocated using
96*2fe8fb19SBen Gras.Xr free 3
97*2fe8fb19SBen Grasafter use.
98*2fe8fb19SBen GrasIf the
99*2fe8fb19SBen Gras.Ar buf
100*2fe8fb19SBen Grasargument is non-null it must point to at least 33 characters of buffer space.
101*2fe8fb19SBen Gras.Sh SEE ALSO
102*2fe8fb19SBen Gras.Xr md2 3 ,
103*2fe8fb19SBen Gras.Rs
104*2fe8fb19SBen Gras.%A B. Kaliski
105*2fe8fb19SBen Gras.%T The MD2 Message-Digest Algorithm
106*2fe8fb19SBen Gras.%O RFC 1319
107*2fe8fb19SBen Gras.Re
108*2fe8fb19SBen Gras.Rs
109*2fe8fb19SBen Gras.%A RSA Laboratories
110*2fe8fb19SBen Gras.%T Frequently Asked Questions About today's Cryptography
111*2fe8fb19SBen Gras.Re
112*2fe8fb19SBen Gras.Sh HISTORY
113*2fe8fb19SBen GrasThese functions appeared in
114*2fe8fb19SBen Gras.Nx 1.3 .
115*2fe8fb19SBen Gras.Sh AUTHORS
116*2fe8fb19SBen GrasThe original MD2 routines were developed by
117*2fe8fb19SBen Gras.Tn RSA
118*2fe8fb19SBen GrasData Security, Inc., and published in the above references.
119*2fe8fb19SBen GrasThis code is a public domain implementation by Andrew Brown.
120*2fe8fb19SBen Gras.Sh BUGS
121*2fe8fb19SBen GrasNo method is known to exist which finds two files having the same hash value,
122*2fe8fb19SBen Grasnor to find a file with a specific hash value.
123*2fe8fb19SBen GrasThere is on the other hand no guarantee that such a method doesn't exist.
124