08RSA
08RSA
1 / 23
Outline
Fact
• x ∈ ZN is invertible iff gcd(x, N ) = 1
• Number of elements in Z∗N is
ϕ(N ) = (p − 1)(q − 1) = N − p − q + 1
Theorem (Euler)
∀x ∈ Z∗N : x ϕ(N ) = 1 (mod N )
3 / 23
The RSA Cryptosystem
4 / 23
Figure: Adi Shamir, Ron Rivest, and Leonard Adleman
5 / 23
Review: Public key encryption
Definition
A Public key encryption system is a triple of algorithms
(G, E, D)
where:
G() : randomized algorithm output a key pair (pk, sk).
E(pk, m) : randomized algorithm that takes m ∈ M and
output c ∈ C.
D(sk, c) : deterministic algorithm that takes c ∈ C and
output m ∈ M or ⊥ (error).
6 / 23
RSA Cryptosystem
Key gen G()
E(pk, x) : D(sk, y) :
return x (mod N )
e
return y d (mod N )
7 / 23
Correctness of Decryption
e · d = 1 + j · ϕ(N )
Therefore:
(x e )d = x 1+ j·ϕ(N )
= x · (x ϕ(N ) ) j
= x · 1 (mod N )
= x (mod N )
8 / 23
Key Generation in Detail
9 / 23
Practical RSA Parameters
10 / 23
The RSA assumption
RSA is one-way permutation
RSA assumption
11 / 23
Security of RSA
12 / 23
Exercise
13 / 23
Exercise
14 / 23
Outline
218 = 2 + 23 + 24 + 26 + 27 .
16 / 23
Example (continued)
We create a table
i 0 1 2 3 4 5 6 7
2i
3 (mod 1000) 3 9 81 561 721 841 281 961
then compute
3 4 6 7
3218 = 32 · 32 · 32 · 32 · 32
≡ 9 · 561 · 721 · 281 · 961 (mod 1000)
≡ 489 (mod 1000).
17 / 23
Fast Computation of a b (mod n)
MODULAR-EXPONENTIATION(a, b, n)
c=0
d =1
Represent b = 〈bk , bk−1 , . . . , b0 〉2
for i = k downto 0
c = 2c
d = (d · d) mod n
if bi == 1 then
c = c+1
d = (d · a) mod n
return d
18 / 23
Example
Compute 7560 mod 561
i 9 8 7 6 5 4 3 2 1 0
bi 1 0 0 0 1 1 0 0 0 0
c 1 2 4 8 17 35 70 140 280 560
d 7 49 157 526 160 241 298 166 67 1
19 / 23
Recursive Algorithm for a b mod n
MODULAR-EXPONENTIATION(a, b, n)
if b == 0 then return 1
if b == 1 then return a
r = MODULAR-EXPONENTIATION(a, b/2, n)
r =r∗r
if b mod 2 == 1 then r = r ∗ a
return r
20 / 23
Exercise: Efficient Modular
Exponentiation
21 / 23
Exercise
• Given that you know ϕ(n),
• explain how to compute the modular inverse
22 / 23
Thank you!
23 / 23