Question: WIRTE TWO PROGRAMS ONE A CLIENT PROGRAM AND ONE A SERVER PROGRAM. WRITE IN C + + Objective You will be introduced to public -

WIRTE TWO PROGRAMS ONE A CLIENT PROGRAM AND ONE A SERVER PROGRAM. WRITE IN C++
Objective
You will be introduced to public-key cryptography and
learn to use datagram sockets.
PUBLIC-KEY CRYPtogRAPHY
Public-key cryptography allows people to exchange secret
signed messages without exchanging 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 only be decrypted using the secret key K_(s) of that
user.
Messages encrypted with the secret key K_(s) of a user
can only be decrypted using the public key K_(F) 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)
Your client/server Pair
You are to write two programs:
A client program that will connect with your server
and ask for the public key of a given 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
a code notifying them that the user is not in the
database.
The server program
Your server should start by prompting the user for a file
name:
Enter a file name: keys2.txt
This file will contain pairs of user IDs and public keys as
in:
jorge@uh.edu alb234c4567df123abc
eva@rice.edu 5672c4567df123abc54
Both entries will never contain any white spaces. It
will then store the contents of the file into a table. Your
server should then prompt for a port number as in:
Enter the server port number: 2468
It will then:
Create a datagram socket in the Internet domain,
Do a bind() to bind the socket to the specified port
number.
Enter an infinite loop where it will repeatedly do a
recvfrom() to receive user IDs from its clients then a
sendto () to reply with the corresponding public keys.
For debugging and grading purposes, your server
should print out the user ID it receives and its status as:
jorge@uh.edu: Found a public key
rick@tamu.edu: Not in the database
Your server will keep accepting client requests until
it receives a Done message from one of its clients. In that
case, it should terminate after printing:
Terminated by user request.
THE CLIENT PROGRAM
Your client should start by prompting the user for a
server hostname and a server port number as:
Enter the server hostname: localhost
Enter the server port number: 2468
It will then prompt for a user ID as:
Enter a user ID: jorge@uh.edu
It should then create a datagram socket, do a
sendto () to send the user ID to the server then a
recvfrom() to get its reply. Once this reply has arrived,
the client should display the outcome of the query as:
The public key for jorge@uh.edu is alb234...
The user rickgtamu.edu is not in the database.
Unlike the server, each client will only handle a single
request.
Hints
Use a single-threaded server to keep things simple.
If you do your assignment on the WSL you should
know that the hostname of your PC does not contain a
domain, say, something like cs.uh.edu. Use
instead localhost.
Please name the two files you will submit
FirstName_LastName_client. {c, cpp} and
FirstName_LastName_server{c,.cpp}.
WIRTE TWO PROGRAMS ONE A CLIENT PROGRAM AND ONE A

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!