Skip to content

Commit 26a45a2

Browse files
committed
fuzz: Add a fuzz target for the HPKE message decoding
1 parent 6034269 commit 26a45a2

6 files changed

Lines changed: 29 additions & 0 deletions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "hpke-initial-message-decoding"
3+
version = "0.1.0"
4+
publish = false
5+
edition = "2021"
6+
7+
[dependencies]
8+
afl = "*"
9+
10+
[dependencies.vodozemac]
11+
path = "../.."
12+
13+
# Prevent this from interfering with workspaces
14+
[workspace]
15+
members = ["."]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "nightly"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use afl::fuzz;
2+
use vodozemac::hpke::InitialMessage;
3+
4+
fn main() {
5+
fuzz!(|data: &[u8]| {
6+
if let Ok(decoded) = InitialMessage::from_bytes(data) {
7+
let encoded = decoded.to_bytes();
8+
let re_decoded = InitialMessage::from_bytes(&encoded).expect("Re-decoding should always succeed");
9+
assert_eq!(decoded, re_decoded);
10+
}
11+
});
12+
}

0 commit comments

Comments
 (0)