MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / token_hash_stable

Function token_hash_stable

nodedb-cluster/src/auth/join_token.rs:229–244  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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-

Callers

nothing calls this directly

Calls 5

nowFunction · 0.85
issue_tokenFunction · 0.85
token_hashFunction · 0.85
duration_sinceMethod · 0.80
hex_decodeFunction · 0.70

Tested by

no test coverage detected