Diffie-Hellman Key Exchange
security- 1976
- One of first public key protocols in Cryptography
- specifics at ibm.com
Its main use is the exchange of symmetric keys over a non-secure channel. It functions using module arithmetics.
prime primitive root of
Let
be a positive integer. A primitive root is an integer such that every integer relatively prime to is congruent to a power of . That is, the integer is a primitive root ( ) if for every number relatively prime to there is an integer such that
Algorithm
To realize DH
we need:
- efficient algorithm for
- efficient algorithm for generating a prime
- efficient algorithm for generating a primitive root for this
int expmod_r (int a, int b, int q) {
if (b == 0) return 1;
if (b%2 == 0)
return ((expmod(a,b/2,q))^2) % q;
else
return (a*expmod(a,b-1,q)) % q;
}
int expmod_i (int a, int[] b, int q) { // here b is encoded in binary
int c = 0, d = 1;
for (i = b.length-1; i >= 0; i--) {
c = c*2; // c is used to prove correctness
d = (d*d)%q;
if (b[i] == 1) {
c++;
d = (d*a)%q;
}
}
return d;
}
Security
By the rules of modular arithmetics:
This way the two sides exchanged the secret value using the private keys
But for langer primes discrete logarithms are considered infeasible.