1.\" $NetBSD: md2.3,v 1.3 2018/12/17 08:18:06 wiz Exp $ 2.\" 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.\" ---------------------------------------------------------------------------- 9.\" 10.\" from FreeBSD Id: mdX.3,v 1.7 1996/10/22 16:28:56 phk Exp 11.\" 12.Dd September 24, 2005 13.Dt MD2 3 14.Os 15.Sh NAME 16.Nm MD2Init , 17.Nm MD2Update , 18.Nm MD2Final , 19.Nm MD2End , 20.Nm MD2File , 21.Nm MD2Data 22.Nd calculate the RSA Data Security, Inc., 23.Dq MD2 24message digest 25.Sh LIBRARY 26.Lb libc 27.Sh SYNOPSIS 28.In sys/types.h 29.In mdX.h 30.Ft void 31.Fn MD2Init "MD2_CTX *context" 32.Ft void 33.Fn MD2Update "MD2_CTX *context" "const unsigned char *data" "unsigned int len" 34.Ft void 35.Fn MD2Final "unsigned char digest[16]" "MD2_CTX *context" 36.Ft "char *" 37.Fn MD2End "MD2_CTX *context" "char *buf" 38.Ft "char *" 39.Fn MD2File "const char *filename" "char *buf" 40.Ft "char *" 41.Fn MD2Data "const unsigned char *data" "unsigned int len" "char *buf" 42.Sh DESCRIPTION 43The MD2 functions calculate a 128-bit cryptographic checksum (digest) 44for any number of input bytes. 45A cryptographic checksum is a one-way 46hash-function, that is, you cannot find (except by exhaustive search) 47the input corresponding to a particular output. 48This net result is 49a ``fingerprint'' of the input-data, which doesn't disclose the actual 50input. 51.Pp 52The MD2 routines should not be used for any security-related purpose. 53.Pp 54The 55.Fn MD2Init , 56.Fn MD2Update , 57and 58.Fn MD2Final 59functions are the core functions. 60Allocate an MD2_CTX, initialize it with 61.Fn MD2Init , 62run over the data with 63.Fn MD2Update , 64and finally extract the result using 65.Fn MD2Final . 66.Pp 67.Fn MD2End 68is a wrapper for 69.Fn MD2Final 70which converts the return value to a 33-character 71(including the terminating '\e0') ASCII 72string which represents the 128 bits in hexadecimal. 73.Pp 74.Fn MD2File 75calculates the digest of a file, and uses 76.Fn MD2End 77to return the result. 78If the file cannot be opened, a null pointer is returned. 79.Fn MD2Data 80calculates the digest of a chunk of data in memory, and uses 81.Fn MD2End 82to return the result. 83.Pp 84When using 85.Fn MD2End , 86.Fn MD2File , 87or 88.Fn MD2Data , 89the 90.Ar buf 91argument can be a null pointer, in which case the returned string 92is allocated with 93.Xr malloc 3 94and subsequently must be explicitly deallocated using 95.Xr free 3 96after use. 97If the 98.Ar buf 99argument is non-null it must point to at least 33 characters of buffer space. 100.Sh SEE ALSO 101.Xr md4 3 , 102.Xr md5 3 , 103.Xr openssl_MD2 3 , 104.Xr openssl_MD4 3 , 105.Xr openssl_MD5 3 , 106.Rs 107.%A B. Kaliski 108.%T The MD2 Message-Digest Algorithm 109.%O RFC 1319 110.Re 111.Rs 112.%A RSA Laboratories 113.%T Frequently Asked Questions About today's Cryptography 114.Re 115.Sh HISTORY 116These functions appeared in 117.Nx 1.3 . 118.Sh AUTHORS 119.An -nosplit 120The original MD2 routines were developed by 121.An RSA Data Security, Inc. , 122and published in the above references. 123This code is a public domain implementation by 124.An Andrew Brown . 125.Sh BUGS 126No method is known to exist which finds two files having the same hash value, 127nor to find a file with a specific hash value. 128There is on the other hand no guarantee that such a method doesn't exist. 129