commit | 34a3955d942937139aeb0adf28b2b4c2fca2c7d5 | [log] [tgz] |
---|---|---|
author | Pierre-Clément Tosi <[email protected]> | Tue Nov 01 17:01:01 2022 +0000 |
committer | Pierre-Clément Tosi <[email protected]> | Mon Nov 14 20:28:39 2022 +0000 |
tree | 09a76155cb53a2f088b6a9d211023eb5b95fd543 | |
parent | 16cc42d73a749e72552abc03c8c5dc961aef47c8 [diff] |
Add a no_std variant of libzeroize The current "libzeroize" requires std support so add a new rust_library that links against the core library, instead. As the crate's "alloc" feature requires an allocator and as there isn't a single standard implementation of it in no_std, don't enable the feature for "libzeroize_nostd". Otherwise, given how Android builds Rust libraries, this would force all users of the rust_library to use and share the same allocator implementation. Test: m pvmfw_bin # libzeroize_nostd linked in aosp/2280853 Change-Id: Ia971829111cd4678cedc16c7e8435a20476caa85
Securely zero memory (a.k.a. zeroize) while avoiding compiler optimizations.
This crate implements a portable approach to securely zeroing memory using techniques which guarantee they won't be “optimized away” by the compiler.
The Zeroize
trait is the crate's primary API.
Zeroing memory securely is hard - compilers optimize for performance, and in doing so they love to “optimize away” unnecessary zeroing calls. There are many documented “tricks” to attempt to avoid these optimizations and ensure that a zeroing routine is performed reliably.
This crate isn‘t about tricks: it uses core::ptr::write_volatile and core::sync::atomic memory fences to provide easy-to-use, portable zeroing behavior which works on all of Rust’s core number types and slices thereof, implemented in pure Rust with no usage of FFI or assembly.
#![no_std]
i.e. embedded-friendly!Rust 1.51 or newer.
In the future, we reserve the right to change MSRV (i.e. MSRV is out-of-scope for this crate's SemVer guarantees), however when we do it will be accompanied by a minor version bump.
Licensed under either of:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.