Objective: Objective of this assignment is to write a program to establish a connection that sends secure application messages from a client to a server using the Python programming language. This...

1 answer below »
Please find attached assignment info


Objective: Objective of this assignment is to write a program to establish a connection that sends secure application messages from a client to a server using the Python programming language. This process is similar to components that exist in many applications (e.g. secure email, SSH, ..). The secure connection requirement in this assignment refers to providing: • Message confidentiality, • Sender authentication, • Message integrity, • and symmetric key distribution Guidelines: • The assignment consists of two parts. Part 1 will rely solely on public/private key encryption while part 2 will highlight the need for symmetric key encryption e.g. when encrypting large files. • The code for part 2 of the assignment should be an enhancement of the code in part 1. Hence, part 1 should be completed before moving to part 2. • The messages are required to flow from the client to the server. Implementing two-directional message flows will earn bonus marks. • The client and server must communicate in a controlled environment. Both the client and the server should run on the same physical machine. You can pick any method to implement message exchanges between them. Just make sure you state clear (in the README file) how you implemented that. • Assume that the public key is trusted. You need to find a way to share the public key. A simple trusted file on the client and/or server will suffice. • The asymmetric cryptography method of RSA should be used, and keys generated should be 2048 bits long. • The Secure Hash algorithm of SHA256 is required. • The program should be written in Python programming language. Students should use the available cryptography library. • For symmetric encryption, use any algorithm you choose from the available libraries Part 1 • All messages from client to the server are confidential. It is assumed both ends trust the public keys. • Employ the diagram to allow the server to verify it is receiving the message from the client and not anyone else • Server should verify the received message has remained intact all the way it traveled from the Client. • Demonstrate no one can read the message even if they could intercept the message in the transit. Part 2: In part 1 of the assignment, the message was encrypted by asymmetric key, using the server’s public key. This is not an efficient approach for large messages. For part 2 of the assignment, you need to modify the program to fulfill the following features: 1- The client generates a secret key and uses a symmetric algorithm to encrypt the message and signature 2- The client uses the server’s public key to encrypt the secret key. 3- It sends the output of last 2 steps, step 1 and 2, to the server.
Answered Same DayNov 08, 2021

Answer To: Objective: Objective of this assignment is to write a program to establish a connection that sends...

Sandeep Kumar answered on Nov 12 2021
143 Votes
import socket
import select
import base64
import os
from cryptography.fernet import Fernet
from cryptography.hazmat.bac
kends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
password = b"abhilash"
salt = os.urandom(16)
kdf = PBKDF2HMAC(
algorithm=hashes.SHA512(),
length=32,
salt=salt,
iterations=100000,
backend=default_backend()
)
key = base64.urlsafe_b64encode(kdf.derive(password))
f = Fernet(key)
print(key)
HEADER_LENGTH = 10
IP = "127.0.0.1"
PORT = 1234
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_socket.bind((IP, PORT))
server_socket.listen()
sockets_list = [server_socket]
clients = {}
print(f'Listening for connections on {IP}:{PORT}...')
def receive_message(client_socket):
try:
message_header = client_socket.recv(HEADER_LENGTH)
if not len(message_header):
return False
message_length = int(message_header.decode('utf-8').strip())
return {'header': message_header, 'data': client_socket.recv(message_length)}
except:
return...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here