Lab 3
Lab 3
A Research Coursework
Prepared by
Kiran Kumar Mohanraj - 20054954
MSc Cyber Security
University of the West of England, Bristol
1
TABLE OF CONTENTS
2
1. LAB TASK
1.1 Task 1: RSA Key Cryptanalysis
To find the RSA public key, the following details are provided:
N=0x8ee32e2bdc9175272b19d9d64667b3869411e62b090bb16c50cabf0b76353ebcda48f9ae
02d0e27c75e2d5c0bff5c0bab5519609e96428fd86d968a27c619
e=0x11f87
p=0x39340499bcb48d0899db332321af58fc9d0c8424d5992fe255da980c4a2e117
Figure 1 show the procedure for RSA Encryption and how public keys are generated.
For this task, we use SageMathCell for carrying out the mathematical calculation. Using the
above shown formulas, we derive the value of d (public key) as shown in Figure 2.
3
1.2 Task 2: Creating a Certificate Authority (CA)
Before creating a Certificate Authority, we need to setup the configuration file (openssl.cnf).
To use this file, we need to create some directories and sub-directories. These steps are
illustrated in Figure 3.
Once the setup is done, we create a self-signed certificate for our CA. Figure 4 shows the
command for self signing a certificate. The outputs of this command is stored in ca.key and
ca.crt files. The ca.key stores the private key of the CA and ca.crt stores the public-key
certificate. The details provided for self-signing a certificate are shown in Figure 4.
Figure 5 and 6 shows the content of the certificate. The subject and issuer are same which
proves that it is a self-signed certificate. In Basic Constraints, the CA is set TRUE, this shows
that this certificate can sign another certificate. This proves that Certificate Authority has been
created successfully.
4
Figure 5 Self-signed Certificate
5
1.3 Task 3: Using your CA to Issue Certificates
Firstly, we need to generate RSA public-private key pairs. Figure 7 shows the commands used
for key pair generation. To view the key pair, we use the command “openssl rsa -in server.key
-text”.
Now, we create Certificate Signing Request (CSR) with the previously generated server key
pair. This CSR is then sent to the CA to generate a certificate for the key and company name.
6
Figure 8 Creating CSR
Figure 9 shows the commands for issuing the certificate where the previously generated CSR
is converted into X509 certificate using the CA’s private key and public-key certificate.
7
1.4 Task 4: Deploying Certificates in OpenSSL HTTPS Server
Firstly, the DNS should be configured. We need to add our entry to /etc/hosts file so that the
machine recognizes the our website without changing the DNS. This entry maps the hostname
to the localhost. Figure 10 shows the demonstration of the above steps.
For configuring the web server, we combine the key and certificate into a single file and then
launch a web server using openssl s_server command. Figure 11 shows that the server is in
ACCEPT state, indicating server is running.
The port 4433 is the default port which the server can listen. The URL for accessing the server
is: www.UWEKiranMohanraj.com:4433/
When we load the URL, we could see an error, which says connection insecure, is displayed in
the web browser. In Advanced options, we could see a message that our URL uses invalid
security certificates. This is because, the root certificate which we created is not recognised by
browser, thus invalidating our certificate.
8
Figure 12 Accessing the web server using our URL
In order to overcome this error, we manually add our certificate to the browser by navigating
to certificate manager and importing ca.crt. Figure 13 shows the our root CA has been added
as trusted certificates.
Once this setup is done, we try to load our URL in the brower. We could see our index.html
being loaded and contents of it has been displayed (as shown in Figure 14).
9
1.5 Task 5: Deploying Certificates in Apache HTTPS Server
For this we use Apache web server for deploying the certificates. Firstly, we add a VirtualHost
entry to the Apache configuration file (default-ssl.conf). Figure 15 shows our entry added to
the configuration. The ServerName entry specifies the name of the website, while the
DocumentRoot entry specifies where the files for the website are stored
Once the setup is done, we run series of commands for starting the apache server. Firstly, the
confirguration file is tested, then the SSL module is enabled, finnaly the apache server is
configured for HTTPS and restarted. Figure 16 shows the series of commands executed for
doing these steps.
Finally, the web browser is launched for loading the 2 URLs. Figure 17 shows the loading of
https://uwekiranmohanraj.com and Figure 18 shows the loading of
http://uwekiranmohanraj.com. The difference that we can notice is that URL with https shows
a secure connection whereas the http shows connection insecure. The https URL is secure
because the data transfered from the server to the browser is encrypted using SSL, thus creating
a secure encrypted connection.
10
Figure 17 HTTPS secure connection
11
1.6 Task 6: Impersonating a Website (Man-in-the-Middle)
Now, we try to impersonate www.uwe.ac.uk. Firstly, we configure our DNS by adding an entry
to the /etc/hosts file using the UWE url (Figure 19). Similar to previous task, we UWE’s
VirtualHost entry to the apache configuration file. Figure 20 shows this the added entry.
Now we browse our website https://www.uwe.ac.uk and see that we get an error saying that
the connection is not secure. In more details option, we could see the common name of our
UWE url and the certificate does not match, indicating the certificate is not meant for this
domain.
12
Figure 21 Browsing https://www.uwe.ac.uk
This proves that the MITM attack is defeated in the use of public key infrastructure. If the
common name matched, then the website would have loaded. However, the common name will
match only if the server had a valid certificate from the CA for its domain, which it didn’t, in
this case.
When we try to browse http://www.uwe.ac.uk, the we could see that the page has been
redirected to Apache2 Default page (as shown in Figure 22). Thus, proving MITM attack can
be implemented.
13
1.7 Task 7: Alternative Approaches to (Certificate-Based) PKI (Research
Task)
INTRODUCTION
Public-key infrastructure (PKI) is the basis for using public-key cryptography through key
management. PKI helps in authenticating the public key of the user. If the authenticity is
compromised, any user can use it to decrypt the messages, leading to problem of repudiation.
In certificate-based PKI, a Certification Authority (CA) issues a digital certificate which
authenticates the public key of the user. This digital certificate contains the public key and
identity of the user. If the user wants to use other entities public key, they must verify its
certificate for validating the authenticity of the public key. The major drawback of certificate-
based PKI is scalability and certificate management. (Singh et al., 2019).
14
encryption) no escrow from public-key certification, thus producing a hybrid PKI scheme. In
this model, the user generates their own private key or public key pair and request a certificate
from the Certificate authority. For decryption key and proof of certification, the Certificate
authority generates implicit certificate by using IBE scheme. This helps in eliminating the
third-party queries on the certificate status (Gentry, 2003).
Shao (Shao, 2011) propose a new Certificate-Based Encryption scheme from pairings provably
secure in the chosen-key model. This scheme is derived from the CBE scheme of Gentry
(Gentry, 2003), after making some improvements. Each client is allowed to choose its partial
private key and partial public key independently. To deal with the certificate revocation
problem, this paper uses the concept of the time period proposed by Gentry, which is added
into certificate information to eliminate the need of the current certification status. The full
public key of the client is just its certificate information with a time period. As results, anyone
can encrypt messages under the certificate information and the time period so that the receiver
can decrypt only if the receiver’s partial public key is currently certified. However, if a client
entirely trusts the authenticity of a receiver’s partial public key, he could use the partial public
key of the receiver directly to encrypt messages. Furthermore, this high security level is just at
the cost of one more hashing and one more point scalar for encryption, which can be
precomputed once for all. This scheme not only overcomes the weakness in the certified-key
model of the Gentry scheme, but also raises efficiency.
CONCLUSION
The demand for successfully implemented PKI systems is increasing as many organisations
are looking to secure their communications. This report provides various hybrid PKI schemes
involving certificates. There is need for some kind of certification is required in order to solve
the problem of explicit authentication and scalability related issues. UPKI achieves all these
problems except with some communication and complexity overhead.
15
1.8 References
Gentry, C. (2003) ‘Certificate-Based Encryption and the Certificate Revocation
Problem’, in Biham, E. (ed.) Advances in Cryptology --- EUROCRYPT 2003.
Berlin, Heidelberg: Springer Berlin Heidelberg, pp. 272–293.
Lee, B. (2010) ‘Unified Public Key Infrastructure Supporting Both Certificate-
Based and ID-Based Cryptography’, in 2010 International Conference on
Availability, Reliability and Security, pp. 54–61. doi: 10.1109/ARES.2010.49.
Lee, B. and Kim, K. (2000) ‘Self-certificate: PKI using self-certified key’, Proc.
of Conference on Information Security and Cryptology, 10(1), pp. 65–73.
Available at: http://cris.joongbu.ac.kr/publication/selfcert-CISC2000.pdf.
Shamir, A. (1985) ‘Identity-Based Cryptosystems and Signature Schemes’, in
Blakley, G. R. and Chaum, D. (eds) Advances in Cryptology. Berlin,
Heidelberg: Springer Berlin Heidelberg, pp. 47–53.
Shao, Z. (2011) ‘Enhanced Certificate-Based Encryption from pairings’,
Computers & Electrical Engineering, 37(2), pp. 136–146. doi:
https://doi.org/10.1016/j.compeleceng.2011.01.007.
Singh, P. et al. (2019) ‘Towards a Hybrid Public Key Infrastructure (PKI): A
Review’, Cryptology ePrint Archive, 509(Report 2019/784), pp. 1–19.
Available at: https://eprint.iacr.org/2019/784.
16