tink-mac

Crates.iotink-mac
lib.rstink-mac
version0.2.5
sourcesrc
created_at2021-01-21 11:16:44.095968
updated_at2023-03-14 07:50:48.418492
descriptionMAC functionality for Rust port of Google's Tink cryptography library
homepage
repositoryhttps://github.com/project-oak/tink-rust
max_upload_size
id344845
size35,192
(conradgrobler)

documentation

https://docs.rs/tink-mac

README

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.

Commit count: 660

cargo fmt