]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libmd/ripemd.3
Merge llvm-project main llvmorg-16-init-18548-gb0daacf58f41
[FreeBSD/FreeBSD.git] / lib / libmd / ripemd.3
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
44 The
45 .Li RIPEMD160_
46 functions calculate a 160-bit cryptographic checksum (digest)
47 for any number of input bytes.
48 A cryptographic checksum is a one-way
49 hash function; that is, it is computationally impractical to find
50 the input corresponding to a particular output.
51 This net result is a
52 .Dq fingerprint
53 of the input-data, which does not disclose the actual input.
54 .Pp
55 The
56 .Fn RIPEMD160_Init ,
57 .Fn RIPEMD160_Update ,
58 and
59 .Fn RIPEMD160_Final
60 functions are the core functions.
61 Allocate an
62 .Vt RIPEMD160_CTX ,
63 initialize it with
64 .Fn RIPEMD160_Init ,
65 run over the data with
66 .Fn RIPEMD160_Update ,
67 and finally extract the result using
68 .Fn RIPEMD160_Final ,
69 which will also erase the
70 .Vt RIPEMD160_CTX .
71 .Pp
72 The
73 .Fn RIPEMD160_End
74 function is a wrapper for
75 .Fn RIPEMD160_Final
76 which converts the return value to a 41-character
77 (including the terminating '\e0')
78 ASCII string which represents the 160 bits in hexadecimal.
79 .Pp
80 The
81 .Fn RIPEMD160_File
82 function calculates the digest of a file, and uses
83 .Fn RIPEMD160_End
84 to return the result.
85 If the file cannot be opened, a null pointer is returned.
86 The
87 .Fn RIPEMD160_FileChunk
88 function is similar to
89 .Fn RIPEMD160_File ,
90 but it only calculates the digest over a byte-range of the file specified,
91 starting at
92 .Fa offset
93 and spanning
94 .Fa length
95 bytes.
96 If the
97 .Fa length
98 parameter is specified as 0, or more than the length of the remaining part
99 of the file,
100 .Fn RIPEMD160_FileChunk
101 calculates the digest from
102 .Fa offset
103 to the end of file.
104 The
105 .Fn RIPEMD160_Data
106 function calculates the digest of a chunk of data in memory, and uses
107 .Fn RIPEMD160_End
108 to return the result.
109 .Pp
110 When using
111 .Fn RIPEMD160_End ,
112 .Fn RIPEMD160_File ,
113 or
114 .Fn RIPEMD160_Data ,
115 the
116 .Fa buf
117 argument can be a null pointer, in which case the returned string
118 is allocated with
119 .Xr malloc 3
120 and subsequently must be explicitly deallocated using
121 .Xr free 3
122 after use.
123 If the
124 .Fa buf
125 argument is non-null it must point to at least 41 characters of buffer space.
126 .Sh ERRORS
127 The
128 .Fn RIPEMD160_End
129 function called with a null buf argument may fail and return NULL if:
130 .Bl -tag -width Er
131 .It Bq Er ENOMEM
132 Insufficient storage space is available.
133 .El
134 .Pp
135 The
136 .Fn RIPEMD160_File
137 and
138 .Fn RIPEMD160_FileChunk
139 may return NULL when underlying
140 .Xr open 2 ,
141 .Xr fstat 2 ,
142 .Xr lseek 2 ,
143 or
144 .Xr RIPEMD160_End 3
145 fail.
146 .Sh SEE ALSO
147 .Xr md4 3 ,
148 .Xr md5 3 ,
149 .Xr sha 3 ,
150 .Xr sha256 3 ,
151 .Xr sha512 3 ,
152 .Xr skein 3
153 .Sh HISTORY
154 These functions appeared in
155 .Fx 4.0 .
156 .Sh AUTHORS
157 The core hash routines were implemented by Eric Young based on the
158 published RIPEMD160 specification.
159 .Sh BUGS
160 No method is known to exist which finds two files having the same hash value,
161 nor to find a file with a specific hash value.
162 There is on the other hand no guarantee that such a method does not exist.