948f446a13
Every target now checks properties instead of only calling the parser: parse -> encode -> parse stability (RTSP request, ENet, input), caps and TooLarge past them, chunking invariance of the framer, XML vs status parser agreement, seal/open round trips, no forged GCM tags. New targets for the parsers and state machines that had none: server_cert_der, enet_client, media_decrypt, video_depacketizer, audio_depacketizer, fec_reconstruct, pairing_session, rtsp_client (25 targets).
25 lines
930 B
Rust
25 lines
930 B
Rust
//! 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());
|
|
}
|
|
});
|