Docsity

Diffie-Hellman Algorithm: A Practical Method for Establishing Shared Secrets, Lecture notes of Computer Science

Partial preview of the text

Download Diffie-Hellman Algorithm: A Practical Method for Establishing Shared Secrets and more Lecture notes Computer Science in PDF only on Docsity!

Classical cryptography.

Diffie-Hellman algorithm

LECTURE 3

Short review

– Cryptography is broadly classified into two categories: Symmetric

key Cryptography and Asymmetric key Cryptography (popularly

known as public key cryptography).

Source: https://www.edureka.co/blog/what-is-cryptography/

Diffie-Hellman algorithm

– U.S. Patent 4,200,770, now expired, describes the algorithm and

credits Hellman, Diffie, and Merkle as inventors.

– https://patents.google.com/patent/US

Description

– Diffie-Hellman establishes a shared secret that can be used for

secret communications by exchanging data over a public network.

Description – The simplest, and original, implementation of the protocol uses the multiplicative group of integers modulo p , where p is prime and g is primitive root mod p. OBS. primitive root calculator: https://www.mathcelebrity.com/primitiveroot.php

Description

– Here is an example of the protocol, with non-secret values in

green, and secret values in boldface red :

AGENT X AGENT Z

Secret Public Calculus Calculus Public Secret p,g p,g x z gx^ (mod p) gz^ (mod p) (gx^ )z(mod p) (gz^ )x(mod p)

EXAMPLE – Let’s take a simple example that outlines the idea behind the protocol. – AGENT Z want to send a message to you’re his friend AGENT X. However, you don’t want anyone apart from AGENT X to know what the contents of the message are. – You’re using the Caesar cipher, a simple encryption technique in which each letter in your address is replaced by a letter that is a fixed number of positions down in the alphabet. – This fixed number of positions is the shared key — if AGENT X has this key, she can decrypt your message.

EXAMPLE

– Instead of sending a key over to AGENT X so that you two have a shared

key, follow the following steps.

– Step 1: Pick two prime numbers and send them to AGENT X.

– Step 2: AGENT X computes X using her own secret key, and sends X to

you.

– Step 3: You compute Z using your own secret key, and send Z to AGENT

X.

– Step 4: AGENT X computes the shared key.

– Step 5: You compute the shared key.

– Wow, both of you now have the same key! And none of you had to send

it to each other explicitly.

– Now, both of you can shift all the letters in your message by “key”

letters

  1. How did this happen? Will both numbers always be the same?

– The mod (modulo) operation has a nifty little property when it comes to

exponentiation:

– (g x mod p) z mod p = g xz mod p*

– where x and z are the ‘secrets’ we used earlier.

– What does this imply? – (g x mod p) z mod p = (g z mod p) x =g xz mod p =g zx mod p** – a and b are individual secrets, but the final result is a shared secret.

  1. The Discrete Logarithm: why is this difficult to break? – The difficulty in reverse engineering the shared secret key lies in the difficulty to compute the discrete logarithm. What is the discrete logarithm? – The regular logarithm in mathematics is the inverse operation of exponentiation. ( e.g. if 2

= 4 , then log of 4 to base 2 , is 2 ). – The discrete logarithm is very close to this logarithm. (e. g. if we compute 4 ² mod 3 which is 1 , how do we find the value 1 , the shared ‘secret’-, if we only knew the values of 4 and 3 )

EXERCISE

– RESULT:

AGENT A AGENT B INTERCEPTOR/HACKER

Known Unknown Known Unknown Known Unknown p=31 p=31 p= g=11 g=11 g= a=6 b b=12 a a,b A = 11^6 mod 31= 4

B
B =

11^12 mod 31= 16

A A,B
B=16 A=4 A=4, B=

Sharedkey= B a^ mod p Sharedkey= A b^ mod p Sharedkey= 16^6 mod 31=

Sharedkey= 4^12 mod 31=

EXERCISE 2

– Please try to compute and fill the secrecy chart by using the

following template:

AGENT A AGENT B INTERCEPTOR/HACKER

Known Unknown Known Unknown Known Unknown p=541? p=541??? g=2? g=2??? a=292? b=426??? ?????? Result?? Result????

EXERCISE

– Please try to implement a program that calculates the key for two

persons using the Diffie-Hellman Key exchange algorithm, using

Java program language.

– (for help: http://billatnapier.com/security 02 .aspx)

EXERCISE

– Input:

– Step 1 : Alex and Thomas get public numbers P = 11 , G = 2 – Step 2 : Alex selected a private key a = 8 and Thomas selected a private key b = 4 – Step 3 : Alex and Thomas compute public values – Step 4 : Alex and Thomas exchange public numbers – Step 5 : Alex and Thomas receives public key – Step 6 : Alex and Thomas compute symmetric keys – Step 7 : Shared key value.

– Output

– The value of P :? – The value of G :? – The private key a for Alex : … – The private key b for Thomas : … – Secret key for the Alex is : … – Secret Key for the Thomas is : …