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
1.0 KiB
Rust
25 lines
1.0 KiB
Rust
//! Fuzzes stored certificates and identities (`ServerCert::from_der`, `ClientIdentity::from_der`).
|
|
//! Asserts invariants, not only "no panic": accepted DER round-trips; an identity never loads from a cert and key that do not match (first byte splits the input).
|
|
//! How to run: see the comment at the top of `fuzz/Cargo.toml`.
|
|
|
|
#![no_main]
|
|
|
|
use libfuzzer_sys::fuzz_target;
|
|
|
|
use domistream::pairing::{ClientIdentity, ServerCert};
|
|
|
|
fuzz_target!(|data: &[u8]| {
|
|
if let Ok(c) = ServerCert::from_der(data) {
|
|
assert_eq!(c.der(), data);
|
|
assert_eq!(c.matches(data), Ok(true));
|
|
}
|
|
let Some((&split, rest)) = data.split_first() else { return };
|
|
let at = (usize::from(split) * rest.len()) / 255;
|
|
let (cert, key) = rest.split_at(at.min(rest.len()));
|
|
if let Ok(id) = ClientIdentity::from_der(cert, key) {
|
|
assert_eq!(id.cert_der(), cert);
|
|
let sig = id.sign(b"fuzz").expect("a loaded identity signs");
|
|
ServerCert::from_der(cert).expect("its cert loads").verify(b"fuzz", &sig).expect("key matches cert");
|
|
}
|
|
});
|