mirror of
https://github.com/rosenpass/rosenpass.git
synced 2026-02-27 22:13:12 -08:00
These targets can be used with rust nightly and cargo-fuzz to fuzz several bits of Rosenpass's API. Fuzzing is an automated way of exploring code paths that may not be hit in unit tests or normal operation. For example the `handle_msg` target exposed the DoS condition fixed in 0.2.1. The other targets focus on the FFI with libsodium and liboqs. Co-authored-by: Karolin Varner <karo@cupdev.net>
20 lines
416 B
Rust
20 lines
416 B
Rust
#![no_main]
|
|
extern crate arbitrary;
|
|
extern crate rosenpass;
|
|
|
|
use libfuzzer_sys::fuzz_target;
|
|
|
|
use rosenpass::pqkem::{EphemeralKEM, KEM};
|
|
|
|
#[derive(arbitrary::Arbitrary, Debug)]
|
|
pub struct Input {
|
|
pub pk: [u8; 800],
|
|
}
|
|
|
|
fuzz_target!(|input: Input| {
|
|
let mut ciphertext = [0u8; 768];
|
|
let mut shared_secret = [0u8; 32];
|
|
|
|
EphemeralKEM::encaps(&mut shared_secret, &mut ciphertext, &input.pk).unwrap();
|
|
});
|