#message-authentication #mac #tink

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

#1162 in Cryptography

Download history 10267/week @ 2024-08-20 11460/week @ 2024-08-27 8789/week @ 2024-09-03 8108/week @ 2024-09-10 7826/week @ 2024-09-17 9876/week @ 2024-09-24 14626/week @ 2024-10-01 3096/week @ 2024-10-08 14058/week @ 2024-10-15 8196/week @ 2024-10-22 10791/week @ 2024-10-29 1494/week @ 2024-11-05 31739/week @ 2024-11-12 22751/week @ 2024-11-19 6087/week @ 2024-11-26 22671/week @ 2024-12-03

83,390 downloads per month
Used in 5 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.4–3.5MB
~51K SLoC