1md4(n)                   MD4 Message-Digest Algorithm                   md4(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       md4 - MD4 Message-Digest Algorithm
9

SYNOPSIS

11       package require Tcl  8.2
12
13       package require md4  ?1.0.7?
14
15       ::md4::md4 ?-hex? [ -channel channel | -file filename | string ]
16
17       ::md4::hmac  ?-hex?  -key  key  [  -channel  channel | -file filename |
18       string ]
19
20       ::md4::MD4Init
21
22       ::md4::MD4Update token data
23
24       ::md4::MD4Final token
25
26       ::md4::HMACInit key
27
28       ::md4::HMACUpdate token data
29
30       ::md4::HMACFinal token
31
32______________________________________________________________________________
33

DESCRIPTION

35       This package is an implementation in  Tcl  of  the  MD4  message-digest
36       algorithm as described in RFC 1320 (1) and (2). This algorithm takes an
37       arbitrary quantity of data and generates a 128-bit message digest  from
38       the  input. The MD4 algorithm is faster but potentially weaker than the
39       related MD5 algorithm (3).
40
41       If you have critcl and have built the tcllibc package then  the  imple‐
42       mentation  of  the hashing function will be performed by compiled code.
43       Alternatively if cryptkit is available this will be used. If no  accel‐
44       erator  package  can be found then the pure-tcl implementation is used.
45       The programming interface remains the same in all cases.
46

COMMANDS

48       ::md4::md4 ?-hex? [ -channel channel | -file filename | string ]
49              Calculate the MD4 digest of the data given in  string.  This  is
50              returned  as  a binary string by default. Giving the -hex option
51              will return a hexadecimal encoded version of the digest.
52
53              The data to be hashed can be specified either as a string  argu‐
54              ment  to the md4 command, or as a filename or a pre-opened chan‐
55              nel. If the -filename argument is given then the file is opened,
56              the data read and hashed and the file is closed. If the -channel
57              argument is given then data is read from the channel  until  the
58              end of file. The channel is not closed.
59
60              Only one of -file, -channel or string should be given.
61
62       ::md4::hmac  ?-hex?  -key  key  [  -channel  channel | -file filename |
63       string ]
64              Calculate an Hashed Message Authentication digest  (HMAC)  using
65              the  MD4  digest  algorithm. HMACs are described in RFC 2104 (4)
66              and provide an MD4 digest that includes a key. All options other
67              than -key are as for the ::md4::md4 command.
68

PROGRAMMING INTERFACE

70       For  the  programmer, the MD4 hash can be viewed as a bucket into which
71       one pours data. When you have finished, you extract  a  value  that  is
72       derived  from the data that was poured into the bucket. The programming
73       interface to the MD4 hash  operates  on  a  token  (equivalent  to  the
74       bucket).  You call MD4Init to obtain a token and then call MD4Update as
75       many times as required  to  add  data  to  the  hash.  To  release  any
76       resources and obtain the hash value, you then call MD4Final. An equiva‐
77       lent set of functions gives you a keyed digest (HMAC).
78
79       ::md4::MD4Init
80              Begins a new MD4 hash. Returns a token ID that must be used  for
81              the remaining functions.
82
83       ::md4::MD4Update token data
84              Add  data  to  the  hash  identified by token. Calling MD4Update
85              $token "abcd" is equivalent to  calling  MD4Update  $token  "ab"
86              followed by MD4Update $token "cb". See EXAMPLES.
87
88       ::md4::MD4Final token
89              Returns  the  hash value and releases any resources held by this
90              token. Once this command completes the token  will  be  invalid.
91              The  result  is a binary string of 16 bytes representing the 128
92              bit MD4 digest value.
93
94       ::md4::HMACInit key
95              This is equivalent to the ::md4::MD4Init command except that  it
96              requires the key that will be included in the HMAC.
97
98       ::md4::HMACUpdate token data
99
100       ::md4::HMACFinal token
101              These commands are identical to the MD4 equivalent commands.
102

EXAMPLES

104              % md4::md4 -hex "Tcl does MD4"
105              858da9b31f57648a032230447bd15f25
106
107
108
109              % md4::hmac -hex -key Sekret "Tcl does MD4"
110              c324088e5752872689caedf2a0464758
111
112
113
114              % set tok [md4::MD4Init]
115              ::md4::1
116              % md4::MD4Update $tok "Tcl "
117              % md4::MD4Update $tok "does "
118              % md4::MD4Update $tok "MD4"
119              % md4::Hex [md4::MD4Final $tok]
120              858da9b31f57648a032230447bd15f25
121
122

REFERENCES

124       [1]    Rivest,  R.,  "The MD4 Message Digest Algorithm", RFC 1320, MIT,
125              April 1992. (http://www.rfc-editor.org/rfc/rfc1320.txt)
126
127       [2]    Rivest, R., "The MD4 message digest algorithm", in A.J.  Menezes
128              and  S.A. Vanstone, editors, Advances in Cryptology - CRYPTO '90
129              Proceedings, pages 303-311, Springer-Verlag, 1991.
130
131       [3]    Rivest, R., "The MD5 Message-Digest Algorithm",  RFC  1321,  MIT
132              and  RSA  Data  Security, Inc, April 1992.  (http://www.rfc-edi
133              tor.org/rfc/rfc1321.txt)
134
135       [4]    Krawczyk, H., Bellare, M. and Canetti, R.  "HMAC:  Keyed-Hashing
136              for   Message   Authentication",   RFC   2104,   February  1997.
137              (http://www.rfc-editor.org/rfc/rfc2104.txt)
138

BUGS, IDEAS, FEEDBACK

140       This document, and the package it describes, will  undoubtedly  contain
141       bugs and other problems.  Please report such in the category md4 of the
142       Tcllib Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please  also
143       report  any  ideas  for  enhancements  you  may have for either package
144       and/or documentation.
145
146       When proposing code changes, please provide unified diffs, i.e the out‐
147       put of diff -u.
148
149       Note  further  that  attachments  are  strongly  preferred over inlined
150       patches. Attachments can be made by going  to  the  Edit  form  of  the
151       ticket  immediately  after  its  creation, and then using the left-most
152       button in the secondary navigation bar.
153

SEE ALSO

155       md5, sha1
156

KEYWORDS

158       hashing, md4, message-digest, rfc 1320, rfc 1321, rfc 2104, security
159

CATEGORY

161       Hashes, checksums, and encryption
162
164       Copyright (c) 2003, Pat Thoyts <patthoyts@users.sourceforge.net>
165
166
167
168
169tcllib                               1.0.7                              md4(n)
Impressum