RustCrypto / RustCrypto/utils

Borrowed zeroizing guard for `&mut [u8]`

Open
#1,509 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
674
Forks
170
Avg merge
1d 12h
Merged PRs (30d)
10

Description

Zeroizing<T> requires the stored type T itself to implement Zeroize. [u8] does but &mut [u8] does not.

I have a large reusable validator buffer where I need per-validation cleanup. Current workaround is a small guard:

struct ZeroizeOnDrop<'a>(&'a mut [u8]);

impl Drop for ZeroizeOnDrop<'_> {
   fn drop(&mut self) {
       self.0.zeroize();
   }
}

Would you be open to adding an official borrowed guard, e.g. ZeroizingRef<'a, T: Zeroize + ?Sized>(&'a mut T), for this use case?

I'm open to alternatives

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing Zeroizing and Zeroize implementations, then compare their behavior with the proposed borrowed guard for &mut [u8]. Determine whether the API should add ZeroizingRef<'a, T: Zeroize + ?Sized> or an alternative. Done means the project has an agreed public API for borrowed cleanup, with the use case and drop behavior covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cryptography, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.