SHA-2
Adapted from Wikipedia · Adventurer experience
SHA-2, which stands for Secure Hash Algorithm 2, is a group of special math tools made to keep information safe. These tools were created by the United States National Security Agency and shared with the world in 2001. They help protect important data like passwords and secret messages by turning them into mixed-up codes that are hard to guess.
SHA-2 is an updated version of an older tool called SHA-1. It includes six different ways to create these safety codes, and the codes can be different lengths, like 224, 256, 384, or 512 bits. Two of the most used versions are SHA-256 and SHA-512. These two work in very similar ways but use different secret rules to make sure the codes stay safe.
These safety tools were first shared as an official United States standard by the National Institute of Standards and Technology. They were patented in the United States, but anyone can use them without paying extra fees. Even though some clever people have found small weaknesses, SHA-2 is still widely used to keep information safe today.
Hash standard
In 2001, the United States government made new rules to help keep information safe. They created three new ways to protect data, called SHA-256, SHA-384, and SHA-512.
More rules were added later to keep these methods strong. In 2004, SHA-224 was added. In 2012, two more methods, SHA-512/224 and SHA-512/256, were created.
Today, these methods help keep many things secure, like online information and important documents.
Main article: Secure Hash Standard
NIST hash function competition
Applications
Further information: Cryptographic hash function § Applications
The SHA-2 hash function is used in many important security tools and systems, like TLS, SSL, PGP, SSH, S/MIME, and IPsec. It helps keep information safe when we use the internet or send messages.
SHA-256 is used to check that software from Debian is real and unchanged, and it helps make sure emails are genuine with DKIM. Both SHA-256 and SHA-512 help keep internet addresses secure with DNSSEC. Most computer systems that use Linux use SHA-2 to protect passwords.
Many cryptocurrencies, like Bitcoin, use SHA-256 to check that money transfers are real and fair. In mobile networks like 4G and 5G, SHA-256 is used to create special codes that keep our calls and data safe.
Cryptanalysis and validation
For a hash function, finding a message that matches a specific code can sometimes be done by trying every possibility, which is called a preimage attack. Another challenge is finding two different messages that produce the same code, known as a collision attack.
Some uses of cryptographic hashes, like storing passwords, are less affected by collision attacks. To create a password that works for a user, you would still need to access the original password's code.
In document signing, an attacker would need to create two documents—one harmless and one harmful—and get the owner to sign the harmless one. This was possible in the past with older security methods.
Researchers have found new ways to challenge SHA-2, but these are not strong enough to break the full system completely.
Official validation
Main article: Cryptographic Module Validation Program
Official checks ensure that security tools follow strict standards. As of December 2013, many versions of SHA-256 and SHA-512 have been officially checked and approved.
Test vectors
Here are some special numbers called "hashes." They help check if information is correct. These hashes are made from empty messages or simple sentences.
Even a very small change in the message, like adding a period, changes the hash a lot. This makes it very hard to trick the system.
Pseudocode
SHA-256 is a way to take any message and turn it into a fixed set of numbers, called a hash. It follows steps to mix and change the message bits.
First, the message gets ready by adding a '1' bit, some '0' bits, and the length of the original message. This makes the total length a multiple of 512 bits.
The message is split into 512-bit pieces. For each piece, the algorithm makes a list of numbers and updates eight values. After all pieces are processed, the final hash is made by combining these eight values.
SHA-224 is like SHA-256 but uses different starting values and leaves out one final value. SHA-512 works like SHA-256 but uses bigger pieces and more steps. Other versions like SHA-384 and SHA-512/t have their own changes.
Comparison of SHA functions
Further information: Merkle–Damgård construction
The table below shows how different SHA functions work inside, called the "internal state," after processing each block of data.
In the table, "Rot" means turning bits in a special way, and "Shr" means moving bits to the right. All these methods use adding numbers in a special way, except for SHA-3.
The performance numbers for computers were tested on different processors. SHA-256 works well on older computers but can run faster on newer ones with special code. SHA-512 works much better on newer computers.
These tests were done by the University of Illinois at Chicago using two different computer systems. The speeds shown are for processing a piece of data that is 4,096 bytes long.
| CPU architecture | Frequency | Algorithm | Word size (bits) | Cycles/byte x86 | MiB/s x86 | Cycles/byte x86-64 | MiB/s x86-64 |
|---|---|---|---|---|---|---|---|
| Intel Ivy Bridge | 3.5 GHz | SHA-256 | 32 | 16.80 | 199 | 13.05 | 256 |
| SHA-512 | 64 | 43.66 | 76 | 8.48 | 394 | ||
| AMD Piledriver APU | 3.8 GHz | SHA-256 | 32 | 22.87 | 158 | 18.47 | 196 |
| SHA-512 | 64 | 88.36 | 41 | 12.43 | 292 |
Implementations
Many tools and programs use SHA-2 to help keep information safe. Some of these tools are Botan, Bouncy Castle, Cryptlib, Crypto++, Libgcrypt, Mbed TLS, libsodium, Nettle, LibreSSL, OpenSSL, GnuTLS, and wolfSSL.
Some computers have special features that make SHA-2 work faster. These include Intel SHA extensions on certain Intel and AMD processors, VIA PadLock, ARMv8 Cryptography Extensions, IBM z/Architecture since 2005, and IBM Power ISA since version 2.07.
Related articles
This article is a child-friendly adaptation of the Wikipedia article on SHA-2, available under CC BY-SA 4.0.
Images from Wikimedia Commons. Tap any image to view credits and license.
Safekipedia