diff --git a/.github/workflows/x509.yml b/.github/workflows/x509.yml index 7a24fbfc4..f818d1a72 100644 --- a/.github/workflows/x509.yml +++ b/.github/workflows/x509.yml @@ -64,3 +64,17 @@ jobs: override: true - uses: RustCrypto/actions/cargo-hack-install@master - run: cargo hack test --feature-powerset + + fuzz: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: RustCrypto/actions/cargo-cache@master + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + - run: cargo install cargo-fuzz + - run: cargo fuzz run certreq -- -max_total_time=30 -seed_inputs="fuzz/inputs/rsa2048-csr.der" + - run: cargo fuzz run certreqinfo -- -max_total_time=30 diff --git a/x509/fuzz/.gitignore b/x509/fuzz/.gitignore new file mode 100644 index 000000000..b9659e613 --- /dev/null +++ b/x509/fuzz/.gitignore @@ -0,0 +1,4 @@ +target +corpus +artifacts +Cargo.lock diff --git a/x509/fuzz/Cargo.toml b/x509/fuzz/Cargo.toml new file mode 100644 index 000000000..2bea670ce --- /dev/null +++ b/x509/fuzz/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "x509-fuzz" +version = "0.0.0" +authors = ["RustCrypto Developers"] +publish = false +edition = "2021" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" +x509 = { path = ".." } + +# Prevents this crate from interfering with the workspace +[workspace] +members = ["."] diff --git a/x509/fuzz/inputs/rsa2048-csr.der b/x509/fuzz/inputs/rsa2048-csr.der new file mode 100644 index 000000000..31c9e225a Binary files /dev/null and b/x509/fuzz/inputs/rsa2048-csr.der differ diff --git a/x509/fuzz/src/bin/certreq.rs b/x509/fuzz/src/bin/certreq.rs new file mode 100644 index 000000000..6551c777a --- /dev/null +++ b/x509/fuzz/src/bin/certreq.rs @@ -0,0 +1,8 @@ +#![no_main] + +use libfuzzer_sys::fuzz_target; +use x509::request::CertReq; + +fuzz_target!(|input: &[u8]| { + let _ = CertReq::try_from(input); +}); diff --git a/x509/fuzz/src/bin/certreqinfo.rs b/x509/fuzz/src/bin/certreqinfo.rs new file mode 100644 index 000000000..4027cbf58 --- /dev/null +++ b/x509/fuzz/src/bin/certreqinfo.rs @@ -0,0 +1,8 @@ +#![no_main] + +use libfuzzer_sys::fuzz_target; +use x509::request::CertReqInfo; + +fuzz_target!(|input: &[u8]| { + let _ = CertReqInfo::try_from(input); +});