Secure Hash Algorithm (SHA)
- SHA is based on the hash function MD4.
- The algorithm takes as input a message of a maximum length of less than 2128bitsand produces a 512-bit message digest.
- The input is processed in 1024-bit blocks.
- The processing consists of the following steps:
- Append padding bits.
- The message is padded so that its length is congruent to 896 modulo 1024.
- The padding consists of a single 1-bit followed by the necessary number of 0-bits.
- Append length.
- A block of 128 bits is appended to the message. This block contains the length of the original message (before the padding).
- The message is now an integer multiple of 1024 bits in length.
- Append padding bits.
- In the figure below, an expanded message is represented as the sequence of 1024-bit blocks M1, M2,…, MN and the total length of the expanded message is N x 1024 bits.
- Initialize hash buffer
- A 512-bit buffer used to hold intermediate and final results of the hash function.
- The buffer can represent as eight 64-bit registers (a, b, c, d, e, f, g, h).
- These registers initialized to the 64-bit integers(hexadecimal values) obtained by taking the first sixty-four bits of the fractional parts of the square roots of the first eight prime numbers.
- Process message in 1024-bit (128-word) blocks.
- The heart of the algorithm is a module Fthat consists of 80 rounds.
- Secure Hash Algorithm (SHA) has 80 rounds.
- Each round takes as input:
- 512-bit buffer value (Hi-1)
- 64-bit words Wt obtained from the current data block by message schedule.
- Moreover, Additive constant Kt which represents the first sixty-four bits of the fractional parts of the cube roots of the first eighty prime numbers.
- The contents of the buffer updated after every round.
- Moreover, The output of the eightieth round added modulo 264to the input to the first round (Hi-1) to produce Hi.
- After all N 1024-bit blocks have processed, the output from the Nth stage the 512-bit message digest.
SHA-512 Round Function: Secure Hash Algorithm (SHA)
Moreover, Each round updates the buffer in the following way:
Message Schedule: Secure Hash Algorithm (SHA)
- The 64-bit word values Wtare derived from the 1024-bit message.
- The first16 values of Wt taken directly from the 16 words of the current block. The remaining values defined as follows:
The message schedule introduces a great deal of redundancy and interdependence into the message blocks that compressed, which complicates the task of finding a different message block that maps to the same compression function output.