Professional Documents
Culture Documents
DIGITAL ASSIGNMENT 4
Submitted by:
Prakshaal Jain
21BCE2735
Submitted to:
Prof. Dr. N. Balaji
Q1. Develop a simple client and server
application using SSL socket
communication.
SSL/TLS is a cryptographic protocol designed to provide
secure communication over a network. It ensures the
confidentiality and integrity of data transmitted between a
client and a server. SSL/TLS operates by establishing a
secure connection between the client and server through a
process called the handshake, which involves the following
steps:
1. Client Hello: The client sends a message to the server
indicating which cryptographic algorithms and
protocols it supports.
2. Server Hello: The server responds with its own
message, selecting the highest version of SSL/TLS
supported by both parties and choosing a cipher suite
for encryption.
3. Key Exchange: The client and server agree on a
method to exchange cryptographic keys securely. This
could involve asymmetric encryption (such as RSA)
for key exchange, or Diffie-Hellman key exchange.
4. Certificate Exchange: The server sends its digital
certificate to the client, which contains the server's
public key and other identifying information. The
client verifies the certificate to ensure the server's
authenticity.
5. Session Key Generation: Both parties generate a
shared session key based on the exchanged keys,
which will be used for symmetric encryption and
decryption of data during the session.
6. Encrypted Data Transfer: Once the handshake is
complete, data transmission occurs securely using
symmetric encryption with the shared session key.
Algorithms:
Server Side:
1. Key Exchange Algorithm: Common key exchange
algorithms used on the server side include:
• RSA (Rivest-Shamir-Adleman): Used for both
public key.
• Checking the certificate's chain of trust.
CODE:
SERVER’s Application:
import socket
import ssl
# Server settings
HOST = 'localhost'
PORT = 12345
CERTIFICATE = 'server.crt'
PRIVATE_KEY = 'server.key'
# Create socket
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as
server_socket:
server_socket.bind((HOST, PORT))
server_socket.listen(1)
print("Server listening on {}:{}".format(HOST, PORT))
import socket
import ssl
# Server settings
HOST = 'localhost'
PORT = 12345
CERTIFICATE = 'client.crt'
PRIVATE_KEY = 'client.key'
# Connect to server
with socket.create_connection((HOST, PORT)) as client_socket:
# Wrap socket with SSL
with context.wrap_socket(client_socket,
server_hostname=HOST) as ssl_socket:
message = b"Hello, server!"
ssl_socket.sendall(message)
data = ssl_socket.recv(1024)
print('Received:', data.decode())
INPUT / OUTPUT:
Q2. The goal of this task is to give you a
better understanding of Certificate
Authorities
(CA) and certificates.
Take a look at the CAs certificates that your
computer trusts.
● Windows: Control Panel -> Search
‘Internet Options’ -> Content -> Certificates
Answer these questions:
1. How many root CA certificates does your
computer have?
2. What is something that you found
interesting from looking at the root CA
certificates?
3. Go to google.com using your favourite
browser, and find a way to look at the
certificates for google.com. List the chain of
certificates your browser sees.
4. What is a possible risk of trusting a CA?
Solution: