extern crate krypton; use krypton::padding::cms::{pad, unpad}; #[test] fn cms_test() { let mut data: Vec = vec![0x41; 8]; pad(&mut data, 16).unwrap(); assert_eq!(data.as_slice(), [ 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08]); pad(&mut data, 16).unwrap(); assert_eq!(data.as_slice(), [ 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10]); unpad(&mut data, 16).unwrap(); assert_eq!(data.as_slice(), [ 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08]); }