
      Message-Digest Algorithms for Delphi/Borland Pascal


This package contains straight-forward Pascal implementations of two 
secure hash algorithms, MD5 and SHA-1. Both implementations have been 
tested against reference implementations.


--- MD5 ---
For more information on the MD5 message-digest algorithm, developed by 
Ron Rivest of RSA Data Security, see the enclosed RFC (rfc1321.txt). 
The actual C-code I translated for this implementation is not the 
reference implementation, but the code used in PGP 2.6.2i. The code 
optimizes very well in 32-bit C or assembler, however speed was not the 
main issue for the Pascal version. Anyway, with Delphi32 and the 
built-in 32-bit assembler (?) this code will be much easier to optimize, 
I guess...
If you are interested in other MDx related documents, surf to 
  <http://www.rsa.com/pub/>


--- SHA-1 ---
The SHA-1 algorithm is a bug-fix of the original SHA, see the enclosed 
FIPS publication (fips180.txt). Be careful, the algorithm described in 
the January 1994 issue of Dr. Dobbs Journal is the original SHA. Since 
then, a flaw has been discovered and corrected by adding a rotate 
instruction in the calculation of Wt. If you look at Section 7 of FIPS 
PUB 180 (page 9), the line which reads

   "b) For t=16 to 79 let Wt = S1(Wt-3 XOR Wt-8 XOR Wt-14 XOR Wt-16)."

has replaced 

   "b) For t=16 to 79 let Wt = Wt-3 XOR Wt-8 XOR Wt-14 XOR Wt-16."

By the way, I found the FIPS document at 
  <http://csrc.ncsl.nist.gov/fips/>



If you need an example on how to use the functions contained in this 
package, have a look at the sample program, hashtest.


Have fun!

Koos Lodewijkx
email: <J.P.Lodewijkx@inter.nl.net>