Version 18 of sha1

Updated 2005-02-21 16:25:46

Implementations:


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

Recent updates to this standard give a set of related hash algorithms with longer bit lengths. See sha2.


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]

Errata

During testing of tcllib's sha1 2.0 it was discovered that the version 1 package had an error in the HMAC-SHA1 function for keys that require hashing (longer that 64 bytes). Any application using HMAC-SHA1 with tcllib sha1 1.n should ensure that they upgrade. (The sha1::sha1 and sha1::hmac functions still take the same parameters.)


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.


RLH - Don't go running through the streets: broken [L1 ]


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

Category Package, subset Tcllib | Category Cryptography