Skip to content

Commit 8351f02

Browse files
committed
Fix builds by removing include_str!(docs).
The latest rust nightlies and beta (at stable version 1.55) include a change from #![cfg_attr(feature = "nightly", feature(external_doc))] #![cfg_attr(feature = "nightly", doc(include = "../README.md"))] to removing `feature(external_doc)` and also changing the syntax of the second line to #![cfg_attr(feature = "nightly", doc = include_str!("../README.md"))] However. `include_str!` is stable currently, but the syntax of `doc = ` is expressly disallowed. This gives me four options: 1. Don't build documentation (bad) 2. Copy-pasta README.md into src/lib.rs (also bad) 3. Support only beta/nightly but not stable (completely untennable for a crate with ~14 million downloads) 4. Support only stable but not beta/nightly (also untennable) Further, waiting for this to be "fixed" by its inclusion in stable Rust in about a week means that our MSRV increases from 1.41 to 1.56, with no changes to actual code (other than how to build documentation) at all, which seems quite unfriendly to downstream dependents who are pinning their rust versions for whatever reason. So, sadly, it seems the most friendly fix is to copy-pasta our README.md into the codebase. (cf. rust-lang/rust#44732, rust-lang/rust#82539)
1 parent 8a70fff commit 8351f02

File tree

2 files changed

+72
-4
lines changed

2 files changed

+72
-4
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ name = "subtle"
44
# - update CHANGELOG
55
# - update html_root_url
66
# - update README if necessary by semver
7+
# - if any updates were made to the README, also update the module documentation in src/lib.rs
78
version = "2.4.0"
89
authors = ["Isis Lovecruft <isis@patternsinthevoid.net>",
910
"Henry de Valence <hdevalence@hdevalence.ca>"]
@@ -30,4 +31,5 @@ rand = { version = "0.7" }
3031
default = ["std", "i128"]
3132
std = []
3233
i128 = []
34+
# DEPRECATED: As of 2.4.1, this feature does nothing.
3335
nightly = []

src/lib.rs

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,79 @@
99
// - Henry de Valence <hdevalence@hdevalence.ca>
1010

1111
#![no_std]
12-
#![cfg_attr(feature = "nightly", doc = include_str!("../README.md"))]
13-
#![cfg_attr(feature = "nightly", deny(missing_docs))]
12+
#![deny(missing_docs)]
1413
#![doc(html_logo_url = "https://doc.dalek.rs/assets/dalek-logo-clear.png")]
1514
#![doc(html_root_url = "https://docs.rs/subtle/2.4.0")]
1615

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://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)
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
1985
2086
#[cfg(feature = "std")]
2187
#[macro_use]

0 commit comments

Comments
 (0)