Diffie-Hellman Key Exchange PDF
Diffie-Hellman Key Exchange PDF
1 Description
1
2 1 DESCRIPTION
1.1 Cryptographic explanation be known by all attackers.) We will write the group
G multiplicatively.
The simplest and the original implementation of the pro-
tocol uses the multiplicative group of integers modulo p, 2. Alice picks a random natural number a and sends ga
where p is prime, and a primitive root modulo p. Here to Bob.
is an example of the protocol, with non-secret values in 3. Bob picks a random natural number b and sends gb
blue, and secret values in red. to Alice.
1. Alice and Bob agree to use a prime number p = 23 4. Alice computes (gb )a .
and base g = 5 (which is a primitive root modulo 23). 5. Bob computes (ga )b .
2. Alice chooses a secret integer a = 6, then sends Bob
A = ga mod p Both Alice and Bob are now in possession of the group
element gab , which can serve as the shared secret key. The
• A = 56 mod 23 = 8 values of (gb )a and (ga )b are the same because groups are
3. Bob chooses a secret integer b = 15, then sends Alice power associative. (See also exponentiation.)
B = gb mod p If m is a message, and an element of the group, then we
can encrypt e = mgab . Then, to decrypt e we must first
• B = 515 mod 23 = 19 compute (gab )−1 , as follows:
4. Alice computes s = Ba mod p Bob knows |G|, b, and ga . A corollary of Lagrange’s the-
orem states that h|G| = 1, the group identity, for all h ε
• s = 196 mod 23 = 2
G.
5. Bob computes s = Ab mod p Bob then calculates (ga )|G|−b = ga(|G|−b) = ga|G|−ab = ga|G| g−ab
• s = 815 mod 23 = 2 = (g|G| )a g−ab = 1a g−ab = g−ab = (gab )−1 .
When Alice sends Bob the encrypted message, e =mgab ,
6. Alice and Bob now share a secret (the number 2). Bob computes (gab )−1 e = mgab (gab )−1 = m(1) = m.
Both Alice and Bob have arrived at the same value, be- When the group is too large for a multiplication ta-
cause (ga )b (for Bob, 815 mod 23 = (ga mod p)b mod p = ble, then a multiplication algorithm is needed, and
(ga )b mod p) and (gb )a are equal mod p. Note that only Exponentiation for finite cyclic groups should be used.
a, b, and (gab mod p = gba mod p) are kept secret. All the How could the key be extracted, in general, from the
other values – p, g, ga mod p, and gb mod p – are sent in shared group element gab ? One could extract a set of AES
the clear. Once Alice and Bob compute the shared secret keys from it. This would require a mapping from G to the
they can use it as an encryption key, known only to them, set of n-bit binary strings, and the mapping would depend
for sending messages across the same open communica- on G. For example, if G consisted of the powers of a fixed
tions channel. nonsingular matrix A defined over a finite field, and if gab
Of course, much larger values of a, b, and p would be = {gᵢ, }, then the element g11 would be an element of the
needed to make this example secure, since there are only field and would have a binary representation that could be
23 possible results of n mod 23. However, if p is a prime divided up into AES keys.
of at least 300 digits, and a and b are at least 100 digits
long, then even the fastest modern computers cannot find 1.3 Secrecy chart
a given only g, p, gb mod p and ga mod p. The problem
such a computer needs to solve is called the discrete loga- The chart below depicts who knows what, again with non-
rithm problem. The computation of ga mod p is known as secret values in blue, and secret values in red. Here Eve is
modular exponentiation and can be done efficiently even an eavesdropper—she watches what is sent between Al-
for large numbers. Note that g need not be large at all, ice and Bob, but she does not alter the contents of their
and in practice is usually a small prime (like 2, 3, 5...) communications.
because primitive roots usually are quite numerous.
• g = public (prime) base, known to Alice, Bob, and
1.2 Generalization to finite cyclic groups Eve. g = 5
• p = public (prime) number, known to Alice, Bob,
Here’s a more general description of the protocol, and Eve. p = 23
1. Alice and Bob agree on a finite cyclic group G and • a = Alice’s private key, known only to Alice. a = 6
a generating element g in G. (This is usually done
long before the rest of the protocol; g is assumed to • b = Bob’s private key known only to Bob. b = 15
3
• A = Alice’s public key, known to Alice, Bob, and An eavesdropper has been able to see g a , g b , g c , g ab ,
Eve. A = ga mod p = 8 g ac , and g bc , but cannot use any combination of these
to reproduce g abc .
• B = Bob’s public key, known to Alice, Bob, and Eve.
B = gb mod p = 19 To extend this mechanism to larger groups, two basic
principles must be followed:
• Now s = the shared secret key and it is known to both
Alice and Bob, but not to Eve. s = 2 • Starting with an “empty” key consisting only of g ,
the secret is made by raising the current value to ev-
Note: It should be difficult for Alice to solve for Bob’s ery participant’s private exponent once, in any order
private key or for Bob to solve for Alice’s private key. (the first such exponentiation yields the participant’s
If it is not difficult for Alice to solve for Bob’s private own public key).
key (or vice versa), Eve may simply substitute her own
private / public key pair, plug Bob’s public key into her • Any intermediate value (having up to N − 1 expo-
private key, produce a fake shared secret key, and solve nents applied, where N is the number of partici-
for Bob’s private key (and use that to solve for the shared pants in the group) may be revealed publicly, but
secret key. Eve may attempt to choose a public / private the final value (having had all N exponents applied)
key pair that will make it easy for her to solve for Bob’s constitutes the shared secret and hence must never
private key). Another demonstration of Diffie-Hellman be revealed publicly. Thus, each user must obtain
(also using numbers too small for practical use) is given their copy of the secret by applying their own private
here [3] key last (otherwise there would be no way for the last
contributor to communicate the final key to its recip-
ient, as that last contributor would have turned the
key into the very secret the group wished to protect).
2 Operation with more than two
parties These principles leave open various options for choosing
in which order participants contribute to keys. The sim-
Diffie–Hellman key agreement is not limited to negotiat- plest and most obvious solution is to arrange the N partic-
ing a key shared by only two participants. Any number of ipants in a circle and have N keys rotate around the circle,
users can take part in an agreement by performing itera- until eventually every key has been contributed to by all
tions of the agreement protocol and exchanging interme- N participants (ending with its owner) and each partici-
diate data (which does not itself need to be kept secret). pant has contributed to N keys (ending with their own).
For example, Alice, Bob, and Carol could participate in a However, this requires that every participant perform N
Diffie–Hellman agreement as follows, with all operations modular exponentiations.
taken to be modulo p :
By choosing a more optimal order, and relying on the fact
that keys can be duplicated, it is possible to reduce the
1. The parties agree on the algorithm parameters p and number of modular exponentiations performed by each
g. participant to log2 (N ) + 1 using a divide-and-conquer-
2. The parties generate their private keys, named a , b style approach, given here for eight participants:
, and c .
1. Participants A, B, C, and D each perform one ex-
3. Alice computes g a and sends it to Bob.
ponentiation, yielding g abcd ; this value is sent to E,
4. Bob computes (g a )b = g ab and sends it to Carol. F, G, and H. In return, participants A, B, C, and D
receive g ef gh .
ab c abc
5. Carol computes (g ) = g and uses it as her
secret. 2. Participants A and B each perform one exponentia-
tion, yielding g ef ghab , which they send to C and D,
6. Bob computes g b and sends it to Carol.
while C and D do the same, yielding g ef ghcd , which
7. Carol computes (g b )c = g bc and sends it to Alice. they send to A and B.
8. Alice computes (g bc )a = g bca = g abc and uses it 3. Participant A performs an exponentiation, yielding
as her secret. g ef ghcda , which it sends to B; similarly, B sends
g ef ghcdb to A. C and D do similarly.
9. Carol computes g c and sends it to Alice.
10. Alice computes (g c )a = g ca and sends it to Bob. 4. Participant A performs one final exponentiation,
yielding the secret g ef ghcdba = g abcdef gh , while B
11. Bob computes (g ca )b = g cab = g abc and uses it as does the same to get g ef ghcdab = g abcdef gh ; again,
his secret. C and D do similarly.
4 5 SEE ALSO
• Non-Secret Encryption Using a Finite Field MJ • C implementation using GNU Multiple Precision
Williamson, January 21, 1974. Arithmetic Library
• Thoughts on Cheaper Non-Secret Encryption MJ • Diffie Hellman in 2 lines of Perl (using dc)
Williamson, August 10, 1976. • Smart Account Management (SAcct) (using DH key
• Diffie, W.; Hellman, M. (1976). “New di- exchange to derive session key)
rections in cryptography”. IEEE Transac- • Talk by Martin Hellman in 2007, Google video (bro-
tions on Information Theory 22 (6): 644–654. ken link)
doi:10.1109/TIT.1976.1055638.
6 9 TEXT AND IMAGE SOURCES, CONTRIBUTORS, AND LICENSES
9.2 Images
• File:Ambox_content.png Source: http://upload.wikimedia.org/wikipedia/en/f/f4/Ambox_content.png License: ? Contributors:
Derived from Image:Information icon.svg Original artist:
El T (original icon); David Levy (modified design); Penubag (modified color)
• File:Crypto_key.svg Source: http://upload.wikimedia.org/wikipedia/commons/6/65/Crypto_key.svg License: CC-BY-SA-3.0 Contribu-
tors: Own work based on image:Key-crypto-sideways.png by MisterMatt originally from English Wikipedia Original artist: MesserWoland
• File:Diffie-Hellman_Key_Exchange.svg Source: http://upload.wikimedia.org/wikipedia/commons/4/46/Diffie-Hellman_Key_
Exchange.svg License: Public domain Contributors: A.J. Han Vinck, Introduction to public key cryptography, p. 16 Original artist:
• SVG version: Flugaal
• File:Edit-clear.svg Source: http://upload.wikimedia.org/wikipedia/en/f/f2/Edit-clear.svg License: ? Contributors: The Tango! Desktop
Project. Original artist:
The people from the Tango! project. And according to the meta-data in the file, specifically: “Andreas Nilsson, and Jakub Steiner (although
minimally).”
• File:Text_document_with_red_question_mark.svg Source: http://upload.wikimedia.org/wikipedia/commons/a/a4/Text_document_
with_red_question_mark.svg License: Public domain Contributors: Created by bdesham with Inkscape; based upon Text-x-generic.svg
from the Tango project. Original artist: Benjamin D. Esham (bdesham)