BIT303 ยท 2082 ยท 10 marks
What are the purposes of message authentication? Explain the working mechanism of MD5.
What are the purposes of message authentication? Explain the working mechanism of MD5.[10]
Quick answer
Message authentication is a mechanism used to verify the integrity and origin of a message.
Message Authentication: Purposes and MD5 Working Mechanism
Part 1: Purposes of Message Authentication
Message authentication is a mechanism used to verify the integrity and origin of a message. The main purposes are:
1. Message Integrity
Ensures that the message has not been altered (accidentally or intentionally) during transmission. The receiver can verify that the received message is exactly what was sent.
2. Message Authentication (Source Verification)
Confirms that the message actually came from the claimed sender and not from an imposter or attacker.
3. Non-repudiation
Prevents the sender from later denying that they sent the message. This is important in legal and financial transactions.
4. Protection Against Masquerade
Prevents an unauthorized party from pretending to be a legitimate sender and injecting false messages.
5. Protection Against Replay Attack
Ensures that a previously sent valid message cannot be captured and retransmitted by an attacker to produce an unauthorized effect.
6. Protection Against Modification
Detects any unauthorized changes to the content, sequence, or timing of a message.
7. Sequence Control
Ensures messages are received in the correct order and none are missing or duplicated.
Part 2: MD5 (Message Digest 5) - Working Mechanism
MD5 was designed by Ronald Rivest in 1991. It produces a 128-bit (16-byte) message digest from an input message of arbitrary length.
Overview
Input Message (any length)
|
v
[Padding + Length]
|
v
[512-bit Blocks]
|
v
[4 Rounds of Processing per Block]
|
v
128-bit Message Digest
Step-by-Step Working of MD5
Step 1: Append Padding Bits
- The original message is padded so that its length becomes congruent to 448 mod 512.
- Padding is always added, even if the message is already the right length.
- Padding consists of a single '1' bit followed by as many '0' bits as needed.
Padded Length โก 448 (mod 512)
Step 2: Append Length
- A 64-bit representation of the original message length (before padding) is appended.
- This makes the total message length a multiple of 512 bits.
Total Length = Multiple of 512 bits
Step 3: Initialize MD Buffer (Initial Hash Values)
MD5 uses a 128-bit buffer divided into four 32-bit registers:
| Register | Initial Value (hex) |
|---|---|
| A | 67452301 |
| B | EFCDAB89 |
| C | 98BADCFE |
| D | 10325476 |
These are fixed constants (little-endian format).
Step 4: Process Message in 512-bit Blocks
Each 512-bit block is divided into sixteen 32-bit sub-blocks (M[0] to M[15]).
Each block goes through 4 rounds, and each round has 16 operations (total = 64 operations per block).
Four Auxiliary (Non-linear) Functions:
| Round | Function | Formula |
|---|---|---|
| 1 | F(B,C,D) | (B AND C) OR (NOT B AND D) |
| 2 | G(B,C,D) | (B AND D) OR (C AND NOT D) |
| 3 | H(B,C,D) | B XOR C XOR D |
| 4 | I(B,C,D) | C XOR (B OR NOT D) |
Each Operation:
Each of the 64 operations follows this general form:
a = b + ((a + F(b,c,d) + M[k] + T[i]) <<< s)
Where:
a, b, c, dare the four registers (rotated each step)Fis the round function (F, G, H, or I)M[k]is a 32-bit sub-block of the messageT[i]is a constant derived from|sin(i)| ร 2^32(precomputed table of 64 constants)<<<denotes left circular shift bysbitssis a per-step shift amount
Step 5: Update Buffer
After processing each 512-bit block, the output of the four rounds is added to the previous buffer values:
A = A + AA
B = B + BB
C = C + CC
D = D + DD
Where AA, BB, CC, DD are the saved values of A, B, C, D before processing the block.
Step 6: Output
After all blocks are processed, the 128-bit message digest is the concatenation of registers:
MD5 Digest = A || B || C || D (128 bits)
Summary Diagram of MD5
Message
|
+---> Padding (to 448 mod 512) + 64-bit length
|
+---> Divide into 512-bit blocks
|
For each block:
|
+----+----+----+----+
| A | B | C | D | <-- 128-bit buffer
+----+----+----+----+
|
Round 1 (16 ops using F)
Round 2 (16 ops using G)
Round 3 (16 ops using H)
Round 4 (16 ops using I)
|
Add to previous A,B,C,D
|
Final Output: 128-bit Digest
Key Properties of MD5
| Property | Value |
|---|---|
| Output size | 128 bits |
| Block size | 512 bits |
| Number of rounds |
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.