# Secure Hash Algorithm (SHA)

Secure Hash Algorithm (SHA) is the important topic of the Subject Information and Network Security.

- 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.

- 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
**F**that consists of 80 rounds. - Secure Hash Algorithm (SHA) has 80 rounds.
- Each round takes as input:
- 512-bit buffer value (
**H**)_{i-1} - 64-bit words
**W**obtained from the current data block by message schedule._{t } - Moreover, Additive constant
**K**which represents the first sixty-four bits of the fractional parts of the cube roots of the first eighty prime numbers._{t}

- 512-bit buffer value (

- 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.
**Output**- After all
*N*1024-bit blocks have processed, the output from the N^{th}stage the 512-bit message digest.

### SHA-512 Round Function: Secure Hash Algorithm (SHA)

Moreover, Each round updates the buffer in the following way:

#### Where,

**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.

**Related Terms**

Information and Network Security, Cryptographic Hash Function, Hash Functions: Cipher Block Chaining, Digital Signature Standard

## Leave a Reply