[][src]Struct binary_ff1::BinaryFF1

pub struct BinaryFF1<'a, C: BlockCipher> { /* fields omitted */ }

A struct for performing FF1 encryption in radix 2.

The block cipher must have a 16 byte block size and should be AES-128, AES-192, or AES-256.

Methods

impl<'a, C> BinaryFF1<'a, C> where
    C: BlockCipher<BlockSize = U16>,
    C::ParBlocks: ArrayLength<GenericArray<u8, U16>>, 
[src]

pub fn new(
    cipher: &'a C,
    len: usize,
    tweak: &[u8],
    scratch: &'a mut [u8]
) -> Result<Self, Error>
[src]

Creates an BinaryFF1 instance for a given block cipher, input length, and tweak. The scratch buffer must be at least len + 1 bytes.

Errors

Returns Error::ScratchTooSmall if the scratch buffer is too small.

Examples

let mut scratch = vec![0; 128];

assert!(BinaryFF1::new(&cipher, 126, &tweak, &mut scratch).is_ok());
assert!(BinaryFF1::new(&cipher, 127, &tweak, &mut scratch).is_ok());

// Scratch buffer must be at least len + 1 bytes
assert_eq!(
    BinaryFF1::new(&cipher, 128, &tweak, &mut scratch).err(),
    Some(Error::ScratchTooSmall)
);

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

Encrypts the given plaintext.

Errors

Returns Error::InvalidInputLength if the length of x is not the same as the input length defined in this BinaryFF1 structure.

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

Decrypts the given ciphertext.

Errors

Returns Error::InvalidInputLength if the length of x is not the same as the input length defined in this BinaryFF1 structure.

Auto Trait Implementations

impl<'a, C> Send for BinaryFF1<'a, C> where
    C: Sync,
    <C as BlockCipher>::BlockSize: ArrayLength<u8>, 

impl<'a, C> Sync for BinaryFF1<'a, C> where
    C: Sync,
    <C as BlockCipher>::BlockSize: ArrayLength<u8>, 

impl<'a, C> Unpin for BinaryFF1<'a, C> where
    <<C as BlockCipher>::BlockSize as ArrayLength<u8>>::ArrayType: Unpin

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> Same<T> for T

type Output = T

Should always be Self

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.