2026-05-01 16:08:57 +03:00
|
|
|
use rand_core::{OsRng, RngCore};
|
|
|
|
|
use lioness_blockcipher::prelude::*;
|
|
|
|
|
type TestLioness = Lioness::<
|
|
|
|
|
ChaCha20StreamCipher,
|
|
|
|
|
KeyedBlake2b,
|
|
|
|
|
TurboShake128Kdf
|
|
|
|
|
>;
|
2026-04-06 08:01:00 +02:00
|
|
|
|
|
|
|
|
fn main() -> anyhow::Result<()> {
|
2026-05-01 16:08:57 +03:00
|
|
|
let mut key: Key256 = Default::default();
|
|
|
|
|
OsRng.fill_bytes(&mut key);
|
2026-04-06 08:01:00 +02:00
|
|
|
|
2026-05-01 16:08:57 +03:00
|
|
|
let cipher: TestLioness = Lioness::new(&key)?;
|
2026-04-06 08:01:00 +02:00
|
|
|
|
2026-05-01 16:08:57 +03:00
|
|
|
// Blocks must be at >64 bytes long
|
|
|
|
|
let mut block = vec![0x84u8; 65];
|
2026-04-06 08:01:00 +02:00
|
|
|
let original = block.clone();
|
|
|
|
|
|
|
|
|
|
cipher.encrypt_in_place(&mut block)?;
|
|
|
|
|
|
|
|
|
|
cipher.decrypt_in_place(&mut block)?;
|
|
|
|
|
|
|
|
|
|
assert_eq!(block, original);
|
|
|
|
|
println!("success!");
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|