extern crate rust_salsa20; use rust_salsa20::{Salsa20, Key::Key32}; #[test] fn generate_test() { test( 0x00000fff, vec![ 134, 70, 88, 94, 194, 104, 117, 219, 33, 198, 116, 85, 32, 52, 54, 214, 98, 231, 58, 191, 69, 243, 75, 142, 233, 245, 119, 223, 113, 31, 50, 172, 218, 9, 93, 192, 217, 5, 89, 3, 23, 219, 138, 102, 123, 126, 49, 43, 100, 214, 63, 72, 58, 63, 235, 216, 134, 201, 110, 26, 32, 108, 173, 131, 0, 115, 70, 177, 106, 80, 30, 31, 64, 133, 206, 66, 189, 33, 230, 73, 25, 7, 28, 232, 186, 237, 142, 10, 249, 100, 2, 137, 9, 38, 38, 76, 198, 28, 204, 149 ] ); test( 0xabcdffffffff, vec![ 97, 110, 63, 93, 34, 205, 56, 57, 45, 32, 254, 71, 231, 158, 15, 119, 20, 42, 196, 244, 211, 196, 35, 76, 99, 7, 146, 45, 78, 217, 181, 127, 19, 15, 133, 99, 183, 18, 33, 117, 233, 111, 214, 39, 88, 176, 34, 246, 166, 177, 26, 251, 99, 106, 175, 169, 8, 171, 109, 76, 29, 35, 87, 249, 33, 230, 92, 90, 54, 84, 188, 78, 48, 238, 50, 41, 84, 100, 217, 62, 216, 72, 17, 199, 8, 80, 228, 76, 44, 71, 87, 16, 31, 20, 226, 164, 160, 186, 140, 113 ] ); fn test(counter: u64, expected_data: Vec) { let key = Key32([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 ]); let nonce = [1, 2, 3, 4, 5, 6, 7, 8]; let mut salsa = Salsa20::new(key, nonce, 0); let mut buffer = vec![0; 100]; salsa.generate(&mut buffer); salsa.set_counter(counter); salsa.generate(&mut buffer); assert_eq!(buffer, expected_data); } }