//! Fuzzes pairing answers. //! Asserts invariants, not only "no panic": decoded values are at most half the body (hex), oversize is TooLarge. //! How to run: see the comment at the top of `fuzz/Cargo.toml`. #![no_main] use libfuzzer_sys::fuzz_target; use domistream::pairing::MAX_PAIR_RESPONSE_BYTES; fuzz_target!(|data: &[u8]| { let r = domistream::pairing::parse_pair_response(data); if data.len() > MAX_PAIR_RESPONSE_BYTES { assert!(matches!(r, Err(domistream::Error::TooLarge { .. }))); } if let Ok(p) = r { for v in [&p.plain_cert, &p.challenge_response, &p.pairing_secret].into_iter().flatten() { assert!(v.len() * 2 <= data.len()); } } });