Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help writing client and server code in C++ You will be introduced to public-key cryptography and learn to use stream sockets. Public-key cryptography allows to

Help writing client and server code in C++

image text in transcribed

You will be introduced to public-key cryptography and learn to use stream sockets. Public-key cryptography allows to people to exchange secret signed messages without having to exchange keys to a secure channel. To achieve that goal, it assigns to each user a public key K_p and a secret key K_s that satisfy the three following properties: Messages encrypted with the public key K_p of a user can be only decrypted using the secret key K_s of that user. Messages encrypted with the secret key K_s of a user can be only can be decrypted using the public key K_p of that user. There is no possible algorithm that can compute in a reasonable amount of time the secret key K_s of a user knowing her public key K_p You are to write two programs: A client program that will connect with your server and send it a single message requesting the public key of a user; A server program that will read a list of pairs (user ID, public key) from a file, wait for connection requests from client processes and send them back either a string containing the requested public key or an empty string if the user is not in the table Your server should start by prompting the user for a file name: This file will contain pairs of user IDs and public keys as in: jorge@uh.edu alb234c4567dfl23abc eva@cs.uh.edu 5672c4567dfl23abc54 Both entries will never contain any spaces or tabs. It will then store the contents of the file into a table. Once it is done, it should prompt the user for a port to listen to as in: It should then create a stream socket, bind it to the specified port number, do a listen () to specify a maximum number of queued connection requests and do an accept() that will let it wait for connection requests. Whenever it accepts a connection request, it will read in a string containing a user ID and reply by sending back the associated public key. in addition, a special user request "Terminate" will force the process to terminate: Your client should start by prompting the user for a server host name and a server port number as in: Please note that the only correct answer to the first prompt is the name of the local host as provided by get hostname (). Your client should reject any other entry and prompt for a new entry. It will then create a stream socket, do a connect () request to the specified server, and prompt for a user name as in: After that, the client will request a public key from the server and print it out as in: the public key for user jorge@uh.edu is 25acd09... unless the user entered the user ID "Terminate." 1. Please refer to "BSD Sockets: A Quick and Dirty Primer" on the Piazza resource page. It contains a general introduction to sockets. You can include any code from that document in your assignment. Keep in mind that server and client processes read the messages byte by byte and have no way to know how many bytes they should read. You will need to come with a way to let the sender specify either the length of each message or its end using a non-printable character. Use a single-threaded server to keep things simple. You will not have to not worry about zombies and can safely ignore the fireman () call in the primer. Neither user IDs nor public keys will ever contain spaces or tabs. You can expect user IDs to be short (think of an email address) and private keys a bit longer (but no more than 256 bytes). Each client process will perform a single server request. the server table should be able to store up to 1,024 pairs (user lD, public key). You will be introduced to public-key cryptography and learn to use stream sockets. Public-key cryptography allows to people to exchange secret signed messages without having to exchange keys to a secure channel. To achieve that goal, it assigns to each user a public key K_p and a secret key K_s that satisfy the three following properties: Messages encrypted with the public key K_p of a user can be only decrypted using the secret key K_s of that user. Messages encrypted with the secret key K_s of a user can be only can be decrypted using the public key K_p of that user. There is no possible algorithm that can compute in a reasonable amount of time the secret key K_s of a user knowing her public key K_p You are to write two programs: A client program that will connect with your server and send it a single message requesting the public key of a user; A server program that will read a list of pairs (user ID, public key) from a file, wait for connection requests from client processes and send them back either a string containing the requested public key or an empty string if the user is not in the table Your server should start by prompting the user for a file name: This file will contain pairs of user IDs and public keys as in: jorge@uh.edu alb234c4567dfl23abc eva@cs.uh.edu 5672c4567dfl23abc54 Both entries will never contain any spaces or tabs. It will then store the contents of the file into a table. Once it is done, it should prompt the user for a port to listen to as in: It should then create a stream socket, bind it to the specified port number, do a listen () to specify a maximum number of queued connection requests and do an accept() that will let it wait for connection requests. Whenever it accepts a connection request, it will read in a string containing a user ID and reply by sending back the associated public key. in addition, a special user request "Terminate" will force the process to terminate: Your client should start by prompting the user for a server host name and a server port number as in: Please note that the only correct answer to the first prompt is the name of the local host as provided by get hostname (). Your client should reject any other entry and prompt for a new entry. It will then create a stream socket, do a connect () request to the specified server, and prompt for a user name as in: After that, the client will request a public key from the server and print it out as in: the public key for user jorge@uh.edu is 25acd09... unless the user entered the user ID "Terminate." 1. Please refer to "BSD Sockets: A Quick and Dirty Primer" on the Piazza resource page. It contains a general introduction to sockets. You can include any code from that document in your assignment. Keep in mind that server and client processes read the messages byte by byte and have no way to know how many bytes they should read. You will need to come with a way to let the sender specify either the length of each message or its end using a non-printable character. Use a single-threaded server to keep things simple. You will not have to not worry about zombies and can safely ignore the fireman () call in the primer. Neither user IDs nor public keys will ever contain spaces or tabs. You can expect user IDs to be short (think of an email address) and private keys a bit longer (but no more than 256 bytes). Each client process will perform a single server request. the server table should be able to store up to 1,024 pairs (user lD, public key)

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

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions