 
 
Search Irongeek.com:
Help Irongeek.com pay for bandwidth and research equipment: 
Dirty DiffieHellman Crappy PHP script for a simple DiffieHellman key exchange calculator. I guess I could have used Javascript instead of PHP, but I had rounding errors. a = 5 A = g^{a} mod p = 10^{5} mod 541 = 456 b = 7 B = g^{b} mod p = 10^{7} mod 541 = 156 Alice and Bob exchange A and B in view of Carl key_{a} = B ^{a} mod p = 156^{5} mod 541 = 193 key_{b} = A ^{B} mod p = 456^{7} mod 541 = 193 Hi all, the point of this game is to meet new people, and to learn about the DiffieHellman key exchange. Did you ever wonder how two parties can negotiate a cryptographic key in the presence of an observer, without the observer figuring out the key? My guess is not, but bear with me. This will be a simplified version of the DiffieHellman key exchange (in real life, better constants and larger variables should be chosen) , in the form of a game. Enter as many times as you like. Fixed numbers: g=10, p=541 Contestant steps: 1. Find someone you do not know, and introduce yourself. 2. One of you is Alice (a), and one is Bob (b). If genders don't match that's ok, one of you can be Alan and the other Barb for all I care. 3. Both of you choose a number between 1 and 100, but don't tell the other person this number. 4. Alice, compute A = g^{a} mod p = 10^{a} mod 541. Bob, compute B = g^{b} mod p = 10^{b} mod 541. Feel free to rip out your calculator or smart phone, or just use this calculator: http://www.irongeek.com/diffiehellman.php 5. Alice and Bob, exchange A and B verbally in the presences of Carl (Or as Chux0r points out, perhaps Christmas "Eve"). 6. Alice, compute SecretKeyA = B^{a} mod p = B^{a} mod 541. Notice the superscript is the lower case variable you chose. Bob, compute SecretKeyB = A^{b} mod p = A^{b} mod 541. Notice the superscript is the lower case variable you chose. 7. If you did it right, SecretKeyA should be the same as SecretKeyB. Write your names, the A and B values, and the shared SecretKey outcome on a piece of paper and turn it in for the drawing. Drawing: The officiator will draw a piece of paper and announce the two people, the values of their A and B, and then wait 20 sec. If someone else can announce Alice and Bob's shared SecretKey in the 20 secs, they win instead.
15 most recent posts on Irongeek.com:

If you would like to republish one of the articles from this site on your
webpage or print journal please contact IronGeek.
Copyright 2016, IronGeek
Louisville / Kentuckiana Information Security Enthusiast