Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I am creating a service that will return an set of objects, which will be used by multiple systems. At the end of the process, one (or more) of the objects will be sent back to our system for association.

My service basically checks our system and gets valid solutions. I want to create a hash to validate that the object returned to us has not had certain values altered from the solution object we gave out, and to make certain that the solution being presented originated from our original service.

The source value that will be hashed will already be at least 80 bytes long. Is there any real value in adding a salt to that value prior to hashing?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

The answer to that depends on the details of your system, and specifically whether someone other than you can modify the hash.

If you store the hash in your database, and retrieve the expected hash value from your own database to compare it with the actual hash (when checking to make sure that those certain values have not been altered), there's no point in using the salt. The only thing someone could try to do to fool you is to find a modification to the object in such a way that leaves the hash result the same; if you use a collision-resistant hash function, he won't be able to do that.

On the other hand, if you return the hash along with the set of objects, and at the end of processing, the hash will be sent back to your system along with the objects, well, one thing someone might do is modify the objects, and then modify the hash to reflect that change; because the hash function can be evaluated publicly, they can do that.

In this second case, introducing an unknown salt value certainly is one way to attempt to prevent this attack, but it's probably not the best. What you really need in this case is a Messsage Authentication Code (MAC) instead of a hash; I would recommend using HMAC based on the hash function you're already using; it's only a constant amount slower than the hash function, and was designed specifically to be strong in this attack model.

share|improve this answer
    
Thank you I think The HMAC is exactly what I want :) –  Chad Dec 1 '11 at 22:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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