NDC & PKI

[Day 4] 2. Diffie-Hellman Key Exchange

D
DITISS Admin
••2 min read

Algorithm to Generate Symmetric Key at Both Ends

The Diffie-Hellman Key Exchange algorithm is commonly used to establish a shared symmetric key between two parties over an insecure channel. Here's how it works:


Setup

Imagine Tinku and Pinki want to securely exchange a symmetric key.

  • Both agree on two public values:
    1. Prime Number
      p
      : 23
    2. Base
      g
      : 5

Step 1: Secret Integers

  • Tinku selects a private secret integer
    a
    : 6
  • Pinki selects a private secret integer
    b
    : 15

Step 2: Compute Public Values

  • Tinku calculates:

    A = g ^ a mod  p
    A = 5 ^ 6 mod  23 = 8

  • Pinki calculates:

    B = g ^ b mod  p
    B = 5 ^ 15 mod  23 = 19

Step 3: Exchange Public Values

  • Tinku sends A (8) to Pinki.
  • Pinki sends B (19) to Tinku.

Step 4: Compute Shared Secret Key

  • Tinku calculates the shared key

    s
    :
    s = B ^ a mod  p
    s = 19 ^ 6 mod  23 = 2

  • Pinki calculates the shared key

    s
    :
    s = A ^ b mod  p

    s = 8 ^ 15 mod  23 = 2

Result

  • Both Tinku and Pinki have independently computed the same shared symmetric key:
    2
    .
  • This symmetric key can now be used for secure communication.

Key Points

  1. Confidentiality: The secret integers (
    a
    and
    b
    ) are never transmitted, ensuring that the shared key is secure.
  2. Shared Key: The same symmetric key (
    2
    in this example) is derived independently by both parties.
  3. Scalability: This method allows secure key exchanges without requiring prior secure communication.

Read Next

8/26/2026

[Day 4] 3. Network Configuration Scenario

You have three machines with different network adapter configurations: 1. **Machine 1** is connected to **VMNET4**. 2. **Machine 2** has two netwo...

8/26/2026

[Day 4] 4. Remote Machine Monitoring (Nagios)

#### **NCPA Plugin** To monitor a remote machine (Windows), we'll use the Nagios plugin **NCPA** (Nagios Cross Platform Agent) in a Windows VM, whi...