rust-secp256k1-unsafe-fast/secp256k1-sys/src
kwantam 8fffbeab13
implement "non_secure_erase" methods
This PR implements a `non_secure_erase()` method on SecretKey,
KeyPair, SharedSecret, Scalar, and DisplaySecret. The purpose
of this method is to (attempt to) overwrite secret data with
valid default values. This method can be used by libraries
to implement Zeroize on structs containing secret values.

`non_secure_erase()` attempts to avoid being optimized away or
reordered using the same mechanism as the zeroize crate: first,
using `std::ptr::write_volatile` (which will not be optimized
away) to overwrite the memory, then using a memory fence to
prevent subtle issues due to load or store reordering.

Note, however, that this method is *very unlikely* to do anything
useful on its own. Effective use involves carefully placing these
values inside non-Copy structs and pinning those structs in place.
See the [`zeroize`](https://docs.rs/zeroize) documentation for tips
and tricks, and for further discussion.

[this commit includes a squashed-in commit from tcharding to fix docs
and helpful suggestions from apoelstra and Kixunil]
2023-02-21 08:56:03 -05:00
..
lib.rs implement "non_secure_erase" methods 2023-02-21 08:56:03 -05:00
macros.rs Move AsRef impl block next to Index 2022-11-18 10:57:32 +11:00
recovery.rs Upgrade the vendored libsecp256k1 code 2022-12-21 08:11:14 +11:00
types.rs Move more things from the std feature to the alloc feature 2022-06-07 23:59:42 +03:00