Version 14 of sha1

Updated 2005-02-21 02:18:58

Implementations:


Cryptographically secure hash designed by NIST and the NSA for the Secure Hash Standard. SHA yields a 160 bit result


For what purposes is SHA1 used??

SHA is based upon the MD4 algorithm designed by Prof. R Rivest. Soon after the release of MD4 some weaknesses were found. While these have not been extended to break the full algorithm MD4 was enhanced by Rivest to create MD5. SHA is also an enhanced MD4 - but has different enhancements. These are an expand transformation, and extra round, and a faster avalanche effect. [BOOK: Applied Cryptography]

SHA might be used for any protocol where a secure one-way cryptographic hash is required. There are lots of such protocols in the literature.


SHA1 in tcllib

PT 21-Feb-2005: The tcllib implementation now supports incremental hashing of data and a critcl compiled extension that maay be used to speed up the digest calculation. The critcl code uses the C implementation from the Tcl sample extension. If available, Trf may be used (where functional).

To incrementally hash data (for instance, while recieving one line at a time of a message):

  package require sha1 2
  set hash [sha1::SHA1Init]
  sha1::SHA1Update $hash $data
  ... repeat ad nauseam ...
  set result [sha1::SHA1Final $hash]

PS 2Feb05: TEA has a sampleextension which is a SHA-1 implementation. Be careful with it, though, it does not function correctly on all platforms. The mingw (windows) build has an odd problem where some times the returned value is 2 characters short or a couple of pairs too long.


See also md4, md5, ripemd, Trf and cryptkit.

Category Package, subset Tcllib | Category Cryptography