tags:

views:

1095

answers:

4
+1  Q: 

Hash and salt

I remember a guy telling me that if i let him change 4 bytes he can make a file have any checksum he wants (crc32).

I heard mention of salting a hash. I am wondering if someone had his file match my file would salting the md5 or sha1 hash change the result so both files no longer collide? or does it change the end hash value only?

+1  A: 

Adding salt to your hash function doesn't really serve any purpose if the digest function has been compromised, because the salt will have to be made public to be used, and the attacker can adjust their file to factor this in too.

The solution to this problem is to use a secure hash function. MD5 has shown to be vulnerable to hash collision, but I believe SHA-1 has not (so far).

David Grant
A: 

Salting is usually used in password hashes to avoid dictionary attacks. There are plenty of web based reverse hash dictionaries where you enter the hash (say: 1a79a4d60de6718e8e5b326e338ae533) and get back the text: "example". With salt, this becomes next to impossible. If you prepend a password with random salt, the dictionary attack become more difficult.

As for collisions, I don't think you need to worry about entire files having the same md5 or sha1 hash. it's not important. The important use of the hash is to prove the file you receive is the same as the file that was approved by someone who is an authority on the file. If you add salt to the file, you need to send the salt so the user can verify the hash.

This actually makes it easier for the attacker to spoof your file because he can provide a false salt along with the false file. The user can usually tell if the file is faked because it no longer serves the purpose it is supposed to. But how is the user supposed to know the difference between the correct salt and the attacker's salt?

jmucchiello
You're confusing dictionary attacks with rainbow tables. Salting will not protect you against dictionary attacks as they are performed on the password level (i.e. trying passwords from a list) as opposed to the hashed level.
Andreas Magnusson
+4  A: 

You are mixing up two different uses of hash values:

  • Checksumming for guarding against random (non-malicious) errors.

  • Computing cryptographical message digests for storing passwords, signing messages, certificates ...

CRCs are a good choice for the first application, but totally unsuited for the second, because it is easy to compute a collision (in math-speak: CRCs are linear). This is what your friend is essentially telling you.

MD5 and SHA1 are cryptographic hashes intended for the second kind of application. However, MD5 has been cracked and SHA1 is considered weak these days. Still, even though MD5 can be cracked it takes a long time to find MD5 collisions (days to weeks).

As for salt, it makes the computation of the cryptographic hash local by mixing in some random non-secret value, this value is called the salt. This prevents computing global tables which make it easy to compute possible values (e.g. passwords) from the hash value. The computation of the tables is extremely expensive, but without salt the cost would be amortized over many cracked passwords.

starblue
what are 'global tables' which make it easy to compute?
acidzombie24
Search for rainbow table.
starblue
+2  A: 

The attack (against crc32) is irrelevant if the hash you are using is not crc32 - md5 and sha1 are not vulnerable to that kind of attack (yet).

The current attacks against md5 are where an attacker creates two documents with the same hash.

Salts are used for password verification - they prevent an attacker performing an offline attack against the password database - each user's password is has a salt attached to the plain-text before the hashing - then a pre-computed rainbow table of plaintext <-> hashed text is useless.

Douglas Leeder