#block-cipher #message-authentication #daa #generic

cbc-mac

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

6 releases

Uses new Rust 2024

0.2.0-rc.0 May 30, 2025
0.2.0-pre.2 Aug 14, 2024
0.2.0-pre.1 Jul 27, 2024
0.1.1 Feb 17, 2022
0.0.0 Jul 22, 2017

#2977 in Cryptography

Download history 49/week @ 2025-03-21 28/week @ 2025-03-28 28/week @ 2025-04-04 20/week @ 2025-04-11 13/week @ 2025-04-18 2/week @ 2025-04-25 17/week @ 2025-05-02 64/week @ 2025-05-09 62/week @ 2025-05-16 70/week @ 2025-05-23 172/week @ 2025-05-30 33/week @ 2025-06-06 13/week @ 2025-06-13 30/week @ 2025-06-20 49/week @ 2025-06-27 95/week @ 2025-07-04

199 downloads per month
Used in icao-9303

MIT/Apache

10KB
169 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

~785KB
~20K SLoC