//! Fuzzes the host certificate PEM (`plaincert`). //! Asserts invariants, not only "no panic": an accepted PEM gives a DER that loads again, equals itself, pins itself, and has a signature. //! How to run: see the comment at the top of `fuzz/Cargo.toml`. #![no_main] use libfuzzer_sys::fuzz_target; use domistream::pairing::ServerCert; use domistream::pairing::identity::{MAX_CERT_DER_BYTES, MAX_CERT_PEM_BYTES}; fuzz_target!(|data: &[u8]| { let r = ServerCert::from_pem(data); if data.len() > MAX_CERT_PEM_BYTES { assert!(matches!(r, Err(domistream::Error::TooLarge { .. }))); } if let Ok(c) = r { assert!(c.der().len() <= MAX_CERT_DER_BYTES); let again = ServerCert::from_der(c.der()).expect("the DER of an accepted PEM loads"); assert_eq!(again, c); assert_eq!(c.matches(c.der()), Ok(true)); assert!(!c.signature().expect("signature").is_empty()); } });