Skip to main content

Crate lioness_rs

Crate lioness_rs 

Source
Expand description

Generic implementations of the BEAR, LION, and LIONESS large-block ciphers of Anderson & Biham, each built from a stream cipher S and a hash H:

  • Bear — keyed hash twice, stream once (3 rounds); requires H: Mac+KeyInit.
  • Lion — stream twice, unkeyed hash once (3 rounds); requires H: Digest.
  • Lioness — stream twice and keyed hash twice (4 rounds); requires H: Mac+KeyInit.

All three are #![no_std] and allocation-free.

§Example

use blake3::Hasher as Blake3;
use chacha20::ChaCha20;
use lioness_rs::{Array, KeyInit, Lioness};

// ChaCha20 (32-byte key) + BLAKE3 (32-byte key & output).
// The full key is k1 || k2 || k3 || k4 = 2 * (32 + 32) = 128 bytes.
type Cipher = Lioness<ChaCha20, Blake3>;
let key = Array::from([0u8; 128]);
let cipher = Cipher::new(&key);

// A block must be strictly longer than the hash output (here, > 32 bytes).
let mut block = [69u8; 96];
cipher.encrypt_block(&mut block).unwrap();
assert_ne!(block, [69u8; 96]);

cipher.decrypt_block(&mut block).unwrap();
assert_eq!(block, [69u8; 96]);

Re-exports§

pub use self;
pub use self;

Structs§

Array
Array is a newtype for an inner [T; N] array where N is determined by a generic ArraySize parameter, which is a marker trait for a numeric value determined by ZSTs that impl the typenum::Unsigned trait.
Bear
The BEAR large-block cipher, generic over a stream cipher S and a keyed hash (MAC) H.
InvalidBlockLength
Lion
The LION large-block cipher, generic over a stream cipher S and an unkeyed hash H.
Lioness
The LIONESS large-block cipher, generic over a stream cipher S and a keyed hash (MAC) H.

Traits§

Digest
Convenience wrapper trait covering functionality of cryptographic hash functions with fixed output size.
KeyInit
Types which can be initialized from a key.
KeySizeUser
Types which use key for initialization.
Mac
Convenience wrapper trait covering functionality of Message Authentication algorithms.

Type Aliases§

Key
Key used by KeySizeUser implementors.