Transcript Lecture 10

Introduction to
Cryptography
Lecture 10
The RSA Public – Key Cryptosystem
Alice:
 Selects two prime numbers p and q.
 Calculates m = pq and n = (p - 1)(q - 1).
 Selects number e relatively prime to n
 Finds inverse of e modulo n
 Publishes e and m
The RSA Public – Key Cryptosystem
Example:
 p =127, q = 223.
 Then m = 28321 and n = 27972
 Let e = 5623, check gcd(n,e) = 1.
 Then using Extended Euclidean Algorithm
d = 22495.
 Public Key: (5623, 28321).
The RSA Public – Key Cryptosystem
To encrypt the message x:
e
y

x
mod m .
 Bob computes:
 Bob sends y to Alice.
To Decrypt the message y:
d
 Alice computes: x  y mod m .
The RSA Public – Key Cryptosystem
Example:
 Let the message be x = 3620.
5623
y

3620
mod 28321  27845.
 Then
 Alice gets one and decrypts it
22495
mod 28321  3620.
 Then x  27845
Public – Key Cryptosystems
Current implementations of public-key
cryptosystems works slow
 Public-key methods are mostly use for
key exchange or key agreement
protocols
 p and q should be at least 155 decimal
digits each

Public – Key Cryptosystems
message
Alice

Bob
Bob sends to Alice message: “Lets
communicate using DES system. Lets
use the key: 11111111…1.”
Public – Key Cryptosystems
Alice does not have to agree on this key
 They can decide on another key
 If they disagree on the key, various
solutions can be given
 A trusted authority will help them to decide
on a key

The Discrete Logarithm Problem
Definition: Given an integers b, c and m,
the discrete logarithm problem is to find
an x such that: b x  c mod m .
 This problem is time consuming and
considered to be hard
 There is no time efficient algorithm to
solve DLP
2 x mod 19
2 x mod 19
The Discrete Logarithm Problem
Example: Let m=19, b=2 and c=14. Find an
x such that: 2 x  14 mod 19 .
x
1
2
3
4
5
6
7
2 x mod 19
2
4
8
16
13
7
14
The solution will be x=7.
Diffie-Hellman Key Agreement
Given:
 p - large prime number, public prime
 s - number between 2 and p-2 (better to take generator),
public base
Alice:
Picks a between 2 and p-2
a
Computes   s and send it
to Bob
Computes the key:
Bob:
Picks b between 2 and p-2
b
Computes   s and send it
to Alice
Computes the key:
k   a mod p  (s b ) a mod p  s ba mod p
k   b mod p  ( s a )b mod p  s ab mod p
Diffie-Hellman Key Agreement
Example:
 Let p=197 and s=31
 Suppose Alice picks a=101, then:
  31101 mod 197  153.
 Suppose Bob chooses b=85, then:
  3185 mod 197  11.
 The key is:

101
 11 mod 197  48  153 mod 197  
101
85
85
ElGamal Cryptosystem
Let p be a public prime and let s be a
number between 2 and p-2
 Alice chooses a between 2 and p-2 and
a


s
computes
. Alice’s private key is a
and Alice’s public key is  .
 Bob chooses b between 2 and p-2 and
computes   s b . Bob’s private key is b and
Bob’s public key is  .

ElGamal Cryptosystem
Encryption:
 Let x be a message (number between 2
and p-2) Bob wants to send to Alice, he:
 Finds Alice’s public key  , and generates
random number k between 2 and p-2
k
k
y


x mod p .
 Calculates t  s mod p and
 Sends t and y to Alice
ElGamal Cryptosystem
Decryption:
 Alice receives t and y from Bob, and
a 1
 Calculates c  (t ) mod p and
y  (t a ) 1 mod p  x .
Question: Why does it work?
It works since: t a  (s k ) a  s ak mod p , so
y  (t a ) 1  ( x  s ak )  ( s ak ) 1  x mod p .
ElGamal Cryptosystem
Example: Let p=11881379, s=23 and
Alice’s public key  =1308503.
Bob wants to send message: LUNCH, or
x=5387103. He picks k=123.
Bob computes:
t  s k mod 11881379  23123 mod 11881379  1777907 , and
y  x   mod 11881379  5387103 138503 mod 11881379  4944577.
k
123
Homework
Read pg.296-304.
 Exercises: 3, 6(a), 7(a) on pg.304-305.
 Those questions will be a part of your
collected homework.
