Pki 2
Pki 2
Pki 2
Chenxiong Qian
cqian@cs.hku.hk
COMP3355 Cyber Security (2023 Fall) PKI
Previously on Crypto
Symmetric crypto
DES, AES, etc.
One secret key
Fast
Asymmetric crypto
RSA
One public key and one private key
Slow
Key exchange, signing, authentication
COMP3355 Cyber Security (2023 Fall) PKI
In This Class
What is public key infrastructure (PKI)?
Encrypt
Decrypt
Alice Bob
COMP3355 Cyber Security (2023 Fall) PKI
Encrypt
Decrypt
Alice Eve
COMP3355 Cyber Security (2023 Fall) PKI
Alice Bob
COMP3355 Cyber Security (2023 Fall) PKI
Problem
How can we verify the identify in the digital world?
COMP3355 Cyber Security (2023 Fall) PKI
Digital Certificate
A certificate is an electronic document that is used to identify an
individual, a server, a company, or some other entity, and to associate
that identity with a public key
COMP3355 Cyber Security (2023 Fall) PKI
Digital Certificate
A certificate is an electronic document that is used to identify an
individual, a server, a company, or some other entity, and to associate
that identity with a public key
COMP3355 Cyber Security (2023 Fall) PKI
Digital Certificate
A certificate is an electronic document that is used to identify an
individual, a server, a company, or some other entity, and to associate
that identity with a public key
COMP3355 Cyber Security (2023 Fall) PKI
Digital Certificate
A certificate is an electronic document that is used to identify an
individual, a server, a company, or some other entity, and to associate
that identity with a public key
COMP3355 Cyber Security (2023 Fall) PKI
Digital Certificate
A certificate is an electronic document that is used to identify an
individual, a server, a company, or some other entity, and to associate
that identity with a public key
COMP3355 Cyber Security (2023 Fall) PKI
Digital Certificate
A certificate is an electronic document that is used to identify an
individual, a server, a company, or some other entity, and to associate
that identity with a public key
COMP3355 Cyber Security (2023 Fall) PKI
Digital Certificate
COMP3355 Cyber Security (2023 Fall) PKI
Digital Certificate
COMP3355 Cyber Security (2023 Fall) PKI
Digital Certificate
Check a website’s certificate
COMP3355 Cyber Security (2023 Fall) PKI
Digital Certificate
Check a website’s certificate
COMP3355 Cyber Security (2023 Fall) PKI
Certificate Authority
Sign and issue
certificates
PKI Overview
COMP3355 Cyber Security (2023 Fall) PKI
Certificate Authority
Sign and issue
certificates
Registration Authority
Identify and authenticate PKI Overview
certificate applicants
COMP3355 Cyber Security (2023 Fall) PKI
Certificate Authority
Validation Authority
Sign and issue
Verify the validity of
certificates
a certificate
Registration Authority
Identify and authenticate PKI Overview
certificate applicants
COMP3355 Cyber Security (2023 Fall) PKI
Registration Authority
A gatekeeper of CA
Does not sign or issue certificates
Checks applicants’ IDs and paperwork
Forwards the request to CA
COMP3355 Cyber Security (2023 Fall) PKI
Certificate Authority
CA receives the request from RA
Request from RA
COMP3355 Cyber Security (2023 Fall) PKI
Certificate Authority
Signs the applicant’s entity info and public key
Generates the signature
Signs the signature using its private key
Request from RA
COMP3355 Cyber Security (2023 Fall) PKI
Certificate Authority
Issues the certificate that contains
The entity info and public key
The signature (encrypted using CA’s private key)
Etc.
CA’s Private Key
Digital Signature
Request from RA
Certificate
COMP3355 Cyber Security (2023 Fall) PKI
Certificate
X.509 is an International Telecommunication Union (ITU) standard
defining the format of public key certificates
HKU’s Wi-Fi
Public key
Signature
COMP3355 Cyber Security (2023 Fall) PKI
Digital Signature
Request from RA
Certificate
COMP3355 Cyber Security (2023 Fall) PKI
I am Peter, this
is my
certificate
Digital Signature
COMP3355 Cyber Security (2023 Fall) PKI
I need to validate
it before using the
public key
Digital Signature
COMP3355 Cyber Security (2023 Fall) PKI
SHA-256 Signature
Digital Signature
COMP3355 Cyber Security (2023 Fall) PKI
SHA-256 Signature
SHA-256 Signature
Decryption
COMP3355 Cyber Security (2023 Fall) PKI
Yes
SHA-256 Signature Equal?
No
He is not
Name: Peter Parker Signature Peter.
Organization: The Avengers
Address: New York, USA
…….
Decryption
COMP3355 Cyber Security (2023 Fall) PKI
CA Hierarchy
Root CA
Issues certificates to
intermediate CAs
Intermediate CA
Issues certificates to
end users
COMP3355 Cyber Security (2023 Fall) PKI
Single/One-Tier Hierarchy
The single CA is both a root CA
and an issuing CA
Security risks
The only CA is online
If the CA is compromised:
Cannot quickly distribute a new
root CA
Cannot revoke the CA
Management issues
Not flexible
Not scalable
COMP3355 Cyber Security (2023 Fall) PKI
Two-Tier Hierarchy
Separate the root CA and
issuing CA
Root CA is offline
Issuing CAs are online
Benefits:
Security
Scalability
Flexibility
Manageability cost
increases
COMP3355 Cyber Security (2023 Fall) PKI
Three-Tier Hierarchy
The second tier CAs
Policy CAs
Revoke CAs
Benefits:
Security
Scalability
Flexibility
Manageability cost
increases
COMP3355 Cyber Security (2023 Fall) PKI
Certificate Path
Reference
Root CA’s Certificate
Intermediate CA Intermediate CA’s Certificate
Private Key Root CA Private Key Root CA
Distinguished Name
Intermediate CA
Distinguished Name
Self-Sign
Sign Root CA Public Key
Intermediate CA Root CA
Public Key
Root CA Signature
Sign Intermediate CA
Signature
Intermediate CA Reference
Distinguished Name
End User
End User’s Certificate
COMP3355 Cyber Security (2023 Fall) PKI
Certificate Verification
Root CA’s Certificate
Intermediate CA’s Certificate
Root CA
Distinguished Name
Intermediate CA
Distinguished Name Verify
Root CA Public Key
Verify Intermediate CA
Public Key
Root CA Signature
Intermediate CA
Signature
Intermediate CA
Distinguished Name
Reference
End User’s Certificate
COMP3355 Cyber Security (2023 Fall) PKI
Demo
https://stackexchange.com
COMP3355 Cyber Security (2023 Fall) PKI
Demo
COMP3355 Cyber Security (2023 Fall) PKI
Demo
https://stackoverflow.com
Why does “stackoverflow” use
“*.stackexchange” certificate?
COMP3355 Cyber Security (2023 Fall) PKI
Demo
http://google.com
Big techs self-sign certificates
COMP3355 Cyber Security (2023 Fall) PKI
Questions
Who is responsible to generate keys?
Key Generation
Basic approach:
Alice generates her own key pair
The CA signs a statement about Alice’s public key and issues a public key
certificate (PKC)
Bob knows Alice’s public key from verifying the PKC
Key Generation
Improved approach (Most common)
Alice generates her own key pair
Alice brings the public key and a signed request showing that she knows the
private key
CA verifies the signed request and the public key
The CA signs a statement about Alice’s public key and issues a PKC
Bob knows Alice’s public key from verifying the PKC
Key Generation
Improved approach
CA generates the key pair for Alice and then issues the key pair to Alice
Symantec Example
One of many fingerprint scanners at the entrance to a Inside these security cabinets are the hardware security modules
data center at Symantec's SSL certificate vault. that safeguard millions credentials used to authenticate the
websites of Symantec customers.
COMP3355 Cyber Security (2023 Fall) PKI
Symantec Example
The digital assets for Symantec can be accessed The key-ceremony room.
only when three separate employees insert a
USB-looking key and enter a corresponding PIN.
COMP3355 Cyber Security (2023 Fall) PKI
DigiNotar Story
Aug. 27th, 2011
An Iranian man “Alibo” couldn’t connect to Gmail
He switched to a virtual private network that disguised his location, and he
can access Gmail
Posted a question about the issue on the Gmail Help Forum
Two days later
Google issued a public statement
COMP3355 Cyber Security (2023 Fall) PKI
DigiNotar Story
COMP3355 Cyber Security (2023 Fall) PKI
DigiNotar Story
Aug. 27th, 2011
An Iranian man “Alibo” couldn’t connect to Gmail
He switched to a virtual private network that disguised his location, and he
can access Gmail
Posted a question about the issue on the Gmail Help Forum
Two days later
Google issued a public statement
Within a month
The Dutch government took over DigiNotar
Within two months
DigiNotar declared bankruptcy and dissolved
COMP3355 Cyber Security (2023 Fall) PKI
DigiNotar Story
On July 19th, DigiNotar found some signed certificates not listed in the
logs, and DigiNotar launched an internal investigation
Aug. 27th, 2011
An Iranian man “Alibo” couldn’t connect to Gmail
He switched to a virtual private network that disguised his location, and he
can access Gmail
Posted a question about the issue on the Gmail Help Forum
Two days later
Google issued a public statement The attacker accessed 300,000
Gmail accounts
Within a month
The Dutch government took over DigiNotar
Within two months
DigiNotar declared bankruptcy and dissolved
COMP3355 Cyber Security (2023 Fall) PKI
Certificate Revocation
Key leaked
CA went wrong
Certificate went wrong
The world went wrong
COMP3355 Cyber Security (2023 Fall) PKI
Demo
https://revoked.badssl.com
Demo
https://www.digicert.com/kb/digicert-root-certificates.htm
Demo Sites for Root revoked
COMP3355 Cyber Security (2023 Fall) PKI
Validation Authority
He is Peter.
Yes
SHA-256 Signature Equal?
No
He is not
Name: Peter Parker Signature Peter.
Organization: The Avengers
Address: New York, USA
…….
Decryption
COMP3355 Cyber Security (2023 Fall) PKI
Validation Authority
Verify the validity of a certificate
Expired? He is Peter.
Revoked?
Yes
SHA-256 Signature Equal?
No
He is not
Name: Peter Parker Signature Peter.
Organization: The Avengers
Address: New York, USA
…….
Decryption
COMP3355 Cyber Security (2023 Fall) PKI
Validation Authority
Verify the validity of a certificate
Expired?
The certificate contains the expiration status
Revoked?
The certificate has no information indicating revocation status
COMP3355 Cyber Security (2023 Fall) PKI
Demo
https://www.apple.com
COMP3355 Cyber Security (2023 Fall) PKI
Demo
https://www.apple.com
Fetch the CRL
wget http://crl.apple.com/apevsrsa2g1.crl
Dump the CRL
openssl crl -inform DER -in apevsrsa2g1.crl -text -out crl.txt
Search the serial number:
2A 70 C0 82 19 20 B6 96 FD 26 B7 5A 72 B8 EC E4
COMP3355 Cyber Security (2023 Fall) PKI
Demo2
https://digicert-tls-ecc-p384-root-g5-revoked.chain-demos.digicert.co
m
COMP3355 Cyber Security (2023 Fall) PKI
Demo2
https://digicert-tls-ecc-p384-root-g5-revoked.chain-demos.digicert.co
m
Fetch the CRLs
wget http://crl3.digicert.com/DigiCertG5TLSECCSHA3842021CA1-1.crl -O 1.crl
wget http://crl4.digicert.com/DigiCertG5TLSECCSHA3842021CA1-1.crl -O 2.crl
Dump the CRLs
openssl crl -inform DER -in 1.crl -text -out crl1.txt
openssl crl -inform DER -in 2.crl -text -out crl2.txt
Search the serial number:
05 9C B6 7A C3 33 6F EE E8 56 B2 72 86 3C 6F 53
COMP3355 Cyber Security (2023 Fall) PKI
Demo
www.hku.hk
Get the certificate
openssl s_client -connect www.hku.hk:443 2>&1 < /dev/null | sed -n '/-----
BEGIN/,/-----END/p' > hku.pem
Get the intermediate certificates
openssl s_client -connect www.hku.hk:443 -showcerts 2>&1 < /dev/null
Copy and paste the intermediate certificates in “chain.pem”
Get the OCSP URI
openssl x509 -text -noout -in hku.pem
Or openssl x509 -noout -ocsp_uri -in hku.pem
Send the OCSP request
openssl ocsp -issuer chain.pem -cert hku.pem -text -url
http://status.geotrust.com
COMP3355 Cyber Security (2023 Fall) PKI
Crypto Review
Symmetric Key
Alice and Bob share a secret key
They encrypt and decrypt messages using the same secret key
COMP3355 Cyber Security (2023 Fall) PKI
Crypto Review
Asymmetric Key
Bob generates a key pair: a public key and a private key
Alice gets Bob’s public key
Alice encrypts the message with the public key
Alice sends the encrypted message to Bob
Bob uses his private key to decrypt the message
COMP3355 Cyber Security (2023 Fall) PKI
Crypto Review
Digital Certificate
Bob generates a key pair: a public key and a private key
CA issues a certificate for Bob’s public key
Alice gets Bob’s certificate
Alice walks through the certificate path to verify Bob’s certificate
Alice gets Bob’s public key from the certificate
Alice encrypts the message with the public key
Alice sends the encrypted message to Bob
Bob uses his private key to decrypt the message
COMP3355 Cyber Security (2023 Fall) PKI
Crypto Review
Digital Certificate with CRL Check
Bob generates a key pair: a public key and a private key
CA issues a certificate for Bob’s public key
Alice gets Bob’s certificate
Alice checks the CRL to make sure Bob’s certificate is not revoked
Alice walks through the certificate path to verify Bob’s certificate
Alice gets Bob’s public key from the certificate
Alice encrypts the message with the public key
Alice sends the encrypted message to Bob
Bob uses his private key to decrypt the message
COMP3355 Cyber Security (2023 Fall) PKI