Skip to content

Commit 0abb475

Browse files
committed
f Use write_volatile
1 parent 03ca9d9 commit 0abb475

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/util/key_obfuscator.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,17 @@ impl KeyObfuscator {
155155
impl Drop for KeyObfuscator {
156156
fn drop(&mut self) {
157157
// Zeroize the owned keys
158-
self.obfuscation_key.copy_from_slice(&[0u8; KEY_LENGTH]);
159-
self.hashing_key.copy_from_slice(&[0u8; KEY_LENGTH]);
158+
for elem in self.obfuscation_key.iter_mut() {
159+
unsafe {
160+
::core::ptr::write_volatile(elem, 0);
161+
}
162+
}
163+
for elem in self.hashing_key.iter_mut() {
164+
unsafe {
165+
::core::ptr::write_volatile(elem, 0);
166+
}
167+
}
168+
::core::sync::atomic::compiler_fence(::core::sync::atomic::Ordering::SeqCst);
160169
}
161170
}
162171

0 commit comments

Comments
 (0)