Chapter_5_Notes
Chapter_5_Notes
Chapter 5
IT 810
Cryptography Public key
and Cryptography and
Network Security RSA
Public Key Cryptosystem evolved from an attempt to solve two of the most • Asymmetric Key Cryptosystem OR Public key Cryptosystem
difficult problems associated with Symmetric Encryption • One key for Encryption and a different but related key for Decryption
1. Key Distribution under Symmetric Encryption requires • Public Key Cryptosystem/Algorithm – Following Characteristics
• That two communicants already share a key, which somehow has been • It is computationally infeasible to determine the decryption key given only
distributed to them knowledge of the cryptographic algorithm and the encryption key
- Non repudiation • Either of the two related keys can be used for encryption, with the other used for
decryption
• The use of a key distribution center – If KDC is compromised
• A Public-Key Encryption scheme has Six Ingredients
How to have secure communications in general without having to trust a KDC with your
key?? • Plaintext – readable message or data that is fed as input
• Encryption Algorithm – Performs various transformations on plaintext
Encryption with Receivers Public Key • Encryption with Senders Private Key
- Achieve Confidentiality • Achieve Authentication
5 6
1
• The essential steps are the following:
1. Each user generates a Pair of Keys to be used for the encryption and decryption
2. Each user places one of the two keys in a public register or other accessible file (This
is the public key). The companion key is kept private. Each user maintains a
collection of public keys obtained from others.
3. If Bob wishes to send a confidential message to Alice, Bob encrypts the message
using Alice's public key.
4. When Alice receives the message, she decrypts it using her private key. No other
recipient can decrypt the message because only Alice knows Alice's private key
7 8
• Source - With the message X and the encryption Key Pub (public key of • Source - With the message X and the encryption Key PRa (Private key of source
Destination B ) as input A ) as input
• Source A forms the Ciphertext Y which is given by • Source A forms the Ciphertext Y which is given by
• Destination B in possession of the matching private key PRb is able to invert • Destination B in possession of the matching public key PUa is able to invert the
the transformation transformation
Authenticated in terms of
Source & Data Integrity
9 10
Public Key Cryptosystem : Both Authentication and Secrecy Applications for Public Key Cryptosystem
• How to Provide both Authentication and Secrecy? • Encryption/ Decryption
• Double use of public key scheme • Sender encrypts the message with the recipients public key
• 1. Source - Encrypt the message X with its own Private Key PRa => Y • Digital Signature
• Provides Digital Signature • The sender “signs” a message with its private key
• 2. Source – Again encrypts Y by using public key PUb of destination => Z • Signing is achieved by a cryptographic algorithm applied to the message
• Provides Secrecy or Confidentiality • Key Exchange -
•The Final Ciphertext • Two sides cooperate to exchange a session key
can be decrypted only
by the intended recei- Some algorithms are suitable for all three applications, whereas others can be used only for
one or two of these applications
ver, who alone has the
Matching key
11 12
2
Requirement of Public Key Cryptography
1. It is computationally easy for a party B to generate a pair (PUb, PRb ) One Way Function:
is one that maps a domain into a range such that every function value has a unique
2. It is computationally easy for a sender A, knowing the public key and the message to be inverse, with the condition that the calculation of the function is easy, whereas the
encrypted M, to generate the corresponding Ciphertext: calculation of the inverse is infeasible
3. It is computationally easy for the receiver B to decrypt the resulting Ciphertext using the
private key to recover the original Message Trap Door One-way Function:
is easy to calculate in one direction and infeasible to calculate in the other direction
4. It is computationally infeasible for an adversary, knowing the public key PUb, to unless certain additional information is known. With the additional information the
determine the private key PRb inverse can be calculated in polynomial time
5. It is computationally infeasible for an adversary, knowing the public key PUb and a
ciphertext, C to recover the original message M
6. The two keys can be applied in either order Thus the development of a practical public-key scheme depends on discovery of a suitable
13 trap-door one-way function 14
2. Another attack - To find some way to compute the private key given the public key. • Use Large Integers – 1024 bits or 309 decimal digits
- To date, it has not been mathematically proven that this form of attack
is infeasible for a particular public-key algorithm
• Based on Exponentiation in finite field over Integers modulo a prime
An integer p > 1 is a
prime number if and
RSA Algorithm RSA Algorithm- Example only if its only divisors
are ±1 and are ± p
3
4. Select e such that e is relatively prime Ø (n) = 160 and less than Ø (n) 5. Determine d such that d x e 1 (mod 160) and d < 160
should satisfy Relative prime property =>> gcd ( Ø (n), e ) = 1
and 1 < e < Ø (n) The correct value is d = 23 because 23 × 7 = 161 = (1 × 160) + 1
How to select e and check whether they are relatively prime ?? d can be calculated using the extended Euclid’s algorithm
Let select e = 7 Extended Euclidian Algorithm => used to find Multiplicative Inverse of a given number
Euclidian Algorithm => used to find gcd of two positive integers -Only for First Time T1 =0 ; T2 = 1
We need to verify gcd ( 160, 7 ) = 1 T = T1 - (T2 x Q) Q A B R T1 T2 T
The algorithm assumes a > b > 0 T = 0 - (1 x 22) = -22 22 160 7 6 0 1 -22
Q A B R
T = 1 - (-22 x 1) = 1 + 22 = 23 1 7 6 1 1 -22 23
22 160 7 6
6 6 1 0 -22 23 -160
1 7 6 1 T = -22 - (23 x 6) = -22 -138 =-160
6 6 1 0 X 1 0 X 23 -160
X 1 0 X Multiplicative inverse of 7 is 23
19 20
n = 187 e= 7 d = 23
• The resulting keys are public key PU = {e , n} =>> {7, 187} and
• Encryption
7
• Let Plaintext = 88 C = 88 mod 187
• Exploiting the properties of Modular arithmetic =>>
21 22
23 24
4
Computational Aspects of RSA Computational Aspects of RSA
1. Exponentiation in Modular Arithmetic: 3. Efficient Operation Using Private Key:
Example1:
• We cannot similarly choose a small constant value of d for efficient operation
• A small value of d is vulnerable to a brute-force attack and to other forms of
• Fast efficient tech for exponentiation is required cryptanalysis
• Example - Requires 15 times multiplications • However, there is a way to speed up computation using the CRT (Chinese Remainder
How to proceed?? Theorem) --This is approx 4 times faster than calculating “Cd mod n” directly
we can achieve the same final result with only four multiplications if we repeatedly • Note that only the owner of the private key details (who knows the values of p & q)
take the square of each partial result, successively forming (x2, x4, x8, x16) can use this technique
With presently known algorithms, determining d given e and n appears to be at least as time-
consuming as the factoring problem. Hence, we can use factoring performance as a
benchmark against which to evaluate the security of RSA
27 28
To avoid values of n that may be factored more easily, the algorithm’s inventors
suggest the following constraints on p and q
In addition, it has been demonstrated that if e < n and d < n1/4, then d can be easily
determined
29 30
5
Timing Attack
-Therefore, if the observed time to execute the decryption algorithm is always slow
when this particular iteration is slow with a 1 bit, then this bit is assumed to be 1.
-If a number of observed execution times for the entire algorithm are fast, then this bit
is assumed to be 0
Countermeasures ??
31 32
2. Add Random delays: For Example : Takes advantage of the following property of RSA
- Better performance could be achieved by adding a random delay to the E(PU,M1) × E(PU,M2) = E(PU, [M1 × M2])
exponentiation algorithm to confuse the timing attack
We can decrypt C = Me mod n using a CCA as follows
1. Compute X = (C × 2e) mod n
3. Blinding: Blind values used in calculations 2. Submit X as a chosen ciphertext and receive back Y = Xd mod n
- Multiply the ciphertext by a random number before performing exponentiation But now note that
- This process prevents the attacker from knowing what ciphertext bits are being
processed inside the computer and therefore prevents the bit-by-bit analysis
essential to the timing attack
Countermeasure - Plaintext is modified using a procedure known as Optimal Asymmetric - The concatenation of the maskedseed and the maskedDB forms the Encoded Message EM
Encryption Padding (OAEP) -Note that the EM includes the padded message, masked by the seed, and the seed, masked
As a first step the message M to be encrypted by the maskedDB
is padded - The EM is then encrypted using RSA
-A set of optional parameters P is passed through
a hash function H
- The output is then padded with zeros to get the
desired length in the overall data block (DB)
- random seed is generated and passed through
another hash function, called the mask
generating function (MGF)
The resulting hash value is bit-by-bit XORed with
DB to produce a maskedDB
- The maskedDB is in turn passed through the
MGF to form a hash that is XORed with the seed
35 36
to produce the masked seed