Struct botan::FPE[][src]

pub struct FPE { /* fields omitted */ }

Represents an instance of format preserving encryption

Examples

use std::str::FromStr;
let modulus = botan::MPI::from_str("1000000000").unwrap();
let key = vec![0; 32];
let rounds = 16;
let compat_mode = false;
let fpe = botan::FPE::new_fe1(&modulus, &key, rounds, compat_mode).unwrap();
let input = botan::MPI::from_str("9392024").unwrap();
let tweak = vec![1,2,3,4,5];
let ctext = fpe.encrypt(&input, &tweak).unwrap();
assert!(ctext < modulus);
let ptext = fpe.decrypt(&ctext, &tweak).unwrap();
assert_eq!(ptext, input);

Implementations

impl FPE[src]

pub fn new_fe1(
    modulus: &MPI,
    key: &[u8],
    rounds: usize,
    compat_mode: bool
) -> Result<FPE>
[src]

Create a new FPE instance, FE1 scheme Rounds should be 16 or higher for best security

pub fn encrypt(&self, x: &MPI, tweak: &[u8]) -> Result<MPI>[src]

Encrypt value under the FPE scheme using provided tweak

pub fn decrypt(&self, x: &MPI, tweak: &[u8]) -> Result<MPI>[src]

Decrypt value under the FPE scheme using provided tweak

Trait Implementations

impl Debug for FPE[src]

impl Drop for FPE[src]

Auto Trait Implementations

impl RefUnwindSafe for FPE

impl !Send for FPE

impl !Sync for FPE

impl Unpin for FPE

impl UnwindSafe for FPE

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.