#google-tink #mac

tink-mac

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

8 releases

0.3.0 Nov 28, 2024
0.2.5 Mar 14, 2023
0.2.4 Mar 25, 2022
0.2.3 Jan 3, 2022
0.1.0 Jan 21, 2021

#1152 in Cryptography

Download history 12665/week @ 2025-10-06 12086/week @ 2025-10-13 7161/week @ 2025-10-20 14512/week @ 2025-10-27 37551/week @ 2025-11-03 34255/week @ 2025-11-10 48873/week @ 2025-11-17 23962/week @ 2025-11-24 50952/week @ 2025-12-01 34865/week @ 2025-12-08 36461/week @ 2025-12-15 3400/week @ 2025-12-22 2197/week @ 2025-12-29 43383/week @ 2026-01-05 51880/week @ 2026-01-12 34156/week @ 2026-01-19

131,655 downloads per month
Used in 6 crates (3 directly)

Apache-2.0

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

~1.8–3.5MB
~66K SLoC