0% found this document useful (0 votes)
68 views29 pages

UNIT-4 Asymmetric Ciphers

C = 105 mod 119 = 1055 mod 119 = 100 mod 119 = 81 Therefore, the cipher text value is 81.

Uploaded by

Ganesh Ghutiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views29 pages

UNIT-4 Asymmetric Ciphers

C = 105 mod 119 = 1055 mod 119 = 100 mod 119 = 81 Therefore, the cipher text value is 81.

Uploaded by

Ganesh Ghutiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

UNIT-4

Asymmetric
Ciphers
Outline
 Public Key Cryptosystems with Applications
 Requirements and Cryptanalysis
 RSA algorithm
 RSA computational aspects and security
 Diffie-Hillman Key Exchange algorithm
 Man-in-Middle attack

Unit-4 Asymmertic Ciphers 2


Symmetric key Encryption
Secret key shared by Secret key shared by
sender and recipient sender and recipient
K
K
Transmitted
cipher text
Y = E(K, X)
X X
Plaintext Encryption Algorithm Decryption Algorithm Plaintext
input (e.g. AES) (reverse of encryption output
algorithm)

Unit-4 Asymmertic Ciphers 3


Asymmetric key Encryption with Public Key
 The entire encrypted message
Bob’s
Public serves as a confidentiality.
Joy key ring
Ted
Mike Alice

PUa Alice’s public PRa Alice’s private


key key

Transmitted
X cipher text X
Y = E(PUa, X)
Plaintext Plaintext
input Encryption Algorithm Decryption Algorithm
output
(e.g. RSA)

Bob Alice
Asymmetric key Encryption with Private Key
 The entire encrypted message Alice’s
serves as a digital signature. Public
Joy key ring
Ted
Mike Bob

PRb Bob’s private PUb Bob’s public


key key

Transmitted
X cipher text X
Y = E(PRb, X)
Plaintext Plaintext
input Encryption Algorithm Decryption Algorithm
output
(e.g. RSA)

Bob Alice
Authentication and Confidentiality
Source A Source B

Message X Encryption Y Encryption Z Decryption Y Decryption X Message


source Algorithm Algorithm Algorithm Algorithm Dest.

PUb PRb
Key pair
PRa PUa source

Key pair
source

Z = E(PUb, E(PRa, X)) X = D(PUa, D(PRB, Z))

Unit-4 Asymmertic Ciphers 6


Applications for Public-Key Cryptosystems
 Encryption/decryption: The sender encrypts a message with the
recipient’s public key.
 Digital signature: The sender “signs” a message with its private
key. Signing is achieved by a cryptographic algorithm applied to
the message or to a small block of data that is a function of the
message.
 Key exchange: Two sides cooperate to exchange a session key.
Several different approaches are possible, involving the private
key(s) of one or both parties.

Unit-4 Asymmertic Ciphers 7


RSA Algorithm
 RSA is a block cipher in which the Plaintext and Ciphertext are
represented as integers between 0 and n-1 for some n.
 Large messages can be broken up into a number of blocks.
 Each block would then be represented by an integer.

Step-1: Generate Public key and Private key


Step-2: Encrypt message using Public key
Step-3: Decrypt message using Private key

Unit-4 Asymmertic Ciphers 8


Step-1: Generate Public key and Private key
 Select two large prime numbers: p and q
 Calculate modulus : n = p * q
 Calculate Euler’s totient function : φ(n) = (p-1) * (q-1)
 Select e such that e is relatively prime to φ(n) and 1 < e < φ(n)

Two numbers are relatively prime if they have no common factors


other than 1.

 Determine d such that d * e ≡ 1 (mod φ(n))


 Publickey : PU = { e, n }
 Privatekey : PR = { d, n }

Unit-4 Asymmertic Ciphers 9


Step-1: Generate Public key and Private key
 Select two large prime numbers: p = 3 and q = 11
 Calculate modulus : n = p * q, n = 33
 Calculate Euler’s totient function : φ(n) = (p-1) * (q-1)
φ(n) = ( 3 – 1 ) * ( 11 – 1 ) = 20
 Select e such that e is relatively prime to φ(n) and 1 < e < φ(n)
 We have several choices for e : 7, 11, 13, 17, 19 Let’s take e = 7
 Determine d such that d * e ≡ 1 (mod φ(n))
• This is equivalent to
 ? * 7 ≡ 1 (mod 20), 3 * 7 ≡ 1 (mod 20) finding d which satisfies
de = 1 + j.φ(n) where j is
 Public key : PU = { e, n } , PU = { 7, 33 } any integer.
• We can rewrite this as
 Private key : PR = { d, n }, PR = { 3, 33 } d = (1 + j. φ(n)) / e
Unit-4 Asymmertic Ciphers 10
Step-2 : Encrypt Message
 Encryption Using Public key: C = Me mod n

Ciphertext Input Publickey


Message

PU = { e, n } , PU = { 7, 33 }
For message M = 14
C = 147 mod 33
C = [(141 mod 33) X (142 mod 33) X (144 mod 33)] mod 33
C = (14 X 31 X 4) mod 33 = 1736 mod 33
C = 20
Unit-4 Asymmertic Ciphers 11
Step-3 : Decrypt Message
 Encryption Using Public key: M = Cd mod n

Plaintext Cipher Privatekey


Message Message

PR = { d, n } , PR = { 3, 33 }
For Ciphertext C = 20
M = 203 mod 33
M = [(201 mod 33) X (202 mod 33)] mod 33
M = (20 X 4) mod 33 = 80 mod 33
M = 14
Unit-4 Asymmertic Ciphers 12
Example RSA Algorithm

Encryption Decryption

Plaintext 7 Ciphertext 3 Plaintext


14 14 mod 33 = 20 20 20 mod 33 = 14 14

PU = 7, 33 PR = 3, 33

Unit-4 Asymmertic Ciphers 13


RSA Example
 Find n, φ(n), e, d for p=7 and q= 19 then demonstrate encryption
and decryption for M = 6
n = p * q = 7 * 19 = 133 Finding e relatively prime to 108
φ(n) = ( p – 1 ) * ( q – 1) = 108 e = 2 => GCD( 2, 108 ) = 2 (no)
e = 3 => GCD( 3, 108 ) = 3 (no)
e = 5 => GCD( 5, 108 ) = 1 (Yes)
• Finding d such that (d * e ) mod φ(n) = 1
• We can rewrite this as d = (1 + j . φ(n)) / Public key :
PU = { e, n } = {5, 133}
e
Private key :
j = 0 => d = 1 / 5 = 0.2  integer ? (no)
PR = { d, n } = {65, 133}
j = 1 => d = 109 / 5 = 21.8  integer ? (no)
j = 2 => d = 217 / 5 = 43.4  integer ? (no)
j = 3 => d = 325 / 5 = 65 integer ? (yes)
Unit-4 Asymmertic Ciphers 14
RSA Example – cont…
 Encryption:

C = Me mod n PU = { e, n } , PU = { 5, 133 }
For message M = 6
C = 65 mod 133
C = 7776 mod 133
C = 62
 Decryption:

M = Cd mod n PR = { d, n } , PU = { 65, 133 }


For C = 62
M = 6265 mod 133
M = 2666 mod 133
M=6
Unit-4 Asymmertic Ciphers 15
RSA Example – cont…
P = Cd % n = 6265 % 133
= 62 * 6264 % 133
= 62 * (622 ) 32 % 133
= 62 * 384432 % 133
= 62 * (3844 % 133)32 % 133
= 62 * 12032 % 133
We now repeat the sequence of operations that reduced 6265 to 12032 to reduce the
exponent down to 1.
= 62 * 3616 % 133
= 62 * 998 % 133
= 62 * 924 % 133
= 62 * 852 % 133
= 62 * 43 % 133
= 2666 % 133
=6

Unit-4 Asymmertic Ciphers 16


RSA Example
 P and Q are two prime numbers. P=7, and Q=17. Take public key
E=5. If plain text value is 10, then what will be cipher text value
according to RSA algorithm?
 n = 119
 φ(n) = 96
 e=5
 d = 77
 PU = { 5, 119 }
 PR = {77, 119}
 C = 105 mod 119 => C = 40

Unit-4 Asymmertic Ciphers 17


Diffie-Hellman key Exchange
 The purpose of the Diffie-Hellman algorithm is to enable two
users to securely exchange a key that can be used for subsequent
encryption of message.
 This algorithm depends for its effectiveness on the difficulty of
computing discrete logarithms.

Unit-4 Asymmertic Ciphers 18


Primitive root
 Let be a prime number
 Then is a primitive root for , if the powers of modulo generates
all integers from 1 to – 1 in some permutation.
𝑎𝑚𝑜𝑑 𝑝 , 𝑎 2 𝑚𝑜𝑑 𝑝 , … , 𝑎𝑝 −1 𝑚𝑜𝑑 𝑝
 Example: p = 7 then primitive root is 3 because powers of 3 mod 7
generates all the integers from 1 to 6

Unit-4 Asymmertic Ciphers 19


Discrete Logarithm
 For any integer and a primitive root of prime number , we can
find a unique exponent such that
𝑏=𝑎 𝑖 (𝑚𝑜𝑑 𝑝 ) 𝑤h𝑒𝑟𝑒 0 ≤ 𝑖 ≤(𝑝 −1)
 The exponent is referred as the discrete logarithm of for the base
, mod . It expressed as below.
𝑏 d log 𝑎 , 𝑝 (𝑏)

Unit-4 Asymmertic Ciphers 20


Diffie-Hellman Key Exchange – Cont…
 User A and User B agree on two large prime numbers q and α.
User A and User B can use insecure channel to agree on them.
 User A selects a random integer and calculates

Unit-4 Asymmertic Ciphers 21


Diffie-Hellman Key Exchange – Cont…
Global Public Elements
prime number
< and is primitive root of

User A Key Generation


Select private
Calculate public

User B Key Generation


Select private
Calculate public
Unit-4 Asymmertic Ciphers 22
Diffie-Hellman Key Exchange – Cont…
User A Key Generation
Select private
Calculate public
User B Key Generation
Select private
Calculate public
Calculation of Secret Key by User A

Calculation of Secret Key by User b

Unit-4 Asymmertic Ciphers 23


Diffie-Hellman Key Exchange – Cont…
User A Key Generation
Private , Public
User B Key Generation
Private , Public
Secret Key by User A :
Secret Key by User B :

Unit-4 Asymmertic Ciphers 24


Diffie-Hellman Key Exchange Example
 Alice and bob agrees on a prime number
 as primitive root of
 Alice selects a private integer
 Alice computes =>
 Bob selects a private integer
 Bob computes =>
 Alice sends to Bob and Bob sends to Alice
 Alice computes key =>

 Bob computes key =>

Unit-4 Asymmertic Ciphers 26


Diffie-Hellman Key Exchange Illustration

Unit-4 Asymmertic Ciphers 27


Man in the middle attack
 Suppose Alice and Bob wish to exchange keys, and Darth is the adversary.
1. Darth prepares for the attack by generating two random private keys XD1
and XD2 and then computes corresponding public keys YD1 and YD2.
2. Alice transmits YA to Bob.
3. Darth intercepts YA and transmits YD1 to Bob. Darth also calculates
K2=(YA)XD2 mod q.
4. Bob receives YD1 and calculates K1 = (YD1)XB mod q.
5. Bob transmits YB to Alice.
6. Darth intercepts YB and transmits YD2 to Alice. Darth calculates K1=(YB)XD1
mod q.
7. Alice receives YD2 and calculates K2 = (YD2)XA mod q.

Unit-4 Asymmertic Ciphers 28

You might also like