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