I saw a few different definitions of message digest and i'm confused.

Message digests is a cryptography technique which uses hash functions to protect the integrity of the document/data etc.

It uses a hash function to produce a fixed length string which represents the data encoded.

Ok, i understood until here.

Here is where my doubt begins.

Does hash functions produce always the same output for the same data?

If no, how can message digest function checks for changes?

  • SHA-256 for example produces always the same output for same text. – Aria Sep 10 '16 at 22:38

Yes, a cryptographic hash function always yields the same result for the same input.

The way hashes or digests are used is by including or packaging them with the message they are a hash of.

This permits the recipient to hash the message they receive and compare the hash or digest they get with what was sent to them.

Of course, an attacker with control over the communication channel can just substitute their own message and hash.

This is the reason for the HMAC variant of the hash operation, which provides a standard way for sender and recipient to include a secret they share in the hash operation.

An attacker who controls the communication channel but lacks the secret will not be able to fool the recipient with a replacement message and hash, because the HMAC produced digest they calculate from the attackers message with the correct secret will differ from the digest provided by the attacker.

  • The symmetric key for the MAC still has to be sent over a secure channel. In many situations if you already established a secure channel of communications it's easier to just send the hash. – GnP Sep 11 '16 at 10:47
  • Thanks. I has having problems to understand what my teacher and what internet was saying. Both had different interpretations of the same subject and he was wrong (or confused, i dont know), but his explanation about it was completly different. – PlayMa256 Sep 12 '16 at 18:35

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.