Skip to main content

zeroize_slice

Function zeroize_slice 

Source
pub fn zeroize_slice<T: Copy + Default>(slice: &mut [T])
Expand description

Overwrites every element of slice with its Default value.

Uses ptr::write_volatile so the compiler cannot prove the writes are dead and elide them (which it would be allowed to do for ordinary assignments to memory that is about to go out of scope). The compiler_fence prevents reordering the volatile stores with subsequent deallocation or reuse of the backing memory.

Called by Drop implementations and new_wiping constructors to ensure expanded round keys do not linger in memory.