From cdb46fbac36383dbb50af398ffbdc551d039a5d8 Mon Sep 17 00:00:00 2001 From: Alexandru Geana Date: Tue, 10 Oct 2023 13:03:13 +0200 Subject: [PATCH] Fuzing: move yubihsm_fuzz.h --- lib/fuzz/fuzz_send_plain_msg.cc | 2 +- lib/fuzz/yubihsm_fuzz.cc | 2 +- lib/fuzz/yubihsm_fuzz.h | 21 +++++++++++++++++++++ pkcs11/CMakeLists.txt | 3 +++ pkcs11/fuzz/fuzz_get_attribute_value.cc | 2 +- 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 lib/fuzz/yubihsm_fuzz.h diff --git a/lib/fuzz/fuzz_send_plain_msg.cc b/lib/fuzz/fuzz_send_plain_msg.cc index 94453342..49d1406e 100644 --- a/lib/fuzz/fuzz_send_plain_msg.cc +++ b/lib/fuzz/fuzz_send_plain_msg.cc @@ -8,7 +8,7 @@ uint8_t *backend_data; size_t backend_data_len; } -#include "../src/fuzz/fuzzer.h" +#include "yubihsm_fuzz.h" yh_connector *connector; diff --git a/lib/fuzz/yubihsm_fuzz.cc b/lib/fuzz/yubihsm_fuzz.cc index cb4708d0..5b90efdf 100644 --- a/lib/fuzz/yubihsm_fuzz.cc +++ b/lib/fuzz/yubihsm_fuzz.cc @@ -32,7 +32,7 @@ extern "C" { #include "../aes_cmac/aes_cmac.h" } -#include "../src/fuzz/fuzzer.h" +#include "yubihsm_fuzz.h" static void process_msg(Msg *msg, Msg *response); static bool compute_mac(Scp_ctx *s, uint8_t *key, Msg *msg, size_t raw_msg_len, diff --git a/lib/fuzz/yubihsm_fuzz.h b/lib/fuzz/yubihsm_fuzz.h new file mode 100644 index 00000000..8b05c8b7 --- /dev/null +++ b/lib/fuzz/yubihsm_fuzz.h @@ -0,0 +1,21 @@ +#ifndef _FUZZER_H +#define _FUZZER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +extern yh_session *fuzz_session; +#define FUZZ_BACKEND_PASSWORD "fuzzfuzz" + +extern uint8_t *backend_data; +extern size_t backend_data_len; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/pkcs11/CMakeLists.txt b/pkcs11/CMakeLists.txt index 3e2acb3a..f6cd5bc2 100644 --- a/pkcs11/CMakeLists.txt +++ b/pkcs11/CMakeLists.txt @@ -100,6 +100,9 @@ install(FILES pkcs11y.h DESTINATION "${YUBIHSM_INSTALL_INC_DIR}/pkcs11") add_subdirectory (tests) if (FUZZING) + include_directories( + ../lib/fuzz + ) add_executable(fuzz_get_attribute_value # harness sources fuzz/fuzz_get_attribute_value.cc diff --git a/pkcs11/fuzz/fuzz_get_attribute_value.cc b/pkcs11/fuzz/fuzz_get_attribute_value.cc index 22f38b5a..2fb1f4fb 100644 --- a/pkcs11/fuzz/fuzz_get_attribute_value.cc +++ b/pkcs11/fuzz/fuzz_get_attribute_value.cc @@ -4,7 +4,7 @@ #include #include -#include "../src/fuzz/fuzzer.h" +#include "yubihsm_fuzz.h" extern "C" { #include "pkcs11.h"