Skip to content

Borrowed zeroizing guard for &mut [u8] #1509

Description

@mattrighetti

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions