Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ctutils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.1.0 (2025-12-19)
- Initial release
5 changes: 4 additions & 1 deletion ctutils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Constant-time utility library with selection and equality testing support target
applications. Supports `const fn` where appropriate. Built on the `cmov` crate which provides
architecture-specific predication intrinsics. Heavily inspired by the `subtle` crate.
"""
version = "0.0.0"
version = "0.1.0"
authors = ["RustCrypto Developers"]
license = "Apache-2.0 OR MIT"
homepage = "https://github.com/RustCrypto/utils/tree/master/ctselect"
Expand All @@ -21,3 +21,6 @@ cmov = "0.4"

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

[package.metadata.docs.rs]
all-features = true
3 changes: 2 additions & 1 deletion ctutils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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

## About

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

[RustCrypto]: https://github.com/RustCrypto
[`cmov`]: https://docs.rs/cmov
[`subtle`]: https://docs.rs/subtle
4 changes: 2 additions & 2 deletions ctutils/src/choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign,
pub struct Choice(u8);

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

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

/// Create a new [`Choice`] from the given `u8` value, which should be either `0` or `1`.
Expand Down
11 changes: 11 additions & 0 deletions ctutils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@
//! *NOTE: for `subtle` users, this is the equivalent of the `ConditionallySelectable` trait*
//!
//! [predication]: https://en.wikipedia.org/wiki/Predication_(computer_architecture)
//!
//! # [`subtle`] interop
//!
//! When the `subtle` feature of this crate is enabled, bidirectional [`From`] impls are available
//! for the following types:
//!
//! - [`Choice`] <=> [`subtle::Choice`]
//! - [`CtOption`] <=> [`subtle::CtOption`]
//!
//! This makes it possible to use `ctutils` in a codebase where other dependencies are using
//! `subtle`.

mod choice;
mod ct_option;
Expand Down
2 changes: 1 addition & 1 deletion ctutils/src/traits/ct_gt.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::Choice;
use core::cmp;

/// Constant time greater than operation.
/// Constant time greater than.
pub trait CtGt {
/// Compute whether `self > other` in constant time.
fn ct_gt(&self, other: &Self) -> Choice;
Expand Down
2 changes: 1 addition & 1 deletion ctutils/src/traits/ct_lt.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::Choice;
use core::cmp;

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