[][src]Trait subtle::ConstantTimeLess

pub trait ConstantTimeLess: ConstantTimeEq + ConstantTimeGreater {
    pub fn ct_lt(&self, other: &Self) -> Choice { ... }
}

A type which can be compared in some manner and be determined to be less than another of the same type.

Provided methods

pub fn ct_lt(&self, other: &Self) -> Choice[src]

Determine whether self < other.

The bitwise-NOT of the return value of this function should be usable to determine if self >= other.

A default implementation is provided and implemented for the unsigned integer types.

This function should execute in constant time.

Returns

A Choice with a set bit if self < other, and with no set bits otherwise.

Example

use subtle::ConstantTimeLess;

let x: u8 = 13;
let y: u8 = 42;

let x_lt_y = x.ct_lt(&y);

assert_eq!(x_lt_y.unwrap_u8(), 1);

let y_lt_x = y.ct_lt(&x);

assert_eq!(y_lt_x.unwrap_u8(), 0);

let x_lt_x = x.ct_lt(&x);

assert_eq!(x_lt_x.unwrap_u8(), 0);
Loading content...

Implementations on Foreign Types

impl ConstantTimeLess for u8[src]

impl ConstantTimeLess for u16[src]

impl ConstantTimeLess for u32[src]

impl ConstantTimeLess for u64[src]

impl ConstantTimeLess for u128[src]

Loading content...

Implementors

Loading content...