A production-grade, continuously authenticated, multi-client secure file workspace protocol.
Built by Sripad Hebbar & Sharan Hiremani
Table of Contents
- Overview
- Why SCSWP?
- Features
- Architecture
- Cryptographic Design
- Protocol Lifecycle
- Installation
- Quick Start
- Project Structure
- OpCode Reference
- Error Codes
- Configuration
- IETF Internet Draft
- Contributing
- Authors
- License
Overview
SCSWP (Secure Collaborative State Workspace Protocol) is a stateful, continuously authenticated protocol that enables multiple clients — operating from geographically separated, heterogeneous networks — to securely access and collaboratively manage a shared file workspace hosted on a central authoritative server.
Unlike traditional approaches that address security and collaboration as separate concerns, SCSWP unifies them into a single, coherent protocol with continuous trust evaluation as a first-class requirement.
Why SCSWP?
| Traditional Approach | SCSWP |
|---|---|
| Trust established once at login | Trust evaluated continuously every 5 seconds |
| Binary authenticated/not state | Graduated Trust Score [0–100] with rekeying and suspension |
| Shared keys for all clients | Per-session K1 → K2 → K3 cryptographic key hierarchy |
| No session recovery | DNAC hash-chain enables cryptographic session recovery |
| No fine-grained access control | Capability bitmask ACL per client per workspace |
| No fairness across clients | Priority-scheduled min-heap worker pool with resource debt |
Features
Security
- Mutual X.509 Authentication — Server CA (ECDSA P-384) issues and validates client certificates.
- ECDH Ephemeral Key Exchange — Fresh P-384 key pair per session; no long-term symmetric keys.
- Three-Level Key Hierarchy — K1 (identity) → K2 (authorization) → K3 (active session subkeys).
- AES-256-GCM Envelopes — File payloads and control messages encrypted with per-purpose subkeys.
- HMAC-SHA-256 Signed Trust Signals — Every D/N/P/S update is authenticated.
- Key-Dissolving Bootstrap — Single-use, time-limited tokens; irrevocably consumed on first use.
- Epoch-Based Key Rotation — K3 rotated on trust threshold breach, explicit rekey, or DNAC recovery.
Collaboration
- Mandatory Server-Side Locking — Exclusive write locks prevent undefined concurrent writes.
- Optimistic Version Control — Five conflict resolution policies:
REJECT,RETRY,MERGE,REBASE,CONFLICT VERSION. - Operation Idempotency — UUID-keyed deduplication prevents duplicate writes on reconnection.
- DNAC Session Recovery — Cryptographic hash-chain recovery; no full re-authentication on transient disconnects.
Operations
- Hash-Chained Audit Ledger — Tamper-evident, exportable (CSV) audit log of every operation.
- Priority Worker Pool — Min-heap scheduler with anti-starvation wait-boost and resource-debt fairness.
- SQLite Persistence — Full session, version history, and idempotency records via SQLAlchemy.
- Health Monitoring — CPU, memory, and connection metrics via
psutil. - Server-Sent Events (SSE) — Real-time workspace update notifications to dashboard.
Architecture
Client Request
│
▼
┌─────────────────────┐
│ IDENTITY PLANE │ X.509 certificate validation
│ │ Key-Dissolving bootstrap
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ TRUST PLANE │ D/N/P/S context evaluation (every 5s)
│ │ Trust Score [0–100] with HMAC-signed signals
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ SECURITY PLANE │ K1 / K2 / K3 key hierarchy
│ │ AES-256-GCM envelope + HMAC-SHA-256
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ AUTHORIZATION PLANE │ Capability bitmask ACL
│ │ Per-client, per-workspace
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ RESOURCE PLANE │ Min-heap worker pool (N=8)
│ │ Backpressure + resource-debt fairness
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ WORKSPACE PLANE │ Exclusive write locks
│ │ Optimistic version control
│ │ UUID idempotency
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ STORAGE PLANE │ SQLite file I/O + version history
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ AUDIT / STATE PLANE │ Hash-chained audit ledger
│ │ DNAC chain advancement
└─────────────────────┘
│
▼
Client Response
Cryptographic Design
ECDH (P-384)
│
▼
IKM (shared secret)
│
▼
HKDF-SHA256 ("SCSWP_K1:" ‖ session_id)
│
▼
┌───────┴───────┐
K1 (Session Root Key)
└───────┬───────┘
│
HKDF-SHA256 ("SCSWP_K2:" ‖ workspace ‖ session_id)
│
▼
┌───────┴───────┐
K2 (Workspace Auth Key)
└───────┬───────┘
│
HKDF-SHA256 ("SCSWP_K3:epoch:" ‖ epoch, salt=epoch_nonce) [96 bytes]
│
┌───────────┼───────────┐
│ │ │
▼ ▼ ▼
K3.auth_key K3.ctrl_key K3.payload_key
(HMAC-SHA256) (AES-256-GCM) (AES-256-GCM)
D/N/P/S sigs control msgs file payloads
| Layer | Algorithm | Key Size |
|---|---|---|
| Key Exchange | ECDH P-384 | 384-bit |
| Key Derivation | HKDF-SHA256 | 256-bit output |
| Symmetric Cipher | AES-256-GCM | 256-bit |
| MAC | HMAC-SHA-256 | 256-bit |
| Certificates | X.509 / ECDSA P-384 | 384-bit |
| Digest | SHA-256 | 256-bit |
| Password Hashing | bcrypt | adaptive |
Protocol Lifecycle
UNREGISTERED ──[OP_PROVISION]──► BOOTSTRAP
│
[OP_AUTH / ECDH]
│
▼
AUTHENTICATING
│
[K1 derived]
│
▼
[K2, K3 derived]
│
┌───────────────▼──────────────────┐
│ ACTIVE │◄──────────┐
└──┬──────────────┬────────────┬───┘ │
│ │ │ │
trust<REKEY trust<=SUSPEND disconnect │
│ │ │ │
▼ ▼ ▼ │
REKEYING SUSPENDED DISCONNECTED │
(new K3) │ │
│ DNAC valid? │
│ ┌────┴────┐ │
│ YES NO │
│ │ │ │
│ ▼ ▼ │
│ RECOVERED [re-auth] │
└──────────────────►┴────────────────────────┘
Installation
From PyPI
pip install scswp
From Source
git clone https://github.com/sripadkarthik/scswp.git
cd scswp
pip install -e ".[dev]"
Windows (Batch Installer)
install_deps.bat
Requirements
- Python 3.10+
- See requirements.txt for full dependency list.
Quick Start
1. Start the Server
scswp-server
The server will:
- Generate a CA key pair and self-signed X.509 certificate.
- Bind to a dynamic port and print the WebSocket URL.
- Open the admin dashboard in your browser.
2. Register a Client (via Admin Dashboard)
In the dashboard:
- Click "Add Client".
- Enter a client name and workspace folder.
- Copy the generated bootstrap token (valid for 24 hours, single-use).
3. Start a Client
scswp-client
Enter the server URL and the bootstrap token when prompted. The client will:
- Complete the Key-Dissolving bootstrap.
- Perform mutual X.509 authentication.
- Execute ECDH key exchange and derive K1 → K2 → K3.
- Begin sending D/N/P/S trust signals.
- Open the workspace UI.
Project Structure
scswp/
├── src/
│ └── scswp/
│ ├── server/
│ │ ├── __init__.py
│ │ ├── server_main.py # FastAPI hub, WebSocket handler, trust engine
│ │ ├── worker_pool.py # Min-heap priority scheduler
│ │ ├── database.py # SQLAlchemy / SQLite persistence layer
│ │ ├── acl.py # Capability-based access control
│ │ ├── state_manager.py # Session + DNAC state management
│ │ ├── builder.py # X.509 certificate builder
│ │ └── static/
│ │ ├── index.html # Server admin dashboard
│ │ └── style.css # Glassmorphism UI
│ ├── client/
│ │ ├── __init__.py
│ │ ├── client_main.py # Client entry point + UI
│ │ ├── protocol_worker.py # SCSWP protocol state machine
│ │ └── static/ # Client workspace UI
│ └── shared/
│ ├── __init__.py
│ ├── opcodes.py # OpCode and error code registry
│ └── crypto_utils.py # ECDH, AES-GCM, HKDF, HMAC utilities
├── tests/
│ ├── test_crypto.py
│ ├── test_worker_pool.py
│ └── test_protocol.py
├── draft-hebbar-hiremani-scswp-secure-collaborative-workspace-00.txt
├── draft-hebbar-hiremani-scswp-secure-collaborative-workspace-00.xml
├── pyproject.toml
├── README.md
├── LICENSE
├── CHANGELOG.md
├── requirements.txt
└── install_deps.bat
OpCode Reference
| Value | Name | Direction | Description |
|---|---|---|---|
0x01 |
OP_PROVISION |
C→S | Bootstrap / Key-Dissolving |
0x02 |
OP_AUTH |
C→S | ECDH identity authentication |
0x03 |
OP_TRUST_EVAL |
C→S | D/N/P/S context signal |
0x04 |
OP_WORKSPACE_AUTH |
C→S | Workspace authorization |
0x05 |
OP_FILE_OP |
C→S | File operation (LIST/READ/WRITE/APPEND) |
0x06 |
OP_LOCK |
C→S | Acquire exclusive write lock |
0x07 |
OP_UNLOCK |
C→S | Release write lock |
0x08 |
OP_DNAC_RECOVERY |
C→S | Session recovery via DNAC |
0x09 |
OP_REKEY |
C→S | Explicit K3 epoch rotation |
0x0A |
OP_HEARTBEAT |
C→S | Keep-alive |
0x0B |
OP_ACK |
S→C | Generic success response |
0x0C |
OP_ERROR |
S→C | Error response |
0x0D |
OP_NACK |
S→C | Negative acknowledgement |
Error Codes
| Code | Name | Description |
|---|---|---|
0x01 |
INVALID_BOOTSTRAP_TOKEN |
Token not found or already used |
0x02 |
TOKEN_EXPIRED |
Token validity period elapsed |
0x03 |
AUTH_FAILED |
ECDH or certificate verification failed |
0x04 |
NO_SESSION |
session_id not found |
0x05 |
FILE_LOCKED |
File held by another session |
0x06 |
VERSION_CONFLICT |
expected_version mismatch |
0x07 |
RETRY_REQUIRED |
Client should re-fetch and retry |
0x08 |
PERMISSION_DENIED |
Client lacks required capability |
0x09 |
SESSION_SUSPENDED |
Trust score at or below threshold |
0x0A |
SERVER_BUSY |
outstanding_ops limit reached |
0x0B |
SIGNATURE_INVALID |
HMAC verification failed |
0x0C |
DNAC_MISMATCH |
DNAC recovery hash mismatch |
0x0D |
UNKNOWN_OPCODE |
Received opcode not recognized |
0x0E |
FILE_NOT_FOUND |
Requested file does not exist |
0x0F |
WORKSPACE_NOT_FOUND |
Workspace folder does not exist |
Configuration
Key protocol parameters (configurable in server_main.py):
| Parameter | Default | Description |
|---|---|---|
T_TRUST |
5s |
D/N/P/S evaluation interval |
T_HEARTBEAT |
10s |
Heartbeat interval |
T_TRUST_TIMEOUT |
15s |
Max silence before trust penalty |
REKEY_THRESHOLD |
80.0 |
Trust score below which K3 rotates |
SUSPEND_THRESHOLD |
10.0 |
Trust score below which session suspends |
N_WORKERS |
8 |
Worker pool size |
MAX_OPS_PER_CLIENT |
10 |
Max concurrent ops per client |
DEBT_INCREMENT |
5.0 |
Resource debt per completed op |
DEBT_DECAY |
0.9 |
Resource debt decay per scheduler cycle |
MAX_LOCK_DURATION |
300s |
Max time a write lock can be held |
TOKEN_TTL |
24h |
Bootstrap token validity period |
Trust Score Penalties
| Signal | Penalty |
|---|---|
| Network address change | −15.0 |
| Device identifier change | −60.0 |
| Operation rate > 20 ops / 10s | −5.0 per evaluation |
| HMAC signature invalid | −25.0 |
| Authentication failure | −25.0 |
| Clean evaluation (heal) | +0.5 |
IETF Internet Draft
This repository includes the formal protocol specification as an IETF Internet Draft:
- Plain Text:
draft-hebbar-hiremani-scswp-secure-collaborative-workspace-00.txt - RFC XML (v3):
draft-hebbar-hiremani-scswp-secure-collaborative-workspace-00.xml
The draft covers:
- Normative protocol message format and OpCode space.
- Cryptographic procedures for K1, K2, and K3 derivation.
- DNAC construction and validation procedure.
- File-state record and concurrency control rules.
- Audit record format and hash-chain construction.
- Security considerations and threat analysis.
- IANA registrations.
Contributing
Contributions are welcome! Please:
- Fork the repository.
- Create a feature branch:
git checkout -b feature/your-feature. - Commit your changes:
git commit -m "feat: add your feature". - Push to the branch:
git push origin feature/your-feature. - Open a Pull Request.
Development Setup
git clone https://github.com/sripadkarthik/scswp.git
cd scswp
pip install -e ".[dev]"
pytest
Code Style
black src/ tests/
isort src/ tests/
mypy src/
Authors
|
Sripad Hebbar First Author sripadkarthik@gmail.com |
Sharan Hiremani Second Author sharanrhiremani@gmail.com |
License
This project is licensed under the MIT License — see the LICENSE file for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scswp-0.1.0.tar.gz.
File metadata
- Download URL: scswp-0.1.0.tar.gz
- Upload date:
- Size: 59.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d160d3c0596f026b14cc6baf39b7ebb2c6050172a899f3d1f88c4b24aa4ab195
|
|
| MD5 |
110bc0e46f2fd4105b3925b3482401ec
|
|
| BLAKE2b-256 |
7b1ad278aeb9e09ab515884f904955fba092fc1b573c1e70128d74dda2a9f607
|
File details
Details for the file scswp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: scswp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 55.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc5d987a9d9ab78e8569da273d80c25deb18b3cbc0ef2a3ad09af88b4311d924
|
|
| MD5 |
751b80424efb1c82e85a0a2642ef3784
|
|
| BLAKE2b-256 |
9ebe9f7e100c2dbec6ef3998cc7de461ad9cf1bfd54389ca73140602495d960f
|