Recent Question/Assignment
Computer Networks 159.334 Assignment 3 Due Friday 17 October 2014
Encryption – a simple implementation of the RSA algorithm
---------------------------------------------------------------------------------------------------------------------------------------
In this assignment, your task is to implement RSA in a simple client/server application using sockets. The client program encrypts all messages sent to the server. Once a connection is established, the server has to send its public key for the session to the client. The client will then use the public key to encrypt messages sent to the server. The server uses its private key to decrypt the messages and print out the decrypted messages received.
For subsequent new connections (new sessions) the server's public and private keys should be different. For this assignment you should use TCP, and you do not have to implement non-blocking communications.
When running the client and server, if the user types into the client “hello”, the server would receive the message, decrypt it and print something like the following:
The server received the message “A85CE8DC452CAE51”
And after decrypting the message received is “hello”
When printing the message received, you should print it in hexademical as above. Be very careful with newline characters because these can throw off the encrypted ciphertext completely, and decrypting would give the wrong answer. You should remove any newline characters before encrypting and before decrypting.
--------------------------------------------------------------------------------------------------------------------------------------
Implementation Details
There are unfortunately a lot of details in a real implementation of RSA that might have to be left out in order to keep this task in the scope of an assignment. You have to ask the following questions regarding some decisions about your implementation of a simple RSA algorithm:
1. What will the sizes of the keys be?
2. Should encryption be done character by character or computed over a set of characters (block-wise)?
3. Should messages be padded?
4. Do you need an arbitrary precision library or will you use keys small enough to use simple exponential code? (Note: you will not be penalised for using small keys).
5. How will the public key be sent from the server to the client? In hexadecimal? What will the packet format look like?
6. Where do the public and private key pairs come from?
The answers to these questions will determine how your encryption protocol works.
-------------------------------------------------------------------------------------------------------------------------------------Specifications:
1. You are allowed to use relatively small prime number pairs, but do not use pairs that will make the same keys for encryption and decryption. So avoid the pair p=5 and q=7, for example.
2. The keys should be different for each subsequent connection (ie. every time a client connects to a running server). You can use a limited set of keys defined statically in your program, or compute a new private/public key pair when the client asks for the establishment of a connection. You can repeat the keys you use every 3 or more connections.
3. You can use the client and server starter programs on Stream, and feel free to change them as you see fit.
--------------------------------------------------------------------------------------------------------------------------------------
Marking - the assignment will be marked based on functionality and design. The marks are distributed as follows :
– 3 marks: successful connection with public keys sent and received
– 3 marks: using different keys for every session (you can repeat the keys after three or more sessions ) – 3 marks: implementation sending a set of alphanumeric characters (at least lower-case a-z, digits 0-9).
– 6 marks: correct implementation for different RSA keys, ie. encryption/decryption results always correct for any keys used.
--------------------------------------------------------------------------------------------------------------------------------------
Notes
1. Submit your client.c and server.c code electronically via Stream.
2. This assignment is worth 15 marks.
3. Marks will be subtracted for obvious copying and/or for delays without justification.