#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

#1053 in Cryptography

Download history 5883/week @ 2024-03-17 11192/week @ 2024-03-24 11891/week @ 2024-03-31 2633/week @ 2024-04-07 4152/week @ 2024-04-14 4315/week @ 2024-04-21 4825/week @ 2024-04-28 2221/week @ 2024-05-05 5125/week @ 2024-05-12 13471/week @ 2024-05-19 5810/week @ 2024-05-26 4991/week @ 2024-06-02 11281/week @ 2024-06-09 4282/week @ 2024-06-16 6675/week @ 2024-06-23 5514/week @ 2024-06-30

27,842 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
~95K SLoC