#cryptography #tink #daead

tink-daead

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

7 releases

0.2.4 Mar 25, 2022
0.2.3 Jan 3, 2022
0.2.1 Oct 8, 2021
0.2.0 May 24, 2021
0.1.0 Jan 21, 2021

#388 in Cryptography

Download history 505/week @ 2022-06-12 286/week @ 2022-06-19 238/week @ 2022-06-26 267/week @ 2022-07-03 159/week @ 2022-07-10 313/week @ 2022-07-17 192/week @ 2022-07-24 393/week @ 2022-07-31 177/week @ 2022-08-07 259/week @ 2022-08-14 137/week @ 2022-08-21 110/week @ 2022-08-28 124/week @ 2022-09-04 195/week @ 2022-09-11 182/week @ 2022-09-18 414/week @ 2022-09-25

918 downloads per month
Used in 2 crates

Apache-2.0

215KB
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

~4.5MB
~64K SLoC