---
title: "Cryptographic inventory: onecrypto scan"
url: https://recursiveai.org/onecrypto/docs/scan/
description: "onecrypto scan lists every cryptographic asset it can parse in files, directories, archives and mail stores, classifies each one for post-quantum readiness, and writes a CycloneDX 1.6 CBOM and a fix list. It only reads, and touches the network only with --tls."
version: "0.5.0-preview.1"
source: https://github.com/recursive-ai-oss/onecrypto-csharp/blob/d80bcb8eb948150b8c78f357b8b6fa4fe88df7b3/docs/scan.md
---

# Cryptographic inventory: `onecrypto scan`

`onecrypto scan` answers "where is my quantum-vulnerable cryptography?". It reads files, directories and the archives and mail stores inside them, lists every cryptographic asset it can parse, classifies each one, and writes a CycloneDX 1.6 CBOM and a fix list. It only reads: nothing is modified, no private key is exported, and nothing touches the network unless `--tls` is given.

```
onecrypto scan <path>... [--tls host[:port]]... [--os-stores] [--cbom out.cdx.json] [--report out.md] [--json]
               [--at TIME] [--password-file FILE] [--max-depth N] [--max-expanded N] [--follow-symlinks] [--fail-on LEVEL]
```

Exit status: 0 done, 1 a finding at or above `--fail-on`, 2 bad usage. The library entry point is `CryptoInventory.Scan(paths)` (core formats only); `InventoryScanner` takes `ScanOptions` (detectors, classifier, reference time, limits) and `InventoryReport` holds assets, findings, issues and statistics.

## What is inventoried

| Family | Assets |
|---|---|
| X.509 | certificates and chains, CSRs, CRLs, OCSP responses (PEM, DER, PKCS #7 bundles); raw public keys |
| PKCS | PKCS #8 plain and encrypted (algorithm and KDF only, no password needed), PKCS #1 and SEC1 keys, legacy `DEK-Info` PEM, PKCS #12 outer algorithms without a password and contents with `--password-file` |
| OpenSSH | private and public keys, certificates, `authorized_keys`, `known_hosts` (hashed hosts included), `allowed_signers`, SSHSIG |
| OpenPGP | keys and keyrings, GnuPG keybox, `private-keys-v1.d`, `trustdb.gpg`, signatures, encrypted messages (recipient key algorithms from the public-key encrypted session key packets, nothing decrypted) |
| CMS | signed, enveloped and authenticated-enveloped data (`.p7m`, `.p7s`, S/MIME in mail), RFC 3161 tokens; signer certificates, recipient key types, KEMRecipientInfo |
| PDF | signature algorithms, signer chain, PAdES level |
| Mail | `.eml`, mbox, PST/OST and MSG through OneMail: S/MIME and OpenPGP (PGP/MIME and inline) in bodies and attachments |
| Archives | zip, tar, gz, 7z and the other OneArchive formats, recursively; ZipCrypto, WinZip AES and 7z AES are reported as findings of their own |
| OS stores | `--os-stores`: anchors and personal certificates, key algorithm only |
| TLS | `--tls`: protocol, cipher suite, certificate chain, and hybrid post-quantum key exchange (below) |

Post-quantum assets that exist in the wild are recognised: ML-DSA, SLH-DSA and composite ML-DSA certificates, ML-KEM keys and KEMRecipientInfo, RFC 9980 OpenPGP keys, LMS/HSS and XMSS/XMSS^MT keys. Anything unparseable that looks cryptographic by name or header is listed as an issue with its reason (`Malformed`, `Encrypted`, `LimitExceeded`, `Unreadable`); the scan never stops on it.

## Classification

Each algorithm use gets one verdict: `QuantumVulnerable` (RSA, DSA, DH, elliptic curves, EdDSA, X25519), `Hybrid`, `PostQuantum`, `SymmetricOk`, `Weak` (MD5, SHA-1 signatures, RSA under 2048 bits, 3DES and other 64-bit ciphers, ZipCrypto) or `Unknown`. Weak SHA-1 and RSA sizes come from `CryptoPolicy.Standard`; the post-quantum table is the scan's own. The classifier is behind `IReadinessClassifier`, so a different rule set can be supplied through `ScanOptions.Classifier`.

For each asset that needs action there is one finding with a severity (`Info` to `High`; the single most severe reason wins), the reason (quantum-vulnerable public-key algorithm, harvest-now-decrypt-later exposure for encryption keys and encrypted data, weak or deprecated algorithm, expiry), the CNSA 2.0 or NIST IR 8547 timeline that applies to the use (signing, web, network, encryption, general), and a fix verb with the command line it will take:

| Verb | For | Command shape |
|---|---|---|
| `reissue` | certificates and keys from our CA or ACME | `onecrypto fix reissue <location> --to ml-dsa-65` |
| `re-sign` | signed PDFs, CMS, OpenPGP and code-signing artefacts | `onecrypto fix re-sign <location> --to ml-dsa-65` |
| `re-encrypt` | CMS/S-MIME, OpenPGP, age, encrypted archives | `onecrypto fix re-encrypt <location> --to x25519-ml-kem-768` |
| `rotate` | SSH and OpenPGP keys | `onecrypto fix rotate <location> --to ed25519` |
| `reconfigure` | TLS endpoints | change the server's key-exchange groups |

SSH keys that are quantum-vulnerable are reported at `Info` because OpenSSH has no post-quantum host or user key type to rotate to yet. The scan only prints the commands. `onecrypto fix` runs them (see [fix.md](https://recursiveai.org/onecrypto/docs/fix/)); `onecrypto fix --from scan.json` applies a whole fix list from `scan --json`.

A location is `path!member!member` (an archive member, a mail message part, a certificate in a signature), with `:line` for line-oriented files.

## CBOM

`--cbom` writes CycloneDX 1.6 JSON (ECMA-424) with a deterministic serial number for a given input and reference time:

- every asset is a `cryptographic-asset` component: `algorithm`, `certificate`, `related-crypto-material` (keys, signatures, encrypted data, key stores) or `protocol` (TLS endpoints), with `cryptoProperties` (primitive, parameter set, curve, classical and NIST quantum security level, certificate validity, key and protection details);
- `dependencies` link each certificate and key to its algorithms;
- the file location of every asset is evidence (`evidence.occurrences`);
- the scan's own verdict and the fix verb are properties.

The output is validated against the published CycloneDX 1.6 JSON schema by `tools/scan/validate-cbom.py` (the schema is fetched at a pinned commit by `tools/scan/fetch-cyclonedx-schema.sh`; set `ONECRYPTO_CYCLONEDX_SCHEMA` to its directory and the test suite validates the corpus CBOM).

## TLS probe

`--tls host[:port]` connects to exactly the hosts named. The BCL `SslStream` handshake reports the protocol, cipher suite and certificate chain. Then three hand-built TLS 1.3 ClientHellos find the key-exchange groups: one per hybrid group with only that group in `supported_groups` (a ServerHello or a HelloRetryRequest selecting it means supported; a handshake alert means not), and one preference probe offering `X25519MLKEM768`, `x25519` and `secp256r1` with a key share for x25519 only. Code points are from the IANA TLS Supported Groups registry (`X25519MLKEM768` 0x11EC, `SecP256r1MLKEM768` 0x11EB, `SecP384r1MLKEM1024` 0x11ED, `MLKEM768` 0x0201, `MLKEM1024` 0x0202); message layouts are RFC 8446 section 4.1 to 4.2. Every probe stops after the server's first flight; there is no key exchange and no TLS transport. The probe has a timeout, follows no redirects, and offers no private key or credential. It contacts exactly the hosts named on the command line and does not apply the library's address guard for loopback, link-local and private ranges, because the user chose the host; nothing else is ever contacted and no host is taken from a scanned file. A server that prefers x25519 when given an x25519 share (OpenSSL does) still shows `Supported` for the hybrid group in the per-group result; the preference value tells which group wins when the client has a share ready.

On macOS the platform's `SslStream` cannot negotiate TLS 1.3 (the handshake fails with "bad protocol version"), so there the protocol, cipher suite and certificate fields stay empty with the error recorded, while the group detection, which uses the hand-built ClientHellos, works the same on every platform.

## Limits (on by default)

Archive nesting 8, whole-file read 32 MiB, 2 GiB expanded in total, 2 million items, 200,000 members per container, 64 MiB per member (a larger member is reported as `LimitExceeded` and not opened), symbolic links skipped. The first three can be changed with `--max-depth` and `--max-expanded` or `ScanOptions`; reaching a limit is a typed issue on that item and the scan carries on.

## Corpus

`testdata/scan/` is generated by `tools/scan/gen-corpus.sh` (OpenSSL, `ssh-keygen`, GnuPG, `zip`, `7z`) and `tools/scan/GenCorpus` (signed PDFs, a PST and MSG files written by OneMail), from throwaway keys committed on purpose. It holds ML-DSA-44/65/87 and SLH-DSA certificates, requests and keys, the three private-key forms OpenSSL writes for ML-DSA and ML-KEM (seed only, expanded only, both), an ML-DSA SignedData and a KEMRecipientInfo message to an ML-KEM-768 recipient. OpenSSL 3.5 cannot encrypt to an ML-KEM recipient, so that one file comes from OpenSSL 3.6 (`OPENSSL_KEM`); `VERSIONS.txt` says so. `VERSIONS.txt` records the generator versions. `tests/OneCrypto.Scan.Tests` asserts the expected inventory per file, the hostile samples (an expansion bomb and a twelve-level archive), the classifier table and the CBOM schema validation.
