|
9 | 9 | // - Henry de Valence <[email protected]>
|
10 | 10 |
|
11 | 11 | #![no_std]
|
12 |
| -#![cfg_attr(feature = "nightly", doc = include_str!("../README.md"))] |
13 |
| -#![cfg_attr(feature = "nightly", deny(missing_docs))] |
| 12 | +#![deny(missing_docs)] |
14 | 13 | #![doc(html_logo_url = "https://doc.dalek.rs/assets/dalek-logo-clear.png")]
|
15 | 14 | #![doc(html_root_url = "https://docs.rs/subtle/2.4.1")]
|
16 | 15 |
|
17 |
| -//! Note that docs will only build on nightly Rust until |
18 |
| -//! [RFC 1990 stabilizes](https://github.com/rust-lang/rust/issues/44732). |
| 16 | +//! # subtle [](https://crates.io/crates/subtle) [](https://doc.dalek.rs/subtle) [](https://travis-ci.org/dalek-cryptography/subtle) |
| 17 | +//! |
| 18 | +//! **Pure-Rust traits and utilities for constant-time cryptographic implementations.** |
| 19 | +//! |
| 20 | +//! It consists of a `Choice` type, and a collection of traits using `Choice` |
| 21 | +//! instead of `bool` which are intended to execute in constant-time. The `Choice` |
| 22 | +//! type is a wrapper around a `u8` that holds a `0` or `1`. |
| 23 | +//! |
| 24 | +//! ```toml |
| 25 | +//! subtle = "2.4" |
| 26 | +//! ``` |
| 27 | +//! |
| 28 | +//! This crate represents a “best-effort” attempt, since side-channels |
| 29 | +//! are ultimately a property of a deployed cryptographic system |
| 30 | +//! including the hardware it runs on, not just of software. |
| 31 | +//! |
| 32 | +//! The traits are implemented using bitwise operations, and should execute in |
| 33 | +//! constant time provided that a) the bitwise operations are constant-time and |
| 34 | +//! b) the bitwise operations are not recognized as a conditional assignment and |
| 35 | +//! optimized back into a branch. |
| 36 | +//! |
| 37 | +//! For a compiler to recognize that bitwise operations represent a conditional |
| 38 | +//! assignment, it needs to know that the value used to generate the bitmasks is |
| 39 | +//! really a boolean `i1` rather than an `i8` byte value. In an attempt to |
| 40 | +//! prevent this refinement, the crate tries to hide the value of a `Choice`'s |
| 41 | +//! inner `u8` by passing it through a volatile read. For more information, see |
| 42 | +//! the _About_ section below. |
| 43 | +//! |
| 44 | +//! Versions prior to `2.2` recommended use of the `nightly` feature to enable an |
| 45 | +//! optimization barrier; this is not required in versions `2.2` and above. |
| 46 | +//! |
| 47 | +//! Note: the `subtle` crate contains `debug_assert`s to check invariants during |
| 48 | +//! debug builds. These invariant checks involve secret-dependent branches, and |
| 49 | +//! are not present when compiled in release mode. This crate is intended to be |
| 50 | +//! used in release mode. |
| 51 | +//! |
| 52 | +//! ## Documentation |
| 53 | +//! |
| 54 | +//! Documentation is available [here][docs]. |
| 55 | +//! |
| 56 | +//! ## Minimum Supported Rust Version |
| 57 | +//! |
| 58 | +//! Rust **1.41** or higher. |
| 59 | +//! |
| 60 | +//! Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. |
| 61 | +//! |
| 62 | +//! ## About |
| 63 | +//! |
| 64 | +//! This library aims to be the Rust equivalent of Go’s `crypto/subtle` module. |
| 65 | +//! |
| 66 | +//! The optimization barrier in `impl From<u8> for Choice` was based on Tim |
| 67 | +//! Maclean's [work on `rust-timing-shield`][rust-timing-shield], which attempts to |
| 68 | +//! provide a more comprehensive approach for preventing software side-channels in |
| 69 | +//! Rust code. |
| 70 | +//! |
| 71 | +//! `subtle` is authored by isis agora lovecruft and Henry de Valence. |
| 72 | +//! |
| 73 | +//! ## Warning |
| 74 | +//! |
| 75 | +//! This code is a low-level library, intended for specific use-cases implementing |
| 76 | +//! cryptographic protocols. It represents a best-effort attempt to protect |
| 77 | +//! against some software side-channels. Because side-channel resistance is not a |
| 78 | +//! property of software alone, but of software together with hardware, any such |
| 79 | +//! effort is fundamentally limited. |
| 80 | +//! |
| 81 | +//! **USE AT YOUR OWN RISK** |
| 82 | +//! |
| 83 | +//! [docs]: https://docs.rs/subtle |
| 84 | +//! [rust-timing-shield]: https://www.chosenplaintext.ca/open-source/rust-timing-shield/security |
19 | 85 |
|
20 | 86 | #[cfg(feature = "std")]
|
21 | 87 | #[macro_use]
|
|
0 commit comments