| Crates.io | trivium |
| lib.rs | trivium |
| version | 0.1.0 |
| created_at | 2026-01-22 15:23:19.841821+00 |
| updated_at | 2026-01-22 15:23:19.841821+00 |
| description | Small Rust implementation of the Trivium stream cipher. |
| homepage | https://github.com/1595901624/trivium-rs |
| repository | https://github.com/1595901624/trivium-rs |
| max_upload_size | |
| id | 2061916 |
| size | 17,360 |
A small Rust implementation of the Trivium stream cipher.
trivium::trivium_xor(key, iv, data)
key and iv are arbitrary-length Vec<u8> values; they are truncated/padded to 10 bytes (80 bits)trivium::Trivium — construct directly with Trivium::new(...) for custom options.trivium::BitOrder and trivium::PackOrder — control how bits are read and packed.Basic example (helper):
let key = vec![0u8; 10];
let iv = vec![0u8; 10];
let data = b"hello".to_vec();
let ct = trivium::trivium_xor(key.clone(), iv.clone(), data.clone()).unwrap();
let pt = trivium::trivium_xor(key, iv, ct).unwrap();
assert_eq!(pt, data);
Direct usage example (custom options):
use trivium::{Trivium, BitOrder, PackOrder};
let key = vec![0u8; 10];
let iv = vec![0u8; 10];
let data = b"hello".to_vec();
// Instantiate with LSB load order and LSB packing for output bytes
let ct = Trivium::new(&key, &iv, BitOrder::Lsb, PackOrder::Lsb).xor_bytes(&data);
let pt = Trivium::new(&key, &iv, BitOrder::Lsb, PackOrder::Lsb).xor_bytes(&ct);
assert_eq!(pt, data);
Note: The crate also exposes
Trivium,BitOrder, andPackOrderand includes a direct-usage example in the crate documentation (seesrc/lib.rsdoctests).
trivium_xor helper no longer accepts a bit_order parameter. It now defaults to MSB when reading key/IV bits within each byte.Trivium::new(&key, &iv, BitOrder::Lsb, PackOrder::Lsb) and call .xor_bytes(&data).Trivium::new and Trivium::xor_bytes are public, and BitOrder/PackOrder are exported from the crate root.