docs: record D-QA-1, the mutual exchange (A-15), the hazmat gate (A-35) and the corrected ml-kem fact

This commit is contained in:
2026-11-25 07:47:46 +01:00
parent 91b84459b0
commit e0c6d53a99
6 changed files with 739 additions and 115 deletions
+160 -88
View File
@@ -14,8 +14,8 @@ ecosystem audits one piece of code instead of five.
| Piece | What it does | Standard |
|:--|:--|:--|
| `xwing` | Hybrid KEM: ML-KEM-768 + X25519, X-Wing combiner | draft-connolly-cfrg-xwing-kem-11, FIPS 203, RFC 7748 |
| `exchange` | One exchange: the initiator encapsulates to the responder's public key; both get a `Session` bound to the full transcript and a caller context | HKDF (RFC 5869) with SHA-256 |
| `xwing` | Hybrid KEM: ML-KEM-768 + X25519, X-Wing exactly as drafted | draft-connolly-cfrg-xwing-kem-11, FIPS 203, RFC 7748 |
| `exchange` | A **mutual** exchange: each peer encapsulates to the other's public key; both get a `Session` bound to both secrets, the full transcript and a caller context | HKDF (RFC 5869) with SHA-256 |
| `Session::wireguard_psk(epoch)` | The 32-byte WireGuard pre-shared key for one rotation epoch | HKDF-Expand |
| `seal` / `open` | One-shot sealed box to a recipient's hybrid public key | X-Wing + HKDF + ChaCha20-Poly1305 (RFC 8439) |
@@ -32,162 +32,234 @@ other Domi apps.
| X25519 | `x25519-dalek` | 3.0.0 | with `curve25519-dalek` 5.0.0 |
| SHA3-256 | `sha3` (RustCrypto) | 0.12.0 | X-Wing combiner |
| SHAKE256 | `shake` (RustCrypto) | 0.1.0 | X-Wing key expansion |
| HKDF-SHA-256 | `hkdf` 0.13.0, `sha2` 0.11 | | key schedule |
| HKDF-SHA-256 | `hkdf` 0.13.0, `hmac` 0.13.0, `sha2` 0.11.1 | | key schedule |
| ChaCha20-Poly1305 | `chacha20poly1305` (RustCrypto) | 0.11.0 | sealing |
| Zeroisation | `zeroize` | 1.x | every secret type is `ZeroizeOnDrop` |
| Zeroisation | `zeroize` | 1.9.2 | every secret type is `ZeroizeOnDrop` |
Exact versions are pinned by `Cargo.lock`, which is committed.
Exact versions are pinned by `Cargo.lock`, which is committed. `ml-kem` and `x25519-dalek` are
pinned with `=` in `Cargo.toml` as well, so an upgrade is a deliberate edit that re-runs the KATs.
### The hybrid KEM: X-Wing, draft -11
### The hybrid KEM: X-Wing, draft -11 (decision D-QA-1)
The roadmap asks for an X-Wing-style combiner and for the current draft to be checked. Facts
checked on 2026-11-25:
Facts checked on 2026-11-25:
- The current draft is **draft-connolly-cfrg-xwing-kem-11**, dated 2026-09-23, an individual
Internet-Draft (intended status Informational), not an RFC and not yet a CFRG-adopted document.
Internet-Draft (intended status Informational), not an RFC and not CFRG-adopted.
Source: <https://datatracker.ietf.org/doc/draft-connolly-cfrg-xwing-kem/>.
- Its change log lists only editorial changes since -06 (ASN.1 module, SHAKE output length stated
in bits, implementation list, PEM header). The algorithm and the test vectors are the same as in
-06. Source: Appendix G of <https://www.ietf.org/archive/id/draft-connolly-cfrg-xwing-kem-11.txt>.
- RustCrypto's `x-wing` crate 0.1.1 (2026-10-01) describes itself as draft 06. Because the
algorithm did not change, its vectors are the -11 vectors; three were compared by hand against
Appendix C of -11 (seed and `ss` of vectors 1 and 2, `ss` of vector 3) and match.
in bits, implementation list, PEM header). Source: Appendix G of
<https://www.ietf.org/archive/id/draft-connolly-cfrg-xwing-kem-11.txt>.
- Appendix C has three vectors and still carries the note "TODO: replace with test vectors that
re-use ML-KEM, X25519 values", so **later drafts may change the vectors**. Arcanum pins the vector
file by sha256 together with the draft number (`tests/vectors/SOURCES.md`); a changed file fails
the KAT, and moving to a new draft is a deliberate decision.
- RustCrypto's `x-wing` 0.1.1 (2026-10-01) describes itself as draft 06; its vectors are the same
three as draft -11 (identical after removing whitespace).
**Chosen: X-Wing as specified in draft -11**, with sizes public key 1216 B, secret key 32 B (a
seed), ciphertext 1120 B, shared secret 32 B:
**Decision D-QA-1 (recommended by QA, adopted).** Mark's spec asks for a combiner that hashes both
shared secrets, both ciphertexts and both public keys, "X-Wing-style … use it if it fits". X-Wing's
combiner hashes `ss_M`, `ss_X`, `ct_X` and `pk_X` and deliberately leaves `ct_M` and `pk_M` to
ML-KEM's own binding (draft -11 §5.3). So:
```
expand(sk) = SHAKE256(sk, 96 bytes) -> d = [0:32], z = [32:64], sk_X = [64:96]
(pk_M, dk_M) = ML-KEM-768.KeyGen_internal(d, z); pk_X = X25519(sk_X, 9)
Encaps(pk, eseed) : (ct_M, ss_M) = ML-KEM-768.Encaps_internal(pk_M, eseed[0:32])
ek_X = eseed[32:64]; ct_X = X25519(ek_X, 9); ss_X = X25519(ek_X, pk_X)
Combiner = SHA3-256(ss_M || ss_X || ct_X || pk_X || "\.//^\")
```
1. **The KEM is X-Wing, unmodified**, so the draft's vectors pass byte for byte:
```
expand(sk) = SHAKE256(sk, 96 bytes) -> d = [0:32], z = [32:64], sk_X = [64:96]
(pk_M, dk_M) = ML-KEM-768.KeyGen_internal(d, z); pk_X = X25519(sk_X, 9)
Encaps(pk, eseed) : (ct_M, ss_M) = ML-KEM-768.Encaps_internal(pk_M, eseed[0:32])
ek_X = eseed[32:64]; ct_X = X25519(ek_X, 9); ss_X = X25519(ek_X, pk_X)
Combiner = SHA3-256(ss_M || ss_X || ct_X || pk_X || "\.//^\")
```
2. **Both public keys and both ciphertexts are bound in Arcanum's own key schedule**, where the
`domi/arcanum/v1/...` labels live (below). That meets the spec in full, and the spec's own
"use it if it fits" condition holds.
Arcanum composes X-Wing itself from `ml-kem`, `x25519-dalek`, `sha3` and `shake` rather than
calling the `x-wing` crate in production. The reasons, in order:
1. Mandatory test 3 must replace a component secret by zeros and see the output change. That needs
the combiner as a separate function, which the `x-wing` crate does not expose.
2. Arcanum must reject malformed input with typed errors (test 5). Owning the parsing makes that
explicit.
3. The composition is twenty lines of glue between vetted primitives, not a primitive. It is pinned
by the three official X-Wing vectors **and** by a differential test against the `x-wing` crate
(dev-dependency only) over random seeds and random ciphertexts.
Arcanum composes X-Wing from `ml-kem`, `x25519-dalek`, `sha3` and `shake` rather than calling the
`x-wing` crate, because mandatory test 3 needs the combiner as a separate function and because
Arcanum wants typed errors for every malformed input. The composition is about twenty lines of
glue between vetted primitives. It is pinned by the draft's three vectors **and** by a differential
test against RustCrypto `x-wing` (a dev-dependency only) over random seeds and random ciphertexts.
**Stricter than the draft, on purpose.** Arcanum rejects an X25519 public key or ciphertext part
that is a low-order point (the X25519 result is all zeros, `was_contributory() == false`). An honest
key or ciphertext can never be such a point (it is a clamped scalar times the base point), so this
changes no honest exchange and no official vector. It removes the case where the classical half
silently contributes a known value. RustCrypto ships the same option as
`DecapsulationKeyRejectNonContrib`.
that is a low-order point (`was_contributory() == false`, a constant-time check in `x25519-dalek`).
An honest key or ciphertext is never such a point, so this changes no honest exchange and no
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`.
**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`.
**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.
**X25519 clamping.** Five bits of the 32-byte X25519 ephemeral scalar (bits 0–2 of the first byte,
bits 6–7 of the last) are clamped by RFC 7748, so changing only those bits of `eseed[32:64]` does
not change the exchange. That is the standard's behaviour, not a binding gap; the byte-flip test
flips bit 4 of each byte.
### Is `ml-kem` stable enough?
- `ml-kem` 0.3.4 (2026-10-31) is the newest release; the 0.3 line has been out since 2026-04-28
(0.3.0, 0.3.2, 0.3.3, 0.3.4). Source: <https://crates.io/api/v1/crates/ml-kem>.
- It is still 0.x, so a minor bump may break the API. The README says it implements FIPS 203
(0.3.0, 0.3.2, 0.3.3, 0.3.4). Source: <https://crates.io/api/v1/crates/ml-kem>. It depends on
`rand_core` 0.10 (read from its `Cargo.toml`).
- It is still 0.x, so a minor bump may break the API. Its README says it implements FIPS 203
(final) and that it **"has never been independently audited"**. Source:
<https://github.com/RustCrypto/KEMs/blob/master/ml-kem/README.md>.
- **Correction to a QA fact (F10):** in 0.3.4, `EncapsulationKey::encapsulate_deterministic` is
public **whether or not** the `hazmat` feature is on; `hazmat` only un-hides it in the docs
(`#[cfg_attr(not(feature = "hazmat"), doc(hidden))]`, `src/encapsulation_key.rs`). So `ml-kem`'s
feature gives no protection; Arcanum's own `hazmat` feature (below) is what gates the
deterministic paths for Domi code.
- Judgement: stable enough for X-Wing in a household mesh where WireGuard's classical security
remains underneath (the PSK can only add security, see THREAT_MODEL.md), **not** stable enough to
be the only protection of anything. The version is locked, and an upgrade must re-run the KATs.
be the only protection of anything. The version is pinned; an upgrade re-runs the KATs.
### `x25519-dalek`
`x25519-dalek` 3.0.0 (2026-07-06), the newest stable release, on `curve25519-dalek` 5.0.0. Source:
<https://crates.io/api/v1/crates/x25519-dalek>. Used with `static_secrets` and `zeroize`.
`x25519-dalek` 3.0.0 (2026-07-06), the newest stable release, on `curve25519-dalek` 5.0.0, with
`SharedSecret::was_contributory()`. Source: <https://crates.io/api/v1/crates/x25519-dalek> and the
crate source. Used with `static_secrets` and `zeroize`.
### The exchange is mutual (decision on QA A-15)
A PSK from a **single** encapsulation authenticates only the receiver: anyone who knows the
responder's public key can encapsulate to it. Today WireGuard's static X25519 keys authenticate
the peers, but a quantum attacker can recover those from the public keys, and then a one-way PSK
is the only thing left — and the attacker could impersonate the initiator and choose it.
**Chosen: both directions.** The initiator encapsulates to the responder (`ct_IR`), the responder
encapsulates back to the initiator (`ct_RI`), and the session is derived from both secrets and the
whole transcript. Whoever lacks either secret key cannot compute the PSK. This is the design
Rosenpass uses for the same reason. API:
```
let init = exchange::initiate(&my_sk, &peer_pk, context, rng)?; // send init.ciphertext()
let (ct_ri, session) = exchange::respond(&my_sk, &peer_pk, &ct_ir, context, rng)?; // send ct_ri
let session = init.finish(&ct_ri)?;
```
What Day 3 must still do (recorded here and in THREAT_MODEL.md):
- **Authenticate the public keys.** Mutual KEM authentication is only as good as each side's copy
of the other's hybrid public key. Via distributes them signed with Tessera. If Tessera's
signatures are classical (Ed25519), a quantum attacker who can forge them can substitute keys.
That is the gap ML-DSA closes later.
- **Forward secrecy against key theft.** With static key pairs, someone who later steals both
secret keys and has recorded the exchanges can recompute every PSK. Day 3 should add an
ephemeral key pair per exchange (Rosenpass does), or rotate the key pairs.
- **One exchange per epoch**, every 120 s (below).
- **Replay and rollback protection** (QA A-13). Arcanum is pure and keeps no epoch state, so
refusing an old epoch or an old exchange is the caller's job. Arcanum does not wrap epochs: the
caller passes a `u64`, and `epoch_at` is a division (QA A-12 becomes a Day 3 test).
### Key schedule (labels `domi/arcanum/v1/...`)
The roadmap's decided combiner "hashes both shared secrets together with both ciphertexts and both
public keys". X-Wing's combiner hashes `ss_M`, `ss_X`, `ct_X` and `pk_X`, and leaves `ct_M` and
`pk_M` to ML-KEM's own binding. Arcanum adds the missing two in the key schedule, so the decided
property holds in full:
```
th = SHA-256("domi/arcanum/v1/transcript" || pk (1216 B) || ct (1120 B) || u32be(len ctx) || ctx)
prk = HKDF-Extract(salt = "domi/arcanum/v1/extract", ikm = ss_xwing || th)
psk(epoch) = HKDF-Expand(prk, "domi/arcanum/v1/wireguard-psk" || u64be(epoch), 32)
exchange: th = SHA-256("domi/arcanum/v1/transcript/exchange"
|| pk_I (1216) || pk_R (1216) || ct_IR (1120) || ct_RI (1120)
|| u64be(len ctx) || ctx)
prk = HKDF-Extract(salt = "domi/arcanum/v1/extract", ikm = ss_IR || ss_RI || th)
psk(epoch) = HKDF-Expand(prk, "domi/arcanum/v1/wireguard-psk" || u64be(epoch), 32)
seal: th = SHA-256("domi/arcanum/v1/transcript/seal" || pk (1216) || ct (1120)
|| u64be(len aad) || aad)
prk = HKDF-Extract(salt = "domi/arcanum/v1/extract", ikm = ss || th)
key = HKDF-Expand(prk, "domi/arcanum/v1/seal/key", 32)
nonce = HKDF-Expand(prk, "domi/arcanum/v1/seal/nonce", 12)
```
`pk` is the whole hybrid public key (`pk_M || pk_X`) and `ct` the whole ciphertext
(`ct_M || ct_X`), so both public keys and both ciphertexts are hashed. `ctx` is the caller's binding
(for Via: the two peers' Tessera device ids and the protocol name). Every label is versioned; a v2
changes the labels, never reuses them.
- `pk_*` are whole hybrid public keys (`pk_M || pk_X`) and `ct_*` whole ciphertexts
(`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
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
(`tests/golden_v1.rs`, QA A-10, A-38), so a "harmless" relabel fails loudly instead of making
every stored Custos blob unopenable.
### WireGuard PSK and rotation
- Rosenpass, the reference design, rotates every two minutes: `REKEY_AFTER_TIME_RESPONDER = 120 s`,
`REKEY_AFTER_TIME_INITIATOR = 130 s` (so the roles alternate), and `REJECT_AFTER_TIME = 180 s`.
Source: <https://github.com/rosenpass/rosenpass/blob/main/rosenpass/src/protocol/constants.rs>,
read 2026-11-25; the code comment cites WireGuard's own two-minute rekey.
read 2026-11-25; the code comment cites WireGuard's own two-minute rekey. The Go port
(cunicu.li/go-rosenpass) uses the same 120 s / +10 s / 3 min.
- Arcanum takes no clock. It exports `RECOMMENDED_EPOCH_SECONDS = 120` and a pure helper
`epoch_at(unix_seconds) = unix_seconds / 120`; the caller passes the time.
- `Session::wireguard_psk(epoch)` is deterministic: both peers get the same PSK for the same epoch,
and successive epochs differ. **Forward secrecy between epochs needs a fresh exchange per epoch**
(as Rosenpass does). Deriving several epochs from one session is a fallback when an exchange
fails, and loses that property; Via's engine (Day 3) must run a new exchange each epoch.
and successive epochs differ. **Forward secrecy between epochs needs a fresh exchange per
epoch.** Deriving several epochs from one session is a fallback when an exchange fails.
### Sealing
```
sealed = 0x01 || ct (1120 B) || ChaCha20-Poly1305(key, nonce, plaintext, aad = 0x01)
th, prk as above with ctx = the caller's associated data
key = HKDF-Expand(prk, "domi/arcanum/v1/seal/key", 32)
nonce = HKDF-Expand(prk, "domi/arcanum/v1/seal/nonce", 12)
```
Each seal uses a fresh encapsulation, so a key and nonce are never used twice. Overhead is 1137
bytes. This is a plain documented construction, not HPKE (RFC 9180).
`sealed = 0x01 || ct (1120 B) || ChaCha20-Poly1305 ciphertext || tag (16 B)`, AEAD associated
data = the version byte, key and nonce from the schedule above. Each seal uses a fresh
encapsulation, so a key and nonce are never used twice. Overhead is 1137 bytes. **Anyone who knows
the recipient's public key can seal**: there is no sender authentication, and ChaCha20-Poly1305 is
not key-committing, so Custos must not read a successful `open` as proof of who sealed it
(QA A-27). The output buffer is allocated once at its final size, so no buffer that held
plaintext is reallocated and freed unwiped (QA A-29). This is a documented construction, not HPKE
(RFC 9180).
### Shape of the API
- `#![no_std]` with `alloc`, `#![forbid(unsafe_code)]`, no I/O, no clock.
- Randomness is a parameter: `&mut impl rand_core::CryptoRng` (rand_core 0.10), with `_derand`
variants that take the exact bytes (used by the known-answer tests).
- Every secret type (`SecretKey`, `SharedSecret`, `Session`, `WireGuardPsk`) is zeroised on drop and
prints as `[redacted]` in `Debug`.
- Every parser returns `Result<_, arcanum::Error>`; nothing panics on input.
- `#![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).
- **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.
- Every secret type (`SecretKey`, `SharedSecret`, `Session`, `Initiation`, `WireGuardPsk`) is
zeroised on drop, is not `Copy`, has no `PartialEq`, and prints as `[redacted]` in `Debug`.
- Every parser returns `Result<_, arcanum::Error>`; errors carry only lengths and variants.
## Tests (written first)
| # | Mandatory test | File |
|:--|:--|:--|
| 1 | KATs: ML-KEM-768 (NIST ACVP), X25519 (RFC 7748), X-Wing (draft -11) | `tests/kat_mlkem768.rs`, `tests/kat_x25519.rs`, `tests/kat_xwing.rs` |
| 1 | KATs: ML-KEM-768 (NIST ACVP), X25519 (RFC 7748), X-Wing (draft -11) + differential vs `x-wing` | `tests/kat_mlkem768.rs`, `tests/kat_x25519.rs`, `tests/kat_xwing.rs` |
| 2 | Both sides derive the same secret; any changed input byte changes it | `tests/exchange.rs` |
| 3 | A zeroed component secret changes the output (both halves bound) | `src/binding_tests.rs`, `tests/binding.rs` |
| 4 | PSK epochs differ and are reproducible | `tests/psk_epochs.rs` |
| 5 | Malformed input gives typed errors, never a panic; fuzz target | `tests/malformed.rs`, `fuzz/fuzz_targets/untrusted_input.rs` |
| 6 | `cargo deny`, `cargo audit` clean; no unsafe | `deny.toml`, `tests/no_unsafe.rs`, `#![forbid(unsafe_code)]` |
Vector provenance is in `tests/vectors/SOURCES.md`.
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
(`F:\Akce\Via\qa\01_arcanum_attacks.md`) is mapped case by case in the PR's self-review.
## Risks
| Risk | Consequence | Mitigation |
|:--|:--|:--|
| A bug in our X-Wing glue | Peers agree on a weak secret, or interoperate with nobody | Official vectors + differential test vs RustCrypto `x-wing` |
| `ml-kem` or `x25519-dalek` bug, side channel | Weaker PQ or classical half | Hybrid: either half suffices; versions locked; `cargo audit` |
| `ml-kem` or `x25519-dalek` bug, side channel | Weaker PQ or classical half | Hybrid: either half suffices; versions pinned; `cargo audit` |
| Reusing one session for many epochs | No forward secrecy between epochs | Documented; Day 3 runs a fresh exchange per epoch |
| Unauthenticated public key (MITM) | Attacker learns the PSK | WireGuard's static keys still authenticate; Via must sign the Arcanum public key with Tessera (Day 3). See THREAT_MODEL.md |
| Randomness misuse in `_derand` functions | Reused eseed leaks the secret | `_derand` documented as test-only hazmat; normal API takes an RNG |
| Substituted public key (MITM) | Attacker learns the PSK | Mutual exchange; Via must authenticate both hybrid public keys (Tessera); PQ signatures later. See THREAT_MODEL.md |
| Static key theft later | Recorded exchanges recomputable | Day 3 adds ephemeral keys or rotates key pairs |
| Deterministic API reaching production | Predictable PSKs | `hazmat` off by default; feature-graph test; consumers repeat it |
| Secrets left in memory | Key recovery from a memory dump | `ZeroizeOnDrop` everywhere we own the bytes; residuals listed below |
| Draft changes before RFC | Interop break with other X-Wing users | Version recorded; labels versioned; vectors pinned |
| Draft changes before RFC | Interop break with other X-Wing users | Draft number and vector sha256 pinned; labels versioned |
| A relabel or re-encoding | Stored sealed blobs unopenable; peers disagree | Golden v1 vectors |
## Gaps (known, not hidden)
- **Not audited**, and neither are `ml-kem` nor the `x-wing` reference.
- **No authentication** in Arcanum v1. Peer public keys must be authenticated by the caller.
Post-quantum authentication (ML-DSA) is out of scope.
- **Side channels** are inherited from the crates; Arcanum adds no constant-time analysis of its own.
- **Zeroisation residuals:** HKDF/HMAC and SHA-3 internal states hold secret-derived data and are
dropped without guaranteed wiping where the crates do not offer it; values moved by the compiler
may leave copies on the stack. `zeroize` cannot promise more than that.
- **No post-quantum authentication of public keys.** The mutual exchange authenticates whoever
holds the secret keys matching the public keys each side was given; getting the right public
keys is the caller's job, and ML-DSA is out of scope.
- **No forward secrecy against later theft of static secret keys** within Arcanum itself.
- **Side channels** are inherited from the crates; Arcanum adds no constant-time analysis of its
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.
- **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.
- **FIPS 203 itself** was not read from the NIST PDF; the ML-KEM facts rest on the ACVP vectors,
the draft's references and the `ml-kem` source.
- **Fuzzing** ran on Windows MSVC with libFuzzer for the time recorded in the PR, not continuously.
+13 -5
View File
@@ -1,6 +1,6 @@
# Arcanum threat model
Scope: the `arcanum` crate v0.1.0 — the X-Wing hybrid KEM, the key schedule, the WireGuard PSK
Scope: the `arcanum` crate v0.1.0 — the X-Wing hybrid KEM, the mutual exchange, the key schedule, the WireGuard PSK
derivation and the sealing helper. **Not audited.**
## Assets
@@ -20,7 +20,8 @@ derivation and the sealing helper. **Not audited.**
| A break of X25519 | Recovers `ss_X` | Yes | ML-KEM still protects it. |
| Active attacker who modifies ciphertexts | Flips bytes in transit | Detected or harmless | Changed `ct_M` → ML-KEM implicit rejection gives an unrelated secret; changed `ct_X` → different `ss_X`; the transcript hash binds both. The peers' PSKs differ and WireGuard simply fails to handshake. Low-order X25519 values are rejected with a typed error. |
| Malformed or hostile input | Sends wrong lengths, invalid ML-KEM keys, random bytes | No panic, typed error | Tests 5 and the fuzz target. |
| Epoch confusion | Replays an old exchange for a new epoch | Harmless | The epoch number is in every PSK derivation; an attacker who cannot decapsulate cannot compute any epoch's PSK. |
| **Impersonating one peer** (QA A-15) | Knows both public keys, sends its own encapsulation as if from the initiator | **Yes** | The exchange is mutual: the PSK needs both directions' secrets, and the responder's encapsulation goes to the real initiator's key. Without that secret key the attacker cannot compute the PSK, even after breaking WireGuard's X25519 keys. |
| Epoch confusion | Replays an old exchange for a new epoch | Harmless for secrecy | The epoch is in every PSK derivation; an attacker who cannot decapsulate cannot compute any epoch's PSK. Refusing to re-install an old PSK (rollback) is the caller's job: Arcanum keeps no state. |
## What Arcanum does NOT protect against
@@ -28,9 +29,9 @@ derivation and the sealing helper. **Not audited.**
|:--|:--|
| **Endpoint compromise** | Malware on a device reads keys and plaintext from memory. Zeroisation narrows the window; it does not close it. Keys at rest belong in Custos or Tessera. |
| **Traffic analysis** | Who talks to whom, when and how much is visible on the wire. Padding and cover traffic are the Stealth transport's job (Day 7), and only partly. |
| **Man in the middle on the public key** | Arcanum v1 does not authenticate. An attacker who substitutes the responder's public key learns that exchange's PSK. In Via, WireGuard's static keys still authenticate the tunnel, so the attacker gets back to classical security, not to plaintext; Via must also sign the Arcanum public key with the device's Tessera key (Day 3). Post-quantum authentication (ML-DSA) is not in v1. |
| **A quantum attacker who is also active today** | Without post-quantum authentication, an active quantum attacker could impersonate a peer in real time. v1 targets the passive harvest-now threat. |
| **Bad randomness** | The caller supplies the RNG. A broken RNG breaks every scheme. The `_derand` functions are for known-answer tests; reusing their seeds is catastrophic. |
| **Substituted public keys** | The mutual exchange authenticates whoever holds the secret keys matching the public keys each side was *given*. An attacker who gets a peer to accept her public key in place of the real one learns that exchange's PSK. In Via, WireGuard's static keys still authenticate the tunnel classically, so this falls back to classical security, not to plaintext. Via must distribute both hybrid public keys signed with Tessera (Day 3). If those signatures are classical (Ed25519), a quantum attacker who can forge them can substitute keys; ML-DSA closes that later. |
| **Theft of static secret keys later** | With static key pairs, whoever later steals both secret keys and has recorded the exchanges can recompute their PSKs. Day 3 must add an ephemeral key pair per exchange (as Rosenpass does) or rotate key pairs. |
| **Bad randomness** | The caller supplies the RNG. A broken RNG breaks every scheme. The `_derand` functions exist only with the off-by-default `hazmat` feature, for known-answer tests; reusing their seeds is catastrophic. |
| **Side channels** | Timing and cache behaviour are those of `ml-kem`, `x25519-dalek`, `sha3` and `chacha20poly1305`. Arcanum adds only fixed-length, data-independent glue, but has not been measured. |
| **Reusing one session for many epochs** | Supported, but a leaked session reveals every epoch's PSK derived from it. Forward secrecy needs one exchange per epoch. |
| **Denial of service** | An attacker on the path can always drop packets. |
@@ -53,3 +54,10 @@ derive a predictable PSK) reduces a Via tunnel to plain WireGuard: still authent
classically, but open to harvest-now-decrypt-later. It never reduces it below WireGuard. Sealing
(Custos, Tabellarius) is different: there Arcanum is the only layer, which is why those migrations
wait for the audit.
## Residual memory exposure
Moves in Rust copy stack bytes, and `zeroize` cannot reach those copies; hash and HMAC states are
wiped only as far as the crates' `zeroize` features go. A process memory dump taken while Arcanum
runs may contain key material. That is accepted for v1 and is one more reason keys at rest live in
Custos or Tessera, not in Arcanum's callers.