Lecture7-PKC
Lecture7-PKC
Security
Lecture-7 (PKC)
Today’s Topics
• Public Key Cryptography
• RSA Cryptosystem
• Diffie-Hellman Key Exchange
• Digital Certificate
Public Key Cryptography
• Also known as “asymmetric cryptography”
• Concept proposed by Diffie and Hellman in 1976
• Requires usage of two different keys between the sender and the
receiver
• Public Key and Private Key
• Remember symmetric crypto requires only a single key
Public Key Cryptography
• Also known as “asymmetric cryptography”
• Concept proposed by Diffie and Hellman in 1976
• Requires usage of two different keys between the sender and the
receiver
• Public Key and Private Key
• Remember symmetric crypto requires only a single key
• Can be used to achieve
• Confidentiality
• Authentication
• Non-Repudiation
Why Public Key Cryptography (PKC) ?
• How to share the secret key between sender and recipient before
using symmetric crypto ?
1. Meet physically beforehand and decide – Not a practical solution
Why Public Key Cryptography (PKC) ?
• How to share the secret key between sender and recipient before
using symmetric crypto ?
1. Meet physically beforehand and decide – Not a practical solution
2. Use a key distribution center(KDC)
• Role of KDC is to distribute the session
key (secret key) between the sender and
the receiver
• But, that means KDC knows our secret
key which is undesirable !!!
Why Public Key Cryptography (PKC) ?
• How to share the secret key between sender and recipient before
using symmetric crypto ?
1. Meet physically beforehand and decide – Not a practical solution
2. Use a key distribution center (KDC)
• Role of KDC is to distribute the session key
(secret key) between the sender and the
receiver
• But, that means KDC knows our secret key
which is undesirable !!!
• PKC helps us achieve total secrecy
over our communication
Basic Framework of PKC
• Each user generates a pair of keys
• Public key (denoted as PU) – Known to all
• Private key (denoted as PR) – Known only
to the owner
Basic Framework of PKC
• Each user generates a pair of keys
• Public key (denoted as PU) – Known to all
• Private key (denoted as PR) – Known only
to the owner
• Encryption
• Sender encrypts the plaintext using
recipient’s public key
Basic Framework of PKC
• Each user generates a pair of keys
• Public key (denoted as PU) – Known to all
• Private key (denoted as PR) – Known only
to the owner
• Encryption
• Sender encrypts the plaintext using
recipient’s public key
• Decryption
• Recipient decrypts the ciphertext using
her private key
• Since only recipient knows the corr.
private key, only she can decrypt the
ciphertext back and nobody else
Basic Framework of PKC
• Digital Signature: Authentication with Public Key
• To determine: x, y, d
• Solving the congruence 𝑎x≡ 1 (mod m) is equivalent
to solving 𝑎x− my = 1.
Extended Euclidean (EE) Algorithm
Algorithm Example
• 𝑟1 ← 𝑛; 𝑟2 ← 𝑏;
Find the multiplicative inverse of 23 (b) modulo 100 (n)
• 𝑡1 ← 0; 𝑡2 ← 1;
While(𝑟2 > 0)
{ q r1 r2 r t1 t2 t
𝑞 ← 𝑟1 /𝑟2 ; 4 100 23 8 0 1 -4
2 23 8 7 1 -4 19
𝑟 ← 𝑟1 − 𝑞 × 𝑟2 ;
𝑟1 ← 𝑟2 ; 𝑟2 ← 𝑟; 1 8 7 1 -4 9 -13
7 7 1 0 9 -13 100
t ← 𝑡1 − 𝑞 × 𝑡2 ; 1 0 -13 100
𝑡1 ← 𝑡2 ; 𝑡2 ← 𝑡;
}
• Note that gcd (100,23) is 1 which means inverse of 23
If 𝑟1 = 1 𝑡ℎ𝑒𝑛 𝑏 −1 ← 𝑡1 exists.
• From above, 𝑡1 = -13 or (-13) mod 100 = 87
• Thus, 87 is the multiplicative inverse of 23 modulo 100
Euler’s Totient
• Defined as the number of positive integers less than n and relatively
prime to n
• Denoted as ϕ n . By convention, ϕ 1 = 1
Euler’s Totient
• Always remember that for a prime number p,
ϕ p =𝑝−1
• Let n = pq , where p and q are prime numbers and p≠ 𝑞, then
𝜙 𝑛 = 𝜙 𝑝𝑞 = 𝜙 𝑝 × 𝜙 𝑞 = (𝑝 − 1)(𝑞 − 1)
• For example, 𝜙 15 = 𝜙 5 × 𝜙 3 = 4 × 2 = 8
RSA Cryptosystem
• Developed in 1977 by Ron Rivest, Adi Shamir, and Len Adleman at MIT
• Based on modular exponentiation and factorization of large numbers
• In RSA block cipher, plaintext (and ciphertext) are integers between 0
and n-1 for some n
• Typically |n| = 1024 bits
• Means, 𝑛 ≤ 21024 or 309 decimal digits
RSA Cryptosystem
• Developed in 1977 by Ron Rivest, Adi Shamir, and Len Adleman at MIT
• Based on modular exponentiation and factorization of large numbers
• In RSA block cipher, plaintext (and ciphertext) are integers between 0
and n-1 for some n
• Typically |n| = 1024 bits
• Means, 𝑛 ≤ 21024 or 309 decimal digits
to make the 3rd and 2nd formula work, we have to break the composite n,
into its primes, currently we dont have any such algo that can do it efficiently
How to generate RSA parameters ?
• Lets focus on value of n now
• Case 2. If n is composite
• Again we want 𝑑 ≡ 𝑒 −1 𝑚𝑜𝑑 𝜙 𝑛
• The extended Euclidean algorithm is an efficient algorithm to find d, but we
need to know 𝜙 𝑛 , otherwise it won’t work!!
• Finding 𝜙 𝑛 for large composite n is computationally hard
• However, if we use n = pq, and know the factorization, we can calculate 𝜙 𝑛 =
𝜙 𝑝𝑞 = (𝑝 − 1)(𝑞 − 1) and thus d
How to generate RSA parameters ?
• Lets focus on value of n now
• Case 2. If n is composite
• Again we want 𝑑 ≡ 𝑒 −1 𝑚𝑜𝑑 𝜙 𝑛
• The extended Euclidean algorithm is an efficient algorithm to find d, but we
need to know 𝜙 𝑛 , otherwise it won’t work!!
• Finding 𝜙 𝑛 for large composite n is computationally hard
• However, if we use n = pq, and know the factorization, we can calculate 𝜙 𝑛 =
𝜙 𝑝𝑞 = (𝑝 − 1)(𝑞 − 1) and thus d
• So RSA uses a large composite n = pq that cannot be factored efficiently
• Factorization of large numbers is NP Hard !!
RSA Algorithm
RSA Numerical
Problem of non-repudiation
Problem of non-repudiation
• Authentication is achieved
• Only Alice could have encrypted the message using her private key
• In broader terms, this is what a digital signature is – encrypting with the
private key of sender
Public Key Authentication
• Authentication is achieved
• Only Alice could have encrypted the message using her private key
• In broader terms, this is what a digital signature is – encrypting with the private key
of sender
• But now there is no confidentiality
• Anybody can decrypt using Alice’s public key
Sign-then-Encrypt
• Message from Alice to Bob would be:
𝐴 → 𝐵: 𝐸𝑃𝑈𝐵 (𝐸𝑃𝑅𝐴 (𝑀))
• Alice cannot now deny signing the message
Sign-then-Encrypt
• Message from Alice to Bob would be:
𝐴 → 𝐵: 𝐸𝑃𝑈𝐵 (𝐸𝑃𝑅𝐴 (𝑀))
• Alice cannot now deny signing the message
• However, another attack possible:
• Surreptitious Forwarding
Sign-then-Encrypt
• Message from Alice to Bob would be:
𝐴 → 𝐵: 𝐸𝑃𝑈𝐵 (𝐸𝑃𝑅𝐴 (𝑀))
• Alice cannot now deny signing the message
• However, another attack possible:
• Surreptitious Forwarding
• Consider the scenario,
• Originally: 𝐴 → 𝐵: 𝐸𝑃𝑈𝐵 (𝐸𝑃𝑅𝐴 (𝑇ℎ𝑒 𝑑𝑒𝑎𝑙 𝑖𝑠 𝑜𝑓𝑓))
• Because Bob wants to take revenge, he will send the same signed message to
Charlie by encrypting with Charlie’s public key
Sign-then-Encrypt
• Message from Alice to Bob would be:
𝐴 → 𝐵: 𝐸𝑃𝑈𝐵 (𝐸𝑃𝑅𝐴 (𝑀))
• Alice cannot now deny signing the message
• However, one attack is possible:
• Consider the scenario,
• Originally: 𝐴 → 𝐵: 𝐸𝑃𝑈𝐵 (𝐸𝑃𝑅𝐴 (𝑇ℎ𝑒 𝑑𝑒𝑎𝑙 𝑖𝑠 𝑜𝑓𝑓))
• Because Bob wants to take revenge, he will send the same signed message to Charlie
by encrypting with Charlie’s public key
• Now: B → 𝐶: 𝐸𝑃𝑈𝐶 (𝐸𝑃𝑅𝐴 (𝑇ℎ𝑒 𝑑𝑒𝑎𝑙 𝑖𝑠 𝑜𝑓𝑓))
• Even though Alice didn’t want to disclose the deal, but to Charlie it will look like as if
Alice wants to do so
Sign-then-Encrypt
• However, Alice can prevent this type of attack
Sign-then-Encrypt
• However, Alice can prevent this type of attack
• Now: 𝐴 → 𝐵: 𝐸𝑃𝑈𝐵 (𝐸𝑃𝑅𝐴 (𝑇ℎ𝑒 𝑑𝑒𝑎𝑙 𝑖𝑠 𝑜𝑓𝑓| 𝐼𝐷𝐵 |𝑇))
• Alice appends an unique identifier of Bob to the original message as well as the
timestamp when the message was sent
Diffie Hellman Key Exchange
p before repeating.
This ensures that every possible key can be derived, making the
system more secure.
Prevents weak keys
Essentially, certificates allows you to verify whether the information you are
getting is unaltered or not, to prevent cases like mitm
Detailed Explanation of the PDF Content
The document primarily discusses Public Key Certificates, their structure, importance, and
revocation process. Here's a detailed breakdown of each section:
Public key certificates are used to exchange cryptographic keys securely without requiring direct
contact with a public key authority. These certificates bind a public-private key pair to a specific
individual or organization.
o A public key.
2. The CA acts as a trusted third party that verifies and signs the certificate.
3. A user can securely present their public key to a CA and obtain a certificate.
4. Once issued, the certificate can be published for others to verify the key owner’s identity.
5. Anyone needing the public key can obtain the certificate and check its validity using the
CA’s signature.
X.509 Standard
Certificate Format
The document does not elaborate on the exact structure but implies that it follows the X.509
format.
Certificate Revocation
5. The CA’s certificate is compromised (e.g., if an attacker gains control of the CA).
Revocation Process
• A CRL contains:
• Users should always check a certificate against the CRL before trusting it.
Public Key Cryptography
• Two users A and B need to know each other’s public key
• How can they know that ??
• How can they trust the credibility of the public key ?
• If the binding is erroneous, someone other than the intended recipient could read the
message.
• Several techniques have been proposed for it!
Public key certificates
• Certificates can be used to exchange keys without contacting a public
key authority
• They bind a public-private key pair to a specific person or
organization
Public key certificates
• Certificates can be used to exchange keys without contacting a public
key authority
• They bind a public-private key pair to a specific person or
organization
• Essentially it consists of a public key plus an identifier of the key
owner, with the whole block signed by a trusted third party known as
certifying authority (CA)
Public key certificates
• Certificates can be used to exchange keys without contacting a public
key authority
• They bind a public-private key pair to a specific person or
organization
• Essentially it consists of a public key plus an identifier of the key
owner, with the whole block signed by a trusted third party known as
certifying authority (CA)
• A certification authority (CA) is an entity that issues certificates.
• A user can present his public key to the authority in a secure manner
and obtain a certificate. He can then publish his certificate
Public key certificates
• Certificates can be used to exchange keys without contacting a public key
authority
• They bind a public-private key pair to a specific person or organization
• Essentially it consists of a public key plus an identifier of the key owner,
with the whole block signed by a trusted third party known as certifying
authority (CA)
• A certification authority (CA) is an entity that issues certificates.
• A user can present his public key to the authority in a secure manner and
obtain a certificate. He can then publish his certificate
• Anyone needing this user’s public key can obtain the certificate and verify
that it is valid by way of attached signature
Requirements of Certificate Scheme
General Certificate Scheme
General Certificate Scheme
One scheme that
has become
universally
accepted for
formatting public
key certificates: the
X.509 standard
General Certificate Scheme
One scheme that
has become
universally
accepted for
formatting public
key certificates: the
X.509 standard
X.509
• Is a standard that defines the format of digital certificates
• Used in many internet protocols like S/MIME, SSL/TLS etc.
Certificate Format
Certificate Format
Certificate Revocation
• What happens in the following cases ?
• User’s certificate has expired
• A new certificate is issued before the expiry
• User’s private key is compromised
• The user is no longer certified by the CA
• The CA’s certificate has been compromised
Certificate Revocation
• What happens in the following cases ?
• User’s certificate has expired
• A new certificate is issued before the expiry
• User’s private key is compromised
• The user is no longer certified by the CA
• The CA’s certificate has been compromised
• The digital certificate is revoked !!
Certificate Revocation
• What happens in the following cases ?
• User’s certificate has expired
• A new certificate is issued before the expiry
• User’s private key is compromised
• The user is no longer certified by the CA
• The CA’s certificate has been compromised
• The digital certificate is revoked !!
• Each CA maintains a list of revoked certificates
• Certificate revocation list (CRL)
• Contains an entry for each revoked certificate
• Each entry consists of the serial number of a
certificate and revocation date for that certificate
• Users should check certificates with CA’s CRL
Key Points
• Symmetric encryptions are used for securing data at rest and in
transition by maintaining confidentiality.
• Pseudo Random Number Generator algorithms are used for generating
random numbers.
• Hash functions are used for data integrity.
• MAC functions are used for data integrity and source authentication.
• Public key encryption is used for key exchange, source authentication
(digital Signature).
Symmetric-Key Cryptography
AES (Advanced Encryption Standard) – Secure block cipher used for encryption. ✅
Confidentiality
DES (Data Encryption Standard) – Older block cipher, now insecure. ✅
Confidentiality
3DES (Triple DES) – Extended DES with better security but inefficient. ✅
Confidentiality
ChaCha20 – Stream cipher alternative to AES with high performance. ✅
Confidentiality
Blowfish – Flexible key-length block cipher, replaced by AES. ✅ Confidentiality
Asymmetric-Key Cryptography
RSA – Public-key encryption and digital signatures. ✅ Confidentiality, ✅
Authenticity, ✅ Non-repudiation
Diffie-Hellman (DH) – Key exchange protocol for secure communication. ✅
Confidentiality
Elliptic Curve Cryptography (ECC) – Efficient alternative to RSA with shorter keys.
✅ Confidentiality, ✅ Authenticity, ✅ Non-repudiation
Hash Functions
SHA-2 (SHA-256, SHA-512) – Secure cryptographic hash functions. ✅ Integrity
SHA-3 – Newer secure hash function alternative to SHA-2. ✅ Integrity
MD5 – Broken hash function, insecure for integrity. ❌ Integrity
SHA-1 – Weak and deprecated hash function. ❌ Integrity
Message Authentication Codes (MACs)
HMAC (Hash-based MAC) – Combines hashing and a secret key for integrity. ✅
Integrity, ✅ Authenticity
CMAC (Cipher-based MAC) – Uses block cipher for message authentication. ✅
Integrity, ✅ Authenticity
Digital Signatures
RSA Signatures – Digital signatures using RSA. ✅ Authenticity, ✅ Integrity, ✅
Non-repudiation
ECDSA (Elliptic Curve Digital Signature Algorithm) – Efficient ECC-based digital
signature. ✅ Authenticity, ✅ Integrity, ✅ Non-repudiation
EdDSA (Ed25519, Ed448) – More secure and efficient alternative to ECDSA. ✅
Authenticity, ✅ Integrity, ✅ Non-repudiation
Key Exchange Protocols
TLS Handshake (RSA/DH/ECDH) – Establishes secure sessions over the internet.
✅ Confidentiality, ✅ Authenticity
IKE (Internet Key Exchange, used in IPsec) – Secure key exchange for VPNs. ✅
Confidentiality, ✅ Authenticity
Zero-Knowledge Proofs
ZK-SNARKs – Used in privacy-focused cryptocurrencies (e.g., Zcash). ✅
Confidentiality