0

I have a hashed value X and need to ensure that any of the data sets D1...Dn can be concatenated with a correctional value C1...Cn and passed into a hashing algorithm to result in the value of X. What I need is a way to figure out what Ci should be in order to ensure that hash( Di ++ Ci ) == X. If I use a simple hash like addition or XOR then it'll be pretty easy, but is there any way to figure out Ci for better hashing algorithms?

Thanks for any help.

8
  • I believe you are looking for homomorphic hashing. Doing a search for that term yields results that look very similar to your description. – BobDalgleish Jun 10 '16 at 18:44
  • Thanks @BobDalgleish, homomorphic hashing does seem pretty close to what I need, only it allows me to generate X if I already have Di and Ci, what I need is to figure out Ci given Di and X. – raystubbs Jun 10 '16 at 20:01
  • What is the purpose of the hash? As blm768's answer correctly points out, what you want to do is something most hash algorithms explicitly try to prevent you from doing, because their goal is to make sure an attacker didn't do exactly that. What you are doing sounds a lot more like a CRC check, where you append a small block of data (typically 16 or 32 bits), such that the CRC algorithm always results in 0 if the packet was uncorrupted. – Cort Ammon Jun 10 '16 at 20:37
  • @Cort Ammon The purpose is to have any set of credentials convert to the same hash ( X ) if it has the appropriate key. A server would know what the hash X is, and given the set of credentials from a client it should generate a key ( really just a character string ) such that the hash of a client's credentials + the generated key will result in the hash X. – raystubbs Jun 10 '16 at 21:22
  • Another approach you might try is a very well tested one. Pick a cryptographically secure hash like SHA-1. Generate a shared secret key that both parties know, k. The server can then verify the credentials by generating a random string X and provides it to the client. The client then calculates SHA1(concatenate(X, k)), and returns the result. The server also calculates SHA1(concatenate(X, k)) on its own and compares the result against that which the client offered. Only if the client knew k to begin with could it calculate the correct value. – Cort Ammon Jun 10 '16 at 22:43
1

Since most hash algorithms (at least cryptographic ones like the SHA family) are designed to prevent what you're trying to do, you won't have an easy time of it. Some older hash functions like MD5 do have some vulnerabilities, though.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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