#encryption #aead #tink #deterministic #google #port #upstream #aead-encryption #daead

tink-daead

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

9 releases

0.3.0 Nov 28, 2024
0.2.5 Mar 14, 2023
0.2.4 Mar 25, 2022
0.2.1 Oct 8, 2021
0.1.0 Jan 21, 2021

#2774 in Cryptography

Download history 51/week @ 2025-02-09 173/week @ 2025-02-16 53/week @ 2025-02-23 235/week @ 2025-03-02 53/week @ 2025-03-09 53/week @ 2025-03-16 34/week @ 2025-03-23 49/week @ 2025-03-30 96/week @ 2025-04-06 159/week @ 2025-04-13 74/week @ 2025-04-20 128/week @ 2025-04-27 88/week @ 2025-05-04 179/week @ 2025-05-11 216/week @ 2025-05-18 126/week @ 2025-05-25

643 downloads per month
Used in 3 crates

Apache-2.0

235KB
3.5K 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

~1.8–4MB
~64K SLoC