31#if __has_include("mocks.h")
62 return raw % (p_max + 1);
71#ifndef FUZZ_APP_HEADER_LEN
72#define FUZZ_APP_HEADER_LEN 0
76#ifndef FUZZ_PICK_COMMAND_STRUCTURED
77#define FUZZ_PICK_COMMAND_STRUCTURED(data, size) (&fuzz_commands[(data)[1] % fuzz_n_commands])
80#ifndef FUZZ_PICK_COMMAND_RAW
81#define FUZZ_PICK_COMMAND_RAW(data, size) (&fuzz_commands[(data)[1] % fuzz_n_commands])
89 try_context_set(NULL);
133 memset(&cmd, 0,
sizeof(cmd));
160#ifndef FUZZ_APP_CUSTOM_MUTATOR
174#ifndef FUZZ_APP_CUSTOM_ENTRY
175int fuzz_entry(
const uint8_t *data,
size_t size);
Shared constants, the input layout, and the command descriptor type for SDK fuzz harnesses.
#define FUZZ_STRUCTURED_LANE_THRESHOLD
Control byte 0 above this value selects the structured lane; at or below it the harness takes the raw...
size_t fuzz_tail_len
Length of fuzz_tail_ptr in bytes.
#define FUZZ_CTRL_LEN
Bytes 0..3 steer the harness; byte 4 onwards is payload.
const uint8_t * fuzz_tail_ptr
The APDU payload for the current iteration (NULL when empty).
try_context_t fuzz_exit_jump_ctx
longjmp landing pad the harness unwinds os_exit() through.
static int fuzz_harness_entry(const uint8_t *data, size_t size)
Default fuzz_entry() body: run one fuzzer input as one APDU.
int fuzz_entry(const uint8_t *data, size_t size)
Default fuzz_entry(), the symbol Absolution calls per iteration.
static int fuzz_lane_structured
#define FUZZ_APP_HEADER_LEN
Bytes an app reserves for its own header, right after the control bytes.
void fuzz_app_reset(void)
Reset app state before each iteration (optional).
void fuzz_app_cleanup(void)
Optional per-iteration teardown; the weak no-op default is in mock/fuzz_runtime.c.
#define FUZZ_PICK_COMMAND_RAW(data, size)
void fuzz_app_dispatch(void *cmd)
Dispatch one command_t to the app (required).
const size_t fuzz_n_commands
Number of entries in fuzz_commands.
size_t LLVMFuzzerCustomMutator(uint8_t *data, size_t size, size_t max_size, unsigned int seed)
Default custom mutator.
static uint8_t fuzz_clamp_p(uint8_t raw, uint8_t p_max)
Clamp a raw P1/P2 byte to the command's declared maximum (0 = full range).
const fuzz_command_spec_t fuzz_commands[]
App command table.
static int fuzz_use_structured_lane(void)
Whether control byte 0 selected the structured lane.
#define FUZZ_PICK_COMMAND_STRUCTURED(data, size)
static void fuzz_harness_cleanup(void)
Prefix-aware LibFuzzer custom mutator.
size_t fuzz_custom_mutator(uint8_t *data, size_t size, size_t max_size, unsigned int seed)
The framework's LLVMFuzzerCustomMutator() body.
uint8_t ins
Instruction class.
uint8_t lc
Instruction parameter 2.
uint8_t p1
Instruction code.
uint8_t p2
Instruction parameter 1.
uint8_t * data
Length of command data.
Describes one APDU command the harness may synthesise and dispatch.
uint8_t p2_max
Upper bound for P2 (0 = full range [0,255]).
uint8_t p1_max
Upper bound for P1 (0 = full range [0,255]).
uint8_t ins
APDU instruction byte.
uint8_t cla
APDU class byte.