Skip to content

Commit f1a041a

Browse files
Rust wrapper: add zeroizing Drop impl for ChaCha20Poly1305
Fix F-1069
1 parent 2c981d6 commit f1a041a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

wrapper/rust/wolfssl-wolfcrypt/src/chacha20_poly1305.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,17 @@ impl ChaCha20Poly1305 {
243243
}
244244
}
245245

246+
impl Drop for ChaCha20Poly1305 {
247+
fn drop(&mut self) {
248+
unsafe {
249+
let ptr = &mut self.wc_ccp as *mut sys::ChaChaPoly_Aead as *mut u8;
250+
for i in 0..core::mem::size_of::<sys::ChaChaPoly_Aead>() {
251+
core::ptr::write_volatile(ptr.add(i), 0);
252+
}
253+
}
254+
}
255+
}
256+
246257
// ---------------------------------------------------------------------------
247258
// ChaCha20-Poly1305 aead trait implementations
248259
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)