#tink #daead

tink-daead

Deterministic AEAD functionality for Rust port of Google's Tink cryptography library

8 releases

0.2.5 Mar 14, 2023
0.2.4 Mar 25, 2022
0.2.3 Jan 3, 2022
0.2.1 Oct 8, 2021
0.1.0 Jan 21, 2021

#1297 in Cryptography

Download history 80/week @ 2024-03-24 32/week @ 2024-03-31 101/week @ 2024-04-07 13/week @ 2024-04-14 38/week @ 2024-04-21 36/week @ 2024-04-28 55/week @ 2024-05-05 102/week @ 2024-05-12 67/week @ 2024-05-19 52/week @ 2024-05-26 25/week @ 2024-06-02 66/week @ 2024-06-09 74/week @ 2024-06-16 50/week @ 2024-06-23 97/week @ 2024-06-30 41/week @ 2024-07-07

262 downloads per month
Used in 2 crates

Apache-2.0

240KB
4K SLoC

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.

Dependencies

~3–5.5MB
~97K SLoC