Introduction to the

The SHA algorithm is used to compute the hash function. The current SHA algorithms include SHA1, SHA2, and SHA3. All three algorithms were developed by NIST in the US.

NIST is the U.S. National Institute of Standards and Technology, which sets standards.

This article will explain the relationship between NIST and SHA algorithms.

SHA1

In cryptography, Secure Hash Algorithm 1 (SHA-1) is an encrypted Hash function that takes an input and produces a 160-bit (20-byte) Hash value called an information digest.

Let’s take a look at the flow chart of SHA1 encryption:

A, B, C, D, and E are 32bits of state.

F is a nonlinear function.

<<< < is the left shift operation, the plus sign in red is the addition and then modulo 232.

The SHA1 algorithm was simple, and after 2005, SHA1 was considered unsafe, and as of 2010, many organizations recommended replacing SHA-1.

NIST officially abolished the use of SHA-1 in 2011 and banned its use for digital signatures in 2013.

All major web browser vendors stopped accepting SHA-1 SSL certificates in 2017.

SHA2

Sha-2 (Secure Hash Algorithm 2) is also a set of cryptographic Hash functions designed by the NATIONAL Security Agency (NSA). It was first published in 2001 and adopts the Merkle-Damgard structure.

Sha-2 includes significant changes compared to SHA-1. The SHA-2 series contains six hash functions, namely, SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256.

Let’s take a look at the algorithm flow of SHA2:

Let’s see what these functions mean:

SHA3

In 2006, NIST organized the NIST Hash Function Competition to create a new hash standard, SHA-3. Sha-3 is not intended to replace SHA-2, as no significant attacks on SHA-2 have yet been proven. But because of the success of MD5, SHA-0, and SHA-1 attacks, NIST decided that an alternative, different cryptography hash was needed, and this was SHA-3.

In this competition, Keccak algorithm won and was selected as the standard of SHA3.

SHA3 algorithm is based on sponge structure. Let’s take a look at the working principle of sponge structure:

The function is divided into two parts, the left part is called the absorption part, and the right part is called the output part, and it sucks in and out, like a sponge, so it’s called the sponge function.

P represents the input string, Z represents the output string.

A sponge function consists of three parts: state, f, and pad.

State is the r+ C part of the figure above, where R is called Bitrate and C is called Capacity.

P is divided into n parts, and each part will be xor with Bitrate. If the length of P is not an integer multiple of Bitrate, Pad function will be used to fill it.

In each round, the result of the xOR operation between Bitrate and P is the latest Bitrate, and then a new state is generated, which is replaced by F (State).

Where function f is a mapping from n {0,1} to n {0,1}.

And so it goes on round and round, until all the P’s are involved.

The output part is to perform F operation on the state finally generated, and each operation takes the Bitrate part as the output, so as to obtain the final output.

This article is available at www.flydean.com/sha1-2-3/

“> < p style =” max-width: 100%; clear: both;

“> < p style =” max-width: 100%; clear: both; min-height: 1em;