Cryptography Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 4.00
 This site Web Message Digest - SHA1 Algorithm Part:   1  2  3  4  This tutorial helps you to understand What is SHA1? SHA1 Algorithm Overview SHA1 Implementation in Java SHA1 Implementation in PHP SHA1 Implementation in Perl What is SHA1 SHA1 (Secure Hash Algorithm 1) is message-digest algorithm, which takes an input message of any length < 2^64 bits and produces a 160-bit output as the message digest. Based on the SHA1 RFC document, the SHA-1 is called secure because it is computationally infeasible to find a message which corresponds to a given message digest, or to find two different messages which produce the same message digest. Any change to a message in transit will, with very high probability, result in a different message digest, and the signature will fail to verify. The original specification of the algorithm was published in 1993 as the Secure Hash Standard, FIPS PUB 180, by US government standards agency NIST (National Institute of Standards and Technology). This version is now often referred to as "SHA0". SHA-0 was withdrawn by the NSA shortly after publication and was superseded by the revised version, published in 1995 in FIPS PUB 180-1 and commonly referred to as "SHA1". SHA1 Algorithm Overview SHA1 algorithm is well described in RFC 3174 - US Secure Hash Algorithm 1 (SHA1), see http://www.ietf.org/rfc/rfc3174.txt. Below is a quick overview of the algorithm. SHA1 algorithm consists of 6 tasks: Task 1. Appending Padding Bits. The original message is "padded" (extended) so that its length (in bits) is congruent to 448, modulo 512. The padding rules are: The original message is always padded with one bit "1" first. Then zero or more bits "0" are padded to bring the length of the message up to 64 bits fewer than a multiple of 512. Task 2. Appending Length. 64 bits are appended to the end of the padded message to indicate the length of the original message in bytes. The rules of appending length are: The length of the original message in bytes is converted to its binary format of 64 bits. If overflow happens, only the low-order 64 bits are used. Break the 64-bit length into 2 words (32 bits each). The low-order word is appended first and followed by the high-order word. (Continued on next part...) Part:   1  2  3  4

Dr. Herong Yang, updated in 2007
Cryptography Tutorials - Herong's Tutorial Notes - Message Digest - SHA1 Algorithm