pub struct BinaryFF1<'a, C: BlockEncrypt> { /* private fields */ }
Expand description
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.
Implementations§
Source§impl<'a, C> BinaryFF1<'a, C>
impl<'a, C> BinaryFF1<'a, C>
Sourcepub fn new(
cipher: &'a C,
len: usize,
tweak: &[u8],
scratch: &'a mut [u8],
) -> Result<Self, Error>
pub fn new( cipher: &'a C, len: usize, tweak: &[u8], scratch: &'a mut [u8], ) -> Result<Self, Error>
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)
);
Auto Trait Implementations§
impl<'a, C> Freeze for BinaryFF1<'a, C>
impl<'a, C> RefUnwindSafe for BinaryFF1<'a, C>where
C: RefUnwindSafe,
<<C as BlockCipher>::BlockSize as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
impl<'a, C> Send for BinaryFF1<'a, C>where
C: Sync,
impl<'a, C> Sync for BinaryFF1<'a, C>where
C: Sync,
impl<'a, C> Unpin for BinaryFF1<'a, C>
impl<'a, C> !UnwindSafe for BinaryFF1<'a, C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more