Update fuzz tests
Several updates to fuzz tests, including http://go/wvgerrit/124043 Add documentation for partners to run fuzzing http://go/wvgerrit/128224 Fix generic verify fuzz script http://go/wvgerrit/120507 Fuzzing: Add fuzzer for reportusage API http://go/wvgerrit/120503 Fuzzing: Add fuzzer for deactivate usageentry API http://go/wvgerrit/120463 Fuzzing: Add logic to exit fuzzer script http://go/wvgerrit/120444 Fuzzing: Add fuzzer for loadusageentry API Bug: 183154879 Bug: 202994773 Bug: 186785830 Test: test only code Change-Id: I877681461824c51bc82f0766a9973378aafadba7
This commit is contained in:
@@ -13,6 +13,16 @@
|
||||
#include "oemcrypto_session_tests_helper.h"
|
||||
|
||||
namespace wvoec {
|
||||
// Forward-declare the libFuzzer's mutator callback. Mark it weak so that
|
||||
// the program links successfully even outside of --config=asan-fuzzer
|
||||
// (apparently the only config in which LLVM uses our custom mutator).
|
||||
extern "C" size_t LLVMFuzzerMutate(uint8_t* Data, size_t Size, size_t MaxSize)
|
||||
__attribute__((weak));
|
||||
|
||||
const size_t KB = 1024;
|
||||
// Maximum signature length. If fuzzed signature length is greater that this,
|
||||
// this value will be used for signature length.
|
||||
const size_t MAX_FUZZ_SIGNATURE_LENGTH = 5 * KB;
|
||||
// Initial setup to create a valid OEMCrypto state such as initializing crypto
|
||||
// firmware/hardware, installing golden key box etc. in order to fuzz
|
||||
// OEMCrypto APIs.
|
||||
@@ -42,12 +52,7 @@ class OEMCryptoLicenseAPIFuzz : public InitializeFuzz {
|
||||
|
||||
Session* session() { return &session_; }
|
||||
|
||||
void LoadLicense() {
|
||||
license_messages_.SignAndVerifyRequest();
|
||||
license_messages_.CreateDefaultResponse();
|
||||
license_messages_.EncryptAndSignResponse();
|
||||
license_messages_.LoadResponse();
|
||||
}
|
||||
void LoadLicense();
|
||||
|
||||
private:
|
||||
Session session_;
|
||||
@@ -64,9 +69,11 @@ class OEMCryptoProvisioningAPIFuzz : public InitializeFuzz {
|
||||
|
||||
~OEMCryptoProvisioningAPIFuzz() { session_.close(); }
|
||||
|
||||
void LoadProvisioning();
|
||||
ProvisioningRoundTrip& provisioning_messages() {
|
||||
return provisioning_messages_;
|
||||
}
|
||||
Session* session() { return &session_; }
|
||||
|
||||
private:
|
||||
Session session_;
|
||||
@@ -85,6 +92,25 @@ class OEMCryptoRenewalAPIFuzz : public OEMCryptoLicenseAPIFuzz {
|
||||
RenewalRoundTrip renewal_messages_;
|
||||
};
|
||||
|
||||
class LicenseWithUsageEntryFuzz : public InitializeFuzz {
|
||||
public:
|
||||
LicenseWithUsageEntryFuzz() : license_messages_(&session_) {
|
||||
license_messages_.set_pst("my_pst");
|
||||
}
|
||||
|
||||
void CreateUsageTableHeader();
|
||||
LicenseRoundTrip& license_messages() { return license_messages_; }
|
||||
const vector<uint8_t>& encrypted_usage_header() {
|
||||
return encrypted_usage_header_;
|
||||
}
|
||||
void LoadLicense();
|
||||
|
||||
private:
|
||||
vector<uint8_t> encrypted_usage_header_;
|
||||
LicenseRoundTrip license_messages_;
|
||||
Session session_;
|
||||
};
|
||||
|
||||
// Convert data to valid enum value.
|
||||
template <typename T>
|
||||
void ConvertDataToValidEnum(T max_enum_value, T* t) {
|
||||
@@ -99,6 +125,10 @@ void RedirectStdoutToFile();
|
||||
|
||||
// Function to split fuzzer input using delimiter "-_^_".
|
||||
std::vector<std::vector<uint8_t>> SplitInput(const uint8_t* data, size_t size);
|
||||
// Check the status and exit fuzzer if arguments do not match. This is usually
|
||||
// called to check status of APIs which are called to setup state for fuzzers.
|
||||
void CheckStatusAndExitFuzzerOnFailure(OEMCryptoResult result,
|
||||
OEMCryptoResult expected_status);
|
||||
} // namespace wvoec
|
||||
|
||||
#endif // OEMCRYPTO_FUZZ_HELPER_H_
|
||||
|
||||
Reference in New Issue
Block a user