Skip to content

Commit

Permalink
Merge pull request #31 from cppalliance/more_fuzz
Browse files Browse the repository at this point in the history
Fuzz the hasher object to include the invalid state
  • Loading branch information
mborland authored Oct 21, 2024
2 parents f71fdee + e7e4679 commit 67a0f25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fuzzing/fuzz_md5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size
std::span data_span {c_data, size};
boost::crypt::md5(data_span);
#endif

// Fuzz the hasher object
boost::crypt::md5_hasher hasher;
hasher.process_bytes(data, size);
hasher.process_bytes(data, size);
hasher.process_bytes(data, size);
hasher.get_digest();
hasher.process_bytes(data, size); // State is invalid but should not crash
}
catch(...)
{
Expand Down
8 changes: 8 additions & 0 deletions fuzzing/fuzz_sha1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size
std::span data_span {c_data, size};
boost::crypt::sha1(data_span);
#endif

// Fuzz the hasher object
boost::crypt::sha1_hasher hasher;
hasher.process_bytes(data, size);
hasher.process_bytes(data, size);
hasher.process_bytes(data, size);
hasher.get_digest();
hasher.process_bytes(data, size); // State is invalid but should not crash
}
catch(...)
{
Expand Down

0 comments on commit 67a0f25

Please sign in to comment.