Crates.io | tink-daead |
lib.rs | tink-daead |
version | 0.3.0 |
source | src |
created_at | 2021-01-21 11:17:47.902378 |
updated_at | 2024-11-28 11:36:14.58824 |
description | Deterministic AEAD functionality for Rust port of Google's Tink cryptography library |
homepage | |
repository | https://github.com/project-oak/tink-rust |
max_upload_size | |
id | 344847 |
size | 21,356 |
This crate provides deterministic authenticated encryption with additional data (DAEAD) functionality, as described in the upstream Tink documentation.
fn main() -> Result<(), Box<dyn Error>> {
tink_daead::init();
let kh = tink_core::keyset::Handle::new(&tink_daead::aes_siv_key_template())?;
let d = tink_daead::new(&kh)?;
let pt = b"this data needs to be encrypted";
let ad = b"additional data";
let ct1 = d.encrypt_deterministically(pt, ad)?;
println!("'{}' => {}", String::from_utf8_lossy(pt), hex::encode(&ct1));
let ct2 = d.encrypt_deterministically(pt, ad)?;
assert_eq!(ct1, ct2, "cipher texts are not equal");
println!("Cipher texts are equal.");
let pt2 = d.decrypt_deterministically(&ct1, ad)?;
assert_eq!(&pt[..], pt2);
Ok(())
}
This is not an officially supported Google product.