[][src]Trait subtle::ConditionallySelectable

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

fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self

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.

Loading content...

Implementors

impl ConditionallySelectable for i8[src]

impl ConditionallySelectable for i16[src]

impl ConditionallySelectable for i32[src]

impl ConditionallySelectable for i64[src]

impl ConditionallySelectable for u8[src]

impl ConditionallySelectable for u16[src]

impl ConditionallySelectable for u32[src]

impl ConditionallySelectable for u64[src]

Loading content...