pqproof 0.1.0__py3-none-any.whl
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.
- pqproof/__init__.py +7 -0
- pqproof/__main__.py +6 -0
- pqproof/_tool/CHANGELOG.md +55 -0
- pqproof/_tool/LICENSE +21 -0
- pqproof/_tool/build-probe.sh +27 -0
- pqproof/_tool/examples/classic/README.md +7 -0
- pqproof/_tool/examples/classic/pom.xml +9 -0
- pqproof/_tool/examples/classic/requirements.txt +1 -0
- pqproof/_tool/examples/classic/src/main/java/demo/sealer/Sealer.java +52 -0
- pqproof/_tool/examples/classic/tools/sign_manifest.py +44 -0
- pqproof/_tool/examples/github-actions/pqproof-sarif.yml +55 -0
- pqproof/_tool/examples/pqc/README.md +6 -0
- pqproof/_tool/examples/pqc/pom.xml +9 -0
- pqproof/_tool/examples/pqc/requirements.txt +1 -0
- pqproof/_tool/examples/pqc/src/main/java/demo/sealer/Sealer.java +61 -0
- pqproof/_tool/examples/pqc/tools/sign_manifest.py +49 -0
- pqproof/_tool/pqlite/__init__.py +3 -0
- pqproof/_tool/pqlite/allowlist.py +573 -0
- pqproof/_tool/pqlite/receipt.py +1167 -0
- pqproof/_tool/pqlite/scan.py +695 -0
- pqproof/_tool/pqlite/tlsprobe.py +290 -0
- pqproof/_tool/pqlite/verify.py +646 -0
- pqproof/_tool/pqlite/version.py +105 -0
- pqproof/_tool/probe/go.mod +5 -0
- pqproof/_tool/probe/tls_probe.go +500 -0
- pqproof/_tool/prove.py +1861 -0
- pqproof/_tool/prove.sh +58 -0
- pqproof/_tool/scan/cbom-scan.sh +768 -0
- pqproof/_tool/scan/fixtures/apache/ssl.conf +9 -0
- pqproof/_tool/scan/fixtures/config/application.yml +10 -0
- pqproof/_tool/scan/fixtures/config/tls.properties +4 -0
- pqproof/_tool/scan/fixtures/docs/README.md +2 -0
- pqproof/_tool/scan/fixtures/go/go.mod +5 -0
- pqproof/_tool/scan/fixtures/go/main.go +25 -0
- pqproof/_tool/scan/fixtures/haproxy/haproxy.cfg +5 -0
- pqproof/_tool/scan/fixtures/java/pom.xml +13 -0
- pqproof/_tool/scan/fixtures/java/src/main/java/com/demo/CryptoService.java +46 -0
- pqproof/_tool/scan/fixtures/java/src/test/java/com/demo/CryptoServiceTest.java +10 -0
- pqproof/_tool/scan/fixtures/nginx/conf.d/default-groups.conf +5 -0
- pqproof/_tool/scan/fixtures/nginx/conf.d/upstream.conf +10 -0
- pqproof/_tool/scan/fixtures/nginx/nginx.conf +14 -0
- pqproof/_tool/scan/fixtures/nginx/sites-available/pqc +8 -0
- pqproof/_tool/scan/fixtures/node/node_modules/legacy/index.js +1 -0
- pqproof/_tool/scan/fixtures/node/package.json +7 -0
- pqproof/_tool/scan/fixtures/node/server.js +12 -0
- pqproof/_tool/scan/fixtures/node/test.mjs +2 -0
- pqproof/_tool/scan/fixtures/node/tls.js +5 -0
- pqproof/_tool/scan/fixtures/openssl/openssl.cnf +9 -0
- pqproof/_tool/scan/fixtures/postgres/16/main/PG_VERSION +1 -0
- pqproof/_tool/scan/fixtures/postgres/16/main/postgresql.conf +5 -0
- pqproof/_tool/scan/fixtures/postgres/18/data/PG_VERSION +1 -0
- pqproof/_tool/scan/fixtures/postgres/18/data/postgresql.conf +2 -0
- pqproof/_tool/scan/fixtures/postgresql/15/main/postgresql.conf +2 -0
- pqproof/_tool/scan/fixtures/postgresql-proxy/nginx.conf +1 -0
- pqproof/_tool/scan/fixtures/python/app.py +17 -0
- pqproof/_tool/scan/fixtures/python/requirements.txt +4 -0
- pqproof/_tool/scan/fixtures/scripts/provision.sh +5 -0
- pqproof/_tool/scan/fixtures/ssh/sshd_config +7 -0
- pqproof/_tool/scan/fixtures/ssh/sshd_config.d/pq.conf +1 -0
- pqproof/_tool/scan/fixtures/ssh-default/sshd_config +3 -0
- pqproof/_tool/scan/residue.sh +182 -0
- pqproof/_tool/scan/ruleset.json +7 -0
- pqproof/_tool/scan/test-paths.ere +9 -0
- pqproof/_tool/tests/e2e_orders_edge.py +264 -0
- pqproof/_tool/tests/fixtures/FROM-pq-proof.txt +5 -0
- pqproof/_tool/tests/fixtures/orders-edge/Dockerfile +14 -0
- pqproof/_tool/tests/fixtures/orders-edge/README.md +2 -0
- pqproof/_tool/tests/fixtures/orders-edge/cmd/api/main.go +63 -0
- pqproof/_tool/tests/fixtures/orders-edge/go.mod +8 -0
- pqproof/_tool/tests/fixtures/orders-edge/internal/auth/jwt.go +34 -0
- pqproof/_tool/tests/fixtures/orders-edge/internal/auth/jwt_test.go +53 -0
- pqproof/_tool/tests/fixtures/orders-edge/internal/tlsconf/tlsconf.go +14 -0
- pqproof/_tool/tests/fixtures/orders-edge/nginx/nginx.conf +31 -0
- pqproof/_tool/tests/fixtures/orders-edge/vendor/github.com/golang-jwt/jwt/v5/rsa.go +5 -0
- pqproof/_tool/tests/fixtures/orders-edge-injected-model.json +113 -0
- pqproof/_tool/tests/fixtures/orders-edge-scripted-model.json +108 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/cbom-fixed/cbom-20261118-011740.csv +17 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/cbom-fixed/cbom-20261118-011740.md +27 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/cbom-fixed/run.log +8 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/cbom-orig/cbom-20261118-011740.csv +15 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/cbom-orig/cbom-20261118-011740.md +25 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/cbom-orig/run.log +6 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/changed-files.json +10 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/residue-fixed.txt +30 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/residue-generic.sh +174 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/residue-orig.txt +51 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/scan-fixed.json +98 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/scan-orig.json +86 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/artifacts/weakening.json +10 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/deck.json +75 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/evidence-fragment.json +37 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/receipt.html +34 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/receipt.json +546 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/tables/cbom-fixed.csv +25 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/tables/cbom-orig.csv +22 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/tables/fragment.html +1 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/tables/java-usage.csv +16 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/tables/java.csv +15 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/tables/report.md +25 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/tables/summary.csv +8 -0
- pqproof/_tool/tests/golden/evidence/f1-public-a/tables/tls.csv +1 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/cbom-fixed/cbom-20261118-024053.csv +17 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/cbom-fixed/cbom-20261118-024053.md +27 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/cbom-fixed/run.log +8 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/cbom-orig/cbom-20261118-024052.csv +15 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/cbom-orig/cbom-20261118-024052.md +25 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/cbom-orig/run.log +6 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/changed-files.json +10 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/residue-fixed.txt +30 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/residue-generic.sh +174 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/residue-orig.txt +51 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/scan-fixed.json +98 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/scan-orig.json +86 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/artifacts/weakening.json +10 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/deck.json +83 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/evidence-fragment.json +40 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/receipt.html +34 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/receipt.json +556 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/tables/cbom-fixed.csv +25 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/tables/cbom-orig.csv +22 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/tables/fragment.html +1 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/tables/java-usage.csv +16 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/tables/java.csv +15 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/tables/report.md +26 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/tables/summary.csv +9 -0
- pqproof/_tool/tests/golden/evidence/f1-public-b/tables/tls.csv +1 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/allow-list.json +1 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/cbom-fixed/cbom-20261118-060849.csv +17 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/cbom-fixed/cbom-20261118-060849.md +27 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/cbom-fixed/run.log +8 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/cbom-orig/cbom-20261118-060849.csv +15 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/cbom-orig/cbom-20261118-060849.md +25 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/cbom-orig/run.log +6 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/changed-files.json +10 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/residue-fixed.txt +30 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/residue-generic.sh +182 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/residue-orig.txt +51 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/scan-fixed.json +98 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/scan-orig.json +86 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/test-paths.ere +9 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/artifacts/weakening.json +10 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/deck.json +86 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/evidence-fragment.json +40 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/receipt.html +34 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/receipt.json +669 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/tables/cbom-fixed.csv +25 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/tables/cbom-orig.csv +22 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/tables/fragment.html +1 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/tables/java-usage.csv +16 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/tables/java.csv +15 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/tables/report.md +26 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/tables/summary.csv +9 -0
- pqproof/_tool/tests/golden/evidence/f1-public-c/tables/tls.csv +1 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/cbom-fixed/cbom-20261118-102745.csv +16 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/cbom-fixed/cbom-20261118-102745.md +26 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/cbom-fixed/run.log +8 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/cbom-orig/cbom-20261118-102744.csv +15 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/cbom-orig/cbom-20261118-102744.md +25 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/cbom-orig/run.log +6 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/changed-files.json +10 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/residue-fixed.txt +30 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/residue-generic.sh +182 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/residue-orig.txt +51 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/scan-fixed.json +86 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/scan-orig.json +86 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/test-paths.ere +9 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/artifacts/weakening.json +27 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/deck.json +89 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/evidence-fragment.json +40 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/receipt.html +34 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/receipt.json +629 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/tables/cbom-fixed.csv +23 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/tables/cbom-orig.csv +22 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/tables/fragment.html +1 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/tables/java-usage.csv +15 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/tables/java.csv +15 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/tables/report.md +28 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/tables/summary.csv +9 -0
- pqproof/_tool/tests/golden/evidence/f2-v0.1.0/tables/tls.csv +1 -0
- pqproof/_tool/tests/golden/evidence/manifest.json +108 -0
- pqproof/_tool/tests/golden/make_fixture.py +151 -0
- pqproof/_tool/tests/golden/verdicts.json +1195 -0
- pqproof/_tool/tests/mutations/files/PqcNames.java +6 -0
- pqproof/_tool/tests/mutations/files/Uplink.java +15 -0
- pqproof/_tool/tests/mutations/files/allow-masking.json +4 -0
- pqproof/_tool/tests/mutations/files/allow-v1-forged.json +8 -0
- pqproof/_tool/tests/mutations/files/allow-v1.json +5 -0
- pqproof/_tool/tests/mutations/files/fetch_unverified.py.txt +12 -0
- pqproof/_tool/tests/mutations/files/seal_keys.go +12 -0
- pqproof/_tool/tests/mutations/files/seal_test.go +16 -0
- pqproof/_tool/tests/mutations/files/trust_all.java.txt +8 -0
- pqproof/_tool/tests/mutations/files/verify_v1.py +12 -0
- pqproof/_tool/tests/mutations/mutations.json +580 -0
- pqproof/_tool/tests/mutations/run_mutations.py +560 -0
- pqproof/_tool/tests/mutations/selfcheck.json +18 -0
- pqproof/_tool/tests/run_unit.py +35 -0
- pqproof/_tool/tests/test_allowlist.py +839 -0
- pqproof/_tool/tests/test_golden.py +66 -0
- pqproof/_tool/tests/test_pqproof_pkg.py +201 -0
- pqproof/_tool/tests/test_prove.py +299 -0
- pqproof/_tool/tests/test_receipt.py +162 -0
- pqproof/_tool/tests/test_scan.py +182 -0
- pqproof/_tool/tests/test_scan_java.py +207 -0
- pqproof/_tool/tests/test_testpaths.py +220 -0
- pqproof/_tool/tests/test_tlsprobe.py +118 -0
- pqproof/_tool/tests/test_verify.py +154 -0
- pqproof/_tool/tests/test_versioning.py +228 -0
- pqproof/cli.py +183 -0
- pqproof/deps.py +146 -0
- pqproof/sarif.py +439 -0
- pqproof-0.1.0.dist-info/METADATA +77 -0
- pqproof-0.1.0.dist-info/RECORD +215 -0
- pqproof-0.1.0.dist-info/WHEEL +4 -0
- pqproof-0.1.0.dist-info/entry_points.txt +2 -0
- pqproof-0.1.0.dist-info/licenses/LICENSE +21 -0
pqproof/__init__.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""PQ-Proof: check that a PQC migration is complete. The original and the converted tree are judged by the same rules,
|
|
2
|
+
and the run leaves a hashed evidence record (RFC 8785 + SHA-256). Offline, no AI calls.
|
|
3
|
+
|
|
4
|
+
The checking code itself is the shell and Python tool shipped as package data under pqproof/_tool (prove.sh, prove.py,
|
|
5
|
+
pqlite/, scan/). The console command `pqproof` runs it exactly like `bash prove.sh`.
|
|
6
|
+
"""
|
|
7
|
+
__version__ = "0.1.0"
|
pqproof/__main__.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to PQ-Proof are listed here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
4
|
+
|
|
5
|
+
Each release has a **Verdict impact (판정 영향)** line. It says whether the same two trees can get a different verdict, check status or count than they got with the previous release.
|
|
6
|
+
|
|
7
|
+
- A rule change (detection pattern, test path, allow rule, a check added or removed) bumps MINOR while the version is 0.x, and MAJOR from 1.0 on. It also gets a new ruleset name in `scan/ruleset.json`.
|
|
8
|
+
- A change that leaves every verdict alone bumps PATCH.
|
|
9
|
+
- Only the latest MINOR release gets fixes. See [SECURITY.md](SECURITY.md).
|
|
10
|
+
|
|
11
|
+
Every run records `tool_version`, `ruleset_version` and `ruleset_sha256` in `receipt.json`, so a receipt from years ago still names the rules that judged it. `--verify` keeps reading older evidence formats.
|
|
12
|
+
|
|
13
|
+
## [Unreleased]
|
|
14
|
+
|
|
15
|
+
## [0.1.0] - 2026-11-18
|
|
16
|
+
|
|
17
|
+
First public release: tool 0.1.0, ruleset 1, evidence format 2. The comparison point is the version that ran in the finals of the 2026 PQC Transition Hackathon on 2026-11-16 ("the finals version" below).
|
|
18
|
+
|
|
19
|
+
**Verdict impact (판정 영향): yes, compared with the finals version.** A tree whose only classical public-key lines sit in test paths used to fail `c-classic` and now passes (D2 below). The new `r-allow` check adds a row, and it fails a run only under `REQUIRE_REVIEW=1`. On 16 runs over the eight practice tasks, every verdict matched the finals version. The one intended difference is a reproduction of the test-path case. Those runs used the rules of this release (ruleset 1); the rule files have changed since only in comments.
|
|
20
|
+
|
|
21
|
+
| Change | Verdict impact (판정 영향) |
|
|
22
|
+
|---|---|
|
|
23
|
+
| New check `r-allow`: was each allowlist entry read by a person (`reviewed_by`, `reviewed_at`, `reviewed_digest`)? | New row. The verdict moves only with `REQUIRE_REVIEW=1`, where an unreviewed entry fails the run. |
|
|
24
|
+
| D1: an allowlist entry that covers no classical line in the fixed tree is reported as unused, with the original lines it would hide. This includes an entry for a file the fix deleted. | `r-allow` needs review, or fails under `REQUIRE_REVIEW=1`. A list whose entries are all unused moves `r-allow` from not applicable to needs review. |
|
|
25
|
+
| D2: one test-path list (`scan/test-paths.ere`) for all scanners, and nothing under `src/main/` counts as a test path. | Can move verdicts: classical lines in `*_test.go`, `*Test.java`, `test_*.py`, `__tests__/`, `testdata/` and top-level example folders no longer count, and `src/main/java/com/example/` is no longer treated as tests. |
|
|
26
|
+
| The verdict line counts removed verification calls, for example `VERDICT=PASS (2 removed verifications need review)`. | Text only. Before, a `verify()` reduced to `return true` passed with no note on the verdict line. |
|
|
27
|
+
| The output says 검증 증적 (verification evidence) for 영수증 (receipt), and 보안레벨 (security level) for 범주 (category). | Text only. |
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- `pqproof` console command and Python package (`pip install pqproof`). It runs the same files as `bash prove.sh`. There are no runtime Python dependencies.
|
|
32
|
+
- `pqproof sarif` and `bash prove.sh sarif`: evidence to SARIF 2.1.0 for GitHub code scanning. Checks that did not run are listed under `notCountedAsPass`.
|
|
33
|
+
- GitHub Action (`action.yml`) with outputs `verdict`, `evidence-hash` and `sarif-file`, and an example workflow in `examples/github-actions/`.
|
|
34
|
+
- Mutation suite (`tests/mutations/`): 18 cases, planted defects and their controls, each with the result it must give. A case that cannot be set up is SKIP and is not counted as passed.
|
|
35
|
+
- Golden verdicts (`tests/golden/verdicts.json`): the verdict, check statuses and counts of every mutation and example case. CI fails when a rule change moves one of them.
|
|
36
|
+
- Evidence format 2: `receipt.json` records `format_version`, `tool_version`, `ruleset_version` and `ruleset_sha256`, the hash of the six rule files that ran. `--verify` recomputes that hash from the tool hashes in the receipt.
|
|
37
|
+
- `bash prove.sh --version` and `pqproof --version`. The version lives in one place, `src/pqproof/__init__.py`.
|
|
38
|
+
- Backward-compatibility fixtures (`tests/golden/evidence/`): evidence written by three earlier public copies and by this release. `--verify` must keep reading them. Local paths were replaced with neutral text; verdicts and counts are unchanged.
|
|
39
|
+
- CI on Ubuntu and macOS with Python 3.9 to 3.14, Pages deployment, and a release workflow that builds the wheel, the sdist, three `tls_probe` binaries, a CycloneDX SBOM and build provenance attestations, then publishes to PyPI with Trusted Publishing.
|
|
40
|
+
- `SECURITY.md`, Dependabot for GitHub Actions and pip, and every action pinned to a commit SHA.
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
|
|
44
|
+
- `--verify` reads evidence format 1 (no `format_version`): the earlier public copies. It accepts their notes and rebuilds their `receipt.html` with the words they used.
|
|
45
|
+
- Self-test and unit tests count skipped cases apart (`n 통과 · m 건너뜀 · k 실패`). With `STRICT=1` a skipped case fails the run. CI runs with `STRICT=1`.
|
|
46
|
+
- After the verdict, the console prints how many checks ended in each state. Only pass counts as passed.
|
|
47
|
+
- An explicit `OPENSSL` is used as given, even below 3.5. Before, a newer OpenSSL found elsewhere took its place.
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
|
|
51
|
+
- Every TLS target in `receipt.json` now has `openssl_agrees`. Without OpenSSL 3.5 (Ubuntu's 3.0, macOS LibreSSL) it is `null` and `openssl_note` says 교차 확인 불가 (cross-check not possible). Before, the field was missing and code that read it failed.
|
|
52
|
+
- `--verify` checks that the residue script hash in `tools[]` matches the copy in `artifacts/` (`java.script_sha256`). Before, the two could differ and the evidence still verified.
|
|
53
|
+
|
|
54
|
+
[Unreleased]: https://github.com/g1mn/pqproof/compare/v0.1.0...HEAD
|
|
55
|
+
[0.1.0]: https://github.com/g1mn/pqproof/releases/tag/v0.1.0
|
pqproof/_tool/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 g1mn
|
|
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,27 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# build-probe.sh: tls_probe 정적 바이너리 3종을 인터넷 없이 만든다(맥 arm64, 리눅스 amd64·arm64).
|
|
3
|
+
# bash build-probe.sh → bin/tls_probe-{darwin-arm64,linux-amd64,linux-arm64}, bin/SHA256SUMS, bin/BUILDINFO
|
|
4
|
+
# PROBE_BIN_DIR=/다른/폴더 bash build-probe.sh → 그 폴더에 만든다(prove.sh도 같은 PROBE_BIN_DIR로 찾는다)
|
|
5
|
+
# Go 표준 라이브러리만 쓴다: GOPROXY=off CGO_ENABLED=0 GOTOOLCHAIN=local(깔린 go만, 내려받기 없음). Go 1.27 이상(crypto/mldsa).
|
|
6
|
+
# 인텔 맥이면 아래 목록에 darwin/amd64를 보탠다.
|
|
7
|
+
# bash 3.2 호환. 지우는 명령 없음(같은 이름 바이너리는 go build가 덮어쓴다).
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
HERE=$(cd "$(dirname "$0")" && pwd)
|
|
10
|
+
command -v go >/dev/null || { echo "go 없음: Go 1.27 이상이 있어야 한다(crypto/mldsa)" >&2; exit 2; }
|
|
11
|
+
OUT=${PROBE_BIN_DIR:-$HERE/bin}
|
|
12
|
+
mkdir -p "$OUT"
|
|
13
|
+
OUT=$(cd "$OUT" && pwd)
|
|
14
|
+
for t in darwin/arm64 linux/amd64 linux/arm64; do
|
|
15
|
+
os=${t%/*}; arch=${t#*/}
|
|
16
|
+
GOOS=$os GOARCH=$arch CGO_ENABLED=0 GOPROXY=off GOTOOLCHAIN=local GOFLAGS=-mod=mod GOWORK=off \
|
|
17
|
+
go build -C "$HERE/probe" -trimpath -buildvcs=false -ldflags='-s -w -buildid=' -o "$OUT/tls_probe-$os-$arch" .
|
|
18
|
+
echo "built $OUT/tls_probe-$os-$arch"
|
|
19
|
+
done
|
|
20
|
+
if command -v shasum >/dev/null; then SUM="shasum -a 256"; else SUM="sha256sum"; fi
|
|
21
|
+
( cd "$OUT" && $SUM tls_probe-darwin-arm64 tls_probe-linux-amd64 tls_probe-linux-arm64 > SHA256SUMS )
|
|
22
|
+
{
|
|
23
|
+
echo "go: $(go version)"
|
|
24
|
+
echo "flags: GOPROXY=off CGO_ENABLED=0 GOTOOLCHAIN=local GOFLAGS=-mod=mod -trimpath -buildvcs=false -ldflags=-s -w -buildid="
|
|
25
|
+
( cd "$HERE/probe" && $SUM go.mod tls_probe.go | sed 's/^/source: /' )
|
|
26
|
+
} > "$OUT/BUILDINFO"
|
|
27
|
+
cat "$OUT/SHA256SUMS"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# sealer (before)
|
|
2
|
+
|
|
3
|
+
A tiny sealer used by `prove.sh --selftest`. It wraps a data key for a recipient and signs the sealed record.
|
|
4
|
+
This is the version before the migration: RSA-OAEP key wrapping and ECDSA P-256 signatures, in Java and in Python.
|
|
5
|
+
Compare it with `../pqc`, the migrated version.
|
|
6
|
+
|
|
7
|
+
Written for this repository.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
|
2
|
+
<modelVersion>4.0.0</modelVersion>
|
|
3
|
+
<groupId>demo</groupId>
|
|
4
|
+
<artifactId>sealer</artifactId>
|
|
5
|
+
<version>1.0.0</version>
|
|
6
|
+
<properties>
|
|
7
|
+
<maven.compiler.release>24</maven.compiler.release>
|
|
8
|
+
</properties>
|
|
9
|
+
</project>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cryptography>=42
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
package demo.sealer;
|
|
2
|
+
|
|
3
|
+
import java.security.GeneralSecurityException;
|
|
4
|
+
import java.security.KeyPair;
|
|
5
|
+
import java.security.KeyPairGenerator;
|
|
6
|
+
import java.security.PrivateKey;
|
|
7
|
+
import java.security.PublicKey;
|
|
8
|
+
import java.security.Signature;
|
|
9
|
+
import java.security.spec.ECGenParameterSpec;
|
|
10
|
+
import javax.crypto.Cipher;
|
|
11
|
+
|
|
12
|
+
/** Wraps a data key for a recipient and signs the sealed record. */
|
|
13
|
+
public final class Sealer {
|
|
14
|
+
|
|
15
|
+
public KeyPair recipientKeys() throws GeneralSecurityException {
|
|
16
|
+
KeyPairGenerator g = KeyPairGenerator.getInstance("RSA");
|
|
17
|
+
g.initialize(3072);
|
|
18
|
+
return g.generateKeyPair();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public KeyPair signingKeys() throws GeneralSecurityException {
|
|
22
|
+
KeyPairGenerator g = KeyPairGenerator.getInstance("EC");
|
|
23
|
+
g.initialize(new ECGenParameterSpec("secp256r1"));
|
|
24
|
+
return g.generateKeyPair();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public byte[] seal(PublicKey recipient, byte[] dataKey) throws GeneralSecurityException {
|
|
28
|
+
Cipher c = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
|
|
29
|
+
c.init(Cipher.ENCRYPT_MODE, recipient);
|
|
30
|
+
return c.doFinal(dataKey);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public byte[] open(PrivateKey recipient, byte[] sealed) throws GeneralSecurityException {
|
|
34
|
+
Cipher c = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
|
|
35
|
+
c.init(Cipher.DECRYPT_MODE, recipient);
|
|
36
|
+
return c.doFinal(sealed);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public byte[] sign(PrivateKey key, byte[] message) throws GeneralSecurityException {
|
|
40
|
+
Signature s = Signature.getInstance("SHA256withECDSA");
|
|
41
|
+
s.initSign(key);
|
|
42
|
+
s.update(message);
|
|
43
|
+
return s.sign();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public boolean verify(PublicKey key, byte[] message, byte[] signature) throws GeneralSecurityException {
|
|
47
|
+
Signature s = Signature.getInstance("SHA256withECDSA");
|
|
48
|
+
s.initVerify(key);
|
|
49
|
+
s.update(message);
|
|
50
|
+
return s.verify(signature);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Signs a release manifest and wraps its data key for the backup host."""
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from cryptography.exceptions import InvalidSignature
|
|
6
|
+
from cryptography.hazmat.primitives import hashes
|
|
7
|
+
from cryptography.hazmat.primitives.asymmetric import ec, padding, rsa
|
|
8
|
+
|
|
9
|
+
WRAP = padding.OAEP(mgf=padding.MGF1(algorithm=hashes.SHA256()), algorithm=hashes.SHA256(), label=None)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def new_keys():
|
|
13
|
+
signing = ec.generate_private_key(ec.SECP256R1())
|
|
14
|
+
backup = rsa.generate_private_key(public_exponent=65537, key_size=3072)
|
|
15
|
+
return signing, backup
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def sign(signing, manifest):
|
|
19
|
+
return signing.sign(manifest, ec.ECDSA(hashes.SHA256()))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def verify(public, manifest, signature):
|
|
23
|
+
try:
|
|
24
|
+
public.verify(signature, manifest, ec.ECDSA(hashes.SHA256()))
|
|
25
|
+
return True
|
|
26
|
+
except InvalidSignature:
|
|
27
|
+
return False
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def wrap_key(backup_public, data_key):
|
|
31
|
+
return backup_public.encrypt(data_key, WRAP)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def unwrap_key(backup, blob):
|
|
35
|
+
return backup.decrypt(blob, WRAP)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
manifest = sys.stdin.buffer.read() if not sys.stdin.isatty() else b"release 1.0\n"
|
|
40
|
+
signing, backup = new_keys()
|
|
41
|
+
sig = sign(signing, manifest)
|
|
42
|
+
data_key = os.urandom(32)
|
|
43
|
+
blob = wrap_key(backup.public_key(), data_key)
|
|
44
|
+
print("signature ok:", verify(signing.public_key(), manifest, sig), "key ok:", unwrap_key(backup, blob) == data_key)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# 예시: PR 마다 기준 브랜치(원본)와 PR 결과(전환본)를 PQ-Proof 로 판정하고, 남은 고전 공개키 위치를
|
|
2
|
+
# GitHub code scanning 경고(SARIF)로 올린다. 검증 증적 폴더는 작업 산출물로 남긴다.
|
|
3
|
+
# 이 파일을 쓰는 저장소의 .github/workflows/ 에 복사한다. 같은 저장소 PR 에서 SARIF 를 올릴 수 있다
|
|
4
|
+
# (포크 PR 은 GITHUB_TOKEN 이 읽기 전용이라 upload-sarif 가 막힌다).
|
|
5
|
+
# 액션은 커밋 SHA 로 고정해 쓰기를 권한다. g1mn/pqproof 는 첫 릴리스(v0.1.0) 뒤 그 태그의 SHA 로 바꾼다.
|
|
6
|
+
name: PQC migration check
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
pull_request:
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
actions: read # 비공개 저장소의 upload-sarif 에 필요하다
|
|
15
|
+
security-events: write # upload-sarif
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
pqproof:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
22
|
+
with:
|
|
23
|
+
fetch-depth: 0
|
|
24
|
+
persist-credentials: false
|
|
25
|
+
|
|
26
|
+
- name: Original tree from the base commit (git archive, no .git inside)
|
|
27
|
+
env:
|
|
28
|
+
BASE: ${{ github.event.pull_request.base.sha || 'HEAD~1' }}
|
|
29
|
+
run: |
|
|
30
|
+
mkdir -p "$RUNNER_TEMP/original"
|
|
31
|
+
git archive "$BASE" | tar -x -C "$RUNNER_TEMP/original"
|
|
32
|
+
|
|
33
|
+
- name: PQ-Proof
|
|
34
|
+
id: pqproof
|
|
35
|
+
uses: g1mn/pqproof@v0.1.0
|
|
36
|
+
with:
|
|
37
|
+
original: ${{ runner.temp }}/original
|
|
38
|
+
converted: .
|
|
39
|
+
allow-list: notes/unconverted.json # 없으면 'none'
|
|
40
|
+
require-review: true # 허용 항목마다 사람 확인(reviewed_by·reviewed_at)
|
|
41
|
+
sarif-anchor: notes/unconverted.json # 위치 없는 검사(c-expect 등)를 이 파일 1행에 붙인다
|
|
42
|
+
|
|
43
|
+
- name: Upload SARIF to code scanning
|
|
44
|
+
if: always() && steps.pqproof.outputs.sarif-file != ''
|
|
45
|
+
uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
|
46
|
+
with:
|
|
47
|
+
sarif_file: ${{ steps.pqproof.outputs.sarif-file }}
|
|
48
|
+
category: pqproof
|
|
49
|
+
|
|
50
|
+
- name: Keep the evidence folder
|
|
51
|
+
if: always() && steps.pqproof.outputs.output-dir != ''
|
|
52
|
+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
53
|
+
with:
|
|
54
|
+
name: pqproof-evidence
|
|
55
|
+
path: ${{ steps.pqproof.outputs.output-dir }}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# sealer (after)
|
|
2
|
+
|
|
3
|
+
The migrated version of `../classic`. Key wrapping uses ML-KEM-768 with AES-256-GCM, and signatures use ML-DSA-65.
|
|
4
|
+
Java needs JDK 24 or later (built-in ML-KEM and ML-DSA). Python needs pyca/cryptography 48 or later on OpenSSL 3.5 or later.
|
|
5
|
+
|
|
6
|
+
Written for this repository.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
|
2
|
+
<modelVersion>4.0.0</modelVersion>
|
|
3
|
+
<groupId>demo</groupId>
|
|
4
|
+
<artifactId>sealer</artifactId>
|
|
5
|
+
<version>1.0.0</version>
|
|
6
|
+
<properties>
|
|
7
|
+
<maven.compiler.release>24</maven.compiler.release>
|
|
8
|
+
</properties>
|
|
9
|
+
</project>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cryptography>=48
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
package demo.sealer;
|
|
2
|
+
|
|
3
|
+
import java.security.GeneralSecurityException;
|
|
4
|
+
import java.security.KeyPair;
|
|
5
|
+
import java.security.KeyPairGenerator;
|
|
6
|
+
import java.security.PrivateKey;
|
|
7
|
+
import java.security.PublicKey;
|
|
8
|
+
import java.security.SecureRandom;
|
|
9
|
+
import java.security.Signature;
|
|
10
|
+
import javax.crypto.Cipher;
|
|
11
|
+
import javax.crypto.KEM;
|
|
12
|
+
import javax.crypto.SecretKey;
|
|
13
|
+
import javax.crypto.spec.GCMParameterSpec;
|
|
14
|
+
|
|
15
|
+
/** Wraps a data key for a recipient and signs the sealed record. */
|
|
16
|
+
public final class Sealer {
|
|
17
|
+
private static final String KEM_KEYS = "ML-KEM-768";
|
|
18
|
+
private static final String SIGNING_KEYS = "ML-DSA-65";
|
|
19
|
+
private final SecureRandom random = new SecureRandom();
|
|
20
|
+
|
|
21
|
+
public KeyPair recipientKeys() throws GeneralSecurityException {
|
|
22
|
+
return KeyPairGenerator.getInstance(KEM_KEYS).generateKeyPair();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public KeyPair signingKeys() throws GeneralSecurityException {
|
|
26
|
+
return KeyPairGenerator.getInstance(SIGNING_KEYS).generateKeyPair();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public Sealed seal(PublicKey recipient, byte[] dataKey) throws GeneralSecurityException {
|
|
30
|
+
KEM.Encapsulated enc = KEM.getInstance("ML-KEM").newEncapsulator(recipient).encapsulate(0, 32, "AES");
|
|
31
|
+
byte[] nonce = new byte[12];
|
|
32
|
+
random.nextBytes(nonce);
|
|
33
|
+
Cipher c = Cipher.getInstance("AES/GCM/NoPadding");
|
|
34
|
+
c.init(Cipher.ENCRYPT_MODE, enc.key(), new GCMParameterSpec(128, nonce));
|
|
35
|
+
return new Sealed(enc.encapsulation(), nonce, c.doFinal(dataKey));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public byte[] open(PrivateKey recipient, Sealed sealed) throws GeneralSecurityException {
|
|
39
|
+
SecretKey shared = KEM.getInstance("ML-KEM").newDecapsulator(recipient).decapsulate(sealed.capsule(), 0, 32, "AES");
|
|
40
|
+
Cipher c = Cipher.getInstance("AES/GCM/NoPadding");
|
|
41
|
+
c.init(Cipher.DECRYPT_MODE, shared, new GCMParameterSpec(128, sealed.nonce()));
|
|
42
|
+
return c.doFinal(sealed.sealedKey());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public byte[] sign(PrivateKey key, byte[] message) throws GeneralSecurityException {
|
|
46
|
+
Signature s = Signature.getInstance(SIGNING_KEYS);
|
|
47
|
+
s.initSign(key);
|
|
48
|
+
s.update(message);
|
|
49
|
+
return s.sign();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public boolean verify(PublicKey key, byte[] message, byte[] signature) throws GeneralSecurityException {
|
|
53
|
+
Signature s = Signature.getInstance(SIGNING_KEYS);
|
|
54
|
+
s.initVerify(key);
|
|
55
|
+
s.update(message);
|
|
56
|
+
return s.verify(signature);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** ML-KEM ciphertext (capsule), AES-GCM nonce and the sealed data key. */
|
|
60
|
+
public record Sealed(byte[] capsule, byte[] nonce, byte[] sealedKey) {}
|
|
61
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Signs a release manifest and wraps its data key for the backup host."""
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from cryptography.exceptions import InvalidSignature
|
|
6
|
+
from cryptography.hazmat.primitives.asymmetric import mldsa, mlkem
|
|
7
|
+
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
|
|
8
|
+
|
|
9
|
+
CAPSULE = 1088 # ML-KEM-768 ciphertext bytes
|
|
10
|
+
NONCE = 12
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def new_keys():
|
|
14
|
+
signing = mldsa.MLDSA65PrivateKey.generate()
|
|
15
|
+
backup = mlkem.MLKEM768PrivateKey.generate()
|
|
16
|
+
return signing, backup
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def sign(signing, manifest):
|
|
20
|
+
return signing.sign(manifest)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def verify(public, manifest, signature):
|
|
24
|
+
try:
|
|
25
|
+
public.verify(signature, manifest)
|
|
26
|
+
return True
|
|
27
|
+
except InvalidSignature:
|
|
28
|
+
return False
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def wrap_key(backup_public, data_key):
|
|
32
|
+
shared, capsule = backup_public.encapsulate()
|
|
33
|
+
nonce = os.urandom(NONCE)
|
|
34
|
+
return capsule + nonce + AESGCM(shared).encrypt(nonce, data_key, None)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def unwrap_key(backup, blob):
|
|
38
|
+
capsule, nonce, body = blob[:CAPSULE], blob[CAPSULE:CAPSULE + NONCE], blob[CAPSULE + NONCE:]
|
|
39
|
+
shared = backup.decapsulate(capsule)
|
|
40
|
+
return AESGCM(shared).decrypt(nonce, body, None)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if __name__ == "__main__":
|
|
44
|
+
manifest = sys.stdin.buffer.read() if not sys.stdin.isatty() else b"release 1.0\n"
|
|
45
|
+
signing, backup = new_keys()
|
|
46
|
+
sig = sign(signing, manifest)
|
|
47
|
+
data_key = os.urandom(32)
|
|
48
|
+
blob = wrap_key(backup.public_key(), data_key)
|
|
49
|
+
print("signature ok:", verify(signing.public_key(), manifest, sig), "key ok:", unwrap_key(backup, blob) == data_key)
|