#cryptography #tink #mac

tink-mac

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

6 releases

0.2.4 Mar 25, 2022
0.2.3 Jan 3, 2022
0.2.1 Oct 8, 2021
0.2.0 May 24, 2021
0.1.0 Jan 21, 2021

#303 in Cryptography

Download history 470/week @ 2022-06-08 382/week @ 2022-06-15 232/week @ 2022-06-22 266/week @ 2022-06-29 188/week @ 2022-07-06 246/week @ 2022-07-13 235/week @ 2022-07-20 548/week @ 2022-07-27 418/week @ 2022-08-03 241/week @ 2022-08-10 229/week @ 2022-08-17 107/week @ 2022-08-24 179/week @ 2022-08-31 234/week @ 2022-09-07 192/week @ 2022-09-14 166/week @ 2022-09-21

793 downloads per month
Used in 5 crates (3 directly)

Apache-2.0

270KB
4K 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

~4MB
~61K SLoC