# Can SHA512 and SHA3-512 Make Same Collisions?

Does combining those two different cryptographic hash functions in HMAC, when each hashes the same data separately, then saved together, guarantee zero possibily of a collision simultaneously or is the assumption false and the possibility is not equal zero even in theory?

• In theory both of these have collisions. In practice, they do not have any collisions. Jun 11 at 13:45
• Your question is not clear, are you looking for the case that if the hash function used in the HMAC has a collision attack then HMAC is secure? Is the HMAC of a broken hash such as MD2, MD5, SHA1 etc, also broken? Jun 11 at 17:20
• Jun 11 at 18:21
• kelalaka, SHA512 and SHA3-512 do not have a collision attack, specific is not general nor a broken hash MD5/SHA1 function as in the three links.
– user91960
Jun 11 at 22:13
• @Quesha It is not really about existing attacks, rather the generic attacks as in the first link. The second one uses the existing attacks that can be rather easy to convert. Jun 11 at 22:38

There is no way to guarantee a hash function (or combination of hash functions) is free of collisions. This is due to the pigeonhole principle. As long as the input is larger than the output hash, some inputs will need to result in the same hash. There's no way to get around this.

Note that both SHA-512 and SHA3-512 are secure hash functions and there is no known way to generate collisions for them more efficiently than provided by the birthday paradox.

• Will pick this as an answer. Thanks.
– user91960
Jun 12 at 3:09

is the assumption false and the possibility is not equal zero even in theory?

It is known to be false; it is easy to show that there must exist two different images that both hash to a common value $$X$$ for SHA-512 and and both hash to a common value $$Y$$ for SHA-3-512, for some 512 bit values $$X, Y$$. In fact, we can show that there exists such a pair both with lengths no more than 1024 bits (128 bytes).

Now, finding such a pair, that's a bit trickier...

• @jcaron I think it's due to the pigeonhole principle again, but it probably does not apply to all hash functions and it might not be possible to rigorously prove it. Jun 11 at 10:16
• @JohnEye: yes, it's the pigeonhole principle, and it can be applied to all hash function. It's easy to prove - one way is to look at the concatination of SHA-2-512(M) and SHA-3-512(M) as a single function with a 1024 bit output; if we consider $2^{1024}+1$ distinct inputs, there must be a pair with same 1024 bit output, which implies that the pair collides for both SHA-2-512 and for SHA-3-512 Jun 11 at 12:50
• Ah, I got confused a bit there and thought that you meant to say that a single input must have the same output for both hash functions at the same time, which is obviously not true. Makes sense now, thanks! Jun 11 at 13:10
• @JohnEye: actually, I tried to word things to try to avoid that possible confusion; obviously, that attempt was not successful - I'll reword it to try to be even more clear Jun 11 at 13:29
• I got confused too, now it's clearly not appicable to the case ("simultaniously," not solo) since "Not applying to the same output to both at the same time."
– user91960
Jun 11 at 22:02