3
$\begingroup$

I create a hash with SHA3-384. I split the resulting array into two. The first called head has the first 320 bits and the second called tail has the last 64 bits.

Next, I XOR head and tail. Which in fact means I XOR the last 64 bits of head with tail. This gives me a new hash of length 320.

The question is how is this resulting hash in terms of collision resistance compared to SHA-256 on one side and SHA-384 on the other side.

My goal is to produce a 320-bits hash. Is there a better way you would go about this?

$\endgroup$

1 Answer 1

3
$\begingroup$

Truncating a hash does reduce the collision resistance. Mixing in an independent string does not.

$$ \text{random thing} \oplus \text{independent thing} \to \text{random thing}\\ \text{random thing} \oplus \text{independent random thing} \to \text{random thing} $$

Truncating hashes is common and the reduction is relative to the bits lost. The truncated $\text{sha3}_{384[320]}$ should be stronger than $\text{sha2}_{256}$ and is weaker than $\text{sha3}_{384}$.

I recommend that you do not try to mix in the truncated $64$-bits.

$\endgroup$
1
  • $\begingroup$ Thanks. I ended up extending KeccakDisgest class from Bouncycastle to overwrite the init() method so i can pass my length directly. It works like a charm. $\endgroup$
    – Klaus
    Commented Mar 11, 2018 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.