Live data from Hacker News

Show HN: SHA-256 explained step-by-step visually

sha256algorithm.com

111–120 of 145 posts

Re: Show HN: SHA-256 explained step-by-step visually

#112
post #44

Earlier quoted context omitted.

Visualized like this it feels like security through obscurity, but there must be reason for this. I did wonder why initialization is like: 1. Initialize hash value h0 to h7: first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19). 2. Initialize array of K constants: first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311

from what I've seen, there's a lot of "obscurity" to this; there are many seemingly arbitrary choices all over the place. In the end most encryption algorithms boil down to doing 'random' (arbitrary, hard to justify why) things to data and then undoing them exactly in order to decrypt. the math is all incredibly abstract but not all that complex, the high level of abstraction does make it quite difficult to grasp. Wh…

> What's worse is that I fear there are incentives (mostly political/security interests)

Nah its mostly just a mix of laziness, rigor, and salesfolk.

Most people don't want nor can properly design a hash algorithm (which works well). Public ones like SHA have received so much scrutiny, they are extremely well vetted...and then there's the mostly valid attitude of "never roll your own crypto" - Don't, not in production or anything that could become production. Unless you are a group of highly skilled cross domain career cryptographers/mathematicians...

Which leads to the last bit, people build whole business out of selling "security products" out of publically available crypto, then make the argument you shouldn't do it yourself, buy theirs. Which sometimes makes sense - often it is a shill/marketing ploy. Rarely do these products provide much on top of the core freely available code...and they probably shouldn't, or else there is probably untrustworthy nonsense inside.

So yeah, don't assume malice where first incompetence is possible.

Re: Show HN: SHA-256 explained step-by-step visually

#113
post #71
post #36

So, how do people come up with these things? I assume every aspect of the design is carefully considered to defend it against various attacks. For example, why "right rotate 7 XOR right rotate 18 XOR right shift 3" and not "right rotate 2 XOR right rotate 3 XOR right shift 4"?

It's helpful to understand that the algorithm wasn't designed the way it's presented in this illustration, and consists of somewhat discrete components. It's an iterated design, like a block cipher, meaning that it's built around a simple round function that's repeated a bunch of times on each input, rather than a super-complicated function run once. It belongs to a large, important family of cryptographic hashes cal…

You might find MD4 easier to get your head around.

You can even generate collisions for it by hand calculation:

https://www.iacr.org/archive/fse2007/45930331/45930331.pdf

Re: Show HN: SHA-256 explained step-by-step visually

#114
post #31

Can it be proven whether values of m exist such that SHA256(m) == 0? If I were omnipotent and wanted people to believe in me, I would write a book that hashes to 0, so that anyone could verify its authenticity.

One way to prove it might be to actually find the "null hash"; turn it into a challenge/puzzle, don't mention hashing or crypto or that it's really hard, and let all the bored people of the world play with it. Perhaps someone might notice something that all the highly-trained cryptographers have missed all along: https://news.ycombinator.com/item?id=30245419

Re: Show HN: SHA-256 explained step-by-step visually

#115
post #84

Does anyone have any good references, preferably a book but a good detailed website is fine, on cryptography, hashing, public/private keys, tokens, encryption, etc. as it relates to a software engineer? I don't necessarily want to know all the nitty gritty details of how these things are implemented. Rather, I think I would prefer simply understanding them and how to use them, piece them together, etc. to build somet…

For that I like this one: https://cryptobook.nakov.com/

Thanks!

Re: Show HN: SHA-256 explained step-by-step visually

#116
post #86
post #84

Does anyone have any good references, preferably a book but a good detailed website is fine, on cryptography, hashing, public/private keys, tokens, encryption, etc. as it relates to a software engineer? I don't necessarily want to know all the nitty gritty details of how these things are implemented. Rather, I think I would prefer simply understanding them and how to use them, piece them together, etc. to build somet…

JP Aumasson is one of the authors of the BLAKE hashes and wrote "Serious Cryptography": https://www.amazon.com/Serious-Cryptography-Practical-Introd...

Thanks!

Re: Show HN: SHA-256 explained step-by-step visually

#117
post #84

Does anyone have any good references, preferably a book but a good detailed website is fine, on cryptography, hashing, public/private keys, tokens, encryption, etc. as it relates to a software engineer? I don't necessarily want to know all the nitty gritty details of how these things are implemented. Rather, I think I would prefer simply understanding them and how to use them, piece them together, etc. to build somet…

I wrote this one: https://app.qvault.io/course/6321ddbf-49eb-4748-9737-6bc12e8...

it's a crypto course where you write the solutions in Go. you might enjoy it :)

Re: Show HN: SHA-256 explained step-by-step visually

#118

Earlier quoted context omitted.

Visualized like this it feels like security through obscurity, but there must be reason for this. I did wonder why initialization is like: 1. Initialize hash value h0 to h7: first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19). 2. Initialize array of K constants: first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311

It's not security through obscurity. In fact, it's the very opposite. You can see the process exactly. The reason this is secure is because the process itself doesn't work backwards. You can create a hash using this algorithm, but you'll never reverse that hash back into the original text.

I'm also wondering, how does this prevent preimaging attacks (or whatever they're called)? That is to say, what's stopping people from reliably producing output based on input?

Re: Show HN: SHA-256 explained step-by-step visually

#120

Earlier quoted context omitted.

It's not security through obscurity. In fact, it's the very opposite. You can see the process exactly. The reason this is secure is because the process itself doesn't work backwards. You can create a hash using this algorithm, but you'll never reverse that hash back into the original text.

I'm also wondering, how does this prevent preimaging attacks (or whatever they're called)? That is to say, what's stopping people from reliably producing output based on input?

> I'm also wondering, how does this prevent preimaging attacks (or whatever they're called)?

First, see the Wikipedia entry about preimage attacks.

Second, I am not a cryptographer but I think in practice there is a couple of things to be aware of:

- make sure slightly different inputs have wildly different outputs

- make sure no parts of the input survives

- practically speaking there are an unlimited number of inputs that map to most (all? I'm not sure how uniform the distribution of sha256 is) output (since input is unlimited and output is a short string.

- the classic preimage attack, rainbow tables, works because 1.) inputs, i.e. passwords, are often short and predictable

- in ancient times password systems didn't use salts

> That is to say, what's stopping people from reliably producing output based on input?

I assume this should be the other way around, which is what I have tried to explain above.

Again, read the Wikipedia page.

Post reply on HN