Version: 1.3 β Federated Secure Chat (Updated 23-10-2025)
Scope: Class-wide standard.
SOCP 1.3 implements a federated end-to-end encrypted chat network. Each user connects to a local server; servers exchange signed presence and messages through a trusted introducer. Every payload is cryptographically signed and encrypted.
- End-to-end encryption (RSA-OAEP + SHA-256).
 - Digital signatures (RSA-PSS + SHA-256) for message authenticity.
 - Secure federation via introducer announcement channel.
 - Dynamic user advertisement and revocation between servers.
 - Command-driven CLI client (/tell, /all, /list, /sendfile, /quit).
 - Full cryptographic key persistence between sessions.
 - Optional sandboxed βbackdoored_version/β.
 
This implementation conforms to SOCP v1.3 (Protocol Freeze: 17-09-2025).
Implemented mandatory features include:
- RSA-4096 encryption (RSA-OAEP, SHA-256)
 - RSASSA-PSS signatures for message integrity
 - End-to-end encrypted direct messages (E2EE)
 - Server β Server gossip for presence updates
 - Bootstrap introducer flow for network join
 - Public channel broadcasting and key distribution
 - Canonical JSON envelope format (one per WebSocket message)
 
                   ββββββββββββββββββββββββββββ
                   β        Introducer        β
                   β (user advertisements +   β
                   β  federation directory)   β
                   ββββββββββββββ¬ββββββββββββββ
                                β
        βββββββββββββββββββββββββΌβββββββββββββββββββββββββ
        β                       β                        β
ββββββββββββββββ       ββββββββββββββββββ        ββββββββββββββββββ
β  Server A    ββββββββΊβ   Server B     βββββββββΊβ   Server C     β
β Local Users  β       β Local Users    β        β Local Users    β
ββββββββββββββββ       ββββββββββββββββββ        ββββββββββββββββββ
        β                        β                         β
     alice                    bob, carol                 dave
- Introducer: maintains a live registry of known servers and users; all communications are signed.
 - Servers: verify incoming signatures, enforce local access control, and relay encrypted payloads.
 - Clients: hold private keys; only clients can decrypt or sign messages.
 
- Encryption β Messages are encrypted with the recipientβs RSA public key using RSA-OAEP (SHA-256).
 - Integrity β All messages are signed with RSA-PSS (SHA-256).
 - Verification β Servers verify signatures before routing.
 - Privacy β Servers cannot decrypt user payloads.
 - Replay Protection (Phase 3 planned) β Timestamp + nonce validation.
 
Security-Programming/
β
βββ Documentation/
β   βββ Developer Setup Guide (Phase 2).md   # Archived: Secure Overlay Chat Protocol overview
β   βββ SCOP.pdf                             # Standard protocol agreement / reference document
β   βββ Reflection_Report/                   # Team reflection and lessons learned
β      βββ Reflective Commentary.pdf         # General reflection: protocols, AI used, testing, peer review, member contributions
β      βββ Appendix/                         # Supporting documents
β         βββ BACKDOOR_README(PoC).md
β         βββ Peer_Review/                   # Holding for both received and given peer reviews
β         βββ Testing Report.pdf             # Testing approach and evidence
β
βββ Implementation/
β   βββ secure_version/                      # Secure implementation (production-ready)
β   β   βββ client.py                        # Client application (connects to server)
β   β   βββ server.py                        # Main server program handling connections
β   β   βββ keys.py                          # Key generation and management logic
β   β   βββ datavault.py                     # Local encrypted data storage and retrieval
β   β   βββ gen_introducer_keys.py           # Utility to generate introducer (server) keys
β   β   βββ introducers.yaml                 # Introducer list (server discovery info)
β   β   βββ requirements.txt                 # Python dependencies
β   β   βββ data_vault.sqlite                # SQLite database file
β   β   βββ data_vault.sqlite-shm            # SQLite shared memory file
β   β   βββ data_vault.sqlite-wal            # SQLite write-ahead log
β   β   βββ downloads/                       # Folder for downloaded files
β   β   βββ __pycache__/                     # Compiled Python bytecode cache
β
β   βββ backdoored_version/                     # Insecure / vulnerable version
β   β   βββ quarantine/                         # PoC attack scripts (for testing/hardening)
β   β   β   βββ poc_inject_unsigned_advert.py   # PoC: send unsigned USER_ADVERTISE to test BACKDOOR_TRUST_GOSSIP
β   β   β   βββ poc_weak_key_register.py        # PoC: register user with intentional 1024-bit RSA key
β   β   βββ ...                                 # Same structure as secure_version but with flaws
β
βββ Testing/
β   βββ test_cases/
β   β   βββ test_client.py                   # Tests for client-side behavior
β   β   βββ test_server.py                   # Tests for server-side operations
β   β   βββ test_keys.py                     # Tests for key handling and persistence
β   β   βββ test_integration.py              # Full integration tests (end-to-end)
β   β   βββ test_security_hardening.py       # Security hardening tests for secure_version
β   β   βββ __pycache__/                     # Cached test bytecode
β
βββ README.md                                # Entry point (this file)
- Python 3.11+ recommended.
 - Linux/Ubuntu dev container (this workspace uses Ubuntu 24.04.2 LTS).
 - Install dependencies via 
requirements.txt:- pytest
 - pytest-asyncio
 - websockets
 - pyyaml
 - cryptography
 
 
# from Implementation/secure_version/
python -m pip install --upgrade pip
python -m pip install -r requirements.txt1. Navigate to the Project Directory:
cd Security-Programming2. Create and Activate a Virtual Environment: macOS/Linux:
python3 -m venv .venv
source .venv/bin/activateWindows (PowerShell):
python -m venv venv
venv\Scripts\activate3. Install Dependencies:
python -m pip install --upgrade pip
python -m pip install -r Implementation/secure_version/requirements.txt4. Generate keys 
Before the first run, generate the introducerβs RSA keys and configuration file:
cd Implementation/secure_version
python gen_introducer_keys.py
1. Start the Introducer
cd Implementation/secure_version
python3 server.py --id 11111111-1111-4111-8111-111111111111 --name introducer1 --port 9001 --introducerExpected output:
loaded existing keys
[keys] Loaded keys for introducer1 β .keys/introducer1.priv.pem / .pub.pem
[vault] SQLite database initialised and public channel ready.
[11111111-1111-4111-8111-111111111111] Listening on ws://127.0.0.1:9001
2. Start Server A and Server B
cd Implementation/secure_version
python3 server.py --name serverA --port 8764
python3 server.py --name serverB --port 8765Expected output:
loaded existing keys
[keys] Loaded keys for serverA β .keys/serverA.priv.pem / .pub.pem
[bootstrap] OK via ws://127.0.0.1:9001 β assigned_id=53e96a0e-f124-4013-a0e9-f5e8df110b9b
[bootstrap] Using server ID: 53e96a0e-f124-4013-a0e9-f5e8df110b9b
[vault] SQLite database initialised and public channel ready.
[53e96a0e-f124-4013-a0e9-f5e8df110b9b] Listening on ws://127.0.0.1:8764
3. Start Clients
cd Implementation/secure_version
python3 client.py --user alice --server ws://127.0.0.1:8764 
python3 client.py --user bob --server ws://127.0.0.1:8765Expected output:
loaded existing keys
Connected to ws://127.0.0.1:8764 as alice (id=ee5966e5-e61d-40e0-a398-6ce2b807931d)
[bootstrap] learned SERVER pubkey for serverA (53e96a0e-f124-4013-a0e9-f5e8df110b9b)
Once connected, each server advertises its local users to others through the introducer.
Step 1: List active users
On Aliceβs terminal:
/list
Expected output:
Connected users:
- bob (ce4732e1-fc12-4c62-a89a-74d5a915b93d)
Step 2: Send an encrypted message
/tell bob Hello Bob, this is a secure message!
Aliceβs client:
- Encrypts with Bobβs public key (RSA-OAEP, SHA-256).
 - Signs message with Aliceβs private key (RSA-PSS, SHA-256).
 - Sends to Server A β Introducer β Server B. 
Bobβs client decrypts and displays: 
alice (ee5966e5-e61d-40e0-a398-6ce2b807931d): Hello Bob, this chat is secure!
Supported commands: /tell, /all, /list, /sendfile, /quit
| Issue | Cause | Fix | 
|---|---|---|
Address already in use | 
Port conflict | Change --port argument | 
cryptography build failed | 
Missing system headers | macOS: brew install openssl β re-install deps | 
Connection refused | 
Server not started or wrong port | Verify introducer + server ports match | 
UnicodeDecodeError  | 
Non-UTF8 payload | Delete old keys and restart | 
βNo active usersβ shown | 
Introducer not reachable | Ensure introducer is running first | 
To verify that the system functions correctly, you can run all automated tests using pytest.
These tests cover individual modules (client.py, server.py, keys.py) as well as end-to-end message exchange.
From the root directory:
pytest -vNote: Ensure that all required dependencies and environment variables are properly set up before running the tests.
The backdoored_version/ directory is provided for educational and testing purposes only.
It intentionally includes insecure patterns to illustrate common vulnerabilities; it is not intended for production use and should be run only in isolated, controlled environments.
For demonstrations or any live testing, we recommend using the secure_version/ implementation.
Developed by group 12 for the University of Adelaide Security Programming course, 2025.
MEMBERS:
- Debasish Saha Pranta (a1963099, debasishsaha.pranta@student.adelaide.edu.au)
 - Samin Yeasar Seaum (a1976022, saminyeasar.seaum@student.adelaide.edu.au)
 - Abidul Kabir (a1974976, abidul.kabir@student.adelaide.edu.au)
 - Sahar Alzahrani (a1938372, sahar.alzahrani@student.adelaide.edu.au)
 - Mahrin Mahia (a1957342, mahrin.mahia@student.adelaide.edu.au)
 - Maria Hasan Logno (a1975478, mariahasan.logno@student.adelaide.edu.au)