You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rust/keystore: more code clarity in memory zeroing
In `copy_seed()`, the seed is put on the heap in a Zeroize<> Vec. When
creating that vector, if the compiler does not optimize, the seed is
first in a stack var and then copied to the heap.
The expression `seed[..seed_len].to_vec()` does not make it obvious
that the seed is not stored in an intermediate non-zeroed location
before being copied into a Vec.
Instead, we use a zeroized Vec from the start, which eliminates these
two potential problems.
Truncating the vector should not result in a copy:
https://doc.rust-lang.org/std/vec/struct.Vec.html#method.truncate
> Note that this method has no effect on the allocated capacity of the vector.
0 commit comments