Question

In cryptography i have heard integrity can be implemented using hashing the message to check whether the message was modified. But how that hash sent to the other party? One can change the message and the hash value also so other party will see that the message was not modified !!

Was it helpful?

Solution

You always need some shared data that was not tampered with in order to obtain integrity or confidentiality. This shared data is usually a shared secret key or the sender's public key.

With a shared secret key you'd use an HMAC, that is hmac(message, key).

If the receiver has the senders public key then the sender can use their private key to sign the message (many possible methods, DSA, RSA, etc) and the receiver can use the public key to determine if the message originated from the sender.

OTHER TIPS

A hash alone doesn't prove the message hasn't been tampered with, you are supposed to also sign the hash using your private key, and then the recipient can verify it using your public key. Or you can sign it using HMAC if you both have a shared secret. This cannot be forged because nobody else has your private/secret key.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top