Skip to content

Commit

Permalink
Add dummy zeroize for jh
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Jan 11, 2024
1 parent f2e728e commit 069c74c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions jh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ simd = { package = "ppv-lite86", version = "0.2.6" }

[dev-dependencies]
digest = { version = "=0.11.0-pre.6", features = ["dev"] }

[features]
zeroize = ["digest/zeroize"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
17 changes: 17 additions & 0 deletions jh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ use digest::{
HashMarker, InvalidOutputSize, Output,
};

#[cfg(feature = "zeroize")]
use digest::zeroize::{Zeroize, ZeroizeOnDrop};

/// Core JH hasher state
#[derive(Clone)]
pub struct JhCore {
Expand Down Expand Up @@ -114,3 +117,17 @@ impl fmt::Debug for JhCore {
f.write_str("JhCore { ... }")
}
}

impl Drop for JhCore {
fn drop(&mut self) {
#[cfg(feature = "zeroize")]
{
// TODO: implement Zeroize for Compressor
// self.state.zeroize();
self.block_len.zeroize();
}
}
}

#[cfg(feature = "zeroize")]
impl ZeroizeOnDrop for JhCore {}

0 comments on commit 069c74c

Please sign in to comment.