The objective of this project was to implement a secure communications channel. Asymmetric encryption, signatures and key management in Java will be utilised to implement a secure protocol.
The project is divided into three sections, with each section built on top of the previous solution. The first section introduces asymmetric encryption, the second introduces key management and finally the third combines the previous two to implement a secure protocol.
The project consists of an Echo Server and a Client program. The server will just echo back the messages recieved back to the client. Howerver, the messages that are passed over the communication channel will be encrypted.
Open two terminals and nivigate to the the src
folder of the project in both of the terminals.
cd src
Compile the following files in one of the terminal sessions.
javac Part1/EchoServer.java Part1/EchoClient.java Part1/Util.java
Run the server program on one terminal and client program on the other
java Part1.EchoServer
java Part1.EchoClient
The following output should be observed
First paste the Client Public key onto the server's terminal and press enter so the server starts listenning for connections. Then paste the Server public key onto the client's terminal.
Once the Server Public key is pasted onto the client's terminal, press enter to prompt the client to send messages to the server.
The following output should be observerd.
The keys were generated using the keytool command which comes with the JCE. The client and server keys were created with same key password for testing purposes. The following commands shown below were used to generate the keys.
keytool -genkey -alias client -keyalg RSA -keystore cybr372.jks -storepass badpassword -keypass password -storetype JKS
keytool -genkey -alias server -keyalg RSA -keystore cybr372.jks -storepass badpassword -keypass password -storetype JKS
Open two terminals and nivigate to the the src
folder of the project in both of the terminals.
cd src
Compile the following files in one of the terminal sessions.
javac Part2/EchoServer.java Part2/EchoClient.java Part2/Util.java
java Part2.EchoServer <storePassword> <keyPassword>
java Part2.EchoClient <storePassword> <keyPassword>
Run the server program on one terminal and the client program on the other. Will also have to specify the store password (badpassword) and the key password.
Note: Ensure that the server program is run first so it's listening for incoming connections.
The following output should be observed.
This sections uses asymmetric encryption for messages regarding key negotiation and once the symmetric keys are generated, symmetric encryption will be used for future messages. This continues until a max message limit is reached where key negotiation occurs again if there are more messages to be sent and received.
Open two terminals and nivigate to the the src
folder of the project in both of the terminals.
cd src
Compile the following files in one of the terminal sessions.
javac Part3/EchoServer.java Part3/EchoClient.java Part3/Util.java
java Part3x.EchoServer <storePassword> <keyPassword> [maxMessages]
java Part3.EchoClient <storePassword> <keyPassword>
Run the server program on one terminal and the client program on the other. Will also have to specify the store password (badpassword) and the key password. The key password for both the client and server is password, for simplicity and testing purposes.
When running the server program, the user can also specify the number of maximum messages that can be received before key negotiation has to be performed again. If not specified this value will be set to 5.
Note: Ensure that the server is ran first and listening for connections.
The following output should be observed.