Grain-128AEADv2
Efficient pure Rust implementation of Grain-128AEADv2.
Please see installation details and doc on crates.io.
Pure Rust implementation of Grain-128AEADv2, a lightweight stream cipher.
Security Notes
[!CAUTION] No security audits of this crate have ever been performed. USE AT YOUR OWN RISK!
Minimum Supported Rust Version
This crate requires Rust 1.85 at a minimum.
Quickstart
With randomly sampled keys and nonces (requires getrandom feature):
use ;
let key = generate_key.expect;
let cipher = new;
// A nonce must be USED ONLY ONCE !
let nonce = generate_nonce.expect;
let = cipher.encrypt_aead;
let plaintext = cipher.decrypt_aead.expect;
assert_eq!;
In-place encryption (requires alloc feature) :
use ;
let key = generate_key.expect;
let cipher = new;
// A nonce must be USED ONLY ONCE !
let nonce = generate_nonce.expect;
// Take care : 8 bytes overhead to store the tag
let mut buffer: = vec!;
buffer.extend_from_slice;
// Perform in place encryption inside 'buffer'
cipher.encrypt_in_place.expect;
// Perform in place decryption
cipher.decrypt_in_place.expect;
assert_eq!;
License
Licensed under either of:
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.