← Back to section · Standards & Specifications
Known-Answer Tests and ACVP: How a Standard Proves Your Implementation Is Right
However precisely an algorithm's text is written, it needs executable criteria: what known-answer test vectors are made of, how NIST's ACVP online validation protocol works, and why intermediate-value tests matter especially for post-quantum algorithms.
Once an algorithm standard is published, the next question follows immediately: with thousands of implementations worldwide, why should anyone believe they compute the same bytes the standard intends? The answer is test vectors — sets of precedents of the form “given this input, the correct output must be exactly that.” They are not part of the standard’s main text, yet they are the other half of what makes a standard workable.
Known-answer tests: the oldest and most direct criterion
A known-answer test (KAT) has a minimal form: feed the implementation a fixed input — a fixed seed, a fixed plaintext, fixed random numbers — and require its output to match the reference value byte for byte. For deterministic algorithms this is straightforward; for algorithms with randomness, the random source is replaced during testing by a deterministic generator driven by a fixed seed, as the standard prescribes, freezing the whole computation into a deterministic one.
Post-quantum algorithms need KATs more urgently than traditional ones. A single ML-KEM encapsulation involves NTT transforms, noisy sampling, compression and rounding — several error-prone stages. If any stage’s constant or bit order is wrong, the final shared key is completely different, and the error is invisible in functional testing: two parties running the same wrong implementation still interoperate with each other. The mistake surfaces only when interoperating with an independent implementation or running test vectors.
ACVP: grading as an online protocol
In the past, test vectors were distributed as files alongside documents and implementers compared results themselves. NIST’s Automated Cryptographic Validation Protocol (ACVP) turned this into an online service: the implementation’s test harness registers its capabilities with the ACVP server (which algorithms, which parameter sets), the server generates a set of random cases and issues them, the implementation computes and returns the results, and the server judges them automatically and records the outcome.
This process connects to the Cryptographic Module Validation Program (CMVP): for a module to obtain a FIPS 140-3 certificate, its algorithm implementations typically must first hold passing ACVP records for the relevant algorithms. For ML-KEM, ML-DSA and SLH-DSA, ACVP covers key generation, encapsulation/decapsulation and sign/verify operations for every approved parameter set, and also includes tampered-ciphertext cases for decapsulation — feeding in a modified ciphertext and checking that the implementation correctly follows the implicit-rejection path and outputs the substitute key rather than erroring or crashing.
That ACVP cases are randomly generated by the server is crucial: it prevents an implementation from “memorizing the answers” to a fixed vector set. Facing fresh cases at every validation, passing means the implementation really is computing according to the standard text.
Intermediate values: from “wrong” to “wrong at step N”
Comparing only final outputs has a flaw: a mismatch tells you that something is wrong, not where. The appendices of FIPS 203 and FIPS 204 therefore provide complete worked examples with intermediate values: starting from the seeds, they list step by step the matrix-expansion results, the sampled noise polynomials and the intermediate quantities in the NTT domain, all the way to the final output. Implementers can compare stage by stage and localize a divergence to a single sub-step.
Such appendices are the new normal for post-quantum standards. The algorithms have many internal stages and dense byte-encoding details (the correspondence between byte strings and polynomial coefficients, the rounding direction of compression functions), and intermediate-value examples are a debugging channel the standard’s authors leave for implementers. Together with ACVP they form a two-level criterion: during development, debug stage by stage against intermediate values; during certification, face the final judgement of ACVP’s random cases.
How randomness is “frozen”: the internal functions are the handle for testing
For an algorithm with randomness to undergo known-answer testing, its randomness must be controllable from outside. FIPS 203 and FIPS 204 define an internal-function layer precisely for this: ML-KEM.KeyGen_internal takes the two 32-byte seeds directly, Encaps_internal takes the random message m directly, and ML-DSA.Sign_internal takes the random value rnd directly. These internal functions are wrapped by random sources in the deployment interface, but exposed in the testing interface, where they become the handle for test vectors.
ACVP is built exactly on this division: the cases the server issues are, in essence, “a set of inputs and expected outputs for the internal functions,” and the test harness replaces the random source with the values the case specifies and compares item by item. The validation semantics layer accordingly — passing the internal functions’ KATs shows the core computation is right; passing the external functions’ behaviour tests (context-string assembly, pre-hash encoding, triggering of implicit rejection) shows the interface contract is right. When the standard texts first cut the algorithms into inner and outer layers, testability was one of the reasons for the cut.
Negative testing: being wrong in the right way
Test vectors validate not only “computing correctly” but also “rejecting correctly.” Signature-verification case sets include tampered signatures, mismatched public keys and signatures checked under a different context string, with the expected result uniformly “verification fails”; decapsulation case sets include modified ciphertexts, with the expected result being the substitute key and no error raised. Such negative cases hunt two kinds of implementation defect: rejecting what should be rejected (accepting invalid input as valid, usually a missing check), and rejecting in the wrong way (erroring, crashing, or producing a distinguishable result — implicit rejection written as explicit rejection).
The existence of negative tests reminds implementers that every check in the standard text, every “must reject” clause, can be graded automatically. Miss one while implementing, and nothing shows in normal operation — until certification testing, or a real attack, picks it out.
Conclusion
The test-vector ecosystem shows one thing: the authority of an algorithm standard comes not only from its text but also from executable criteria. The text defines “what is right,” intermediate-value examples show “what right looks like,” and ACVP lets any implementation be verified independently and repeatedly. Without these three layers, a standard would be merely a well-written paper.
Tags: ACVPtest vectorsknown-answer testsimplementation validation