Trait subtle::ConditionallySelectable [] [src]

pub trait ConditionallySelectable {
    fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self;
}

Select one of two inputs according to a Choice in constant time.

Examples

use subtle::ConditionallySelectable;
use subtle::Choice;
let a: i32 = 5;
let b: i32 = 13;

assert_eq!(i32::conditional_select(&a, &b, Choice::from(0)), a);
assert_eq!(i32::conditional_select(&a, &b, Choice::from(1)), b);

Required Methods

Select a or b according to choice.

Returns

  • a if choice == Choice(0);
  • b if choice == Choice(1).

This function should execute in constant time.

Implementors