trivium
A small Rust implementation of the Trivium stream cipher.
- Exported helper:
trivium::trivium_xor(key, iv, data)keyandivare arbitrary-lengthVec<u8>values; they are truncated/padded to 10 bytes (80 bits)- Key/IV bits are interpreted MSB-first by default when using the helper.
- Public types for advanced use:
trivium::Trivium— construct directly withTrivium::new(...)for custom options.trivium::BitOrderandtrivium::PackOrder— control how bits are read and packed.
Basic example (helper):
let key = vec!;
let iv = vec!;
let data = b"hello".to_vec;
let ct = trivium_xor.unwrap;
let pt = trivium_xor.unwrap;
assert_eq!;
Direct usage example (custom options):
use ;
let key = vec!;
let iv = vec!;
let data = b"hello".to_vec;
// Instantiate with LSB load order and LSB packing for output bytes
let ct = new.xor_bytes;
let pt = new.xor_bytes;
assert_eq!;
Note: The crate also exposes
Trivium,BitOrder, andPackOrderand includes a direct-usage example in the crate documentation (seesrc/lib.rsdoctests).
Migration / Breaking changes
- The
trivium_xorhelper no longer accepts abit_orderparameter. It now defaults to MSB when reading key/IV bits within each byte. - For LSB loading or other custom behavior, construct directly with
Trivium::new(&key, &iv, BitOrder::Lsb, PackOrder::Lsb)and call.xor_bytes(&data). Trivium::newandTrivium::xor_bytesare public, andBitOrder/PackOrderare exported from the crate root.