Debian Codegraph @

third_party/rust/zeroize/README.md

raw
1 # [RustCrypto]: zeroize
2
3 [![Crate][crate-image]][crate-link]
4 [![Docs][docs-image]][docs-link]
5 ![Apache 2.0/MIT Licensed][license-image]
6 ![MSRV][rustc-image]
7 [![Build Status][build-image]][build-link]
8
9 Securely zero memory (a.k.a. [zeroize]) while avoiding compiler optimizations.
10
11 This crate implements a portable approach to securely zeroing memory using
12 techniques which guarantee they won't be "optimized away" by the compiler.
13
14 The [`Zeroize` trait] is the crate's primary API.
15
16 [Documentation]
17
18 ## About
19
20 [Zeroing memory securely is hard] - compilers optimize for performance, and
21 in doing so they love to "optimize away" unnecessary zeroing calls. There are
22 many documented "tricks" to attempt to avoid these optimizations and ensure
23 that a zeroing routine is performed reliably.
24
25 This crate isn't about tricks: it uses [core::ptr::write_volatile]
26 and [core::sync::atomic] memory fences to provide easy-to-use, portable
27 zeroing behavior which works on all of Rust's core number types and slices
28 thereof, implemented in pure Rust with no usage of FFI or assembly.
29
30 - No insecure fallbacks!
31 - No dependencies!
32 - No FFI or inline assembly! **WASM friendly** (and tested)!
33 - `#![no_std]` i.e. **embedded-friendly**!
34 - No functionality besides securely zeroing memory!
35 - (Optional) Custom derive support for zeroing complex structures
36
37 ## Minimum Supported Rust Version
38
39 Rust **1.60** or newer.
40
41 In the future, we reserve the right to change MSRV (i.e. MSRV is out-of-scope
42 for this crate's SemVer guarantees), however when we do it will be accompanied by
43 a minor version bump.
44
45 ## License
46
47 Licensed under either of:
48
49 * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
50 * [MIT license](http://opensource.org/licenses/MIT)
51
52 at your option.
53
54 ### Contribution
55
56 Unless you explicitly state otherwise, any contribution intentionally submitted
57 for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
58 dual licensed as above, without any additional terms or conditions.
59
60 [//]: # (badges)
61
62 [crate-image]: https://img.shields.io/crates/v/zeroize.svg
63 [crate-link]: https://crates.io/crates/zeroize
64 [docs-image]: https://docs.rs/zeroize/badge.svg
65 [docs-link]: https://docs.rs/zeroize/
66 [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
67 [rustc-image]: https://img.shields.io/badge/rustc-1.60+-blue.svg
68 [build-image]: https://github.com/RustCrypto/utils/actions/workflows/zeroize.yml/badge.svg
69 [build-link]: https://github.com/RustCrypto/utils/actions/workflows/zeroize.yml
70
71 [//]: # (general links)
72
73 [RustCrypto]: https://github.com/RustCrypto
74 [zeroize]: https://en.wikipedia.org/wiki/Zeroisation
75 [`Zeroize` trait]: https://docs.rs/zeroize/latest/zeroize/trait.Zeroize.html
76 [Documentation]: https://docs.rs/zeroize/
77 [Zeroing memory securely is hard]: http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html
78 [core::ptr::write_volatile]: https://doc.rust-lang.org/core/ptr/fn.write_volatile.html
79 [core::sync::atomic]: https://doc.rust-lang.org/stable/core/sync/atomic/index.html
80 [good cryptographic hygiene]: https://github.com/veorq/cryptocoding#clean-memory-of-secret-data