Testing & Validation
A correct post-quantum implementation must prove it matches the standard bit-for-bit and, for regulated environments, earn a FIPS 140-3 certificate. This page covers Known Answer Tests, NIST's ACVP/CAVP programs, and what you actually need to test.
Two kinds of assurance
There are two distinct questions to answer about any PQC deployment. First, does the implementation compute the standardized algorithm correctly? — answered by test vectors and the ACVP/CAVP validation programs. Second, does it resist side-channel leakage? — a separate concern covered under side channels, because passing functional tests says nothing about timing or power leaks.
Known Answer Tests (KATs) and test vectors
For validating FIPS 203/204/205 implementations, use the final-standard test vectors published or generated by NIST CAVP/ACVP; do not mix in intermediate values from the draft-FIPS phase or third-party copies. These Known Answer Tests pair fixed inputs (seeds, messages) with the exact expected outputs (keys, ciphertexts, shared secrets, signatures) for every parameter set, and a conforming implementation must reproduce them byte-for-byte.
- Deterministic per parameter set. KATs are provided for each parameter set (ML-KEM-512/768/1024, ML-DSA-44/65/87, the SLH-DSA variants), seeded so output is reproducible.
- First gate in CI. Run KATs on every build and platform; they catch endianness bugs, NTT errors, and incorrect domain separation immediately.
- Source of truth. Use the official NIST test vectors and the reference implementations that accompany the standards as the authority, not a third-party copy.
ACVP and CAVP
For FIPS 140-3 validation, NIST runs two programs that work together:
- ACVP — Automated Cryptographic Validation Protocol. A protocol and server that issue test vectors to your module and check its responses automatically. It supersedes the old static-file flow with a request/response exchange covering many edge cases.
- CAVP — Cryptographic Algorithm Validation Program. The program under which an algorithm implementation is validated (via ACVP) and issued an algorithm certificate. CAVP validation is a prerequisite for the module-level CMVP / FIPS 140-3 certificate.
The chain is: pass ACVP tests for the algorithm → earn a CAVP certificate → include it in a FIPS 140-3 module validation (CMVP). Only the module certificate, scoped to specific algorithms and parameter sets, lets you claim compliance.
CAVP/ACVP validates the algorithm implementation; CMVP/FIPS 140-3 validates the cryptographic module that contains the algorithm implementation. An algorithm certificate is an essential component of module validation, but algorithm validation alone cannot substitute for a module certificate.
The FIPS algorithm boundary
Validation applies to a defined cryptographic boundary — a specific module version, build, and set of algorithms. ML-KEM, ML-DSA, and SLH-DSA each have their own validation scope. A library "supporting" an algorithm is not the same as that algorithm being inside a validated boundary, so confirm the certificate covers the exact parameter set you ship.
What to actually test
- KAT conformance for every parameter set, on every target platform and build configuration.
- Signing determinism modes. ML-DSA supports both a deterministic (hedged-off) and a randomized signing mode — test both, and confirm deterministic mode reproduces the KAT signatures exactly.
- KEM decapsulation failure handling. Feed malformed and tampered ciphertexts and verify the implementation follows FIPS 203 implicit-rejection logic: the bad-ciphertext path still produces a pseudorandom shared secret, and must not reveal a "decapsulation failure" through a return code, log, timing, or error branch (the failure-oracle risk from side channels).
- Round-trip property tests. Random keygen → encaps/sign → decaps/verify across many iterations to catch low-probability decapsulation-failure handling.
- Interoperability. Cross-test against a second independent implementation (e.g. your library vs OpenSSL) to confirm wire-format agreement.
- Negative tests. Wrong-key, truncated-input, and bit-flipped-signature cases must all be rejected.
Related
Standards →
The FIPS documents that define the test vectors.
Side channels →
What functional testing cannot catch.
Library matrix →
Which libraries are FIPS-validated.
ML-DSA →
Deterministic vs randomized signing modes.
Standards & references
- NIST CAVP/ACVP — the algorithm validation program and protocol.
- FIPS 203 (ML-KEM) — standard and Known Answer Tests.
- FIPS 204 (ML-DSA) — standard and Known Answer Tests.
- FIPS 205 (SLH-DSA) — standard and Known Answer Tests.
- NIST PQC project — official test vectors and reference implementations.
- Resources — full standards register
测试与验证
一个正确的后量子实现必须证明自己逐比特符合标准,在受监管环境中还要取得 FIPS 140-3 证书。本页讲解已知答案测试、NIST 的 ACVP/CAVP 程序,以及实际需要测什么。
两类保证
对任何 PQC 部署,都需要回答两个不同的问题。其一,实现是否正确计算了标准化算法?这由测试向量与 ACVP/CAVP 验证程序回答。其二,它是否抵御侧信道泄漏?这是另一个层面的问题(见 侧信道),因为通过功能测试并不能说明任何关于时序或功耗泄漏的情况。
已知答案测试 KAT 与测试向量
对 FIPS 203/204/205 的实现验证,应使用 NIST CAVP/ACVP 发布或生成的 final 标准测试向量;不要混用 draft FIPS 阶段的中间值或第三方副本。这些已知答案测试以固定的输入(种子、消息)配以每个参数集精确的预期输出(密钥、密文、共享密钥、签名);符合标准的实现必须逐字节重现它们。
- 按参数集确定。每个参数集(ML-KEM-512/768/1024、ML-DSA-44/65/87、各 SLH-DSA 变体)都提供 KAT,并以种子保证输出可复现。
- CI 的第一道关。在每次构建、每个平台上跑 KAT,可立即捕获字节序错误、NTT 错误与域分隔不当。
- 权威来源。以官方 NIST 测试向量及随标准发布的参考实现为准,而非第三方副本。
ACVP 与 CAVP
为通过 FIPS 140-3 验证,NIST 运行两个相互配合的程序:
- ACVP(自动化密码验证协议)。一套协议与服务器,向你的模块下发测试向量并自动校验响应;它以请求响应交互取代旧的静态文件流程,覆盖大量边界情形。
- CAVP(密码算法验证程序)。算法实现在该程序下经 ACVP 验证并获颁算法证书;CAVP 验证是模块级 CMVP / FIPS 140-3 证书的前提。
整条链路为:通过算法的 ACVP 测试 → 取得 CAVP 证书 → 纳入 FIPS 140-3 模块验证(CMVP)。只有限定到具体算法与参数集的模块证书,才能用于声称合规。
CAVP/ACVP 验证的是算法实现;CMVP/FIPS 140-3 验证的是包含算法实现的密码模块。算法证书是模块验证的重要组成部分,但单独的算法验证不能替代模块证书。
FIPS 算法边界
验证适用于一个明确的密码边界,即特定的模块版本、构建与算法集合;ML-KEM、ML-DSA 与 SLH-DSA 各有自己的验证范围。"库支持某算法"与"该算法处于已验证边界之内"并非一回事,务必确认证书覆盖你所上线的确切参数集。
实际要测什么
- KAT 一致性。在每个目标平台与构建配置上,对每个参数集逐一验证。
- 签名确定性模式。ML-DSA 同时支持确定性(关闭加扰)与随机化两种签名模式,两者都要测,并确认确定性模式能精确复现 KAT 签名。
- KEM 解封装失败处理。喂入畸形与篡改的密文,验证实现采用 FIPS 203 的隐式拒绝逻辑:坏密文路径也产生伪随机共享秘密,且不能通过返回码、日志、时序或错误分支暴露“解封装失败”(即 侧信道 中的失败预言机风险)。
- 往返属性测试。随机密钥生成、封装签名、解封装验证,多轮迭代,以捕获低概率的解封装失败。
- 互操作性。与第二个独立实现交叉测试(如你的库与 OpenSSL),确认线上格式一致。
- 否定测试。错误密钥、截断输入、翻转比特的签名等情形都必须被拒绝。
相关
标准与参考
- NIST CAVP/ACVP — 算法验证程序与协议
- FIPS 203 (ML-KEM) — 标准与已知答案测试
- FIPS 204 (ML-DSA) — 标准与已知答案测试
- FIPS 205 (SLH-DSA) — 标准与已知答案测试
- NIST PQC 项目 — 官方测试向量与参考实现
- 资源链接 — 完整标准登记册