Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fuzz: add higher level functional fuzzing #90

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cargo-fuzz = true
ctap-types = { version = "0.2.0", features = ["arbitrary"] }
libfuzzer-sys = "0.4"
trussed-staging = { version = "0.3.0", features = ["chunked", "hkdf", "virt"] }
arbitrary = "1.3"

[dependencies.fido-authenticator]
path = ".."
Expand All @@ -22,6 +23,13 @@ test = false
doc = false
bench = false

[[bin]]
name = "functional"
path = "fuzz_targets/functional.rs"
test = false
doc = false
bench = false

[patch.crates-io]
ctap-types = { git = "https://github.com/trussed-dev/ctap-types.git", rev = "72eb68b61e3f14957c5ab89bd22f776ac860eb62" }
littlefs2 = { git = "https://github.com/trussed-dev/littlefs2.git", rev = "2b45a7559ff44260c6dd693e4cb61f54ae5efc53" }
Expand Down
57 changes: 57 additions & 0 deletions fuzz/fuzz_targets/functional.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#![no_main]

use fido_authenticator::{Authenticator, Config, Conforming};
use trussed_staging::virt;

use ctap_types::{
ctap1::Authenticator as _,
ctap1::{authenticate, register},
ctap2::make_credential,
ctap2::Authenticator as _,
};

use arbitrary::Arbitrary;

use libfuzzer_sys::fuzz_target;

#[derive(Debug, Arbitrary, Eq, PartialEq)]
enum Action<'a> {
MakeCredential {
request: make_credential::Request<'a>,
},
Register {
request: register::Request<'a>,
},
Authenticate {
request: authenticate::Request<'a>,
},
}

fuzz_target!(|actions: Vec<Action<'_>>| {
virt::with_ram_client("fido", |client| {
let mut authenticator = Authenticator::new(
client,
Conforming {},
Config {
max_msg_size: 0,
skip_up_timeout: None,
max_resident_credential_count: Some(20),
large_blobs: None,
nfc_transport: false,
},
);
for action in actions {
match action {
Action::MakeCredential { request: req } => {
authenticator.make_credential(&req).ok();
}
Action::Register { request: req } => {
authenticator.register(&req).ok();
}
Action::Authenticate { request: req } => {
authenticator.authenticate(&req).ok();
}
}
}
});
});
Loading