Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions blake2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## 0.11.1 (UNRELEASED)
### Fixed
- Zeroization with enabled `reset` crate feature ([#966])
- `Blake2b` and `Blake2s` now implement `ZeroizeOnDrop` ([#912])

[#966]: https://github.com/RustCrypto/hashes/pull/966
[#912]: https://github.com/RustCrypto/hashes/issues/912

## 0.11.0 (2026-08-26)
### Added
Expand Down
12 changes: 12 additions & 0 deletions blake2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ pub type Blake2b256 = Blake2b<U32>;
/// BLAKE2b-512 hasher state.
pub type Blake2b512 = Blake2b<U64>;

#[cfg(feature = "zeroize")]
impl<OutSize> ZeroizeOnDrop for Blake2b<OutSize> where
OutSize: ArraySize + IsLessOrEqual<U64, Output = True>
{
}

blake2_mac_impl!(Blake2bMac, Blake2bVarCore, U64, "Blake2b MAC function");

/// BLAKE2b-512 MAC state.
Expand Down Expand Up @@ -126,6 +132,12 @@ pub type Blake2s128 = Blake2s<U16>;
/// BLAKE2s-256 hasher state.
pub type Blake2s256 = Blake2s<U32>;

#[cfg(feature = "zeroize")]
impl<OutSize> ZeroizeOnDrop for Blake2s<OutSize> where
OutSize: ArraySize + IsLessOrEqual<U32, Output = True>
{
}

blake2_mac_impl!(Blake2sMac, Blake2sVarCore, U32, "Blake2s MAC function");

/// BLAKE2s-256 MAC state.
Expand Down
15 changes: 15 additions & 0 deletions blake2/tests/zeroize.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! `ZeroizeOnDrop` support for the fixed-output hashers.

#[cfg(feature = "zeroize")]
#[test]
fn zeroize_on_drop() {
use blake2::{Blake2b512, Blake2bMac512, Blake2s256, Blake2sMac256};
use digest::zeroize::ZeroizeOnDrop;

fn assert_zeroize_on_drop<T: ZeroizeOnDrop>() {}

assert_zeroize_on_drop::<Blake2b512>();
assert_zeroize_on_drop::<Blake2s256>();
assert_zeroize_on_drop::<Blake2bMac512>();
assert_zeroize_on_drop::<Blake2sMac256>();
}
Loading