STECH JSC

How secure is 256-bit hashing?

This article explains one-way SHA-256 hashing as simply as it can be explained

WHAT IS SHA-256?

SHA (Secure Hash Algorithm) is a family of five algorithms accepted by FIPS that turn a given block of data into a block of fixed length, with a very high probability that different inputs give different outputs.

The SHA algorithms are cryptographic hash functions developed by the United States National Security Agency (NSA) and published as a US government standard by the National Institute of Standards and Technology (NIST)

The five standard SHA algorithms are SHA-1 (a 160-bit result), SHA-224 (224 bits), SHA-256 (256 bits), SHA-384 (384 bits) and SHA-512 (512 bits).

They are called "secure" because, under FIPS 180-2 published on 1 August 2002:
"1) Given a hash value produced by one of the SHA algorithms, it is computationally infeasible to recover the original data. This is what is meant by a one-way function,
2) It is computationally infeasible to find two different blocks of data that produce the same hash under one of the SHA algorithms.
3) Any change to the original data, however small, will with very high probability produce a completely different hash value."

An example of the SHA-256 hash of a message:


WHERE IT IS USED

Since 2008 STECH has used SHA in SmartQMAN as the authentication code on every packet exchanged — between software modules, and between the on-site software and the central QMS Server. STECH also uses SHA as the licence key for software supplied to customers. Today's secure internet protocols, such as SSL and digital signatures, all use SHA hash functions.

The best-known application of SHA, though, is Bitcoin: a distributed monetary transaction system on the internet that uses SHA-256 to authenticate transactions and to store a chain of historical events in time, linked to one another by those authentication codes (the blockchain).


HOW SAFE IS 256 BITS

The common use of a one-way SHA hash is to create a signature for a message by hashing the message together with a secret key, the secret key generally being very long:

signature = SHA256("the message to authenticate", "secret key") = hash

Because the hash is one-way, the signature can be public and the message can be public, but the secret key cannot be recovered: deriving the whole original input from the signature is impossible.

The only way to recover the original input is to try every possible secret key and every way the key might be combined with the message — which amounts to testing every possible input to find one whose signature matches the known signature. That method is brute force. Without loss of generality, take "secret key" = SHA256("secret-key") = 256 bits

Because any change to the input, however small, produces a completely different and unpredictable hash with very high probability, this search covers the entire space of hash values — a brute force over 2256 possibilities.

So how hard is a brute force over 2256?

2256 = 115792 089237316 195423570 985008687 907853269 984665640 564039457 584007913 129639936 > 1078

Assume a personal computer at 4 GHz can compute 1.4 billion hashes per second, 1.4x109 hash/s, and that all 7 billion people on Earth each have one such computer. The computing power of the whole Earth is then 1019 hash/s

The Milky Way holds roughly 100 billion stars. Assume 1% of them host a civilisation like Earth's: the hashing power of the galaxy is then 1019 hash/s x 1% x 100x109 = 1028 hash/s

The observable universe is thought to hold 100 billion galaxies, and the universe as a whole to be ten times larger again, so the hashing power of the entire universe is 1028 hash/s x 100x109 x 10 = 1042 hash/s

At that rate, to test all 1078 cases the entire universe would need 1036 seconds ≈ 3.17x1028 years, or ≈ 2.4x1018 times the age of the universe itself. It is not feasible.

That is why SHA-256 is considered very safe.

- source: dev@stech.vn -