Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/zeroize/README.md # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / zeroize / README.md` 96 lines ยท 3614 bytes Raw Blame History Rendered 1 # [RustCrypto]: zeroize 2 3 [![Crate][crate-image]][crate-link] 4 [![Docs][docs-image]][docs-link] 5 [![Build Status][build-image]][build-link] 6 ![Apache 2.0/MIT Licensed][license-image] 7 ![MSRV][rustc-image] 8 [![Project Chat][chat-image]][chat-link] 9 10 Securely zero memory (a.k.a. [zeroize]) while avoiding compiler optimizations. 11 12 This crate implements a portable approach to securely zeroing memory using 13 techniques which guarantee they won't be "optimized away" by the compiler. 14 15 The [`Zeroize` trait] is the crate's primary API. 16 17 [Documentation] 18 19 ## About 20 21 [Zeroing memory securely is hard] - compilers optimize for performance, and 22 in doing so they love to "optimize away" unnecessary zeroing calls. There are 23 many documented "tricks" to attempt to avoid these optimizations and ensure 24 that a zeroing routine is performed reliably. 25 26 This crate isn't about tricks: it uses [core::ptr::write_volatile] 27 and [core::sync::atomic] memory fences to provide easy-to-use, portable 28 zeroing behavior which works on all of Rust's core number types and slices 29 thereof, implemented in pure Rust with no usage of FFI or assembly. 30 31 - No insecure fallbacks! 32 - No dependencies! 33 - No FFI or inline assembly! **WASM friendly** (and tested)! 34 - `#![no_std]` i.e. **embedded-friendly**! 35 - No functionality besides securely zeroing memory! 36 - (Optional) Custom derive support for zeroing complex structures 37 38 ## Minimum Supported Rust Version 39 40 Requires Rust **1.85** or newer. 41 42 In the future, we reserve the right to change MSRV (i.e. MSRV is out-of-scope for this crate's 43 semantic versioning guarantees). 44 45 ## Example 46 47 ``` 48 use zeroize::Zeroize; 49 50 // Protip: don't embed secrets in your source code. 51 // This is just an example. 52 let mut secret = b"Air shield password: 1,2,3,4,5".to_vec(); 53 // [ ... ] open the air shield here 54 55 // Now that we're done using the secret, zero it out. 56 secret.zeroize(); 57 ``` 58 59 ## License 60 61 Licensed under either of: 62 63 * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) 64 * [MIT license](http://opensource.org/licenses/MIT) 65 66 at your option. 67 68 ### Contribution 69 70 Unless you explicitly state otherwise, any contribution intentionally submitted 71 for inclusion in the work by you, as defined in the Apache-2.0 license, shall be 72 dual licensed as above, without any additional terms or conditions. 73 74 [//]: # (badges) 75 76 [crate-image]: https://img.shields.io/crates/v/zeroize.svg 77 [crate-link]: https://crates.io/crates/zeroize 78 [build-image]: https://github.com/RustCrypto/utils/actions/workflows/zeroize.yml/badge.svg?branch=master 79 [build-link]: https://github.com/RustCrypto/utils/actions/workflows/zeroize.yml?query=branch:master 80 [docs-image]: https://docs.rs/zeroize/badge.svg 81 [docs-link]: https://docs.rs/zeroize/ 82 [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg 83 [rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg 84 [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg 85 [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260052-utils 86 87 [//]: # (general links) 88 89 [RustCrypto]: https://github.com/RustCrypto 90 [zeroize]: https://en.wikipedia.org/wiki/Zeroisation 91 [`Zeroize` trait]: https://docs.rs/zeroize/latest/zeroize/trait.Zeroize.html 92 [Documentation]: https://docs.rs/zeroize/ 93 [Zeroing memory securely is hard]: http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html 94 [core::ptr::write_volatile]: https://doc.rust-lang.org/core/ptr/fn.write_volatile.html 95 [core::sync::atomic]: https://doc.rust-lang.org/stable/core/sync/atomic/index.html 96 [good cryptographic hygiene]: https://github.com/veorq/cryptocoding#clean-memory-of-secret-data