| 1 |
# CryptoDataHub |
| 2 |
|
| 3 |
A repository of cryptography-related data available under a free license, with a Python wrapper. Ships algorithm identifiers, Diffie-Hellman and elliptic curve parameters, trust stores, Certificate Transparency log lists, client capabilities and vulnerability data as JSON, exposed as typed enumerations. Consumed by CryptoParser and CryptoLyzer. |
| 4 |
|
| 5 |
## Files |
| 6 |
|
| 7 |
### Project Root |
| 8 |
- `pyproject.toml` — Build system, dependencies, metadata (setuptools + setuptools-scm) |
| 9 |
- `setup.py` — Delegates to pyproject.toml |
| 10 |
- `README.md` — Project overview, install instructions, license |
| 11 |
- `CHANGELOG.rst` — Versioned changelog |
| 12 |
- `CONTRIBUTING.md` — Contribution guidelines |
| 13 |
- `LICENSE.txt` — MPL-2.0 |
| 14 |
|
| 15 |
### Common Infrastructure (`cryptodatahub/common/`) |
| 16 |
- `types.py` — Data loading engine: `CryptoDataEnumBase`, `CryptoDataEnumCodedBase`, `CryptoDataEnumOIDBase`, `CryptoDataEnumBinaryBase`, `CryptoDataParamsBase`, `CryptoDataParamsNamed`, and the converters that turn JSON values into typed attributes (`convert_enum`, `convert_datetime`, `convert_base64_data`, `convert_hex_data`, `convert_mapping`, `convert_variadic`) |
| 17 |
- `algorithm.py` — Protocol-independent algorithm enumerations: `Authentication`, `BlockCipher`, `BlockCipherMode`, `Hash`, `KeyExchange`, `MAC`, `MACMode`, `Signature`, `IpProtocolNumber`, `NistSecurityLevel` |
| 18 |
- `grade.py` — Security grading: `Grade`, `Gradeable`, `GradeableSimple`, `GradeableVulnerabilities`, `GradeableComplex`, `Vulnerability`, `AttackType`, `AttackNamed` |
| 19 |
- `parameter.py` — Well-known parameters, sharing one shape in `ParamWellKnownBase`: `DHParamWellKnownBase`, `DHParameterNumbers`, `ECParamWellKnownBase`, `ECParameterForm`, the seven `ECParameterNumbers` classes, `StandardParams`, `PaperParams` |
| 20 |
- `pqc.py` — Post-quantum registries: `KeyEncapsulationMechanism`, `HybridNamedGroup`, and the key parameter helpers every protocol code point resolves through (`KEY_PARAMETER_REGISTRIES`, `KeyParameter`, `convert_key_parameter`, `validate_key_parameter`) |
| 21 |
- `key.py` — Public key handling: `PublicKey`, `PublicKeySigned`, `PublicKeyX509Base`, `PublicKeySize`, per-algorithm parameter classes (RSA, DSA, ECDSA, EdDSA) |
| 22 |
- `stores.py` — Trust stores: `RootCertificateBase`, `RootCertificateParams`, `CertificateTransparencyLogBase`, `CertificateTransparencyOperator`, `CertificateTrustConstraint` |
| 23 |
- `entity.py` — Entities: `EntityBase`, `EntityType`, `EntityRole`, `ClientType`, `ServerType` |
| 24 |
- `client.py` — Client capability base classes: `ClientVersionedParamsBase`, `ClientParamsBase`, `ClientConfigurationChange` |
| 25 |
- `fetcher.py` — Source fetchers used by the updaters: Certificate Transparency log stores (Google, Apple), root certificate stores (Android, Apple, Chrome, Microsoft, Mozilla, OpenJDK, Oracle JDK) |
| 26 |
- `exception.py` — Exceptions: `InvalidValue` |
| 27 |
- `utils.py` — Utility: `bytes_to_hex_string()`, `bytes_from_hex_string()`, `name_to_enum_item_name()`, `hash_bytes()`, `HttpFetcher` |
| 28 |
|
| 29 |
### TLS/SSL (`cryptodatahub/tls/`) |
| 30 |
- `algorithm.py` — TLS algorithm enumerations: cipher suites, SSL cipher kinds, named curves, hash and signature algorithms, extension types, compression methods, EC point formats, protocol names, GREASE values |
| 31 |
- `version.py` — TLS and SSL protocol version data |
| 32 |
- `client.py` — Client capability data of browsers and libraries |
| 33 |
|
| 34 |
### SSH (`cryptodatahub/ssh/`) |
| 35 |
- `algorithm.py` — SSH algorithm enumerations: encryption, MAC, key exchange, host key, compression algorithms, elliptic curve identifiers |
| 36 |
|
| 37 |
### IKE (`cryptodatahub/ike/`) |
| 38 |
- `algorithm.py` — IKEv1 and IKEv2 algorithm enumerations: encryption, hash, integrity, pseudorandom function, Diffie-Hellman group, authentication method, transform, payload, notify and exchange types, vendor identifiers |
| 39 |
- `version.py` — ISAKMP and IKE version data |
| 40 |
|
| 41 |
### DNSSEC (`cryptodatahub/dnsrec/`) |
| 42 |
- `algorithm.py` — DNSSEC algorithm enumerations: DNSKEY algorithms, digest types, resource record types, SSHFP algorithms and fingerprint types |
| 43 |
|
| 44 |
### Data (`cryptodatahub/*/*.json`) |
| 45 |
- One JSON file per enumeration, named after it (`tls/cipher-suite.json`, `common/root-certificate.json`, `ike/ikev2-diffie-hellman-group.json`, …) |
| 46 |
- Loaded lazily by the enumeration classes in the module next to them |
| 47 |
- Packaged via `[tool.setuptools.package-data]` in `pyproject.toml` |
| 48 |
|
| 49 |
### Updaters (`updaters/`) |
| 50 |
- `ct_log.py` — Regenerates `common/certificate-transparency-log.json`, entry point `update-ct-log` |
| 51 |
- `trust_stores.py` — Regenerates `common/root-certificate.json`, entry point `update-trust-stores` |
| 52 |
- `common.py` — Shared updater infrastructure |
| 53 |
|
| 54 |
### Tests (`test/`) |
| 55 |
- `test/common/` — Common infrastructure tests: types and converters, algorithms, grading, parameters, keys, stores, entities, exceptions, utilities |
| 56 |
- `test/tls/` — TLS data tests: algorithms, versions, client capabilities |
| 57 |
- `test/ssh/` — SSH algorithm data tests |
| 58 |
- `test/ike/` — IKE algorithm data tests |
| 59 |
- `test/dnsrec/`, `test/dnssec/` — DNSSEC algorithm data tests |
| 60 |
- `test/updaters/` — Updater tests: Certificate Transparency logs, trust stores, shared updater infrastructure |
| 61 |
|
| 62 |
## Architecture |
| 63 |
|
| 64 |
The project separates the data from the code that exposes it: |
| 65 |
|
| 66 |
1. **Data** — JSON files next to the module that owns them, one file per enumeration. |
| 67 |
2. **Loading** (`common/types.py`) — `CryptoDataEnumBase` reads the JSON file belonging to the enumeration and builds its members from the entries. Converters map JSON values to typed attributes. |
| 68 |
3. **Parameter classes** — Each enumeration member carries a parameter object (`CryptoDataParamsBase` subclass) holding its code point, name, and algorithm-specific attributes. |
| 69 |
4. **Grading** (`common/grade.py`) — Parameter classes mix in `GradeableSimple`, `GradeableVulnerabilities` or `GradeableComplex`, so a member can report its security grade and the vulnerabilities affecting it. |
| 70 |
5. **Updaters** (`updaters/`) — Fetch the original sources and regenerate the JSON files, so the data can be refreshed without hand editing. |
| 71 |
|
| 72 |
## Key Patterns |
| 73 |
|
| 74 |
- Enumeration classes subclass `CryptoDataEnumBase` and gain lookup classmethods built on `_from_attr()`, for example `from_code()` on `CryptoDataEnumCodedBase` and `from_oid()` on `CryptoDataEnumOIDBase` |
| 75 |
- Parameter classes are `@attr.s` (attrs library) data classes with validators |
| 76 |
- Converters are factory functions returning a converter object, passed to `attr.ib(converter=...)` |
| 77 |
- Data files are never edited by hand where an updater exists for them |