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

Signed-off-by: Kamal Tufekcic <kamal@lo.sh>
This commit is contained in:
Kamal Tufekcic 2026-04-02 23:48:10 +03:00
commit 1d99048c95
No known key found for this signature in database
165830 changed files with 79062 additions and 0 deletions

View file

@ -0,0 +1,35 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use soliton::storage::{encrypt_blob, decrypt_blob, StorageKey, StorageKeyRing};
const FUZZ_KEY: [u8; 32] = [0x42; 32];
fuzz_target!(|data: &[u8]| {
if data.is_empty() {
return;
}
// Cap input size to prevent OOM on CI runners — compress_to_vec allocates
// working buffers proportional to input size (~2× for zstd).
if data.len() > 1_048_576 {
return;
}
let key = StorageKey::new(1, FUZZ_KEY).unwrap();
let compress = data[0] & 0x01 != 0;
let plaintext = &data[1..];
// encrypt_blob must never panic regardless of plaintext size, content, or
// compress flag. Exercises: capacity calculation, optional ruzstd compression,
// nonce generation, AAD construction, XChaCha20-Poly1305 encryption.
let blob = match encrypt_blob(&key, plaintext, "fuzz-channel", "fuzz-segment", compress) {
Ok(b) => b,
Err(_) => return,
};
// Roundtrip verification: decrypt must recover the original plaintext.
// Catches malformed blob layout, wrong AAD, header byte errors, and
// compression flag mismatches that a crash-only target would miss.
let keyring = StorageKeyRing::new(StorageKey::new(1, FUZZ_KEY).unwrap()).unwrap();
let recovered = decrypt_blob(&keyring, &blob, "fuzz-channel", "fuzz-segment")
.expect("decrypt_blob failed on freshly encrypted blob");
assert_eq!(&*recovered, plaintext, "roundtrip mismatch");
});