Expand description
§RustCrypto: Retail MAC
Pure Rust implementation of the Retail Message Authentication Code, also known as ISO/IEC 9797-1 MAC algorithm 3.
WARNING! The algorithm has known weaknesses in case of variable-length messages. See the Wikipedia article for CBC-MAC for more information.
§Examples
use retail_mac::{digest::KeyInit, RetailMac, Mac};
use des::Des;
use hex_literal::hex;
type RetailMacDes = RetailMac<Des>;
// test from ISO/IEC 9797-1:2011 section B.4
// K and K' are concatenated:
let key = hex!("0123456789ABCDEFFEDCBA9876543210");
let mut mac = RetailMacDes::new_from_slice(&key).unwrap();
mac.update(b"Now is the time for all ");
let correct = hex!("A1C72E74EA3FA9B6");
mac.verify_slice(&correct).unwrap();
let mut mac2 = RetailMacDes::new_from_slice(&key).unwrap();
mac2.update(b"Now is the time for it");
let correct2 = hex!("2E2B1428CC78254F");
mac2.verify_slice(&correct2).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.
Re-exports§
pub use digest;
Modules§
- block_
api - Block-level implementation.
Structs§
- Retail
Mac - Generic Retail MAC instance.
Traits§
- KeyInit
- Types which can be initialized from a key.
- Mac
- Convenience wrapper trait covering functionality of Message Authentication algorithms.
Type Aliases§
- Key
- Key used by
KeySizeUserimplementors.