Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have this code that I made so far but I don't know how to complete it . I have to: At the browser /

I have this code that I made so far but I don't know how to complete it. I have to:
At the browser/client side:
*Validate the self-signed certificate
*Generate a random session key for AES
*Use RSA to encrypt the session key using the servers public key extracted from the certificate
*Send the encrypted session key to the server
At the server side:
*Use the servers private key to decrypt the ession key
*Print out ************ Now both parties have the session key ***************
*The server uses AES to encrypt a message saying Hello Browser
At the browser/client side:
*The Client received the encrypted message and check that it says Hello Browser
*The client uses AES to encrypt a message saying Hello Browser123
At the server side:
*The server decrypts the message and check that it says Hello Browser123
*Print out ************** Secure communicate can start now ******************
The code:
from OpenSSL import crypto, SSL
from socket import gethostname
from pprint import pprint
from time import gmtime, mktime
CERT_FILE = "selfsigned.crt"
KEY_FILE = "private.key"
def create_self_signed_cert():
# create a key pair
k = crypto.PKey()
k.generate_key(crypto.TYPE_RSA, 1024)
# create a self-signed cert
cert = crypto.X509()
cert.get_subject().C ="UK" #The country of the entity
cert.get_subject().ST = "Buckinghshire" #State Or Province Name
cert.get_subject().L = "Buckingham" #locality Name
cert.get_subject().O = "The University of Buckignham" #Organization Name
cert.get_subject().OU = "Computing School" #organizational Unit Name
cert.get_subject().CN = "Kiundae Tuzo" # commonName.. you could use gethostname()
cert.get_subject().emailAddress="hisham.al-assam@buckingham.ac.uk"
cert.set_serial_number(1000)
cert.gmtime_adj_notBefore(0) #time before which the certificate is not valid
cert.gmtime_adj_notAfter(10*365*24*60*60) #time after which the certificate is not validcert.set_issuer(cert.get_subject())
cert.set_pubkey(k)
cert.sign(k, 'sha1')
open(CERT_FILE, "wb").write( crypto.dump_certificate(crypto.FILETYPE_PEM, cert))
open(KEY_FILE, "wb").write(crypto.dump_privatekey(crypto.FILETYPE_PEM, k))
create_self_signed_cert()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

3030302776, 978-3030302771

More Books

Students also viewed these Databases questions

Question

3. List ways to manage relationship dynamics

Answered: 1 week ago