2082 2

CSC327 · 2082 · 10 marks

Illustrate the man in middle attack in Diffie-Hellman key exchange protocol. Assume the prime number be 19 and 10 as its primitive root. Select 5 as private key and 4 as random integer. Find the cipher text of M = 2 using Elgamal crypto system.

Illustrate the man in middle attack in Diffie-Hellman key exchange protocol. Assume the prime number be 19 and 10 as its primitive root. Select 5 as private key and 4 as random integer. Find the cipher text of M = 2 using Elgamal crypto system.[10]

CryptographyChapter 3: Asymmetric CiphersMan-in-the-Middle AttackNumerical: Diffie-Hellman, Elgamal cryptosystem

Man-in-the-Middle Attack on Diffie-Hellman & ElGamal Cryptosystem

Given Data

  • Prime number: $p = 19$
  • Primitive root: $g = 10$
  • Private key: $x = 5$
  • Random integer: $k = 4$
  • Message: $M = 2$

Part 1: Man-in-the-Middle Attack on Diffie-Hellman

Normal Diffie-Hellman

Public parameters: $p = 19$, $g = 10$.

  1. Alice picks private $X_A$, sends $Y_A = g^{X_A} \bmod p$.
  2. Bob picks private $X_B$, sends $Y_B = g^{X_B} \bmod p$.
  3. Shared key: $K = Y_B^{X_A} \bmod p = Y_A^{X_B} \bmod p$.

The Attack

An attacker Darth (D) sits between Alice and Bob. Since plain Diffie-Hellman has no authentication, Darth impersonates each side to the other.

Darth chooses two private keys $X_{D1}, X_{D2}$ and computes: $$Y_{D1} = g^{X_{D1}} \bmod p, \qquad Y_{D2} = g^{X_{D2}} \bmod p$$

Alice (A)                Darth (D)                Bob (B)
   |--- Y_A ------------->|                          |
   |                      |--- Y_D1 ---------------->|
   |                      |<-- Y_B ------------------|
   |<-- Y_D2 -------------|                          |

Steps:

  1. Alice sends $Y_A$; Darth intercepts it.
  2. Darth sends $Y_{D1}$ to Bob.
  3. Bob sends $Y_B$; Darth intercepts it.
  4. Darth sends $Y_{D2}$ to Alice.

Resulting keys:

PartyKey computed
Alice$K_1 = Y_{D2}^{X_A} \bmod p$
Darth (with Alice)$K_1 = Y_A^{X_{D2}} \bmod p$
Darth (with Bob)$K_2 = Y_B^{X_{D1}} \bmod p$
Bob$K_2 = Y_{D1}^{X_B} \bmod p$

Consequence: Alice shares $K_1$ with Darth (thinking it is Bob), Bob shares $K_2$ with Darth (thinking it is Alice). Darth decrypts, reads, possibly alters, and re-encrypts every message. The attack succeeds because DH does not authenticate the parties.


Part 2: ElGamal Cryptosystem

Step 1: Key Generation

Public key: $$y = g^x \bmod p = 10^5 \bmod 19$$

  • $10^2 = 100 \equiv 5 \pmod{19}$
  • $10^4 \equiv 5^2 = 25 \equiv 6 \pmod{19}$
  • $10^5 \equiv 6 \cdot 10 = 60 \equiv 60 - 57 = 3 \pmod{19}$

$$\boxed{y = 3}$$

Public key = $(p=19,\ g=10,\ y=3)$; Private key = $5$.

Step 2: Encryption of $M = 2$ with $k = 4$

Compute $C_1$: $$C_1 = g^k \bmod p = 10^4 \bmod 19 = 6$$

Compute $C_2$: $$y^k \bmod p = 3^4 \bmod 19 = 81 \bmod 19 = 5$$ $$C_2 = (y^k \cdot M)\bmod p = (5 \cdot 2)\bmod 19 = 10$$

Final Answer

$$\textbf{Ciphertext } (C_1, C_2) = (6,\ 10)$$

Verification (Decryption)

$$M = C_2 \cdot (C_1^{x})^{-1} \bmod p$$

  • $6^5 \bmod 19$: $6^2 = 36 \equiv 17$; $6^4 \equiv 17^2 = 289 \equiv 4$; $6^5 \equiv 4 \cdot 6 = 24 \equiv 5$.
  • $5^{-1} \bmod 19 = 4$ (since $5 \cdot 4 = 20 \equiv 1$).
  • $M = 10 \cdot 4 \bmod 19 = 40 \bmod 19 = 2 \checkmark$

Recovered $M = 2$, matching the original message.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.