subtle
subtle copied to clipboard
Pure-Rust traits and utilities for constant-time cryptographic implementations.
For now, the library only supports constant-time equality comparison. Could it be extended to support constant-time ordering comparisons (https://doc.rust-lang.org/std/cmp/trait.Ord.html)? In particular for slices of the same length (using lexicographical comparison)....
Add constant time warning to `unwrap_or_else` doc comment so that the user knows that the closure will not be lazy evaluated.
This PR implements `ConstantTimeEq` for `str`.
Attributes that are in function prototypes are ignored and emit a compiler warning. This pull request should not have any effect except removing the compiler warnings: ``` warning: `#[inline]` is...
The analyzer warns about `#[inline]` on function prototypes. While it seems useful to keep the attribute around as a helpful reminder in relevant traits, this PR silences the warnings.
The current implementation of `ConstantTimeEquality` for arrays and slices will short-circuit if the lengths are different. This PR does a constant-time length check before the componentwise check, and then uses...
`ConstantTimeSelect` is intended as a replacement to `ConditionallySelectable`, which is preserved but deprecated. It replaces the previous `Copy` bound with a bound on a new `ConstantTimeClone` marker trait, which allows...
It seems like `usize` and `isize` could reasonably be allowed to implement `ConstantTime{Greater,Less}` via the macros that are already used for other integer types. I assumed it was an oversight...
This generalizes the implementation of `ConstantTimeEq` for `[T]` to also support `ConstantTimeGreater` and `ConstantTimeLess`. I haven't touched the implementation of `ConstantTimeEq for [T]` as the standalone implementation is more efficient...
The foundation of `ConditionallySelectable` is bitwise masking of values + XOR, using the input `Choice` to generate a conditional mask, such that the mask erases one of the two values...