Diffie-Hellman Key Agreement Protocol (DH-KAP)

Tax included

Diffie-Hellman (DH) Key Agreement Protocol (KAP) between two parties: Alice and Bob.



This protocol is executed between Student Alice (You) and Mentor Bob. Parameter values sent by Alice are included in brackets [ ] and must be entered in the corresponding input fields.


The following functions are used in the protocol:

>> genstrongprime(bl)                          

>> mod_exp(g,x,p)                                

>> randi(z)                                             


1.      Generate strong prime number p is of 28 bits length using Octave function

>> genstrongprime(28)

You could wait for a moment. You must check that generated p is greater than 227=134217728. Send [p] to the Bob.


2.      If it is OK, find a generator g of multiplicative group Zp={1,2,3, … p-1} and send system parameters [p, g] to the Bob.


3.      If it is OK, generate at random secret number x in the interval 1<x<p-1, compute public parameter KA=gx mod p and send [KA] to the Bob.


4.      If it is OK, Bob sends to You KB=….. which is expressed by the formula KB=gy mod p. Compute the common secret key KAB and encrypt current date and time in the format DT=MMDDhhmm using Vernam cipher with agreed secret key KAB obtaining ciphertext CDT. Send encrypted message [CD] to the Bob.


5.      If it is OK, Bob current finds date and time DT=MMDDhhmm by decrypting CDT and takes his current capital value V in Euros. He computes integer DTV=MMDDhhmm+V and encrypts it obtaining ciphertext CDTV using Vernam cipher with the same agreed secret key KBA=KAB. Bob sends to You ciphertext value CDTV=….. . Is his behavior correct?

In order to learn Bob do not do such mistakes, when capital value V can be approximately computed by the adversary, You must decrypt ciphertext CDTV, extract capital value V and send it to Bob as a plaintext. Send to Bob [V] to confirm Your knowledge of Vernam cipher security. 

3289 Items