You are on page 1of 99

Information

Security
(3170720)
UNIT 4: PUBLIC KEY C R Y P TO S Y S T E M S WITH A P P L I C AT I O N S ,
R EQ U I R E M E N T S AND C R Y P TA N A LY S I S , RSA A LG O R I T H M , ITS
C O M P U TAT I O N A L ASPECTS AND S E C U R I T Y, DIFFIE-HILLMAN KEY
E XC H A N G E A LG O R I T H M , M A N - I N - M I D D L E AT TA C K
R E F E R E N C E B O O K - C R Y P TO G R A P H Y A N D N E T W O R K S E C U R I T Y, P R I N C I P L E S
A N D P R A C T I C E S I X T H E D I T I O N , W I L L I A M S TA L L I N G S , P E A R S O N
CHAPTER -9 AND CHAPTER -10
Road Map

 Public Key Cryptosystems with Applications


 Requirements and Cryptanalysis
 RSA algorithm, its computational aspects and
security
 Diffie-Hillman Key Exchange algorithm
 Man-in-Middle attack
Problem with Symmetric Cryptography

Key Distribution Problem (confidentiality)


 The Two communicating parties must somehow share a secret key
before any secure communication can be initiated, and both parties
must then ensure that the key remains secret.
 It requires either (1) that two communicants already share a key,
which somehow has been distributed to them; or (2) the use of a key
distribution center.
 In symmetric cryptography a secret key is used to encrypt as well as
decrypt the message. So, this key must be shared by both the
communicating parties by any means or they must rely on a third
party for the distribution of the key i.e. key distribution centre. But
relying on a third party again risk the secrecy of the secret key.
Problem with Symmetric Cryptography

Trust Problem (Authentication)


 Symmetric key also had an issue with
authentication.
 To become widespread there was a need for
digital signatures that assure all parties that a
particular message has been sent from a
particular person.

The public key cryptosystem is successful in achieving both these


principles i.e. confidentiality and authenticity
Conventional Cryptography till 1976
Secret Key systems

Sender Ciphering De-Ciphering Receiver

Y = E (Z,X)
X E ( Z,X ) D ( Z,Y ) X
Message Channel Message

Z Z
Public-Key system
drops that part completely
Secret Key Channel

Secret Key = Z
Known lock
Public key Cryptosystems
 Public Key Cryptography is a cryptographic technique that involves
‘two distinct keys’ for encryption and decryption.
 That’s why it is also known as asymmetric-key cryptography.
 It is not that symmetric key cryptosystem is less efficient than public
key or the public key cryptosystem is superior.
 The security of any cryptosystem depends only the length of key and
computation required in cracking the encrypted cipher text.
 These algorithms have the following important characteristic.

It is computationally infeasible to determine the decryption key given


only knowledge of the cryptographic algorithm and the encryption key.

In addition, some algorithms, such as RSA, also exhibit the following characteristic
Either of the two related keys can be used for encryption, with the
other used for decryption.
Public key Cryptosystems
 Each user generates a pair of keys to be used for the
encryption and decryption  each user have two keys
 Each user places one of the two keys in a public register or
other accessible file the public key
 The other key is kept private, which is the private key
 Either of the two related keys can be used for encryption, with
the other used for decryption.
Public key Cryptosystems
 A public-key encryption scheme has six ingredients
 Plaintext
 Encryption algorithm
 Public key
 Private key
 Cipher text
 Decryption algorithm
Public key Cryptosystems (Encryption with public key)
Public key Cryptosystems
The essential steps are the following.
1. Each user generates a pair of keys to be used for the
encryption and decryption of messages.
2. Each user places one of the two keys in a public register or
other accessible file. This is the public key. The other 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.
Public key Cryptosystems (Encryption with private key)
Encryption with public key: Secrecy
Encryption with public key: Secrecy
 B generates a related pair of keys: a public key, PUb, and a private key, PRb.
PRb is known only to B, whereas PUb is publicly available and therefore
accessible by A.
 With the message X and the encryption key PUb as input, A forms the
ciphertext Y , given by Y = E(PUb, X)
 Receiver in possession of the matching private key PRb, is able to invert the
transformation X = D(PRb,Y)
 An adversary, observing Y and having access to PUb, but not having access to
PRb or X, must attempt to recover X and/or PRb
 It is assumed that the adversary does have knowledge of the encryption (E)
and decryption (D) algorithms.
 If the adversary is interested only in this particular message, then the focus
of effort is to recover X by generating a plaintext estimate Xn .
 Often, however, the adversary is interested in being able to read future
messages as well, in which case an attempt is made to recover PRb by
generating an estimate
Encryption with private key: Authentication
Encryption with private key: Authentication
 A encrypts it using A’s private key before transmitting it.
Y = E(PRa,X)
 B can decrypt the message using A’s public key.
X = D(PUa,Y)
 Only A could have prepared the message, Therefore, the entire
encrypted message serves as a digital signature.
 In addition, it is impossible to alter the message without access
to A’s private key
 The message being sent is safe from alteration.
 But not confidentiality because any observer can decrypt the
message by using the sender’s public key
Public-Key Cryptosystem: Authentication and Secrecy
 It is important to emphasize that the encryption process using
private key does not provide confidentiality and the
encryption process using public key does not provide
authentication
 It is, however, possible to provide both the authentication
function and confidentiality by a double use of the public-key
scheme
Z = E(PUb, E(PRa,X))
X = D(PUa, D(PRb, Z)
Public-Key Cryptosystem: Authentication and Secrecy
Public-Key Cryptosystem: Authentication and Secrecy
Public-Key Cryptosystem: Authentication and Secrecy
 In this case, we begin as before by encrypting a message, using
the sender’s private key.  provides the digital signature.
 Next, we encrypt again, using the receiver’s public key.
 The final ciphertext can be decrypted only by the intended
receiver, who alone has the matching private key. Thus,
confidentiality is provided.
 The disadvantage of this approach is that the public-key
algorithm, which is complex, must be exercised four times
rather than two in each communication.
Application for Public-Key Cryptosystem
Public-Key Cryptanalysis
 Vulnerable to a brute-force attack –
 To prevent the brute force attack the key size must be kept large
enough so that it would be impractical for an adversary to calculate the
encryption and decryption.
 But the key size should not be so large such that it would become
impractical to compute practical encryption and decryption.
 Another type of attack  adversary would try to compute private key
knowing the public key.
 Probable message attack.
 If an adversary knows that the encrypted message from a particular
sender is a 56-bit key.
 Then he would simply encrypt all possible 56-bit keys using the sender’s
public key as the public key is known to all. And then match all the
encrypted messages with the cipher text.
 This type of attack can be prevented by appending some random bits
to the original message.
Convention and Public-Key Encryption
RSA Algorithm
 Invented by Rivest, Shamir & Adleman of MIT in 1977 and
published in 1978.
 It is a best known & widely used public-key scheme.
 It is a block cipher algorithm in which plaintext and ciphertext
integers between 0 to n-1 for some n.
 A typical size for n is 1024 bits or 309 decimal digits i.e.
( n < 21024).
 Each block would be represented by an integers
RSA Algorithm
 RSA makes use of an expression with exponentials.
 Each block having a binary value less than some number n. That is,
the block size must be less than or equal to log2(n) + 1; in practice,
the block size is i bits, where 2i < n ≤ 2i+1.

 Both sender and receiver must know the value of n.


RSA Algorithm steps

Plain
Text Core
Element
Step 1: Generate Public and Private Key
Select two large prime number p and q (pq)
Compute n= p*q (n is called the modulus and it is public Its
length denotes the key length)
Compute Euler’s totient function (n)= (p-1) * (q-1)
Choose e, such that 1 < e < (n) and gcd(e, (n)) = 1 i.e. e is
relatively prime to (n) (e is released as public exponent)
Compute d such that d*e  1 mod (n)  d*e mod (n) = 1
(multiplicative inverse of mod)
Public key : PU = {e, n}
Private key : PR = {d,n}
Euler’s Totient function
 Totient function (n)
 Number of positive numbers less than n that are relatively
prime to n
• Two numbers are relatively prime when their greatest
common divisor is 1

 Example: (10) = 4
 1, 3, 7, 9

 Example: (7) = 6
 1, 2, 3, 4, 5, 6

 If n is prime, (n) = n-1


How to calculate multiplicative inverse modulo
Method 1: using Extended Euclidian Algorithm
Take t1=0 and t2=1
And t= t1 –q*t2
Solve until r2 = 0 when r2=0 value of t1 will be multiplicative
inverse
11 *x mod 26 =1

q r1 r2 r t1 t2 t
26 11 0 1
How to calculate multiplicative inverse modulo
Method 1: using Extended Euclidian Algorithm
Take t1=0 and t2=1
And t= t1 –q*t2
Solve until r2 = 0 when r2=0 value of t1 will be multiplicative
inverse
11 *x mod 26 =1

q r1 r2 r t1 t2 t
2 26 11 4 0 1
How to calculate multiplicative inverse modulo
Method 1: using Extended Euclidian Algorithm
Take t1=0 and t2=1
And t= t1 –q*t2
Solve until r2 = 0 when r2=0 value of t1 will be multiplicative
inverse
11 *x mod 26 =1 T=t1-q*t2
= 0-2*1
=-2

q r1 r2 r t1 t2 t
2 26 11 4 0 1 -2
How to calculate multiplicative inverse modulo
Method 1: using Extended Euclidian Algorithm
Take t1=0 and t2=1
And t= t1 –q*t2
Solve until r2 = 0 when r2=0 value of t1 will be multiplicative
inverse
11 *x mod 26 =1

q r1 r2 r t1 t2 t
2 26 11 4 0 1 -2
11 4 1 -2
How to calculate multiplicative inverse modulo
Method 1: using Extended Euclidian Algorithm
Take t1=0 and t2=1
And t= t1 –q*t2
Solve until r2 = 0 when r2=0 value of t1 will be multiplicative
inverse
11 *x mod 26 =1 T=t1-q*t2
= 1-2*(-2)
=5

q r1 r2 r t1 t2 t
2 26 11 4 0 1 -2
2 11 4 3 1 -2 5
How to calculate multiplicative inverse modulo
Method 1: using Extended Euclidian Algorithm
Take t1=0 and t2=1
And t= t1 –q*t2
Solve until r2 = 0 when r2=0 value of t1 will be multiplicative
inverse
11 *x mod 26 =1

q r1 r2 r t1 t2 t
2 26 11 4 0 1 -2
2 11 4 3 1 -2 5
4 3 -2 5
How to calculate multiplicative inverse modulo
Method 1: using Extended Euclidian Algorithm
Take t1=0 and t2=1
And t= t1 –q*t2
Solve until r2 = 0 when r2=0 value of t1 will be multiplicative
inverse
11 *x mod 26 =1 T=t1-q*t2
= (-2)-1*(5)
=-7

q r1 r2 r t1 t2 t
2 26 11 4 0 1 -2
2 11 4 3 1 -2 5
1 4 3 1 -2 5 -7
How to calculate multiplicative inverse modulo
Method 1: using Extended Euclidian Algorithm
Take t1=0 and t2=1
And t= t1 –q*t2
Solve until r2 = 0 when r2=0 value of t1 will be multiplicative
inverse
11 *x mod 26 =1

q r1 r2 r t1 t2 t
2 26 11 4 0 1 -2
2 11 4 3 1 -2 5
1 4 3 1 -2 5 -7
3 1 5 -7
How to calculate multiplicative inverse modulo
Method 1: using Extended Euclidian Algorithm
Take t1=0 and t2=1
And t= t1 –q*t2
Solve until r2 = 0 when r2=0 value of t1 will be multiplicative
inverse
11 *x mod 26 =1 T=t1-q*t2
= (5)-3*(-7)
=26

q r1 r2 r t1 t2 t
2 26 11 4 0 1 -2
2 11 4 3 1 -2 5
1 4 3 1 -2 5 -7
3 3 1 0 5 -7 26
How to calculate multiplicative inverse modulo
Method 1: using Extended Euclidian Algorithm
Take t1=0 and t2=1
And t= t1 –q*t2
Solve until r2 = 0 when r2=0 value of t1 will be multiplicative
inverse
11 *x mod 26 =1
Multiplicative inverse modulo is 19 (t1 is negative hence add mod
value  -7+26 = 19)
q r1 r2 r t1 t2 t
2 26 11 4 0 1 -2
2 11 4 3 1 -2 5
1 4 3 1 -2 5 -7
3 3 1 0 5 -7 26
1 5
0 -7
How to calculate multiplicative inverse modulo
Method 2: e*d mod (n) =1

d= (((n) *I ) +1)/e

11 *x mod 26 =1

(26*1 +1)/11 = 2.45


(26*2+1)/11 = 4.73
(26*3+1)/11 =7.09
..

(26*8+1)/11 =19 (continue until result becomes integer value)


Step 2: Encryption using Public key
Step 3: Decryption using Private key
RSA Example - 1
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

Step1: Key generation

1) Calculate N
N=p*q = 3*11=33

2) Calculate Euler’s tutient function (N) = (p-1) * (q-1) = 2*10 =20

3) Select e such that e is relatively prime to (N) and 1 < e < (N)

We have a choice for e: 7, 11, 13, 17, 19, let’s take e=7

4) Find d such that d*e  1 (mod (N))


RSA Example - 1
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

4) Find d such that d*e  1 (mod (N))

Here, 7 * d  1 (mod 20)

Method 2:
d= (20*1 +1)/7 = 3  hence d=3
RSA Example - 1
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

4) Find d such that d*e  1 (mod (N))

Here, 7 * d  1 (mod 20)

Method 2:
d= (20*1 +1)/7 = 3  hence d=3
RSA Example - 1
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

Step 2: Encryption using PU {7, 33}

C= Me mod n
= (14)7 mod 33
= [141 mod 33 * 142 mod 33 * 144 mod 33 ] mod 33
= (14*31*4) mod 33
= 20
RSA Example - 1
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

Step 3: Decryption using PR {3, 33}

P= Cd mod n
= (20)3 mod 33
= [201 mod 33 * 202 mod 33]mod 33
= (20*4) mod 33
= 14
RSA Example - 2
Consider p=7 and q= 19, demonstrate encryption and decryption for
M=6.

Step1: Key generation

1) Calculate N
N=p*q = 7*19=133

2) Calculate Euler’s tutient function (N) = (p-1) * (q-1) = 6*18 =108

3) Select e such that e is relatively prime to (N) and 1 < e < (N)

Let’s take e=5 (GCD(5, 108) =1)

4) Find d such that d*e  1 (mod (N))


RSA Example - 2
Consider p=7 and q= 19, demonstrate encryption and decryption
for M=6.

4) Find d such that d*e  1 (mod (N))

Here, 5 * d  1 (mod 108)

Method 2:

= (108*1 +1)/5 = 21.8 (i=1)


= (108*2 +1)/5 = 43.4 (i=2)
=(108*3 +1)/5 =65  integer Hence d=65

PU = {e, n}= {5, 133}


PR = {d, n} = {65,133}
RSA Example - 2
Consider p=7 and q= 19, demonstrate encryption and decryption
for M=6.

Step 2: Encryption using PU {5, 133}


C= Me mod n
= (6)5 mod 133
= (7776) mod 33
= 62
RSA Example - 2
Step 3: Decryption using PR {65, 133}
P= Cd mod n = 6265 mod 133
Initially , X=1
M=62 If bit =0 then (X2 mod n)
Step 1: write down key (d) in binary form Otherwise ((X2 mod n)* M) mod n

64 32 16 8 4 2 1
1 0 0 0 0 0 1
62

Bit =1 hence ((X2 mod n) *M) mod n)


=(( 12 mod 133)* 62) mod 133
=62 mod 133
= 62
RSA Example - 2
Step 3: Decryption using PR {65, 133}
P= Cd mod n = 6265 mod 133
Initially , X=1
M=62 If bit =0 then (X2 mod n)
Step 1: write down key in binary form Otherwise ((X2 mod n)* M) mod n

64 32 16 8 4 2 1
1 0 0 0 0 0 1
62 120

Bit =0 hence X2 mod n


= 622 mod 133
=3844 mod 133
= 120
RSA Example - 2
Step 3: Decryption using PR {65, 133}
P= Cd mod n = 6265 mod 133
Initially , X=1
M=62 If bit =0 then (X2 mod n)
Step 1: write down key in binary form Otherwise ((X2 mod n)* M) mod n

64 32 16 8 4 2 1
1 0 0 0 0 0 1
62 120 36

Bit =0 hence X2 mod n


= 1202 mod 133
=14400 mod 133
= 36
RSA Example - 2
Step 3: Decryption using PR {65, 133}
P= Cd mod n = 6265 mod 133
Initially , X=1
M=62 If bit =0 then (X2 mod n)
Step 1: write down key in binary form Otherwise ((X2 mod n)* M) mod n

64 32 16 8 4 2 1
1 0 0 0 0 0 1
62 120 36 99

Bit =0 hence X2 mod n


= 362 mod 133
= 1296 mod 133
= 99
RSA Example - 2
Step 3: Decryption using PR {65, 133}
P= Cd mod n = 6265 mod 133
Initially , X=1
M=62 If bit =0 then (X2 mod n)
Step 1: write down key in binary form Otherwise ((X2 mod n)* M) mod n

64 32 16 8 4 2 1
1 0 0 0 0 0 1
62 120 36 99 92

Bit =0 hence X2 mod n


= 992 mod 133
= 9801 mod 133
= 92
RSA Example - 2
Step 3: Decryption using PR {65, 133}
P= Cd mod n = 6265 mod 133
Initially , X=1
M=62 If bit =0 then (X2 mod n)
Step 1: write down key in binary form Otherwise ((X2 mod n)* M) mod n

64 32 16 8 4 2 1
1 0 0 0 0 0 1
62 120 36 99 92 85

Bit =0 hence X2 mod n


= 922 mod 133
= 8464 mod 133
= 85
RSA Example - 2
Step 3: Decryption using PR {65, 133}
P= Cd mod n = 6265 mod 133
Initially , X=1
M=62 If bit =0 then (X2 mod n)
Step 1: write down key in binary form Otherwise ((X2 mod n)* M) mod n

64 32 16 8 4 2 1
1 0 0 0 0 0 1
62 120 36 99 92 85 6
Bit =1 hence (X2 mod n) *M mod n
= ((852 mod 133)* 62) mod 133
= ((7225 mod 133)*62) mod 133
= (43*62) mod 133
= 2666 mod 133
=6

Decrypted Text: 6
GTU Summer 2019 – 4 Marks

GTU Winter 2016 – 7 Marks

GTU Winter 2019 – 7 Marks


GTU Question
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

Step1: Key generation

1) Calculate N
N=p*q = 5*7=35

2) Calculate Euler’s tutient function (N) = (p-1) * (q-1) = 4*6 =24

3) e=11 (Encryption Key Given)

4) Find d such that d*e  1 (mod (N))


GTU Question
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

4) Find d such that d*e  1 (mod (N))

Here, 11 * d  1 (mod 24)

Method 2:
d= (24*1 +1)/11 = 2.27
d= (24*2 +1)/11 = 4.45
d= (24*3 +1)/11 = 6.63
d= (24*4 +1)/11 = 8.18
d= (24*5 +1)/11 = 11  hence d=11
GTU Question
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

Step 2: Encryption using PU {11,35 }

C= Me mod n
= (2)11 mod 35
= [26 mod 35 * 25 mod 35] mod 35
= (29 * 32) mod 35
= 18
GTU Question
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

Step1: Key generation

1) Calculate N
N=7*17 = 7*17=119

2) Calculate Euler’s tutient function (N) = (p-1) * (q-1) = 6*16 =96

3) e=7 (Encryption Key Given)

4) Find d such that d*e  1 (mod (N))


GTU Question
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

4) Find d such that d*e  1 (mod (N))

Here, 7* d  1 (mod 96)

Method 2:
d= (96*1 +1)/7 = 13.86
d= (96*2 +1)/7 = 27.57
d= (96*3 +1)/7 = 41.28
d= (96*4 +1)/7 = 55 hence d= 55
GTU Question
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

Step 2: Encryption using PU {7,119 }


Let M=2

C= Me mod n
= (2)7 mod 119
= 128 mod 119
= 9
GTU Question
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

Step1: Key generation

1) Calculate N
N=7*17 = 7*17=119

2) Calculate Euler’s tutient function (N) = (p-1) * (q-1) = 6*16 =96

3) e=5 (Encryption Key Given)

4) Find d such that d*e  1 (mod (N))


GTU Question
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

4) Find d such that d*e  1 (mod (N))

Here, 5* d  1 (mod 96)

Method 2:
d= (96*1 +1)/5 = 19.4
d= (96*2 +1)/5 = 38.6
d= (96*3 +1)/5 = 57.8
d= (96*4 +1)/5 = 77  hence d= 77
GTU Question
Consider p=3 and q= 11, demonstrate encryption and decryption
for M=14.

Step 2: Encryption using PU {5,119 }

C= Me mod n
= (6)5 mod 119
= 7776 mod 119
= 41
RSA Example
 p=7, q=11
• N=77
• (N) = (6)(10) = 60
 Bob chooses e=17

 Uses extended Euclidean algorithm to find inverse of e mod 60


 Finds d=53

 Bob makes {77, 17} public


RSA Example
 Alice wants to send Bob “HELLO WORLD”

 Represent each letter as a number 00(A) to 25(Z)


• 26 is a space

 Calculates:
0717 mod 77 = 28, 0417 mod 77 = 16, …, 0317 mod 77 = 75

 Sends Bob 28 16 44 44 42 38 22 42 19 44 75

 He decrypts each number with his private key and gets “HELLO
WORLD”
Computational Aspects of RSA
 There are actually two issues to consider:
1. Encryption/Decryption Process
2. key generation.

1. Encryption / Decryption Process


 Raising an integer to an integer power mod n (Me, Cd)
 Need of fast exponentiation algorithms
 Useful property of modular arithmetic:
(a x b) mod n = [(a mod n) x (b mod n)] mod n
2. Key Generation
 Finding Large Prime Numbers (p , q)
 Currently, no useful techniques to yield arbitrarily large primes
 Generate a random odd number and test for primality
 Probabilistic algorithms (ex Miller-Rabin algorithm)
 Selecting either e or d and calculating the other
 Extended Euclid’s algorithm
Security of RSA
 Five possible approaches to attacking the RSA algorithm are

1. Brute force attack: This involves trying all possible private keys.
• Not feasible for large key
• Actually no body attack RSA in this way
2. Mathematical attacks:
• There are several approaches, all equivalent in effort to
factoring the product of two primes.
3. Timing attacks:
• These depend on the running time of the decryption
algorithm.
4. Hardware fault-based attack: This involves inducing hardware
faults in the processor that is generating digital signatures.
5. Chosen ciphertext attacks: This type of attack exploits
properties of the RSA algorithm.
Security of RSA – Mathematical Attacks
 There are three approached to attacking RSA mathematically

1. Factor n = p* q (two prime numbers) hence calculate (n)


and then d
2. Determine (n) directly (without p and q) and find d (is
equivalent of factoring n)
3. Determine d directly without first determining (n) ( as
difficult as factoring n)

 So RSA cryptanalysis is focus on factorization of n.


Security of RSA – Mathematical Attacks
 Factoring is splitting an integer into a set of smaller integers
which, when multiplied together form the original integer.
 The problem: for example, 2*7 = 14
 The factoring problem is to find 2 and 7 when given 14
 Prime factorization requires splitting an integer into factors
that are prime numbers.
 However, none of existing factorization algorithms can factor a
large integer with polynomial time complexity.
 To be secure, RSA presently requires that n should be more
than 300 decimal digits, which means that the modulus must
be at least 1024 bits.
Security of RSA – Chosen Ciphertext attack
 The Basic RSA is vulnerable to a Chosen Ciphertext Attack (CCA)
attackers chooses ciphertexts & gets decrypted plaintext back.
 Chosen ciphertext attack try to exploit properties of RSA to
provide info to help cryptanalysis
 To counter such attack, modify plaintext with random padding
or use Optimal Asymmetric Encryption Padding (OASP).
Security of RSA – timing attack
 A side-channel attack is any attack based on information gained from
the implementation of a computer system, rather than weaknesses
in the implemented algorithm itself (e.g. cryptanalysis and software
bugs).
 Timing information, power consumption, electromagnetic leaks or
even sound can provide an extra source of information, which can be
exploited.
 Some side-channel attacks require technical knowledge of the internal
operation of the system.
 Timing attack — attacks based on measuring how much time various
computations (such as, say, comparing an attacker's given password
with the victim's unknown one) take to perform.
Security of RSA – timing attack
 A timing attack is a side-channel attack in which the attacker
attempts to compromise a cryptosystem by analyzing the time taken
to execute cryptographic algorithms.
 Every logical operation in a computer takes time to execute, and the
time can differ based on the input; with precise measurements of the
time for each operation, an attacker can work backwards to the
input.
 Finding secrets through timing information may be significantly easier
than using cryptanalysis of known plaintext, ciphertext pairs.
Security of RSA – timing attack
 RSA exploits time taken in exponentiation.
 Countermeasures (how to overcome)
 Use constant exponentiation time - Ensure that all
exponentiations take the same amount of time before returning a
result.
 Random Delay - add random delays to the exponentiations to
make each exponentiation take the same amount of time
 Blinding - blind values used in calculations -multiply the ciphertext
by a random number before decryption.
• 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.
Security of RSA – Fault based attack
 The approach is an attack on a processor that is generating RSA digital
signatures.
 The attack induces faults in the signature computation by reducing the
power to the processor.
 The faults cause the software to produce invalid signatures, which
can then be analyzed by the attacker to recover the private key.
 This attack does not appear to be a serious threat to RSA.
 It requires that the attacker have physical access to the target
machine and that the attacker is able to directly control the input
power to the processor.
 Controlling the input power would for most hardware require more
than simply controlling the AC power, but would also involve the
power supply control hardware on the chip.
RSA
Advantage

 RSA is stronger than any other symmetric key algorithm.


 RSA has overcome the weakness of symmetric algorithm i.e.
authenticity and confidentiality.

Disadvantage
 RSA has too much computation.
Diffie-Hellman Key Exchange
Diffie-Hellman Key Exchange
 The purpose of the algorithm is to enable two users to securely
exchange a secret key that can then be used for subsequent
symmetric encryption of messages.
 It is not used for encryption or decryption.
 A public-key distribution scheme
 cannot be used to exchange an arbitrary message
 rather it can establish a common key
 known only to the two participants
 Value of key depends on the participants (and their private and
public key information)
Diffie-Hellman Key Exchange
 All users agree on global parameters
 Large prime number (q)
 Primitive root of selected large prime number (α < q)
 primitive root of a prime number q is one whose powers
modulo q generate all the integers from 1 to q - 1.
 That is, if α is a primitive root of the prime number q,
then the numbers
α mod q, α2 mod q, ……, αq-1 mod q
 Let q= 7 then primitive root of 7 is 3 and 5. choose any
one of them
Diffie-Hellman Key Exchange setup
Global Public Elements

q prime number
α α < q and α is primitive root of q

User’s A Key Generation

Select private XA XA < q


Calculate public YA YA = αX mod q
A

User’s B Key Generation

Select private XB XB < q


Calculate public YB YB = αX mod q
B
Diffie-Hellman Key Exchange setup
Diffie-Hellman Key Calculation of Secret Key

Calculation of secret key by User A

K = (YB) X mod q
A

Calculation of secret key by User b

K = (YA) X mod q
B
Diffie-Hellman Key Exchange

User A: User B:
K= (YB)XA mod q K= (YA)XB mod q
=(XB)XA mod q =(XA)XB mod q
= (XB)XA mod q

Secret Key Generated by User A and User B are same (By equation)
Diffie-Hellman Key Exchange illustration
Diffie-Hellman Key Exchange Example
How to find primitive root of a prime number

5 is the smallest primitive root of prime no 157


How to find primitive root of a prime number

 Euler Totient Function (n) = n-1 [Assuming n is


prime]
 Find all prime factors of (n).
 Calculate all powers to be calculated further
using ((n) /prime-factors) one by one.
 Check for all numbered for all powers from i=2 to
n-1 i.e. (i^ powers) modulo n.
 If it is 1 then 'i' is not a primitive root of n.
GTU Question

Winter 2017 – 4 Marks

Summer 2019 – 4 Marks


Man in middle attack

Most serious weakness in Diffie-Hellman


Assumes Darth has ability to:
◦ Intercept messages between Alice and Bob
◦ Masquerade as Alice or Bob to send messages to the other

“I am Bob” “I am Alice”
Man in middle attack
Man in middle attack
Public-key cryptography is also known as ?
A. asymmetric cryptography
B. symmetric cryptography
C. Both A and B
D. None of the above

Euler’s totient function is determined by


A. Pq
B. (p-1)(q-1)
C. (p+1)(q+1)
D. p/q

In public key cryptosystem which is kept as public?


A. Decryption keys
B. Encryption keys
C. Encryption & Decryption keys
D. None of the above
Which of the following is based on”trap door one way” function?
A. Public key cryptosystem.
B. Public key.
C. Symmetric key.
D. Secret key.
In asymmetric key cryptography, the private key is kept by
a) sender
b) receiver
c) sender and receiver
d) all the connected devices to the network

In an efficient algorithm for factoring large number is discovered, which of the


Following schemes will be known to be not secure?
a) Diffle-Hellman
b) RSA
c) AES
d) None of the above

The symmetric (Shared) key in the Diffle-Hellman protocol is:


a) k = α xy and p
b) K = α xy mod q
c) K = (R2)x
d) All of the above
In the RSA algorithm, we select 2 random large values ‘p’ and ‘q’. Which of the
following is the property of ‘p’ and ‘q’?
a) p and q should be divisible by Ф(n)
b) p and q should be co-prime
c) p and q should be prime
d) p/q should give no remainder

In RSA, we select a value ‘e’ such that it lies between 0 and Ф(n) and it is relatively prime to
Ф(n).
a) True
b) False

For p = 11 and q = 19 and choose e=17. Apply RSA algorithm where message=5 and find
the cipher text.
a) C=80
b) C=92
c) C=56
d) C=23
Richard would like to digitally sign a message he’s sending to Sue so that Sue can be sure
the message came from him without modification while in transit. Which key should he
use to encrypt the message digest?
A. Richard's public key
B. Richard's private key
C. Sue's public key
D. Sue's private key

In the RSA public key cryptosystem, which one of the following numbers will
always be largest?
A. e
B. n
C. p
D. q

Richard received an encrypted message sent to him from Sue. Which key should
he use to decrypt the message?
A. Richard's public key
B. Richard's private key
C. Sue's public key
D. Sue's private key
__________ refers more to asymmetric key cryptography.
a. Timing attack.
b. Meet in middle attack.
c. Virus attack.
d. Worms attack.

The security of Diffie-Hellman key exchange relies on which assumption?


A. It is computationally infeasible to compute a GCD of two large numbers.
B. It is computationally infeasible to compute an inverse modulo prime p.
C. It is computationally infeasible to test whether a large number is prime.
D. It is computationally infeasible to solve the discrete log problem

What is the objective of Diffie-Hellman key exchange?


A. To protect encrypted data from man-in-the-middle attack
B. To perform mutual authentication on both sides
C. To prove to another party that one holds a secret key without revealing it
D. To establish a shared secret key on both sides

The security of RSA encryption relies on which assumption?


A. It is computationally infeasible to compute a GCD of two large numbers.
B. It is computationally infeasible to factor a large number.
C. It is computationally infeasible to test whether a large number is prime.
D. It is computationally infeasible to compute a square modulo n.

You might also like