#mac #message-authentication #tink

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

#1131 in Cryptography

Download history 3496/week @ 2024-01-01 3971/week @ 2024-01-08 3470/week @ 2024-01-15 7556/week @ 2024-01-22 4224/week @ 2024-01-29 6057/week @ 2024-02-05 7360/week @ 2024-02-12 1518/week @ 2024-02-19 7497/week @ 2024-02-26 2555/week @ 2024-03-04 7048/week @ 2024-03-11 5885/week @ 2024-03-18 11185/week @ 2024-03-25 11901/week @ 2024-04-01 2629/week @ 2024-04-08 4146/week @ 2024-04-15

29,877 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

~3–5.5MB
~93K SLoC