Skip to content

Commit edb327f

Browse files
authored
ecdsa: impl Zeroize for Signature (#948)
1 parent 57588e2 commit edb327f

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ecdsa/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ rust-version = "1.85"
1919
[dependencies]
2020
elliptic-curve = { version = "0.14.0-rc.1", default-features = false, features = ["sec1"] }
2121
signature = { version = "=3.0.0-pre", default-features = false, features = ["rand_core"] }
22+
zeroize = { version = "1.5", default-features = false }
2223

2324
# optional dependencies
2425
der = { version = "0.8.0-rc.2", optional = true }

ecdsa/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub use elliptic_curve::{self, PrimeCurve, sec1::EncodedPoint};
7777

7878
// Re-export the `signature` crate (and select types)
7979
pub use signature::{self, Error, Result, SignatureEncoding};
80+
use zeroize::Zeroize;
8081

8182
#[cfg(feature = "signing")]
8283
pub use crate::signing::SigningKey;
@@ -525,6 +526,13 @@ where
525526
}
526527
}
527528

529+
impl<C: EcdsaCurve> Zeroize for Signature<C> {
530+
fn zeroize(&mut self) {
531+
self.r = ScalarPrimitive::ONE;
532+
self.s = ScalarPrimitive::ONE;
533+
}
534+
}
535+
528536
/// An extended [`Signature`] type which is parameterized by an
529537
/// `ObjectIdentifier` which identifies the ECDSA variant used by a
530538
/// particular signature.

0 commit comments

Comments
 (0)