Struct botan::FPE [−][src]
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]
modulus: &MPI,
key: &[u8],
rounds: usize,
compat_mode: bool
) -> Result<FPE>
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,