diff --git a/Cargo.lock b/Cargo.lock index 8abbe55b..10f2e1c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,7 +78,7 @@ dependencies = [ [[package]] name = "ctutils" -version = "0.0.0" +version = "0.1.0" dependencies = [ "cmov", "subtle", diff --git a/ctutils/CHANGELOG.md b/ctutils/CHANGELOG.md index d6637e04..d457d66c 100644 --- a/ctutils/CHANGELOG.md +++ b/ctutils/CHANGELOG.md @@ -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 diff --git a/ctutils/Cargo.toml b/ctutils/Cargo.toml index 0819767e..a8ad9ef7 100644 --- a/ctutils/Cargo.toml +++ b/ctutils/Cargo.toml @@ -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" @@ -21,3 +21,6 @@ cmov = "0.4" # optional dependencies subtle = { version = "2", optional = true, default-features = false } + +[package.metadata.docs.rs] +all-features = true diff --git a/ctutils/README.md b/ctutils/README.md index 65fe6e73..ef26dac7 100644 --- a/ctutils/README.md +++ b/ctutils/README.md @@ -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 @@ -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 diff --git a/ctutils/src/choice.rs b/ctutils/src/choice.rs index 2954d5ee..98dfac91 100644 --- a/ctutils/src/choice.rs +++ b/ctutils/src/choice.rs @@ -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`. diff --git a/ctutils/src/lib.rs b/ctutils/src/lib.rs index 449f8e13..ad29074b 100644 --- a/ctutils/src/lib.rs +++ b/ctutils/src/lib.rs @@ -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; diff --git a/ctutils/src/traits/ct_gt.rs b/ctutils/src/traits/ct_gt.rs index 2036306f..512fd5b7 100644 --- a/ctutils/src/traits/ct_gt.rs +++ b/ctutils/src/traits/ct_gt.rs @@ -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; diff --git a/ctutils/src/traits/ct_lt.rs b/ctutils/src/traits/ct_lt.rs index db237e34..2fffbebf 100644 --- a/ctutils/src/traits/ct_lt.rs +++ b/ctutils/src/traits/ct_lt.rs @@ -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;