Lecture 2 Public Key Cryptography
Lecture 2 Public Key Cryptography
CSC 427
Lecture 2
L!
I
FA
Solution 2
Alice sends the key at some time prior to sending Bob
the encrypted message
L!
I
FA
Solution 3 – Use public key crypto
Diffie Hellman Key Exchange
All users share common modulus, p, and element g
g ≠ 0, g ≠ 1, and g ≠ p-1
Alice chooses her private key, k
A
Computes K = gkA mod p and sends it to Bob in the clear
A
Bob chooses his private key, k
B
Computes K = gkB mod p and sends it to Alice in the clear
B
When Alice and Bob want to agree on a shared key,
they compute a shared secret S
S = KBkA mod p
A,B
S = K kB mod p
B,A A
Diffie Hellman Key Exchange
Diffie-Hellman algorithm is one of the most important
algorithms used for establishing a shared secret. At the
time of exchanging data over a public network, we can use
the shared secret for secret communication. We use an
elliptic curve for generating points and getting a secret key
using the parameters.
Let-
Private key of the sender = Xs
Public key of the sender = Ys
Private key of the receiver = Xr
Public key of the receiver = Yr
Step-03:
Both the parties receive public key of each other.
Now, both the parties calculate the value of secret key.
Why does DH work?
Sender calculates secret key as-
Secret key = (Yr)Xs mod n
Receiver calculates secret key as-
Secret key = (Ys)Xr mod n
Problem-01:
Suppose that two parties A and B wish to set up a common
secret key (D-H key) between themselves using the Diffie
Hellman key exchange technique. They agree on 7 as the
modulus and 3 as the primitive root. Party A chooses 2 and
party B chooses 5 as their respective secrets. Their D-H key
is-
How does DH work?
Solution-
Given-
n=7
a=3
Private key of A = 2
Private key of B = 5
Step-01:
Both the parties calculate the value of their public key and
exchange with each other.
Public key of A
= 3private key of A mod 7
= 32 mod 7
=2
How does DH work?
Public key of B
= 3private key of B mod 7
= 35 mod 7
=5
Step-02:
Both the parties calculate the value of secret key at their
respective side.
Secret key obtained by A
= 5private key of A mod 7
= 52 mod 7
=4
How does DH work?
Secret key obtained by B
= 2private key of B mod 7
= 25 mod 7
=4