Skip to content

Commit

Permalink
Zeroize intermediate strings allocated during seed construction (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
karbyshev committed May 21, 2023
1 parent 4bde6ea commit adb249a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/seed.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt;
use unicode_normalization::UnicodeNormalization;
use zeroize::Zeroize;
use zeroize::{Zeroize, Zeroizing};
use crate::crypto::pbkdf2;
use crate::mnemonic::Mnemonic;

Expand Down Expand Up @@ -31,8 +31,8 @@ impl Seed {
///
/// [Mnemonic]: ./mnemonic/struct.Mnemonic.html
pub fn new(mnemonic: &Mnemonic, password: &str) -> Self {
let salt = format!("mnemonic{}", password);
let normalized_salt = salt.nfkd().to_string();
let salt = Zeroizing::new(format!("mnemonic{}", password));
let normalized_salt = Zeroizing::new(salt.nfkd().to_string());
let bytes = pbkdf2(mnemonic.phrase().as_bytes(), &normalized_salt);

Self { bytes }
Expand Down

0 comments on commit adb249a

Please sign in to comment.