#message-authentication #daa

cbc-mac

Implementation of Cipher Block Chaining Message Authentication Code (CBC-MAC)

11 releases

Uses new Rust 2024

0.2.0 Apr 10, 2026
0.2.0-rc.5 Mar 25, 2026
0.2.0-rc.4 Feb 2, 2026
0.2.0-rc.3 Nov 5, 2025
0.0.0 Jul 22, 2017

#2986 in Cryptography

Download history 1/week @ 2026-01-05 211/week @ 2026-01-12 294/week @ 2026-01-19 373/week @ 2026-01-26 171/week @ 2026-02-02 128/week @ 2026-02-09 182/week @ 2026-02-16 311/week @ 2026-02-23 151/week @ 2026-03-02 92/week @ 2026-03-09 165/week @ 2026-03-16 220/week @ 2026-03-23 69/week @ 2026-03-30 131/week @ 2026-04-06 146/week @ 2026-04-13 106/week @ 2026-04-20

454 downloads per month
Used in icao-9303

MIT/Apache

11KB
172 lines

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.

Dependencies

~1MB
~23K SLoC