Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.This is an extension of previous assignment. Using only symmetric key crypto (AES), extend your previous system: (a) to support integrity (in addition to confidentiality)

1.This is an extension of previous assignment. Using only symmetric key crypto (AES), extend your previous system: (a) to support integrity (in addition to confidentiality) of exchanged files (b) allow for files to be exchanged in either direction that is, from client to server and server to client.

prevous assignment was: Build a file server from which a client can request files. Pick a programming language and investigate how to use its networking libraries. Conduct some research on network or socket programming in the language you choose. I recommend Python, Java or C++. Build on the above so as to provide confidentiality of the files transmitted by the server to the client. Use a symmetric key crypto algorithm such as AES in CBC mode. Generate a key on the server side. Export this key into a file. Using a secure channel, copy this file (key) to the client computer. Consult the crypto libraries for the programming language you chose. For example, for Java, do an Internet search on Java Crypto library or Java encryption example. You can find crypto libs for C++ and Python as well. The goal is to learn how to use the crypto APIs for symmetric key encryption and decryption, key generation and for exporting the key so it can be shared between the client and the server.

Code: import os import socket from cryptography.fernet import Fernet

# Generate a symmetric key using AES in CBC mode key = Fernet.generate_key()

# Write the key to a file on the server side with open('keyfile.key', 'wb') as file: file.write(key)

# Define a function to securely send the key file to the client def send_key(conn): # Open the key file and read its contents with open('keyfile.key', 'rb') as file: key_data = file.read() # Send the size of the key file to the client conn.sendall(len(key_data).to_bytes(4, byteorder='big')) # Send the key file itself to the client conn.sendall(key_data)

# Define a function to securely receive the key file on the client sidea def receive_key(conn): # Receive the size of the key file from the server key_size = int.from_bytes(conn.recv(4), byteorder='big') # Receive the key file itself from the server key_data = b'' while len(key_data) < key_size: chunk = conn.recv(min(key_size - len(key_data), 1024)) if not chunk: raise Exception('Failed to receive key') key_data += chunk # Write the key file to disk on the client side with open('keyfile.key', 'wb') as file: file.write(key_data)

# Set up a socket server to listen for client connections server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.bind(('localhost', 8000)) server_socket.listen(1)

# Wait for a client to connect and receive the key file from the server conn, addr = server_socket.accept() receive_key(conn)

# Once the key file is received, create a Fernet instance on the client side with open('keyfile.key', 'rb') as file: key = file.read() fernet = Fernet(key)

** do it in JAVA

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_2

Step: 3

blur-text-image_3

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

How can you defend against SQL injection attacks?

Answered: 1 week ago

Question

=+4 How does one acquire a global mindset?

Answered: 1 week ago

Question

=+2 How can the effectiveness of global virtual teams be improved?

Answered: 1 week ago