Skip to content

Commit

Permalink
fixup zeroize
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Mar 13, 2024
1 parent 0d129f4 commit 2cb69a3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion sha1-checked/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exclude = [
[dependencies]
digest = "0.10.7"
sha1 = { version = "0.10.6", default-features = false, features = ["compress"] }
zeroize = { version = "1.7", default-features = false, optional = true }

[dev-dependencies]
digest = { version = "0.10.7", features = ["dev"] }
Expand All @@ -29,7 +30,7 @@ hex-literal = "0.4"
default = ["oid", "std"]
std = ["digest/std", "sha1/std"]
oid = ["digest/oid", "sha1/oid"] # Enable OID support
zeroize = []
zeroize = ["dep:zeroize"]


[package.metadata.docs.rs]
Expand Down
14 changes: 2 additions & 12 deletions sha1-checked/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ use core::slice::from_ref;
#[cfg(feature = "std")]
extern crate std;

#[cfg(feature = "zeroize")]
use digest::zeroize::{Zeroize, ZeroizeOnDrop};
use digest::{
block_buffer::{BlockBuffer, Eager},
core_api::BlockSizeUser,
typenum::{Unsigned, U20, U64},
FixedOutput, FixedOutputReset, HashMarker, Output, OutputSizeUser, Reset, Update,
};
#[cfg(feature = "zeroize")]
use zeroize::{Zeroize, ZeroizeOnDrop};

const BLOCK_SIZE: usize = <sha1::Sha1Core as BlockSizeUser>::BlockSize::USIZE;
const STATE_LEN: usize = 5;
Expand Down Expand Up @@ -212,16 +212,6 @@ impl FixedOutputReset for Sha1 {
}
}

impl Drop for Sha1 {
#[inline]
fn drop(&mut self) {
#[cfg(feature = "zeroize")]
{
self.buffer.zeroize();
}
}
}

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

Expand Down

0 comments on commit 2cb69a3

Please sign in to comment.