tink-daead

Crates.iotink-daead
lib.rstink-daead
version0.3.0
sourcesrc
created_at2021-01-21 11:17:47.902378
updated_at2024-11-28 11:36:14.58824
descriptionDeterministic AEAD functionality for Rust port of Google's Tink cryptography library
homepage
repositoryhttps://github.com/project-oak/tink-rust
max_upload_size
id344847
size21,356
(conradgrobler)

documentation

https://docs.rs/tink-daead

README

Tink-Rust: Deterministic Authenticated Encryption with Additional Data

Docs MSRV

This crate provides deterministic authenticated encryption with additional data (DAEAD) functionality, as described in the upstream Tink documentation.

Usage

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(())
}

License

Apache License, Version 2.0

Disclaimer

This is not an officially supported Google product.

Commit count: 765

cargo fmt