Cryptography and Security
Cryptography and Security
Mechanisms
Mechanisms
Nazar Abbas Saqib
[email protected]
2
Agenda
Agenda
Agenda
Agenda
Agenda
Agenda
Agenda
Agenda
Prime Numbers
•
An integer p > 1 is a prime number if its only divisors are ±1 and ±pPrimes Under 2000
Primality Testing
Primality Testing
Primality Testing
Fundamental Theorem of Arithmetic
Fundamental Theorem of Arithmetic
Every integer
n
≥ 2 has a factorization as a product of
prime powers:
Where the
p
iare distinct primes, and the
e
iare positive
integers. Furthermore, the factorization is unique up to
the rearrangement of factors.
,
2 12
1
ke
k
e
e
p
p
p
Factorization Prime Number
Factorization Prime Number
Trial division method
Trial division method
Factorization Prime Number
Factorization Prime Number
Trial division method
Trial division method
Determining GCD
Determining GCD
GCD of any positive integers can be easily determined if
they are written as a product of prime powers:
15
RSA Factoring Challenge
RSA Factoring Challenge
Numbers are designated “RSA-XXXX”, where XXXX is the number’s length in bits
Challenge Number Prize ($US) Status
RSA-576 (174 Digits) $10,000 Factored (Dec 2003) RSA-640 (193 Digits) $20,000 Factored (Nov 2005) RSA-704 (212 Digits) $30,000 Not Factored
RSA-768 (232 Digits) $50,000 Not Factored RSA-896 (270 Digits) $75,000 Not Factored RSA-1024 (309 Digits) $100,000 Not Factored RSA-1536 (463 Digits) $150,000 Not Factored RSA-2048 (617 Digits) $200,000 Not Factored
RSA-704
Decimal Digits: 212
17
Relatively Prime Numbers
Relatively Prime Numbers
Two integers are relatively prime if there only common
positive integer factor is 1
Fermat’s Little Theorem (FLT)
Fermat’s Little theorem:
If p is prime and a is a positive integer not divisible by p, then
ap-1 ≡ 1 mod p
a=7, p=19
72 = 49 ≡ 11 (mod 19)
74 = 121 ≡ 7 (mod 19)
78 = 49 ≡ 11 (mod 19)
716 = 121 ≡ 7 (mod 19)
ap-1 = 718 = 716x72 ≡ 7x11≡1 (mod 19
)
719 (mod 19) ?
720 (mod 19) ?
721 (mod 19) ?
Fermat’s Little Theorem
• Alternative Form
If p is prime and a is a positive integer, then
a
p≡
a mod
p
Example 1:
a=3, p=5 ap=35 = 243 ≡ 3 (mod 5)= a (mod p)
Example 2:
a=10, p=5 ap=105 = 100000 ≡ 10 (mod 5) ≡ 0 (mod 5) ≡ a
(mod p)
Fermat’s Little Theorem-Application
8-1 mod 17=817-2 mod 17=815 mod 17=15 mod 17
Euler’s Phi-Function
Definition: Euler’s phi-function φ(n) is defined to be the
number of positive integers less than n (including 1) that are relatively prime to n
Example 1: Because 37 is prime, all positive integers from
1 through 36 are relatively prime. Thus Ф(37)=36
Example 2: Ф(35)=24 ?
To determine Ф(35), we list all of the positive integers less than 35 that are relatively prime to n
22
Euler’s Phi-Function
For two prime numbers p & q, with p≠q,
n=pq
Ф(n)= Ф(pq)= Ф(p) × Ф(q)= (p -1)×(q-1)
Example: Ф(21)= Ф(3)× Ф(7)=Ф(3-1)× Ф(7-1)=2×6=12
Where the 12 integers are
23
Euler Theorem
Euler’s theorem states that for every a and n that are relatively prime:
aФ(n)≡ 1 mod n
Example 1: a=3,n=10; Ф(10)=4 aФ(n) = 34 =81≡ 1 (mod 10) = 1
(mod n)
Example 2: a=2,n=11; Ф(11)=10 aФ(n)= 210=1024 ≡ 1 (mod 11) = 1
(mod n)
An alternative form of the theorem is:
aФ(n) +1 ≡ a mod n
24
Modular Exponentiation
M
15How many multiplications are needed??
Naïve Answer (requires 14 multiplications):
M
→
M
2→
M
3→
M
4→
M
5→
…
→
M
15Binary Method (requires 6 multiplications):
Modular Exponentiation: Binary Method
Let k be the number of bits of e, i.e.,
Input: M, e, n.
Output: C := Me mod n
1. If ek-1 = 1 then C := M else C := 1; 2. For i = k-2 downto 0
3. C := C2 mod n
4. If ei = 1 then C := C x M mod n
3. Return C;
(
)
Modular Exponentiation: Binary Method
Example: e = 250 = (11111010), thus k = 8
Initially, C = M since e
k-1= e
7= 1
i ei Step 2a Step 2b
7 1 M M
6 1 (M)2 = M2 M2
⋅M = M3
5 1 (M3)2 = M6 M6
⋅M = M7
4 1 (M7)2 = M14 M14
⋅M = M15
3 1 (M15)2 = M30 M30
⋅M = M31
2 0 (M31)2 = M62 M62
1 1 (M62)2 = M124 M124
⋅M = M125
Discrete Logarithmic Problem
Many tools based on discrete logarithm problem
ax = y modulo n
given x „easy“ to find y given y „hard“ to find x
Example?
102=100
Log10100 = 2
Guess the values of ‘x’ when
5x=7 mod 19
Chinese Remainder Theorem
Chinese Remainder Theorem
1
mod
i i iM
M
m
m
−=
1 1 1 1 1mod
M
M
m
m
− −
=
1 1 13 5 7
mod 3
3
M
− −
× ×
=
Solution: Four steps
1 1
1
35
2 mod 3
M
−=
−≡
1 1
2
21
1mod 5
M
−=
−≡
1 1
3
15
1mod 7