()
| 227 | |
| 228 | #[test] |
| 229 | fn token_hash_stable() { |
| 230 | let secret = [0x33u8; 32]; |
| 231 | let expiry = SystemTime::now() |
| 232 | .duration_since(UNIX_EPOCH) |
| 233 | .unwrap() |
| 234 | .as_secs() |
| 235 | + 60; |
| 236 | let hex = issue_token(&secret, 7, expiry).unwrap(); |
| 237 | let h1 = token_hash(&hex).unwrap(); |
| 238 | let h2 = token_hash(&hex).unwrap(); |
| 239 | assert_eq!(h1, h2); |
| 240 | // Hash must differ from token bytes |
| 241 | let _bytes = hex_decode(&hex).unwrap(); |
| 242 | // Just check it's non-zero |
| 243 | assert!(h1.iter().any(|&b| b != 0)); |
| 244 | } |
| 245 | |
| 246 | // Verify constant-time property indirectly: the rejection path for |
| 247 | // InvalidMac must go through `verify_slice`, not a byte-by-byte short- |
nothing calls this directly
no test coverage detected