#message-authentication #mac #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

#1408 in Cryptography

Download history 4166/week @ 2024-07-20 3311/week @ 2024-07-27 3543/week @ 2024-08-03 7167/week @ 2024-08-10 8592/week @ 2024-08-17 13384/week @ 2024-08-24 6450/week @ 2024-08-31 9979/week @ 2024-09-07 7219/week @ 2024-09-14 8849/week @ 2024-09-21 16630/week @ 2024-09-28 3211/week @ 2024-10-05 13573/week @ 2024-10-12 7739/week @ 2024-10-19 11600/week @ 2024-10-26 1570/week @ 2024-11-02

34,966 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
~99K SLoC