CSE 539: Applied Cryptography
Project 5, Due date: Nov 19 2019
[Groups of TWO]
Digital certificates are electronic documents that are used to identify an individual, company, server, or other entity while associating the identity with a public key. You could think of a digital certificate like that of a passport, driverís license, or personal ID which provides a recognized proof of identity. Digital certificates can be essential to security. The implementation of digital certifications assists in the problem of impersonation as it is privacy-based which will allow the private data to be protected and prevents those without access from viewing. The purpose of this project is to challenge students to write a program that interacts with given certificates.
Students will be able to:
● Differentiate digital certificates and certification authority (CA)
● Encrypt and decrypt strings with RSA using public and private keys
● Explain ubiquity
● Python 3 on Linux
In cryptography, a certification authority (CA) is an entity that issues digital certificates. A CA acts as a trusted third party who can be trusted both by the owner of the certificate and the party relying upon the certificate. A digital certificate certifies that a public key is owned by the named owner of the certificate (subject). The format of these certificates is specified by the X.509 or OpenSSL standards. A very common use for certificate authorities is to sign certificates used in HTTPS, the secure browsing protocol for the WWW.
A certificate is essential to circumvent a malicious party which happens to be on the route to a target server which acts as if it were the target. The client (your browser) uses the CA certificate to authenticate the CA signature on the server certificate as part of the authorizations before launching a secure connection. Usually, browsers include a set of trusted CA certificates. The quantity of internet browsers, other devices, and applications which trust certificate authority is referred to as ubiquity.
Submission Directions for Project Deliverables
This project should be submitted electronically and will be graded by execution of the program. Use Python, and provide a README with details on how to execute your program. Keep in mind that during grading, the programs will be executed on a Linux machine - do not use paths like C:\\ in your code. Keep them relative according to Linux norms for ease of grading.
Method of Submission:
Submit your program as a single file named CertAuth.py. The OpenSSL and cryptography Python 3 libraries will be needed, see ďHow toĒ below.
For this assignment you have been provided 3 certificates in the certificate.zip file:
● A public certificate (subject.crt)
● A backup file containing the private key corresponding to it (cert_bckup.p12)
○ Password on the .p12 file: CSE539_Rocks!
● The CA public certificate (root.cer)
Write a Python 3 program to do tasks 1-6. For each task, you should print out the relevant value as a line of text.
1. Verify the Subjectís certificate (print True if valid, False otherwise)
2. Print the following form on the Subjectís certificate (where applicable, print the common name):
a. Subject name
c. Serial Number
d. Encryption Algorithm
e. Not Valid Before
f. Not Valid After
3. Print the Subjectís public and private key (the public key is represented by the integers n and e; and, the private key, by the integer d)
a. Public Key Modulus (n)
b. Public Key Exponent (e)
c. Private Key Exponent (d)
4. Print the public Key of Certification Authority.
a. Root Public Key Modulus (n)
b. Root Public Key Exponent (e)
5. Print the hex signature on the Subjectís certificate
6. Encrypt the following string using RSA: bíHello Worldí. Use OEAP padding, the mask generation function MGF1, and the SHA256 hash function. Note that encryption may not produce deterministic results. You can verify your encryption algorithm by writing a decryption algorithm in the same way. For encryption, use the subjectís public key. For decryption, use the subjectís private key.
For submission, your program should work with any files from the command line. You will receive as input, in order: the p12 file path, the CA (root) crt file path, the client (subject) crt file path, and the password. A sample of running the program with the given input files and a sample output is included at the end of this document. As mentioned above, encrypt may return a different value.
You will need to create certificate objects with both the OpenSSL and the x509 cryptography libraries. Printing signature in hex format is possible only with x509. Print all other the information using the OpenSSL certificate object only. You will need to supply CSE539_Rocks! as the password to access private certificate data for the sample file.
You can use X509Store method in
the OpenSSL crypto package. You will need to create a store object and add root
certificate to it. After you create an X509 store context object and add store
and subject certificate to it, you can call the verify method on the store
Note that verify either returns true or throws an exception, so you will need to handle the exception using try catch like construct.
Read Public and Private Key:
Read the public key from the subject.crt certificate. A private key is only available in the .p12 backup file. You will need to supply the password CSE539_Rocks! to access the private key data. Read the CA public key from the root.crt certificate.
Encrypt and Decrypt:
You donít need to initialize a new key object; use the public key and private key objects you received when reading the subjectís public and private certificate. Use a public key to encrypt and a private key to decrypt.
Sectigo RSA Domain Validation Secure Server CA