@@ -21,3 +21,30 @@ For the demo:
2121``` FuzzedDataProvider fuzz_data(Data, Size); ```
2222``` mocklib_set_data(&fuzz_data); ```
2323- You also need to include the FuzzedDataProvider.h and mocklib.h in the fuzztest
24+ - Now the fuzz test can run
25+ - To create a fuzz test for all the functions fill in the excel sheet testgen_functions.xlsx like this:
26+
27+ | enum crypto_return_status crypto_calculate_hmac(const uint8_t * message, int len, crypto_hmac * hmac) | message: ARG_DATA() | len: ARG_SIZE() | hmac: ARG_STRUCT_PTR(crypto_hmac) | |
28+ | -------------------------------------------------------------------------------------------------------| ----------------------------------------| --------------------| -----------------------------------| ---|
29+ | enum crypto_return_status crypto_set_key(crypto_key key) | key: ARG_STRUCT(crypto_key) | | | |
30+ | enum crypto_return_status crypto_set_nonce(crypto_nonce nonce) | nonce: ARG_STRUCT(crypto_nonce) | | | |
31+ | enum crypto_return_status crypto_verify_hmac(const uint8_t * message, int len, crypto_hmac * hmac) | message: ARG_DATA() | len: ARG_SIZE() | hmac: ARG_STRUCT_PTR(crypto_hmac) | |
32+ | enum crypto_return_status crypto_verify_key(crypto_key key) | key: ARG_STRUCT(crypto_key) | | | |
33+ | enum crypto_return_status crypto_verify_nonce(crypto_nonce * nonce) | nonce: ARG_STRUCT_PTR(crypto_nonce) | | | |
34+ | uint8_t * generate_random_bytes(uint8_t * buffer, uint8_t length) | buffer: ARG_DATA() | length: ARG_SIZE() | | |
35+ | enum GPS_return_status get_current_position(GPS_position * position) | position: ARG_STRUCT_PTR(GPS_position) | | | |
36+ | void key_management_create_key(uint8_t * key, uint8_t length) | key: ARG_DATA() | length: ARG_SIZE() | | |
37+ | void key_management_create_nonce(uint8_t * nonce, uint8_t length) | nonce: ARG_DATA() | length: ARG_SIZE() | | |
38+ | enum GPS_return_status set_destination_postition(GPS_position position) | position: ARG_STRUCT(GPS_position) | | | |
39+ | enum crypto_state crypto_get_state() | | | | |
40+ | void crypto_init() | | | | |
41+ | GPS_position get_destination_position() | | | | |
42+ | enum GPS_return_status init_crypto_module() | | | | |
43+ | int time_current_time() | | | | |
44+ - Then generate the fuzz test with the following command:
45+ - ``` python3 gen_tests.py fuzztests gen_template/testgen_functions.xlsx . ```
46+ - This will create a file fuzztest.c. Copy its content to your own fuzztest
47+ - Include crypto_module_types.h and GPS_module_types.h in the fuzztest
48+ - Run the fuzztest
49+
50+
0 commit comments