#tink #mac

tink-mac

MAC functionality for Rust port of Google's Tink cryptography library

7 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

#1266 in Cryptography

Download history 1089/week @ 2023-08-17 1581/week @ 2023-08-24 779/week @ 2023-08-31 1210/week @ 2023-09-07 1667/week @ 2023-09-14 2184/week @ 2023-09-21 5073/week @ 2023-09-28 6226/week @ 2023-10-05 13403/week @ 2023-10-12 3954/week @ 2023-10-19 12326/week @ 2023-10-26 9527/week @ 2023-11-02 7457/week @ 2023-11-09 12396/week @ 2023-11-16 14907/week @ 2023-11-23 5548/week @ 2023-11-30

42,315 downloads per month
Used in 5 crates (3 directly)

Apache-2.0

290KB
4.5K SLoC

Tink-Rust: Message Authentication Code

Docs MSRV

This crate provides message authentication code (MAC) functionality, as described in the upstream Tink documentation.

Usage

fn main() -> Result<(), Box<dyn Error>> {
    tink_mac::init();
    let kh = tink_core::keyset::Handle::new(&tink_mac::hmac_sha256_tag256_key_template())?;
    let m = tink_mac::new(&kh)?;

    let pt = b"this data needs to be MACed";
    let mac = m.compute_mac(pt)?;
    println!("'{}' => {}", String::from_utf8_lossy(pt), hex::encode(&mac));

    assert!(m.verify_mac(&mac, b"this data needs to be MACed").is_ok());
    println!("MAC verification succeeded.");
    Ok(())
}

License

Apache License, Version 2.0

Disclaimer

This is not an officially supported Google product.

Dependencies

~2.8–5MB
~90K SLoC