Skip to content

Commit f64379d

Browse files
authored
ctutils v0.1.0 (#1265)
Initial release
1 parent 14297e2 commit f64379d

File tree

8 files changed

+25
-7
lines changed

8 files changed

+25
-7
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.

ctutils/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## 0.1.0 (2025-12-19)
8+
- Initial release

ctutils/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Constant-time utility library with selection and equality testing support target
55
applications. Supports `const fn` where appropriate. Built on the `cmov` crate which provides
66
architecture-specific predication intrinsics. Heavily inspired by the `subtle` crate.
77
"""
8-
version = "0.0.0"
8+
version = "0.1.0"
99
authors = ["RustCrypto Developers"]
1010
license = "Apache-2.0 OR MIT"
1111
homepage = "https://github.com/RustCrypto/utils/tree/master/ctselect"
@@ -21,3 +21,6 @@ cmov = "0.4"
2121

2222
# optional dependencies
2323
subtle = { version = "2", optional = true, default-features = false }
24+
25+
[package.metadata.docs.rs]
26+
all-features = true

ctutils/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Constant-time utility library with selection and equality testing support targeting cryptographic
1010
applications. Supports `const fn` where appropriate. Built on the [`cmov`] crate which provides
11-
architecture-specific predication intrinsics. Heavily inspired by the `subtle` crate.
11+
architecture-specific predication intrinsics. Heavily inspired by the [`subtle`] crate.
1212

1313
## About
1414

@@ -65,3 +65,4 @@ dual licensed as above, without any additional terms or conditions.
6565

6666
[RustCrypto]: https://github.com/RustCrypto
6767
[`cmov`]: https://docs.rs/cmov
68+
[`subtle`]: https://docs.rs/subtle

ctutils/src/choice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign,
1313
pub struct Choice(u8);
1414

1515
impl Choice {
16-
/// The falsy value.
16+
/// Equivalent of [`false`].
1717
pub const FALSE: Self = Self(0);
1818

19-
/// The truthy value.
19+
/// Equivalent of [`true`].
2020
pub const TRUE: Self = Self(1);
2121

2222
/// Create a new [`Choice`] from the given `u8` value, which should be either `0` or `1`.

ctutils/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@
6363
//! *NOTE: for `subtle` users, this is the equivalent of the `ConditionallySelectable` trait*
6464
//!
6565
//! [predication]: https://en.wikipedia.org/wiki/Predication_(computer_architecture)
66+
//!
67+
//! # [`subtle`] interop
68+
//!
69+
//! When the `subtle` feature of this crate is enabled, bidirectional [`From`] impls are available
70+
//! for the following types:
71+
//!
72+
//! - [`Choice`] <=> [`subtle::Choice`]
73+
//! - [`CtOption`] <=> [`subtle::CtOption`]
74+
//!
75+
//! This makes it possible to use `ctutils` in a codebase where other dependencies are using
76+
//! `subtle`.
6677
6778
mod choice;
6879
mod ct_option;

ctutils/src/traits/ct_gt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::Choice;
22
use core::cmp;
33

4-
/// Constant time greater than operation.
4+
/// Constant time greater than.
55
pub trait CtGt {
66
/// Compute whether `self > other` in constant time.
77
fn ct_gt(&self, other: &Self) -> Choice;

ctutils/src/traits/ct_lt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::Choice;
22
use core::cmp;
33

4-
/// Constant time less than operation.
4+
/// Constant time less than.
55
pub trait CtLt {
66
/// Compute whether `self < other` in constant time.
77
fn ct_lt(&self, other: &Self) -> Choice;

0 commit comments

Comments
 (0)