This project is a simple tcp client-server messaging system with E2E encryption support. The server is implemented with python, and the client is implemented with C++ with Boost and Crypto++.
This is a simple implementation of a client-server TCP based messaging system with end-2-end encryption of messages. Each client has a PKI pair, and will negotiate a symmetric key with each additional client it wish to communicate with. This implementation also fully supports files (including big files).
The request has the following format:
- Client ID - 16 bytes - the client ID
- Version - 1 byte - the version of the client
- Request code - 1 byte - the request code
- Payload size - 4 bytes - the size of the payload
- Payload - dynamic size - the payload data
The response has the following format:
- Version - 1 byte - the version of the server
- Response code - 2 bytes - the server response code
- Payload size - 4 bytes - the size of the payload
- Payload - dynamic size - the payload data
Code = 100 Payload = Name(255 bytes), Public key(160 bytes)
Success response : Code = 1000 Payload = Client ID(16 bytes)
Code = 101 Payload = NONE
Success response: Code = 1001 Payload = For each client: Client ID(16 bytes), Client name (255 bytes)
Code = 102 Payload = Client ID(16 bytes)
Success response: Code = 1002 Payload = Client ID(16 bytes), Public key (160 bytes)
Code = 103 Payload = Client ID(16 bytes), Msg type(1 byte), Msg size(4 bytes), Msg content(Dynamic)
Message types:
- Public key request
- Public key
- Text message
- File message
Success response: Code = 1003 Payload = Client ID(16 bytes), Msg ID (4 bytes)
Code = 104 Payload = NONE
Success response: Code = 1004 Payload = For each message: Client ID(16 bytes), Msg ID(4 bytes), Msg type(1 byte), Msg size(4 bytes), Msg content(Dynamic)
Code = 9000
Name | Responsibility |
---|---|
server_main.py | The main entry point for the server |
bytes_buffer.py | A set of classes to implement large size capable bits stream from various sources |
model.py | Implementation of basic model classes |
storage_manager.py | Storage management which is responsible for storing the clients and messages of the messaging system |
db_storage_manager.py | An SQLite implementation of the StorageManager class |
request_handler.py | Logic handler for the server. responsible for processing the requests and returning the responses |
request_reader.py, response_writer.py, request_payload_parser.py, response_payload_writer.py | Reading and writing requests and responses |
The server requires python version 3.x to run.
To run the server:
- Create a file named "port.info" with the port number information
- Run the command "python server_main.py"
On the first run the SQLite DB will be created by the name "server.db".
Name | Responsibility |
---|---|
MessagingSystemClient | The main entry point for the client application |
TestingManager | Running the test suite |
ByteBuffer, BinaryByteBuffer, FileByteBuffer, SocketByteBuffer | A set of classes to implement large size capable bits stream from various sources |
ClientLogicHandler | Responsible for the implementation of the client actions |
InteractiveMenuManager | Responsible for showing the menu and running the user selected commands |
Request, RequestReader, Response, ResponseWriter | Set of classes for request and response and reading and writing them from the socket |
EncryptionUtils | Facade implementation for all encryption related operations in this project, e.g. generation of keys, and decryption and encryption |
Using Visual studio you will need to set up Boost and Crypto++ and then compile the code.
The client was tested on Linux x64 / Ubuntu OS.
Using eclipse, set up Boost and Crypto++, and compile the project
To run the automatic tests for the client, simply run it with the "test" argument.
To run the client normally:
- Create a file named "server.info" on the running directory with the HOST:PORT information of the server
- Run the "client" command
- Register yourself to start working