Add optional zeroize support

This commit is contained in:
Praveen Perera 2021-04-19 11:31:53 -04:00
parent 520e15a6e5
commit a298344178
No known key found for this signature in database
GPG Key ID: FA763323122DA6E9
2 changed files with 13 additions and 0 deletions

View File

@ -46,6 +46,7 @@ rand_core = "0.4.0"
unicode-normalization = { version = "=0.1.9", optional = true }
rand = { version = "0.6.0", optional = true }
serde = { version = "1.0", default-features = false, optional = true }
zeroize = {version = "1.2", optional = true}
[dev-dependencies]
rand = { version = "0.6.0", optional = false }

View File

@ -53,6 +53,11 @@ use bitcoin_hashes::{sha256, Hash};
#[cfg(feature = "std")]
use unicode_normalization::UnicodeNormalization;
#[cfg(feature = "zeroize")]
extern crate zeroize;
#[cfg(feature = "zeroize")]
use zeroize::Zeroize;
#[macro_use]
mod internal_macros;
mod language;
@ -160,6 +165,13 @@ pub struct Mnemonic {
words: [u16; MAX_NB_WORDS],
}
#[cfg(feature = "zeroize")]
impl Zeroize for Mnemonic {
fn zeroize(&mut self) {
self.words.zeroize()
}
}
serde_string_impl!(Mnemonic, "a BIP-39 Mnemonic Code");
impl Mnemonic {