docs: R2-01 to R2-05 decisions, canonical pk_X, and rules for Arcanum's consumers
This commit is contained in:
+45
-7
@@ -85,6 +85,17 @@ An honest key or ciphertext is never such a point, so this changes no honest exc
|
||||
official vector; it removes the case where the classical half silently contributes a known value
|
||||
(QA A-16, A-17). RustCrypto ships the same option as `DecapsulationKeyRejectNonContrib`.
|
||||
|
||||
**Canonical X25519 public keys only (QA R2-02).** Draft -11 says nothing about the encoding of
|
||||
`pk_X` beyond "the 32 byte string representing the u-coordinate" (§4), and its Python reference
|
||||
decodes with `% p`, so it would accept aliases. RFC 7748 decoders mask bit 255 and reduce mod p,
|
||||
which means `pk_X`, `pk_X` with bit 255 set, and `pk_X + p` (where that fits) are the same key to
|
||||
X25519 but different bytes to the combiner and the transcript: a peer given an alias "succeeds" and
|
||||
silently derives a PSK the owner never matches. `PublicKey::from_bytes` therefore refuses an
|
||||
X25519 half with bit 255 set or a value of at least 2^255 - 19, as `Error::InvalidPublicKey`.
|
||||
X25519 outputs are always canonical, so no honest key and no official vector is affected. A
|
||||
ciphertext's `ct_X` is not checked this way: it is single-use, and its raw bytes are bound by the
|
||||
combiner (QA A-04), so an alias only gives a different secret.
|
||||
|
||||
**ML-KEM key check.** The draft requires the FIPS 203 §7.2 encapsulation key check.
|
||||
`ml-kem`'s `EncapsulationKey::new` performs it; Arcanum maps its failure to
|
||||
`Error::InvalidPublicKey`, and the NIST ACVP `encapsulationKeyCheck` vectors check that.
|
||||
@@ -169,8 +180,10 @@ seal: th = SHA-256("domi/arcanum/v1/transcript/seal" || pk (1216) || ct (11
|
||||
(`ct_M || ct_X`), so both public keys and both ciphertexts of each direction are hashed.
|
||||
- Roles are bound by position (initiator first), so a reflected exchange gives a different PSK
|
||||
(QA A-14).
|
||||
- Every field before the context is fixed-width and the context is length-prefixed, so the
|
||||
encoding is injective (QA A-08). Labels are unique, versioned and prefix-free (QA A-07, a unit
|
||||
- Every transcript field before the context is fixed-width and the context is length-prefixed, so
|
||||
the transcript encoding is injective (QA A-08). The HKDF-Expand helper takes exactly one label
|
||||
and one fixed-width field array (QA R2-03), so its `info` is injective by its signature, not by
|
||||
the discipline of its callers; this did not change any v1 byte (the golden vectors are unchanged). Labels are unique, versioned and prefix-free (QA A-07, a unit
|
||||
test). The epoch is a full 64-bit big-endian value (QA A-11).
|
||||
- `ctx` is the caller's binding (for Via: both Tessera device ids, the protocol name, the version).
|
||||
- A v2 changes the labels and never reuses these. The v1 outputs are frozen by golden vectors
|
||||
@@ -205,15 +218,37 @@ plaintext is reallocated and freed unwiped (QA A-29). This is a documented const
|
||||
|
||||
- `#![no_std]` with `alloc`, `#![forbid(unsafe_code)]`, no I/O, no clock, no OS RNG in the normal
|
||||
dependency graph (checked by `tests/feature_hygiene.rs`).
|
||||
- Randomness is a parameter: `&mut R where R: rand_core::CryptoRng` (rand_core 0.10).
|
||||
- Randomness is a parameter: `&mut R where R: rand_core::CryptoRng` (rand_core 0.10). **`rng` must
|
||||
be the operating system's RNG** (`getrandom`, `OsRng`) or a CSPRNG seeded from it once per
|
||||
process, never a fixed, derived or configured seed (QA R2-04). `CryptoRng` is only a marker: a
|
||||
CSPRNG with a constant seed satisfies it and makes `generate`, `initiate`, `respond` and `seal`
|
||||
fully deterministic, which no type check can prevent. Each of those functions says so.
|
||||
- **The raw one-way KEM is not in the release API (QA R2-01).** `PublicKey::encapsulate`,
|
||||
`SecretKey::decapsulate` and `SharedSecret::as_bytes` exist only with `hazmat`. A one-way X-Wing
|
||||
secret authenticates only the receiver and is bound to no transcript, so a release consumer
|
||||
can reach a key only through `exchange` (mutual, transcript-bound) or `seal`. Interop with other
|
||||
X-Wing users, if Domi ever needs it, gets its own loudly named feature and the same
|
||||
feature-graph check.
|
||||
- **The `hazmat` feature** exposes the deterministic entry points (`SecretKey::from_seed`,
|
||||
`PublicKey::encapsulate_derand`, `exchange::{initiate,respond}_derand`, `seal::seal_derand`)
|
||||
used by the known-answer tests. It is off by default. The tests turn it on through a
|
||||
self-dev-dependency, which never reaches a normal build; `tests/feature_hygiene.rs` asserts that
|
||||
neither `arcanum/hazmat` nor `ml-kem/hazmat` is in the normal-edge feature graph, and proves the
|
||||
check can see the feature when it is on (QA A-34, A-35). Via and via-core must run the same check.
|
||||
check can see the feature when it is on (QA A-34, A-35); `tests/qa_consumer_api.rs` compiles a
|
||||
default-features consumer to prove none of these items, nor the raw KEM, can be named.
|
||||
- **Rules for consumers (via-core, via, and later Canalis, Custos, Tabellarius):**
|
||||
- run the same `cargo tree -e features,normal -i arcanum` / `-i ml-kem` check in CI, so no
|
||||
`[dependencies]` entry turns on `arcanum/hazmat`;
|
||||
- **no direct `ml-kem` (or `x25519-dalek`, `x-wing`) dependency**: ban them in `deny.toml`
|
||||
(`[bans] deny = [...]`, with `arcanum` as the only allowed wrapper). In `ml-kem` 0.3.4,
|
||||
`encapsulate_deterministic` is public with or without its `hazmat` feature, so a direct
|
||||
dependency reopens chosen-randomness encapsulation;
|
||||
- grep for `from_seed(` outside `tests/`, which catches a CSPRNG seeded from a constant (R2-04).
|
||||
- Every secret type (`SecretKey`, `SharedSecret`, `Session`, `Initiation`, `WireGuardPsk`) is
|
||||
zeroised on drop, is not `Copy`, has no `PartialEq`, and prints as `[redacted]` in `Debug`.
|
||||
`ZeroizeOnDrop` (`Initiation` got the marker with QA R2-05), is not `Copy` or `Clone`, has no
|
||||
`PartialEq`, and prints as `[redacted]` in `Debug` (compile-time asserted in `tests/qa_review.rs`).
|
||||
`seal` keeps its output buffer `Zeroizing` until the plaintext in it has been encrypted, so the
|
||||
`MessageTooLong` path wipes the copy (R2-05).
|
||||
- Every parser returns `Result<_, arcanum::Error>`; errors carry only lengths and variants.
|
||||
|
||||
## Tests (written first)
|
||||
@@ -228,7 +263,9 @@ plaintext is reallocated and freed unwiped (QA A-29). This is a documented const
|
||||
| 6 | `cargo deny`, `cargo audit` clean; no unsafe | `deny.toml`, `tests/no_unsafe.rs`, `#![forbid(unsafe_code)]` |
|
||||
|
||||
Also: `tests/golden_v1.rs` (frozen v1 outputs), `tests/feature_hygiene.rs` (no hazmat, no OS RNG
|
||||
in the release graph). Vector provenance is in `tests/vectors/SOURCES.md`. QA's attack plan
|
||||
in the release graph), and QA's `tests/qa_review.rs`, `tests/qa_consumer_api.rs` (what a
|
||||
default-features consumer can and cannot compile), `src/qa_review_tests.rs` and `zeroize-probe/`.
|
||||
Vector provenance is in `tests/vectors/SOURCES.md`. QA's attack plan
|
||||
(`F:\Akce\Via\qa\01_arcanum_attacks.md`) is mapped case by case in the PR's self-review.
|
||||
|
||||
## Risks
|
||||
@@ -256,7 +293,8 @@ in the release graph). Vector provenance is in `tests/vectors/SOURCES.md`. QA's
|
||||
own (QA A-32, a dudect run, is not done).
|
||||
- **Zeroisation residuals:** HKDF/HMAC and SHA-3 internal states are wiped only as far as those
|
||||
crates' `zeroize` features go; values moved by the compiler may leave copies on the stack;
|
||||
`PublicKey` copies are not secret. QA A-29's allocator probe is not built.
|
||||
`PublicKey` copies are not secret. QA's allocator probe (`zeroize-probe/`, A-29) checks the heap
|
||||
only: no secret block is freed unwiped; stack copies are out of its reach.
|
||||
- **Sealing is not HPKE**, and has no sender authentication.
|
||||
- **X25519 RFC 7748 1,000,000-iteration vector** is not run (minutes in a debug build); the
|
||||
1- and 1,000-iteration vectors are.
|
||||
|
||||
Reference in New Issue
Block a user