xref: /freebsd/lib/libmd/ripemd.3 (revision 13ea0450a9c8742119d36f3bf8f47accdce46e54)
1.\"
2.\" ----------------------------------------------------------------------------
3.\" "THE BEER-WARE LICENSE" (Revision 42):
4.\" <phk@FreeBSD.org> 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 July 20, 2018
13.Dt RIPEMD 3
14.Os
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.In sys/types.h
28.In 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.
48A cryptographic checksum is a one-way
49hash function; that is, it is computationally impractical to find
50the input corresponding to a particular output.
51This net result is a
52.Dq fingerprint
53of the input-data, which does not disclose the actual input.
54.Pp
55The
56.Fn RIPEMD160_Init ,
57.Fn RIPEMD160_Update ,
58and
59.Fn RIPEMD160_Final
60functions are the core functions.
61Allocate an
62.Vt RIPEMD160_CTX ,
63initialize it with
64.Fn RIPEMD160_Init ,
65run over the data with
66.Fn RIPEMD160_Update ,
67and finally extract the result using
68.Fn RIPEMD160_Final ,
69which will also erase the
70.Vt RIPEMD160_CTX .
71.Pp
72The
73.Fn RIPEMD160_End
74function is a wrapper for
75.Fn RIPEMD160_Final
76which converts the return value to a 41-character
77(including the terminating '\e0')
78.Tn ASCII
79string which represents the 160 bits in hexadecimal.
80.Pp
81The
82.Fn RIPEMD160_File
83function calculates the digest of a file, and uses
84.Fn RIPEMD160_End
85to return the result.
86If the file cannot be opened, a null pointer is returned.
87The
88.Fn RIPEMD160_FileChunk
89function is similar to
90.Fn RIPEMD160_File ,
91but it only calculates the digest over a byte-range of the file specified,
92starting at
93.Fa offset
94and spanning
95.Fa length
96bytes.
97If the
98.Fa length
99parameter is specified as 0, or more than the length of the remaining part
100of the file,
101.Fn RIPEMD160_FileChunk
102calculates the digest from
103.Fa offset
104to the end of file.
105The
106.Fn RIPEMD160_Data
107function calculates the digest of a chunk of data in memory, and uses
108.Fn RIPEMD160_End
109to return the result.
110.Pp
111When using
112.Fn RIPEMD160_End ,
113.Fn RIPEMD160_File ,
114or
115.Fn RIPEMD160_Data ,
116the
117.Fa buf
118argument can be a null pointer, in which case the returned string
119is allocated with
120.Xr malloc 3
121and subsequently must be explicitly deallocated using
122.Xr free 3
123after use.
124If the
125.Fa buf
126argument is non-null it must point to at least 41 characters of buffer space.
127.Sh SEE ALSO
128.Xr md4 3 ,
129.Xr md5 3 ,
130.Xr sha 3 ,
131.Xr sha256 3 ,
132.Xr sha512 3 ,
133.Xr skein 3
134.Sh HISTORY
135These functions appeared in
136.Fx 4.0 .
137.Sh AUTHORS
138The core hash routines were implemented by Eric Young based on the
139published
140.Tn RIPEMD160
141specification.
142.Sh BUGS
143No method is known to exist which finds two files having the same hash value,
144nor to find a file with a specific hash value.
145There is on the other hand no guarantee that such a method does not exist.
146