Master of nuggets, chicken bones and all other kinky food!

Security Engineering

Diffie-Hellman Method

1)      Attacks on Diffie-Hellman key exchange model: Probably the easiest explanation that we can use on Diffie-Hellman protocol is saying that “f^a = e^b = g^(ab) (mod p)”. If there are two users would like to use secure transmission in a public environment.

–          User 1 picks a random number “a” (“a” should be smaller than “d”) , calculates “g^a (mod p), sends that to user 2, calculates “e = g^a (mod p), sends that to user 2, receives “f = g^b (mod p)” from user 2, and finally calculates f^a (mod p). The key is “f^a (mod p)

–          User 2 picks a random number “b” (b should be smaller than d), calculates “g^b (mod p) , calculates “f=g^b(mod p) and sends that user 1, receives “e = g^a(mod p) and calculates “e^b (mod p) which is the final key; and it is “f^a = e^b = g^(ab) (mod p)”

It works for two users with no problem. The most mentioned attack on Diffie-Hellman is that the protocol is weak against “man in the middle” type of attacks. If there is a third user, user 1 calculates its public key and sends it to the man in the middle (in our case user 3), user 3 replaces it with its own public key and sends it to user 2. Therefore user 3 becomes a receiver for all messages and can see / amend messages in between other users. (RSA Labs, nd) There are few methods that could be used to secure transmission and stop man in the middle type of attacks. One method is having 2 users (user 1 and user 2) using digital signatures on their messages. This would probably stop the third user amending messages but couldn’t stop them reading it.

Another attack that this protocol may be experiencing is Denial of Services Attacks. Attacker may try to delete messages in between 2 parties, or by overwhelming the parties with unnecessary messages. (Raymond J, Stiglic A, nd) Probably solution against this will be a network based security against attackers. There are other types of attacks are also listed by Raymond J, Stiglic A e.g. Outsider attacks, Insider Attacks and Attacks based on number theory.


‘Raymond JF, Stiglic A’, (nd), ‘Security Issues in the Diffie-Hellman KeyAgreement Protocol’ [Online] Available from viewed 27 June 2012

‘What is Diffie-Hellman?’ (nd), ‘RSA Labs’, [Online] Available from viewed 27 June 2012

2)      A)

x = 5

X = gx mod p = 115 mod 29 = 14

y = 7

Y = gy mod p = 117 mod 29 = 12

keyx = Y x mod p = 125 mod 29 = 12

keyy = X y mod p = 147 mod 29 = 12

In this case symmetric key is 12, R1 = 14 and R2 = 12

B) If values are same…

Lets say that g is 11, p is 29 x and y are 10.


x = 10

X = gx mod p = 1110 mod 29 = 22

y = 10

Y = gy mod p = 1110 mod 29 = 22

keyx = Y x mod p = 2210 mod 29 = 24

keyy = X y mod p = 2210 mod 29 = 24


At the end of the day values being same shouldn’t change anything. Both parties would calculate their values without checking the first value, as well as session key value. It was equal to each other. In the first question I have given an example for f^a = e^b = g^(ab) (mod p). Meanwhile, my little research about if using same key is available in Diffie-Hellman protocol hasn’t returned with any value, which shows that it is possible that both parties could use same random key.

3)      A) Values are provided for p and q will give us values N and r. N is equal to p times q which is 713. And r is equal to (p-1) times (q-1) which is 660. 1 mod r would give us candidates for e and d. These could be 661, 1981, 2641 so on. if these are correct using either 2 keys mod 1 should give us correct result (e*d mod r = 1)

Leave a Reply

Your email address will not be published. Required fields are marked *