This document discusses public key cryptography and the RSA algorithm. It begins by explaining the differences between symmetric and asymmetric cryptosystems. It then describes the key components of public key cryptography, including public/private key pairs, certificates, and algorithms. The document goes on to explain the mathematical foundations of public key cryptography using concepts like Euler's totient function and the discrete logarithm problem. It provides details on the RSA algorithm, including key generation, encryption, and decryption. It also includes an example of RSA encryption and decryption. Finally, it discusses some attacks on RSA like brute force and timing attacks, as well as countermeasures.
Application of Residue Theorem to evaluate real integrations.pptx
Public key CryptoSystem
1. IT402 Cryptography and Cyber
Security
S8 B. Tech
Information Technology
ANVER. S. R
Associate Professor, CSE
LBS College of Engineering,
Kasaragod.
Module 5
Public key CryptoSystem
2. TYPES OF CRYPTOGRAPHY
● SYMMETRIC CRYPTOSYSTEM
− There is a secret(key), which is shared between
two persons.
− Encryption and Decryption are done using the
same key.
− If there are n participating entities, the number
of keys will be ??
− n(n-1)/2
− Based on substitution and permutation of
symbols.
− Made secure by providing confusion and
diffusion.
3. TYPES OF CRYPTOGRAPHY
● ASYMMETRIC CRYPTOSYSTEM
− There is a personal secret(private key),
which is not shared.
− Encryption and Decryption are done
using the different keys.
− For every private key, there is a
corresponding public key belonging to
each person.
− If there are n participating entities, the
number of keys will be ??
− 2n, n private keys and n public keys
4. Asymmetric Cryptosystem
● Based on applying
mathematical functions to
numbers.
● Its made secure by providing
mathematically hard problems.
● More secure from cryptanalysis
than symmetric cryptosystem.
● computationally infeasible to
find private key knowing only
algorithm & public key
● computationally easy to
en/decrypt messages when the
relevant (private/public) key
is known.
5. Public Key
Cryptosystem-Components
● Asymetric Keys
− Two related keys,
− a public key and a private key,
− used to perform complementary
operations,
− encryption and decryption or
− signature generation and
signature verification
● Public Key Certificate
− A digital document issued and
digitally signed by the private key of
a Certification authority that binds
the name of a subscriber to a public
key.
− The certificate indicates that the
subscriber identified in the
certificate has sole control and
− access to the corresponding private
key.
6. Public key Cryptography –
components.
● Public key cryptographic
algorithm:
− A cryptographic algorithm
that uses two related keys,
− a public key and a private
key
● Public key infrastructure (PKI)
− A set of policies, processes,
server platform, software and
workstations used for the
purpose of administrating
certificates and public-private
key pairs, including the ability to
issue, maintain, and revoke
public certificate.
7. Public key cryptosystem –
Ingrediants.
● Plaintext
− This is a readable message or
data that is fed into the
algorithm as the input
● Encryption algorithm
− The encryption algorithm
performs various
transformations on the plaintext
● Public and private keys
− this is a pair of keys that have been
selected so that if one is used for
encryption, the other is used for
decryption.
− The exact transformations
performed by the algorithm
depend on the public key and the
private key that is provided as
input.
8. PKC - Ingredients
● Cipher text
− this is the scrambled
message produced as
output.
● Decryption algorithm
− The algorithm that accepts the
cipher text and matching key
and produces the original plain
text.
9. PKC-The essential steps.
● Each user generates a pair of keys to be used for the encryption and decryption of
messages
● Each user places one of the two keys in public register or other accessible file. This is
public key. The other key is kept private. Each user maintains a collection of public keys
obtained from others
● If Bob wishes to send a confidential message to Alice, Bob encrypts the message using
Alice’s public key.
● When Alice receives the message, she decrypts it using her private key
● No other recipient can decrypt the message because only Alice knows her private key
10. Public key cryptography
● Public key cryptography –
authentication.
●
●
●
● Public key cryptography –
secrecy
12. PKC-Applications
● Applications are divided in three broad categories:
− Encryption/decryption – The sender encrypts the message with the
recipient’s public key.
− Digital Signature – The sender “signs” a message with its private key
− Key exchange – two sides cooperate toexchange a session key
13. Mathematics for public key
cryptosystem
● Euler’s Phi(Totient) function:
− Euler's totient function counts the
positive integers up to a given integer n
that are relatively prime to n. It is
denoted as ϕ(n)
− Zn* denoted the reduced residue mod n
system.
− ϕ(n) is the cardinality of Zn*
− Example n = 9
− Φ(1)=0, ϕ(p)=p-1.
● Fermat’s little Theorem.
− if p is a prime number, then for
any integer a,which is not
divisible by p,
● ap − 1
≡ 1 ( mod p )
● ap
≡ a ( mod p )
− Example:
● a = 2
● p = 7
14. Mathematics for Public key
cryptosystem.
● Euler’s Theorem
− Generalization of fermat’s
little theorem.
− In Fermat’s theorem, modulus
p, a prime number
− Here, n is an integer.
− aφ ( n )
≡ 1 ( mod n )
− ak*φ ( n )+1
≡ a ( mod n )
15. Asymmetric Cryptosystem – hard
problems
● Discrete logarithm problem
− Defined with regard to multiplicative
cyclic groups.
− h=gx
in G, then x is the discrete log of
h to the base g.
− Not always hard, hardness depends
on the groups.
− Zp
*
, p should be a safe prime, a
prime number which equals 2q+1
where q is a large prime number.
● Prime factorization problem
− Prime factorization is a way of
writing a composite number as
a product of prime numbers.
− Is easy if n is the product of
small primes.
− Is hard, if n is the product of
very large primes.
16. Asymmetric crypto system
● Function:
− A rule that associates (maps)
one element in set A to one
element in set B.
● Invertible function:
− A function that associates each
element in the range with
exactly one element in the
domain.
● One way function(OWF)
− Is a function that satisfies
● f is easy to compute,ie.If x is given, can
compute y = f(x)
● f-1
is difficult to compute, if y is given,
computationally infeasible to calculate
x.
− Example:
● Given p, q, n = p * q
● If given n, very difficult to compute p
and q
17. Asymmetric Cryprosystem
● Trapdoor function:
− Is a one way function with an
additional property.
− Given y and a trapdoor
(secret), x can be computed
easily.
● Example:
− Given x, k and n
− Easy to calculate
● y = xk
(mod n)
− Given y, k and n, difficult
− Given y, n and k’ such that
k*k’=1 (mod ϕ(n)), then
● x = yk’
(mod n)
18. RSA Algorithm
● Asymmetric key cryptographic algorithm
● The name RSA is given by taking the firstname of its inventors
Rivest-Shamir-Adleman.
● It uses prime numbers
− This algorithm is based on the fact that it is easy to find and multiply large prime numbers
together, but it is extremely difficult to factor their product
− The private and public keys in RSA are based on very large prime numbers
● The real challenge in RSA is the selection and generation of the public key and
private key
19. RSA Algorithm
1) Choose two prime numbers p and q
2) Calculate n = p * q
3) Calculate ϕ(n) as (p-1) * (q-1)
4) Select the public key e (i.e. Encryption key) such that it is relatively prime to ϕ(n)
5) Calculate the private key d (i.e. Decryption key) such that d is the multiplicative
inverse of e (mod ϕ(n))
6) Publish (n, e) as public key
7) Keep (p, q, d) as private key
20. RSA algorithm
● RSA Encryption(Sender Side)
● Alice
− Sender chooses the Plaintext P
− Public Key of recipient = (n, e)
− Ciphertext C = Pe
(mod n)
● RSA Decryption (Receiver
Side)
● Bob
− Receiver reciever the ciphertext
C encrypted using the public key
of recipient.
− Private key = d
− Plaintext P = Cd
(mod n)
21. RSA algorithm - Example
1) Choose two large prime numbers p and q,
1) let p = 7 and q = 17
2) Calculate n = p * q, n = 7 * 17 = 119
3) Calculate ϕ(n) as (p-1) * (q-1), ϕ(n) = 6 * 16 = 96.
4) Select the public key e (i.e. Encryption key) such that it is relatively prime to ϕ(n)=96
1) The factors of 96 are 2,2,2,2,2 and 3 ( because 96 = 2*2*2*2*2*3)
2) Thus we have to choose E such that none of the factors of E is 2 and 3
3) Lets choose E as 5
22. RSA Algorithm - Example
1. Calculate the private key d (i.e. Decryption key) such that d is the
multiplicative inverse of e (mod ϕ(n))
ie, (d * e) mod ϕ(n) = 1 We have (D * 5) mod (7-1) * (17-1) = 1
i.e. (d * 5) mod 96 = 1
We can use Extended Euclid algorithm to find the multiplicative inverse of 5 mod 96.
d=77, So that (77 * 5) mod (96) = 385 mod 96 = 1
2. Public key = ( 119, 5)
3. Private key is 77
23. RSA Algorithm - Example
● Encryption – Sender Side -
Alice
− P = 10
− Public key = (119, 5)
− C = 105
mod 119
− = 100000 mod 119
− = 40.
− Send C=40 to the receiver.
● Decryption – Receiver Side
− Cipher Text Received = 40
− Private key d = 77
− Plaintext P is calculated as
● P = 4077
mod 119
● = 10.
24. Proof of RSA
● The private key d is unique and d must be co-prime to ɸ (n)
● Proof :
− We have taken e such that e and ɸ (n) are co-prime.
− Therefore, there exists only one unique integer d, such that ed mod ɸ (n) = 1 .
− We have to prove d is unique
● Assume that d is not co-prime so t is the greatest common divisor of d and ɸ (n)
● Let d = c1* t and ɸ (n) = c2* t.
● From ed mod ɸ(n) = 1. We know ed = c3 * ɸ (n) + 1 for some integer c3 .
● Hence: e * c1* t = c3 *c2 * t + 1
● t(e * c1- c3 * c2)=1
− Therefore t=1.
● Hence it is proved that the private key d is unique and co-prime with ɸ (n) .
25. Proof of RSA
● Let C be the ciphertext recieved by Bob.
● Bob Computes the plaintext as P1.
● We have to prove that P1 = P
− Bob Computes P1 as P1 = Cd
(mod n)
− i.e. P1 = (Pe
)d
(mod n)
− = Ped
(mod n)
− ed = k * ɸ(n) + 1 (Since, ed (mod ɸ(n) = 1)
− P1 = Pk * ɸ(n) + 1
(mod n)
− = P mod n = P
− Hence Proved.
26. Attacking RSA
● Brute force attacks: try all possible private keys
− As in the other cases defend using large keys: nowadays integers between 1024 and
2048 bits
● Mathematical attacks
− Factor n into its two primes p,q: this is a hard problem for large n
− Determine φ(n) directly without first determining p,q: this math problem is
equivalent to factoring
− Determine d directly, without first determining φ(n): this is believed to be at least as
difficult as factoring
27. Attacking RSA
● Timing attacks:
− determine a private key by keeping track of how long a computer
takes to decipher a message (ciphertext-only attack) –this is
essentially an attack on the fast exponentiation algorithm but can be
adapted for any other algorithm
− Whenever a bit is 1 the algorithm has more computations to do and
takes more time
28. Timing Attack - Countermeasures
● Countermeasures:
− Ensure that all exponentiations take the same time before returning a result: degrade
performance of the algorithm
− Add some random delay: if there is not enough noise the attack succeeds
− Blinding: multiply the ciphertext by a randomnumber before performing exponentiation
–in this way the attacker does not know the input to the exponentiation algorithm.
● Choose r between 1 to n-1.
● C1 = C * re
mod n
● P1 = C1d
mod n
● P = P1 * r-1
mod n