pub struct FF1 { /* private fields */ }Expand description
An FF1 cipher: a key, a radix and optional configuration, validated once.
Every input is validated before any computation, with the same rules,
order and messages as the fpr-ff1 Python package; see Error.
An instance holds only its configuration. No cipher context is cached: each call builds its own AES key schedule, so an instance may be shared freely between threads.
Implementations§
Source§impl FF1
impl FF1
Sourcepub fn new(key: &[u8], radix: u32) -> Result<FF1, Error>
pub fn new(key: &[u8], radix: u32) -> Result<FF1, Error>
An FF1 cipher with no alphabet, an empty default tweak and no tweak
bounds. Equivalent to FF1::builder(key, radix).build().
key must be 16, 24 or 32 bytes; radix must satisfy
2 <= radix < 2**16.
Sourcepub fn builder(key: &[u8], radix: u32) -> Builder<'_>
pub fn builder(key: &[u8], radix: u32) -> Builder<'_>
Start configuring an FF1 cipher with an alphabet, a default tweak or tweak-length bounds.
Sourcepub fn encrypt_numerals(
&self,
x: &[u16],
tweak: Option<&[u8]>,
) -> Result<Vec<u16>, Error>
pub fn encrypt_numerals( &self, x: &[u16], tweak: Option<&[u8]>, ) -> Result<Vec<u16>, Error>
Encrypt a numeral sequence (SP 800-38G Algorithm 7). Each numeral must
be less than the radix. tweak of None uses the default tweak.
Sourcepub fn decrypt_numerals(
&self,
x: &[u16],
tweak: Option<&[u8]>,
) -> Result<Vec<u16>, Error>
pub fn decrypt_numerals( &self, x: &[u16], tweak: Option<&[u8]>, ) -> Result<Vec<u16>, Error>
Decrypt a numeral sequence (SP 800-38G Algorithm 8). Each numeral must
be less than the radix. tweak of None uses the default tweak.
Sourcepub fn encrypt(&self, s: &str, tweak: Option<&[u8]>) -> Result<String, Error>
pub fn encrypt(&self, s: &str, tweak: Option<&[u8]>) -> Result<String, Error>
Encrypt a string over the configured alphabet.
Sourcepub fn decrypt(&self, s: &str, tweak: Option<&[u8]>) -> Result<String, Error>
pub fn decrypt(&self, s: &str, tweak: Option<&[u8]>) -> Result<String, Error>
Decrypt a string over the configured alphabet.
Sourcepub fn min_length(&self) -> usize
pub fn min_length(&self) -> usize
The shortest input accepted for this radix: the smallest n with
radix**n >= 1_000_000 (6 for radix 10, 20 for radix 2).
Sourcepub fn max_length(&self) -> u64
pub fn max_length(&self) -> u64
The longest input accepted: 2**32 - 1, since SP 800-38G requires
maxlen < 2**32.