Video Over IP: A Practical Guide to Technology and Applications

In 1976, Whitfield Diffie and Martin Hellman published a paper [1] that first described one of the key underlying technologies for exchanging cryptographic keys between two parties that wish to communicate. This process, which has come to be known as the Diffie-Hellman Key Exchange, is now in common use in throughout the Internet, particularly since the key US patents covering this technology expired in 1997. Since this is such an important technology, let's look at how it works.
Let's say two users, whom we'll call Bonnie and Clyde, are trying to exchange a secret message. Before they begin, they need to agree on two numbers: a prime number (p), and a second, smaller number called a generator (g). [2] For this example, let's say that they choose p = 19 and g = 2.
The first thing Bonnie does is choose her private key (a). Let's say she picks the number 7. Bonnie keeps this number secret but calculates her public number (x) by doing the calculation: x = g a modulo p, or x= 2 7 modulo 19. This gives her a public number x = 14, which she sends to Clyde. [3]
Meanwhile, Clyde picks his own private key (b). Let's say he picks the number 8. Clyde keeps this number secret but calculates his public number (y) by doing the following calculation: y = g b modulo p, or y = 2 8 modulo 19. This gives him a public number...