Sitemap
Miguel

Miguel

Planing is Guessing | Career is Switching

Message Integrity

2 min readNov 28, 2018

Encryption, Message Integrity and Digital Signatures go hand in hand in our daily communication. Here we talk about message integrity.

If Bob receives a message (either be encrypted or be in plaintext) from Alice, he needs to verify:

  1. The message indeed originated from Alice.
  2. The message was not tempered with on its way to Bob.

Before talking about how to achieve the above goals, we need to introduce cryptographic hash functions.

A hash function takes an input, m, and computes a fixed-size string H(m). A cryptographic hash function also needs to satisfy an additional property:

  • It is computationally infeasible to find any two different messages x and y such that H(x) = H(y).

Common hash algorithms are MD5 [RFC 1321] and SHA-1 [FIPS 1995].

Get Miguel’s stories in your inbox

Join Medium for free to get updates from this writer.

After we having the cryptographic hash function. A naive step to perform message integrity would be:

  1. Alice creates message m and send Bob (m, H(m)).
  2. After Bob receives (m, H(m)), he uses the same hash function to check whether after hashing m, the result is equal to the H(m) he received from Alice.

The approach is flawed because other party can also send message to bob (m’, H(m’)) claiming that this is from Alice, and Bob has no way to tell even the hash result is correct.

In order to prove the message is indeed from Alice, Alice and Bob should have a shared secret s. This shared secret is called authentication key. Using this shared secret, message integrity can be performed as:

  1. Alice creates message m, concatenates s to m, calculates H(m+s), sends Bob (m, H(m+s)). H(m+s) here is called the message authentication code (MAC).
  2. Bob receives (m, H(m+s)), calculates the MAC using his s, check whether it is the same H(m+s) he received from the message.

Note that message integrity does not imply or require encrypting the message between Alice and Bob. However, a remaining issue is, how do we distribute the shared authentication key between Alice and Bob? We will discuss it in another article.

This is a notes from Chapter 8.3, Computer Networking: A Top-Down Approach, 7th Edition

--

--

Miguel
Miguel

Written by Miguel

Planing is Guessing | Career is Switching