From 7c693fb23c4100ecd975274131e05c704516cff1 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sun, 25 Oct 2026 14:51:23 -0600 Subject: [PATCH] sntrup-kem: replace `subtle` with `ctutils` `subtle` is unmaintained and `ctutils` is the standard library we use for constant time for all of the other KEM implementations in this repo --- Cargo.lock | 2 +- sntrup-kem/Cargo.toml | 2 +- sntrup-kem/src/types.rs | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2859e6..9c7d697 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1341,6 +1341,7 @@ name = "sntrup-kem" version = "0.1.0" dependencies = [ "criterion", + "ctutils", "getrandom", "hex", "hybrid-array", @@ -1352,7 +1353,6 @@ dependencies = [ "serde_json", "serdect", "sha2", - "subtle", "thiserror", "zeroize", ] diff --git a/sntrup-kem/Cargo.toml b/sntrup-kem/Cargo.toml index fa897a1..64aa83e 100644 --- a/sntrup-kem/Cargo.toml +++ b/sntrup-kem/Cargo.toml @@ -27,10 +27,10 @@ serde = ["dep:serdect", "dep:serde"] js = ["getrandom/wasm_js"] [dependencies] +ctutils = "0.4" hex = "0.4" rand = "0.10.0" rand_chacha = "0.10.0" -subtle = "2" getrandom = { version = "0.4", optional = true } hybrid-array = { version = "0.4.14", features = ["extra-sizes"], optional = true } kem = { version = "0.3", optional = true } diff --git a/sntrup-kem/src/types.rs b/sntrup-kem/src/types.rs index 742a4b6..1710500 100644 --- a/sntrup-kem/src/types.rs +++ b/sntrup-kem/src/types.rs @@ -3,7 +3,7 @@ use crate::error::Error; use crate::params::SntrupParams; use core::marker::PhantomData; -use subtle::ConstantTimeEq; +use ctutils::{Choice, CtEq}; use zeroize::Zeroize; /// Streamlined NTRU Prime encapsulation key (public key). @@ -215,11 +215,11 @@ impl PartialEq for Ciphertext

{ impl Eq for Ciphertext

{} // --------------------------------------------------------------------------- -// ConstantTimeEq / PartialEq / Eq (DecapsulationKey) +// CtEq / PartialEq / Eq (DecapsulationKey) // --------------------------------------------------------------------------- -impl ConstantTimeEq for DecapsulationKey

{ - fn ct_eq(&self, other: &Self) -> subtle::Choice { +impl CtEq for DecapsulationKey

{ + fn ct_eq(&self, other: &Self) -> Choice { self.bytes.as_slice().ct_eq(other.bytes.as_slice()) } } @@ -233,11 +233,11 @@ impl PartialEq for DecapsulationKey

{ impl Eq for DecapsulationKey

{} // --------------------------------------------------------------------------- -// ConstantTimeEq / PartialEq / Eq (SharedSecret) +// CtEq / PartialEq / Eq (SharedSecret) // --------------------------------------------------------------------------- -impl ConstantTimeEq for SharedSecret

{ - fn ct_eq(&self, other: &Self) -> subtle::Choice { +impl CtEq for SharedSecret

{ + fn ct_eq(&self, other: &Self) -> Choice { self.bytes.as_slice().ct_eq(other.bytes.as_slice()) } }