41 return raw % (p_max + 1);
45#ifndef FUZZ_PICK_COMMAND_STRUCTURED
46#define FUZZ_PICK_COMMAND_STRUCTURED(data, size) (&fuzz_commands[fuzz_ctrl[1] % fuzz_n_commands])
49#ifndef FUZZ_PICK_COMMAND_RAW
50#define FUZZ_PICK_COMMAND_RAW(data, size) (&fuzz_commands[(data)[1] % fuzz_n_commands])
58 try_context_set(NULL);
59 memset(&fuzz_exit_jump_ctx, 0,
sizeof(fuzz_exit_jump_ctx));
71 try_context_set(&fuzz_exit_jump_ctx);
73 if (sigsetjmp(fuzz_exit_jump_ctx.jmp_buf, 1)) {
84 fuzz_tail_ptr = (size > 4) ? data + 4 : NULL;
85 fuzz_tail_len = (size > 4) ? size - 4 : 0;
96 memset(&cmd, 0,
sizeof(cmd));
104 size_t payload = size - 4;
105 cmd.
lc = (uint8_t) (payload > 255 ? 255 : payload);
106 cmd.
data = (uint8_t *) &data[4];
Shared constants 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...
static int fuzz_harness_entry(const uint8_t *data, size_t size)
Default fuzz_entry() body: run one fuzzer input as one APDU.
void fuzz_app_reset(void)
Reset app state before each iteration (required).
void fuzz_app_cleanup(void)
Optional per-iteration teardown; a weak no-op default is provided.
#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.
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 selects the structured lane.
#define FUZZ_PICK_COMMAND_STRUCTURED(data, size)
static void fuzz_harness_cleanup(void)
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.