Skip to content

[ml-dsa]Implement Zeroize for MLDSASigningKey/[traits,secrets,chacha20poly1305]Implement Zeroize for AEAD Key#1387

Open
MavenRain wants to merge 2 commits into
celabshq:mainfrom
MavenRain:onyeka/zeroize
Open

[ml-dsa]Implement Zeroize for MLDSASigningKey/[traits,secrets,chacha20poly1305]Implement Zeroize for AEAD Key#1387
MavenRain wants to merge 2 commits into
celabshq:mainfrom
MavenRain:onyeka/zeroize

Conversation

@MavenRain

Copy link
Copy Markdown

Add an optional zeroize feature implementing Zeroize, Drop, and
ZeroizeOnDrop for MLDSASigningKey and MLDSAKeyPair. MLDSAKeyPair
clears only the signing key; the verification key is public material.

Gated on not(hax) so hax extraction is unaffected.

Closes #1370.

Add an optional zeroize feature:

  • libcrux-secrets: Zeroize for Secret<T> where T: Zeroize, so [U8; N] zeroizes under both default (U8 = u8) and check-secret-independence (U8 = Secret) configurations.
  • libcrux-traits: Zeroize for typed_owned::Key<Algo> where Algo::Key: Zeroize. Covers chacha20poly1305::Key and any future AEAD whose key bytes are Zeroize.
  • libcrux-chacha20poly1305: zeroize feature forwarding to both.

Drop and ZeroizeOnDrop are not implemented in this PR. Adding them
requires Algo::Key: Zeroize as a bound on typed_owned::Aead (or a
sealed helper trait), which is a larger trait-level change. Happy to
follow up if maintainers want one of those approaches. In the meantime,
callers wanting drop-on-zero can wrap in zeroize::Zeroizing<Key<...>>.

Closes #1375.

…0poly1305]Implement Zeroize for AEAD Key

  Add an optional `zeroize` feature implementing Zeroize, Drop, and
  ZeroizeOnDrop for MLDSASigningKey<SIZE> and MLDSAKeyPair.  MLDSAKeyPair
  clears only the signing key; the verification key is public material.

  Gated on `not(hax)` so hax extraction is unaffected.

  Closes celabshq#1370.

  Add an optional `zeroize` feature:

  - libcrux-secrets: `Zeroize for Secret<T> where T: Zeroize`, so `[U8; N]`
    zeroizes under both default (U8 = u8) and `check-secret-independence`
    (U8 = Secret<u8>) configurations.
  - libcrux-traits: `Zeroize for typed_owned::Key<Algo>` where
    `Algo::Key: Zeroize`.  Covers `chacha20poly1305::Key` and any future
    AEAD whose key bytes are Zeroize.
  - libcrux-chacha20poly1305: `zeroize` feature forwarding to both.

  Drop and ZeroizeOnDrop are not implemented in this PR.  Adding them
  requires `Algo::Key: Zeroize` as a bound on `typed_owned::Aead` (or a
  sealed helper trait), which is a larger trait-level change.  Happy to
  follow up if maintainers want one of those approaches.  In the meantime,
  callers wanting drop-on-zero can wrap in `zeroize::Zeroizing<Key<...>>`.

  Closes celabshq#1375.
@MavenRain MavenRain requested review from a team as code owners April 22, 2026 01:25
@MavenRain MavenRain requested a review from keks April 22, 2026 01:25
@jschneider-bensch jschneider-bensch added the waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 22, 2026
@jschneider-bensch jschneider-bensch requested review from jschneider-bensch and removed request for keks April 22, 2026 08:28
  Resolve conflict in crates/algorithms/chacha20poly1305/Cargo.toml
  dev-dependencies: keep the upstream upgrade to rand_core 0.10
  (and the new rand = "0.10" with the sys_rng feature) alongside
  the zeroize dev-dep added on this branch.
@jschneider-bensch

Copy link
Copy Markdown
Collaborator

Thanks! I will review when I have capacity for it.
I'll say upfront (as mentioned in #1332) that I'm a bit apprehensive about adding new cargo features and I'm thinking about different ways to manage array-backed key types (cf. #1390).

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been marked as stale due to a lack of activity for 60 days. If you believe this pull request is still relevant, please provide an update or comment to keep it open. Otherwise, it will be closed in 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

keep-open waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

2 participants