kingfisher/fuzz/fuzz_targets/fuzz_entropy.rs
2026-03-19 23:52:38 -07:00

11 lines
408 B
Rust

#![no_main]
use libfuzzer_sys::fuzz_target;
use kingfisher_core::calculate_shannon_entropy;
fuzz_target!(|data: &[u8]| {
let entropy = calculate_shannon_entropy(data);
// Invariants that must always hold:
assert!(entropy.is_finite(), "entropy must be finite");
assert!(entropy >= 0.0, "entropy must be non-negative");
assert!(entropy <= 8.0, "entropy must be <= 8.0 for byte data");
});