Skip to main content

SecureCompare

Trait SecureCompare 

Source
pub trait SecureCompare: Sized {
    // Required methods
    fn secure_eq(&self, other: &Self) -> bool;
    fn secure_cmp(&self, other: &Self) -> Choice;
}
Expand description

Trait for types that can be securely compared

This trait provides constant-time comparison operations to prevent timing attacks.

Required Methods§

Source

fn secure_eq(&self, other: &Self) -> bool

Compare two values in constant time

Source

fn secure_cmp(&self, other: &Self) -> Choice

Compare two values and return a constant-time choice

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SecureCompare for &[u8]

Source§

fn secure_eq(&self, other: &&[u8]) -> bool

Source§

fn secure_cmp(&self, other: &&[u8]) -> Choice

Source§

impl<const N: usize> SecureCompare for [u8; N]

Source§

fn secure_eq(&self, other: &[u8; N]) -> bool

Source§

fn secure_cmp(&self, other: &[u8; N]) -> Choice

Implementors§