quantumguard-cnsa2 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. quantumguard_cnsa2-0.2.0/LICENSE +21 -0
  2. quantumguard_cnsa2-0.2.0/MANIFEST.in +4 -0
  3. quantumguard_cnsa2-0.2.0/PKG-INFO +456 -0
  4. quantumguard_cnsa2-0.2.0/README.md +404 -0
  5. quantumguard_cnsa2-0.2.0/SECURITY_AUDIT_REPORT.md +103 -0
  6. quantumguard_cnsa2-0.2.0/benchmarks/__init__.py +1 -0
  7. quantumguard_cnsa2-0.2.0/benchmarks/results.json +579 -0
  8. quantumguard_cnsa2-0.2.0/benchmarks/satqkd_erasure_bench.py +597 -0
  9. quantumguard_cnsa2-0.2.0/formal/README.md +46 -0
  10. quantumguard_cnsa2-0.2.0/formal/quantumguard_handshake.spthy +254 -0
  11. quantumguard_cnsa2-0.2.0/pyproject.toml +90 -0
  12. quantumguard_cnsa2-0.2.0/quantumguard/__init__.py +81 -0
  13. quantumguard_cnsa2-0.2.0/quantumguard/__main__.py +6 -0
  14. quantumguard_cnsa2-0.2.0/quantumguard/cbom_scanner.py +583 -0
  15. quantumguard_cnsa2-0.2.0/quantumguard/cli.py +389 -0
  16. quantumguard_cnsa2-0.2.0/quantumguard/crypto_core.py +845 -0
  17. quantumguard_cnsa2-0.2.0/quantumguard/dashboard.py +413 -0
  18. quantumguard_cnsa2-0.2.0/quantumguard/guard.py +911 -0
  19. quantumguard_cnsa2-0.2.0/quantumguard/kme_mock.py +227 -0
  20. quantumguard_cnsa2-0.2.0/quantumguard/py.typed +0 -0
  21. quantumguard_cnsa2-0.2.0/quantumguard/sidechannel.py +300 -0
  22. quantumguard_cnsa2-0.2.0/quantumguard/tunnel.py +598 -0
  23. quantumguard_cnsa2-0.2.0/quantumguard_cnsa2.egg-info/PKG-INFO +456 -0
  24. quantumguard_cnsa2-0.2.0/quantumguard_cnsa2.egg-info/SOURCES.txt +40 -0
  25. quantumguard_cnsa2-0.2.0/quantumguard_cnsa2.egg-info/dependency_links.txt +1 -0
  26. quantumguard_cnsa2-0.2.0/quantumguard_cnsa2.egg-info/entry_points.txt +2 -0
  27. quantumguard_cnsa2-0.2.0/quantumguard_cnsa2.egg-info/requires.txt +26 -0
  28. quantumguard_cnsa2-0.2.0/quantumguard_cnsa2.egg-info/top_level.txt +1 -0
  29. quantumguard_cnsa2-0.2.0/setup.cfg +4 -0
  30. quantumguard_cnsa2-0.2.0/tests/test_cbom_and_dashboard.py +238 -0
  31. quantumguard_cnsa2-0.2.0/tests/test_crypto_core.py +223 -0
  32. quantumguard_cnsa2-0.2.0/tests/test_security_fuzz.py +305 -0
  33. quantumguard_cnsa2-0.2.0/tests/test_tunnel_and_guard.py +223 -0
  34. quantumguard_cnsa2-0.2.0/tests/test_wycheproof_and_kat.py +433 -0
  35. quantumguard_cnsa2-0.2.0/tests/vectors/SHA256SUMS.txt +7 -0
  36. quantumguard_cnsa2-0.2.0/tests/vectors/aes_gcm_test.json +5018 -0
  37. quantumguard_cnsa2-0.2.0/tests/vectors/ecdh_secp384r1_test.json +11692 -0
  38. quantumguard_cnsa2-0.2.0/tests/vectors/hkdf_sha384_test.json +1175 -0
  39. quantumguard_cnsa2-0.2.0/tests/vectors/nist_fips203_mlkem1024_encapdecap.json +526 -0
  40. quantumguard_cnsa2-0.2.0/tests/vectors/nist_fips203_mlkem1024_keygen.json +216 -0
  41. quantumguard_cnsa2-0.2.0/tests/vectors/nist_fips204_mldsa87_keygen.json +191 -0
  42. quantumguard_cnsa2-0.2.0/tests/vectors/nist_fips204_mldsa87_sigver.json +739 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Runtime-Slayers Research Group
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include LICENSE README.md SECURITY_AUDIT_REPORT.md
2
+ recursive-include tests/vectors *.json *.txt
3
+ recursive-include formal *.spthy *.md
4
+ recursive-include benchmarks *.py *.json
@@ -0,0 +1,456 @@
1
+ Metadata-Version: 2.4
2
+ Name: quantumguard-cnsa2
3
+ Version: 0.2.0
4
+ Summary: CNSA 2.0 Hybrid PQC (SecP384r1MLKEM1024 + ML-DSA-87) + ETSI GS QKD 014 Transport, Downgrade Firewall & Automated CBOM CI Gate
5
+ Author: Runtime-Slayers Research Group
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Runtime-Slayers/QuantumGuard
8
+ Project-URL: Repository, https://github.com/Runtime-Slayers/QuantumGuard
9
+ Project-URL: Documentation, https://github.com/Runtime-Slayers/QuantumGuard#readme
10
+ Project-URL: Issues, https://github.com/Runtime-Slayers/QuantumGuard/issues
11
+ Project-URL: Changelog, https://github.com/Runtime-Slayers/QuantumGuard/releases
12
+ Project-URL: Security, https://github.com/Runtime-Slayers/QuantumGuard/blob/main/SECURITY_AUDIT_REPORT.md
13
+ Keywords: post-quantum-cryptography,cnsa-2.0,ml-kem-1024,ml-dsa-87,qkd,etsi-014,cbom,cyclonedx,downgrade-firewall,fips-203,fips-204
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Security :: Cryptography
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.11
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: cryptography>=50.0.0
28
+ Requires-Dist: fastapi>=0.165.1
29
+ Requires-Dist: starlette>=1.10.0
30
+ Requires-Dist: anyio>=4.16.0
31
+ Requires-Dist: uvicorn>=0.30.0
32
+ Requires-Dist: httpx>=0.27.0
33
+ Requires-Dist: pydantic>=2.8.0
34
+ Requires-Dist: rich>=13.0.0
35
+ Provides-Extra: bench
36
+ Requires-Dist: numpy>=2.0.0; extra == "bench"
37
+ Requires-Dist: scipy>=1.14.0; extra == "bench"
38
+ Requires-Dist: stim>=1.14.0; extra == "bench"
39
+ Requires-Dist: pymatching>=2.2.0; extra == "bench"
40
+ Requires-Dist: ldpc>=2.3.0; extra == "bench"
41
+ Provides-Extra: dev
42
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
43
+ Requires-Dist: pytest-timeout>=2.3.0; extra == "dev"
44
+ Requires-Dist: bandit>=1.7.0; extra == "dev"
45
+ Requires-Dist: ruff>=0.15.0; extra == "dev"
46
+ Requires-Dist: pip-audit>=2.10.0; extra == "dev"
47
+ Requires-Dist: hypothesis>=6.150.0; extra == "dev"
48
+ Requires-Dist: schemathesis>=4.30.0; extra == "dev"
49
+ Requires-Dist: numpy>=2.0.0; extra == "dev"
50
+ Requires-Dist: scipy>=1.14.0; extra == "dev"
51
+ Dynamic: license-file
52
+
53
+ # QuantumGuard (`quantumguard-cnsa2` v0.2.0)
54
+
55
+ [![PyPI version](https://img.shields.io/pypi/v/quantumguard-cnsa2.svg)](https://pypi.org/project/quantumguard-cnsa2/)
56
+ [![CI & Tamarin Verification](https://github.com/Runtime-Slayers/QuantumGuard/actions/workflows/ci.yml/badge.svg)](https://github.com/Runtime-Slayers/QuantumGuard/actions/workflows/ci.yml)
57
+ [![CNSA 2.0 CBOM Gate](https://github.com/Runtime-Slayers/QuantumGuard/actions/workflows/quantumguard-cbom.yml/badge.svg)](https://github.com/Runtime-Slayers/QuantumGuard/actions/workflows/quantumguard-cbom.yml)
58
+ ![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue)
59
+ ![License: MIT](https://img.shields.io/badge/license-MIT-green)
60
+ ![Standards: CNSA 2.0 / FIPS 203 & 204](https://img.shields.io/badge/standards-CNSA%202.0%20%7C%20FIPS%20203%20%7C%20FIPS%20204-0ea5e9)
61
+
62
+ **CNSA 2.0 Hybrid Post-Quantum Transport (`SecP384r1MLKEM1024` + `ML-DSA-87`) + ETSI GS QKD 014 Key Engine, Active Downgrade Firewall, Side-Channel & Tamarin Formal Verification Suite**
63
+
64
+ ![QuantumGuard v0.2.0 Architecture](https://raw.githubusercontent.com/Runtime-Slayers/QuantumGuard/main/assets/quantumguard-architecture.svg)
65
+
66
+ `quantumguard-cnsa2` (imported in Python as `quantumguard`, CLI entrypoint `quantumguard`) is an open-source, `pip`-installable cryptographic transport and verification toolkit backed by OpenSSL 4.0 / `cryptography>=50.0.0`. It combines wire-level CNSA 2.0 hybrid post-quantum key exchange, pluggable ETSI GS QKD 014 key delivery (live REST HTTP KME or pooled finite-key LEO Decoy-BB84 simulation), an active downgrade & asymmetric-abort firewall (`NSA PP-26-4956`), CycloneDX v1.6 Cryptographic Bill of Materials (CBOM) CI gating (**NSA CNSA 2.0**, **US EO 14412**, **India CERT-In / DST CII**), and three non-AI ground-truth assurance pillars (**Project Wycheproof + NIST ACVP FIPS 203/204 KATs**, **India `TEC 91011:2026` / `dudect` Welch's t-test timing detector**, and a **Tamarin Prover** symbolic handshake model).
67
+
68
+ ---
69
+
70
+ ## Why QuantumGuard? (Threat Model & Design Overview)
71
+
72
+ | Risk Addressed | QuantumGuard Control | Module |
73
+ |---|---|---|
74
+ | **Harvest-Now-Decrypt-Later (CRQC)** | Hybrid `RFC 10024` `SecP384r1MLKEM1024` (`1665 B`) + `ETSI GS QKD 014` mixed via transcript-bound `HKDF-SHA384` | `quantumguard/crypto_core.py` |
75
+ | **Algorithm Downgrade & Key-Swap Attacks** | Rejects legacy curves/suites, stripped key shares (`< 1665 B`), forged `ML-DSA-87` signatures, and `qkd_key_id` swaps/replays (`PP-26-4956`) | `quantumguard/guard.py` |
76
+ | **Pre-Auth Memory DoS & Asymmetric Aborts** | `64 KiB` pre-auth frame ceiling (`PRE_AUTH_MAX_FRAME_BYTES`) + `CLIENT_FINISH` / `SERVER_COMMIT_ACK` commitment barrier before `AppData` | `quantumguard/tunnel.py` |
77
+ | **Timing Side Channels (`TEC 91011:2026`)** | Branchless `GF(2^128)` `WegmanCarterMAC`, `hmac.compare_digest` key comparison, constant-time `ML-KEM-1024` implicit rejection + statistical `dudect` verifier | `quantumguard/sidechannel.py` |
78
+ | **Classical-EC Compromise in Symbolic Analysis** | Dolev-Yao Tamarin model proving `session_key_secrecy` even when classical `ECDH P-384` ephemeral scalars leak | `formal/quantumguard_handshake.spthy` |
79
+ | **Legacy Cryptography Sprawl in CI/CD** | AST + multi-language CBOM scanner failing CI (`exit 1`) on prohibited standalone classical crypto and emitting CycloneDX v1.6 JSON | `quantumguard/cbom_scanner.py` |
80
+
81
+ ---
82
+
83
+ ## Architecture
84
+
85
+ ```mermaid
86
+ flowchart LR
87
+ Cli["Client / Local TCP Proxy<br/>(quantumguard connect)"] -->|"CLIENT_HELLO<br/>RFC 10024 1665 B + Key_ID + ML-DSA-87"| FW["Active Downgrade Firewall<br/>(guard.py / PP-26-4956)"]
88
+ KMS["ETSI GS QKD 014 Provider<br/>(REST HTTPS or LEO Decoy-BB84)"] -->|"256-bit K_QKD + key_ID"| Cli
89
+ KMS -->|"key_ID lookup (no replay)"| Srv
90
+ FW -->|"Inspect Suite / Nonce / Key_ID / Sig"| Srv["Tunnel Server<br/>(quantumguard serve)"]
91
+ Srv -->|"SERVER_HELLO + HKDF-SHA384<br/>Transcript & Key_ID Bound"| Cli
92
+ Cli -->|"CLIENT_FINISH<br/>ML-DSA-87 + GF(2^128) WC MAC"| Srv
93
+ Srv -->|"SERVER_COMMIT_ACK Barrier"| Cli
94
+ Cli <-->|"AES-256-GCM AEAD + Epoch Ratchet"| Srv
95
+ Repo["Source & Configs<br/>(.py .c .cpp .h .js .ts .yml .conf Dockerfile)"] -->|"AST + Regex Audit"| CBOM["CycloneDX v1.6 CBOM Gate<br/>(quantumguard audit / GitHub Action)"]
96
+ ```
97
+
98
+ ### Verified Cryptographic & Protocol Components
99
+
100
+ 1. **Real FIPS 203 / FIPS 204 / RFC 10024 Core (`quantumguard/crypto_core.py`)**
101
+ - `ML-KEM-1024`: `ek = 1568 B`, `ct = 1568 B`, `ss = 32 B`
102
+ - `ML-DSA-87`: `pk = 2592 B`, `sig = 4627 B`
103
+ - `ECDH P-384` uncompressed X9.62 point (`97 B`, `48 B` shared secret) combined into `1665 B` `SecP384r1MLKEM1024` shares (`group_id = 0x11ED`)
104
+ - Domain-separated `HKDF-SHA384` binding `K_QKD || K_MLKEM1024 || K_P384` to `SHA384(transcript) || suite_id || qkd_key_id` (mitigating Dependent-Key attacks)
105
+ - `AES-256-GCM` record layer with strict monotonic `(epoch, seq)` replay rejection, HKDF-SHA384 key ratcheting, and GF(2^128) $\varepsilon$-$\text{ASU}_2$ `WegmanCarterMAC` for handshake commit frames
106
+ - Pluggable `ETSI GS QKD 014` `KeyProvider`: REST/HTTPS `Etsi014Client` (`/enc_keys`, `/dec_keys`) and `SimulatedLEOBB84Provider`
107
+
108
+ 2. **Active Downgrade & Asymmetric-Abort Firewall (`quantumguard/guard.py`)**
109
+ - Blocks stripped PQ shares (`< 1665 B`), legacy/forbidden cipher suites (`X25519`, `P-256`, `RSA-2048`, `TLS 1.2`, `X25519MLKEM768` under strict CNSA 2.0), corrupted `ML-DSA-87` signatures, `qkd_key_id` swaps/replays, stale nonces, and premature aborts prior to `SERVER_COMMIT_ACK`
110
+ - Built-in 6-vector Red-Team fuzz suite (`quantumguard attack-test`)
111
+
112
+ 3. **Low-Latency Binary Wire Tunnel & TCP Proxy (`quantumguard/tunnel.py`)**
113
+ - `TCP_NODELAY=1`, compact `QG2B` binary handshake (`18,154 B` total wire bytes vs `30,809 B` JSON in v0.1.0), `PRE_AUTH_MAX_FRAME_BYTES = 65_536` DoS ceiling, cached `AESGCM` instances, and `writelines` scatter/gather `128 KiB` record streaming (`> 200 MB/s` local loopback echo)
114
+ - `TunnelServer` (`echo` or decrypted TCP `--upstream` forwarding) and `TunnelClient` (`one-shot` echo probe or local port-forwarding proxy bridge via `--listen`)
115
+
116
+ 4. **Automated CycloneDX v1.6 CBOM Scanner (`quantumguard/cbom_scanner.py`)**
117
+ - AST-based Python analysis (recognizing standalone vs. hybrid `ECDH-P384 + ML-KEM-1024`) plus context-aware rules for `.c`, `.cpp`, `.h`, `.js`, `.ts`, `.yml`, `.yaml`, `.conf`, and `Dockerfile`
118
+ - Returns exit code `1` on CNSA 2.0 policy violations and `0` when compliant
119
+
120
+ 5. **CLI, FastAPI Security Console & ETSI GS QKD 014 Mock KME (`quantumguard/cli.py`, `dashboard.py`, `kme_mock.py`)**
121
+ - Interactive web UI (`/`) and JSON endpoints (`/api/fips-selftest`, `/api/handshake`, `/api/attack-test`, `/api/audit-snippet`) with HTTP security headers & 256 KiB payload limits
122
+ - Live ETSI GS QKD 014 v1.1.1 HTTP KME server (`quantumguard kme-mock`) exposing `GET /api/v1/keys/{slave_sae_id}/status`, `POST /api/v1/keys/{slave_sae_id}/enc_keys`, and single-use `POST /api/v1/keys/{master_sae_id}/dec_keys` (`404`/`410` replay & TTL rejection)
123
+
124
+ 6. **Non-AI Cryptographic Assurance Stack (`tests/test_wycheproof_and_kat.py`, `quantumguard/sidechannel.py`, `formal/`)**
125
+ - **Project Wycheproof v1 + NIST ACVP KATs (`tests/vectors/`)**: SHA-256 verified official JSON suites (`316` AES-GCM, `1,047` P-384 ECDH, `83` HKDF-SHA-384, `25`/`55` FIPS 203 ML-KEM-1024 KeyGen/encapDecap, `25`/`60` FIPS 204 ML-DSA-87 KeyGen/SigVer) plus FIPS 203 implicit rejection and 1-bit signature flip tests
126
+ - **TEC 91011:2026 / `dudect` Timing Detector (`quantumguard sidechannel-check`)**: `time.perf_counter_ns()` interleaved Class 0/1 Welch's t-test harness with pooled 5%–95% outlier cropping across `WegmanCarterMAC.verify`, `HandshakeFirewall.constant_time_key_id_equal`, and `ML-KEM-1024` decapsulation (`|t| < 4.5` pass threshold) + in-place mutable buffer scrubber `zeroize_bytes`
127
+ - **Tamarin Prover Symbolic Model (`formal/quantumguard_handshake.spthy`)**: Dolev-Yao + classical CRQC ECDH P-384 oracle model with 4 formal lemmas (`executable`, `session_key_secrecy`, injective `mutual_authentication`, `commit_barrier_consistency`), wired into Ubuntu 24.04 GitHub Actions CI
128
+
129
+ 7. **Space QKD & Erasure-Aware QEC Benchmark (`benchmarks/satqkd_erasure_bench.py`)**
130
+ - Finite-key Decoy-BB84 LEO downlink budget (`500 km` orbit, `15°`–`85°` elevation)
131
+ - Explicitly separates **Regime I** `circuit_level_pauli_stim` rotated surface code (`d=3, 5`) gate-noise sweeps from **Regime II** `code_capacity_memory_hold_erasure` (`0%` vs `90%` heralded memory-hold erasure conversion comparing `Surface-d5` vs `BB-qLDPC-[[144,12,12]]` via `ldpc.BpOsdDecoder`, reporting both `block_ler` and `per_logical_qubit_ler = 1 - (1 - block_ler)**(1/k)`)
132
+
133
+ ---
134
+
135
+ ## Installation
136
+
137
+ Requires **Python 3.11+** (`Python 3.13.3` Windows and `3.13.18` Ubuntu verified). Note that because `quantumguard` is already occupied on PyPI, the distribution package is named **`quantumguard-cnsa2`**, while Python imports (`import quantumguard`) and the CLI (`quantumguard`) stay unchanged:
138
+
139
+ ```bash
140
+ # Install core package from PyPI:
141
+ pip install quantumguard-cnsa2
142
+
143
+ # Or include QEC / Sat-QKD simulator extras (stim, pymatching, ldpc, numpy, scipy):
144
+ pip install "quantumguard-cnsa2[bench]"
145
+
146
+ # Or install from GitHub source with development & QEC benchmark extras:
147
+ git clone https://github.com/Runtime-Slayers/QuantumGuard.git
148
+ cd QuantumGuard
149
+ pip install -e ".[dev,bench]"
150
+
151
+ # Build distribution wheel + source tarball (dist/quantumguard_cnsa2-0.2.0-py3-none-any.whl):
152
+ python -m build
153
+
154
+ # Or run the FastAPI security console inside Docker (port 7860):
155
+ docker build -t quantumguard-cnsa2:0.2.0 .
156
+ docker run -p 7860:7860 quantumguard-cnsa2:0.2.0
157
+ ```
158
+
159
+ ---
160
+
161
+ ## Quickstart
162
+
163
+ Use `quantumguard` (or `python -m quantumguard`):
164
+
165
+ ### 1. Run Encrypted Tunnel Proxy
166
+
167
+ ```bash
168
+ # Terminal 1: Start CNSA 2.0 + ETSI 014 server forwarding decrypted TCP to local service 127.0.0.1:9000
169
+ python -m quantumguard serve --listen 127.0.0.1:8443 --upstream 127.0.0.1:9000
170
+
171
+ # Terminal 2: Open local plain TCP bridge 127.0.0.1:7000 -> encrypted tunnel -> 127.0.0.1:8443
172
+ python -m quantumguard connect --peer 127.0.0.1:8443 --listen 127.0.0.1:7000
173
+ ```
174
+
175
+ Or run a one-shot encrypted echo handshake:
176
+
177
+ ```bash
178
+ python -m quantumguard serve --listen 127.0.0.1:8443
179
+ python -m quantumguard connect --peer 127.0.0.1:8443 --message "CNSA 2.0 telemetry test"
180
+ ```
181
+
182
+ ### 2. Run 1,000-Attack Red-Team Downgrade Test
183
+
184
+ ```bash
185
+ python -m quantumguard attack-test --spawn-local --count 1000
186
+ ```
187
+
188
+ ### 3. Run CycloneDX CBOM Compliance Audit
189
+
190
+ ```bash
191
+ python -m quantumguard audit . --output cbom.json
192
+ ```
193
+
194
+ ### 4. Launch Mock ETSI GS QKD 014 KME, Timing Side-Channel Check, Socket Bench & Security Console
195
+
196
+ ```bash
197
+ # Start live ETSI GS QKD 014 v1.1.1 HTTP Mock KME server:
198
+ python -m quantumguard kme-mock --host 127.0.0.1 --port 8443
199
+
200
+ # Run TEC 91011:2026 / dudect timing side-channel verification (2,500 samples/class):
201
+ python -m quantumguard sidechannel-check
202
+ python -m quantumguard sidechannel-check --json
203
+
204
+ # Benchmark binary CNSA 2.0 handshakes & 128 KiB AES-256-GCM loopback echo:
205
+ python -m quantumguard bench --handshakes 50 --payload-mb 16 --chunk-kb 128
206
+
207
+ # Launch interactive FastAPI console:
208
+ python -m quantumguard demo --host 127.0.0.1 --port 8080
209
+ ```
210
+
211
+ ### 5. Run Wycheproof / NIST KATs, LEO Sat-QKD Benchmark & Tamarin Formal Model
212
+
213
+ ```bash
214
+ # Wycheproof v1 + NIST ACVP FIPS 203/204 KATs + dudect sensitivity + Tamarin CI structural check:
215
+ python -m pytest tests/test_wycheproof_and_kat.py -v
216
+
217
+ # Full 42-test suite (including Hypothesis & Schemathesis ASGI OpenAPI fuzzing):
218
+ python -m pytest -v
219
+
220
+ # LEO Sat-QKD & Erasure-Aware QEC benchmark:
221
+ python benchmarks/satqkd_erasure_bench.py --output benchmarks/results.json
222
+ python benchmarks/satqkd_erasure_bench.py --fast
223
+
224
+ # Tamarin Prover (Linux/Docker/WSL2 — runs automatically on ubuntu-latest CI):
225
+ docker run --rm -v "${PWD}/formal:/work" infsec/tamarin-prover:latest --prove /work/quantumguard_handshake.spthy
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Measured Verification & Benchmark Results (`v0.2.0`)
231
+
232
+ All metrics below were measured locally on Windows 11 (`AMD64`, `Python 3.13.3`, `cryptography 50.0.0` / OpenSSL 4, `stim 1.16.0`, `pymatching 2.4.0`, `ldpc 2.4.1`):
233
+
234
+ ### Transport, Firewall & Assurance Gates (Latest Observed Post-Edit Runs)
235
+
236
+ | Metric | Latest Measured Result (`v0.2.0`) |
237
+ |---|---|
238
+ | `ML-KEM-1024` Sizes (`verify_fips_sizes`) | `ek = 1568 B`, `ct = 1568 B`, `ss = 32 B` |
239
+ | `ML-DSA-87` Sizes (`verify_fips_sizes`) | `pk = 2592 B`, `sig = 4627 B` |
240
+ | `RFC 10024` `SecP384r1MLKEM1024` Wire Share | `1665 B` (`97 B` P-384 + `1568 B` ML-KEM-1024) |
241
+ | Live Binary Handshake (`quantumguard bench`, 50 runs) | Mean `14.763 ms`, p95 `26.016 ms`, `18,154 B` wire total (`chunk_kb=128`; prior pre-assurance sample: `10.854 ms` mean / `16.160 ms` p95) |
242
+ | Live `AES-256-GCM` Echo (`16.0 MB`, `chunk_kb=128`) | `0.084 s` round-trip (**`189.47 MB/s`**; prior sample: `0.078 s` / `205.80 MB/s`) |
243
+ | Red-Team Firewall (`attack-test --spawn-local --count 1000`) | **`1000 / 1000` blocked in `8.55 s`** (`0` bypasses across all 6 binary vectors) |
244
+ | CBOM Audit (`quantumguard audit .`) | **`20` files: `43` compliant assets, `0` violations (exit `0`)**; RSA-2048 fixture: exit `1` |
245
+ | Wycheproof & NIST ACVP KATs (`test_wycheproof_and_kat.py`) | **`316` AES-GCM + `1,047` P-384 ECDH + `83` HKDF-SHA-384 + `25`/`10` FIPS 203 + `25`/`30` FIPS 204 vectors (`100% PASS`)** |
246
+ | Timing Side-Channel (`quantumguard sidechannel-check --json`) | `TEC 91011:2026` / `dudect` (`2,500` samples/class, 5%-95% crop): `wegman_carter_mac_verify` `\|t\|=1.8944`, `firewall_qkd_key_id_compare` `\|t\|=0.0` (`raw=0.1178`), `mlkem1024_decapsulation` `\|t\|=0.3854` -> **`COMPLIANT` (`PASS`)** |
247
+ | Formal Tamarin Model (`formal/quantumguard_handshake.spthy`) | **`Tamarin 1.12.0` (`Maude 3.5.1`) PASS (`22.02s`, Ubuntu 24.04 CI):** `executable` (`18 steps`), `session_key_secrecy` (`10 steps`), `mutual_authentication` (`71 steps`), `commit_barrier_consistency` (`10 steps`) — [CI Run](https://github.com/Runtime-Slayers/QuantumGuard/actions/runs/47609459438) |
248
+ | Static & Dependency Security (`bandit`, `ruff`, `semgrep`, `pip-audit`) | `bandit`: `0` issues (`3,798` LOC, `0 #nosec`); `ruff`: `0` issues; `semgrep`: `0` findings (`156` rules / `21` targets); `pip-audit`: `0` CVEs across `40` `quantumguard` closure packages (`385` unrelated global env CVEs) |
249
+ | Full Test & Fuzz Suite (`pytest -v`, `Hypothesis` + `Schemathesis`) | **`42 passed in 80.25s`** on Ubuntu 24.04 CI (`115.17s` local Windows; `0` failed, `0` skipped) |
250
+ | Packaging (`python -m build` / `pip wheel`) | `dist/quantumguard_cnsa2-0.2.0-py3-none-any.whl` & `.tar.gz` (`quantumguard-cnsa2` on PyPI) |
251
+
252
+ ---
253
+
254
+ ## Cryptographic Assurance Ledger & Verbatim Re-Check Outputs
255
+
256
+ Everything delivered in the `QuantumGuard v0.2.0` cryptographic assurance upgrade and the exact observed outputs for independent re-check are preserved below.
257
+
258
+ ### 1. Project Wycheproof v1 & NIST ACVP FIPS 203/204 Vector Manifest (`tests/vectors/SHA256SUMS.txt`)
259
+
260
+ ```text
261
+ 985e5ecc172e181eaf49e89508b9470dcf478002eb7e8559c707eb42dc97dfe7 aes_gcm_test.json
262
+ 25a9c41573dbea97c5b4be2dd00369fa68dc37ac8f41807d8e16226d188ec6a7 ecdh_secp384r1_test.json
263
+ 69ff6ea3657bb9c1b8cdffbbb4e7832353d08fd15c0d9997b03f7a6b180e3678 hkdf_sha384_test.json
264
+ 2ce955e45ed66b87abdab56f25d28e8665035c123a85eb556685411355d189ec nist_fips203_mlkem1024_encapdecap.json
265
+ e47bf2d00d8ca63baf3cac3430e2177454fa53c7511e3afe8a656e209c4cbac7 nist_fips203_mlkem1024_keygen.json
266
+ 4c92b74f21ef0abfa610766fc7204b6cf56bfbf95026e3650ed140f748456458 nist_fips204_mldsa87_keygen.json
267
+ e542a23ce10d1ffa3cdc2fc1e1ee06a2852cb6fdc07e22cc897e9aa40a8c6f01 nist_fips204_mldsa87_sigver.json
268
+ ```
269
+
270
+ **Observed Edge-Case & Conformance Findings (`test_wycheproof_and_kat.py`):**
271
+ - **Wycheproof `AES-GCM` (`316 / 316`):** `202` valid exact decryptions, `81` invalid tags/AAD rejected (`InvalidTag` / `ValueError`), `33` out-of-range IV lengths (`< 8 B` or `> 128 B`, including `0 B`) deterministically rejected (`ValueError`) by OpenSSL SP 800-38D bounds. For all `256`-bit key + `96`-bit nonce vectors wrapped in `AES256GCMChannel`, directional AAD (`c2s` vs `s2c`) blocked self-reflection and 1-bit ciphertext tamper.
272
+ - **Wycheproof `ECDH P-384` (`1,047 / 1,047`):** `771 / 771` valid exact shared-secret matches, `46 / 46` invalid rejected, `230` acceptable handled (`1` accepted, `229` rejected). Raw X9.62 points (`97 B`) extracted from invalid SPKIs (`InvalidCurveAttack`, `ModifiedPublicPoint`, `WeakPublicKey`, `WrongCurve`), infinity `(0x00 * 97)`, and compressed prefix `0x02` all raised `ValueError`/`CryptoEngineError` inside `responder_encapsulate_hybrid`. Note: `6` `UnnamedCurve` SPKIs (`tcId 792, 793, 798, 799, 801, 803`) modify ASN.1 curve order/cofactor/prime while keeping an on-curve P-384 `(x, y)` coordinate; stripping ASN.1 leaves a valid P-384 point, which is why ASN.1/SPKI validation rejects `46 / 46`. Separately, FIPS 203 `ByteDecode_12` coefficient bounds (`< q = 3329`) permit `0x00 * 1568` syntactically in `MLKEM1024PublicKey.from_public_bytes`.
273
+ - **Wycheproof `HKDF-SHA-384` (`83 / 83`):** `80` valid exact OKMs + `3` `SizeTooLarge` rejected (`ValueError`).
274
+ - **NIST ACVP FIPS 203 `ML-KEM-1024`:** `25 / 25` deterministic `from_seed_bytes(d + z)` KeyGen `ek` byte-exact matches + `10 / 10` `encapsulationKeyCheck` matches + FIPS 203 §7.3 implicit rejection verified (`decapsulate(corrupted_ct)` returns deterministic `32 B` `K_bar != ss`, distinct across different corruptions).
275
+ - **NIST ACVP FIPS 204 `ML-DSA-87`:** `25 / 25` `from_seed_bytes(seed)` KeyGen `pk` byte-exact matches + `15 / 15` `external/pure` `SigVer` + `15 / 15` `externalMu` `SigVer` + deterministic rejection across 1-bit signature flips in `IdentityKeyPair.verify_with_public_bytes`.
276
+
277
+ ### 2. Verbatim `quantumguard sidechannel-check --json` Output (`TEC 91011:2026` / `dudect`)
278
+
279
+ ```json
280
+ {
281
+ "standard": "TEC 91011:2026 (Section 5) / dudect Welch t-test",
282
+ "platform_info": "Windows 11 (AMD64)",
283
+ "python_version": "3.13.3",
284
+ "timer_source": "time.perf_counter_ns()",
285
+ "samples_per_class": 2500,
286
+ "warmup_samples": 500,
287
+ "crop_percentiles": [0.05, 0.95],
288
+ "threshold": 4.5,
289
+ "all_passed": true,
290
+ "results": [
291
+ {
292
+ "name": "wegman_carter_mac_verify",
293
+ "description": "WegmanCarterMAC.verify (fixed 15/16-byte prefix match vs. random mismatched tag)",
294
+ "samples_per_class": 2500,
295
+ "cropped_n0": 2258,
296
+ "cropped_n1": 2265,
297
+ "mean_ns_class0": 146310.23,
298
+ "mean_ns_class1": 145979.47,
299
+ "stdev_ns_class0": 6029.4,
300
+ "stdev_ns_class1": 5707.94,
301
+ "welch_t_abs": 1.8944,
302
+ "welch_t_raw_abs": 0.8952,
303
+ "threshold": 4.5,
304
+ "verdict": "PASS"
305
+ },
306
+ {
307
+ "name": "firewall_qkd_key_id_compare",
308
+ "description": "HandshakeFirewall.constant_time_key_id_equal (tail-only diff vs. random head diff)",
309
+ "samples_per_class": 2500,
310
+ "cropped_n0": 2383,
311
+ "cropped_n1": 2355,
312
+ "mean_ns_class0": 200.0,
313
+ "mean_ns_class1": 200.0,
314
+ "stdev_ns_class0": 0.0,
315
+ "stdev_ns_class1": 0.0,
316
+ "welch_t_abs": 0.0,
317
+ "welch_t_raw_abs": 0.1178,
318
+ "threshold": 4.5,
319
+ "verdict": "PASS"
320
+ },
321
+ {
322
+ "name": "mlkem1024_decapsulation",
323
+ "description": "FIPS 203 ML-KEM-1024 decapsulate (valid ciphertext vs. corrupted implicit-rejection)",
324
+ "samples_per_class": 2500,
325
+ "cropped_n0": 2291,
326
+ "cropped_n1": 2302,
327
+ "mean_ns_class0": 64858.27,
328
+ "mean_ns_class1": 64887.62,
329
+ "stdev_ns_class0": 2582.86,
330
+ "stdev_ns_class1": 2577.32,
331
+ "welch_t_abs": 0.3854,
332
+ "welch_t_raw_abs": 0.2325,
333
+ "threshold": 4.5,
334
+ "verdict": "PASS"
335
+ }
336
+ ]
337
+ }
338
+ ```
339
+
340
+ - **Calibration & Measurement Caveats:**
341
+ - Synthetic leaky branch control in `test_zeroize_bytes_and_dudect_sensitivity` (`~50 us` asymmetric busy-spin) deterministically fails with `|t| >= 4.5` (`WARN/INVESTIGATE`), proving leak sensitivity.
342
+ - Windows `time.perf_counter_ns()` exhibits ~`100 ns` QueryPerformanceCounter quantization, so sub-microsecond paths like `firewall_qkd_key_id_compare` round to `200.0 ns` (cropped stdev `0.0`, raw uncropped `|t| = 0.1178`).
343
+ - **Python Buffer Zeroization Scope (`zeroize_bytes`):** `zeroize_bytes` wipes mutable `bytearray` and writable `memoryview` buffers in place (e.g., `ikm_buf` inside `derive_hybrid_session_keys`); however, CPython `bytes` objects returned by OpenSSL/C bindings remain **immutable** until reference-count reclamation / GC.
344
+
345
+ ### 3. Verbatim Transport, Red-Team & Static Security Outputs
346
+
347
+ ```text
348
+ # python -m quantumguard bench
349
+ FIPS 203/204 Self-Test PASS: ML-KEM-1024 (ek=1568 B, ct=1568 B, ss=32 B) |
350
+ ML-DSA-87 (pk=2592 B, sig=4627 B) | RFC 10024 Share=1665 B
351
+ {
352
+ "handshakes": 50,
353
+ "handshake_mean_ms": 14.763,
354
+ "handshake_p95_ms": 26.016,
355
+ "handshake_wire_bytes": 18154,
356
+ "chunk_kb": 128,
357
+ "echo_payload_mb": 16.0,
358
+ "echo_roundtrip_sec": 0.084,
359
+ "throughput_mb_per_sec": 189.47
360
+ }
361
+
362
+ # python -m quantumguard attack-test --spawn-local --count 1000
363
+ stripped_pq_downgrade: 167/167 blocked (0 bypassed)
364
+ classical_suite_downgrade: 167/167 blocked (0 bypassed)
365
+ corrupted_mldsa87_sig: 167/167 blocked (0 bypassed)
366
+ qkd_key_id_swap: 167/167 blocked (0 bypassed)
367
+ nonce_replay: 166/166 blocked (0 bypassed)
368
+ asymmetric_abort_truncation: 166/166 blocked (0 bypassed)
369
+ Summary: 1000/1000 blocked in 8.55s | Bypasses: 0
370
+
371
+ # python -m pytest -v
372
+ 42 passed in 80.25s (Ubuntu 24.04 CI) | 42 passed in 115.17s (Windows 11)
373
+
374
+ # python -m bandit -r quantumguard -v
375
+ No issues identified. Code scanned: 3798 lines across 10 files (0 #nosec)
376
+
377
+ # python -m ruff check quantumguard --select S,B,E,F --ignore E501
378
+ All checks passed!
379
+
380
+ # semgrep scan --config p/python --config p/owasp-top-ten quantumguard --json --output audit_semgrep.json
381
+ Ran 156 rules on 21 files: 0 findings. (semgrep results: 0 errors: 0)
382
+
383
+ # python -m quantumguard audit .
384
+ Scanned 20 files | Assets: 43 | Violations: 0 (Exit 0)
385
+
386
+ # python -m build (or python -m pip wheel --no-deps --no-build-isolation . -w dist/)
387
+ dist/quantumguard_cnsa2-0.2.0-py3-none-any.whl & dist/quantumguard_cnsa2-0.2.0.tar.gz
388
+ ```
389
+
390
+ ### 4. Tamarin Prover Formal Model & Environment Transparency (`formal/quantumguard_handshake.spthy`)
391
+
392
+ - **Formalized Theory & Lemmas:**
393
+ - `executable` — Honest 4-step trace witness (`ServerCommitted < ClientCommitAckVerified < ClientSendAppData`) with zero key leaks.
394
+ - `session_key_secrecy` — Adversary cannot derive `k_c2s` or `k_s2c` even when `Reveal_Classical_ECDH_Client` / `Reveal_Classical_ECDH_Server` compromises classical P-384 ephemeral scalars (assuming honest `ML-DSA-87` identities and uncompromised QKD / `ML-KEM-1024`).
395
+ - `mutual_authentication` — Injective agreement between Client and Server on `(transcript, qkd_key_id, k_c2s, k_s2c)` backed by single-use linear `QKD_Client_Token` / `QKD_Server_Token` facts.
396
+ - `commit_barrier_consistency` — Client linear state transition prohibits `Client_Transmit_AppData` before `Client_Recv_CommitAck` verifies `SERVER_COMMIT_ACK`.
397
+ - **CI & Local Environment Execution:**
398
+ - Verified live in GitHub Actions Ubuntu 24.04 CI ([Run 47609459438](https://github.com/Runtime-Slayers/QuantumGuard/actions/runs/47609459438)) with `Tamarin version 1.12.0` + `Maude version 3.5.1` (`processing time: 22.02s`): `executable (exists-trace): verified (18 steps)`, `session_key_secrecy (all-traces): verified (10 steps)`, `mutual_authentication (all-traces): verified (71 steps)`, `commit_barrier_consistency (all-traces): verified (10 steps)`.
399
+ - On the local Windows host (which lacks a native `tamarin-prover` binary and has `com.docker.service` stopped), `formal/quantumguard_handshake.spthy` and its CI wiring are additionally checked via `test_formal_tamarin_model_and_ci_wiring`.
400
+ - Docker Hub image note: `infsec/tamarin-prover:latest` resolves (`HTTP 200`), and official release `tamarin-prover-1.12.0-linux64-ubuntu.tar.gz` installs cleanly on Ubuntu 24.04. Temporary Hugging Face Docker Space attempt returned `HTTP 402` (`Pro: No`; no Space active), and `nvidia-nim` `nim_guard_check` returned `HTTP 410 Gone` (`deepseek-ai/deepseek-v4.1-flash` EOL).
401
+
402
+ ### LEO Decoy-BB84 Link Budget (`500 km`, `625 MHz`) & Erasure QEC Crossover (`benchmarks/satqkd_erasure_bench.py`)
403
+
404
+ - **LEO Link Budget**: From `15.0°` elevation (`35.71 dB` loss, `4.191%` QBER, `8,397.38 bps` finite-key SKR) to `85.0°` zenith (`21.18 dB` loss, `1.903%` QBER, `367,391.20 bps` SKR).
405
+ - **Noise-Regime Separation (`benchmarks/results.json`)**:
406
+ - **Regime I (`circuit_level_pauli_stim`)**: Evaluates unheralded full circuit-level gate Pauli noise on rotated surface codes (`d = 3, 5`, `10,000` shots/point) via Stim.
407
+ - **Regime II (`code_capacity_memory_hold_erasure`, `1,200` shots/point, `p = 0.08`)**: Evaluates heralded optical/neutral-atom memory-hold erasure on the satellite buffer using both `block_ler` and normalized `per_logical_qubit_ler = 1 - (1 - block_ler)**(1/k)`:
408
+ - `Surface-d5` (`rate = 0.0400`, `n=25, k=1`): `block_ler` / `per_logical_qubit_ler` drops from `0.0842` `[0.0698, 0.1012]` (`0%` erasure, `217.1 ms`) to `0.0008` `[0.0001, 0.0047]` (`90%` erasure conversion, `211.3 ms`).
409
+ - `BB-qLDPC-[[144,12,12]]` (`rate = 0.0833`, `n=144, k=12`, BP+OSD-cs order 2): at `0%` erasure (`531.6 ms`), `block_ler = 0.4242` `[0.3965, 0.4523]` corresponds to `per_logical_qubit_ler = 0.0450`; at `90%` erasure conversion (`95.5 ms`), both `block_ler` and `per_logical_qubit_ler` collapse to `0.0000` `[0.0000, 0.0032]` while delivering `2.08x` the encoding rate of `d=5` rotated surface code.
410
+
411
+ ---
412
+
413
+ ## Project Structure
414
+
415
+ ```text
416
+ QuantumGuard/
417
+ ├── .github/workflows/
418
+ │ ├── ci.yml # Pytest, Bandit, 1000-attack fuzz, CBOM, dudect & Tamarin CI
419
+ │ ├── publish-pypi.yml # OIDC PyPI Trusted Publishing release workflow (`quantumguard-cnsa2`)
420
+ │ └── quantumguard-cbom.yml # Automated CycloneDX 1.6 CBOM compliance gate
421
+ ├── assets/
422
+ │ └── quantumguard-architecture.svg # Architecture & assurance overview diagram
423
+ ├── benchmarks/
424
+ │ ├── __init__.py
425
+ │ ├── results.json # Saved Sat-QKD + Regime I/II Erasure QEC JSON benchmark artifact
426
+ │ └── satqkd_erasure_bench.py # LEO finite-key BB84 & Stim vs. BB qLDPC runner
427
+ ├── dist/ # Built `.whl` and `.tar.gz` artifacts (gitignored)
428
+ ├── formal/
429
+ │ ├── README.md # Tamarin Prover Docker & CI instructions
430
+ │ └── quantumguard_handshake.spthy # Symbolic CRQC-resilient handshake model (4 lemmas)
431
+ ├── quantumguard/
432
+ │ ├── __init__.py
433
+ │ ├── __main__.py
434
+ │ ├── cbom_scanner.py # AST + regex CycloneDX v1.6 scanner & policy gate
435
+ │ ├── cli.py # `quantumguard` CLI entrypoint (`kme-mock`, `sidechannel-check`, `bench`)
436
+ │ ├── crypto_core.py # ML-KEM-1024, ML-DSA-87, P-384, ETSI 014, UUIDv7 pool, AES-GCM, WC MAC
437
+ │ ├── dashboard.py # FastAPI interactive security console
438
+ │ ├── guard.py # Compact binary & JSON active downgrade/replay/abort firewall
439
+ │ ├── kme_mock.py # FastAPI ETSI GS QKD 014 v1.1.1 HTTP Mock KME server
440
+ │ ├── py.typed
441
+ │ ├── sidechannel.py # TEC 91011:2026 / dudect Welch's t-test side-channel detector
442
+ │ └── tunnel.py # Low-latency asyncio TCP_NODELAY proxy & tunnel
443
+ ├── tests/
444
+ │ ├── vectors/ # SHA-256 verified C2SP Wycheproof & NIST ACVP FIPS 203/204 JSONs
445
+ │ ├── test_cbom_and_dashboard.py # CBOM multi-language audit, FastAPI UI, kme-mock & QEC tests
446
+ │ ├── test_crypto_core.py # FIPS sizes, KEM, HTTP ETSI 014, UUIDv7 TTL/LRU, HKDF, AEAD & MAC tests
447
+ │ ├── test_security_fuzz.py # Hypothesis property fuzzing & Schemathesis ASGI OpenAPI tests
448
+ │ ├── test_tunnel_and_guard.py # Live tunnel, proxy bridge, abort & 1,000-attack binary tests
449
+ │ └── test_wycheproof_and_kat.py # Wycheproof, NIST ACVP KAT, zeroization, dudect & Tamarin checks
450
+ ├── .gitignore
451
+ ├── Dockerfile # Non-root OCI container (port 7860)
452
+ ├── LICENSE # MIT License
453
+ ├── pyproject.toml # Package config (`name = "quantumguard-cnsa2"`)
454
+ ├── README.md
455
+ └── SECURITY_AUDIT_REPORT.md
456
+ ```