This is a AES encrypted implementation of Socket Programming (in C++) which allows multiple clients to connect and chat as a group
Socket Programming is a way of connecting two nodes on a network to communicate with each other, where one node (socket) listens on one of it assigned ports for connections and the other node (socket) reaches out to make connections and relay messages.
Here, in this project the one listening is called the SEVER and the other one is called the CLIENT, which trying to connect to the server. I have used Winsock API to create a network locally on our windows machine for multiple clients to connect to the server in a TCP based connection.
- You start the server which listens on the assigned port for connections.
- Then initiate the client side application, for it to connect to the server.
- Now, after such subsequent connection the server automatically creates another socket (similar to the previous one) and listens for other connection request from other clients.
This implementation facilitates multiple client connections through the use of threads.
- The message or any information exchange between clients and the server is happening in clear text.
- Easily intercepatable by an adversary.
This project was created keeping in mind the deficiencies in the basic traditional socket creation. Hence this secure (encrypted) tunneled connection is safe, easy to use, and non interceptable.
Note :- Visual Studio is used for the development of this application, so make sure you have it installed already with C++ development environment package. I would suggest you to use community edition.
DISCLAIMER: There are visuals included in the Readme to show the steps to follow. They might take sometime to load depending on your connectivity!
-
Clone the Crypto++ Repo. or just search Cyptoo++ github. (you can also download it by searching it on Crypto++ site, I preferred cloning it.)
-
Also download (clone) the Cryptopp PEM. pack.
Make sure to note the location of the cloned repositories or downloads.
-
Now, copy and paste the contents of the CryptoPP PEM folder in the Cryptopp folder. (skip the files if there's a collision.)
-
Search for cryptlib.vcxproj in the Cryptopp folder and open it with Visual Studio.
-
Click on the cyptlib to view the dependencies and right click to add the header files (existing .h files), source files (existing .cpp files) as shown.
- Change the solution configuration to Release, x64.
- Now right click on the cryptlib solution and click build.
- Will take some time to complete and upon completion it will show Build success message in the Output area.
(I already did this process, so it shows me successfully Updated message.)
- You can close it after success.
- Create a new blank project -> Empty C++ project in Visual Studio.
- Add C++ source file in the Source files section.
- Get the code from the Crypto++ site or from the CPP file in this repository. (Cryptopp.cpp).
- Change the solution configuration to Release, x64.
- Paste the code and you will find that the IDE is unable to resolve path for the incuded header files. Don't worry let's add their path.
- Open the project properties as shown.
- Check that the configuration is set to Active(Release) and Platform Active(x64).
- Navigate to C/C++ option in left panel, expand it and click General properties. Click Additional Include Directories and edit it with the path to cryptopp folder as shown.
- Click OK. Then go to Code Generation and change Runtime Library to Multi-threaded (/MT).
- Once this is done, collapse the C/C++ property and expand Linker properties.
- Click General properties. Click Additional Library Directories and edit it with the path to cryptopp\x64\Output\Release folder as shown. Click Ok
- Also change the Enable Incremental Linking to No (/INCREMENTAL:NO).
- Go to the Input properties and Click Additional Dependencies, edit it and write cryptlib.lib and click Ok.
- Once all this is done Click Apply and Ok.
- Woah! Everything will be resolved. Save the file and run it by clicking Local Windows Debugger option.
(hope you followed the steps correctly :)).
- Create a new project and an empty C++ project, name it Server side.
- Add a C++ source file and copy the code from the repository (click here).
- Change the solution configuration to Release, x64.
- Save the Solution.
- Create a new project and an empty C++ project, name it Client side.
- Add a C++ source file and copy the code from the repository (click here).
- Change the solution configuration to Release, x64.
Caution this is the most important part for Client Side.
- Follow the Same steps as followed for basic AES setup above.
- Save the Solution.
- Run the Server Side code first by clicking the Local Windows Debugger.
- Then run the Client side code.
- The terminal windows will appear showing the connection successful message.
- Now just enter the name in the client side terminal and Viola! you can send messages and see if they are encrypted or not.
- This requires nothing special, just create multiple client projects as you have done for single client as it is.
- Run the code once the server is running, enter the names and Bingo! you are all set up.
- Clients can leave the chat if the enter "quit" in chat.
- Generates random keys and IV everytime and for every message, even if the same message was sent multiple times. Making the cipher text unique everytime, un-interceptable and un-decodable.
- Multiple clients can connect and chat without any restrictions.
Do share if you liked my work. Thanks!
😄















