1ripemd128(n) RIPEMD Message-Digest Algorithm ripemd128(n)
2
3
4
5______________________________________________________________________________
6
8 ripemd128 - RIPEMD-128 Message-Digest Algorithm
9
11 package require Tcl 8.2
12
13 package require ripemd128 ?1.0.5?
14
15 ::ripemd::ripemd128 ?-hex? [ -channel channel | -file filename | string
16 ]
17
18 ::ripemd::hmac128 ?-hex? -key key [ -channel channel | -file filename |
19 string ]
20
21 ::ripemd::RIPEMD128Init
22
23 ::ripemd::RIPEMD128Update token data
24
25 ::ripemd::RIPEMD128Final token
26
27 ::ripemd::RIPEHMAC128Init key
28
29 ::ripemd::RIPEHMAC128Update token data
30
31 ::ripemd::RIPEHMAC128Final token
32
33______________________________________________________________________________
34
36 This package is an implementation in Tcl of the RIPEMD-128 message-
37 digest algorithm (1). This algorithm takes an arbitrary quantity of
38 data and generates a 128-bit message digest from the input. The
39 RIPEMD-128 algorithm is based upon the MD4 algorithm (2, 4) but has
40 been cryptographically strengthened against weaknesses that have been
41 found in MD4 (4). RIPEMD-128 has been designed to be a drop-in replace‐
42 ment for MD4 and MD5 (5). If security is the major consideration, then
43 RIPEMD-160 or SHA1 should be considered.
44
45 This package will use Trf to accelerate the digest computation if
46 available. In the absence of an accelerator package the pure-Tcl imple‐
47 mentation will be used.
48
50 ::ripemd::ripemd128 ?-hex? [ -channel channel | -file filename | string
51 ]
52 Calculate the RIPEMD-128 digest of the data given in string.
53 This is returned as a binary string by default. Giving the -hex
54 option will return a hexadecimal encoded version of the digest.
55
56 The data to be hashed can be specified either as a string argu‐
57 ment to the ripemd128 command, or as a filename or a pre-opened
58 channel. If the -filename argument is given then the file is
59 opened, the data read and hashed and the file is closed. If the
60 -channel argument is given then data is read from the channel
61 until the end of file. The channel is not closed.
62
63 Only one of -file, -channel or string should be given.
64
65 ::ripemd::hmac128 ?-hex? -key key [ -channel channel | -file filename |
66 string ]
67 Calculate an Hashed Message Authentication digest (HMAC) using
68 the RIPEMD-128 digest algorithm. HMACs are described in RFC 2104
69 (6) and provide a RIPEMD-128 digest that includes a key. All
70 options other than -key are as for the ::ripemd::ripemd128 com‐
71 mand.
72
74 For the programmer, hash functions can be viewed as a bucket into which
75 one pours data. When you have finished, you extract a value that is
76 uniquely derived from the data that was poured into the bucket. The
77 programming interface to the hash operates on a token (equivalent to
78 the bucket). You call RIPEMD128Init to obtain a token and then call
79 RIPEMD128Update as many times as required to add data to the hash. To
80 release any resources and obtain the hash value, you then call
81 RIPEMD128Final. An equivalent set of functions gives you a keyed digest
82 (HMAC).
83
84 If you have critcl and have built the tcllibc package then the imple‐
85 mentation of the hashing function will be performed by compiled code.
86 Alternatively if both the Trf and Memchan extensions are available then
87 these will be used. Finally the package will revert to a pure-Tcl
88 implementation. The programming interface remains the same, however.
89
90 ::ripemd::RIPEMD128Init
91 Begins a new RIPEMD-128 hash. Returns a token ID that must be
92 used for the remaining functions.
93
94 ::ripemd::RIPEMD128Update token data
95 Add data to the hash identified by token. Calling
96 RIPEMD128Update $token "abcd" is equivalent to calling
97 RIPEMD128Update $token "ab" followed by RIPEMD128Update $token
98 "cb". See EXAMPLES.
99
100 ::ripemd::RIPEMD128Final token
101 Returns the hash value and releases any resources held by this
102 token. Once this command completes the token will be invalid.
103 The result is a binary string of 16 bytes representing the 128
104 bit RIPEMD-128 digest value.
105
106 ::ripemd::RIPEHMAC128Init key
107 This is equivalent to the ::ripemd::RIPEMD128Init command except
108 that it requires the key that will be included in the HMAC.
109
110 ::ripemd::RIPEHMAC128Update token data
111
112 ::ripemd::RIPEHMAC128Final token
113 These commands are identical to the RIPEMD128 equivalent com‐
114 mands.
115
117 % ripemd::ripemd128 -hex "Tcl does RIPEMD-128"
118 3cab177bae65205d81e7978f63556c63
119
120
121
122 % ripemd::hmac128 -hex -key Sekret "Tcl does RIPEMD-128"
123 b359dc5971a05beea0be7b106b30e389
124
125
126
127 % set tok [ripemd::RIPEMD128Init]
128 ::ripemd::1
129 % ripemd::RIPEMD128Update $tok "Tcl "
130 % ripemd::RIPEMD128Update $tok "does "
131 % ripemd::RIPEMD128Update $tok "RIPEMD-128"
132 % ripemd::Hex [ripemd::RIPEMD128Final $tok]
133 3cab177bae65205d81e7978f63556c63
134
135
137 [1] H. Dobbertin, A. Bosselaers, B. Preneel, "RIPEMD-160, a
138 strengthened version of RIPEMD" http://www.esat.kuleu‐
139 ven.ac.be/~cosicart/pdf/AB-9601/AB-9601.pdf
140
141 [2] Rivest, R., "The MD4 Message Digest Algorithm", RFC 1320, MIT,
142 April 1992. (http://www.rfc-editor.org/rfc/rfc1320.txt)
143
144 [3] Rivest, R., "The MD4 message digest algorithm", in A.J. Menezes
145 and S.A. Vanstone, editors, Advances in Cryptology - CRYPTO '90
146 Proceedings, pages 303-311, Springer-Verlag, 1991.
147
148 [4] Dobbertin, H., "Cryptanalysis of MD4", Journal of Cryptology vol
149 11 (4), pp. 253-271 (1998)
150
151 [5] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, MIT
152 and RSA Data Security, Inc, April 1992. (http://www.rfc-edi‐
153 tor.org/rfc/rfc1321.txt)
154
155 [6] Krawczyk, H., Bellare, M. and Canetti, R. "HMAC: Keyed-Hashing
156 for Message Authentication", RFC 2104, February 1997.
157 (http://www.rfc-editor.org/rfc/rfc2104.txt)
158
160 This document, and the package it describes, will undoubtedly contain
161 bugs and other problems. Please report such in the category ripemd of
162 the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please
163 also report any ideas for enhancements you may have for either package
164 and/or documentation.
165
166 When proposing code changes, please provide unified diffs, i.e the out‐
167 put of diff -u.
168
169 Note further that attachments are strongly preferred over inlined
170 patches. Attachments can be made by going to the Edit form of the
171 ticket immediately after its creation, and then using the left-most
172 button in the secondary navigation bar.
173
175 md4, md5, ripemd160, sha1
176
178 RIPEMD, hashing, md4, message-digest, rfc 1320, rfc 1321, rfc 2104,
179 security
180
182 Hashes, checksums, and encryption
183
185 Copyright (c) 2004, Pat Thoyts <patthoyts@users.sourceforge.net>
186
187
188
189
190tcllib 1.0.5 ripemd128(n)