Table 1: Steps in Negotiating Diffie-Hellman Key Agreement Diffie- Hellman Example A and B agree on two numbers, a generator g of Z(p)* and a prime p. Alice and I agree g = 7, while p = 23. A chooses a secret random integer x. Alice chooses x = 5. B chooses a secret random integer y. I choose y = 8. A computes X = g ^ x mod p. Alice computes X = 7 ^ 5 mod 23 = 17. B computes Y = g ^ y mod p. I compute Y = 7 ^ 8 mod 23 = 12. A sends X to B, and B sends Y to A. Alice sends 17 to me; I send 12 to Alice. A computes K = Y ^ x mod p Alice computes K = 12 ^ 5 mod 23 = 18. B computes K = X ^ y mod p I compute K = 17 ^ 8 mod 23 = 18. K is the encryption key for this communication session. K = 18 is the encryption key for this communication session. Table 2: RSA Public Key System RSA Public Key System Example Choose p and q, where both p and q are prime. Choose 11 and 13, which are prime numbers. Find their product n = pq. Calculate n = 11*13 = 143. Calculate Euler's totient function t = (p1)(q-1). Calculate t = (11-1)*(13-1) = 120. Select an integer e, where e<t, and the greatest common divisor of e and t is 1. Let e = 7. This will work because 7<120, and their greatest common divisor is 1. Calculate d such that e*d = 1 mod t. We want 7*d = 1 mod 120. Thus d = 103, as 7*103 = 721 = 1 mod 120. The public key is (e, n). The public key is (7, 143). The private key is (d, n). The private key is (103, 143). Plaintext can be any number M, where M Let the numerical representation of M be M = < n, and neither p nor q divides M 5, for example. The ciphertext is C = M^e mod n. The ciphertext is C = 5^7 mod 143 = 47. The plaintext is C^d mod n = (M^e)^d mod n = M. The plaintext is 47^103 mod 143 = 5. To see this last step, note the following, mod 143: 47^103 = (5^7)^103 = 5^721 = 5*[5^720] =5*[(5^120)^6] = 5*[ 1^6] = 5. Here we have used the result that 5^120 = 5^t = 1 mod 143 by Euler's theorem. Or, more simply, x^(e*d) = x; hence, 5^721 = 5.