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 / subtle / README.md

74 lines · 3415 bytes Raw Blame History Rendered
1# subtle [![](https://img.shields.io/crates/v/subtle.svg)](https://crates.io/crates/subtle) [![](https://img.shields.io/badge/dynamic/json.svg?label=docs&uri=https%3A%2F%2Fcrates.io%2Fapi%2Fv1%2Fcrates%2Fsubtle%2Fversions&query=%24.versions%5B0%5D.num&colorB=4F74A6)](https://doc.dalek.rs/subtle) [![](https://travis-ci.org/dalek-cryptography/subtle.svg?branch=master)](https://travis-ci.org/dalek-cryptography/subtle)
2
3**Pure-Rust traits and utilities for constant-time cryptographic implementations.**
4
5It consists of a `Choice` type, and a collection of traits using `Choice`
6instead of `bool` which are intended to execute in constant-time. The `Choice`
7type is a wrapper around a `u8` that holds a `0` or `1`.
8
9```toml
10subtle = "2.6"
11```
12
13This crate represents a “best-effort” attempt, since side-channels
14are ultimately a property of a deployed cryptographic system
15including the hardware it runs on, not just of software.
16
17The traits are implemented using bitwise operations, and should execute in
18constant time provided that a) the bitwise operations are constant-time and
19b) the bitwise operations are not recognized as a conditional assignment and
20optimized back into a branch.
21
22For a compiler to recognize that bitwise operations represent a conditional
23assignment, it needs to know that the value used to generate the bitmasks is
24really a boolean `i1` rather than an `i8` byte value. In an attempt to
25prevent this refinement, the crate tries to hide the value of a `Choice`'s
26inner `u8` by passing it through a volatile read. For more information, see
27the _About_ section below.
28
29Rust versions from 1.51 or higher have const generics support. You may enable
30`const-generics` feautre to have `subtle` traits implemented for arrays `[T; N]`.
31
32Versions prior to `2.2` recommended use of the `nightly` feature to enable an
33optimization barrier; this is not required in versions `2.2` and above.
34
35Note: the `subtle` crate contains `debug_assert`s to check invariants during
36debug builds. These invariant checks involve secret-dependent branches, and
37are not present when compiled in release mode. This crate is intended to be
38used in release mode.
39
40## Documentation
41
42Documentation is available [here][docs].
43
44## Minimum Supported Rust Version
45
46Rust **1.41** or higher.
47
48Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump.
49
50## About
51
52This library aims to be the Rust equivalent of Go’s `crypto/subtle` module.
53
54Old versions of the optimization barrier in `impl From<u8> for Choice` were
55based on Tim Maclean's [work on `rust-timing-shield`][rust-timing-shield],
56which attempts to provide a more comprehensive approach for preventing
57software side-channels in Rust code.
58From version `2.2`, it was based on Diane Hosfelt and Amber Sprenkels' work on
59"Secret Types in Rust".
60
61`subtle` is authored by isis agora lovecruft and Henry de Valence.
62
63## Warning
64
65This code is a low-level library, intended for specific use-cases implementing
66cryptographic protocols. It represents a best-effort attempt to protect
67against some software side-channels. Because side-channel resistance is not a
68property of software alone, but of software together with hardware, any such
69effort is fundamentally limited.
70
71**USE AT YOUR OWN RISK**
72
73[docs]: https://docs.rs/subtle
74[rust-timing-shield]: https://www.chosenplaintext.ca/open-source/rust-timing-shield/security