initial commit
Some checks failed
CI / lint (push) Successful in 1m37s
CI / test-python (push) Successful in 1m49s
CI / test-zig (push) Successful in 1m39s
CI / test-wasm (push) Successful in 1m54s
CI / test (push) Successful in 14m44s
CI / miri (push) Successful in 14m18s
CI / build (push) Successful in 1m9s
CI / fuzz-regression (push) Successful in 9m9s
CI / publish (push) Failing after 1m10s
CI / publish-python (push) Failing after 1m46s
CI / publish-wasm (push) Has been cancelled
Some checks failed
CI / lint (push) Successful in 1m37s
CI / test-python (push) Successful in 1m49s
CI / test-zig (push) Successful in 1m39s
CI / test-wasm (push) Successful in 1m54s
CI / test (push) Successful in 14m44s
CI / miri (push) Successful in 14m18s
CI / build (push) Successful in 1m9s
CI / fuzz-regression (push) Successful in 9m9s
CI / publish (push) Failing after 1m10s
CI / publish-python (push) Failing after 1m46s
CI / publish-wasm (push) Has been cancelled
Signed-off-by: Kamal Tufekcic <kamal@lo.sh>
This commit is contained in:
commit
1d99048c95
165830 changed files with 79062 additions and 0 deletions
37
soliton/fuzz/fuzz_targets/fuzz_xwing_roundtrip.rs
Normal file
37
soliton/fuzz/fuzz_targets/fuzz_xwing_roundtrip.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#![no_main]
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
use soliton::primitives::xwing;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
// Fixed keypair for ciphertext mutation testing — keygen is expensive.
|
||||
static KP: LazyLock<(xwing::PublicKey, xwing::SecretKey)> =
|
||||
LazyLock::new(|| xwing::keygen().unwrap());
|
||||
|
||||
const CT_SIZE: usize = 1120;
|
||||
|
||||
// Two modes selected by data[0] & 0x01:
|
||||
// 0 (even) — encapsulate + decapsulate roundtrip: proves freshly produced
|
||||
// ciphertexts always decapsulate without error.
|
||||
// 1 (odd) — fuzz ciphertext bytes: decapsulate must never panic on any ct.
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
if data.is_empty() {
|
||||
return;
|
||||
}
|
||||
if data[0] & 0x01 != 0 {
|
||||
// Mode A: arbitrary ciphertext → decapsulate must not panic.
|
||||
if data.len() < 1 + CT_SIZE {
|
||||
return;
|
||||
}
|
||||
let Ok(ct) = xwing::Ciphertext::from_bytes(data[1..1 + CT_SIZE].to_vec()) else { return; };
|
||||
let _ = xwing::decapsulate(&KP.1, &ct);
|
||||
} else {
|
||||
// Mode B: encapsulate → decapsulate → must succeed.
|
||||
// Exercises the full KEM path with freshly-generated randomness.
|
||||
let Ok((ct, _ss)) = xwing::encapsulate(&KP.0) else {
|
||||
panic!("encapsulate failed on a valid public key");
|
||||
};
|
||||
if xwing::decapsulate(&KP.1, &ct).is_err() {
|
||||
panic!("decapsulate failed on a ciphertext produced by encapsulate");
|
||||
}
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue