interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

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
10Securely zero memory (a.k.a. [zeroize]) while avoiding compiler optimizations.
11
12This crate implements a portable approach to securely zeroing memory using
13techniques which guarantee they won't be "optimized away" by the compiler.
14
15The [`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
22in doing so they love to "optimize away" unnecessary zeroing calls. There are
23many documented "tricks" to attempt to avoid these optimizations and ensure
24that a zeroing routine is performed reliably.
25
26This crate isn't about tricks: it uses [core::ptr::write_volatile]
27and [core::sync::atomic] memory fences to provide easy-to-use, portable
28zeroing behavior which works on all of Rust's core number types and slices
29thereof, 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
40Requires Rust **1.85** or newer.
41
42In the future, we reserve the right to change MSRV (i.e. MSRV is out-of-scope for this crate's
43semantic versioning guarantees).
44
45## Example
46
47```
48use zeroize::Zeroize;
49
50// Protip: don't embed secrets in your source code.
51// This is just an example.
52let 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.
56secret.zeroize();
57```
58
59## License
60
61Licensed 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
66at your option.
67
68### Contribution
69
70Unless you explicitly state otherwise, any contribution intentionally submitted
71for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
72dual 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