· 6 years ago · Oct 10, 2019, 04:50 PM
1fn prop_auth_key_sizes(data: Vec<u8>) -> bool {
2 // The length bounds set by auth module
3 if data.len() >= 32 && data.len() <= 64 {
4 let sk = SecretKey::from_slice(data).unwrap();
5 let expected = authenticate(&sk, b"Test").unwrap();
6 assert!(authenticate_verify(&expected, &sk, b"Test").is_ok())
7 // Now the length bounds set by SecretKey newtype
8 } else if data.len() > 0 && data.len() < u32::max_value() {
9 let bougs_tag = Tag::from_slice(&[0u8; 32]).unwrap();
10 // SK is the same throughout all of hiugh-level,
11 let sk = SecretKey::from_slice(data).unwrap();
12 assert!(authenticate(&sk, b"Test").is_err());
13 assert!(authenticate_verify(&bogus_tag, &sk, b"Test").is_err());
14 } else {
15 // In this case even the SecretKey can't be made
16 assert!(SecretKey::from_slice(data).is_err());
17 }
18
19 true
20}
21
22fn main() {
23 println!("Hello, world!");
24}