Skip to content

Commit 0ceaf97

Browse files
committed
k256: impl Drop for ecdsa::SigningKey
Adds a `Drop` handler which calls `zeroize()` on the `NonZeroScalar` which the `SigningKey` newtype wraps.
1 parent daa50d5 commit 0ceaf97

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

k256/src/ecdsa/sign.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use elliptic_curve::{
1919
ops::{Invert, Reduce},
2020
rand_core::{CryptoRng, RngCore},
2121
subtle::{Choice, ConstantTimeEq},
22+
zeroize::Zeroize,
2223
};
2324

2425
#[cfg(any(feature = "keccak256", feature = "sha256"))]
@@ -274,6 +275,12 @@ impl From<&NonZeroScalar> for SigningKey {
274275
}
275276
}
276277

278+
impl Drop for SigningKey {
279+
fn drop(&mut self) {
280+
self.inner.zeroize();
281+
}
282+
}
283+
277284
#[cfg(feature = "pkcs8")]
278285
#[cfg_attr(docsrs, doc(cfg(feature = "pkcs8")))]
279286
impl FromPrivateKey for SigningKey {

0 commit comments

Comments
 (0)