Source release 17.1.0
This commit is contained in:
62
oemcrypto/test/fuzz_tests/oemcrypto_opk_dispatcher_fuzz.cc
Normal file
62
oemcrypto/test/fuzz_tests/oemcrypto_opk_dispatcher_fuzz.cc
Normal file
@@ -0,0 +1,62 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "opk_dispatcher.h"
|
||||
#include "opk_init.h"
|
||||
#include "tos_transport_interface.h"
|
||||
|
||||
namespace wvoec {
|
||||
|
||||
void OpenOEMCryptoTASession() {
|
||||
ODK_Message request;
|
||||
ODK_Message response;
|
||||
uint8_t response_buffer[0x1000];
|
||||
uint8_t request_body[] = {
|
||||
0x06, // TAG_UINT32
|
||||
0x09, 0x00, 0x00, 0x00, // API value (0x09)
|
||||
0x01, // TAG_BOOL
|
||||
0x00, // value (false)
|
||||
0x0a // TAG_EOM
|
||||
};
|
||||
request = ODK_Message_Create(request_body, sizeof(request_body));
|
||||
OPK_DispatchMessage(&request, &response);
|
||||
}
|
||||
|
||||
void InitializeOEMCryptoTA() {
|
||||
ODK_Message init_request;
|
||||
ODK_Message init_response;
|
||||
uint8_t response_buffer[0x1000];
|
||||
uint8_t init_request_body[] = {
|
||||
0x06, // TAG_UINT32
|
||||
0x01, 0x00, 0x00, 0x00, // API value(0x01)
|
||||
0x0a // TAG_EOM
|
||||
};
|
||||
|
||||
init_request =
|
||||
ODK_Message_Create(init_request_body, sizeof(init_request_body));
|
||||
OPK_DispatchMessage(&init_request, &init_response);
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
|
||||
OPK_Initialize();
|
||||
InitializeOEMCryptoTA();
|
||||
OpenOEMCryptoTASession();
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
ODK_Message request;
|
||||
ODK_Message response;
|
||||
unsigned char response_buffer[0x1000];
|
||||
|
||||
uint8_t* input = new uint8_t[size];
|
||||
memcpy(input, data, size);
|
||||
|
||||
request = ODK_Message_Create(input, size);
|
||||
OPK_DispatchMessage(&request, &response);
|
||||
|
||||
delete[] input;
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace wvoec
|
||||
Reference in New Issue
Block a user