diff --git a/.github/workflows/ctutils.yml b/.github/workflows/ctutils.yml index b4304da7..997b3a07 100644 --- a/.github/workflows/ctutils.yml +++ b/.github/workflows/ctutils.yml @@ -33,7 +33,7 @@ jobs: strategy: matrix: rust: - - 1.86.0 # MSRV + - 1.87.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -58,7 +58,7 @@ jobs: strategy: matrix: rust: - - 1.86.0 # MSRV + - 1.87.0 # MSRV - stable steps: - uses: actions/checkout@v7 diff --git a/ctutils/Cargo.toml b/ctutils/Cargo.toml index 514485a1..36b7b8b6 100644 --- a/ctutils/Cargo.toml +++ b/ctutils/Cargo.toml @@ -14,7 +14,7 @@ categories = ["cryptography", "no-std"] keywords = ["constant-time", "crypto", "intrinsics"] readme = "README.md" edition = "2024" -rust-version = "1.86" +rust-version = "1.87" [dependencies] cmov = "0.5.3" diff --git a/ctutils/README.md b/ctutils/README.md index 74cc8d64..e5713d6b 100644 --- a/ctutils/README.md +++ b/ctutils/README.md @@ -79,7 +79,7 @@ dual licensed as above, without any additional terms or conditions. [docs-image]: https://docs.rs/ctutils/badge.svg [docs-link]: https://docs.rs/ctutils/ [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[msrv-image]: https://img.shields.io/badge/rustc-1.86+-blue.svg +[msrv-image]: https://img.shields.io/badge/rustc-1.87+-blue.svg [build-image]: https://github.com/RustCrypto/utils/actions/workflows/ctutils.yml/badge.svg [build-link]: https://github.com/RustCrypto/utils/actions/workflows/ctutils.yml [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg diff --git a/ctutils/src/choice.rs b/ctutils/src/choice.rs index 16a73879..d6a8415b 100644 --- a/ctutils/src/choice.rs +++ b/ctutils/src/choice.rs @@ -108,10 +108,8 @@ impl Choice { /// Returns [`Choice::TRUE`] if `x == y`, and [`Choice::FALSE`] otherwise. #[inline] #[must_use] - #[allow(clippy::cast_sign_loss)] pub const fn from_i64_eq(x: i64, y: i64) -> Self { - // TODO(tarcieri): use `cast_unsigned` when MSRV is 1.87 - Self::from_u64_nz(x as u64 ^ y as u64).not() + Self::from_u64_nz(x.cast_unsigned() ^ y.cast_unsigned()).not() } // u8 @@ -309,10 +307,9 @@ impl Choice { /// and can't use the trait. The former will provide better constant-time assurances. #[inline] #[must_use] - #[allow(clippy::cast_possible_wrap, clippy::cast_sign_loss)] pub const fn select_i64(self, a: i64, b: i64) -> i64 { - // TODO(tarcieri): use `cast_signed` when MSRV is 1.87 - self.select_u64(a as u64, b as u64) as i64 + self.select_u64(a.cast_unsigned(), b.cast_unsigned()) + .cast_signed() } /// `const fn` helper: return `b` if `self` is [`Choice::TRUE`], otherwise return `a`. diff --git a/ctutils/src/traits/ct_gt.rs b/ctutils/src/traits/ct_gt.rs index f220f047..79f7db9d 100644 --- a/ctutils/src/traits/ct_gt.rs +++ b/ctutils/src/traits/ct_gt.rs @@ -55,13 +55,11 @@ impl CtGt for cmp::Ordering { #[inline] #[allow(clippy::arithmetic_side_effects, clippy::cast_sign_loss)] fn ct_gt(&self, other: &Self) -> Choice { - // No impl of `CtGt` for `i8`, so use `u8` - // TODO(tarcieri): use `cast_signed` when MSRV is 1.87 let a = (*self as i8) + 1; let b = (*other as i8) + 1; - // TODO(tarcieri): use `cast_unsigned` when MSRV is 1.87 - (a as u8).ct_gt(&(b as u8)) + // No impl of `CtGt` for `i8`, so use `u8` + a.cast_unsigned().ct_gt(&b.cast_unsigned()) } } diff --git a/ctutils/src/traits/ct_lt.rs b/ctutils/src/traits/ct_lt.rs index 9f6d8afe..11bc4b50 100644 --- a/ctutils/src/traits/ct_lt.rs +++ b/ctutils/src/traits/ct_lt.rs @@ -55,13 +55,11 @@ impl CtLt for cmp::Ordering { #[inline] #[allow(clippy::arithmetic_side_effects, clippy::cast_sign_loss)] fn ct_lt(&self, other: &Self) -> Choice { - // No impl of `CtLt` for `i8`, so use `u8` - // TODO(tarcieri): use `cast_signed` when MSRV is 1.87 let a = (*self as i8) + 1; let b = (*other as i8) + 1; - // TODO(tarcieri): use `cast_unsigned` when MSRV is 1.87 - (a as u8).ct_lt(&(b as u8)) + // No impl of `CtLt` for `i8`, so use `u8` + a.cast_unsigned().ct_lt(&b.cast_unsigned()) } }