cbomly 0.4.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. {cbomly-0.4.0/src/cbomly.egg-info → cbomly-0.5.0}/PKG-INFO +20 -8
  2. {cbomly-0.4.0 → cbomly-0.5.0}/README.md +19 -7
  3. {cbomly-0.4.0 → cbomly-0.5.0}/pyproject.toml +1 -1
  4. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/__init__.py +1 -1
  5. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/algorithms.py +70 -0
  6. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/cbom.py +3 -3
  7. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/cli.py +90 -6
  8. cbomly-0.5.0/src/cbomly/detect/binary.py +93 -0
  9. cbomly-0.5.0/src/cbomly/detect/configs.py +396 -0
  10. cbomly-0.5.0/src/cbomly/detect/deps.py +148 -0
  11. cbomly-0.5.0/src/cbomly/detect/keys.py +917 -0
  12. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/detect/source.py +211 -2
  13. cbomly-0.5.0/src/cbomly/image.py +268 -0
  14. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/inventory.py +1 -1
  15. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/report.py +1 -1
  16. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/scanner.py +24 -9
  17. cbomly-0.5.0/src/cbomly/tlscheck.py +191 -0
  18. {cbomly-0.4.0 → cbomly-0.5.0/src/cbomly.egg-info}/PKG-INFO +20 -8
  19. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly.egg-info/SOURCES.txt +5 -0
  20. cbomly-0.5.0/tests/test_formats.py +64 -0
  21. cbomly-0.4.0/src/cbomly/detect/deps.py +0 -81
  22. cbomly-0.4.0/src/cbomly/detect/keys.py +0 -319
  23. {cbomly-0.4.0 → cbomly-0.5.0}/LICENSE +0 -0
  24. {cbomly-0.4.0 → cbomly-0.5.0}/NOTICE +0 -0
  25. {cbomly-0.4.0 → cbomly-0.5.0}/setup.cfg +0 -0
  26. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/__main__.py +0 -0
  27. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/cbom_names.py +0 -0
  28. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/detect/__init__.py +0 -0
  29. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/detect/ai.py +0 -0
  30. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/detect/manifest.py +0 -0
  31. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/detect/services.py +0 -0
  32. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/detect/vendors.py +0 -0
  33. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/findings.py +0 -0
  34. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/importer.py +0 -0
  35. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/packs/au.toml +0 -0
  36. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/packs/baseline.toml +0 -0
  37. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/packs/ca.toml +0 -0
  38. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/packs/eu.toml +0 -0
  39. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/packs/india.toml +0 -0
  40. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/packs/jp.toml +0 -0
  41. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/packs/pci-dss.toml +0 -0
  42. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/packs/sg.toml +0 -0
  43. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/packs/uk.toml +0 -0
  44. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/packs/us-cnsa2.toml +0 -0
  45. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/packs/us-fda.toml +0 -0
  46. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/packs/us.toml +0 -0
  47. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/rules.py +0 -0
  48. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/sbom.py +0 -0
  49. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/syft_fetch.py +0 -0
  50. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly/upload.py +0 -0
  51. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly.egg-info/dependency_links.txt +0 -0
  52. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly.egg-info/entry_points.txt +0 -0
  53. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly.egg-info/requires.txt +0 -0
  54. {cbomly-0.4.0 → cbomly-0.5.0}/src/cbomly.egg-info/top_level.txt +0 -0
  55. {cbomly-0.4.0 → cbomly-0.5.0}/tests/test_cli.py +0 -0
  56. {cbomly-0.4.0 → cbomly-0.5.0}/tests/test_keys.py +0 -0
  57. {cbomly-0.4.0 → cbomly-0.5.0}/tests/test_rules.py +0 -0
  58. {cbomly-0.4.0 → cbomly-0.5.0}/tests/test_source.py +0 -0
  59. {cbomly-0.4.0 → cbomly-0.5.0}/tests/test_upload.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cbomly
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: Find the cryptography in your software, write a CycloneDX CBOM, and check it is quantum-safe.
5
5
  Author-email: Cbomly <team@cbomly.com>
6
6
  License-Expression: Apache-2.0
@@ -107,8 +107,12 @@ cbomly scan . --exclude 'testdata' # skip folders or files by name pattern
107
107
  cbomly rules # list rule packs
108
108
  cbomly rules india # show the rules in a pack
109
109
  cbomly import cbom.json -r india # use a CBOM from IBM CBOMkit, cdxgen or another tool instead of scanning
110
+ cbomly scan nginx:1.27 # scan a container image (public registry, local Docker/Podman, or a `docker save` .tar)
111
+ cbomly tls example.com # check a live server you run: TLS versions, post-quantum key exchange, certificates
110
112
  ```
111
113
 
114
+ `cbomly tls` makes ordinary handshakes, like a browser. Only point it at servers you run or are allowed to test.
115
+
112
116
  **Already have a CBOM?** `cbomly import` reads any CycloneDX 1.6+ CBOM, for example from IBM's
113
117
  CBOMkit / Sonar Cryptography plugin or cdxgen. It maps each `cryptographic-asset` (algorithms, keys,
114
118
  certificates, protocols) to Cbomly's catalog by OID or name, keeps the software components as the SBOM, and
@@ -149,15 +153,22 @@ the trend view, alerts for new RSA/ECC and the release gate.
149
153
 
150
154
  | Where | How |
151
155
  |---|---|
152
- | Source code: Python, Java/Kotlin, Go, JavaScript/TypeScript, C/C++, C#, Ruby, PHP, Rust, Swift | Known crypto API calls (e.g. `KeyPairGenerator.getInstance("RSA")`, `rsa.generate_private_key`, `crypto.subtle`, OpenSSL `EVP_*`), including key sizes and curves where written in the code |
153
- | Config files: nginx/Apache, YAML, TOML, properties, JSON | TLS versions, cipher suites, JWT algorithms (`RS256`, `ES256`) |
154
- | Keys and certificates: PEM, DER, SSH keys | Algorithm, key size, curve, signature hash, subject and validity dates. Private keys are flagged as leaks |
155
- | Dependencies (via Syft) | Crypto libraries such as OpenSSL, Bouncy Castle and Go's standard library, and whether the version supports post-quantum algorithms |
156
- | Post-quantum use | ML-KEM, ML-DSA, SLH-DSA and hybrid X25519MLKEM768 are recognised and reported as good news |
156
+ | Source code: Python, Java/Kotlin/Scala, Go, JavaScript/TypeScript, C/C++/Objective-C, C#, Ruby, PHP, Rust, Swift, Dart, Elixir/Erlang | Known crypto API calls, including key sizes and curves where written in the code. Covers the standard libraries plus Bouncy Castle (classic and PQC), OpenSSL, BoringSSL, wolfSSL, Mbed TLS, Botan, libgcrypt, libsodium, CommonCrypto and CryptoKit, ring, rustls, aws-lc-rs, RustCrypto, PyCryptodome, PyNaCl, paramiko, liboqs, crypto-js, noble, jsrsasign, phpseclib, pointycastle and Erlang `:crypto` |
157
+ | Post-quantum APIs | Java 24 ML-KEM/ML-DSA, .NET 10 `MLKem`/`MLDsa`/`SlhDsa`, Apple CryptoKit ML-KEM/ML-DSA/X-Wing, Go `crypto/mlkem`, Bouncy Castle, liboqs, LMS/XMSS, FN-DSA (Falcon), HQC, FrodoKEM, Classic McEliece, composite ML-DSA and hybrid key exchange (X25519MLKEM768, SecP256r1MLKEM768, mlkem768x25519-sha256, sntrup761) |
158
+ | Web, proxy and app server configs | nginx, Apache, HAProxy, Caddy, Envoy, Traefik, Postfix, OpenSSL `openssl.cnf`, Java `java.security`, Spring Boot: TLS versions, cipher suites and key exchange groups, and whether a post-quantum hybrid group is on |
159
+ | SSH | `sshd_config`/`ssh_config` key exchange, host key, cipher and MAC lists; host keys, `authorized_keys`, `known_hosts` |
160
+ | VPN | WireGuard (warns when no PresharedKey), strongSwan/libreswan IKE and ESP proposals (including ML-KEM), OpenVPN cipher, auth, minimum TLS version and DH size |
161
+ | Infrastructure as code | Terraform, CloudFormation and Bicep: `tls_private_key`, AWS/Google/Azure KMS key specs (including ML-DSA), ACM key algorithms, load balancer TLS policies (post-quantum and TLS 1.0/1.1 policies), CloudFront, API Gateway and Azure minimum TLS versions. Kubernetes: cert-manager certificates, Ingress TLS annotations, Istio minimum TLS, and TLS Secrets |
162
+ | Keys and certificates | PEM, DER, PKCS#7 chains, CSRs, PKCS#8 (including how encrypted keys are protected), OpenSSH, PuTTY `.ppk`, OpenPGP/GPG, JWK/JWKS, Java keystores (JKS, JCEKS: certificates are read without the password), PKCS#12 `.p12`/`.pfx` (protection scheme; contents too if the password is empty or a common default and `cryptography` is installed). Algorithm, key size, curve, signature hash, subject and validity dates. Private keys are flagged as leaks |
163
+ | Container images | Every layer of a public image, an image in your local Docker/Podman, or a `docker save` archive. The system CA trust store is counted, not listed |
164
+ | Compiled binaries | Crypto library versions built into ELF, PE and Mach-O files (OpenSSL, LibreSSL, BoringSSL, AWS-LC, wolfSSL, Mbed TLS, GnuTLS, OpenSSH, Dropbear, libsodium, liboqs, Go) and well-known algorithm constants |
165
+ | Live servers (`cbomly tls`) | Accepted TLS versions, supported key exchange groups including X25519MLKEM768, negotiated cipher and the certificate chain |
166
+ | Dependencies (via Syft) | Over 40 crypto library families and runtimes (OpenSSL, Bouncy Castle, wolfSSL, AWS-LC, Tink, libsodium, OpenSSH, Java, .NET, Go and more), with whether the version supports post-quantum algorithms. Abandoned libraries such as PyCrypto and crypto-js are called out |
157
167
  | Third-party crypto services | AWS KMS, CloudHSM, Certificate Manager and Secrets Manager, Google Cloud KMS and Secret Manager, Azure Key Vault, HashiCorp Vault, Thales Luna, YubiHSM, Fortanix, PKCS#11 HSMs, Let's Encrypt and eMudhra, listed as vendors |
158
168
  | AI models | Model files (Safetensors, GGUF, ONNX, PyTorch, TensorFlow, Keras, Core ML, TFLite and more, with SHA-256; Git LFS pointers count too), Hugging Face model ids in code, and hosted models named in code or config (GPT, Claude, Gemini, Llama, Mistral, DeepSeek and others). Pickle-based model files are flagged because they can run code when loaded |
159
169
  | AI libraries | ML frameworks (PyTorch, TensorFlow, Transformers, scikit-learn…), model runtimes (ONNX Runtime, llama.cpp, Ollama, vLLM…), LLM and agent frameworks (LangChain, LlamaIndex, Vercel AI SDK…) and AI provider SDKs, from imports, manifests and the SBOM |
160
170
  | Third-party services (vendor inventory) | About 90 services across AI providers, cloud (per service, e.g. Amazon S3), payments, email, SMS, identity, analytics, monitoring, hosted databases, search and more, found from SDK imports, API hostnames, API-key variable names, manifests (requirements.txt, package.json, go.mod, pom.xml, Gemfile, Cargo.toml, .csproj…) and the SBOM |
171
+ | Weak and broken crypto | MD4, MD5, SHA-1, DES, 3DES, RC2, RC4, Blowfish, IDEA, CAST5, ECB mode, SSL 3.0, TLS 1.0/1.1, JWT `none`, XML-signature `rsa-sha1` (SAML), legacy PKCS#12 encryption |
161
172
  | Safe crypto | AES (with key size and mode), ChaCha20-Poly1305, SHA-2, SHA-3, BLAKE2, HMAC, key derivation (PBKDF2, HKDF, scrypt, Argon2, bcrypt) and secure random number generators. Listed in the CBOM and marked quantum-safe, so the inventory is complete. AES-128 is marked "weakened by quantum" |
162
173
 
163
174
  Every algorithm, certificate, key and protocol gets one status: **broken**, **deprecated**,
@@ -166,8 +177,9 @@ show issuer, public key, signature and expiry. Keys show size or curve. The **Cr
166
177
  who supplies or controls your crypto: library makers, certificate issuers, and key management services.
167
178
  AI detection and the vendor inventory always run; they never send anything anywhere.
168
179
 
169
- Detection is pattern-based, so it is fast and needs no build, but it can miss crypto hidden inside
170
- compiled binaries or wrapper functions, and it can report false positives. Findings carry a
180
+ Detection is pattern-based, so it is fast and needs no build, but it can miss crypto hidden behind
181
+ wrapper functions, and it can report false positives. Constants found in binaries show an algorithm is
182
+ compiled in, not that it is used. Findings carry a
171
183
  confidence level (high, medium, low).
172
184
 
173
185
  ## Rule packs
@@ -81,8 +81,12 @@ cbomly scan . --exclude 'testdata' # skip folders or files by name pattern
81
81
  cbomly rules # list rule packs
82
82
  cbomly rules india # show the rules in a pack
83
83
  cbomly import cbom.json -r india # use a CBOM from IBM CBOMkit, cdxgen or another tool instead of scanning
84
+ cbomly scan nginx:1.27 # scan a container image (public registry, local Docker/Podman, or a `docker save` .tar)
85
+ cbomly tls example.com # check a live server you run: TLS versions, post-quantum key exchange, certificates
84
86
  ```
85
87
 
88
+ `cbomly tls` makes ordinary handshakes, like a browser. Only point it at servers you run or are allowed to test.
89
+
86
90
  **Already have a CBOM?** `cbomly import` reads any CycloneDX 1.6+ CBOM, for example from IBM's
87
91
  CBOMkit / Sonar Cryptography plugin or cdxgen. It maps each `cryptographic-asset` (algorithms, keys,
88
92
  certificates, protocols) to Cbomly's catalog by OID or name, keeps the software components as the SBOM, and
@@ -123,15 +127,22 @@ the trend view, alerts for new RSA/ECC and the release gate.
123
127
 
124
128
  | Where | How |
125
129
  |---|---|
126
- | Source code: Python, Java/Kotlin, Go, JavaScript/TypeScript, C/C++, C#, Ruby, PHP, Rust, Swift | Known crypto API calls (e.g. `KeyPairGenerator.getInstance("RSA")`, `rsa.generate_private_key`, `crypto.subtle`, OpenSSL `EVP_*`), including key sizes and curves where written in the code |
127
- | Config files: nginx/Apache, YAML, TOML, properties, JSON | TLS versions, cipher suites, JWT algorithms (`RS256`, `ES256`) |
128
- | Keys and certificates: PEM, DER, SSH keys | Algorithm, key size, curve, signature hash, subject and validity dates. Private keys are flagged as leaks |
129
- | Dependencies (via Syft) | Crypto libraries such as OpenSSL, Bouncy Castle and Go's standard library, and whether the version supports post-quantum algorithms |
130
- | Post-quantum use | ML-KEM, ML-DSA, SLH-DSA and hybrid X25519MLKEM768 are recognised and reported as good news |
130
+ | Source code: Python, Java/Kotlin/Scala, Go, JavaScript/TypeScript, C/C++/Objective-C, C#, Ruby, PHP, Rust, Swift, Dart, Elixir/Erlang | Known crypto API calls, including key sizes and curves where written in the code. Covers the standard libraries plus Bouncy Castle (classic and PQC), OpenSSL, BoringSSL, wolfSSL, Mbed TLS, Botan, libgcrypt, libsodium, CommonCrypto and CryptoKit, ring, rustls, aws-lc-rs, RustCrypto, PyCryptodome, PyNaCl, paramiko, liboqs, crypto-js, noble, jsrsasign, phpseclib, pointycastle and Erlang `:crypto` |
131
+ | Post-quantum APIs | Java 24 ML-KEM/ML-DSA, .NET 10 `MLKem`/`MLDsa`/`SlhDsa`, Apple CryptoKit ML-KEM/ML-DSA/X-Wing, Go `crypto/mlkem`, Bouncy Castle, liboqs, LMS/XMSS, FN-DSA (Falcon), HQC, FrodoKEM, Classic McEliece, composite ML-DSA and hybrid key exchange (X25519MLKEM768, SecP256r1MLKEM768, mlkem768x25519-sha256, sntrup761) |
132
+ | Web, proxy and app server configs | nginx, Apache, HAProxy, Caddy, Envoy, Traefik, Postfix, OpenSSL `openssl.cnf`, Java `java.security`, Spring Boot: TLS versions, cipher suites and key exchange groups, and whether a post-quantum hybrid group is on |
133
+ | SSH | `sshd_config`/`ssh_config` key exchange, host key, cipher and MAC lists; host keys, `authorized_keys`, `known_hosts` |
134
+ | VPN | WireGuard (warns when no PresharedKey), strongSwan/libreswan IKE and ESP proposals (including ML-KEM), OpenVPN cipher, auth, minimum TLS version and DH size |
135
+ | Infrastructure as code | Terraform, CloudFormation and Bicep: `tls_private_key`, AWS/Google/Azure KMS key specs (including ML-DSA), ACM key algorithms, load balancer TLS policies (post-quantum and TLS 1.0/1.1 policies), CloudFront, API Gateway and Azure minimum TLS versions. Kubernetes: cert-manager certificates, Ingress TLS annotations, Istio minimum TLS, and TLS Secrets |
136
+ | Keys and certificates | PEM, DER, PKCS#7 chains, CSRs, PKCS#8 (including how encrypted keys are protected), OpenSSH, PuTTY `.ppk`, OpenPGP/GPG, JWK/JWKS, Java keystores (JKS, JCEKS: certificates are read without the password), PKCS#12 `.p12`/`.pfx` (protection scheme; contents too if the password is empty or a common default and `cryptography` is installed). Algorithm, key size, curve, signature hash, subject and validity dates. Private keys are flagged as leaks |
137
+ | Container images | Every layer of a public image, an image in your local Docker/Podman, or a `docker save` archive. The system CA trust store is counted, not listed |
138
+ | Compiled binaries | Crypto library versions built into ELF, PE and Mach-O files (OpenSSL, LibreSSL, BoringSSL, AWS-LC, wolfSSL, Mbed TLS, GnuTLS, OpenSSH, Dropbear, libsodium, liboqs, Go) and well-known algorithm constants |
139
+ | Live servers (`cbomly tls`) | Accepted TLS versions, supported key exchange groups including X25519MLKEM768, negotiated cipher and the certificate chain |
140
+ | Dependencies (via Syft) | Over 40 crypto library families and runtimes (OpenSSL, Bouncy Castle, wolfSSL, AWS-LC, Tink, libsodium, OpenSSH, Java, .NET, Go and more), with whether the version supports post-quantum algorithms. Abandoned libraries such as PyCrypto and crypto-js are called out |
131
141
  | Third-party crypto services | AWS KMS, CloudHSM, Certificate Manager and Secrets Manager, Google Cloud KMS and Secret Manager, Azure Key Vault, HashiCorp Vault, Thales Luna, YubiHSM, Fortanix, PKCS#11 HSMs, Let's Encrypt and eMudhra, listed as vendors |
132
142
  | AI models | Model files (Safetensors, GGUF, ONNX, PyTorch, TensorFlow, Keras, Core ML, TFLite and more, with SHA-256; Git LFS pointers count too), Hugging Face model ids in code, and hosted models named in code or config (GPT, Claude, Gemini, Llama, Mistral, DeepSeek and others). Pickle-based model files are flagged because they can run code when loaded |
133
143
  | AI libraries | ML frameworks (PyTorch, TensorFlow, Transformers, scikit-learn…), model runtimes (ONNX Runtime, llama.cpp, Ollama, vLLM…), LLM and agent frameworks (LangChain, LlamaIndex, Vercel AI SDK…) and AI provider SDKs, from imports, manifests and the SBOM |
134
144
  | Third-party services (vendor inventory) | About 90 services across AI providers, cloud (per service, e.g. Amazon S3), payments, email, SMS, identity, analytics, monitoring, hosted databases, search and more, found from SDK imports, API hostnames, API-key variable names, manifests (requirements.txt, package.json, go.mod, pom.xml, Gemfile, Cargo.toml, .csproj…) and the SBOM |
145
+ | Weak and broken crypto | MD4, MD5, SHA-1, DES, 3DES, RC2, RC4, Blowfish, IDEA, CAST5, ECB mode, SSL 3.0, TLS 1.0/1.1, JWT `none`, XML-signature `rsa-sha1` (SAML), legacy PKCS#12 encryption |
135
146
  | Safe crypto | AES (with key size and mode), ChaCha20-Poly1305, SHA-2, SHA-3, BLAKE2, HMAC, key derivation (PBKDF2, HKDF, scrypt, Argon2, bcrypt) and secure random number generators. Listed in the CBOM and marked quantum-safe, so the inventory is complete. AES-128 is marked "weakened by quantum" |
136
147
 
137
148
  Every algorithm, certificate, key and protocol gets one status: **broken**, **deprecated**,
@@ -140,8 +151,9 @@ show issuer, public key, signature and expiry. Keys show size or curve. The **Cr
140
151
  who supplies or controls your crypto: library makers, certificate issuers, and key management services.
141
152
  AI detection and the vendor inventory always run; they never send anything anywhere.
142
153
 
143
- Detection is pattern-based, so it is fast and needs no build, but it can miss crypto hidden inside
144
- compiled binaries or wrapper functions, and it can report false positives. Findings carry a
154
+ Detection is pattern-based, so it is fast and needs no build, but it can miss crypto hidden behind
155
+ wrapper functions, and it can report false positives. Constants found in binaries show an algorithm is
156
+ compiled in, not that it is used. Findings carry a
145
157
  confidence level (high, medium, low).
146
158
 
147
159
  ## Rule packs
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cbomly"
7
- version = "0.4.0"
7
+ version = "0.5.0"
8
8
  description = "Find the cryptography in your software, write a CycloneDX CBOM, and check it is quantum-safe."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -1,3 +1,3 @@
1
1
  """Cbomly: find the cryptography in your software and check it is quantum-safe."""
2
2
 
3
- __version__ = "0.4.0"
3
+ __version__ = "0.5.0"
@@ -103,6 +103,25 @@ CATALOG: dict[str, Algorithm] = {a.id: a for a in [
103
103
  _A("hybrid-kem", "Hybrid X25519MLKEM768", "kem", "resistant", "acceptable",
104
104
  "Keep.", "Classical + post-quantum hybrid key exchange (TLS 1.3).",
105
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),
106
125
 
107
126
  # --- Hashes -------------------------------------------------------
108
127
  _A("md5", "MD5", "hash", "not-applicable", "broken",
@@ -142,6 +161,22 @@ CATALOG: dict[str, Algorithm] = {a.id: a for a in [
142
161
  "Biased keystream; banned in TLS (RFC 7465)."),
143
162
  _A("ecb", "ECB mode", "block-cipher", "not-applicable", "broken", "GCM or another authenticated mode",
144
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."),
145
180
  _A("chacha20", "ChaCha20-Poly1305", "ae", "resistant", "acceptable", "Keep.",
146
181
  "256-bit key; fine against quantum attacks.", classical_security_bits=256, nist_quantum_level=5),
147
182
  _A("hmac", "HMAC", "mac", "resistant", "acceptable", "Keep (with SHA-256 or better).", "",
@@ -162,6 +197,10 @@ CATALOG: dict[str, Algorithm] = {a.id: a for a in [
162
197
  "Deprecated by RFC 8996.", asset_type="protocol"),
163
198
  _A("tls1.1", "TLS 1.1", "other", "not-applicable", "broken", "TLS 1.3",
164
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"),
165
204
  _A("sslv3", "SSL 3.0", "other", "not-applicable", "broken", "TLS 1.3",
166
205
  "Broken (POODLE).", asset_type="protocol"),
167
206
  ]}
@@ -209,6 +248,37 @@ OIDS: dict[str, tuple[str, str | None]] = {
209
248
  }
210
249
  for _n in range(20, 32):
211
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
+ }
212
282
 
213
283
  CURVE_OIDS = {
214
284
  "1.2.840.10045.3.1.7": "P-256",
@@ -168,8 +168,8 @@ def build(findings: list[Finding], sbom: dict | None, target_name: str, crypto_l
168
168
 
169
169
  # 4. keys and certificates as their own assets
170
170
  inv = inventory.build(findings)
171
- for k in inv["keys"]:
172
- ref = _ref("key", f"{k['file']}:{k['line']}:{k['type']}")
171
+ for i, k in enumerate(inv["keys"]):
172
+ ref = _ref("key", f"{k['file']}:{k['line']}:{k['type']}:{i}")
173
173
  prop = {"type": k["type"], "algorithmRef": alg_ref_by_name[k["algorithm"]]}
174
174
  if k["size"]:
175
175
  prop["size"] = k["size"]
@@ -184,7 +184,7 @@ def build(findings: list[Finding], sbom: dict | None, target_name: str, crypto_l
184
184
  })
185
185
  crypto_refs.append(ref)
186
186
  for c in inv["certificates"]:
187
- ref = _ref("certificate", f"{c['file']}:{c['line']}")
187
+ ref = _ref("certificate", f"{c['file']}:{c['line']}:{c.get('subject')}:{c.get('not_after')}")
188
188
  cp = {"certificateFormat": "X.509"}
189
189
  for src, dst in (("subject", "subjectName"), ("issuer", "issuerName"),
190
190
  ("not_before", "notValidBefore"), ("not_after", "notValidAfter")):
@@ -6,10 +6,12 @@ import argparse
6
6
  import json
7
7
  import os
8
8
  import sys
9
+ import tarfile
10
+ import tempfile
9
11
  from datetime import UTC, datetime
10
12
  from pathlib import Path
11
13
 
12
- from . import __version__, algorithms, cbom, inventory, report, rules, sbom, scanner
14
+ from . import __version__, algorithms, cbom, image, inventory, report, rules, sbom, scanner
13
15
  from .detect import ai, deps, vendors
14
16
  from .rules import SEVERITIES
15
17
 
@@ -20,7 +22,9 @@ def _parser() -> argparse.ArgumentParser:
20
22
  sub = p.add_subparsers(dest="cmd", required=True)
21
23
 
22
24
  s = sub.add_parser("scan", help="scan a folder and write a CBOM plus a readable report")
23
- s.add_argument("path", nargs="?", default=".", help="folder (or file) to scan; default: current folder")
25
+ s.add_argument("path", nargs="?", default=".",
26
+ help="folder, file, container image (e.g. nginx:1.27) or `docker save` .tar; default: current folder")
27
+ s.add_argument("--image", action="store_true", help="treat PATH as a container image reference")
24
28
  s.add_argument("-r", "--rules", default="baseline", help="rule pack(s), comma-separated, e.g. india (default: baseline)")
25
29
  s.add_argument("--rules-dir", action="append", default=[], help="extra folder of .toml rule packs")
26
30
  s.add_argument("-o", "--out", default="cbomly-out", help="output folder (default: ./cbomly-out)")
@@ -55,26 +59,61 @@ def _parser() -> argparse.ArgumentParser:
55
59
  im.add_argument("-q", "--quiet", action="store_true")
56
60
  im.add_argument("--no-color", action="store_true")
57
61
 
62
+ t = sub.add_parser("tls", help="check live TLS servers you run: versions, post-quantum key exchange, certificates")
63
+ t.add_argument("hosts", nargs="+", help="host or host:port (default port 443)")
64
+ t.add_argument("-r", "--rules", default="baseline", help="rule pack(s), comma-separated (default: baseline)")
65
+ t.add_argument("--rules-dir", action="append", default=[], help="extra folder of .toml rule packs")
66
+ t.add_argument("-o", "--out", default="cbomly-out", help="output folder (default: ./cbomly-out)")
67
+ t.add_argument("--name", help="product name to put in the reports (default: the first host)")
68
+ t.add_argument("--timeout", type=float, default=8.0, help="seconds per connection (default: 8)")
69
+ t.add_argument("--fail-on", choices=SEVERITIES[:-1], help="exit with code 1 if any issue is this severe or worse")
70
+ t.add_argument("-q", "--quiet", action="store_true")
71
+ t.add_argument("--no-color", action="store_true")
72
+
58
73
  sub.add_parser("doctor", help="check that helper tools are installed")
59
74
  return p
60
75
 
61
76
 
62
77
  def cmd_scan(a) -> int:
78
+ if a.image or image.looks_like_image(a.path) or image.is_image_archive(Path(a.path)):
79
+ return _scan_image(a)
63
80
  target = Path(a.path)
64
81
  if not target.exists():
65
82
  print(f"cbomly: {a.path}: no such file or folder", file=sys.stderr)
66
83
  return 2
67
- name = a.name or target.resolve().name
84
+ return _scan_folder(a, target, a.name or target.resolve().name)
85
+
86
+
87
+ def _scan_image(a) -> int:
88
+ log = (lambda *m: None) if a.quiet else (lambda *m: print(*m, file=sys.stderr))
89
+ with tempfile.TemporaryDirectory(prefix="cbomly-image-") as td:
90
+ root = Path(td)
91
+ log(f"Unpacking container image {a.path}…")
92
+ try:
93
+ info = image.unpack(a.path, root, log)
94
+ except (image.ImageError, OSError, KeyError, ValueError, tarfile.TarError) as e:
95
+ print(f"cbomly: could not read image {a.path}: {e}", file=sys.stderr)
96
+ return 2
97
+ notes = list(info.get("notes", []))
98
+ n_ca = image.trust_store_count(root)
99
+ if n_ca:
100
+ notes.append(f"The image's system trust store holds {n_ca} CA certificates; they are not listed as the product's own.")
101
+ name = a.name or info.get("image") or a.path
102
+ return _scan_folder(a, root, name, extra_excludes=image.TRUST_STORE_NAMES + image.SKIP_DIRS, notes=notes)
103
+
104
+
105
+ def _scan_folder(a, target: Path, name: str, extra_excludes: list[str] | None = None,
106
+ notes: list[str] | None = None) -> int:
68
107
  try:
69
108
  packs = rules.resolve([x.strip() for x in a.rules.split(",") if x.strip()], a.rules_dir)
70
109
  except ValueError as e:
71
110
  print(f"cbomly: {e}", file=sys.stderr)
72
111
  return 2
73
112
  log = (lambda *m: None) if a.quiet else (lambda *m: print(*m, file=sys.stderr))
74
- notes: list[str] = []
113
+ notes = notes or []
75
114
 
76
115
  base = [".git", ".hg", ".svn", "cbomly-out"] if a.include_vendored else list(scanner.DEFAULT_EXCLUDES)
77
- excludes = base + a.exclude + [Path(a.out).name]
116
+ excludes = base + a.exclude + [Path(a.out).name] + (extra_excludes or [])
78
117
 
79
118
  log(f"Scanning {target} for cryptography, AI and third-party services…")
80
119
  findings, stats = scanner.scan_path(target, excludes)
@@ -97,10 +136,36 @@ def cmd_scan(a) -> int:
97
136
  except sbom.SyftError as e:
98
137
  log(f" Syft failed: {e}")
99
138
  notes.append(f"Syft failed, so no software list (SBOM) was produced: {str(e)[:200]}")
139
+ if sb is not None and stats.binary_libs:
140
+ _add_binary_libs(sb, stats.binary_libs)
141
+ elif stats.binary_libs:
142
+ found = ", ".join(sorted({f"{x['library']} {x['version']}".strip() for x in stats.binary_libs}))
143
+ notes.append(f"Crypto libraries compiled into binaries: {found}.")
100
144
 
101
145
  return write_outputs(a, name, packs, findings, sb, stats, notes, tool_versions)
102
146
 
103
147
 
148
+ _LIB_PURL = {"OpenSSL": "openssl", "LibreSSL": "libressl", "BoringSSL": "boringssl", "AWS-LC": "aws-lc",
149
+ "wolfSSL": "wolfssl", "Mbed TLS": "mbedtls", "GnuTLS": "gnutls", "libgcrypt": "libgcrypt",
150
+ "OpenSSH": "openssh", "libsodium": "libsodium", "liboqs": "liboqs"}
151
+
152
+
153
+ def _add_binary_libs(sb: dict, libs: list[dict]) -> None:
154
+ """Crypto libraries found inside binaries become SBOM components (unless Syft already listed them)."""
155
+ have = {(c.get("name", "").lower(), c.get("version")) for c in sb.get("components", [])}
156
+ for lib in libs:
157
+ pname = _LIB_PURL.get(lib["library"])
158
+ if not pname or not lib["version"] or (pname, lib["version"]) in have:
159
+ continue
160
+ have.add((pname, lib["version"]))
161
+ sb.setdefault("components", []).append({
162
+ "type": "library", "name": pname, "version": lib["version"],
163
+ "bom-ref": f"cbomly-binary:{pname}@{lib['version']}",
164
+ "purl": f"pkg:generic/{pname}@{lib['version']}",
165
+ "evidence": {"occurrences": [{"location": lib["file"]}]},
166
+ })
167
+
168
+
104
169
  def write_outputs(a, name, packs, findings, sb, stats, notes, tool_versions, source=None) -> int:
105
170
  """Shared by `scan` and `import`: evaluate rules, write the three output files, print the summary."""
106
171
  libs = deps.crypto_libraries(sb)
@@ -135,6 +200,25 @@ def write_outputs(a, name, packs, findings, sb, stats, notes, tool_versions, sou
135
200
  return 0
136
201
 
137
202
 
203
+ def cmd_tls(a) -> int:
204
+ from . import tlscheck
205
+
206
+ try:
207
+ packs = rules.resolve([x.strip() for x in a.rules.split(",") if x.strip()], a.rules_dir)
208
+ except ValueError as e:
209
+ print(f"cbomly: {e}", file=sys.stderr)
210
+ return 2
211
+ log = (lambda *m: None) if a.quiet else (lambda *m: print(*m, file=sys.stderr))
212
+ findings, notes = [], ["Live TLS check: only test servers you run or are allowed to test."]
213
+ for host in a.hosts:
214
+ fs, ns = tlscheck.check(host, a.timeout, log)
215
+ findings.extend(fs)
216
+ notes.extend(ns)
217
+ stats = scanner.ScanStats()
218
+ source = {"type": "tls", "hosts": a.hosts}
219
+ return write_outputs(a, a.name or a.hosts[0], packs, findings, None, stats, notes, {}, source)
220
+
221
+
138
222
  def cmd_import(a) -> int:
139
223
  from . import importer
140
224
 
@@ -243,7 +327,7 @@ def main(argv: list[str] | None = None) -> int:
243
327
  if hasattr(stream, "reconfigure"):
244
328
  stream.reconfigure(errors="replace")
245
329
  a = _parser().parse_args(argv)
246
- return {"scan": cmd_scan, "import": cmd_import, "rules": cmd_rules, "doctor": cmd_doctor,
330
+ return {"scan": cmd_scan, "import": cmd_import, "tls": cmd_tls, "rules": cmd_rules, "doctor": cmd_doctor,
247
331
  "upload": cmd_upload}[a.cmd](a)
248
332
 
249
333
 
@@ -0,0 +1,93 @@
1
+ """Find crypto inside compiled programs and libraries (ELF, PE, Mach-O).
2
+
3
+ Two signals, both cheap:
4
+ * version strings that crypto libraries compile in ("OpenSSL 1.1.1w",
5
+ "OpenSSH_9.6", "wolfSSL 5.7.2", ...), which tell a buyer which library and
6
+ version a firmware image or container really ships;
7
+ * well-known constants that implementations must contain (the AES S-box,
8
+ SHA-256 round constants, the P-256 prime, ...). These say an algorithm is
9
+ compiled in, not that it is used, so they are reported with lower confidence.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import re
15
+
16
+ from ..findings import Finding
17
+
18
+ MAGICS = (b"\x7fELF", b"MZ", b"\xcf\xfa\xed\xfe", b"\xce\xfa\xed\xfe", b"\xfe\xed\xfa\xcf", b"\xca\xfe\xba\xbe", b"!<arch>")
19
+ BIN_EXTS = {".so", ".dll", ".dylib", ".exe", ".a", ".o", ".bin", ".elf", ".node", ".ko", ".sys", ".efi", ".img", ".fw"}
20
+ BIN_DIRS = {"bin", "sbin", "libexec"}
21
+ MAX_BINARY = 64 * 1024 * 1024
22
+
23
+
24
+ def is_candidate(name: str, ext: str, parent: str) -> bool:
25
+ return ext in BIN_EXTS or ".so." in name or parent in BIN_DIRS
26
+
27
+
28
+ def is_binary(data: bytes) -> bool:
29
+ return data[:7].startswith(MAGICS)
30
+
31
+
32
+ # (library, regex over the bytes, version group)
33
+ VERSIONS = [
34
+ ("OpenSSL", rb"OpenSSL (\d+\.\d+\.\d+[a-z]?)(?:[ -]| +\d)"),
35
+ ("LibreSSL", rb"LibreSSL (\d+\.\d+\.\d+)"),
36
+ ("BoringSSL", rb"(BoringSSL)"),
37
+ ("AWS-LC", rb"AWS-LC (?:FIPS )?(\d+\.\d+\.\d+)"),
38
+ ("wolfSSL", rb"wolfSSL (?:v|version )?(\d+\.\d+\.\d+)"),
39
+ ("Mbed TLS", rb"[Mm]bed ?TLS (\d+\.\d+\.\d+)"),
40
+ ("GnuTLS", rb"GnuTLS (\d+\.\d+\.\d+)"),
41
+ ("libgcrypt", rb"Libgcrypt (\d+\.\d+\.\d+)"),
42
+ ("OpenSSH", rb"OpenSSH_(\d+\.\d+(?:p\d+)?)"),
43
+ ("Dropbear SSH", rb"dropbear_(\d{4}\.\d+)"),
44
+ ("libsodium", rb"libsodium[-/ ](\d+\.\d+\.\d+)"),
45
+ ("Go runtime", rb"\x00go(1\.\d+(?:\.\d+)?)\x00"),
46
+ ("liboqs", rb"liboqs[ -]?(\d+\.\d+\.\d+)"),
47
+ ]
48
+ VERSIONS_C = [(n, re.compile(rx)) for n, rx in VERSIONS]
49
+
50
+ # (algorithm, constant bytes, function, confidence)
51
+ CONSTANTS = [
52
+ ("aes", bytes.fromhex("637c777bf26b6fc53001672bfed7ab76"), "encrypt", "medium"), # AES S-box
53
+ ("aes", bytes.fromhex("c66363a5f87c7c84ee777799f67b7b8d"), "encrypt", "medium"), # AES T-table (big-endian)
54
+ ("aes", bytes.fromhex("a56363c6847c7cf8997777ee8d7b7bf6"), "encrypt", "medium"), # AES T-table (little-endian)
55
+ ("sha256", bytes.fromhex("428a2f9871374491b5c0fbcfe9b5dba5"), "digest", "medium"),
56
+ ("sha256", bytes.fromhex("982f8a4291443771cffbc0b5a5dbb5e9"), "digest", "medium"),
57
+ ("sha512", bytes.fromhex("428a2f98d728ae227137449123ef65cd"), "digest", "medium"),
58
+ ("sha512", bytes.fromhex("22ae28d7982f8a42cd65ef2391443771"), "digest", "medium"),
59
+ ("md5", bytes.fromhex("78a46ad756b7c7e8db702024eecebdc1"), "digest", "medium"), # MD5 T[0..3], little-endian
60
+ ("md5", bytes.fromhex("d76aa478e8c7b756242070dbc1bdceee"), "digest", "medium"),
61
+ ("sha1", bytes.fromhex("9979825aa1ebd96edcbc1b8fd6c162ca"), "digest", "low"), # SHA-1 K0..K3, little-endian
62
+ ("sha1", bytes.fromhex("5a8279996ed9eba18f1bbcdcca62c1d6"), "digest", "low"),
63
+ ("ecdh", bytes.fromhex("ffffffff00000001000000000000000000000000ffffffffffffffffffffffff"), "keyderive", "low"), # P-256 prime
64
+ ("chacha20", b"expand 32-byte k", "encrypt", "low"),
65
+ ("blowfish", bytes.fromhex("243f6a8885a308d313198a2e03707344a4093822"), "encrypt", "low"), # Blowfish P-array
66
+ ("blowfish", bytes.fromhex("886a3f24d308a3852e8a191344737003223809a4"), "encrypt", "low"),
67
+ ]
68
+ NAMES = re.compile(rb"\b(X25519MLKEM768|SecP256r1MLKEM768|mlkem768x25519-sha256|sntrup761x25519-sha512|ML-KEM-(?:512|768|1024)|ML-DSA-(?:44|65|87)|SLH-DSA-[\w-]+)\b")
69
+ NAME_ALG = {b"X25519MLKEM768": "hybrid-kem", b"SecP256r1MLKEM768": "hybrid-kem", b"mlkem768x25519-sha256": "hybrid-kem",
70
+ b"sntrup761x25519-sha512": "sntrup"}
71
+
72
+
73
+ def scan(rel: str, data: bytes) -> tuple[list[Finding], list[dict]]:
74
+ """Return (findings, libraries) for one binary file."""
75
+ findings: list[Finding] = []
76
+ libs: list[dict] = []
77
+ seen_libs = set()
78
+ for name, rx in VERSIONS_C:
79
+ m = rx.search(data)
80
+ if m and name not in seen_libs:
81
+ seen_libs.add(name)
82
+ v = m.group(1).decode("ascii", "replace")
83
+ libs.append({"library": name, "version": "" if v == name else v, "file": rel})
84
+ for alg, const, fn, conf in CONSTANTS:
85
+ if any(f.algorithm == alg for f in findings):
86
+ continue
87
+ if const in data:
88
+ findings.append(Finding(alg, rel, None, f"{alg} constant in binary", "binary", conf, None, fn))
89
+ for m in {m.group(1) for m in NAMES.finditer(data)}:
90
+ alg = NAME_ALG.get(m) or ("ml-kem" if m.startswith(b"ML-KEM") else "ml-dsa" if m.startswith(b"ML-DSA") else "slh-dsa")
91
+ params = m.decode().split("-")[-1] if alg in ("ml-kem", "ml-dsa") else None
92
+ findings.append(Finding(alg, rel, None, m.decode(), "binary", "medium", params))
93
+ return findings, libs