From 3e27bf3c77901920a8463207d5a054244dad73f4 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Tue, 29 Apr 2025 18:56:27 +0200 Subject: [PATCH] Implement `Zeroize` for `ed25519::Signature` --- ed25519/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ed25519/src/lib.rs b/ed25519/src/lib.rs index 01f3951f..d62e0cbc 100644 --- a/ed25519/src/lib.rs +++ b/ed25519/src/lib.rs @@ -292,6 +292,9 @@ use pkcs8::spki::{ der::{self, asn1::BitString}, }; +#[cfg(feature = "zeroize")] +use zeroize::Zeroize; + /// Size of a single component of an Ed25519 signature. const COMPONENT_SIZE: usize = 32; @@ -446,3 +449,11 @@ impl fmt::Display for Signature { write!(f, "{:X}", self) } } + +#[cfg(feature = "zeroize")] +impl Zeroize for Signature { + fn zeroize(&mut self) { + self.R = [0; 32]; + self.s = [0; 32]; + } +}