gimli-crypto
A no_std compatible Rust implementation of the Gimli cryptographic permutation and its applications:
- AEAD (
aead/gimli24v1): Authenticated Encryption with Associated Data - Hash (
hash/gimli24v1): Cryptographic hash function
Based on the Gimli specification by Bernstein et al.
Usage
AEAD Encryption (In-Place)
use ;
let key = ;
let nonce = ; // MUST be unique per encryption!
let mut data = *b"Secret message!!";
let aad = b"public header";
// Encrypt in-place
let tag = encrypt_in_place;
// Decrypt in-place with authentication
decrypt_in_place
.expect;
assert_eq!;
AEAD Encryption (RustCrypto Trait)
use GimliAead;
use ;
use GenericArray;
let key = from;
let cipher = new;
let nonce = from;
let plaintext = *b"Hello, RustCrypto AEAD!";
let aad = b"associated data";
let mut ciphertext = plaintext.clone;
let tag = cipher
.encrypt_in_place_detached
.expect;
cipher
.decrypt_in_place_detached
.expect;
assert_eq!;
Cryptographic Hash
use ;
// One-shot hashing
let digest = hash;
assert_eq!; // 256-bit output
// Incremental hashing
let mut hasher = new;
hasher.update;
hasher.update;
let digest2 = hasher.finalize;
assert_eq!;
Hash (RustCrypto Digest Trait)
use GimliHash;
use Digest;
let mut hasher = new;
hasher.update;
hasher.update;
let result = hasher.finalize;
References
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
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.