#![cfg_attr(not(feature = "std"), no_std)]
#![warn(unsafe_op_in_unsafe_fn)]
#![warn(clippy::undocumented_unsafe_blocks)]
#[doc(hidden)]
pub mod classic;
#[doc(hidden)]
pub mod generic;
#[cfg(all(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "sse2",
not(miri)
))]
mod sse2;
#[cfg(all(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "sse2",
not(miri)
))]
use sse2 as simd;
#[cfg(all(target_arch = "aarch64", target_feature = "neon", not(miri)))]
mod neon;
#[cfg(all(target_arch = "aarch64", target_feature = "neon", not(miri)))]
use neon as simd;
#[cfg(not(any(
all(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "sse2",
not(miri)
),
all(target_arch = "aarch64", target_feature = "neon", not(miri))
)))]
use generic as simd;
#[cfg(all(target_arch = "aarch64", not(miri)))]
mod dit;
#[cfg(all(target_arch = "aarch64", not(miri)))]
use dit::with_dit;
#[cfg(any(not(target_arch = "aarch64"), miri))]
#[inline(always)]
pub(crate) fn with_dit<T, F>(f: F) -> T
where
F: FnOnce() -> T,
{
f()
}
#[must_use]
pub fn constant_time_eq(a: &[u8], b: &[u8]) -> bool {
simd::constant_time_eq(a, b)
}
#[must_use]
pub fn constant_time_eq_n<const N: usize>(a: &[u8; N], b: &[u8; N]) -> bool {
simd::constant_time_eq_n(a, b)
}
#[inline]
#[must_use]
pub fn constant_time_eq_16(a: &[u8; 16], b: &[u8; 16]) -> bool {
constant_time_eq_n(a, b)
}
#[inline]
#[must_use]
pub fn constant_time_eq_32(a: &[u8; 32], b: &[u8; 32]) -> bool {
constant_time_eq_n(a, b)
}
#[inline]
#[must_use]
pub fn constant_time_eq_64(a: &[u8; 64], b: &[u8; 64]) -> bool {
constant_time_eq_n(a, b)
}