A review of the post-quantum primitives, their stateful-signature store, the OpenPGP RFC 9980 paths, and the X.509, CMS, PKCS#8, key-interface, policy and FIPS-mode integration, done by a reviewer who did not write any of it. The brief was to find what a release that advertises post-quantum by default could not afford: an accepted forgery, a leaked key or plaintext, a reused one-time leaf, or a policy path that silently falls back.
Scope and method
Reviewed, at the state of the main branch after the post-quantum integration work:
src/OneCrypto/Primitives: ML-KEM (MlKemFips203,Internal/MlKemCore), ML-DSA (MlDsa,Internal/MlDsaCore), SLH-DSA, LMS/HSS, XMSS/XMSS^MT,SignatureStateStore, the incremental Keccak sponge,CompositeMlDsa,CompositeMlKem.src/OneCrypto.OpenPgp:PqcSessionKeys, composite and SLH-DSA signature verification inSignatureEngine, recipient selection inMessageWriter, the PKESK parser.src/OneCrypto:PreparedSignature(external-mu state), KEMRecipientInfo inEnvelopedData,PlatformPostQuantum, FIPS-mode dispatch throughSignatureAlgorithms, the path validator,Pkcs/PqPrivateKeys.
Method: the specifications (FIPS 203, 204, 205, SP 800-208, RFC 8554, RFC 8391, RFC 9580, RFC 9629, RFC 9980, the composite drafts) read against the code; mutation probes over every verifier and parser (every field flipped, cut short and extended; the quick run samples positions, ONECRYPTO_PQ_SWEEP=1 flips every byte); crafted malformed hint encodings, out-of-range z, modulus-check and hash-check violations; a differential of the incremental sponge against the platform's SHAKE at every block boundary; for each finding, a test that fails without the fix.
Tests: tests/OneCrypto.Tests/Primitives/PqReviewProbeTests.cs, PqReviewStateTests.cs, tests/OneCrypto.Tests/Keys/PqIntegrationReviewTests.cs, tests/OneCrypto.OpenPgp.Tests/Review/PqReviewTests.cs.
Findings
| # | Severity | Finding | Spec | Test | Fix |
|---|---|---|---|---|---|
| 1 | medium | In FIPS mode the path validator checked certificate, CRL and OCSP signatures with the library's own ML-DSA and SLH-DSA: the switch reached only direct PublicKeyInfo.VerifySignature calls with a policy and CMS verification. A caller who set FipsMode for a validated module got unvalidated code in the chain check, with no sign of it. | the documented FIPS-mode contract | PqIntegrationReviewTests.FipsModeNeverVerifiesAChainSignatureOrACompositeWithTheLibrarysOwnMlDsa | The validator passes its policy's switch to the signature checks. |
| 2 | medium | In FIPS mode a composite ML-DSA signature check and a composite ML-KEM recipient ran on the library's own ML-DSA and ML-KEM, because the platform has no composite and the code did not say so. | the documented FIPS-mode contract ("never falls back") | FipsModeNeverVerifies..., FipsModeRefusesACompositeKemRecipientInsteadOfSwitching... | Both now fail with AlgorithmNotSupported naming the algorithm. |
| 3 | medium | Documentation overstated FIPS mode ("every ML-KEM, ML-DSA and SLH-DSA operation"): key generation, signing and decapsulation with library-held keys were not routed, so a FIPS-mode caller could still run them on the library's own code. | the documented FIPS-mode contract | FipsOperationTests (platform copy does the work: the library's key is disposed after the hand-over and the interface key still signs or decapsulates; refusal where the platform lacks the algorithm), PqReviewTests.FipsModeRefusesOpenPgpPostQuantumOperations... | Policy overloads of PrivateKey and CmsDecryptionKey and policy-aware key generation hand ML-DSA, SLH-DSA and ML-KEM keys to the platform (PlatformPostQuantum); composites, LMS/HSS, XMSS/XMSS^MT and OpenPGP post-quantum keys are refused. docs/policy.md and docs/pq.md state it. Keys loaded without a policy are still the library's own: wrap them with the policy overloads. |
| 4 | medium | RFC 9980 §3.5 binds the post-quantum algorithms to key versions (ML-DSA, SLH-DSA and ML-KEM-1024 + X448 to version 6; ML-KEM-768 + X25519 also to version 4 encryption subkeys). Nothing enforced it, so a version 4 key carrying an ML-DSA or SLH-DSA key was accepted for verification, and a version 4 ML-KEM-1024 key for encryption and decryption. | RFC 9980 §3.5, §4.3.2, §5.3.2 | PqReviewTests.PostQuantumAlgorithmsAreBoundToKeyVersions | PqcSessionKeys.KeyVersionAllowed, applied in signature verification, session-key decryption and recipient selection. |
| 5 | low | PostQuantumMode.Off did not influence OpenPGP encryption: a recipient with a post-quantum subkey always got it, so the Permissive preset could not be used to ask for classical encryption except per recipient. | the post-quantum encryption defaults | PqReviewTests.PostQuantumModeOffPrefers... | Off prefers the classical subkey for every recipient; a recipient who has only a post-quantum key still gets it. |
| 6 | low | A truncated signature state file raised EndOfStreamException instead of SignatureStateException. The key still could not sign, but a caller handling the documented damage error missed it. | SP 800-208 §8.1 (state integrity) | PqReviewStateTests.ATruncatedStateFileIsReportedAsDamage... | Reported as damage. |
| 7 | low | An in-memory state store constructed beyond the key's capacity made Remaining wrap around to a huge number; signing was still refused. | PqReviewStateTests.AStoreStartedBeyondTheKeysCapacity... | Refused when bound to a key. | |
| 8 | low | The KEM secret in KEMRecipientInfo opening stayed in memory on the refused-wrap-size and unsupported-KDF paths; ML-DSA hedging randomness was not wiped after signing. | covered by the KEM mutation test (behaviour unchanged) | Wiped on every path. | |
| 9 | note | The two-record file store cannot tell a torn newest record (a crash during the write, where falling back to the older record is right) from later damage to a record that was already acknowledged (where falling back repeats the last reservation). Media corruption of exactly the newest record therefore rolls the counter back by one reservation. | SP 800-208 §8.1 | SignatureStateTests.FileStoreSurvivesATornNewestRecord... pins the torn-write behaviour | Not fixed: indistinguishable without a third record or an external witness. Documented limit: copies, restores and corrupted media void the guarantee, as the type's remarks say. Keys with reservation sizes above one waste leaves rather than repeat them. |
| 10 | note | The file store's exclusion is the file-sharing lock of the .NET runtime, which on Unix is advisory between .NET processes only. | ConcurrentSignersOnOneFileNeverCollide (separate store objects, threads) | Not fixed; no cross-process test was added, only separate store objects over one file. | |
| 11 | note | LMS/HSS/XMSS keys cannot detect a copied key: two processes holding the same exported key with separate stores both sign the same leaves. Inherent to the design; the export format records the counter and the docs say a key must have exactly one state. | SP 800-208 §9.1 | ARestoredOlderExportCannotRepeatALeaf... shows the store moving forward only | none |
Found sound
- ML-KEM. Implicit rejection is a full comparison followed by a mask select; every mutated ciphertext position gives exactly
SHAKE256(z || c)(checked against the platform's SHAKE); the §7.2 modulus check and §7.3 hash check apply in every import path; wrong lengths, disposed keys and swapped parameter sets fail without writing output. - ML-DSA. Hint decoding refuses every non-canonical form (descending or over-long counts, unsorted or repeated positions, non-zero padding);
‖z‖∞is checked againstγ1 − β; the context length, mu length and digest length are checked; HashML-DSA binds the hash identifier and does not cross-verify with the pure scheme. Verification never throws on malformed input. - SLH-DSA. Every mutation, truncation and extension of a signature is a plain rejection; the pre-hash identifier and the context are bound.
- LMS/HSS, XMSS/XMSS^MT. Every field of a signature is checked before hashing; no mutation is accepted; HSS level counts that disagree between key and signature are refused. A leaf is reserved durably before it is used, a failing store releases no signature, a batched key counts its unused leaves as used on export, concurrent signers on one key object and on separate store objects over one file never repeat a leaf, and exhaustion is a typed error.
- Keccak. The incremental sponge equals the platform's SHAKE for absorb and squeeze split at, before and after every rate boundary.
- OpenPGP RFC 9980. The combiner (
SHA3-256(mlkem || ecdh || ecdhCiphertext || ecdhPublic || algId || domSep || len)), the packet field lengths, the AES-only restriction on version 3 packets, the key-length check against the symmetric algorithm, algorithm matching between packet and key, and fail-closed unwrapping all follow §4. Composite signatures need both components, version 6, and a digest of at least 256 bits; a flipped bit in either component and a splice of components from two signatures are refused. - Composite ML-DSA and ML-KEM (drafts). The representative, label and context binding follow the drafts; both halves must verify; every mutation, cut and extension of a composite signature is refused; altered ML-KEM parts give an unrelated secret and altered traditional parts give an unrelated secret or a typed
CryptographicException. - KEMRecipientInfo. Every failure (decapsulation, KDF, wrap size, unwrap, content-encryption-key length) is "could not decrypt"; damage to the recipient part never changes what opens.
- External-mu state. The serialised state binds key, scheme, context, data and mu; any damaged byte other than the free-text purpose label is rejected; a signature over another document, by another key, or in another form does not complete it.
- PKCS#8. Seed, expanded and both forms: a both-form key whose parts disagree is refused; damaged keys give typed errors.
Not covered
Timing re-runs were not needed: no secret-handling arithmetic changed. Interop with OpenSSL, Sequoia and Botan was not re-run beyond the existing suites. The cross-process behaviour of the state-file lock was only exercised with separate store objects in one process.