Skip to content

Commit

Permalink
Fuzing: move yubihsm_fuzz.h
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgeana committed Oct 10, 2023
1 parent 51735d3 commit cdb46fb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/fuzz/fuzz_send_plain_msg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lib/fuzz/yubihsm_fuzz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions lib/fuzz/yubihsm_fuzz.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef _FUZZER_H
#define _FUZZER_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>
#include <yubihsm.h>

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
3 changes: 3 additions & 0 deletions pkcs11/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkcs11/fuzz/fuzz_get_attribute_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <openssl/ec.h>
#include <openssl/x509.h>

#include "../src/fuzz/fuzzer.h"
#include "yubihsm_fuzz.h"

extern "C" {
#include "pkcs11.h"
Expand Down

0 comments on commit cdb46fb

Please sign in to comment.