-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2024 Matt Borland | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
|
||
#include <boost/crypt2/hash/sha3_224.hpp> | ||
#include <iostream> | ||
#include <exception> | ||
#include <string> | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) | ||
{ | ||
try | ||
{ | ||
auto c_data = reinterpret_cast<const char*>(data); | ||
std::string c_data_str {c_data, size}; // Guarantee null termination since we can't pass the size argument | ||
|
||
boost::crypt::sha3_224(c_data_str); | ||
|
||
std::string_view view {c_data_str}; | ||
boost::crypt::sha3_224(view); | ||
|
||
std::span data_span {c_data, size}; | ||
boost::crypt::sha3_224(data_span); | ||
|
||
// Fuzz the hasher object | ||
boost::crypt::sha3_224_hasher hasher; | ||
hasher.process_bytes(data_span); | ||
hasher.process_bytes(data_span); | ||
hasher.process_bytes(data_span); | ||
hasher.finalize(); | ||
[[maybe_unused]] const auto res = hasher.get_digest(); | ||
hasher.process_bytes(data_span); // State is invalid but should not crash | ||
} | ||
catch(...) | ||
{ | ||
std::cerr << "Error with: " << data << std::endl; | ||
std::terminate(); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2024 Matt Borland | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
|
||
#include <boost/crypt2/hash/sha3_256.hpp> | ||
#include <iostream> | ||
#include <exception> | ||
#include <string> | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) | ||
{ | ||
try | ||
{ | ||
auto c_data = reinterpret_cast<const char*>(data); | ||
std::string c_data_str {c_data, size}; // Guarantee null termination since we can't pass the size argument | ||
|
||
boost::crypt::sha3_256(c_data_str); | ||
|
||
std::string_view view {c_data_str}; | ||
boost::crypt::sha3_256(view); | ||
|
||
std::span data_span {c_data, size}; | ||
boost::crypt::sha3_256(data_span); | ||
|
||
// Fuzz the hasher object | ||
boost::crypt::sha3_256_hasher hasher; | ||
hasher.process_bytes(data_span); | ||
hasher.process_bytes(data_span); | ||
hasher.process_bytes(data_span); | ||
hasher.finalize(); | ||
[[maybe_unused]] const auto res = hasher.get_digest(); | ||
hasher.process_bytes(data_span); // State is invalid but should not crash | ||
} | ||
catch(...) | ||
{ | ||
std::cerr << "Error with: " << data << std::endl; | ||
std::terminate(); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2024 Matt Borland | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
|
||
#include <boost/crypt2/hash/sha3_384.hpp> | ||
#include <iostream> | ||
#include <exception> | ||
#include <string> | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) | ||
{ | ||
try | ||
{ | ||
auto c_data = reinterpret_cast<const char*>(data); | ||
std::string c_data_str {c_data, size}; // Guarantee null termination since we can't pass the size argument | ||
|
||
boost::crypt::sha3_384(c_data_str); | ||
|
||
std::string_view view {c_data_str}; | ||
boost::crypt::sha3_384(view); | ||
|
||
std::span data_span {c_data, size}; | ||
boost::crypt::sha3_384(data_span); | ||
|
||
// Fuzz the hasher object | ||
boost::crypt::sha3_384_hasher hasher; | ||
hasher.process_bytes(data_span); | ||
hasher.process_bytes(data_span); | ||
hasher.process_bytes(data_span); | ||
hasher.finalize(); | ||
[[maybe_unused]] const auto res = hasher.get_digest(); | ||
hasher.process_bytes(data_span); // State is invalid but should not crash | ||
} | ||
catch(...) | ||
{ | ||
std::cerr << "Error with: " << data << std::endl; | ||
std::terminate(); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2024 Matt Borland | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
|
||
#include <boost/crypt2/hash/shake128.hpp> | ||
#include <iostream> | ||
#include <exception> | ||
#include <string> | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) | ||
{ | ||
try | ||
{ | ||
auto c_data = reinterpret_cast<const char*>(data); | ||
std::string c_data_str {c_data, size}; // Guarantee null termination since we can't pass the size argument | ||
|
||
boost::crypt::shake128(c_data_str); | ||
|
||
std::string_view view {c_data_str}; | ||
boost::crypt::shake128(view); | ||
|
||
std::span data_span {c_data, size}; | ||
boost::crypt::shake128(data_span); | ||
|
||
// Fuzz the hasher object | ||
boost::crypt::shake128_hasher hasher; | ||
hasher.process_bytes(data_span); | ||
hasher.process_bytes(data_span); | ||
hasher.process_bytes(data_span); | ||
hasher.finalize(); | ||
[[maybe_unused]] const auto res = hasher.get_digest(); | ||
hasher.process_bytes(data_span); // State is invalid but should not crash | ||
} | ||
catch(...) | ||
{ | ||
std::cerr << "Error with: " << data << std::endl; | ||
std::terminate(); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2024 Matt Borland | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
|
||
#include <boost/crypt2/hash/shake256.hpp> | ||
#include <iostream> | ||
#include <exception> | ||
#include <string> | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) | ||
{ | ||
try | ||
{ | ||
auto c_data = reinterpret_cast<const char*>(data); | ||
std::string c_data_str {c_data, size}; // Guarantee null termination since we can't pass the size argument | ||
|
||
boost::crypt::shake256(c_data_str); | ||
|
||
std::string_view view {c_data_str}; | ||
boost::crypt::shake256(view); | ||
|
||
std::span data_span {c_data, size}; | ||
boost::crypt::shake256(data_span); | ||
|
||
// Fuzz the hasher object | ||
boost::crypt::shake256_hasher hasher; | ||
hasher.process_bytes(data_span); | ||
hasher.process_bytes(data_span); | ||
hasher.process_bytes(data_span); | ||
hasher.finalize(); | ||
[[maybe_unused]] const auto res = hasher.get_digest(); | ||
hasher.process_bytes(data_span); // State is invalid but should not crash | ||
} | ||
catch(...) | ||
{ | ||
std::cerr << "Error with: " << data << std::endl; | ||
std::terminate(); | ||
} | ||
|
||
return 0; | ||
} |