CompSec 4035 Chapter 3 Lesson 4
CompSec 4035 Chapter 3 Lesson 4
Asymmetric Cryptography
Encryption and decryption are performed using two
different keys;
public key and
private key.
It is also known as public-key encryption
Invented by Diffie and Hellman in 1976
Based on mathematical functions/the two different
keys are mathematically related
Transforms plaintext/ciphertext into ciphertext/
plaintext using one of the two keys and an encryption/
decryption algorithm.
Asymmetric-key(public key) encryption
The basic idea:
Different algorithms
RSA
Diffie –Hellman
DSS – Digital Signature Standard
Elliptic Curve
Public-key Cryptosystem: Example RSA
RSA is from R. Rivesh, S. Shamir and A. Aldermen
Principle:
No mathematical method is yet known to efficiently find the prime
factors of large numbers: Ex: 2100= 2x2x3x5x5x7
In RSA, the private and public keys are constructed from very
large prime numbers (consisting of hundreds of decimal
digits)
One of the keys can be made public
Support both public key encryption and digital signature
Breaking RSA is equivalent to finding the prime
factors: this is known to be computationally infeasible
It is only the person who has produced the keys from
the prime number can easily decrypt the messages
Public-key Cryptography
RSA- Example of Asymmetric/Public-Key Cryptosystem
I
- The RSA algorithm
Used for both public key encryption and digital
signatures.
Security is based on the difficulty of factoring large
integers.
- Major Activities
Key Generation (Algorithm)
Encryption
Decryption
Digital signing
Signature verification
Public-key Cryptosystem: Example RSA
RSA is the most common and well-known public key
cryptosystem
RSA- Key Generating Algorithm
1. Pick/Generate two large random prime numbers, p and q
2. Compute n = pq and (φ) phi = (p-1)(q-1), totient function
3. Choose an integer e, such that 1 < e < φ, and
gcd(e, phi) = 1, relatively pr.
Doesn’t have common factor
4. Compute/determine d (secret exponent), such that
1 < d < φ ,and φ divides ed-1 or (ed)Mod φ = 1=>(ed-1)Mod φ=0
5. The public key is (n, e) and
The private key is (n, d)
Keep all the values d, p, q and φ secret
e is known as the public key exponent or encryption exponent
d is known as the secret key exponent or decryption exponent.
Public-key Cryptosystem: Example RSA
Both sender and receiver know n
Sender knows e
Only receiver knows d
RSA- Encryption
To encrypt a message M, 0≤M<n
Obtain the public key (e,n)
Compute C = Me mod n
RSA- Decryption
To decrypt the cyphertext C,
Use your private key (d,n)
Compute M = Cd mod n
Public-key Cryptosystem: RSA Example 1
1. Choose 2 prime numbers: p=7, q=17 & let M=19
2. Compute n=p*q=7*17=119
ø(n)=(p-1)*(q-1)= 6*16=96
3. Choose e relative prime to ø(n), e=5
4. Determine d: de=1 mod 96 and d < 96
Compute d = 5–1 mod 96=77
5. Publish (5,119), public key
Keep (77,119), 7, 17, Private key
Encrypt
195 mod 119 = 2,476,099 mod 119 = 66
Decrypt
6677 mod 119 = 19 mod 119 = 19
Public-key Cryptosystem: RSA Example 2
1. Select primes p=11, q=3.
2. n = pq = 11*3 = 33
phi = (p-1)(q-1) = 10*2 = 20
3. Choose e=3
Check gcd(e, p-1) = gcd(3, 10) = 1 (i.e. 3 and 10 are relatively
prime - have no common factors except 1) and check gcd(e,
q-1) = gcd(3, 2) = 1,
therefore gcd(e, phi) = gcd(e, (p-1)(q-1)) = gcd(3, 20) = 1
4. Compute d (1<d<phi) such that d = e-1 mod phi = 3-1 mod 20
i.e. find a value for d such that phi divides ed-1 (20 divides 3d-
1)
Simple testing (d = 2, 3 ...) gives d = 7
Check: ed-1 = 3*7 - 1 = 20, which is divisible by phi (20).
5. Public key = (n, e) = (33, 3)
Private key = (n, d) = (33, 7)
Public-key Cryptosystem: RSA Example 2
Given
Public key = (n, e) = (33, 3)
Private key = (n, d) = (33, 7)
Encryption
• Now say we want to encrypt the message m = 7
- c = me mod n = 73 mod 33 = 343 mod 33 = 13
- Hence the ciphertext c = 13
Decryption
• To check decryption we compute
- m = cd mod n = 137 mod 33 = 7
Public-key Cryptosystem: RSA Example 3
1. Select primes: p=17 & q=11
2. Calculate n = pq =17 x 11=187
ø(n)=(p–1)(q-1)=16x10=160
3. Select e: gcd(e,160)=1; choose e=7
4. Determine d: de = 1 mod 160 and d < 160
Value is d=23 since 160 divides 7x23-1
5. Publish public key PU={7,187}
Keep secret private key PR={23,187}
given message M = 88
Encryption:
C = 887 mod 187 = 11
Decryption:
M = 1123 mod 187 = 88
RSA Algorithm Summary
Strengths of RSA
No prior communication needed
Highly secure (for large enough keys)
Well-understood
Allows both encryption and signing
Weaknesses of RSA
Large keys needed (1024 bits is current standard)
Relatively slow
Not suitable for very large messages
Public keys must still be distributed safely.
The Diffie-Hellman Algorithm for generating a
shared secret session key
19
Diffie-Hellman Example
users Alice & Bob who wish to swap keys:
agree on prime q=11 and α=2
select random secret keys:
A chooses xA=8, B chooses xB=4
compute public keys:
8
yA=2 mod 11 = 3 (Alice)
4
yB=2 mod 11 = 5 (Bob)
compute shared session key as:
xA 8
K= yB mod q = 5 mod 11= 4 (Alice)
xB 4
K= yA mod q = 3 mod 11= 4 (Bob)
20
The Diffie-Hellman Algorithm with key
exchange
21
The Diffie-Hellman Algorithm Security
The difficulty of determining the secret shared key
K from the publicly available q, α , YA, and YB is
sometimes referred to as the Computational Diffie-
Hellman Assumption.
Is this enough to compute the K value? No! In
order to compute K, the eavesdropper must do
either of two things:
Raise αXA to the XB power (mod q), which he
cannot do because he does not know XB, or
Raise αXB to the XA power (mod q), which he
cannot do because he does not know22XA.
The Diffie-Hellman Algorithm Security
25
Digital Signatures and Digital Certificates
Message Authentication-security requirements
In the context of communications across a network, the
following attacks can be identified:
Disclosure: Release of message contents to any person
or process not possessing the appropriate cryptographic
key.
Traffic analysis: Discovery of the pattern of traffic
between parties.
Masquerade: Insertion of messages into the network
from a fraudulent source.
This includes the creation of messages by an opponent that
are supposed to come from an authorized entity.
26
Digital Signatures and Digital Certificates
Message Authentication-security requirements
Content modification: Changes to the contents of a message,
including insertion, deletion, transposition, and
modification.
Sequence modification: Any modification to a sequence of
messages between parties, including insertion, deletion, and
reordering.
Timing modification: Delay or replay of messages.
Source repudiation: Denial of transmission of message by
source.
Destination repudiation: Denial of receipt of message by
destination. 27
Digital Signatures and Digital Certificates
28
Digital Signatures and Digital Certificates
29
Digital Signatures and Digital Certificates
30
Digital Signatures and Digital Certificates
Reading Assignment
Digital Signatures – Authentication using hash function
Public key Infrastructure
Digital Certification
31