RFC-0029: Envelope Conformance Suite

  • Status: Proposed.

  • Owner: Format lead.

  • Last updated: 2026-11-30

Context

The specification’s vectors (section 12) give every intermediate value for four envelopes and twelve rejections: enough to build a reader, not enough to show that a reader decides like the reference across the space of real inputs. RFC-0023 showed the value of a differential test between two implementations; that test lived inside the Python suite. Implementers in other languages need the same evidence without Python: a published corpus and a minimal way to run it, in the spirit of Project Wycheproof.

Binding decision

  • Corpus. conformance/envelope-v4.0-corpus.json (cryptography-suite-conformance/1) lists cases with an id, a description, the envelope, the context as [key, {"text"|"bytes": ...}] pairs, and the expected outcome: {"ok": true, "plaintext_hex"} or {"ok": false, "code"} with a section 10 code. It currently has 248 cases: 40 valid envelopes (both profiles, one to three recipients in random order, record sizes 1 to 256 bytes, NFC-sensitive contexts), each with two bit flips, a truncation, an extension, and a wrong context, and eight targeted preamble cases.

  • Test provider. Provider test.interop, wrapping algorithm test-aes256gcm-binding-sha256, wrapped key nonce || AES-256-GCM(KEK, nonce, data key) with additional data SHA-256(protected bytes), KEKs published in the corpus. An unknown algorithm is CAPABILITY_UNSUPPORTED, an unknown key KEY_NOT_FOUND, other providers are skipped.

  • Adapter protocol. An adapter is a command that receives the corpus path as its last argument and prints one JSON outcome per case, in order. tools/conformance.py run -- <command> compares and reports, exiting non-zero on any disagreement; check runs the Python reference.

  • Reproducibility. Every choice, data key, message identifier, and nonce comes from SHAKE-256 over a fixed seed (the protector’s random source is replaced only during generation), so generate --check holds across Python versions and platforms; CI checks it.

  • Reference. Expected outcomes come from the Python implementation, which is itself bound to the specification by the vectors and an independent decoder.

The first generation labelled the modified-minor-version case “accepted”. Its outcome is AUTHENTICATION_FAILED, correctly: readers parse any minor version, but the minor-version byte is part of the protected preamble, so changing it on a sealed envelope breaks the binding. The label was fixed.

Test and validation requirements

tests/contract/test_conformance_suite.py checks that the corpus is current, that it covers every outcome kind, that the Python reference and the JavaScript implementation both agree on all cases, and that the runner reports disagreements, wrong-length output, and failing adapters. The quality gate runs generate --check and check.