quantum-safe-py 0.1.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.
- quantum_safe_py-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +36 -0
- quantum_safe_py-0.1.0/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- quantum_safe_py-0.1.0/.github/pull_request_template.md +36 -0
- quantum_safe_py-0.1.0/.github/workflows/ci.yml +223 -0
- quantum_safe_py-0.1.0/.gitignore +129 -0
- quantum_safe_py-0.1.0/.readthedocs.yaml +23 -0
- quantum_safe_py-0.1.0/CHANGELOG.md +181 -0
- quantum_safe_py-0.1.0/CONTRIBUTING.md +93 -0
- quantum_safe_py-0.1.0/Dockerfile +53 -0
- quantum_safe_py-0.1.0/LICENSE +179 -0
- quantum_safe_py-0.1.0/PKG-INFO +622 -0
- quantum_safe_py-0.1.0/README.md +577 -0
- quantum_safe_py-0.1.0/RUNBOOK.md +579 -0
- quantum_safe_py-0.1.0/SECURITY.md +55 -0
- quantum_safe_py-0.1.0/docker-compose.yml +16 -0
- quantum_safe_py-0.1.0/docs/Makefile +17 -0
- quantum_safe_py-0.1.0/docs/api/audit.rst +40 -0
- quantum_safe_py-0.1.0/docs/api/backends.rst +35 -0
- quantum_safe_py-0.1.0/docs/api/exceptions.rst +76 -0
- quantum_safe_py-0.1.0/docs/api/kem.rst +25 -0
- quantum_safe_py-0.1.0/docs/api/migrate.rst +48 -0
- quantum_safe_py-0.1.0/docs/api/protocols.rst +44 -0
- quantum_safe_py-0.1.0/docs/api/signatures.rst +25 -0
- quantum_safe_py-0.1.0/docs/api/types.rst +76 -0
- quantum_safe_py-0.1.0/docs/changelog.rst +134 -0
- quantum_safe_py-0.1.0/docs/conf.py +89 -0
- quantum_safe_py-0.1.0/docs/guides/audit.rst +164 -0
- quantum_safe_py-0.1.0/docs/guides/benchmarks.rst +479 -0
- quantum_safe_py-0.1.0/docs/guides/cli.rst +170 -0
- quantum_safe_py-0.1.0/docs/guides/concepts.rst +164 -0
- quantum_safe_py-0.1.0/docs/guides/installation.rst +78 -0
- quantum_safe_py-0.1.0/docs/guides/kem.rst +163 -0
- quantum_safe_py-0.1.0/docs/guides/migration.rst +144 -0
- quantum_safe_py-0.1.0/docs/guides/protocols.rst +153 -0
- quantum_safe_py-0.1.0/docs/guides/quickstart.rst +99 -0
- quantum_safe_py-0.1.0/docs/guides/signatures.rst +165 -0
- quantum_safe_py-0.1.0/docs/index.rst +72 -0
- quantum_safe_py-0.1.0/docs/make.bat +32 -0
- quantum_safe_py-0.1.0/pyproject.toml +157 -0
- quantum_safe_py-0.1.0/results/BENCHMARKS.md +405 -0
- quantum_safe_py-0.1.0/src/quantum_safe/__init__.py +97 -0
- quantum_safe_py-0.1.0/src/quantum_safe/_internal/__init__.py +2 -0
- quantum_safe_py-0.1.0/src/quantum_safe/_internal/serialization.py +104 -0
- quantum_safe_py-0.1.0/src/quantum_safe/_version.py +5 -0
- quantum_safe_py-0.1.0/src/quantum_safe/audit/__init__.py +50 -0
- quantum_safe_py-0.1.0/src/quantum_safe/audit/auditor.py +292 -0
- quantum_safe_py-0.1.0/src/quantum_safe/audit/cli.py +299 -0
- quantum_safe_py-0.1.0/src/quantum_safe/audit/compliance.py +332 -0
- quantum_safe_py-0.1.0/src/quantum_safe/audit/policy.py +242 -0
- quantum_safe_py-0.1.0/src/quantum_safe/audit/sbom.py +357 -0
- quantum_safe_py-0.1.0/src/quantum_safe/backends/__init__.py +172 -0
- quantum_safe_py-0.1.0/src/quantum_safe/backends/base.py +220 -0
- quantum_safe_py-0.1.0/src/quantum_safe/backends/liboqs.py +439 -0
- quantum_safe_py-0.1.0/src/quantum_safe/backends/rustcrypto.py +187 -0
- quantum_safe_py-0.1.0/src/quantum_safe/exceptions.py +276 -0
- quantum_safe_py-0.1.0/src/quantum_safe/kem/__init__.py +32 -0
- quantum_safe_py-0.1.0/src/quantum_safe/kem/algorithms.py +218 -0
- quantum_safe_py-0.1.0/src/quantum_safe/kem/core.py +196 -0
- quantum_safe_py-0.1.0/src/quantum_safe/kem/hybrid.py +496 -0
- quantum_safe_py-0.1.0/src/quantum_safe/migrate/__init__.py +50 -0
- quantum_safe_py-0.1.0/src/quantum_safe/migrate/cli.py +158 -0
- quantum_safe_py-0.1.0/src/quantum_safe/migrate/scanner.py +707 -0
- quantum_safe_py-0.1.0/src/quantum_safe/migrate/shims.py +251 -0
- quantum_safe_py-0.1.0/src/quantum_safe/migrate/state.py +350 -0
- quantum_safe_py-0.1.0/src/quantum_safe/migrate/upgrader.py +340 -0
- quantum_safe_py-0.1.0/src/quantum_safe/protocols/__init__.py +49 -0
- quantum_safe_py-0.1.0/src/quantum_safe/protocols/envelope.py +354 -0
- quantum_safe_py-0.1.0/src/quantum_safe/protocols/jwt.py +332 -0
- quantum_safe_py-0.1.0/src/quantum_safe/protocols/tls.py +276 -0
- quantum_safe_py-0.1.0/src/quantum_safe/protocols/x509.py +340 -0
- quantum_safe_py-0.1.0/src/quantum_safe/signatures/__init__.py +34 -0
- quantum_safe_py-0.1.0/src/quantum_safe/signatures/algorithms.py +224 -0
- quantum_safe_py-0.1.0/src/quantum_safe/signatures/core.py +369 -0
- quantum_safe_py-0.1.0/src/quantum_safe/signatures/hybrid.py +465 -0
- quantum_safe_py-0.1.0/src/quantum_safe/types/__init__.py +42 -0
- quantum_safe_py-0.1.0/src/quantum_safe/types/kem.py +345 -0
- quantum_safe_py-0.1.0/src/quantum_safe/types/keys.py +789 -0
- quantum_safe_py-0.1.0/src/quantum_safe/types/signatures.py +212 -0
- quantum_safe_py-0.1.0/tests/__init__.py +0 -0
- quantum_safe_py-0.1.0/tests/bench/__init__.py +0 -0
- quantum_safe_py-0.1.0/tests/bench/_oqs_path.py +32 -0
- quantum_safe_py-0.1.0/tests/bench/bench_kem.py +571 -0
- quantum_safe_py-0.1.0/tests/bench/bench_signatures.py +464 -0
- quantum_safe_py-0.1.0/tests/bench/bench_stats.py +687 -0
- quantum_safe_py-0.1.0/tests/bench/run_stats_demo.py +310 -0
- quantum_safe_py-0.1.0/tests/integration/__init__.py +0 -0
- quantum_safe_py-0.1.0/tests/integration/test_end_to_end.py +526 -0
- quantum_safe_py-0.1.0/tests/unit/__init__.py +0 -0
- quantum_safe_py-0.1.0/tests/unit/test_audit.py +488 -0
- quantum_safe_py-0.1.0/tests/unit/test_bench_stats.py +526 -0
- quantum_safe_py-0.1.0/tests/unit/test_cli.py +665 -0
- quantum_safe_py-0.1.0/tests/unit/test_exceptions.py +118 -0
- quantum_safe_py-0.1.0/tests/unit/test_kem.py +401 -0
- quantum_safe_py-0.1.0/tests/unit/test_migrate.py +608 -0
- quantum_safe_py-0.1.0/tests/unit/test_protocols.py +672 -0
- quantum_safe_py-0.1.0/tests/unit/test_signatures.py +545 -0
- quantum_safe_py-0.1.0/tests/unit/test_types.py +500 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Something is broken or behaving incorrectly
|
|
4
|
+
labels: bug
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Description
|
|
8
|
+
|
|
9
|
+
A clear description of the bug.
|
|
10
|
+
|
|
11
|
+
## Reproduction
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
# Minimal code that reproduces the issue
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Expected behaviour
|
|
18
|
+
|
|
19
|
+
What you expected to happen.
|
|
20
|
+
|
|
21
|
+
## Actual behaviour
|
|
22
|
+
|
|
23
|
+
What actually happened. Include the full traceback if applicable.
|
|
24
|
+
|
|
25
|
+
## Environment
|
|
26
|
+
|
|
27
|
+
- `quantum-safe` version:
|
|
28
|
+
- Python version:
|
|
29
|
+
- OS and architecture:
|
|
30
|
+
- Backend (`liboqs` / `rustcrypto` / none):
|
|
31
|
+
- `liboqs-python` version (if applicable):
|
|
32
|
+
|
|
33
|
+
## Security note
|
|
34
|
+
|
|
35
|
+
If this bug has security implications, **do not open a public issue**.
|
|
36
|
+
See [SECURITY.md](../../SECURITY.md) for the private reporting process.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest a new algorithm, API addition, or other enhancement
|
|
4
|
+
labels: enhancement
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Problem / motivation
|
|
8
|
+
|
|
9
|
+
What problem does this solve? Why is it needed?
|
|
10
|
+
|
|
11
|
+
## Proposed solution
|
|
12
|
+
|
|
13
|
+
Describe the API or behaviour change you have in mind.
|
|
14
|
+
|
|
15
|
+
## Alternatives considered
|
|
16
|
+
|
|
17
|
+
Other approaches you thought of and why you rejected them.
|
|
18
|
+
|
|
19
|
+
## Cryptographic notes
|
|
20
|
+
|
|
21
|
+
If the request involves a new algorithm or changes to key handling, please
|
|
22
|
+
note the relevant standard (FIPS number, IETF draft, etc.) and any known
|
|
23
|
+
implementation constraints.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
<!-- What does this PR do? One paragraph. -->
|
|
4
|
+
|
|
5
|
+
## Type of change
|
|
6
|
+
|
|
7
|
+
- [ ] Bug fix
|
|
8
|
+
- [ ] Security fix (see SECURITY.md if applicable)
|
|
9
|
+
- [ ] New feature
|
|
10
|
+
- [ ] Documentation update
|
|
11
|
+
- [ ] Benchmark / performance
|
|
12
|
+
- [ ] Refactor (no behaviour change)
|
|
13
|
+
|
|
14
|
+
## Cryptographic review checklist
|
|
15
|
+
|
|
16
|
+
For changes to `types/keys.py`, `kem/hybrid.py`, `signatures/hybrid.py`,
|
|
17
|
+
`backends/`, or `protocols/`:
|
|
18
|
+
|
|
19
|
+
- [ ] Secret material is zeroized with `ctypes.memset`, not a Python byte-loop
|
|
20
|
+
- [ ] Both hybrid sub-operations are evaluated unconditionally before the
|
|
21
|
+
combined result is checked (no early-return timing oracles)
|
|
22
|
+
- [ ] New serialization paths include a payload size cap
|
|
23
|
+
- [ ] No `__new__` bypass of constructors that run `validate_*` checks
|
|
24
|
+
- [ ] Thread-safety implications considered (per-key locks where needed)
|
|
25
|
+
|
|
26
|
+
## Test coverage
|
|
27
|
+
|
|
28
|
+
- [ ] Unit tests added or updated
|
|
29
|
+
- [ ] Integration tests added if a new backend path is exercised
|
|
30
|
+
- [ ] `python -m pytest tests/ -q` passes locally
|
|
31
|
+
|
|
32
|
+
## Documentation
|
|
33
|
+
|
|
34
|
+
- [ ] Docstrings updated
|
|
35
|
+
- [ ] RST guides updated if user-visible behaviour changed
|
|
36
|
+
- [ ] CHANGELOG.md entry added under `[Unreleased]`
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master, main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [master, main]
|
|
8
|
+
|
|
9
|
+
# Cancel in-progress runs on the same branch
|
|
10
|
+
concurrency:
|
|
11
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
12
|
+
cancel-in-progress: true
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
# ---------------------------------------------------------------------------
|
|
16
|
+
# Unit tests — no PQC backend required (fast, runs on all Python versions)
|
|
17
|
+
# ---------------------------------------------------------------------------
|
|
18
|
+
unit-tests:
|
|
19
|
+
name: Unit tests (Python ${{ matrix.python-version }})
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
|
|
22
|
+
strategy:
|
|
23
|
+
fail-fast: false
|
|
24
|
+
matrix:
|
|
25
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
26
|
+
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
|
|
30
|
+
- uses: actions/setup-python@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: ${{ matrix.python-version }}
|
|
33
|
+
cache: pip
|
|
34
|
+
|
|
35
|
+
- name: Install core + dev dependencies
|
|
36
|
+
run: pip install -e '.[dev]'
|
|
37
|
+
|
|
38
|
+
- name: Run unit tests
|
|
39
|
+
run: python -m pytest tests/unit/ -v --tb=short -q --junitxml=junit-unit-${{ matrix.python-version }}.xml
|
|
40
|
+
|
|
41
|
+
- name: Upload test results
|
|
42
|
+
if: always()
|
|
43
|
+
uses: actions/upload-artifact@v4
|
|
44
|
+
with:
|
|
45
|
+
name: junit-unit-${{ matrix.python-version }}
|
|
46
|
+
path: junit-unit-*.xml
|
|
47
|
+
|
|
48
|
+
# ---------------------------------------------------------------------------
|
|
49
|
+
# Integration tests — requires liboqs-python (pre-built binary on ubuntu)
|
|
50
|
+
# ---------------------------------------------------------------------------
|
|
51
|
+
integration-tests:
|
|
52
|
+
name: Integration tests (liboqs)
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
needs: unit-tests
|
|
55
|
+
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@v4
|
|
58
|
+
|
|
59
|
+
- uses: actions/setup-python@v5
|
|
60
|
+
with:
|
|
61
|
+
python-version: "3.11"
|
|
62
|
+
cache: pip
|
|
63
|
+
|
|
64
|
+
- name: Install with liboqs backend
|
|
65
|
+
run: pip install -e '.[dev,liboqs]'
|
|
66
|
+
|
|
67
|
+
- name: Verify liboqs loaded and ML-KEM-768 is available
|
|
68
|
+
run: |
|
|
69
|
+
python - <<'EOF'
|
|
70
|
+
import oqs
|
|
71
|
+
assert "ML-KEM-768" in oqs.get_enabled_kem_mechanisms(), "ML-KEM-768 not available"
|
|
72
|
+
assert "ML-DSA-65" in oqs.get_enabled_sig_mechanisms(), "ML-DSA-65 not available"
|
|
73
|
+
print("liboqs OK —", oqs.oqs_version())
|
|
74
|
+
EOF
|
|
75
|
+
|
|
76
|
+
- name: Run full test suite (skip slow benchmarks)
|
|
77
|
+
run: python -m pytest tests/ -v --tb=short -q -m "not slow" --junitxml=junit-integration.xml
|
|
78
|
+
|
|
79
|
+
- name: Upload test results
|
|
80
|
+
if: always()
|
|
81
|
+
uses: actions/upload-artifact@v4
|
|
82
|
+
with:
|
|
83
|
+
name: junit-integration
|
|
84
|
+
path: junit-integration.xml
|
|
85
|
+
|
|
86
|
+
# ---------------------------------------------------------------------------
|
|
87
|
+
# Lint and type-check
|
|
88
|
+
# ---------------------------------------------------------------------------
|
|
89
|
+
lint:
|
|
90
|
+
name: Lint & type-check
|
|
91
|
+
runs-on: ubuntu-latest
|
|
92
|
+
|
|
93
|
+
steps:
|
|
94
|
+
- uses: actions/checkout@v4
|
|
95
|
+
|
|
96
|
+
- uses: actions/setup-python@v5
|
|
97
|
+
with:
|
|
98
|
+
python-version: "3.11"
|
|
99
|
+
cache: pip
|
|
100
|
+
|
|
101
|
+
- name: Install dev dependencies
|
|
102
|
+
run: pip install -e '.[dev]'
|
|
103
|
+
|
|
104
|
+
- name: Ruff (lint + import sort)
|
|
105
|
+
run: python -m ruff check src/ tests/
|
|
106
|
+
|
|
107
|
+
- name: Ruff (format check)
|
|
108
|
+
run: python -m ruff format --check src/ tests/
|
|
109
|
+
|
|
110
|
+
- name: Mypy (strict type check)
|
|
111
|
+
run: python -m mypy src/quantum_safe
|
|
112
|
+
|
|
113
|
+
# ---------------------------------------------------------------------------
|
|
114
|
+
# DevSecOps — dependency vulnerability scan
|
|
115
|
+
# ---------------------------------------------------------------------------
|
|
116
|
+
dependency-audit:
|
|
117
|
+
name: Dependency vulnerability scan (pip-audit)
|
|
118
|
+
runs-on: ubuntu-latest
|
|
119
|
+
|
|
120
|
+
steps:
|
|
121
|
+
- uses: actions/checkout@v4
|
|
122
|
+
|
|
123
|
+
- uses: actions/setup-python@v5
|
|
124
|
+
with:
|
|
125
|
+
python-version: "3.11"
|
|
126
|
+
cache: pip
|
|
127
|
+
|
|
128
|
+
- name: Install pip-audit
|
|
129
|
+
run: pip install pip-audit
|
|
130
|
+
|
|
131
|
+
- name: Install project dependencies
|
|
132
|
+
run: pip install -e '.[liboqs]'
|
|
133
|
+
|
|
134
|
+
- name: Audit dependencies for known CVEs
|
|
135
|
+
# Fails the build if any dependency has a known vulnerability.
|
|
136
|
+
# Use --ignore-vuln <GHSA-id> only with a documented justification.
|
|
137
|
+
run: pip-audit --strict --desc on
|
|
138
|
+
|
|
139
|
+
# ---------------------------------------------------------------------------
|
|
140
|
+
# DevSecOps — static application security testing (Bandit)
|
|
141
|
+
# ---------------------------------------------------------------------------
|
|
142
|
+
sast:
|
|
143
|
+
name: SAST (Bandit)
|
|
144
|
+
runs-on: ubuntu-latest
|
|
145
|
+
|
|
146
|
+
steps:
|
|
147
|
+
- uses: actions/checkout@v4
|
|
148
|
+
|
|
149
|
+
- uses: actions/setup-python@v5
|
|
150
|
+
with:
|
|
151
|
+
python-version: "3.11"
|
|
152
|
+
cache: pip
|
|
153
|
+
|
|
154
|
+
- name: Install Bandit
|
|
155
|
+
run: pip install bandit[toml]
|
|
156
|
+
|
|
157
|
+
- name: Run Bandit on src/
|
|
158
|
+
# Severity HIGH or CRITICAL fails the build.
|
|
159
|
+
# Medium issues are reported but don't block.
|
|
160
|
+
run: |
|
|
161
|
+
bandit -r src/ \
|
|
162
|
+
--severity-level high \
|
|
163
|
+
--confidence-level medium \
|
|
164
|
+
-f json \
|
|
165
|
+
-o bandit-report.json \
|
|
166
|
+
|| (cat bandit-report.json && exit 1)
|
|
167
|
+
|
|
168
|
+
- name: Upload Bandit report
|
|
169
|
+
if: always()
|
|
170
|
+
uses: actions/upload-artifact@v4
|
|
171
|
+
with:
|
|
172
|
+
name: bandit-report
|
|
173
|
+
path: bandit-report.json
|
|
174
|
+
|
|
175
|
+
# ---------------------------------------------------------------------------
|
|
176
|
+
# DevSecOps — CodeQL semantic analysis
|
|
177
|
+
# ---------------------------------------------------------------------------
|
|
178
|
+
codeql:
|
|
179
|
+
name: CodeQL analysis
|
|
180
|
+
runs-on: ubuntu-latest
|
|
181
|
+
permissions:
|
|
182
|
+
security-events: write
|
|
183
|
+
|
|
184
|
+
steps:
|
|
185
|
+
- uses: actions/checkout@v4
|
|
186
|
+
|
|
187
|
+
- name: Initialize CodeQL
|
|
188
|
+
uses: github/codeql-action/init@v3
|
|
189
|
+
with:
|
|
190
|
+
languages: python
|
|
191
|
+
queries: security-extended
|
|
192
|
+
|
|
193
|
+
- name: Perform CodeQL analysis
|
|
194
|
+
uses: github/codeql-action/analyze@v3
|
|
195
|
+
with:
|
|
196
|
+
category: "/language:python"
|
|
197
|
+
|
|
198
|
+
# ---------------------------------------------------------------------------
|
|
199
|
+
# Sphinx docs build — catches import errors and broken cross-references
|
|
200
|
+
# ---------------------------------------------------------------------------
|
|
201
|
+
docs:
|
|
202
|
+
name: Build Sphinx docs
|
|
203
|
+
runs-on: ubuntu-latest
|
|
204
|
+
|
|
205
|
+
steps:
|
|
206
|
+
- uses: actions/checkout@v4
|
|
207
|
+
|
|
208
|
+
- uses: actions/setup-python@v5
|
|
209
|
+
with:
|
|
210
|
+
python-version: "3.11"
|
|
211
|
+
cache: pip
|
|
212
|
+
|
|
213
|
+
- name: Install docs dependencies
|
|
214
|
+
run: pip install -e '.[docs]'
|
|
215
|
+
|
|
216
|
+
- name: Build HTML docs (warnings as errors)
|
|
217
|
+
run: sphinx-build -W --keep-going -b html docs/ docs/_build/html
|
|
218
|
+
|
|
219
|
+
- name: Upload built docs
|
|
220
|
+
uses: actions/upload-artifact@v4
|
|
221
|
+
with:
|
|
222
|
+
name: sphinx-html
|
|
223
|
+
path: docs/_build/html/
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# quantum-safe — .gitignore
|
|
3
|
+
# =============================================================================
|
|
4
|
+
|
|
5
|
+
# ---------------------------------------------------------------------------
|
|
6
|
+
# Context document and Claude Code session data — local only, not for source control
|
|
7
|
+
# ---------------------------------------------------------------------------
|
|
8
|
+
docs/CLAUDE_CONTEXT.md
|
|
9
|
+
.claude/
|
|
10
|
+
|
|
11
|
+
# ---------------------------------------------------------------------------
|
|
12
|
+
# Research notes and paper drafts — local working files, not for source control
|
|
13
|
+
# Keep docs/ for Sphinx sources only.
|
|
14
|
+
# ---------------------------------------------------------------------------
|
|
15
|
+
notes/
|
|
16
|
+
|
|
17
|
+
# ---------------------------------------------------------------------------
|
|
18
|
+
# Python bytecode and caches
|
|
19
|
+
# ---------------------------------------------------------------------------
|
|
20
|
+
__pycache__/
|
|
21
|
+
*.py[cod]
|
|
22
|
+
*$py.class
|
|
23
|
+
*.pyo
|
|
24
|
+
|
|
25
|
+
# ---------------------------------------------------------------------------
|
|
26
|
+
# Distribution / packaging
|
|
27
|
+
# ---------------------------------------------------------------------------
|
|
28
|
+
.Python
|
|
29
|
+
build/
|
|
30
|
+
dist/
|
|
31
|
+
eggs/
|
|
32
|
+
.eggs/
|
|
33
|
+
*.egg-info/
|
|
34
|
+
*.egg
|
|
35
|
+
MANIFEST
|
|
36
|
+
wheels/
|
|
37
|
+
pip-wheel-metadata/
|
|
38
|
+
share/python-wheels/
|
|
39
|
+
|
|
40
|
+
# ---------------------------------------------------------------------------
|
|
41
|
+
# Virtual environments
|
|
42
|
+
# ---------------------------------------------------------------------------
|
|
43
|
+
.venv/
|
|
44
|
+
venv/
|
|
45
|
+
env/
|
|
46
|
+
ENV/
|
|
47
|
+
.env
|
|
48
|
+
|
|
49
|
+
# ---------------------------------------------------------------------------
|
|
50
|
+
# Secrets / local environment files
|
|
51
|
+
# ---------------------------------------------------------------------------
|
|
52
|
+
.env.local
|
|
53
|
+
.env.*.local
|
|
54
|
+
*.secret
|
|
55
|
+
|
|
56
|
+
# ---------------------------------------------------------------------------
|
|
57
|
+
# Test artefacts
|
|
58
|
+
# ---------------------------------------------------------------------------
|
|
59
|
+
.pytest_cache/
|
|
60
|
+
.coverage
|
|
61
|
+
.coverage.*
|
|
62
|
+
htmlcov/
|
|
63
|
+
coverage.xml
|
|
64
|
+
*.cover
|
|
65
|
+
.hypothesis/
|
|
66
|
+
.benchmarks/
|
|
67
|
+
|
|
68
|
+
# ---------------------------------------------------------------------------
|
|
69
|
+
# Benchmark and results output
|
|
70
|
+
# JSON dumps are large/noisy — gitignored. BENCHMARKS.md is tracked.
|
|
71
|
+
# ---------------------------------------------------------------------------
|
|
72
|
+
results/*.json
|
|
73
|
+
results/**/*.json
|
|
74
|
+
results/old_benchmarks/
|
|
75
|
+
results/bench_stats_*.txt
|
|
76
|
+
*.json.bak
|
|
77
|
+
|
|
78
|
+
# ---------------------------------------------------------------------------
|
|
79
|
+
# Paper — self-contained LaTeX manuscript and generated figures
|
|
80
|
+
# Add to gitignore; will be made public separately (arXiv / IACR ePrint)
|
|
81
|
+
# ---------------------------------------------------------------------------
|
|
82
|
+
paper/
|
|
83
|
+
|
|
84
|
+
# ---------------------------------------------------------------------------
|
|
85
|
+
# Type checker
|
|
86
|
+
# ---------------------------------------------------------------------------
|
|
87
|
+
.mypy_cache/
|
|
88
|
+
.dmypy.json
|
|
89
|
+
dmypy.json
|
|
90
|
+
.pytype/
|
|
91
|
+
.pyre/
|
|
92
|
+
|
|
93
|
+
# ---------------------------------------------------------------------------
|
|
94
|
+
# Linters / formatters
|
|
95
|
+
# ---------------------------------------------------------------------------
|
|
96
|
+
.ruff_cache/
|
|
97
|
+
|
|
98
|
+
# ---------------------------------------------------------------------------
|
|
99
|
+
# Build / CI artefacts
|
|
100
|
+
# ---------------------------------------------------------------------------
|
|
101
|
+
.tox/
|
|
102
|
+
.nox/
|
|
103
|
+
|
|
104
|
+
# ---------------------------------------------------------------------------
|
|
105
|
+
# Editors and IDEs
|
|
106
|
+
# ---------------------------------------------------------------------------
|
|
107
|
+
.vscode/
|
|
108
|
+
.idea/
|
|
109
|
+
*.swp
|
|
110
|
+
*.swo
|
|
111
|
+
*~
|
|
112
|
+
.DS_Store
|
|
113
|
+
Thumbs.db
|
|
114
|
+
|
|
115
|
+
# ---------------------------------------------------------------------------
|
|
116
|
+
# liboqs build directory (if built from source locally)
|
|
117
|
+
# ---------------------------------------------------------------------------
|
|
118
|
+
liboqs/
|
|
119
|
+
|
|
120
|
+
# ---------------------------------------------------------------------------
|
|
121
|
+
# Jupyter notebooks (checkpoints)
|
|
122
|
+
# ---------------------------------------------------------------------------
|
|
123
|
+
.ipynb_checkpoints/
|
|
124
|
+
|
|
125
|
+
# ---------------------------------------------------------------------------
|
|
126
|
+
# Documentation build output
|
|
127
|
+
# ---------------------------------------------------------------------------
|
|
128
|
+
site/
|
|
129
|
+
docs/_build/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Read the Docs configuration
|
|
2
|
+
# https://docs.readthedocs.io/en/stable/config-file/v2.html
|
|
3
|
+
|
|
4
|
+
version: 2
|
|
5
|
+
|
|
6
|
+
build:
|
|
7
|
+
os: ubuntu-24.04
|
|
8
|
+
tools:
|
|
9
|
+
python: "3.11"
|
|
10
|
+
|
|
11
|
+
# Build Sphinx HTML docs
|
|
12
|
+
sphinx:
|
|
13
|
+
configuration: docs/conf.py
|
|
14
|
+
fail_on_warning: true
|
|
15
|
+
|
|
16
|
+
# Install the package and its docs extras so autodoc can import the source
|
|
17
|
+
python:
|
|
18
|
+
install:
|
|
19
|
+
- method: pip
|
|
20
|
+
path: .
|
|
21
|
+
extra_requirements:
|
|
22
|
+
- docs
|
|
23
|
+
- liboqs
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to quantum-safe are documented here.
|
|
4
|
+
|
|
5
|
+
## [Unreleased] — Security hardening 2026-04-12
|
|
6
|
+
|
|
7
|
+
### Security
|
|
8
|
+
|
|
9
|
+
A comprehensive cryptographic security audit (14 findings) was performed against
|
|
10
|
+
v0.1.0 source. All findings have been remediated in this release.
|
|
11
|
+
|
|
12
|
+
#### HIGH severity
|
|
13
|
+
|
|
14
|
+
- **Memory zeroization hardened** (`types/keys.py`, `types/kem.py`):
|
|
15
|
+
`_ZeroizingBytes.__del__` and `SharedSecret.__del__` now use `ctypes.memset`
|
|
16
|
+
against the live `bytearray` buffer instead of a Python byte-loop. The Python
|
|
17
|
+
optimizer can elide dead stores; `ctypes.memset` operates at the C level and
|
|
18
|
+
cannot be optimized away.
|
|
19
|
+
|
|
20
|
+
- **`SecretKey._raw_bytearray` property added** (`types/keys.py`):
|
|
21
|
+
Callers that need a mutable copy they can zero after use (e.g. backends passing
|
|
22
|
+
key material to C libraries) now have a first-class way to obtain one. The
|
|
23
|
+
property documents the zero-after-use pattern with `ctypes.memset`.
|
|
24
|
+
|
|
25
|
+
- **Version rollback rejected** (`types/keys.py`):
|
|
26
|
+
Deserialized CBOR key payloads with `version < 1` are now rejected with
|
|
27
|
+
`KeyParseError`. Previously an attacker who could tamper with stored key
|
|
28
|
+
material could downgrade the version field to bypass future format hardening.
|
|
29
|
+
|
|
30
|
+
#### MEDIUM severity
|
|
31
|
+
|
|
32
|
+
- **Serialization payload size cap** (`_internal/serialization.py`):
|
|
33
|
+
`loads()` now rejects payloads larger than 10 MB in both the cbor2 and JSON
|
|
34
|
+
fallback paths, guarding against memory-exhaustion via deeply nested or padded
|
|
35
|
+
structures.
|
|
36
|
+
|
|
37
|
+
- **P-256 ECDH output length guard** (`kem/hybrid.py`):
|
|
38
|
+
`_encapsulate_classical` and `_decapsulate_classical` now assert the P-256 ECDH
|
|
39
|
+
output is at least 32 bytes before passing it to the HKDF combiner.
|
|
40
|
+
|
|
41
|
+
- **liboqs secret key local copy zeroed** (`backends/liboqs.py`):
|
|
42
|
+
`LiboqsKEMBackend.decapsulate` and `LiboqsSignatureBackend.sign` convert the
|
|
43
|
+
incoming `bytes` to a `bytearray`, pass the bytes view to the C library, and
|
|
44
|
+
zero the local copy in a `finally` block via `ctypes.memset`.
|
|
45
|
+
|
|
46
|
+
- **Public key size validation** (`types/keys.py`):
|
|
47
|
+
`PublicKey.__init__` now validates the raw byte length against known FIPS sizes
|
|
48
|
+
for all non-hybrid algorithms (ML-KEM-512/768/1024, ML-DSA-44/65/87,
|
|
49
|
+
SLH-DSA variants). This prevents key-type confusion attacks where, for example,
|
|
50
|
+
ML-DSA bytes are accepted as an ML-KEM public key.
|
|
51
|
+
|
|
52
|
+
- **Migration state manager is thread-safe** (`migrate/state.py`):
|
|
53
|
+
`MigrationStateManager.transition()` now holds a per-key `threading.Lock` across
|
|
54
|
+
the read-check-write critical section, eliminating the TOCTOU race that could
|
|
55
|
+
allow two concurrent callers to both observe the same current state and both
|
|
56
|
+
commit conflicting transitions.
|
|
57
|
+
|
|
58
|
+
- **Hybrid signature verification is timing-safe** (`signatures/hybrid.py`):
|
|
59
|
+
`HybridSign.verify()` previously returned early after the classical sub-signature
|
|
60
|
+
failed, creating a timing oracle that revealed which component was invalid.
|
|
61
|
+
Both sub-signatures are now verified unconditionally before the combined result
|
|
62
|
+
is checked.
|
|
63
|
+
|
|
64
|
+
- **`HybridSign` constructor bypass removed** (`protocols/jwt.py`, `protocols/x509.py`):
|
|
65
|
+
`JWTSigner`, `JWTVerifier`, and `HybridCertificateBuilder` were constructing
|
|
66
|
+
`HybridSign` via `__new__` plus manual attribute assignment, bypassing
|
|
67
|
+
`validate_hybrid_combination()`. All three now use the normal constructor.
|
|
68
|
+
|
|
69
|
+
#### LOW severity
|
|
70
|
+
|
|
71
|
+
- **`PublicKey.__repr__` fingerprint cached** (`types/keys.py`):
|
|
72
|
+
`_cached_fp` slot added; SHA-256 is computed once and cached, preventing
|
|
73
|
+
repeated full-key hashing on every repr call (e.g. in log-heavy environments).
|
|
74
|
+
|
|
75
|
+
- **`generate_nonce()` warns on short nonces** (`types/keys.py`):
|
|
76
|
+
Nonces shorter than 12 bytes now emit a `UserWarning` pointing to the 12-byte
|
|
77
|
+
AEAD minimum (e.g. AES-GCM).
|
|
78
|
+
|
|
79
|
+
- **Hash-pinning documentation added** (`pyproject.toml`):
|
|
80
|
+
A comment block above the liboqs optional dependency explains how to generate
|
|
81
|
+
a hash-pinned `requirements.txt` for production installs.
|
|
82
|
+
|
|
83
|
+
- **liboqs-python upper version bound** (`pyproject.toml`):
|
|
84
|
+
`liboqs-python` is now pinned to `>=0.10.0,<0.12` to prevent silent breakage
|
|
85
|
+
if the upstream package makes incompatible API changes in a future minor release.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## [Unreleased] — Benchmark refresh 2026-03-29
|
|
90
|
+
|
|
91
|
+
### Changed
|
|
92
|
+
|
|
93
|
+
- **Benchmark methodology**: iterations increased from 1,000 to 3,000 per operation for tighter
|
|
94
|
+
confidence intervals; CPU pinning (`--cpuset-cpus="0,1"`) added to Docker runs to eliminate
|
|
95
|
+
cross-core migration noise; best-of-3 independent runs selected as authoritative result.
|
|
96
|
+
- **Headline numbers updated** (ENV-2, Docker/WSL2 Linux):
|
|
97
|
+
- Full hybrid KEM handshake: **~243 µs** (was ~301 µs — 19% improvement via methodology)
|
|
98
|
+
- HybridKEM keygen (real ML-KEM-768): **~99 µs** (was ~113 µs)
|
|
99
|
+
- Throughput @ 5,000 concurrent users: **~2,848 ops/s** (was ~2,009 ops/s)
|
|
100
|
+
- Throughput degradation 100→5,000 users: **−4.9%** (confirms GIL release and linear scaling)
|
|
101
|
+
- **ENV-1 refreshed** (Windows 11 native, 3,000 iterations): full hybrid KEM handshake **~587 µs**
|
|
102
|
+
- **Cross-environment comparison**: Linux 2.4× faster than Windows full handshake; 6.2× faster
|
|
103
|
+
on raw ML-KEM-768 keygen (build flag effect: `-DOQS_DIST_BUILD=ON` enables AVX2/AVX-512)
|
|
104
|
+
- `results/BENCHMARKS.md`: complete rewrite with dual-environment tables, combiner overhead
|
|
105
|
+
breakdown, CoV reference table, and paper headline numbers
|
|
106
|
+
- Old benchmark files archived to `results/old_benchmarks/`
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## [0.1.0] — unreleased
|
|
111
|
+
|
|
112
|
+
### Added
|
|
113
|
+
|
|
114
|
+
#### Core type system
|
|
115
|
+
|
|
116
|
+
- `PublicKey`, `SecretKey`, `KeyPair` with algorithm metadata and migration state
|
|
117
|
+
- `_ZeroizingBytes` — best-effort secret material zeroization on deletion
|
|
118
|
+
- `CipherText`, `HybridCipherText`, `SharedSecret` — distinct types prevent misuse
|
|
119
|
+
- `SignedMessage`, `HybridSignature` — self-describing signed message format
|
|
120
|
+
- Key serialization: PEM (with `qs-version`/`qs-algo` headers), CBOR, JWK
|
|
121
|
+
- Cross-format round-trip: Python ↔ TypeScript ↔ Rust use the same envelope
|
|
122
|
+
|
|
123
|
+
#### KEM module
|
|
124
|
+
|
|
125
|
+
- `KEM` — single-algorithm PQC KEM with backend dispatch
|
|
126
|
+
- `HybridKEM` — X25519+ML-KEM combined KEM (default: X25519+ML-KEM-768)
|
|
127
|
+
- HKDF-SHA256 hybrid combiner following draft-ietf-tls-hybrid-design
|
|
128
|
+
- P-256 support as alternative classical companion
|
|
129
|
+
- Algorithm registry: ML-KEM-512/768/1024, BIKE-L1, HQC-128
|
|
130
|
+
|
|
131
|
+
#### Signatures module
|
|
132
|
+
|
|
133
|
+
- `Sign` — single-algorithm PQC signer with hedged mode
|
|
134
|
+
- `HybridSign` — Ed25519+ML-DSA combined signer (default: Ed25519+ML-DSA-65)
|
|
135
|
+
- Hedged mode (default on): random prefix prevents fault injection attacks
|
|
136
|
+
- Context string support for domain separation (per FIPS 204 §5.2)
|
|
137
|
+
- Algorithm registry: ML-DSA-44/65/87, SLH-DSA-SHAKE-128s/128f
|
|
138
|
+
|
|
139
|
+
#### Backends
|
|
140
|
+
|
|
141
|
+
- `liboqs` backend — full algorithm set via liboqs-python
|
|
142
|
+
- `rustcrypto` backend — stub (FIPS-subset, pending PyO3 crate publication)
|
|
143
|
+
- Auto-selection: tries rustcrypto first, falls back to liboqs
|
|
144
|
+
- `list_available_backends()` for diagnostics
|
|
145
|
+
|
|
146
|
+
#### Protocol helpers
|
|
147
|
+
|
|
148
|
+
- `Envelope.seal()` / `Envelope.open()` — KEM + AES-256-GCM authenticated encryption
|
|
149
|
+
- `JWTSigner` / `JWTVerifier` — PQC JWT (draft-ietf-jose-pqc-signatures identifiers)
|
|
150
|
+
- `HybridTLSConfig` / `configure_hybrid_context()` — TLS hybrid key exchange
|
|
151
|
+
- `HybridCertificateBuilder` — X.509 certs with PQC co-signature extension
|
|
152
|
+
|
|
153
|
+
#### Migration tooling
|
|
154
|
+
|
|
155
|
+
- `Scanner` — AST-based classical crypto detector (14 rules covering `cryptography`, `pycryptodome`, and stdlib `hashlib`; SARIF output)
|
|
156
|
+
- `MigrationStateManager` — state machine for per-key migration tracking
|
|
157
|
+
- `Upgrader` — upgrades classical keys to hybrid while preserving backward compat
|
|
158
|
+
- `FernetShim`, `JWTShim` — drop-in shims with usage logging
|
|
159
|
+
- `qs-migrate` CLI with `scan`, `upgrade-key`, `status` subcommands
|
|
160
|
+
|
|
161
|
+
#### Audit and compliance
|
|
162
|
+
|
|
163
|
+
- `Auditor` — orchestrates scan + policy evaluation
|
|
164
|
+
- `AuditPolicy` — configurable policy (presets: standard, strict, transition, permissive)
|
|
165
|
+
- `NISTComplianceChecker` — maps findings to FIPS 203/204/205, SP 800-208, CISA checklist
|
|
166
|
+
- `SBOMEnricher` — CycloneDX SBOM enrichment with PQC-readiness annotations
|
|
167
|
+
- `qs-audit` CLI with `scan`, `sbom`, `requirements`, `compliance` subcommands
|
|
168
|
+
- CI gate: `Auditor.ci_gate()` returns exit code 0/1 and writes SARIF/JSON
|
|
169
|
+
|
|
170
|
+
#### Internal
|
|
171
|
+
|
|
172
|
+
- `_internal.serialization` — cbor2 (required) with JSON+base64 fallback for constrained environments
|
|
173
|
+
- `exceptions.py` — full 3-level exception hierarchy with machine-readable `code` fields
|
|
174
|
+
|
|
175
|
+
### Known limitations (v0.1.0)
|
|
176
|
+
|
|
177
|
+
- RustCrypto backend is a stub — `is_available()` returns False until PyO3 crate ships
|
|
178
|
+
- noble (JavaScript/WASM) backend is JS-only — not available in Python
|
|
179
|
+
- TLS `set_groups()` requires OQS-patched OpenSSL — degrades gracefully without it
|
|
180
|
+
- X.509 co-signature OID (`1.3.6.1.4.1.99999.1`) is a placeholder — register before production use
|
|
181
|
+
- TypeScript/Rust scanner rules are planned for v0.2
|