SHA-256
The NIST Merkle–Damgård hash family behind most of today's TLS, signatures and software
About SHA-256
SHA-256 is one of 6 SHA-2 variants in the NextSSL registry, a cryptographic hash function. It produces a 32-byte (256-bit) output. Its registry entry cites FIPS 180-4 and RFC 6234. It is also known as sha-256 and sha2-256. NextSSL lists it in the safe tier and exposes it through the safe API.
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–2012SHA-256, SHA-384 and SHA-512 proposed
Published in FIPS 180-2
SHA-224 added
Specified in RFC 6234
SHA-512/224 and SHA-512/256 added in FIPS 180-4
How it works
- Pad the message and append its bit length
- Split into 512-bit (SHA-256) or 1024-bit (SHA-512) blocks
- Expand each block into a message schedule of 64 or 80 words
- Run the compression rounds and add the result into the chaining state
- 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
Sizes
| Field | Bytes | Meaning |
|---|---|---|
| out | 32 | Output |
Use it
from nextssl_demo import NextSSL
ns = NextSSL() # safe API: safe and standard tiers
digest = ns.call("hash_with", "sha256", None, b"abc")[0]
nextssl_hash_with("sha256", NULL, data, out);
use nextssl_core::Params;
use nextssl_registry::{self as reg, Policy};
let digest = reg::hash_in(reg::all(), Policy::Safe, "sha256", &Params::new(), b"abc")?;
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Other SHA-2 variants
5Similar names
Looking for something else?More hash functions
All 424Frequently asked questions
What is SHA-256?
SHA-256 is a hash in the SHA-2 family. SHA-2 is a family of hash functions designed by the NSA and published by NIST in FIPS 180. It is also known as sha-256, sha2-256.
What are the SHA-256 sizes?
In NextSSL, SHA-256 uses: output 32 bytes.
Who designed SHA-256 and when?
SHA-256 belongs to the SHA-2 family, first published in 2001 by National Security Agency. Its origin: NIST FIPS 180-2 / FIPS 180-4.
Which standards define SHA-256?
SHA-256 is referenced by FIPS 180-4, RFC 6234. It is specified in a FIPS standard.
Is SHA-256 safe to use?
SHA-256 is in the safe tier. Modern and recommended. The default choice for new designs. It can be called from the safe API.
What other SHA-2 variants are there?
NextSSL also registers sha224, sha384, sha512, sha512-224, sha512-256 in the SHA-2 family.
Related families
NIST SP 800-90A deterministic random bit generator built on HMAC
BLAKE2A fast, secure successor to BLAKE with built-in keying, salting and tree hashing
SHA-3 and KeccakThe Keccak sponge, standardised by NIST in FIPS 202 as a structural alternative to SHA-2
HKDFHMAC-based extract-and-expand key derivation function (RFC 5869)
BLAKE2A fast, secure successor to BLAKE with built-in keying, salting and tree hashing
HMACThe standard way to build a MAC from a cryptographic hash (RFC 2104, FIPS 198-1)