cbc-mac

Crates.iocbc-mac
lib.rscbc-mac
version0.2.0-rc.1
created_at2017-07-22 19:27:06.373844+00
updated_at2025-09-03 02:28:20.061063+00
descriptionImplementation of Cipher Block Chaining Message Authentication Code (CBC-MAC)
homepage
repositoryhttps://github.com/RustCrypto/MACs
max_upload_size
id24551
size26,199
MACs (github:rustcrypto:macs)

documentation

https://docs.rs/cbc-mac

README

RustCrypto: CBC-MAC

crate Docs Build Status Apache2/MIT licensed Rust Version Project Chat

Generic implementation of Cipher Block Chaining Message Authentication Code (CBC-MAC).

WARNING! The algorithm has known weaknesses in case of variable-length messages. See the linked Wikipedia article for more information.

Examples

use cbc_mac::{digest::KeyInit, CbcMac, Mac};
use des::Des;
use hex_literal::hex;

// CBC-MAC with the DES block cipher is equivalent to DAA
type Daa = CbcMac<Des>;

// test from FIPS 113
let key = hex!("0123456789ABCDEF");
let mut mac = Daa::new_from_slice(&key).unwrap();
mac.update(b"7654321 Now is the time for ");
let correct = hex!("F1D30F6849312CA4");
mac.verify_slice(&correct).unwrap();

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 238

cargo fmt