Hash family

SHA-2

The NIST Merkle–Damgård hash family behind most of today's TLS, signatures and software

safe 6 variants NIST FIPS 180-2 / FIPS 180-4

Overview

SHA-2 is a family of hash functions designed by the NSA and published by NIST in FIPS 180. SHA-256 and SHA-512 are the most widely deployed cryptographic hashes in use, and the family remains unbroken after more than two decades of analysis.

SHA-2 follows the Merkle–Damgård construction. The message is padded with a single 1 bit, zeros and a length field, split into fixed-size blocks, and fed through a compression function built in Davies–Meyer style from a dedicated block cipher. SHA-256 works on 32-bit words with 64 rounds over 512-bit blocks; SHA-512 uses 64-bit words with 80 rounds over 1024-bit blocks. Each round combines additions, rotations and the Ch and Maj boolean functions.

NextSSL carries SHA-224 and SHA-256 from the 32-bit branch, and SHA-384, SHA-512, SHA-512/224 and SHA-512/256 from the 64-bit branch. The truncated variants use distinct initial values, so they are not simple prefixes of the full outputs. SHA-512/256 is often faster than SHA-256 on 64-bit processors while offering the same nominal collision resistance.

SHA-256 and SHA-512 were introduced in FIPS 180-2 in 2002, SHA-224 was added in 2004, and the SHA-512/t variants arrived with FIPS 180-4. RFC 6234 provides a reference implementation. The family is used throughout TLS, X.509, code signing, Git's SHA-256 object format and many blockchains. It is the default hash in most libraries and the one auditors expect to see.

History

2001–2012
  1. SHA-256, SHA-384 and SHA-512 proposed

  2. Published in FIPS 180-2

  3. SHA-224 added

  4. Specified in RFC 6234

  5. SHA-512/224 and SHA-512/256 added in FIPS 180-4

How it works

  1. Pad the message and append its bit length
  2. Split into 512-bit (SHA-256) or 1024-bit (SHA-512) blocks
  3. Expand each block into a message schedule of 64 or 80 words
  4. Run the compression rounds and add the result into the chaining state
  5. Output the final state, truncated for the shorter variants

Security notes

No practical collision or preimage attacks are known against full SHA-2. SHA-256 and SHA-512 are vulnerable to length-extension, so they must not be used as a MAC by simple prefixing a key; use HMAC instead. SHA-384 and SHA-512/256 are not length-extendable because their output is truncated.

Typical uses

Digital signatures and certificatesHMAC and HKDFFile and package integrityContent addressing

Variants in NextSSL

6
AlgorithmTierSizes (bytes)StandardsAPI
SHA-256
sha256
safe FIPS out 32 FIPS 180-4, RFC 6234 safe
SHA-384
sha384
safe FIPS out 48 FIPS 180-4, RFC 6234 safe
SHA-512
sha512
safe FIPS out 64 FIPS 180-4, RFC 6234 safe
SHA-512-224
sha512-224
safe FIPS out 28 FIPS 180-4 safe
SHA-512-256
sha512-256
safe FIPS out 32 FIPS 180-4 safe
SHA-224
sha224
standard FIPS out 28 FIPS 180-4, RFC 6234 safe

Frequently asked questions

Which SHA-2 variants does NextSSL include?

NextSSL registers 6 SHA-2 variants: sha256, sha384, sha512, sha512-224, sha512-256, sha224.