Skip to content

Commit bb0c0a2

Browse files
committed
cmov v0.5.0-pre.2
1 parent ec38437 commit bb0c0a2

File tree

4 files changed

+35
-15
lines changed

4 files changed

+35
-15
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmov/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cmov"
3-
version = "0.5.0-pre.1"
3+
version = "0.5.0-pre.2"
44
authors = ["RustCrypto Developers"]
55
edition = "2024"
66
rust-version = "1.85"

cmov/README.md

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,14 @@ execution features which might introduce timing or other microarchitectural
2222
sidechannels introduced by branch prediction or other speculative execution
2323
features.
2424

25-
Intel has confirmed that all extant CPUs implement the CMOV family of
26-
instructions in constant-time, and that this property will hold for future
27-
Intel CPUs as well.
28-
2925
This crate provides wrappers for the CMOV/CSEL instructions implemented using
30-
inline assembly as stabilized in Rust 1.59. This means the implementation
31-
is a black box that will not be rewritten by e.g. LLVM's architecture-specific
32-
lowerings, such as the [x86-cmov-conversion] pass.
26+
inline `asm!`, which means the implementation is a black box that will not be
27+
rewritten by e.g. LLVM's architecture-specific lowerings, such as the
28+
[x86-cmov-conversion] pass.
3329

3430
## Supported target architectures
3531

36-
This crate provides guaranteed constant-time operation using inline assembly
32+
This crate provides guaranteed constant-time operation using inline `asm!`
3733
on the following CPU architectures:
3834

3935
- [x] `x86` (`CMOVZ`, `CMOVNZ`)
@@ -42,11 +38,33 @@ on the following CPU architectures:
4238
- [x] `aarch64` (`CSEL`)
4339

4440
On other target architectures, a "best effort" portable fallback implementation
45-
based on bitwise arithmetic is used instead. However, we cannot guarantee that
46-
this implementation generates branch-free code.
41+
based on bitwise arithmetic is used instead, augmented with tactical usage of
42+
`core::hint::black_box` based on past analysis of the generated assembly.
43+
However, we cannot guarantee that this implementation generates branch-free
44+
code, especially on hypothetical future rustc versions which introduce new
45+
optimizations.
46+
47+
Please [open an issue] if you notice non-constant-time CPU instructions
48+
(e.g. branches, secret-dependent address calculations) being generated and we
49+
will treat it as a security issue and do our best to find a solution.
50+
51+
You can also open an issue to request first-class support for native
52+
predication instructions on other architectures we don't currently support.
53+
54+
### `x86` / `x86_64` notes
55+
56+
Intel has confirmed that all extant CPUs implement the CMOV family of
57+
instructions in constant-time, and that this property will hold for future
58+
Intel CPUs as well.
59+
60+
## ⚠️ Security Warning
61+
62+
The implementation contained in this crate has never been independently audited!
63+
USE AT YOUR OWN RISK!
64+
65+
Below are security issues this crate has experienced in the past:
4766

48-
It's possible to extend constant-time guarantees to other CPU architectures.
49-
Please open an issue with your desired CPU architecture if this interests you.
67+
- [RUSTSEC-2026-0003]: Non-constant-time code generation on ARM32 targets
5068

5169
## Minimum Supported Rust Version (MSRV) Policy
5270

@@ -91,3 +109,5 @@ dual licensed as above, without any additional terms or conditions.
91109
[CSEL]: https://developer.arm.com/documentation/dui0802/b/CSEL
92110
[predication]: https://en.wikipedia.org/wiki/Predication_(computer_architecture)
93111
[x86-cmov-conversion]: https://dsprenkels.com/cmov-conversion.html
112+
[open an issue]: https://github.com/RustCrypto/utils/issues
113+
[RUSTSEC-2026-0003]: https://rustsec.org/advisories/RUSTSEC-2026-0003.html

ctutils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ edition = "2024"
1717
rust-version = "1.85"
1818

1919
[dependencies]
20-
cmov = "0.5.0-pre.0"
20+
cmov = "0.5.0-pre.2"
2121

2222
# optional dependencies
2323
subtle = { version = "2", optional = true, default-features = false }

0 commit comments

Comments
 (0)