xbomly 0.14.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.
- xbomly/__init__.py +12 -0
- xbomly/__main__.py +5 -0
- xbomly/aibom.py +188 -0
- xbomly/algorithms.py +288 -0
- xbomly/app/__init__.py +1155 -0
- xbomly/app/icon.ico +0 -0
- xbomly/app/icon.png +0 -0
- xbomly/app/native.py +109 -0
- xbomly/app/report.py +810 -0
- xbomly/app/tracking.py +227 -0
- xbomly/app/ui.html +1209 -0
- xbomly/app/update.py +109 -0
- xbomly/app/view.py +506 -0
- xbomly/applicability.py +66 -0
- xbomly/cbom.py +317 -0
- xbomly/cbom_names.py +35 -0
- xbomly/certs.py +192 -0
- xbomly/cli.py +707 -0
- xbomly/cloud.py +139 -0
- xbomly/detect/__init__.py +1 -0
- xbomly/detect/ai.py +585 -0
- xbomly/detect/binary.py +95 -0
- xbomly/detect/configs.py +399 -0
- xbomly/detect/deps.py +154 -0
- xbomly/detect/hardware.py +398 -0
- xbomly/detect/keys.py +921 -0
- xbomly/detect/manifest.py +97 -0
- xbomly/detect/ops.py +82 -0
- xbomly/detect/osstores.py +108 -0
- xbomly/detect/services.py +69 -0
- xbomly/detect/source.py +567 -0
- xbomly/detect/vendors.py +313 -0
- xbomly/findings.py +29 -0
- xbomly/grc.py +459 -0
- xbomly/hbom.py +113 -0
- xbomly/image.py +312 -0
- xbomly/importer.py +248 -0
- xbomly/inventory.py +150 -0
- xbomly/license.py +273 -0
- xbomly/logs.py +521 -0
- xbomly/packs/au.toml +50 -0
- xbomly/packs/baseline.toml +123 -0
- xbomly/packs/ca.toml +72 -0
- xbomly/packs/eu.toml +108 -0
- xbomly/packs/india.toml +167 -0
- xbomly/packs/jp.toml +50 -0
- xbomly/packs/pci-dss.toml +66 -0
- xbomly/packs/sg.toml +52 -0
- xbomly/packs/uk.toml +53 -0
- xbomly/packs/us-cnsa2.toml +93 -0
- xbomly/packs/us-fda.toml +77 -0
- xbomly/packs/us.toml +125 -0
- xbomly/planner.py +308 -0
- xbomly/probe.py +370 -0
- xbomly/report.py +387 -0
- xbomly/rules.py +267 -0
- xbomly/sbom.py +175 -0
- xbomly/scanner.py +240 -0
- xbomly/syft_fetch.py +144 -0
- xbomly/term/__init__.py +698 -0
- xbomly/tlscheck.py +200 -0
- xbomly/upload.py +98 -0
- xbomly-0.14.0.dist-info/METADATA +438 -0
- xbomly-0.14.0.dist-info/RECORD +68 -0
- xbomly-0.14.0.dist-info/WHEEL +5 -0
- xbomly-0.14.0.dist-info/entry_points.txt +2 -0
- xbomly-0.14.0.dist-info/licenses/LICENSE +56 -0
- xbomly-0.14.0.dist-info/top_level.txt +1 -0
xbomly/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Xbomly: find the cryptography in your software and check it is quantum-safe."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.14.0"
|
|
4
|
+
|
|
5
|
+
# Xbomly was called Cbomly until December 2026. Settings made with the old names still work:
|
|
6
|
+
# every CBOMLY_* environment variable counts as the matching XBOMLY_* one unless that is set too.
|
|
7
|
+
import os as _os
|
|
8
|
+
|
|
9
|
+
for _k, _v in list(_os.environ.items()):
|
|
10
|
+
if _k.startswith("CBOMLY_"):
|
|
11
|
+
_os.environ.setdefault("XBOMLY_" + _k[7:], _v)
|
|
12
|
+
del _os
|
xbomly/__main__.py
ADDED
xbomly/aibom.py
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""Write the AI part of a scan as its own CycloneDX 1.6 AI bill of materials (aibom.cdx.json).
|
|
2
|
+
|
|
3
|
+
CycloneDX calls this an ML-BOM: one "machine-learning-model" component per model with a model card
|
|
4
|
+
(task, architecture, training data, licence), the AI libraries the product uses, and the hosted AI
|
|
5
|
+
services it sends data to, all tied to the product by the dependency graph.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import hashlib
|
|
11
|
+
import re
|
|
12
|
+
import uuid
|
|
13
|
+
from datetime import UTC, datetime
|
|
14
|
+
from urllib.parse import quote
|
|
15
|
+
|
|
16
|
+
from . import __version__
|
|
17
|
+
from .detect.ai import AI_APIS, HF_HUB
|
|
18
|
+
|
|
19
|
+
SOURCE = {"file": "file", "huggingface": "huggingface-hub", "hosted": "hosted-api", "local": "local-runtime", "open": "open-weight"}
|
|
20
|
+
# Licences Hugging Face model cards use, as SPDX ids. Anything else is recorded by name.
|
|
21
|
+
SPDX = {x.lower(): x for x in (
|
|
22
|
+
"Apache-2.0", "MIT", "BSD-2-Clause", "BSD-3-Clause", "CC0-1.0", "CC-BY-4.0", "CC-BY-SA-4.0", "CC-BY-NC-4.0",
|
|
23
|
+
"CC-BY-NC-SA-4.0", "CC-BY-NC-ND-4.0", "MPL-2.0", "Unlicense", "Artistic-2.0", "BSL-1.0", "ISC", "Zlib")}
|
|
24
|
+
SPDX |= {"gpl-3.0": "GPL-3.0-only", "gpl-2.0": "GPL-2.0-only", "agpl-3.0": "AGPL-3.0-only", "lgpl-3.0": "LGPL-3.0-only",
|
|
25
|
+
"lgpl-2.1": "LGPL-2.1-only", "afl-3.0": "AFL-3.0", "openrail": None}
|
|
26
|
+
HF_ID = re.compile(r"^[A-Za-z0-9][\w.-]*/[A-Za-z0-9][\w.-]*$")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def ref(kind: str, key: str) -> str:
|
|
30
|
+
return f"{kind}/{hashlib.sha1(key.encode()).hexdigest()[:12]}"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def model_ref(m: dict) -> str:
|
|
34
|
+
key = f"{m['kind']}:{m['name']}:{m['places'][0]['file']}" if m["kind"] == "file" else f"{m['kind']}:{m['name']}"
|
|
35
|
+
return ref("ai/model", key)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def service_of(m: dict) -> tuple[str, str] | None:
|
|
39
|
+
"""(service name, address) a model is reached through, if it is reached over the network."""
|
|
40
|
+
if m["kind"] == "hosted":
|
|
41
|
+
return AI_APIS.get(m.get("supplier") or "")
|
|
42
|
+
if m["kind"] == "huggingface":
|
|
43
|
+
return HF_HUB
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _license(name: str) -> dict:
|
|
48
|
+
spdx = SPDX.get(name.lower())
|
|
49
|
+
return {"license": {"id": spdx}} if spdx else {"license": {"name": name}}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _loc(p: dict) -> dict:
|
|
53
|
+
return {"location": p["file"], **({"line": p["line"]} if p.get("line") else {})}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def model_component(m: dict) -> dict:
|
|
57
|
+
"""One model as a CycloneDX machine-learning-model component, with a model card where anything is known."""
|
|
58
|
+
meta = m.get("meta") or {}
|
|
59
|
+
props = [{"name": "xbomly:ai-model-source", "value": SOURCE[m["kind"]]}]
|
|
60
|
+
comp: dict = {"type": "machine-learning-model", "name": m["name"], "bom-ref": model_ref(m)}
|
|
61
|
+
if meta.get("model_version"):
|
|
62
|
+
comp["version"] = str(meta["model_version"])
|
|
63
|
+
supplier = meta.get("author") or (m.get("supplier") if m["kind"] != "file" else None)
|
|
64
|
+
if supplier and supplier != "Unknown":
|
|
65
|
+
comp["supplier"] = {"name": supplier}
|
|
66
|
+
if meta.get("model_name") and meta["model_name"] != m["name"]:
|
|
67
|
+
comp["description"] = meta["model_name"]
|
|
68
|
+
if m["kind"] == "file":
|
|
69
|
+
props.append({"name": "xbomly:model-format", "value": m["format"]})
|
|
70
|
+
if m.get("pickle"):
|
|
71
|
+
props.append({"name": "xbomly:pickle-format", "value": "true"})
|
|
72
|
+
for imp in m.get("unsafe_imports") or []:
|
|
73
|
+
props.append({"name": "xbomly:unsafe-pickle-import", "value": imp})
|
|
74
|
+
if m.get("size"):
|
|
75
|
+
props.append({"name": "xbomly:size-bytes", "value": str(m["size"])})
|
|
76
|
+
if m.get("sha256"):
|
|
77
|
+
comp["hashes"] = [{"alg": "SHA-256", "content": m["sha256"]}]
|
|
78
|
+
if m.get("runtime"):
|
|
79
|
+
props.append({"name": "xbomly:ai-runtime", "value": m["runtime"]})
|
|
80
|
+
hf = m["name"] if m["kind"] == "huggingface" else meta.get("source_repo")
|
|
81
|
+
if hf and HF_ID.match(hf):
|
|
82
|
+
org, _, model = hf.partition("/")
|
|
83
|
+
if m["kind"] == "huggingface":
|
|
84
|
+
comp["group"] = org
|
|
85
|
+
comp["purl"] = f"pkg:huggingface/{quote(org)}/{quote(model)}"
|
|
86
|
+
comp["externalReferences"] = [{"type": "model-card", "url": f"https://huggingface.co/{hf}"}]
|
|
87
|
+
if meta.get("license"):
|
|
88
|
+
lic = meta["license"]
|
|
89
|
+
comp["licenses"] = [_license(x) for x in (lic if isinstance(lic, list) else [lic])]
|
|
90
|
+
if meta.get("base_models"):
|
|
91
|
+
comp["pedigree"] = {"ancestors": [{"type": "machine-learning-model", "name": b} for b in meta["base_models"]]}
|
|
92
|
+
|
|
93
|
+
params: dict = {}
|
|
94
|
+
if meta.get("task"):
|
|
95
|
+
params["task"] = meta["task"]
|
|
96
|
+
if meta.get("architecture_family") or meta.get("architecture"):
|
|
97
|
+
params["architectureFamily"] = meta.get("architecture_family") or meta["architecture"]
|
|
98
|
+
if meta.get("architecture"):
|
|
99
|
+
params["modelArchitecture"] = meta["architecture"]
|
|
100
|
+
if meta.get("datasets"):
|
|
101
|
+
params["datasets"] = [{"type": "dataset", "name": d} for d in meta["datasets"]]
|
|
102
|
+
card_props = [{"name": f"xbomly:{k.replace('_', '-')}", "value": str(meta[k] if not isinstance(meta[k], list)
|
|
103
|
+
else ", ".join(meta[k]))} for k in ("parameters", "size_label", "precision", "quantization",
|
|
104
|
+
"context_length", "adapter", "languages", "library")
|
|
105
|
+
if meta.get(k)]
|
|
106
|
+
if params or card_props:
|
|
107
|
+
comp["modelCard"] = {"bom-ref": comp["bom-ref"] + "/card", **({"modelParameters": params} if params else {}),
|
|
108
|
+
**({"properties": card_props} if card_props else {})}
|
|
109
|
+
for g in m.get("gaps") or []:
|
|
110
|
+
props.append({"name": "xbomly:aibom-missing", "value": g})
|
|
111
|
+
comp["evidence"] = {"occurrences": [_loc(p) for p in m["places"]]}
|
|
112
|
+
comp["properties"] = props
|
|
113
|
+
return comp
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def services(models: list[dict]) -> list[dict]:
|
|
117
|
+
"""The hosted AI services and model hubs the product talks to, one per service."""
|
|
118
|
+
out: dict[str, dict] = {}
|
|
119
|
+
for m in models:
|
|
120
|
+
svc = service_of(m)
|
|
121
|
+
if not svc:
|
|
122
|
+
continue
|
|
123
|
+
e = out.setdefault(svc[0], {
|
|
124
|
+
"bom-ref": ref("ai/service", svc[0]), "provider": {"name": m["supplier"] if m["kind"] == "hosted" else "Hugging Face"},
|
|
125
|
+
"name": svc[0], "endpoints": [svc[1]], "x-trust-boundary": True,
|
|
126
|
+
"data": [{"flow": "bi-directional" if m["kind"] == "hosted" else "inbound",
|
|
127
|
+
"classification": "prompts and model output" if m["kind"] == "hosted" else "model weights"}],
|
|
128
|
+
"properties": []})
|
|
129
|
+
e["properties"].append({"name": "xbomly:ai-model", "value": m["name"]})
|
|
130
|
+
return list(out.values())
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def build(ai_inv: dict, sbom: dict | None, target_name: str) -> dict:
|
|
134
|
+
now = datetime.now(UTC).replace(microsecond=0).isoformat().replace("+00:00", "Z")
|
|
135
|
+
root = dict(((sbom or {}).get("metadata") or {}).get("component") or {"type": "application"})
|
|
136
|
+
root["bom-ref"] = root.get("bom-ref") or "root"
|
|
137
|
+
if not root.get("name") or root["name"] in (".", "/"):
|
|
138
|
+
root["name"] = target_name
|
|
139
|
+
models, libs = ai_inv.get("models", []), ai_inv.get("libraries", [])
|
|
140
|
+
bom: dict = {
|
|
141
|
+
"$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json",
|
|
142
|
+
"bomFormat": "CycloneDX", "specVersion": "1.6", "serialNumber": f"urn:uuid:{uuid.uuid4()}", "version": 1,
|
|
143
|
+
"metadata": {
|
|
144
|
+
"timestamp": now,
|
|
145
|
+
"tools": {"components": [{"type": "application", "name": "xbomly", "version": __version__,
|
|
146
|
+
"externalReferences": [{"type": "website", "url": "https://xbomly.com"}]}]},
|
|
147
|
+
"component": root,
|
|
148
|
+
"properties": [{"name": "xbomly:bom-kind", "value": "aibom"},
|
|
149
|
+
{"name": "xbomly:models", "value": str(len(models))},
|
|
150
|
+
{"name": "xbomly:models-with-gaps", "value": str(sum(bool(m.get("gaps")) for m in models))}],
|
|
151
|
+
},
|
|
152
|
+
"components": [],
|
|
153
|
+
"dependencies": [],
|
|
154
|
+
}
|
|
155
|
+
sb = {c.get("bom-ref"): c for c in (sbom or {}).get("components", [])}
|
|
156
|
+
top: list[str] = []
|
|
157
|
+
for lib in libs:
|
|
158
|
+
tags = [{"name": "xbomly:ai-library", "value": lib["name"]}, {"name": "xbomly:ai-role", "value": lib["role"]}]
|
|
159
|
+
found = [sb[r] for r in lib["bom_refs"] if r in sb]
|
|
160
|
+
for c in found:
|
|
161
|
+
if c["bom-ref"] in top:
|
|
162
|
+
continue
|
|
163
|
+
comp = {k: c[k] for k in ("type", "name", "group", "version", "purl", "bom-ref", "licenses") if k in c}
|
|
164
|
+
comp["properties"] = tags
|
|
165
|
+
bom["components"].append(comp)
|
|
166
|
+
top.append(comp["bom-ref"])
|
|
167
|
+
if not found:
|
|
168
|
+
comp = {"type": "library", "name": lib["name"], "bom-ref": ref("ai/library", lib["name"]), "properties": tags}
|
|
169
|
+
if lib["versions"]:
|
|
170
|
+
comp["version"] = lib["versions"][0]
|
|
171
|
+
if lib["places"]:
|
|
172
|
+
comp["evidence"] = {"occurrences": [_loc(p) for p in lib["places"]]}
|
|
173
|
+
bom["components"].append(comp)
|
|
174
|
+
top.append(comp["bom-ref"])
|
|
175
|
+
svcs = services(models)
|
|
176
|
+
svc_ref = {s["name"]: s["bom-ref"] for s in svcs}
|
|
177
|
+
for m in models:
|
|
178
|
+
comp = model_component(m)
|
|
179
|
+
bom["components"].append(comp)
|
|
180
|
+
top.append(comp["bom-ref"])
|
|
181
|
+
svc = service_of(m)
|
|
182
|
+
if svc:
|
|
183
|
+
bom["dependencies"].append({"ref": comp["bom-ref"], "dependsOn": [svc_ref[svc[0]]]})
|
|
184
|
+
if svcs:
|
|
185
|
+
bom["services"] = svcs
|
|
186
|
+
top += [s["bom-ref"] for s in svcs]
|
|
187
|
+
bom["dependencies"].insert(0, {"ref": root["bom-ref"], "dependsOn": list(dict.fromkeys(top))})
|
|
188
|
+
return bom
|
xbomly/algorithms.py
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
"""Catalog of cryptographic algorithms Xbomly knows about.
|
|
2
|
+
|
|
3
|
+
Each entry says what the algorithm is for, whether a large quantum computer
|
|
4
|
+
would break it, and what to move to instead. Rule packs and reports read
|
|
5
|
+
this catalog, so country-specific logic never needs to repeat these facts.
|
|
6
|
+
|
|
7
|
+
Quantum status values:
|
|
8
|
+
vulnerable Broken by Shor's algorithm on a large quantum computer
|
|
9
|
+
(RSA, elliptic curves, Diffie-Hellman, DSA).
|
|
10
|
+
reduced Grover's algorithm roughly halves the strength. Still safe
|
|
11
|
+
with large enough keys (e.g. move AES-128 to AES-256).
|
|
12
|
+
resistant Believed safe against quantum attacks.
|
|
13
|
+
not-applicable Not a security primitive on its own.
|
|
14
|
+
|
|
15
|
+
Classical status values:
|
|
16
|
+
broken Unsafe today, even without a quantum computer.
|
|
17
|
+
deprecated Being phased out by standards bodies; avoid in new designs.
|
|
18
|
+
acceptable Fine today.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
from dataclasses import dataclass, field
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True)
|
|
27
|
+
class Algorithm:
|
|
28
|
+
id: str
|
|
29
|
+
name: str
|
|
30
|
+
primitive: str # CycloneDX 1.6 primitive enum
|
|
31
|
+
quantum: str
|
|
32
|
+
classical: str
|
|
33
|
+
replacement: str
|
|
34
|
+
note: str
|
|
35
|
+
oid: str | None = None
|
|
36
|
+
classical_security_bits: int | None = None
|
|
37
|
+
nist_quantum_level: int = 0
|
|
38
|
+
asset_type: str = "algorithm" # or "protocol"
|
|
39
|
+
aliases: tuple[str, ...] = field(default_factory=tuple)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
_A = Algorithm
|
|
43
|
+
|
|
44
|
+
CATALOG: dict[str, Algorithm] = {a.id: a for a in [
|
|
45
|
+
# --- Public-key: quantum-vulnerable -------------------------------
|
|
46
|
+
_A("rsa", "RSA", "pke", "vulnerable", "acceptable",
|
|
47
|
+
"ML-KEM (FIPS 203) for encryption/key exchange, ML-DSA (FIPS 204) for signatures; hybrid during migration",
|
|
48
|
+
"Shor's algorithm breaks RSA at any key size.",
|
|
49
|
+
oid="1.2.840.113549.1.1.1", classical_security_bits=112),
|
|
50
|
+
_A("rsa-sig", "RSA signature", "signature", "vulnerable", "acceptable",
|
|
51
|
+
"ML-DSA (FIPS 204) or SLH-DSA (FIPS 205); hybrid RSA+ML-DSA during migration",
|
|
52
|
+
"Shor's algorithm breaks RSA signatures at any key size.",
|
|
53
|
+
oid="1.2.840.113549.1.1.11", classical_security_bits=112),
|
|
54
|
+
_A("ecdsa", "ECDSA", "signature", "vulnerable", "acceptable",
|
|
55
|
+
"ML-DSA (FIPS 204); hybrid ECDSA+ML-DSA during migration",
|
|
56
|
+
"Shor's algorithm breaks elliptic-curve signatures.",
|
|
57
|
+
oid="1.2.840.10045.2.1", classical_security_bits=128),
|
|
58
|
+
_A("ecdh", "ECDH", "key-agree", "vulnerable", "acceptable",
|
|
59
|
+
"ML-KEM (FIPS 203); hybrid X25519MLKEM768 in TLS",
|
|
60
|
+
"Shor's algorithm breaks elliptic-curve key agreement. Recorded traffic can be decrypted later (harvest now, decrypt later).",
|
|
61
|
+
classical_security_bits=128),
|
|
62
|
+
_A("ec", "Elliptic curve (unspecified use)", "other", "vulnerable", "acceptable",
|
|
63
|
+
"ML-KEM for key exchange, ML-DSA for signatures",
|
|
64
|
+
"An elliptic-curve key or curve was found; Shor's algorithm breaks it.",
|
|
65
|
+
oid="1.2.840.10045.2.1", classical_security_bits=128),
|
|
66
|
+
_A("ed25519", "Ed25519", "signature", "vulnerable", "acceptable",
|
|
67
|
+
"ML-DSA (FIPS 204); hybrid Ed25519+ML-DSA during migration",
|
|
68
|
+
"Modern and fast, but still an elliptic curve: Shor's algorithm breaks it.",
|
|
69
|
+
oid="1.3.101.112", classical_security_bits=128),
|
|
70
|
+
_A("ed448", "Ed448", "signature", "vulnerable", "acceptable",
|
|
71
|
+
"ML-DSA (FIPS 204)", "Elliptic-curve signature; quantum-vulnerable.",
|
|
72
|
+
oid="1.3.101.113", classical_security_bits=224),
|
|
73
|
+
_A("x25519", "X25519", "key-agree", "vulnerable", "acceptable",
|
|
74
|
+
"Hybrid X25519MLKEM768, then ML-KEM",
|
|
75
|
+
"Elliptic-curve key agreement; quantum-vulnerable.",
|
|
76
|
+
oid="1.3.101.110", classical_security_bits=128),
|
|
77
|
+
_A("x448", "X448", "key-agree", "vulnerable", "acceptable",
|
|
78
|
+
"ML-KEM-1024", "Elliptic-curve key agreement; quantum-vulnerable.",
|
|
79
|
+
oid="1.3.101.111", classical_security_bits=224),
|
|
80
|
+
_A("dsa", "DSA", "signature", "vulnerable", "deprecated",
|
|
81
|
+
"ML-DSA (FIPS 204)",
|
|
82
|
+
"Removed for new signatures in FIPS 186-5, and quantum-vulnerable.",
|
|
83
|
+
oid="1.2.840.10040.4.1", classical_security_bits=112),
|
|
84
|
+
_A("dh", "Diffie-Hellman (finite field)", "key-agree", "vulnerable", "acceptable",
|
|
85
|
+
"ML-KEM (FIPS 203)", "Shor's algorithm breaks finite-field Diffie-Hellman.",
|
|
86
|
+
oid="1.2.840.113549.1.3.1", classical_security_bits=112),
|
|
87
|
+
|
|
88
|
+
# --- Public-key: quantum-resistant --------------------------------
|
|
89
|
+
_A("ml-kem", "ML-KEM (Kyber)", "kem", "resistant", "acceptable",
|
|
90
|
+
"Keep. Consider hybrid with X25519 while ecosystems mature.",
|
|
91
|
+
"NIST FIPS 203 post-quantum key encapsulation.", nist_quantum_level=3,
|
|
92
|
+
aliases=("kyber",)),
|
|
93
|
+
_A("ml-dsa", "ML-DSA (Dilithium)", "signature", "resistant", "acceptable",
|
|
94
|
+
"Keep.", "NIST FIPS 204 post-quantum signature.", nist_quantum_level=3,
|
|
95
|
+
aliases=("dilithium",)),
|
|
96
|
+
_A("slh-dsa", "SLH-DSA (SPHINCS+)", "signature", "resistant", "acceptable",
|
|
97
|
+
"Keep.", "NIST FIPS 205 hash-based post-quantum signature.", nist_quantum_level=1,
|
|
98
|
+
aliases=("sphincs+",)),
|
|
99
|
+
_A("lms", "LMS / XMSS (stateful hash-based)", "signature", "resistant", "acceptable",
|
|
100
|
+
"Keep; manage signing state carefully.",
|
|
101
|
+
"NIST SP 800-208 stateful hash-based signatures, suited to firmware signing.",
|
|
102
|
+
nist_quantum_level=1),
|
|
103
|
+
_A("hybrid-kem", "Hybrid X25519MLKEM768", "kem", "resistant", "acceptable",
|
|
104
|
+
"Keep.", "Classical + post-quantum hybrid key exchange (TLS 1.3).",
|
|
105
|
+
nist_quantum_level=3),
|
|
106
|
+
_A("hybrid-sig", "Composite / hybrid ML-DSA signature", "signature", "resistant", "acceptable",
|
|
107
|
+
"Keep.", "Classical + ML-DSA composite signature (IETF LAMPS draft).", nist_quantum_level=3),
|
|
108
|
+
_A("fn-dsa", "FN-DSA (Falcon)", "signature", "resistant", "acceptable",
|
|
109
|
+
"Keep; FIPS 206 is still a draft, so plan to re-check parameters.",
|
|
110
|
+
"NIST's lattice signature selected for standardisation as FN-DSA.", nist_quantum_level=1,
|
|
111
|
+
aliases=("falcon",)),
|
|
112
|
+
_A("hqc", "HQC", "kem", "resistant", "acceptable",
|
|
113
|
+
"Keep as a backup KEM; ML-KEM is the primary standard.",
|
|
114
|
+
"Code-based KEM selected by NIST in 2025 as a backup to ML-KEM.", nist_quantum_level=1),
|
|
115
|
+
_A("frodokem", "FrodoKEM", "kem", "resistant", "acceptable",
|
|
116
|
+
"Keep; recommended by BSI and ANSSI, not a NIST standard.", "Conservative lattice KEM.",
|
|
117
|
+
nist_quantum_level=1),
|
|
118
|
+
_A("mceliece", "Classic McEliece", "kem", "resistant", "acceptable",
|
|
119
|
+
"Keep; very large public keys.", "Code-based KEM; ISO standardisation in progress.",
|
|
120
|
+
nist_quantum_level=1),
|
|
121
|
+
_A("sntrup", "Hybrid sntrup761x25519 (SSH)", "kem", "resistant", "acceptable",
|
|
122
|
+
"Keep, or move to mlkem768x25519-sha256 (OpenSSH 10 default).",
|
|
123
|
+
"Streamlined NTRU Prime + X25519 hybrid key exchange used by OpenSSH since 9.0.",
|
|
124
|
+
nist_quantum_level=1),
|
|
125
|
+
|
|
126
|
+
# --- Hashes -------------------------------------------------------
|
|
127
|
+
_A("md5", "MD5", "hash", "not-applicable", "broken",
|
|
128
|
+
"SHA-256 or SHA-3", "Collisions are practical today; never use for security.",
|
|
129
|
+
oid="1.2.840.113549.2.5", classical_security_bits=0),
|
|
130
|
+
_A("sha1", "SHA-1", "hash", "not-applicable", "broken",
|
|
131
|
+
"SHA-256, SHA-384 or SHA-3", "Practical collisions since 2017; unsafe for signatures and certificates.",
|
|
132
|
+
oid="1.3.14.3.2.26", classical_security_bits=63),
|
|
133
|
+
_A("sha256", "SHA-256", "hash", "resistant", "acceptable",
|
|
134
|
+
"Keep. CNSA 2.0 prefers SHA-384 or SHA-512.", "Grover only gives a small speed-up against hashes.",
|
|
135
|
+
oid="2.16.840.1.101.3.4.2.1", classical_security_bits=128, nist_quantum_level=2),
|
|
136
|
+
_A("sha384", "SHA-384", "hash", "resistant", "acceptable", "Keep.", "",
|
|
137
|
+
oid="2.16.840.1.101.3.4.2.2", classical_security_bits=192, nist_quantum_level=4),
|
|
138
|
+
_A("sha512", "SHA-512", "hash", "resistant", "acceptable", "Keep.", "",
|
|
139
|
+
oid="2.16.840.1.101.3.4.2.3", classical_security_bits=256, nist_quantum_level=5),
|
|
140
|
+
_A("sha3", "SHA-3", "hash", "resistant", "acceptable", "Keep.", "",
|
|
141
|
+
classical_security_bits=128, nist_quantum_level=2),
|
|
142
|
+
_A("blake2", "BLAKE2", "hash", "resistant", "acceptable", "Keep.", "",
|
|
143
|
+
classical_security_bits=128, nist_quantum_level=2),
|
|
144
|
+
|
|
145
|
+
# --- Symmetric ----------------------------------------------------
|
|
146
|
+
_A("aes-128", "AES-128", "block-cipher", "reduced", "acceptable",
|
|
147
|
+
"AES-256 (required by CNSA 2.0)", "Grover's algorithm roughly halves the effective key strength.",
|
|
148
|
+
classical_security_bits=128, nist_quantum_level=1),
|
|
149
|
+
_A("aes-192", "AES-192", "block-cipher", "resistant", "acceptable",
|
|
150
|
+
"Keep. CNSA 2.0 requires AES-256.", "", classical_security_bits=192, nist_quantum_level=3),
|
|
151
|
+
_A("aes-256", "AES-256", "block-cipher", "resistant", "acceptable", "Keep.", "",
|
|
152
|
+
classical_security_bits=256, nist_quantum_level=5),
|
|
153
|
+
_A("aes", "AES (key size not detected)", "block-cipher", "reduced", "acceptable",
|
|
154
|
+
"Confirm the key size; use AES-256", "AES-256 is quantum-safe; AES-128 is weakened.",
|
|
155
|
+
classical_security_bits=128),
|
|
156
|
+
_A("des", "DES", "block-cipher", "not-applicable", "broken", "AES-256",
|
|
157
|
+
"56-bit key; brute-forceable today."),
|
|
158
|
+
_A("3des", "Triple DES", "block-cipher", "not-applicable", "deprecated", "AES-256",
|
|
159
|
+
"Disallowed by NIST after 2023; 64-bit block size."),
|
|
160
|
+
_A("rc4", "RC4", "stream-cipher", "not-applicable", "broken", "AES-GCM or ChaCha20-Poly1305",
|
|
161
|
+
"Biased keystream; banned in TLS (RFC 7465)."),
|
|
162
|
+
_A("ecb", "ECB mode", "block-cipher", "not-applicable", "broken", "GCM or another authenticated mode",
|
|
163
|
+
"ECB leaks patterns in the plaintext."),
|
|
164
|
+
_A("blowfish", "Blowfish", "block-cipher", "not-applicable", "deprecated", "AES-256",
|
|
165
|
+
"64-bit block size (Sweet32 attacks); not approved by NIST."),
|
|
166
|
+
_A("rc2", "RC2", "block-cipher", "not-applicable", "broken", "AES-256",
|
|
167
|
+
"Weak cipher, often with 40-bit keys (for example in legacy PKCS#12 files)."),
|
|
168
|
+
_A("idea", "IDEA", "block-cipher", "not-applicable", "deprecated", "AES-256",
|
|
169
|
+
"64-bit block size; removed from modern TLS."),
|
|
170
|
+
_A("cast5", "CAST5", "block-cipher", "not-applicable", "deprecated", "AES-256",
|
|
171
|
+
"64-bit block size; legacy OpenPGP default."),
|
|
172
|
+
_A("md4", "MD4", "hash", "not-applicable", "broken", "SHA-256 or SHA-3",
|
|
173
|
+
"Collisions can be found by hand; never use."),
|
|
174
|
+
_A("jwt-none", "JWT \"none\" algorithm", "signature", "not-applicable", "broken",
|
|
175
|
+
"RS/ES/EdDSA, or ML-DSA when JOSE support lands",
|
|
176
|
+
"An unsigned JWT can be forged by anyone.", asset_type="protocol"),
|
|
177
|
+
_A("unknown-key", "Key (algorithm not readable)", "other", "not-applicable", "acceptable",
|
|
178
|
+
"Inspect the key to confirm its algorithm and size.",
|
|
179
|
+
"The key is encrypted or in a format the scanner cannot read without a password."),
|
|
180
|
+
_A("chacha20", "ChaCha20-Poly1305", "ae", "resistant", "acceptable", "Keep.",
|
|
181
|
+
"256-bit key; fine against quantum attacks.", classical_security_bits=256, nist_quantum_level=5),
|
|
182
|
+
_A("hmac", "HMAC", "mac", "resistant", "acceptable", "Keep (with SHA-256 or better).", "",
|
|
183
|
+
classical_security_bits=128),
|
|
184
|
+
|
|
185
|
+
# --- Key derivation and random numbers ----------------------------
|
|
186
|
+
_A("pbkdf2", "PBKDF2", "kdf", "resistant", "acceptable",
|
|
187
|
+
"Keep with a high iteration count; Argon2id is preferred for passwords.", ""),
|
|
188
|
+
_A("hkdf", "HKDF", "kdf", "resistant", "acceptable", "Keep.", ""),
|
|
189
|
+
_A("scrypt", "scrypt", "kdf", "resistant", "acceptable", "Keep.", ""),
|
|
190
|
+
_A("argon2", "Argon2", "kdf", "resistant", "acceptable", "Keep.", "Recommended password hash."),
|
|
191
|
+
_A("bcrypt", "bcrypt", "kdf", "resistant", "acceptable", "Keep.", "Password hash."),
|
|
192
|
+
_A("csprng", "Secure random number generator", "drbg", "resistant", "acceptable", "Keep.",
|
|
193
|
+
"Operating-system or library cryptographic random source."),
|
|
194
|
+
|
|
195
|
+
# --- Protocols ----------------------------------------------------
|
|
196
|
+
_A("tls1.0", "TLS 1.0", "other", "not-applicable", "broken", "TLS 1.3",
|
|
197
|
+
"Deprecated by RFC 8996.", asset_type="protocol"),
|
|
198
|
+
_A("tls1.1", "TLS 1.1", "other", "not-applicable", "broken", "TLS 1.3",
|
|
199
|
+
"Deprecated by RFC 8996.", asset_type="protocol"),
|
|
200
|
+
_A("tls1.2", "TLS 1.2", "other", "not-applicable", "acceptable", "TLS 1.3 with hybrid X25519MLKEM768",
|
|
201
|
+
"Fine today; post-quantum hybrid key exchange needs TLS 1.3.", asset_type="protocol"),
|
|
202
|
+
_A("tls1.3", "TLS 1.3", "other", "not-applicable", "acceptable", "Keep; enable X25519MLKEM768",
|
|
203
|
+
"Current version; supports post-quantum hybrid key exchange.", asset_type="protocol"),
|
|
204
|
+
_A("sslv3", "SSL 3.0", "other", "not-applicable", "broken", "TLS 1.3",
|
|
205
|
+
"Broken (POODLE).", asset_type="protocol"),
|
|
206
|
+
]}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
QUANTUM_LABEL = {
|
|
210
|
+
"vulnerable": "Quantum-vulnerable",
|
|
211
|
+
"reduced": "Weakened by quantum",
|
|
212
|
+
"resistant": "Quantum-safe",
|
|
213
|
+
"not-applicable": "n/a",
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def get(alg_id: str) -> Algorithm:
|
|
218
|
+
return CATALOG[alg_id]
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
# OIDs seen inside certificates and keys -> (algorithm id, parameter hint)
|
|
222
|
+
OIDS: dict[str, tuple[str, str | None]] = {
|
|
223
|
+
"1.2.840.113549.1.1.1": ("rsa", None),
|
|
224
|
+
"1.2.840.113549.1.1.4": ("rsa-sig", "MD5"),
|
|
225
|
+
"1.2.840.113549.1.1.5": ("rsa-sig", "SHA-1"),
|
|
226
|
+
"1.2.840.113549.1.1.10": ("rsa-sig", "PSS"),
|
|
227
|
+
"1.2.840.113549.1.1.11": ("rsa-sig", "SHA-256"),
|
|
228
|
+
"1.2.840.113549.1.1.12": ("rsa-sig", "SHA-384"),
|
|
229
|
+
"1.2.840.113549.1.1.13": ("rsa-sig", "SHA-512"),
|
|
230
|
+
"1.2.840.10045.2.1": ("ec", None),
|
|
231
|
+
"1.2.840.10045.4.1": ("ecdsa", "SHA-1"),
|
|
232
|
+
"1.2.840.10045.4.3.2": ("ecdsa", "SHA-256"),
|
|
233
|
+
"1.2.840.10045.4.3.3": ("ecdsa", "SHA-384"),
|
|
234
|
+
"1.2.840.10045.4.3.4": ("ecdsa", "SHA-512"),
|
|
235
|
+
"1.3.101.110": ("x25519", None),
|
|
236
|
+
"1.3.101.111": ("x448", None),
|
|
237
|
+
"1.3.101.112": ("ed25519", None),
|
|
238
|
+
"1.3.101.113": ("ed448", None),
|
|
239
|
+
"1.2.840.10040.4.1": ("dsa", None),
|
|
240
|
+
"1.2.840.10040.4.3": ("dsa", "SHA-1"),
|
|
241
|
+
"1.2.840.113549.1.3.1": ("dh", None),
|
|
242
|
+
"2.16.840.1.101.3.4.3.17": ("ml-dsa", "ML-DSA-44"),
|
|
243
|
+
"2.16.840.1.101.3.4.3.18": ("ml-dsa", "ML-DSA-65"),
|
|
244
|
+
"2.16.840.1.101.3.4.3.19": ("ml-dsa", "ML-DSA-87"),
|
|
245
|
+
"2.16.840.1.101.3.4.4.1": ("ml-kem", "ML-KEM-512"),
|
|
246
|
+
"2.16.840.1.101.3.4.4.2": ("ml-kem", "ML-KEM-768"),
|
|
247
|
+
"2.16.840.1.101.3.4.4.3": ("ml-kem", "ML-KEM-1024"),
|
|
248
|
+
}
|
|
249
|
+
for _n in range(20, 32):
|
|
250
|
+
OIDS[f"2.16.840.1.101.3.4.3.{_n}"] = ("slh-dsa", None)
|
|
251
|
+
OIDS.update({
|
|
252
|
+
"1.2.840.113549.1.9.16.3.17": ("lms", "HSS/LMS"), # id-alg-hss-lms-hashsig (RFC 8708)
|
|
253
|
+
"1.3.6.1.5.5.7.6.34": ("lms", "XMSS"), # id-alg-xmss-hashsig (RFC 9802)
|
|
254
|
+
"1.3.6.1.5.5.7.6.35": ("lms", "XMSS^MT"),
|
|
255
|
+
"1.2.840.113549.1.1.2": ("rsa-sig", "MD2"),
|
|
256
|
+
"1.2.840.113549.1.1.3": ("rsa-sig", "MD4"),
|
|
257
|
+
"1.2.840.113549.1.1.14": ("rsa-sig", "SHA-224"),
|
|
258
|
+
"1.2.840.10040.4.3": ("dsa", "SHA-1"),
|
|
259
|
+
"2.16.840.1.101.3.4.3.2": ("dsa", "SHA-256"),
|
|
260
|
+
})
|
|
261
|
+
# Composite ML-DSA (draft-ietf-lamps-pq-composite-sigs) and the older entrust arcs.
|
|
262
|
+
for _n in range(37, 55):
|
|
263
|
+
OIDS[f"1.3.6.1.5.5.7.6.{_n}"] = ("hybrid-sig", None)
|
|
264
|
+
|
|
265
|
+
# Password-based encryption seen in PKCS#8 and PKCS#12 files -> (algorithm, note)
|
|
266
|
+
PBE_OIDS: dict[str, tuple[str, str]] = {
|
|
267
|
+
"1.2.840.113549.1.12.1.1": ("rc4", "pbeWithSHAAnd128BitRC4"),
|
|
268
|
+
"1.2.840.113549.1.12.1.2": ("rc4", "pbeWithSHAAnd40BitRC4"),
|
|
269
|
+
"1.2.840.113549.1.12.1.3": ("3des", "pbeWithSHAAnd3-KeyTripleDES-CBC"),
|
|
270
|
+
"1.2.840.113549.1.12.1.4": ("3des", "pbeWithSHAAnd2-KeyTripleDES-CBC"),
|
|
271
|
+
"1.2.840.113549.1.12.1.5": ("rc2", "pbeWithSHAAnd128BitRC2-CBC"),
|
|
272
|
+
"1.2.840.113549.1.12.1.6": ("rc2", "pbeWithSHAAnd40BitRC2-CBC"),
|
|
273
|
+
"1.2.840.113549.1.5.3": ("des", "pbeWithMD5AndDES-CBC"),
|
|
274
|
+
"1.2.840.113549.1.5.10": ("des", "pbeWithSHA1AndDES-CBC"),
|
|
275
|
+
"1.2.840.113549.1.5.13": ("pbkdf2", "PBES2"),
|
|
276
|
+
}
|
|
277
|
+
# Ciphers inside PBES2
|
|
278
|
+
CIPHER_OIDS: dict[str, str] = {
|
|
279
|
+
"2.16.840.1.101.3.4.1.2": "aes-128", "2.16.840.1.101.3.4.1.22": "aes-192",
|
|
280
|
+
"2.16.840.1.101.3.4.1.42": "aes-256", "1.2.840.113549.3.7": "3des", "1.3.14.3.2.7": "des",
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
CURVE_OIDS = {
|
|
284
|
+
"1.2.840.10045.3.1.7": "P-256",
|
|
285
|
+
"1.3.132.0.34": "P-384",
|
|
286
|
+
"1.3.132.0.35": "P-521",
|
|
287
|
+
"1.3.132.0.10": "secp256k1",
|
|
288
|
+
}
|