Secure Chat is a C program that allows you host decentralized system and chat securely with your friends. -It implements Diffie-Hellman (DH) key exchange to prevent man-in-the-middle (MitM) attacks, it uses the RSA algorithm to create sessions and AES algorithm for message end-to-end (EE2E) encryption-. Messages are stored in SQLite3 (ultimately other, distributed) database and can be read by the recipient only. Sending messages in optimized for maximum performance and resource usage.
The application uses the OpenSSL library for HTTPS connection, encryption, and decryption. The server acts as a buffer and router for clients. The following algorithms are used:
AES algorithm: Used to encrypt and decrypt messages between clients.
Diffie-Hellman: (DH) key exchange: Used to secretly exchange the AES encryption key between clients for each conversation.
RSA algorithm: Used to create pre-shared public and private keys for each client, enabling secure message buffering when sending messages to new or offline users.
The server does not store any messages, only the public keys of the clients. The messages are stored in the SQLite3 database and can be read by the recipient only. The server does not have access to the messages.
Server is responsible for handling client connections, retrieving messages from the database and sending messages to the recipients. It also manages user registration and authentication according to the protocol. Multithreading is used to allow many concurrent requests and connections. Client connections are stored in a thread-safe hash map and only one logged instance of a client is allowed. Messages before handling are stored in thread-safe queue. Server facilitates CLI for system administration. Server logs all requests, client connections and errors.
Common generates static library that is used by both server and client, i.e. communication protocol, encryption and decryption functions. It also defines the message structure, signal codes, data structures and functions that are shared between server and client.
SQLite3 database is utilized at the moment. There is planned usage of distributed database system Cassandra or MongoDB in the further project iterations.