The Secure Hash Algorithms are a family of cryptographic hash functions published by the National Institute of Standards and Technology (NIST) as a U.S. Federal Information Processing Standard (FIPS), including:

  • SHA-0: A retronym applied to the original version of the 160-bit hash function published in 1993 under the name "SHA". It was withdrawn shortly after publication due to an undisclosed "significant flaw" and replaced by the slightly revised version SHA-1.
  • SHA-1: A 160-bit hash function which resembles the earlier MD5 algorithm. This was designed by the National Security Agency (NSA) to be part of the Digital Signature Algorithm. Cryptographic weaknesses were discovered in SHA-1, and the standard was no longer approved for most cryptographic uses after 2010.
  • SHA-2: A family of two similar hash functions, with different block sizes, known as SHA-256 and SHA-512. They differ in the word size; SHA-256 uses 32-bit words where SHA-512 uses 64-bit words. There are also truncated versions of each standard, known as SHA-224, SHA-384, SHA-512/224 and SHA-512/256. These were also designed by the NSA.
  • SHA-3: A hash function formerly called Keccak, chosen in 2012 after a public competition among non-NSA designers. It supports the same hash lengths as SHA-2, and its internal structure differs significantly from the rest of the SHA family.
  • SHA-4: A "standard for arithmetization-oriented hash functions" under development.

The corresponding standards are FIPS PUB 180 (original SHA), FIPS PUB 180-1 (SHA-1), FIPS PUB 180-2 (SHA-1, SHA-256, SHA-384, and SHA-512). NIST has updated Draft FIPS Publication 202, SHA-3 Standard separate from the Secure Hash Standard (SHS).

Comparison of SHA functions

In the table below, internal state means the "internal hash sum" after each compression of a data block.

Comparison of SHA functions viewtalkedit
Algorithm and variantOutput size (bits)Internal state size (bits)Block size (bits)RoundsOperationsSecurity (bits)Performance on Skylake (median cpb)First published
Long messages8 bytes
MD5 (as reference)128128 (4 × 32)5124 (16 operations in each round)And, Xor, Or, Rot, Add (mod 232)≤ 18 (collisions found)4.9955.001992
SHA-0160160 (5 × 32)51280And, Xor, Or, Rot, Add (mod 232)< 34 (collisions found)≈ SHA-1≈ SHA-11993
SHA-1< 63 (collisions found)3.4752.001995
SHA-2SHA-224 SHA-256224 256256 (8 × 32)51264And, Xor, Or, Rot, Shr, Add (mod 232)112 1287.62 7.6384.50 85.252004 2001
SHA-384384512 (8 × 64)102480And, Xor, Or, Rot, Shr, Add (mod 264)1925.12135.752001
SHA-5125122565.06135.502001
SHA-512/224 SHA-512/256224 256112 128≈ SHA-384≈ SHA-3842012
SHA-3SHA3-224 SHA3-256 SHA3-384 SHA3-512224 256 384 5121600 (5 × 5 × 64)1152 1088 832 57624And, Xor, Rot, Not112 128 192 2568.12 8.59 11.06 15.88154.25 155.50 164.00 164.002015
SHAKE128 SHAKE256d (arbitrary) d (arbitrary)1344 1088min(d/2, 128) min(d/2, 256)7.08 8.59155.25 155.50

Validation

All SHA-family algorithms, as FIPS-approved security functions, are subject to official validation by the CMVP (Cryptographic Module Validation Program), a joint program run by the American National Institute of Standards and Technology (NIST) and the Canadian Communications Security Establishment (CSE).