Skip to content

Commit

Permalink
fix zeroize support in jh
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Jan 11, 2024
1 parent 176d993 commit c080ac9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions jh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ impl Drop for JhCore {
fn drop(&mut self) {
#[cfg(feature = "zeroize")]
{
// TODO: implement Zeroize for Compressor
// self.state.zeroize();
const N: usize = core::mem::size_of::<Compressor>();
// TODO: remove this unsafe after migration from `ppv-lite86`
unsafe {
let p: *mut [u8; N] = (&mut self.state as *mut Compressor).cast();
core::ptr::write_volatile(p, [0u8; N]);
}
self.block_len.zeroize();
}
}
Expand Down

0 comments on commit c080ac9

Please sign in to comment.