1ripemd128(n)            RIPEMD Message-Digest Algorithm           ripemd128(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       ripemd128 - RIPEMD-128 Message-Digest Algorithm
9

SYNOPSIS

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

DESCRIPTION

36       This  package is an implementation in Tcl of the RIPEMD-128 message-di‐
37       gest algorithm (1). This algorithm takes an arbitrary quantity of  data
38       and  generates  a 128-bit message digest from the input. The RIPEMD-128
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). RIPEMD-128 has been designed to be a drop-in replacement  for  MD4
42       and MD5 (5). If security is the major consideration, then RIPEMD-160 or
43       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

COMMANDS

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 op‐
70              tions other than -key are as for  the  ::ripemd::ripemd128  com‐
71              mand.
72

PROGRAMMING INTERFACE

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  im‐
88       plementation.  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  RIPEMD128Up‐
96              date $token "abcd" is equivalent to calling RIPEMD128Update $to‐
97              ken "ab" followed by RIPEMD128Update $token "cb". See EXAMPLES.
98
99       ::ripemd::RIPEMD128Final token
100              Returns the hash value and releases any resources held  by  this
101              token.  Once  this  command completes the token will be invalid.
102              The result is a binary string of 16 bytes representing  the  128
103              bit RIPEMD-128 digest value.
104
105       ::ripemd::RIPEHMAC128Init key
106              This is equivalent to the ::ripemd::RIPEMD128Init command except
107              that it requires the key that will be included in the HMAC.
108
109       ::ripemd::RIPEHMAC128Update token data
110
111       ::ripemd::RIPEHMAC128Final token
112              These commands are identical to the  RIPEMD128  equivalent  com‐
113              mands.
114

EXAMPLES

116              % ripemd::ripemd128 -hex "Tcl does RIPEMD-128"
117              3cab177bae65205d81e7978f63556c63
118
119
120
121              % ripemd::hmac128 -hex -key Sekret "Tcl does RIPEMD-128"
122              b359dc5971a05beea0be7b106b30e389
123
124
125
126              % set tok [ripemd::RIPEMD128Init]
127              ::ripemd::1
128              % ripemd::RIPEMD128Update $tok "Tcl "
129              % ripemd::RIPEMD128Update $tok "does "
130              % ripemd::RIPEMD128Update $tok "RIPEMD-128"
131              % ripemd::Hex [ripemd::RIPEMD128Final $tok]
132              3cab177bae65205d81e7978f63556c63
133
134

REFERENCES

136       [1]    H.   Dobbertin,   A.  Bosselaers,  B.  Preneel,  "RIPEMD-160,  a
137              strengthened   version   of    RIPEMD"    http://www.esat.kuleu
138              ven.ac.be/~cosicart/pdf/AB-9601/AB-9601.pdf
139
140       [2]    Rivest,  R.,  "The MD4 Message Digest Algorithm", RFC 1320, MIT,
141              April 1992. (http://www.rfc-editor.org/rfc/rfc1320.txt)
142
143       [3]    Rivest, R., "The MD4 message digest algorithm", in A.J.  Menezes
144              and  S.A. Vanstone, editors, Advances in Cryptology - CRYPTO '90
145              Proceedings, pages 303-311, Springer-Verlag, 1991.
146
147       [4]    Dobbertin, H., "Cryptanalysis of MD4", Journal of Cryptology vol
148              11 (4), pp. 253-271 (1998)
149
150       [5]    Rivest,  R.,  "The  MD5 Message-Digest Algorithm", RFC 1321, MIT
151              and RSA Data Security, Inc,  April  1992.   (http://www.rfc-edi
152              tor.org/rfc/rfc1321.txt)
153
154       [6]    Krawczyk,  H.,  Bellare, M. and Canetti, R. "HMAC: Keyed-Hashing
155              for  Message   Authentication",   RFC   2104,   February   1997.
156              (http://www.rfc-editor.org/rfc/rfc2104.txt)
157

BUGS, IDEAS, FEEDBACK

159       This  document,  and the package it describes, will undoubtedly contain
160       bugs and other problems.  Please report such in the category ripemd  of
161       the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please
162       also report any ideas for enhancements you may have for either  package
163       and/or documentation.
164
165       When proposing code changes, please provide unified diffs, i.e the out‐
166       put of diff -u.
167
168       Note further that  attachments  are  strongly  preferred  over  inlined
169       patches.  Attachments  can  be  made  by  going to the Edit form of the
170       ticket immediately after its creation, and  then  using  the  left-most
171       button in the secondary navigation bar.
172

SEE ALSO

174       md4, md5, ripemd160, sha1
175

KEYWORDS

177       RIPEMD, hashing, md4, message-digest, rfc 1320, rfc 1321, rfc 2104, se‐
178       curity
179

CATEGORY

181       Hashes, checksums, and encryption
182
184       Copyright (c) 2004, Pat Thoyts <patthoyts@users.sourceforge.net>
185
186
187
188
189tcllib                               1.0.5                        ripemd128(n)
Impressum