home
Click to return to DHKE

DHKE: Man in the Middle Attack

Maths Example

Alice

Bob

Click play to see Diffie-Hellman Key Exchange with a man in the middle attack using a mathmatical example

Eve

eve

G=15 and P=1011

G=15 and P=1011

a = 5

A=15^5 mod 1011

A=114

b = 9

K= 375^5 mod 1011

K = 402

B=15^9 mod 1011

B=462

K= 375^9 mod 1011

K= 528

e = 7

E = 15^7 mod 1011

E = 375

K = 114^7 mod 1011

K = 402

e = 7

E = 15^7 mod 1011

E = 375

K = 462^7 mod 1011

K = 528

Alice and Bob picks a large prime P and a number G, which is a primitive root modulo p.

Alice and Bob randomly generates a private key a/b

Alice and Bob will then calculate their public key using P,G and their private key

Oh No! An attcker called eve has intercepted this exchange, Eve is going to pretend to be Bob

Eve is going to gerate her own Private and private keys just like Alice and Bob

Alice still thinks shes talking to Bob. However she will share her public key, A, to Eve without her knowing and eve will share her public key, E, with Alice

Alice will calculate Key K with Eve's public key, E, thinking its Bob's. And Eve will calculate the key K with eves public key, A.

Eve has sucessfully impersonated Bob without Alice's knowlege. In parellel to this Eve has been doing the same to Bob, pretending to be Alice.

Eve will now repeate the same process with Bob without Bob's knowledge that hes no longer talking with Alice.

Eve is now free to steal any information flowing through this falsely secured channel.

alicepub bobpub bobpub shared key shared key2 eve key eve key

Colour Mixing Example

Alice

Bob

Eve

eve

Agree on a colour (p,g)

Both users will pick their own private colour that is different from the other persons. (This is the users Private key)

The users will then mix their private colour with the agreed colour (This is the users Public key)

Alice has sarted sending her key to Bob but Oh No! An attcker called Eve has intercepted this exchange, Eve is going to pretend to be Bob and Alice

Eve Will now genrate her own public colour which she will share with Alice and Bob. Alice will share her public colour with eve thinking its Bob.

Eve and Alice will Mix their private colour with the shared colour. The final colour will be the same meaning a 'secure' channel will be made.

Alice still believes she has created the secure channel with Bob and Eve now is free to steal any information flowing through this falsely secured channel. Simaltaniously Eve has also been doing this with Bob.

Bob belives he's sending his public colour to Alice however Eve has intercepted the sent colour and will pretend to be Alice.

Bob will mix his private colour with Eves public colour thinking its Alices. The two colours again match resulting in a secure channel being succesfully made.

Eve has sucessfully performed a man in the middle attack and has secure channels with Alice and Bob. She is now free to steal any information flowing through this falsely secured channel.

Click play to see Diffie-Hellman Key Exchange with a man in the middle attack using a colour mixing example