So here is the confusion: in cryptography we use huge values for our hashes >= 160 bits. How can we operate on this values if most computers can address only 64 or 32 bits?
-
There's a misconception. Addressing memory and storing it in a register are two different things. – Artjom B. Apr 25 '15 at 16:01
-
@Artjom yeah, but there are arithmetical overflows right... – YohanRoth Apr 25 '15 at 16:04
-
What arithmetical overflows are you talking about? It's not like the whole internal state of the hasher is loaded all of the time into registers when the hashing runs. Are you having trouble understanding how the CPU manages to compute values larger than its registers? Perhaps you should look into [Arbitrary-precision arithmetic Explanation](http://stackoverflow.com/questions/1218149/arbitrary-precision-arithmetic-explanation) which not necessarily applies to hashing algorithms – Artjom B. Apr 25 '15 at 16:13
-
See also: [What happens when a computer program runs?](http://stackoverflow.com/questions/5162580/what-happens-when-a-computer-program-runs) – Artjom B. Apr 25 '15 at 16:21
1 Answers
Your post is 174 bytes large, i.e., 1392 bits. Computers did all sorts of things with it so I can now read your writing from the comfort of my chair. That isn't puzzling, is it?
You mention arithmetic overflow. That leads me to the assumption you think the arithmetic circuits in our CPUs are somehow special. They aren't. Give me loops, memory, and basic logic operations (and, or, not) and I can implement all sorts of arithmetic on numbers as large as memory can hold. It may not be as efficient as optimized hardware, but it works. (And for numbers only a few times larger than what the hardware can work on, it will only be a few times slower.)
Furthermore, most operations used in hashes and block ciphers are of a bitwise nature (bit shifts, rotations, XOR, etc.) and don't even need any of the above. In fact, if you look at SHA-1 code you'll find that it only performs operations on individual 32 bit chunks of the state.