p256check 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.
- p256check-0.2.0/LICENSE +21 -0
- p256check-0.2.0/PKG-INFO +176 -0
- p256check-0.2.0/README.md +156 -0
- p256check-0.2.0/p256check/__init__.py +2 -0
- p256check-0.2.0/p256check/__main__.py +174 -0
- p256check-0.2.0/p256check/anchors.py +353 -0
- p256check-0.2.0/p256check/artifacts.py +329 -0
- p256check-0.2.0/p256check/binary.py +428 -0
- p256check-0.2.0/p256check/catalog.py +459 -0
- p256check-0.2.0/p256check/cbom.py +95 -0
- p256check-0.2.0/p256check/data/chrome_root_store.json +929 -0
- p256check-0.2.0/p256check/data/microsoft_root_store.json +1369 -0
- p256check-0.2.0/p256check/deps.py +240 -0
- p256check-0.2.0/p256check/lexer.py +74 -0
- p256check-0.2.0/p256check/mcp.py +186 -0
- p256check-0.2.0/p256check/model.py +77 -0
- p256check-0.2.0/p256check/p256.py +601 -0
- p256check-0.2.0/p256check/profiles.py +145 -0
- p256check-0.2.0/p256check/report.py +197 -0
- p256check-0.2.0/p256check/scan.py +131 -0
- p256check-0.2.0/p256check/source.py +855 -0
- p256check-0.2.0/p256check/tls.py +203 -0
- p256check-0.2.0/p256check/web.py +126 -0
- p256check-0.2.0/p256check.egg-info/PKG-INFO +176 -0
- p256check-0.2.0/p256check.egg-info/SOURCES.txt +32 -0
- p256check-0.2.0/p256check.egg-info/dependency_links.txt +1 -0
- p256check-0.2.0/p256check.egg-info/entry_points.txt +2 -0
- p256check-0.2.0/p256check.egg-info/top_level.txt +1 -0
- p256check-0.2.0/pyproject.toml +35 -0
- p256check-0.2.0/setup.cfg +4 -0
- p256check-0.2.0/tests/test_anchors.py +446 -0
- p256check-0.2.0/tests/test_p256.py +363 -0
- p256check-0.2.0/tests/test_scan.py +314 -0
- p256check-0.2.0/tests/test_top.py +62 -0
p256check-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MFaiqKhan
|
|
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.
|
p256check-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: p256check
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Will Chrome, Edge or Windows stop trusting your site in 2027? P-256 CA chain check, post-quantum readiness scanner (CBOM) and MCP server. No dependencies.
|
|
5
|
+
Author: Muhammad Faiq Khan
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://mfaiqkhan.github.io/p256check/
|
|
8
|
+
Project-URL: Source, https://github.com/MFaiqKhan/p256check
|
|
9
|
+
Project-URL: Issues, https://github.com/MFaiqKhan/p256check/issues
|
|
10
|
+
Keywords: post-quantum,pqc,ml-kem,cbom,tls,certificates,chrome,p-256,mcp,cryptography
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: System Administrators
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Security :: Cryptography
|
|
16
|
+
Requires-Python: >=3.13
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# p256check
|
|
22
|
+
|
|
23
|
+
[](https://mfaiqkhan.github.io/p256check/)
|
|
24
|
+
|
|
25
|
+
**Check your site and see the full daily scoreboard: https://mfaiqkhan.github.io/p256check/** (the card above updates every day).
|
|
26
|
+
|
|
27
|
+
**Will Chrome block your site on 15 March 2027?** From that date Chrome blocks certificate chains in which
|
|
28
|
+
any CA certificate has an ECDSA P-256 key ([Chrome Root Program, 3 Dec 2026](https://groups.google.com/a/ccadb.org/g/public/c/E4M_IG6VT_o)).
|
|
29
|
+
Microsoft follows: Edge applies the same rule on the same day, and Windows stops trusting P-256 *roots* on
|
|
30
|
+
23 February 2027 ([Microsoft Trusted Root Program, 4 Dec 2026](https://github.com/TrustedRootProgram/Program-Requirements/blob/main/Announcements.md)).
|
|
31
|
+
p256check builds the path from your site to a Chrome root and to a Microsoft root, reads every CA key on it
|
|
32
|
+
(root included), and tells you for all three. The same tool inventories the cryptography in code, binaries and live servers for the move to
|
|
33
|
+
post-quantum algorithms (ML-KEM, ML-DSA, SLH-DSA), with a CycloneDX 1.6 CBOM.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
uvx p256check example.com # Chrome, Edge and Windows P-256 rules + ML-KEM key exchange
|
|
37
|
+
uvx p256check scan --domain example.com --ssh example.com . # everything: TLS, JWKS, DNSSEC, SSH, this repo
|
|
38
|
+
claude mcp add p256check -- uvx p256check mcp # let a coding agent check and draft the fixes
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
No dependencies: Python 3.13+, standard library only. Live scoreboard of ~100 major sites and a daily survey of
|
|
42
|
+
the Tranco top 10,000: `docs/` (GitHub Pages).
|
|
43
|
+
|
|
44
|
+
## The 15 March check
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
$ p256check bitbucket.org
|
|
48
|
+
bitbucket.org:443 BLOCKED FROM 15 MARCH 2027
|
|
49
|
+
Blocked in Chrome from 15 March 2027: P-256 CA key in the chain, and this certificate is valid until 2027-05-26
|
|
50
|
+
chain *.bitbucket.org [ECDSA P-256, expires 2027-05-26]
|
|
51
|
+
<- Amazon ECDSA 256 S17 [ECDSA P-256] <- P-256 CA key
|
|
52
|
+
<- Amazon Root CA 3 [ECDSA P-256, Chrome root] <- P-256 CA key; Chrome stops trusting its new certificates after 2027-09-14
|
|
53
|
+
Edge: blocked from 15 March 2027: P-256 CA key in the chain (Amazon ECDSA 256 S17, Amazon Root CA 3) and the certificate is valid until 2027-05-26
|
|
54
|
+
Windows: blocked from 23 February 2027: P-256 root (Amazon Root CA 3) and the certificate is valid until 2027-05-26
|
|
55
|
+
site key: ECDSA P-256 (not covered by the 15 March rule; a 256-bit curve the 2 Dec 2026 NSA advisory flags)
|
|
56
|
+
key exchange: X25519MLKEM768 (post-quantum hybrid)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Status | Meaning |
|
|
60
|
+
|---|---|
|
|
61
|
+
| `blocked` | A CA key on the path is P-256 and the certificate is valid past the cutoff |
|
|
62
|
+
| `renewal-at-risk` | A CA key on the path is P-256; the certificate expires first, so the next one must come from a CA without a P-256 key (the common case: Google says over 99% of affected certificates expire first) |
|
|
63
|
+
| `alt-path` | The served chain has a P-256 CA, but another path to a Chrome root avoids it |
|
|
64
|
+
| `ok` | No CA key on the path is P-256 (a P-256 *site* key is reported, but the rule does not cover it) |
|
|
65
|
+
| `no-chrome-root` | No path to a Chrome root: the rule does not apply |
|
|
66
|
+
|
|
67
|
+
Edge and Windows use the same statuses against Microsoft's root store (`no-root` when there is none). Windows
|
|
68
|
+
counts only the root's key and uses 23 February 2027. Microsoft's server-authentication roots come from its
|
|
69
|
+
CCADB report and Microsoft's own download point (`tools/update_ms_root_store.py`; 227 roots, 5 of them P-256).
|
|
70
|
+
|
|
71
|
+
How: the certificates the server sends, missing intermediates from the AIA URL, and the trust anchors of the
|
|
72
|
+
Chrome Root Store bundled from Chromium's source (`tools/update_root_store.py`; version 45 has 95 roots, 3 of
|
|
73
|
+
them P-256, as Google's announcement says). Chrome's "no new certificates after" dates for roots are reported
|
|
74
|
+
as notes. Exit code 1 when a site is blocked or at risk (for CI), 2 on a connection error.
|
|
75
|
+
|
|
76
|
+
Checked against OpenSSL's own path building and signature verification on the same roots, 106 major sites:
|
|
77
|
+
verdict, CA names, CA keys and site key agree on 106 of 106 (`tests/eval_chrome_p256.py`,
|
|
78
|
+
`tests/real/RESULTS.md`).
|
|
79
|
+
|
|
80
|
+
Limits: one connection from one place (a CDN can serve other chains elsewhere); a server with both RSA and
|
|
81
|
+
ECDSA certificates shows the one a modern client gets; signatures are not verified by p256check itself
|
|
82
|
+
(certificates are linked by name and key identifier).
|
|
83
|
+
|
|
84
|
+
### Coding agents
|
|
85
|
+
|
|
86
|
+
- **MCP server:** `p256check mcp` (stdio). Tools: `chrome_p256_check`, `scan_code`, `probe_endpoints`.
|
|
87
|
+
- **Agent Skill:** `skills/p256check/SKILL.md`. It covers the rule, how to read the results, and fixes per CA, based on chains measured on real sites. Copy the folder to `~/.claude/skills/` (Claude Code), or to the skills folder of any agent that reads `SKILL.md`.
|
|
88
|
+
|
|
89
|
+
### Scoreboard and live checker
|
|
90
|
+
|
|
91
|
+
- `docs/` is the public page.
|
|
92
|
+
- `scoreboard/scan.py` refreshes `docs/data/` from `scoreboard/domains.txt`.
|
|
93
|
+
- `scoreboard/top.py` surveys a pinned Tranco top-10,000 list (`scoreboard/top.txt`; `top.py pin` re-pins). It keeps one status letter per domain per day in `docs/data/top_history.json`, so changes come from certificates, not from the ranking.
|
|
94
|
+
- `.github/workflows/scoreboard.yml` runs both every day and refreshes both root stores on Mondays.
|
|
95
|
+
- The live checker is `api/check.py` (Vercel) or `p256check serve` (anywhere). It only checks public addresses, only on port 443, with a rate limit and a 10-minute cache. Set its URL in `docs/config.js`.
|
|
96
|
+
|
|
97
|
+
## The full inventory
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
p256check scan path/to/project # folder, file, archive (.jar .whl .zip .tgz) or binary
|
|
101
|
+
p256check scan --domain example.com # TLS chain + OpenID/JWKS keys + DNSSEC keys of a domain
|
|
102
|
+
p256check scan --ssh host.example.com # SSH key exchange, host key algorithms and host keys
|
|
103
|
+
p256check scan --jwks https://login.example.com --dnssec example.com --tls api.example.com:8443
|
|
104
|
+
p256check scan . --profile pqc # rank on the quantum-only timeline instead
|
|
105
|
+
p256check scan . --fail-on suspect-now # CI: exit 1 on 256-bit curves or anything worse
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Output goes to `p256check-out/cbom.json` and `p256check-out/report.html`. From a checkout, use `python -m p256check`.
|
|
109
|
+
|
|
110
|
+
## What it looks at
|
|
111
|
+
|
|
112
|
+
| Layer | How | Finds |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| Dependencies | package-lock, yarn, pnpm, requirements, poetry, uv, Pipfile, go.mod, Cargo, Maven, Gradle, Gemfile, Composer, NuGet | crypto libraries, direct or transitive |
|
|
115
|
+
| Source | language rules for Python, JS/TS, Java/Kotlin, Go, C/C++ (OpenSSL 3, liboqs, PQClean), Rust, C#; comments are blanked first; constants are followed (`ALG = "RSA"` … `getInstance(ALG)`); import aliases undone | the algorithm, key size or curve, and whether it is used for key exchange or signatures |
|
|
116
|
+
| Hand-written crypto | curve primes, orders and generators as integer literals; ML-KEM / ML-DSA NTT root tables as number lists | crypto code written without a library |
|
|
117
|
+
| Keys and certificates | built-in DER parser: X.509, PKCS#8, PKCS#1, SEC1, OpenSSH private keys, SSH public keys | key type, RSA modulus size, curve, signature algorithm, certificates that are still valid after 2030 |
|
|
118
|
+
| Configs | sshd/ssh config, nginx, Apache, OpenSSL, HAProxy, YAML/properties/TOML keys | KEX/host-key algorithms, TLS groups, cipher suites, JWT algorithms |
|
|
119
|
+
| Binaries | constant tables computed from their definitions (ML-KEM and ML-DSA NTT roots in plain and Montgomery form, AES, SHA-1/2/3, MD5, P-256/P-384/P-521/secp256k1, Ed25519), symbols, Go package paths, Rust crate paths, Java class constant pools; archives are opened | crypto inside compiled code and vendor software |
|
|
120
|
+
| TLS (`--tls`) | a TLS 1.3 ClientHello with an empty key_share, so a server that supports a group must name it in a HelloRetryRequest; then one normal handshake for the certificate chain | which groups a server accepts (X25519MLKEM768, SecP256r1MLKEM768, ML-KEM, classical); key and size of the leaf, every intermediate and a sent root. A signature row appears only when its signer is not in the chain |
|
|
121
|
+
| SSH (`--ssh`) | the server's KEXINIT, which is sent in the clear before any key exchange; `ssh-keyscan` (if installed) for the host keys themselves | offered key exchange (mlkem768x25519-sha256, sntrup761, curve25519, ecdh, DH group sizes), host key algorithms (incl. `ssh-mldsa44-ed25519`), weak ciphers, real host key sizes and curves; classical key exchange next to a PQ hybrid is marked as a fallback |
|
|
122
|
+
| JWT signing keys (`--jwks`) | `/.well-known/openid-configuration` → `jwks_uri`, or a JWKS URL directly | each key: RSA size from the modulus, EC/OKP curve, ML-DSA (`AKP`), signing or encryption use; advertised algorithms only when no key of that family is published |
|
|
123
|
+
| DNSSEC (`--dnssec`) | a DNSKEY query with the DO bit to the system resolver (or `--resolver`), TCP when truncated | algorithm and RSA size of the key-signing and zone-signing keys; SHA-1 algorithms (5, 7) |
|
|
124
|
+
|
|
125
|
+
`--domain D` runs `--tls D --jwks D --dnssec D`. SSH stays a separate flag, so the tool never connects to a domain's SSH port unasked. All probes read public data only.
|
|
126
|
+
|
|
127
|
+
## Ranking
|
|
128
|
+
|
|
129
|
+
The threat reading changed on 2 Dec 2026 and is disputed, so the ranking is a switch (`--profile`).
|
|
130
|
+
|
|
131
|
+
**`dec2026` (default).** Follows the NSA advisory "Immediate Actions to Push Toward Post-Quantum" (2 Dec 2026). Its inventory step flags every elliptic curve except P-384 and P-521, and EdDSA, and it asks for RSA-3072 or P-384 roots. Filippo Valsorda reads it as 256-bit curves (P-256, X25519, Ed25519) being likely weakened, possibly without a quantum computer. The NSA has not confirmed that, and Rob Joyce says elliptic curves are "still solid". So these curves get their own level, `suspect-now`, and never `fix-now`.
|
|
132
|
+
|
|
133
|
+
| Priority | dec2026 | pqc |
|
|
134
|
+
|---|---|---|
|
|
135
|
+
| fix-now | broken in public: MD5, SHA-1, DES, 3DES, RC4, DSA, RSA/DH under 2048 | MD5, SHA-1, DES, 3DES, RC4 |
|
|
136
|
+
| suspect-now | P-256, P-224, P-192, secp256k1, brainpoolP256r1, X25519, Ed25519 | (not used) |
|
|
137
|
+
| high | key exchange with RSA-3072+, P-384, P-521, DH; RSA-2048 anywhere; keys whose size or curve is not visible | quantum-vulnerable key exchange (recorded traffic can be decrypted later) |
|
|
138
|
+
| medium | signatures with RSA-3072+, P-384, P-521, Ed448 (stopgaps until ML-DSA) | quantum-vulnerable signatures (NIST IR 8547: deprecated after 2030, disallowed after 2035) |
|
|
139
|
+
| ready | ML-KEM, ML-DSA, SLH-DSA, hybrids (X25519MLKEM768, mlkem768x25519-sha256, ssh-mldsa44-ed25519) | same |
|
|
140
|
+
| info | AES, SHA-2/3, crypto libraries (capabilities, not choices), `usedforsecurity=False` | same |
|
|
141
|
+
|
|
142
|
+
Every finding carries a one-line reason (`why` in JSON, italic in the HTML). Under `dec2026` the advice also warns against the migration many guides still suggest: RSA → P-256/ES256/Ed25519 moves a key into the suspect set.
|
|
143
|
+
|
|
144
|
+
Findings in tests, vendored folders and crypto libraries are listed apart and do not affect `--fail-on`.
|
|
145
|
+
|
|
146
|
+
## How well it works (measured)
|
|
147
|
+
|
|
148
|
+
- **Independent corpus** (`tests/heldout/`): 66 files in 8 languages and config formats, with 209 labeled uses and 81 traps (words like RSA in comments, `PRESSURE`, `md5` in URLs, names in disable lists). A separate author wrote it without seeing the scanner. The split was fixed before the first run. On the held-out half after tuning: **84% of uses found on the exact line, 89% within 2 lines, 0 of 52 traps hit**. On the tuning half: 98% / 100%. Details: `tests/heldout/RESULTS.md`.
|
|
149
|
+
- **Real binaries.** The ML-KEM NTT table was found in four independent implementations: OpenSSL 3.6 libcrypto, OpenSSH 10.5, libsodium and NSS freebl. The ML-DSA table was found in libcrypto. 2 MB of random bytes produce no findings.
|
|
150
|
+
- **Real keys.** Keys and certificates made by OpenSSL 3.6 and ssh-keygen were read correctly, including an ML-DSA-65 certificate and an ML-KEM-768 key.
|
|
151
|
+
- **TLS probe.** It tells a hybrid-PQ OpenSSL server (preferred X25519MLKEM768) from a classical one.
|
|
152
|
+
- **CBOM.** Output validates against the official CycloneDX 1.6 JSON schema (0 errors).
|
|
153
|
+
- **A large real tree.** Hermes Agent v0.23.1 source (23,435 files, 440 MB) took 114 s on one core. It found real `hashlib.md5`/`sha1` uses and RS256/ES256 JWT checks in auth plugins. It also produced one false positive, "falcon" in a list of animal names read as FN-DSA, which is now fixed: bare words like falcon, kyber and LMS need crypto context.
|
|
154
|
+
- **Probes, offline.** A local `openssl s_server` with a P-384 root, an RSA-2048 intermediate and a P-256 leaf: chain read as leaf > intermediate > root, each ranked, no duplicate signature rows. A local unprivileged `sshd` (OpenSSH 10.5) with RSA-3072, P-384 and Ed25519 host keys: all three read with sizes. A fake SSH server offering `ssh-mldsa44-ed25519`, `diffie-hellman-group1-sha1` and `3des-cbc`. A local OpenID provider with RSA-2048/3072, P-256, P-384, Ed25519 and ML-DSA-65 keys. A fake DNS server, over UDP and with truncation to TCP.
|
|
155
|
+
- **Probes, real endpoints (3 Dec 2026).** DNSSEC: cloudflare.com, isc.org, nic.cz and example.com sign with P-256 (algorithm 13, suspect-now); the root zone and `.se` with RSA-2048; nasa.gov's zone-signing keys are RSA-1024 (fix-now; sizes checked against `dig`); google.com is unsigned. OIDC: Google and Microsoft sign ID tokens with RSA-2048 keys. github.com SSH offers mlkem768x25519-sha256 with RSA-3072, P-256 and Ed25519 host keys. cloudflare.com TLS prefers X25519MLKEM768 and still accepts draft Kyber, X25519, P-256 and P-384.
|
|
156
|
+
- **Tests.** `python -m unittest discover -s tests`: 39 tests, offline (24 scanner, 15 profile and probe). They generate their own keys and servers.
|
|
157
|
+
|
|
158
|
+
## Limits
|
|
159
|
+
|
|
160
|
+
- Pattern-based, not dataflow. An algorithm chosen at runtime from a config outside the tree, or passed through several functions, can be missed. In a binary, "supports" cannot be told apart from "uses".
|
|
161
|
+
- Draft Kyber and ML-KEM share NTT constants, so in binaries the constants alone cannot tell them apart. Names and OIDs can.
|
|
162
|
+
- In a statically linked binary that embeds OpenSSL (Node, for example), everything OpenSSL supports shows up. It is marked as library capability.
|
|
163
|
+
- Not compared head to head with PQCA CBOMkit or the commercial scanners yet.
|
|
164
|
+
- Probes: SSH host key sizes need `ssh-keyscan`; without it only the offered algorithm names are listed. The TLS chain needs Python 3.13+ (`get_unverified_chain`); older versions read the leaf only. DNSSEC trusts the resolver's answer (it does not validate signatures). Identical keys on one endpoint are shown once (two RSA-2048 JWKS keys are one row; the probe summary lists them all).
|
|
165
|
+
- The `dec2026` profile encodes one reading of a disputed advisory. Use `--profile pqc` for the earlier quantum-only view.
|
|
166
|
+
|
|
167
|
+
## Accuracy on real projects and servers (2026-12-04/05)
|
|
168
|
+
- Precision on 11 real open-source projects (two independent samples of 110 random findings, labelled blind):
|
|
169
|
+
0.95 and 0.94; key sizes/curves right in every scored case.
|
|
170
|
+
- Recall on real code (42 random crypto files, 600 uses listed blind): the scanner lists the right algorithm for a
|
|
171
|
+
file in 66% of cases and finds 36% of individual uses. It misses libraries and type-level APIs it has no rules for
|
|
172
|
+
(Java/Groovy JWK code, libtomcrypt, aws-lc-rs, age's hybrid API). The synthetic corpus (84-89%) overstates recall.
|
|
173
|
+
- Server checks against openssl, ssh, ssh-keyscan, curl/jq and dig on 42 public endpoints: 338/339 facts agree
|
|
174
|
+
(the one difference is Microsoft serving two key sets).
|
|
175
|
+
- Commands: `python tests/eval_real.py fetch|scan|sample|score|recall-score --run N`,
|
|
176
|
+
`python tests/eval_probes.py run && python tests/eval_probes.py score`. Details and limits: `tests/real/RESULTS.md`.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# p256check
|
|
2
|
+
|
|
3
|
+
[](https://mfaiqkhan.github.io/p256check/)
|
|
4
|
+
|
|
5
|
+
**Check your site and see the full daily scoreboard: https://mfaiqkhan.github.io/p256check/** (the card above updates every day).
|
|
6
|
+
|
|
7
|
+
**Will Chrome block your site on 15 March 2027?** From that date Chrome blocks certificate chains in which
|
|
8
|
+
any CA certificate has an ECDSA P-256 key ([Chrome Root Program, 3 Dec 2026](https://groups.google.com/a/ccadb.org/g/public/c/E4M_IG6VT_o)).
|
|
9
|
+
Microsoft follows: Edge applies the same rule on the same day, and Windows stops trusting P-256 *roots* on
|
|
10
|
+
23 February 2027 ([Microsoft Trusted Root Program, 4 Dec 2026](https://github.com/TrustedRootProgram/Program-Requirements/blob/main/Announcements.md)).
|
|
11
|
+
p256check builds the path from your site to a Chrome root and to a Microsoft root, reads every CA key on it
|
|
12
|
+
(root included), and tells you for all three. The same tool inventories the cryptography in code, binaries and live servers for the move to
|
|
13
|
+
post-quantum algorithms (ML-KEM, ML-DSA, SLH-DSA), with a CycloneDX 1.6 CBOM.
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
uvx p256check example.com # Chrome, Edge and Windows P-256 rules + ML-KEM key exchange
|
|
17
|
+
uvx p256check scan --domain example.com --ssh example.com . # everything: TLS, JWKS, DNSSEC, SSH, this repo
|
|
18
|
+
claude mcp add p256check -- uvx p256check mcp # let a coding agent check and draft the fixes
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
No dependencies: Python 3.13+, standard library only. Live scoreboard of ~100 major sites and a daily survey of
|
|
22
|
+
the Tranco top 10,000: `docs/` (GitHub Pages).
|
|
23
|
+
|
|
24
|
+
## The 15 March check
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
$ p256check bitbucket.org
|
|
28
|
+
bitbucket.org:443 BLOCKED FROM 15 MARCH 2027
|
|
29
|
+
Blocked in Chrome from 15 March 2027: P-256 CA key in the chain, and this certificate is valid until 2027-05-26
|
|
30
|
+
chain *.bitbucket.org [ECDSA P-256, expires 2027-05-26]
|
|
31
|
+
<- Amazon ECDSA 256 S17 [ECDSA P-256] <- P-256 CA key
|
|
32
|
+
<- Amazon Root CA 3 [ECDSA P-256, Chrome root] <- P-256 CA key; Chrome stops trusting its new certificates after 2027-09-14
|
|
33
|
+
Edge: blocked from 15 March 2027: P-256 CA key in the chain (Amazon ECDSA 256 S17, Amazon Root CA 3) and the certificate is valid until 2027-05-26
|
|
34
|
+
Windows: blocked from 23 February 2027: P-256 root (Amazon Root CA 3) and the certificate is valid until 2027-05-26
|
|
35
|
+
site key: ECDSA P-256 (not covered by the 15 March rule; a 256-bit curve the 2 Dec 2026 NSA advisory flags)
|
|
36
|
+
key exchange: X25519MLKEM768 (post-quantum hybrid)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
| Status | Meaning |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `blocked` | A CA key on the path is P-256 and the certificate is valid past the cutoff |
|
|
42
|
+
| `renewal-at-risk` | A CA key on the path is P-256; the certificate expires first, so the next one must come from a CA without a P-256 key (the common case: Google says over 99% of affected certificates expire first) |
|
|
43
|
+
| `alt-path` | The served chain has a P-256 CA, but another path to a Chrome root avoids it |
|
|
44
|
+
| `ok` | No CA key on the path is P-256 (a P-256 *site* key is reported, but the rule does not cover it) |
|
|
45
|
+
| `no-chrome-root` | No path to a Chrome root: the rule does not apply |
|
|
46
|
+
|
|
47
|
+
Edge and Windows use the same statuses against Microsoft's root store (`no-root` when there is none). Windows
|
|
48
|
+
counts only the root's key and uses 23 February 2027. Microsoft's server-authentication roots come from its
|
|
49
|
+
CCADB report and Microsoft's own download point (`tools/update_ms_root_store.py`; 227 roots, 5 of them P-256).
|
|
50
|
+
|
|
51
|
+
How: the certificates the server sends, missing intermediates from the AIA URL, and the trust anchors of the
|
|
52
|
+
Chrome Root Store bundled from Chromium's source (`tools/update_root_store.py`; version 45 has 95 roots, 3 of
|
|
53
|
+
them P-256, as Google's announcement says). Chrome's "no new certificates after" dates for roots are reported
|
|
54
|
+
as notes. Exit code 1 when a site is blocked or at risk (for CI), 2 on a connection error.
|
|
55
|
+
|
|
56
|
+
Checked against OpenSSL's own path building and signature verification on the same roots, 106 major sites:
|
|
57
|
+
verdict, CA names, CA keys and site key agree on 106 of 106 (`tests/eval_chrome_p256.py`,
|
|
58
|
+
`tests/real/RESULTS.md`).
|
|
59
|
+
|
|
60
|
+
Limits: one connection from one place (a CDN can serve other chains elsewhere); a server with both RSA and
|
|
61
|
+
ECDSA certificates shows the one a modern client gets; signatures are not verified by p256check itself
|
|
62
|
+
(certificates are linked by name and key identifier).
|
|
63
|
+
|
|
64
|
+
### Coding agents
|
|
65
|
+
|
|
66
|
+
- **MCP server:** `p256check mcp` (stdio). Tools: `chrome_p256_check`, `scan_code`, `probe_endpoints`.
|
|
67
|
+
- **Agent Skill:** `skills/p256check/SKILL.md`. It covers the rule, how to read the results, and fixes per CA, based on chains measured on real sites. Copy the folder to `~/.claude/skills/` (Claude Code), or to the skills folder of any agent that reads `SKILL.md`.
|
|
68
|
+
|
|
69
|
+
### Scoreboard and live checker
|
|
70
|
+
|
|
71
|
+
- `docs/` is the public page.
|
|
72
|
+
- `scoreboard/scan.py` refreshes `docs/data/` from `scoreboard/domains.txt`.
|
|
73
|
+
- `scoreboard/top.py` surveys a pinned Tranco top-10,000 list (`scoreboard/top.txt`; `top.py pin` re-pins). It keeps one status letter per domain per day in `docs/data/top_history.json`, so changes come from certificates, not from the ranking.
|
|
74
|
+
- `.github/workflows/scoreboard.yml` runs both every day and refreshes both root stores on Mondays.
|
|
75
|
+
- The live checker is `api/check.py` (Vercel) or `p256check serve` (anywhere). It only checks public addresses, only on port 443, with a rate limit and a 10-minute cache. Set its URL in `docs/config.js`.
|
|
76
|
+
|
|
77
|
+
## The full inventory
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
p256check scan path/to/project # folder, file, archive (.jar .whl .zip .tgz) or binary
|
|
81
|
+
p256check scan --domain example.com # TLS chain + OpenID/JWKS keys + DNSSEC keys of a domain
|
|
82
|
+
p256check scan --ssh host.example.com # SSH key exchange, host key algorithms and host keys
|
|
83
|
+
p256check scan --jwks https://login.example.com --dnssec example.com --tls api.example.com:8443
|
|
84
|
+
p256check scan . --profile pqc # rank on the quantum-only timeline instead
|
|
85
|
+
p256check scan . --fail-on suspect-now # CI: exit 1 on 256-bit curves or anything worse
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Output goes to `p256check-out/cbom.json` and `p256check-out/report.html`. From a checkout, use `python -m p256check`.
|
|
89
|
+
|
|
90
|
+
## What it looks at
|
|
91
|
+
|
|
92
|
+
| Layer | How | Finds |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| Dependencies | package-lock, yarn, pnpm, requirements, poetry, uv, Pipfile, go.mod, Cargo, Maven, Gradle, Gemfile, Composer, NuGet | crypto libraries, direct or transitive |
|
|
95
|
+
| Source | language rules for Python, JS/TS, Java/Kotlin, Go, C/C++ (OpenSSL 3, liboqs, PQClean), Rust, C#; comments are blanked first; constants are followed (`ALG = "RSA"` … `getInstance(ALG)`); import aliases undone | the algorithm, key size or curve, and whether it is used for key exchange or signatures |
|
|
96
|
+
| Hand-written crypto | curve primes, orders and generators as integer literals; ML-KEM / ML-DSA NTT root tables as number lists | crypto code written without a library |
|
|
97
|
+
| Keys and certificates | built-in DER parser: X.509, PKCS#8, PKCS#1, SEC1, OpenSSH private keys, SSH public keys | key type, RSA modulus size, curve, signature algorithm, certificates that are still valid after 2030 |
|
|
98
|
+
| Configs | sshd/ssh config, nginx, Apache, OpenSSL, HAProxy, YAML/properties/TOML keys | KEX/host-key algorithms, TLS groups, cipher suites, JWT algorithms |
|
|
99
|
+
| Binaries | constant tables computed from their definitions (ML-KEM and ML-DSA NTT roots in plain and Montgomery form, AES, SHA-1/2/3, MD5, P-256/P-384/P-521/secp256k1, Ed25519), symbols, Go package paths, Rust crate paths, Java class constant pools; archives are opened | crypto inside compiled code and vendor software |
|
|
100
|
+
| TLS (`--tls`) | a TLS 1.3 ClientHello with an empty key_share, so a server that supports a group must name it in a HelloRetryRequest; then one normal handshake for the certificate chain | which groups a server accepts (X25519MLKEM768, SecP256r1MLKEM768, ML-KEM, classical); key and size of the leaf, every intermediate and a sent root. A signature row appears only when its signer is not in the chain |
|
|
101
|
+
| SSH (`--ssh`) | the server's KEXINIT, which is sent in the clear before any key exchange; `ssh-keyscan` (if installed) for the host keys themselves | offered key exchange (mlkem768x25519-sha256, sntrup761, curve25519, ecdh, DH group sizes), host key algorithms (incl. `ssh-mldsa44-ed25519`), weak ciphers, real host key sizes and curves; classical key exchange next to a PQ hybrid is marked as a fallback |
|
|
102
|
+
| JWT signing keys (`--jwks`) | `/.well-known/openid-configuration` → `jwks_uri`, or a JWKS URL directly | each key: RSA size from the modulus, EC/OKP curve, ML-DSA (`AKP`), signing or encryption use; advertised algorithms only when no key of that family is published |
|
|
103
|
+
| DNSSEC (`--dnssec`) | a DNSKEY query with the DO bit to the system resolver (or `--resolver`), TCP when truncated | algorithm and RSA size of the key-signing and zone-signing keys; SHA-1 algorithms (5, 7) |
|
|
104
|
+
|
|
105
|
+
`--domain D` runs `--tls D --jwks D --dnssec D`. SSH stays a separate flag, so the tool never connects to a domain's SSH port unasked. All probes read public data only.
|
|
106
|
+
|
|
107
|
+
## Ranking
|
|
108
|
+
|
|
109
|
+
The threat reading changed on 2 Dec 2026 and is disputed, so the ranking is a switch (`--profile`).
|
|
110
|
+
|
|
111
|
+
**`dec2026` (default).** Follows the NSA advisory "Immediate Actions to Push Toward Post-Quantum" (2 Dec 2026). Its inventory step flags every elliptic curve except P-384 and P-521, and EdDSA, and it asks for RSA-3072 or P-384 roots. Filippo Valsorda reads it as 256-bit curves (P-256, X25519, Ed25519) being likely weakened, possibly without a quantum computer. The NSA has not confirmed that, and Rob Joyce says elliptic curves are "still solid". So these curves get their own level, `suspect-now`, and never `fix-now`.
|
|
112
|
+
|
|
113
|
+
| Priority | dec2026 | pqc |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| fix-now | broken in public: MD5, SHA-1, DES, 3DES, RC4, DSA, RSA/DH under 2048 | MD5, SHA-1, DES, 3DES, RC4 |
|
|
116
|
+
| suspect-now | P-256, P-224, P-192, secp256k1, brainpoolP256r1, X25519, Ed25519 | (not used) |
|
|
117
|
+
| high | key exchange with RSA-3072+, P-384, P-521, DH; RSA-2048 anywhere; keys whose size or curve is not visible | quantum-vulnerable key exchange (recorded traffic can be decrypted later) |
|
|
118
|
+
| medium | signatures with RSA-3072+, P-384, P-521, Ed448 (stopgaps until ML-DSA) | quantum-vulnerable signatures (NIST IR 8547: deprecated after 2030, disallowed after 2035) |
|
|
119
|
+
| ready | ML-KEM, ML-DSA, SLH-DSA, hybrids (X25519MLKEM768, mlkem768x25519-sha256, ssh-mldsa44-ed25519) | same |
|
|
120
|
+
| info | AES, SHA-2/3, crypto libraries (capabilities, not choices), `usedforsecurity=False` | same |
|
|
121
|
+
|
|
122
|
+
Every finding carries a one-line reason (`why` in JSON, italic in the HTML). Under `dec2026` the advice also warns against the migration many guides still suggest: RSA → P-256/ES256/Ed25519 moves a key into the suspect set.
|
|
123
|
+
|
|
124
|
+
Findings in tests, vendored folders and crypto libraries are listed apart and do not affect `--fail-on`.
|
|
125
|
+
|
|
126
|
+
## How well it works (measured)
|
|
127
|
+
|
|
128
|
+
- **Independent corpus** (`tests/heldout/`): 66 files in 8 languages and config formats, with 209 labeled uses and 81 traps (words like RSA in comments, `PRESSURE`, `md5` in URLs, names in disable lists). A separate author wrote it without seeing the scanner. The split was fixed before the first run. On the held-out half after tuning: **84% of uses found on the exact line, 89% within 2 lines, 0 of 52 traps hit**. On the tuning half: 98% / 100%. Details: `tests/heldout/RESULTS.md`.
|
|
129
|
+
- **Real binaries.** The ML-KEM NTT table was found in four independent implementations: OpenSSL 3.6 libcrypto, OpenSSH 10.5, libsodium and NSS freebl. The ML-DSA table was found in libcrypto. 2 MB of random bytes produce no findings.
|
|
130
|
+
- **Real keys.** Keys and certificates made by OpenSSL 3.6 and ssh-keygen were read correctly, including an ML-DSA-65 certificate and an ML-KEM-768 key.
|
|
131
|
+
- **TLS probe.** It tells a hybrid-PQ OpenSSL server (preferred X25519MLKEM768) from a classical one.
|
|
132
|
+
- **CBOM.** Output validates against the official CycloneDX 1.6 JSON schema (0 errors).
|
|
133
|
+
- **A large real tree.** Hermes Agent v0.23.1 source (23,435 files, 440 MB) took 114 s on one core. It found real `hashlib.md5`/`sha1` uses and RS256/ES256 JWT checks in auth plugins. It also produced one false positive, "falcon" in a list of animal names read as FN-DSA, which is now fixed: bare words like falcon, kyber and LMS need crypto context.
|
|
134
|
+
- **Probes, offline.** A local `openssl s_server` with a P-384 root, an RSA-2048 intermediate and a P-256 leaf: chain read as leaf > intermediate > root, each ranked, no duplicate signature rows. A local unprivileged `sshd` (OpenSSH 10.5) with RSA-3072, P-384 and Ed25519 host keys: all three read with sizes. A fake SSH server offering `ssh-mldsa44-ed25519`, `diffie-hellman-group1-sha1` and `3des-cbc`. A local OpenID provider with RSA-2048/3072, P-256, P-384, Ed25519 and ML-DSA-65 keys. A fake DNS server, over UDP and with truncation to TCP.
|
|
135
|
+
- **Probes, real endpoints (3 Dec 2026).** DNSSEC: cloudflare.com, isc.org, nic.cz and example.com sign with P-256 (algorithm 13, suspect-now); the root zone and `.se` with RSA-2048; nasa.gov's zone-signing keys are RSA-1024 (fix-now; sizes checked against `dig`); google.com is unsigned. OIDC: Google and Microsoft sign ID tokens with RSA-2048 keys. github.com SSH offers mlkem768x25519-sha256 with RSA-3072, P-256 and Ed25519 host keys. cloudflare.com TLS prefers X25519MLKEM768 and still accepts draft Kyber, X25519, P-256 and P-384.
|
|
136
|
+
- **Tests.** `python -m unittest discover -s tests`: 39 tests, offline (24 scanner, 15 profile and probe). They generate their own keys and servers.
|
|
137
|
+
|
|
138
|
+
## Limits
|
|
139
|
+
|
|
140
|
+
- Pattern-based, not dataflow. An algorithm chosen at runtime from a config outside the tree, or passed through several functions, can be missed. In a binary, "supports" cannot be told apart from "uses".
|
|
141
|
+
- Draft Kyber and ML-KEM share NTT constants, so in binaries the constants alone cannot tell them apart. Names and OIDs can.
|
|
142
|
+
- In a statically linked binary that embeds OpenSSL (Node, for example), everything OpenSSL supports shows up. It is marked as library capability.
|
|
143
|
+
- Not compared head to head with PQCA CBOMkit or the commercial scanners yet.
|
|
144
|
+
- Probes: SSH host key sizes need `ssh-keyscan`; without it only the offered algorithm names are listed. The TLS chain needs Python 3.13+ (`get_unverified_chain`); older versions read the leaf only. DNSSEC trusts the resolver's answer (it does not validate signatures). Identical keys on one endpoint are shown once (two RSA-2048 JWKS keys are one row; the probe summary lists them all).
|
|
145
|
+
- The `dec2026` profile encodes one reading of a disputed advisory. Use `--profile pqc` for the earlier quantum-only view.
|
|
146
|
+
|
|
147
|
+
## Accuracy on real projects and servers (2026-12-04/05)
|
|
148
|
+
- Precision on 11 real open-source projects (two independent samples of 110 random findings, labelled blind):
|
|
149
|
+
0.95 and 0.94; key sizes/curves right in every scored case.
|
|
150
|
+
- Recall on real code (42 random crypto files, 600 uses listed blind): the scanner lists the right algorithm for a
|
|
151
|
+
file in 66% of cases and finds 36% of individual uses. It misses libraries and type-level APIs it has no rules for
|
|
152
|
+
(Java/Groovy JWK code, libtomcrypt, aws-lc-rs, age's hybrid API). The synthetic corpus (84-89%) overstates recall.
|
|
153
|
+
- Server checks against openssl, ssh, ssh-keyscan, curl/jq and dig on 42 public endpoints: 338/339 facts agree
|
|
154
|
+
(the one difference is Microsoft serving two key sets).
|
|
155
|
+
- Commands: `python tests/eval_real.py fetch|scan|sample|score|recall-score --run N`,
|
|
156
|
+
`python tests/eval_probes.py run && python tests/eval_probes.py score`. Details and limits: `tests/real/RESULTS.md`.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"""p256check: will Chrome, Edge or Windows stop trusting your site's certificate chain in 2027?
|
|
2
|
+
|
|
3
|
+
p256check HOST [HOST ...] the P-256 CA rules (Chrome and Edge 15 March 2027, Windows 23 Feb 2027)
|
|
4
|
+
plus post-quantum (ML-KEM) key exchange; same as `p256check check`
|
|
5
|
+
p256check scan [PATH ...] [--tls host[:port]] [--ssh host[:port]] [--jwks URL|domain]
|
|
6
|
+
[--dnssec zone] [--domain example.com] [--profile dec2026|pqc] [-o DIR] [--json]
|
|
7
|
+
[--fail-on LEVEL] cryptography inventory (CBOM) for the post-quantum move
|
|
8
|
+
p256check mcp MCP server on stdio for coding agents
|
|
9
|
+
p256check serve [DIR] [--port N] the scoreboard page plus the live checker API
|
|
10
|
+
"""
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import argparse
|
|
14
|
+
import json
|
|
15
|
+
import os
|
|
16
|
+
import sys
|
|
17
|
+
from datetime import datetime
|
|
18
|
+
|
|
19
|
+
from . import __version__, cbom, profiles, report
|
|
20
|
+
from .model import merge, PRIORITY_ORDER
|
|
21
|
+
from .scan import scan_path
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def check_main(argv):
|
|
25
|
+
"""p256check HOST [HOST ...]: Chrome's 15 March 2027 P-256 CA rule plus post-quantum key exchange."""
|
|
26
|
+
from . import p256
|
|
27
|
+
ap = argparse.ArgumentParser(prog="p256check", description="Will Chrome, Edge or Windows stop trusting this site in 2027? "
|
|
28
|
+
"Builds the certificate path to a Chrome root and reads every CA key on it; also "
|
|
29
|
+
"checks whether the server accepts an ML-KEM (post-quantum) key exchange.")
|
|
30
|
+
ap.add_argument("hosts", nargs="+", metavar="HOST[:PORT]")
|
|
31
|
+
ap.add_argument("--json", action="store_true", help="print results as JSON")
|
|
32
|
+
ap.add_argument("--no-pq", action="store_true", help="skip the key exchange probe")
|
|
33
|
+
ap.add_argument("--timeout", type=float, default=6.0)
|
|
34
|
+
ap.add_argument("--exit-zero", action="store_true", help="exit 0 even when a site is blocked")
|
|
35
|
+
a = ap.parse_args(argv)
|
|
36
|
+
results = []
|
|
37
|
+
for h in a.hosts:
|
|
38
|
+
try:
|
|
39
|
+
results.append(p256.check(h, a.timeout, pq=not a.no_pq))
|
|
40
|
+
except p256.CheckError as e:
|
|
41
|
+
results.append({"target": h, "error": str(e)})
|
|
42
|
+
if not a.json:
|
|
43
|
+
print(p256.render(results[-1], color=sys.stdout.isatty()) + "\n")
|
|
44
|
+
if a.json:
|
|
45
|
+
print(json.dumps(results if len(results) > 1 else results[0], indent=1))
|
|
46
|
+
else:
|
|
47
|
+
print(f"Rule: {p256.ANNOUNCEMENT} (Chrome Root Store version {p256.load_store().version})")
|
|
48
|
+
if any("error" in r for r in results):
|
|
49
|
+
return 2
|
|
50
|
+
if not a.exit_zero and any(r["status"] in ("blocked", "renewal-at-risk") for r in results):
|
|
51
|
+
return 1
|
|
52
|
+
return 0
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def main(argv=None):
|
|
56
|
+
argv = sys.argv[1:] if argv is None else argv
|
|
57
|
+
if not argv or argv[0] in ("-h", "--help", "help"):
|
|
58
|
+
print(__doc__.strip())
|
|
59
|
+
return 0 if argv else 2
|
|
60
|
+
if argv[0] == "--version":
|
|
61
|
+
print(f"p256check {__version__}")
|
|
62
|
+
return 0
|
|
63
|
+
if argv[0] == "check":
|
|
64
|
+
return check_main(argv[1:])
|
|
65
|
+
if argv[0] == "scan":
|
|
66
|
+
return scan_main(argv[1:])
|
|
67
|
+
if argv[0] == "mcp":
|
|
68
|
+
from . import mcp
|
|
69
|
+
return mcp.serve()
|
|
70
|
+
if argv[0] == "serve":
|
|
71
|
+
from . import web
|
|
72
|
+
sp = argparse.ArgumentParser(prog="p256check serve", description="Serve the scoreboard page and the "
|
|
73
|
+
"live checker (/api/check) on one port.")
|
|
74
|
+
sp.add_argument("site", nargs="?", default="docs", help="folder with index.html (default: docs)")
|
|
75
|
+
sp.add_argument("--port", type=int, default=8080)
|
|
76
|
+
sp.add_argument("--bind", default="127.0.0.1")
|
|
77
|
+
x = sp.parse_args(argv[1:])
|
|
78
|
+
return web.serve(os.path.abspath(x.site), x.port, x.bind)
|
|
79
|
+
return check_main(argv)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def scan_main(argv):
|
|
83
|
+
"""p256check scan PATH ...: the cryptography inventory and post-quantum ranking."""
|
|
84
|
+
ap = argparse.ArgumentParser(prog="p256check scan", description="Find the cryptography a project uses and rank it "
|
|
85
|
+
"for the post-quantum move. Writes cbom.json (CycloneDX 1.6) and report.html.")
|
|
86
|
+
ap.add_argument("paths", nargs="*", help="folders, files, archives (.jar .whl .zip .tgz) or binaries")
|
|
87
|
+
ap.add_argument("--tls", action="append", default=[], metavar="HOST[:PORT]",
|
|
88
|
+
help="probe a TLS server: key exchange groups and certificate chain (~12 handshakes)")
|
|
89
|
+
ap.add_argument("--ssh", action="append", default=[], metavar="HOST[:PORT]",
|
|
90
|
+
help="probe an SSH server: offered key exchange and host key algorithms, host keys")
|
|
91
|
+
ap.add_argument("--jwks", action="append", default=[], metavar="URL|DOMAIN",
|
|
92
|
+
help="read an OpenID provider's discovery document and JSON Web Key Set")
|
|
93
|
+
ap.add_argument("--dnssec", action="append", default=[], metavar="ZONE",
|
|
94
|
+
help="read a zone's DNSSEC keys (DNSKEY) through the system resolver")
|
|
95
|
+
ap.add_argument("--resolver", help="DNS server for --dnssec (default: from /etc/resolv.conf)")
|
|
96
|
+
ap.add_argument("--domain", action="append", default=[], metavar="DOMAIN",
|
|
97
|
+
help="shortcut: --tls DOMAIN --jwks DOMAIN --dnssec DOMAIN (SSH stays explicit)")
|
|
98
|
+
ap.add_argument("--profile", choices=profiles.PROFILES, default="dec2026",
|
|
99
|
+
help="ranking: dec2026 (default; 256-bit curves suspect after the 2 Dec 2026 NSA advisory) "
|
|
100
|
+
"or pqc (quantum-only timeline, NIST IR 8547)")
|
|
101
|
+
ap.add_argument("-o", "--out", default="p256check-out", help="output folder (default: p256check-out)")
|
|
102
|
+
ap.add_argument("--json", action="store_true", help="print findings as JSON instead of the summary")
|
|
103
|
+
ap.add_argument("--vendored", action="store_true", help="also scan node_modules, vendor, .venv, target ...")
|
|
104
|
+
ap.add_argument("--no-binaries", action="store_true", help="skip compiled files")
|
|
105
|
+
ap.add_argument("--no-write", action="store_true", help="do not write cbom.json/report.html")
|
|
106
|
+
ap.add_argument("--fail-on", choices=["fix-now", "suspect-now", "high", "medium"], help="exit 1 if anything at this level or "
|
|
107
|
+
"worse is found in non-test code (for CI)")
|
|
108
|
+
ap.add_argument("--limit", type=int, default=12, help="rows per section in the terminal (default 12)")
|
|
109
|
+
ap.add_argument("--version", action="version", version=f"p256check {__version__}")
|
|
110
|
+
a = ap.parse_args(argv)
|
|
111
|
+
profiles.set_profile(a.profile)
|
|
112
|
+
for d in a.domain:
|
|
113
|
+
a.tls.append(d)
|
|
114
|
+
a.jwks.append(d)
|
|
115
|
+
a.dnssec.append(d)
|
|
116
|
+
probes = a.tls or a.ssh or a.jwks or a.dnssec
|
|
117
|
+
if not a.paths and not probes:
|
|
118
|
+
a.paths = ["."]
|
|
119
|
+
|
|
120
|
+
opts = {"vendored": a.vendored, "binaries": not a.no_binaries}
|
|
121
|
+
findings, stats = [], {"files": 0, "bytes": 0, "seconds": 0.0}
|
|
122
|
+
for p in a.paths:
|
|
123
|
+
if not os.path.exists(p):
|
|
124
|
+
print(f"p256check: {p}: no such file or folder", file=sys.stderr)
|
|
125
|
+
return 2
|
|
126
|
+
f, s = scan_path(p, opts)
|
|
127
|
+
if len(a.paths) > 1:
|
|
128
|
+
for x in f:
|
|
129
|
+
x.path = f"{os.path.basename(os.path.abspath(p))}/{x.path}"
|
|
130
|
+
findings += f
|
|
131
|
+
for k in ("files", "bytes", "seconds"):
|
|
132
|
+
stats[k] = round(stats[k] + s.get(k, 0), 2)
|
|
133
|
+
from . import anchors, tls
|
|
134
|
+
tls_reports = []
|
|
135
|
+
runs = [(tls.probe, t, "tls") for t in a.tls] + [(anchors.probe_ssh, t, "ssh") for t in a.ssh] \
|
|
136
|
+
+ [(anchors.probe_jwks, t, "jwks") for t in a.jwks] \
|
|
137
|
+
+ [(lambda z: anchors.probe_dnssec(z, a.resolver), t, "dnssec") for t in a.dnssec]
|
|
138
|
+
for fn, t, kind in runs:
|
|
139
|
+
f, r = fn(t)
|
|
140
|
+
r.setdefault("kind", kind)
|
|
141
|
+
findings += f
|
|
142
|
+
tls_reports.append(r)
|
|
143
|
+
findings = merge(findings)
|
|
144
|
+
target = ", ".join(a.paths + [f"{k}://{t}" for _, t, k in runs])
|
|
145
|
+
|
|
146
|
+
if a.json:
|
|
147
|
+
print(json.dumps({"target": target, "profile": a.profile, "stats": stats, "probes": tls_reports,
|
|
148
|
+
"findings": [f.to_dict() for f in findings]}, indent=1, default=str))
|
|
149
|
+
else:
|
|
150
|
+
print(report.terminal(findings, stats, target, tls_reports, a.limit, color=sys.stdout.isatty()))
|
|
151
|
+
|
|
152
|
+
if not a.no_write:
|
|
153
|
+
os.makedirs(a.out, exist_ok=True)
|
|
154
|
+
with open(os.path.join(a.out, "cbom.json"), "w") as fh:
|
|
155
|
+
json.dump(cbom.build(findings, target, stats), fh, indent=1, default=str)
|
|
156
|
+
with open(os.path.join(a.out, "report.html"), "w") as fh:
|
|
157
|
+
fh.write(report.html_report(findings, stats, target, tls_reports,
|
|
158
|
+
datetime.now().strftime("%Y-%m-%d %H:%M")))
|
|
159
|
+
if not a.json:
|
|
160
|
+
print(f"\nWrote {a.out}/cbom.json and {a.out}/report.html")
|
|
161
|
+
|
|
162
|
+
if a.fail_on:
|
|
163
|
+
worst = PRIORITY_ORDER.index(a.fail_on)
|
|
164
|
+
if any(PRIORITY_ORDER.index(f.priority) <= worst and f.context == "code" for f in findings):
|
|
165
|
+
return 1
|
|
166
|
+
return 0
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def entry():
|
|
170
|
+
sys.exit(main())
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
if __name__ == "__main__":
|
|
174
|
+
entry()
|