Public Key Cryptography - Chapter 9
Public Key Cryptography - Chapter 9
Chapter 9
Module 4-Part 2
Prepared by:
Dr. S V Uma,
Associate Professor,
Dept. of ECE,
RNSIT
Private-Key Cryptography
Traditional private/secret/single key
cryptography uses one key
Shared by both sender and receiver
If this key is disclosed communications are
compromised
Also if symmetric, parties are equal
Hence does not protect sender from receiver
forging a message & claiming it is sent by sender
Public-Key Cryptography
•Probably most significant advance in the 3000
year history of cryptography
•Uses two keys – a public & a private key
•Asymmetric since parties are not equal
•Uses clever application of number theoretic
concepts to function
•Complements rather than replaces private key
cryptosystems
Why Public-Key Cryptography?
•Developed to address two key issues:
•Key distribution – how to have secure
communications in general without having to
trust a KDC with your key
•Digital signatures – how to verify a message
comes intact from the claimed sender
•Public invention due to Whitfield Diffie &
Martin Hellman at Stanford Univ. in 1976
•known earlier in classified community
Public-Key Cryptography
•Public-key/two-key/asymmetric cryptography
involves the use of two keys:
• A public-key, which may be known by anybody, and
can be used to encrypt messages, and verify
signatures
• A related private-key, known only to the recipient,
used to decrypt messages, and sign (create) signatures
•Infeasible to determine private key from public
•Is asymmetric because
• Those who encrypt messages or verify signatures
cannot decrypt messages or create signatures
A Public-Key Cryptography system
Public-Key Cryptography Principles
•The use of two keys has consequences in: key
distribution, confidentiality and authentication.
•The scheme has six ingredients
• Plaintext
• Encryption algorithm
• Public and private key
• Ciphertext
• Decryption algorithm
Applications for Public-Key
Cryptosystems
•Three categories:
• Encryption/decryption: The sender encrypts a
message with the recipient’s public key.
Henric Johnson 9
Authentication using Public-Key
System(Signature Authentication)
Public-Key Cryptosystems - Both
Authentication and Secrecy
Symmetric vs Public-Key
Public-Key Applications
•Some algorithms are suitable for all uses,
others are specific to one
Public-Key Requirements
•Public-Key algorithms rely on two keys where:
• It is computationally infeasible to find decryption key
knowing only algorithm & encryption key
• It is computationally easy to en/decrypt messages
when the relevant (en/decrypt) key is known
• Either of the two related keys can be used for
encryption, with the other used for decryption (for
some algorithms)
• These are formidable requirements which only a few
algorithms have satisfied
Public-Key Requirements
•Need a trapdoor one-way function
•One-way function has
•Y = f(X) easy
•X = f–1(Y) infeasible
•A trap-door one-way function has
•Y = fk(X) easy, if k and X are known
•X = fk–1(Y) easy, if k and Y are known
•X = fk–1(Y) infeasible, if Y known but k not
known
•A practical public-key scheme depends on a
suitable trap-door one-way function
Security of Public Key Schemes
Like private key schemes brute force exhaustive
search attack is always theoretically possible
But keys used are too large (>512bits)
Security relies on a large enough difference in
difficulty between easy (en/decrypt) and hard
(cryptanalyse) problems
More generally the hard problem is known, but is
made hard enough to be impractical to break
Requires the use of very large numbers
Hence is slow compared to private key schemes
RSA
By Rivest, Shamir & Adleman of MIT in 1977
Best known & widely used public-key scheme
Based on exponentiation in a finite (Galois) field
over integers modulo a prime
Exponentiation takes O((log n)3) operations (easy)
Uses large integers (eg. 1024 bits)
Security due to cost of factoring large numbers
Factorization takes O(e log n ) operations (hard)
RSA En/decryption
•To encrypt a message M the sender:
•Obtains public key of recipient PU={e,n}
•Computes: C = Me mod n, where 0≤M<n
•To decrypt the ciphertext C the receiver:
•Uses their private key PR={d,n}
•Computes: M = Cd mod n
•Note that the message M must be smaller
than the modulus n (block if needed)
The RSA Algorithm – Key Generation
•Plaintext: M<n
•Ciphertext: C = Me (mod n)
The RSA Algorithm - Decryption
•Ciphertext: C
•Plaintext: M = Cd (mod n)
RSA Key Setup
•Each user generates a public/private key pair by:
•Selecting two large primes at random: p, q
•Computing their system modulus n=p.q
•Note that ø(n)=(p-1)(q-1)
•Selecting at random the encryption key e
•Where 1<e<ø(n), gcd(e,ø(n))=1
•Solve following equation to find decryption key d
•e.d=1 mod ø(n) and 0≤d≤n
•Publish their public encryption key: PU={e,n}
•Keep secret private decryption key: PR={d,n}
Why RSA Works
•Because of Euler's Theorem:
•aø(n)mod n = 1 where gcd(a,n)=1
•In RSA we have:
•n=p.q
•ø(n)=(p-1)(q-1)
•Carefully chose e & d to be inverses mod ø(n)
•Hence e.d=1+k.ø(n) for some k
•Hence :
Cd = Me.d = M1+k.ø(n) = M1.(Mø(n))k
= M1.(1)k = M1 = M mod n
RSA Example - Key Setup
1. Select primes: p=17 & q=11
2. Calculate n = pq =17 x 11=187
3. Calculate ø(n)=(p–1)(q-1)=
16x10=160
4. Select e: gcd(e,160)=1; choose e=7
5. Determine d: de=1 mod 160 and d <
160 Value is d=23 since 23x7=161=
10x16+1
6. Publish public key PU={7,187}
7. Keep secret private key PR={23,187}
RSA Example - En/Decryption
Sample RSA encryption/decryption is:
Given message M = 88 ( note 88<187)
Encryption:
C = 887 mod 187 = 11
Decryption:
M = 1123 mod 187 = 88
Exponentiation
•Can use the Square and Multiply Algorithm
•A fast, efficient algorithm for exponentiation
•Concept is based on repeatedly squaring base
and multiplying in the ones that are needed to
compute the result
•Look at binary representation of exponent
•Only takes O(log2 n) multiples for number n
• eg. 75 = 74.71 = 3.7 = 10 mod 11
• eg. 3129 = 3128.31 = 5.3 = 4 mod 11
Exponentiation-Square and
b
Multiply Algorithm for a mod n
c = 0; f = 1
for i = k downto 0
do c = 2 x c
f = (f x f) mod n
if bi == 1 then
c = c + 1
f = (f x a) mod n
return f
Efficient Encryption
•Encryption uses exponentiation to power e
•Hence if e is small, this will be faster
• often choose e=65537 (216-1)
• also see choices of e=3 or e=17
•But if e too small (eg e=3) can attack
• using Chinese remainder theorem & 3 messages
with different modulii
•If e is fixed must ensure gcd(e,ø(n))=1
• i.e reject any p or q not relatively prime to e
Efficient Decryption
•Decryption uses exponentiation to power d
• this is likely large, insecure if not
•Can use the Chinese Remainder Theorem
(CRT) to compute mod p & q separately, then
combine to get desired answer
• approx 4 times faster than doing directly
•Only owner of private key who knows values
of p & q can use this technique
RSA Key Generation
•Users of RSA must:
• determine two primes at random - p, q
• select either e or d and compute the other
•Primes p,q must not be easily derived from
modulus n=p.q
• means must be sufficiently large
• typically guess and use probabilistic test
•Exponents e, d are inverses, so use Inverse
algorithm to compute the other
RSA Processing of Multiple blocks
RSA Security
•Possible approaches to attacking RSA are:
•Brute force key search - infeasible given size
of numbers
•Mathematical attacks - based on difficulty of
computing ø(n), by factoring modulus n
•Timing attacks - on running of decryption
•Chosen ciphertext attacks - given properties
of RSA
Factoring Problem
•Have considered:
•principles of public-key cryptography
•RSA algorithm, implementation,
security
KEY MANAGEMENT
P + P = 2P = R.
• The tangent from P is always vertical
if yP = 0.
Doubling the point P if yP = 0
3P = P, 4P = O, 5P = P, 6P = O, 7P = P, etc.
Elliptic Curve Addition: An Algebraic Approach
P + Q = R where
• When yP is not 0,
2P = R where
s = (3xP2 + a) / (2yP )
xR = s2 - 2xP and yR = -yP + s(xP - xR)
Recall that a is one of the parameters chosen with
the elliptic curve and that s is the tangent on the
point P.
Elliptic Curve Picture
y
• Consider elliptic curve
P2 E: y2 = x3 - x + 1
P1
x • If P1 and P2 are on E, we can
P3 define
P3 = P1 + P2
as shown in picture
• Addition is all we need
Elliptic Curve Addition
• Consider y2 = x3 - 36x. Points on the curve are P=(-
3.5,9.5) and Q=(-2.5,8.5). Find P+Q and 2P
• R = (x3,y3)?
s = (8.5-9.5)(-2.5+3.5)-1 = -11-1
= -1
x3 = 1 + 3.5 + 2.5 = 7
y3 = -1(-3.5-7) – 9.5 = 1
R = (x3,y3)=(7,1)
S= (3xP2 + a) / (2yP ) = {3(-3.5)2+(-36)}/2(9.5) =
xR = s2 - 2xP = and
yR = -yP + s(xP - xR) =
Elliptic Curve Groups over Fp
• Calculations over the real numbers are slow and
inaccurate due to round-off error. Cryptographic
applications require fast and precise arithmetic; thus
elliptic curve groups over the finite fields of Fp and F2m
are used in practice.
• Recall that the field Fp uses the numbers from 0 to p - 1,
and computations end by taking the remainder on division
by p. For example, in F23 the field is composed of integers
from 0 to 22, and any operation within this field will result
in an integer also between 0 and 22.
• An elliptic curve with the underlying field of Fp can formed
by choosing the variables a and b within the field of Fp.
The elliptic curve includes all points (x,y) which satisfy the
elliptic curve equation modulo p (where x and y are
numbers in Fp).
• For example: y2 mod p = x3 + ax + b mod p has an
underlying field of Fp if a and b are in Fp.
• Consider y2 = x3 + 2x + 3 (mod 5)
x = 0 y2 = 3 no solution (mod 5)
x = 1 y2 = 6 = 1 y = 1,4 (mod 5)
x = 2 y2 = 15 = 0 y = 0 (mod 5)
x = 3 y2 = 36 = 1 y = 1,4 (mod 5)
x = 4 y2 = 75 = 0 y = 0 (mod 5)
• Then points on the elliptic curve are
(1,1) (1,4) (2,0) (3,1) (3,4) (4,0)
and the point at infinity:
Example of an Elliptic Curve Group over Fp
• As a very small example, consider an elliptic curve over the field
F23. With a = 1 and b = 0, the elliptic curve equation is y2 = x3 + x.
• The point (9,5) satisfies this equation since:
y2 mod p = x3 + x mod p
25 mod 23 = 729 + 9 mod 23
25 mod 23 = 738 mod 23
2=2
The 23 points which satisfy this equation are:
(0,0) (1,5) (1,18) (9,5) (9,18) (11,10) (11,13) (13,5) (13,18) (15,3)
(15,20) (16,8) (16,15) (17,10) (17,13) (18,10) (18,13) (19,1) (19,22)
(20,4) (20,19) (21,6) (21,17)
P + Q = R where
xR = s2 - xP - xQ mod P and
yR = -yP + s(xP - xR) mod P
• When yP is not 0,
2P = R where
s = (3xP2 + a) / (2yP ) mod P
xR = s2 - 2xP mod P and yR = -yP + s(xP - xR) mod P
Recall that a is one of the parameters chosen with
the elliptic curve and that s is the tangent on the
point P.
Elliptic Curve Addition
ga mod p
gb mod p
Alice, a Bob, b
• Suppose that Bob and Alice use gab mod p as a symmetric key
• Trudy can see ga mod p and gb mod p
• Note ga gb mod p = ga+b mod p gab mod p
• If Trudy can find a or b, system is broken
• If Trudy can solve discrete log problem, then she can find a or
b
Diffie-Hellman
ga mod p gt mod p
gt mod p gb mod p
A(x,y)
B(x,y)
Alice, A Bob, B