2026-05-01 16:08:57 +03:00
|
|
|
use rand_core::{OsRng, RngCore};
|
2026-05-14 11:56:12 +03:00
|
|
|
use lioness_blockcipher::cipher::Aes128CtrStreamCipher;
|
|
|
|
|
use lioness_blockcipher::kdf::DomSepSha256Kdf;
|
|
|
|
|
use lioness_blockcipher::keyed_hash::Sha256PrependKey;
|
2026-05-01 16:08:57 +03:00
|
|
|
use lioness_blockcipher::prelude::*;
|
|
|
|
|
type TestLioness = Lioness::<
|
2026-05-14 11:56:12 +03:00
|
|
|
Aes128CtrStreamCipher,
|
|
|
|
|
Sha256PrependKey,
|
|
|
|
|
DomSepSha256Kdf,
|
2026-05-01 16:08:57 +03:00
|
|
|
>;
|
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(())
|
|
|
|
|
}
|