xref: /freebsd/lib/libmd/ripemd.3 (revision 8a24546c85d1bd2cf5c71ec245301ff0b7712bae)
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.\" 	From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
10.\" $FreeBSD$
11.\"
12.Dd February 26, 1999
13.Dt RIPEMD 3
14.Os FreeBSD
15.Sh NAME
16.Nm RIPEMD160_Init ,
17.Nm RIPEMD160_Update ,
18.Nm RIPEMD160_Final ,
19.Nm RIPEMD160_End ,
20.Nm RIPEMD160_File ,
21.Nm RIPEMD160_FileChunk ,
22.Nm RIPEMD160_Data
23.Nd calculate the RIPEMD160 message digest
24.Sh LIBRARY
25.Lb libmd
26.Sh SYNOPSIS
27.Fd #include <sys/types.h>
28.Fd #include <ripemd.h>
29.Ft void
30.Fn RIPEMD160_Init "RIPEMD160_CTX *context"
31.Ft void
32.Fn RIPEMD160_Update "RIPEMD160_CTX *context" "const unsigned char *data" "unsigned int len"
33.Ft void
34.Fn RIPEMD160_Final "unsigned char digest[20]" "RIPEMD160_CTX *context"
35.Ft "char *"
36.Fn RIPEMD160_End "RIPEMD160_CTX *context" "char *buf"
37.Ft "char *"
38.Fn RIPEMD160_File "const char *filename" "char *buf"
39.Ft "char *"
40.Fn RIPEMD160_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
41.Ft "char *"
42.Fn RIPEMD160_Data "const unsigned char *data" "unsigned int len" "char *buf"
43.Sh DESCRIPTION
44The
45.Li RIPEMD160_
46functions calculate a 160-bit cryptographic checksum (digest)
47for any number of input bytes.  A cryptographic checksum is a one-way
48hash function; that is, it is computationally impractical to find
49the input corresponding to a particular output.  This net result is
50a ``fingerprint'' of the input-data, which doesn't disclose the actual
51input.
52.Pp
53The
54.Fn RIPEMD160_Init  ,
55.Fn RIPEMD160_Update ,
56and
57.Fn RIPEMD160_Final
58functions are the core functions.  Allocate an RIPEMD160_CTX, initialize it with
59.Fn RIPEMD160_Init ,
60run over the data with
61.Fn RIPEMD160_Update ,
62and finally extract the result using
63.Fn RIPEMD160_Final .
64.Pp
65.Fn RIPEMD160_End
66is a wrapper for
67.Fn RIPEMD160_Final
68which converts the return value to a 41-character
69(including the terminating '\e0')
70.Tn ASCII
71string which represents the 160 bits in hexadecimal.
72.Pp
73.Fn RIPEMD160_File
74calculates the digest of a file, and uses
75.Fn RIPEMD160_End
76to return the result.
77If the file cannot be opened, a null pointer is returned.
78.Fn RIPEMD160_FileChunk
79is similar to
80.Fn RIPEMD160_File ,
81but it only calculates the digest over a byte-range of the file specified,
82starting at
83.Ar offset
84and spanning
85.Ar length
86bytes.
87If the
88.Ar length
89parameter is specified as 0, or more than the length of the remaining part
90of the file,
91.Fn RIPEMD160_FileChunk
92calculates the digest from
93.Ar offset
94to the end of file.
95.Fn RIPEMD160_Data
96calculates the digest of a chunk of data in memory, and uses
97.Fn RIPEMD160_End
98to return the result.
99.Pp
100When using
101.Fn RIPEMD160_End ,
102.Fn RIPEMD160_File ,
103or
104.Fn RIPEMD160_Data ,
105the
106.Ar buf
107argument can be a null pointer, in which case the returned string
108is allocated with
109.Xr malloc 3
110and subsequently must be explicitly deallocated using
111.Xr free 3
112after use.
113If the
114.Ar buf
115argument is non-null it must point to at least 41 characters of buffer space.
116.Sh SEE ALSO
117.Xr md2 3 ,
118.Xr md4 3 ,
119.Xr md5 3 ,
120.Xr sha 3
121.Sh AUTHORS
122The core hash routines were implemented by Eric Young based on the
123published
124.Tn RIPEMD160
125specification.
126.Sh HISTORY
127These functions appeared in
128.Fx 4.0 .
129.Sh BUGS
130No method is known to exist which finds two files having the same hash value,
131nor to find a file with a specific hash value.
132There is on the other hand no guarantee that such a method doesn't exist.
133