binary_ff1/lib.rs
1//! Optimized Rust implementation of FF1 encryption with radix 2, specified in
2//! [NIST Special Publication 800-38G](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38G.pdf).
3//!
4//! # Example
5//!
6//! ```rust
7//! # use aes::{
8//! # cipher::{generic_array::GenericArray, NewBlockCipher},
9//! # Aes256,
10//! # };
11//! # use binary_ff1::BinaryFF1;
12//! #
13//! const KEY: [u8; 32] = [0; 32];
14//! const LEN: usize = 3;
15//!
16//! let cipher = Aes256::new(GenericArray::from_slice(&KEY));
17//! let mut scratch = [0; LEN + 1];
18//! let mut ff1 = BinaryFF1::new(&cipher, LEN, &[], &mut scratch).unwrap();
19//!
20//! let mut x: [u8; LEN] = [0xAB, 0xCD, 0xEF];
21//! ff1.encrypt(&mut x).unwrap();
22//! assert_eq!(x, [0x75, 0xFB, 0x62]);
23//! ff1.decrypt(&mut x).unwrap();
24//! assert_eq!(x, [0xAB, 0xCD, 0xEF]);
25//! ```
26
27#![cfg_attr(not(test), no_std)]
28#![deny(missing_docs)]
29
30mod error;
31mod ff1;
32mod limb;
33mod prf;
34
35pub use crate::{error::Error, ff1::BinaryFF1};
36
37use crate::{limb::Limbs, prf::Prf};