docs: QA S-04, S-07, S-08, S-12 as gaps; the expanded key is 35 kB on the stack
- The expanded ML-DSA-65 key is 34,992 bytes on the stack (QA measured; A_hat's rows are boxed inside ml-dsa), not 64 kB, and it is exactly the secret part. src/sign.rs and docs/02_signatures.md corrected. - S-04: ml-dsa's signing loop leaves rnd, rho'' and y on the stack; a leaked y gives s1. Recorded in docs/02 and docs/THREAT_MODEL.md, with the key-construction stack copy. - S-07: under open question 1, the recommendation for Day 3: a separate, freshly generated composite identity, never a wrapped Tessera Ed25519 seed (RFC 10073 3.1); from_bytes cannot detect reuse (also on its docs). - S-08: verify_binding does not tie id to vk and has no serial; both are the caller's, with the Day 3 replay rule (QA E-07); also on its docs. - S-12: decoded on 2026-11-26, none of the 9 ML-DSA-65 "modified z" sigVer cases at a7f283cd reaches the z infinity-norm bound (max 524,077 < 524,092), so no ACVP case could be added; only Wycheproof covers it. - S-05, S-10, S-11 noted under "As built" and gaps.
This commit is contained in:
+33
-3
@@ -149,6 +149,9 @@ Where the code differs from, or adds to, the design above (the code wins):
|
|||||||
a set sign bit on x = 0. Arcanum re-encodes the point and refuses any encoding that is not the
|
a set sign bit on x = 0. Arcanum re-encodes the point and refuses any encoding that is not the
|
||||||
canonical one, as well as small-order points (`Error::InvalidVerifyingKey`). Invisible to honest
|
canonical one, as well as small-order points (`Error::InvalidVerifyingKey`). Invisible to honest
|
||||||
keys and to the RFC's vectors.
|
keys and to the RFC's vectors.
|
||||||
|
- **And a weak ML-DSA key check** (QA S-05): an ML-DSA-65 half whose t1 is all zero is refused as
|
||||||
|
`InvalidVerifyingKey`. With t1 = 0 a signature needs no secret (Wycheproof's `ZeroPublicKey`), so such a
|
||||||
|
composite would silently be no stronger than Ed25519. ρ may be anything.
|
||||||
- **App labels are 1 to 231 bytes** (`MAX_APP_LABEL_LEN` = 255 minus the 24-byte prefix); an empty
|
- **App labels are 1 to 231 bytes** (`MAX_APP_LABEL_LEN` = 255 minus the 24-byte prefix); an empty
|
||||||
label is `TooShort`, a longer one `TooLong`. **And `&'static`** (QA S-09): `AppContext::new` is a
|
label is `TooShort`, a longer one `TooLong`. **And `&'static`** (QA S-09): `AppContext::new` is a
|
||||||
`const fn` taking `&'static [u8]`, so a label is written in the source, not derived from a peer
|
`const fn` taking `&'static [u8]`, so a label is written in the source, not derived from a peer
|
||||||
@@ -176,13 +179,40 @@ Where the code differs from, or adds to, the design above (the code wins):
|
|||||||
- ACVP sigGen, sigVer and Wycheproof `mldsa_65_verify` run as subsets (`tests/vectors/SOURCES.md`): 18 of
|
- ACVP sigGen, sigVer and Wycheproof `mldsa_65_verify` run as subsets (`tests/vectors/SOURCES.md`): 18 of
|
||||||
the sigGen cases, 15 sigVer cases, 70 of 210 Wycheproof verify cases. The full files' sha256 are pinned,
|
the sigGen cases, 15 sigVer cases, 70 of 210 Wycheproof verify cases. The full files' sha256 are pinned,
|
||||||
so the subsets can be rechecked against them by rerunning `make_subsets.py`.
|
so the subsets can be rechecked against them by rerunning `make_subsets.py`.
|
||||||
- Stack copies: building a `SigningKey` moves the expanded ML-DSA key (about 64 kB) through the stack
|
- Stack copies: building a `SigningKey` moves the expanded ML-DSA key through the stack before it is boxed:
|
||||||
before it is boxed; the allocator probe sees only the heap (as in v0.1.0's threat model).
|
**about 35 kB** (34,992 B, QA's measurement; `A_hat`'s rows are boxed inside `ml-dsa`), and those bytes are
|
||||||
|
exactly the secret part (s1, s2, t0 and their NTT forms). The allocator probe sees only the heap.
|
||||||
|
- **Stack residue inside `ml-dsa`** (QA S-04): every signature leaves `rnd`, ρ'' and the mask y on the stack,
|
||||||
|
unwiped, in `try_raw_sign_mu`; with the public z, a leaked y gives c·s1 and so s1. Arcanum cannot reach
|
||||||
|
it; it is in `docs/THREAT_MODEL.md`. The allocator probe now watches the expanded key's K and s1 bytes on
|
||||||
|
the heap as well as the seed canary, but no heap probe can see the stack.
|
||||||
|
- **Stack size** (QA S-11): building a key and signing need more than 128 KiB of stack in release (fit in
|
||||||
|
256 KiB) and more than 256 KiB in Arcanum's debug profile (fit in 512 KiB); a smaller thread aborts the
|
||||||
|
process. Documented on `SigningKey`; pinned for release by `tests/sig_stack.rs`.
|
||||||
|
- **ACVP never reaches the ‖z‖∞ bound** (QA S-12). The sigVer file at `a7f283cd` has 9 "modified signature - z"
|
||||||
|
cases in its ML-DSA-65 non-preHash groups (3 kept in the subset); decoded with a script on 2026-11-26, the
|
||||||
|
largest |z| coefficient among them is 524,077, below γ1 − β = 524,092, so all 9 decode and are refused only
|
||||||
|
by the c̃ comparison. No ACVP case could be added for the bound; only Wycheproof's `InfinityNormViolation`
|
||||||
|
cases (6 kept) test `ml-dsa`'s norm check at decode. Which of the 9 the ModifyZ correction changed was not
|
||||||
|
checked (that needs the `2972def2` sigVer file).
|
||||||
|
- **Key bindings have no serial and do not tie `id` to `vk`** (QA S-08). `verify_binding` checks that the
|
||||||
|
holder of `vk` bound `kem` to `id` within the window; that `vk` is the right key for `id`, and that a newer
|
||||||
|
binding has not replaced this one, are the caller's. For Day 3 (with the plan-replay rule, QA E-07): short
|
||||||
|
windows, and keep only the binding with the newest `not_before` per `id` (no format change needed).
|
||||||
|
- **Feature unification** (QA S-10): `ed25519-dalek/legacy_compatibility` in any crate of a consumer's binary
|
||||||
|
would accept a non-reduced S (a second encoding of the Ed25519 half). Arcanum's `deny.toml` bans it (and
|
||||||
|
`ed25519-dalek/hazmat`); consumers must ban it in theirs.
|
||||||
|
|
||||||
## Questions (none blocks the work)
|
## Questions (none blocks the work)
|
||||||
|
|
||||||
1. Should Tessera's device identity itself move to this composite key, or should Tessera keep Ed25519 and
|
1. Should Tessera's device identity itself move to this composite key, or should Tessera keep Ed25519 and
|
||||||
this key be a separate Via identity signed by it? Day 3's `docs/03_engine.md` must decide; Arcanum works
|
this key be a separate Via identity signed by it? Day 3's `docs/03_engine.md` must decide; Arcanum works
|
||||||
either way.
|
either way. **Recommendation (QA S-07):** the composite key is a **separate, freshly generated** identity
|
||||||
|
(`SigningKey::generate`), optionally certified once by the old Ed25519 key. Never build it as
|
||||||
|
`SigningKey::from_bytes(new_mldsa_seed || tessera_ed25519_seed)`: RFC 10073 §3.1 forbids reusing a component
|
||||||
|
key, and with only weak non-separability (§9.2) any Tessera path that signs caller-influenced bytes
|
||||||
|
beginning with the RFC Prefix would become a forgery oracle for the composite once ML-DSA falls. If the two
|
||||||
|
keys ever coexist on one device, Tessera's Ed25519 signer should refuse messages that begin with
|
||||||
|
`CompositeAlgorithmSignatures2025` (§9.4). `from_bytes` cannot detect reuse: any 64 bytes are a key.
|
||||||
2. Validity windows on key bindings: the default the engine should use (proposal: 30 days, renewed by the
|
2. Validity windows on key bindings: the default the engine should use (proposal: 30 days, renewed by the
|
||||||
control service).
|
control service).
|
||||||
|
|||||||
@@ -61,3 +61,9 @@ Moves in Rust copy stack bytes, and `zeroize` cannot reach those copies; hash an
|
|||||||
wiped only as far as the crates' `zeroize` features go. A process memory dump taken while Arcanum
|
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
|
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.
|
Custos or Tessera, not in Arcanum's callers.
|
||||||
|
|
||||||
|
v0.2.0 adds two stack exposures in signing, both accepted on the same terms: building a `SigningKey`
|
||||||
|
moves the 35 kB expanded ML-DSA key (s1, s2, t0 and their NTT forms) through the stack before it is
|
||||||
|
boxed, and `ml-dsa`'s signing loop (`try_raw_sign_mu`) leaves `rnd`, ρ'' and the mask y on the stack
|
||||||
|
unwiped after every signature. A leaked y, with the public z, gives c·s1 and so s1. Neither is
|
||||||
|
reachable from Arcanum, and neither is visible to the heap allocator probe (QA S-04, PR #2).
|
||||||
|
|||||||
+15
-1
@@ -295,7 +295,8 @@ impl fmt::Debug for Signature {
|
|||||||
/// blocking-pool or JNI threads that sign at least 512 KiB, and measure unoptimised debug builds.
|
/// blocking-pool or JNI threads that sign at least 512 KiB, and measure unoptimised debug builds.
|
||||||
pub struct SigningKey {
|
pub struct SigningKey {
|
||||||
seeds: Zeroizing<[u8; SIGNING_KEY_LEN]>,
|
seeds: Zeroizing<[u8; SIGNING_KEY_LEN]>,
|
||||||
// Boxed: the expanded ML-DSA-65 key is about 64 kB.
|
// Boxed: the expanded ML-DSA-65 key is 34,992 bytes on the stack (its A_hat rows are already
|
||||||
|
// boxed inside ml-dsa); those bytes are the secret part, s1, s2, t0 and their NTT forms.
|
||||||
ml: Box<ExpandedSigningKey<MlDsa65>>,
|
ml: Box<ExpandedSigningKey<MlDsa65>>,
|
||||||
ed: ed25519_dalek::SigningKey,
|
ed: ed25519_dalek::SigningKey,
|
||||||
public: VerifyingKey,
|
public: VerifyingKey,
|
||||||
@@ -315,6 +316,12 @@ impl SigningKey {
|
|||||||
/// Parse a stored signing key: the ML-DSA-65 seed, then the Ed25519 seed (RFC 10073's
|
/// Parse a stored signing key: the ML-DSA-65 seed, then the Ed25519 seed (RFC 10073's
|
||||||
/// private key format).
|
/// private key format).
|
||||||
///
|
///
|
||||||
|
/// **The 64 bytes must come from [`SigningKey::generate`]** (or from another RFC 10073 composite
|
||||||
|
/// key), never from component seeds used anywhere else: RFC 10073 §3.1 forbids reusing a
|
||||||
|
/// component key, and an existing Ed25519 seed (Tessera's, say) wrapped in here would make
|
||||||
|
/// every classic signer of that key a potential forgery oracle for the composite if ML-DSA
|
||||||
|
/// ever falls (QA S-07). This function cannot tell: any 64 bytes are a valid key.
|
||||||
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// [`Error::InvalidLength`] if it is not 64 bytes. Every 64-byte value is a valid key.
|
/// [`Error::InvalidLength`] if it is not 64 bytes. Every 64-byte value is a valid key.
|
||||||
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error> {
|
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error> {
|
||||||
@@ -424,6 +431,13 @@ pub fn bind_kem_key<R: CryptoRng + ?Sized>(
|
|||||||
|
|
||||||
/// Check a key binding made by [`bind_kem_key`], at time `now` (Arcanum has no clock).
|
/// Check a key binding made by [`bind_kem_key`], at time `now` (Arcanum has no clock).
|
||||||
///
|
///
|
||||||
|
/// **Two checks stay with the caller** (QA S-08): (1) that `vk` is *the* verifying key of `id`,
|
||||||
|
/// from a trusted source: a binding only says "the holder of `vk` says `kem` is `id`'s"; and
|
||||||
|
/// (2) freshness: there is no serial, so after a rotation the previous binding still verifies
|
||||||
|
/// until its `valid.1`. Keep windows short and keep only the binding with the newest `valid.0`
|
||||||
|
/// per `id`, refusing older ones (Day 3's replay design, QA E-07). `(0, u64::MAX)` is an
|
||||||
|
/// eternal binding; avoid it.
|
||||||
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// In this order: [`Error::InvalidValidity`] or [`Error::TooLong`] for a malformed window or id;
|
/// In this order: [`Error::InvalidValidity`] or [`Error::TooLong`] for a malformed window or id;
|
||||||
/// [`Error::InvalidSignature`] if the binding is not authentic; [`Error::OutsideValidity`] if it is
|
/// [`Error::InvalidSignature`] if the binding is not authentic; [`Error::OutsideValidity`] if it is
|
||||||
|
|||||||
Reference in New Issue
Block a user