Skip to content

Commit 6b6a81a

Browse files
committed
Merge branch 'release/2.5' into main
2 parents bd282be + 574347d commit 6b6a81a

12 files changed

+206
-55
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ script:
2727
cargo test --no-default-features --features std &&
2828
cargo test --no-default-features --features "std i128" &&
2929
cargo test --no-default-features --features "std core_hint_black_box" &&
30-
cargo test --no-default-features --features "std i128 core_hint_black_box"
30+
cargo test --no-default-features --features "std const-generics" &&
31+
cargo test --no-default-features --features "std i128 core_hint_black_box" &&
32+
cargo test --no-default-features --features "std i128 core_hint_black_box const-generics"
3133

3234
notifications:
3335
slack:

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
Entries are listed in reverse chronological order.
44

5+
## 2.5.0
6+
7+
* Add constant-timedness note to the documentation for `CtOption::unwrap_or_else`.
8+
* Add `CtOption::expect`.
9+
* Add `ConstantTimeEq::ct_ne` with default implementation.
10+
* Add new `core_hint_black_box` feature from Diane Hosfelt and Amber
11+
Sprenkels which utilises the original `black_box` functionality from
12+
when subtle was first written, which has now found it's way into the
13+
Rust standard library.
14+
* Add new `const-generics` feature from @survived which adds support
15+
for subtle traits for generic arrays `[T; N]`.
16+
* Add new feature for supporting `core::cmp::Ordering` for types which
17+
implement subtle traits, patch from @tarcieri.
18+
* Update `rand` dependency to 0.8.
19+
520
## 2.4.1
621

722
* Fix a bug in how the README was included in the documentation builds

Cargo.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ name = "subtle"
55
# - update html_root_url
66
# - update README if necessary by semver
77
# - if any updates were made to the README, also update the module documentation in src/lib.rs
8-
version = "2.4.1"
8+
version = "2.5.0"
9+
edition = "2018"
910
authors = ["Isis Lovecruft <[email protected]>",
1011
"Henry de Valence <[email protected]>"]
1112
readme = "README.md"
@@ -25,9 +26,10 @@ exclude = [
2526
travis-ci = { repository = "dalek-cryptography/subtle", branch = "master"}
2627

2728
[dev-dependencies]
28-
rand = { version = "0.7" }
29+
rand = { version = "0.8" }
2930

3031
[features]
32+
const-generics = []
3133
core_hint_black_box = []
3234
default = ["std", "i128"]
3335
std = []

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ instead of `bool` which are intended to execute in constant-time. The `Choice`
77
type is a wrapper around a `u8` that holds a `0` or `1`.
88

99
```toml
10-
subtle = "2.4"
10+
subtle = "2.5"
1111
```
1212

1313
This crate represents a “best-effort” attempt, since side-channels
@@ -30,6 +30,9 @@ Rust versions from 1.66 or higher support a new best-effort optimization
3030
barrier ([`core::hint::black_box`]). To use the new optimization barrier,
3131
enable the `core_hint_black_box` feature.
3232

33+
Rust versions from 1.51 or higher have const generics support. You may enable
34+
`const-generics` feautre to have `subtle` traits implemented for arrays `[T; N]`.
35+
3336
Versions prior to `2.2` recommended use of the `nightly` feature to enable an
3437
optimization barrier; this is not required in versions `2.2` and above.
3538

@@ -58,7 +61,7 @@ which attempts to provide a more comprehensive approach for preventing
5861
software side-channels in Rust code.
5962

6063
From version `2.2`, it was based on Diane Hosfelt and Amber Sprenkels' work on
61-
"Secret Types in Rust". Version `2.3` adds the `core_hint_black_box` feature,
64+
"Secret Types in Rust". Version `2.5` adds the `core_hint_black_box` feature,
6265
which uses the original method through the [`core::hint::black_box`] function
6366
from the Rust standard library.
6467

fuzz/Cargo.toml

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
21
[package]
32
name = "subtle-fuzz"
43
version = "0.0.1"
54
authors = ["Automatically generated"]
65
publish = false
6+
edition = "2018"
77

88
[package.metadata]
99
cargo-fuzz = true
1010

1111
[dependencies.subtle]
1212
path = ".."
13-
features = ["nightly"]
14-
[dependencies.libfuzzer-sys]
15-
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
13+
features = ["nightly", "const-generics"]
14+
15+
[dependencies]
16+
libfuzzer-sys = "0.4"
1617

1718
# Prevent this from interfering with workspaces
1819
[workspace]
@@ -21,15 +22,27 @@ members = ["."]
2122
[[bin]]
2223
name = "conditional_assign_u8"
2324
path = "fuzzers/conditional_assign_u8.rs"
25+
test = false
26+
doc = false
2427

2528
[[bin]]
2629
name = "conditional_assign_u16"
2730
path = "fuzzers/conditional_assign_u16.rs"
31+
test = false
32+
doc = false
2833

2934
[[bin]]
3035
name = "conditional_assign_i8"
3136
path = "fuzzers/conditional_assign_i8.rs"
37+
test = false
38+
doc = false
3239

3340
[[bin]]
3441
name = "conditional_assign_i128"
3542
path = "fuzzers/conditional_assign_i128.rs"
43+
test = false
44+
doc = false
45+
46+
[[bin]]
47+
name = "conditional_assign_array"
48+
path = "fuzzers/conditional_assign_array.rs"
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#![no_main]
2+
3+
#[macro_use]
4+
extern crate libfuzzer_sys;
5+
extern crate subtle;
6+
extern crate core;
7+
8+
use core::convert::TryFrom;
9+
10+
use subtle::ConditionallySelectable;
11+
12+
fuzz_target!(|data: &[u8]| {
13+
let chunk_size: usize = 16;
14+
15+
if data.len() % chunk_size != 0 {
16+
return;
17+
}
18+
19+
for bytes in data.chunks(chunk_size) {
20+
let mut x = [0u8; 16];
21+
let y = <[u8; 16]>::try_from(bytes).unwrap();
22+
23+
x.conditional_assign(&y, 0.into());
24+
assert_eq!(x, [0u8; 16]);
25+
26+
x.conditional_assign(&y, 1.into());
27+
assert_eq!(x, y);
28+
}
29+
});

fuzz/fuzzers/conditional_assign_i128.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
#![no_main]
2-
3-
#[macro_use]
4-
extern crate libfuzzer_sys;
5-
extern crate subtle;
6-
extern crate core;
7-
2+
use libfuzzer_sys::fuzz_target;
83
use core::intrinsics::transmute;
9-
104
use subtle::ConditionallySelectable;
115

126
fuzz_target!(|data: &[u8]| {
@@ -20,10 +14,10 @@ fuzz_target!(|data: &[u8]| {
2014
unsafe {
2115
let mut x: i128 = 0;
2216
let y: i128 = transmute::<[u8; 16], i128>([
23-
bytes[0], bytes[1], bytes[2], bytes[3],
24-
bytes[4], bytes[5], bytes[6], bytes[7],
25-
bytes[8], bytes[9], bytes[10], bytes[11],
26-
bytes[12], bytes[13], bytes[14], bytes[15]]);
17+
bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7],
18+
bytes[8], bytes[9], bytes[10], bytes[11], bytes[12], bytes[13], bytes[14],
19+
bytes[15],
20+
]);
2721

2822
x.conditional_assign(&y, 0.into());
2923
assert_eq!(x, 0);

fuzz/fuzzers/conditional_assign_i8.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
#![no_main]
2-
3-
#[macro_use]
4-
extern crate libfuzzer_sys;
5-
extern crate subtle;
6-
extern crate core;
7-
2+
use libfuzzer_sys::fuzz_target;
83
use core::intrinsics::transmute;
9-
104
use subtle::ConditionallySelectable;
115

126
fuzz_target!(|data: &[u8]| {

fuzz/fuzzers/conditional_assign_u16.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
#![no_main]
2-
3-
#[macro_use]
4-
extern crate libfuzzer_sys;
5-
extern crate subtle;
6-
extern crate core;
7-
2+
use libfuzzer_sys::fuzz_target;
83
use core::intrinsics::transmute;
9-
104
use subtle::ConditionallySelectable;
115

126
fuzz_target!(|data: &[u8]| {

fuzz/fuzzers/conditional_assign_u8.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#![no_main]
2-
3-
#[macro_use]
4-
extern crate libfuzzer_sys;
5-
extern crate subtle;
6-
extern crate core;
7-
2+
use libfuzzer_sys::fuzz_target;
83
use subtle::ConditionallySelectable;
94

105
fuzz_target!(|data: &[u8]| {

0 commit comments

Comments
 (0)