RKU PPT-4
RKU PPT-4
Safe with a strong lock, only Alice and Bob have a copy of the key
• Alice encrypts: locks message in the safe with her key
• Bob decrypts: uses his copy of the key to open the safe
Asymmetric cryptography (public key cryptography)
Asymmetric cryptography, also known as public key cryptography, uses public and private
keys to encrypt and decrypt data.
The keys are simply large numbers that have been paired together but are not identical
(asymmetric).
One key in the pair can be shared with everyone; it is called the public key.
The other key in the pair is kept secret; it is called the private key. Either of the keys can be
used to encrypt a message; the opposite key from the one used to encrypt the message is
used for decryption.
Many protocols like SSH, OpenPGP, S/MIME, and SSL/TLS rely on asymmetric cryptography
for encryption and digital signature functions.
It is also used in software programs, such as browsers, which need to establish a secure
connection over an insecure network like the Internet or need to validate a digital
signature
How asymmetric encryption works
Transmitted
X cipher text X
Y = E(PUa, X)
Plaintext Plaintext
input Encryption Decryption output
Algorithm Algorithm
(e.g. RSA)
Bob Alice
Asymmetric Key Encryption with Private Key
Alice’s
Public
The entire encrypted message
key
serves as a digital signature. Joy ring
Ted
Mike Bob
Transmitted
X cipher text X
Y = E(PRb,
Plaintext X) Plaintext
input Encryption Decryption
output
Algorithm Algorithm
(e.g. RSA)
Bob Alice
Asymmetric Key Encryption example
New Idea:
Use the good old mailbox principle:
Public Key
Private Key
Authentication and Confidentiality
Source A Source B
Y
X Y Encryption Z X
Message Encryption Decryption Decryption Message
source Algorithm Algorithm Algorithm Algorithm Dest.
PUb PRb
PRa
Key pair
PUa source
Key pair
source
RSA is a block cipher in which the Plaintext and Ciphertext are represented as integers
between 0 and n-1 for some value of n.
Large messages can be broken up into a number of blocks.
Each block would then be represented by an integer.
Plaintext: M
Ciphertext: C = Me mod n
Step-3: Decryption using Private Key:
Ciphertext: C
Plaintext: M = Cd mod n
Step-1: Generate Public key and Private key
Select two large prime numbers: p = 3 and q = 11
Calculate modulus : n = p * q = 3 * 11 = 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 :3, 7, 11, 13, 17, 19 Let’s take e = 7
Determine d such that d * e ≡ 1 (mod φ(n))
? * 7 ≡ 1 (mod 20), 3 * 7 ≡ 1 (mod 20)
? * 7 (mod 20) ≡ 1, 3 * 7 (mod 20) ≡ 1
Public key : PU = { e, n } , PU = { 7, 33 }
Private key : PR = { d, n }, PR = { 3, 33 }
Step-2 : Encrypt Message
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
Step-3 : Decrypt Message
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
Example RSA Algorithm
RSA Example - 1
Find n, φ(n), e, d for p=7 and q= 19 then demonstrate encryption and decryption for M = 6
Finding e relatively prime to 108
n = p * q = 7 * 19 = 133 e = 2 => GCD( 2, 108 ) = 2 (no)
e = 3 => GCD( 3, 108 ) = 3 (no)
φ(n) = ( p – 1 ) * ( q – 1) = 108 e = 5 => GCD( 5, 108 ) = 1 (Yes)
Encryption:
C = Me mod n PU = { e, n } , PU = { 5, 133 }
For message M = 6
C = 65 mod 133
C = 7776 mod 33
C = 62
Decryption:
M = Cd mod n PR = { d, n } , PU = { 65, 133 }
For C = 62
M = 6265 mod 133
M = 2666 mod 33
M=6
RSA Example - 2
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
RSA Example - 3
P and Q are two prime numbers. P=17, and Q=11. If plain text value is 88, then
what will be cipher text value according to RSA algorithm?
n = 187
φ(n) = 160
e=7
d = 23
PU = { 7, 187 }
PR = {23, 187}
C = 887 mod 187 => C = 11
DIFFERENCE:
Benefits and disadvantages of asymmetric cryptography
the key distribution problem is eliminated because there's no need for exchanging keys.
security is increased as the private keys don't ever have to be transmitted or revealed to
anyone.
the use of digital signatures is enabled so that a recipient can verify that a message comes
from a particular sender.
it allows for non-repudiation so the sender can't deny sending a message.
Disadvantages include:
it's a slow process compared to symmetric crytography, so it's not appropriate for decrypting
bulk messages.
if an individual loses his private key, he can't decrypt the messages he receives.
since the public keys aren't authenticated, no one really knows if a public key belongs to the
person specified. Consequently, users have to verify that their public keys belong to them.
if a hacker identifies a person's private key, the attacker can read all of that individual's
messages.
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.
The effectiveness of an algorithm is depends on the difficulty of computing discrete
logarithms.
Primitive root
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 𝑎 ,𝑝 (𝑏)
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 .
User B selects a random integer and calculates .
Diffie-Hellman Key Exchange – Cont…
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
3. Darth intercepts YA and transmits YD1 to Bob. Darth also calculates K2=(YA) mod q.
6. Darth intercepts YB and transmits YD2 to Alice. Darth calculates K1=(YB) mod q.
XA = 10
XB = 11
YA = 3 mod 19 =
YB = 3 mod 19 = 10
16 YA = YB = 10
16
XD1 = 2
XD2 = 7
YD1 = 3 mod 19 = 9
YD2 = 3 mod 19 = 2
YD2 = YD1 =
2 9
K2 = (2) mod 19 K2 = (16) mod K1 = (9) mod 19
k2 = 17 19 k2 = 17 k1 = 5
K1 = (10) mod
19 k1 = 5
Secret key encryption algorithms, such as Rijndael or Twofish, for message encryption.
Public key encryption algorithm from RSA for secret key encryption with a receiver’s
public key.
A digital envelope may be decrypted by using a receiver's private key to decrypt a secret key,
or by using a secret key to decrypt encrypted data.