Skip to content

Commit

Permalink
[fi] Add new Ibex FI command handlers
Browse files Browse the repository at this point in the history
This commit adds new command handlers for Ibex FI tests as well as
the corresponding configuration files for running a test.

Signed-off-by: Pascal Nasahl <[email protected]>
  • Loading branch information
nasahlpa committed Dec 3, 2024
1 parent f5f53b8 commit 298b11c
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ test:
which_test: "ibex_char_hardened_check_eq_unimp"
# which_test: "ibex_char_hardened_check_eq_2_unimps"
# which_test: "ibex_char_hardened_check_eq_3_unimps"
# which_test: "ibex_char_hardened_check_eq_4_unimps"
# which_test: "ibex_char_hardened_check_eq_5_unimps"
# which_test: "ibex_char_hardened_check_eq_complement_branch"
# For this test, the expected result is actually a crash of the system. On
# a successful FI attack, this could be one result:
expected_result: '{"result1":0,"result2":1,"err_status":0,"alerts":0}'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
target:
target_type: cw310
fpga_bitstream: "../objs/lowrisc_systems_chip_earlgrey_cw310_0.1.bit"
force_program_bitstream: False
fw_bin: "../objs/sca_ujson_fpga_cw310.bin"
output_len_bytes: 16
target_clk_mult: 0.24
target_freq: 24000000
baudrate: 115200
protocol: "ujson"
port: "/dev/ttyACM1"
fisetup:
fi_gear: "husky"
fi_type: "voltage_glitch"
# Parameter generation.
parameter_generation: "random"
# Number of randomized iterations for the parameter sweep.
# For parameter_generation: "random", this is the number of iterations.
# For parameter_generation: "deterministic", this is the number of iterations
# per fixed parameter.
num_iterations: 10000
# Voltage glitch width in cycles.
glitch_width_min: 5
glitch_width_max: 150
glitch_width_step: 3
# Range for trigger delay in cycles.
trigger_delay_min: 0
trigger_delay_max: 500
trigger_step: 10
fiproject:
# Project database type and memory threshold.
project_db: "ot_fi_project"
project_mem_threshold: 10000
# Store FI plot.
show_plot: True
num_plots: 100
plot_x_axis: "trigger_delay"
plot_x_axis_legend: "[cycles]"
plot_y_axis: "glitch_width"
plot_y_axis_legend: "[cycles]"
test:
which_test: "ibex_char_unrolled_reg_op_loop_chain"
expected_result: '{"err_status":0,"addresses":[0,0,0,0,0,0,0,0],"data":[60,55,56,57,58,59,0,0],"alerts":[0,0,0]}'
# Set to true if the test should ignore alerts returned by the test. As the
# alert handler on the device could sometime fire alerts that are not
# related to the FI, ignoring is by default set to true. A manual analysis
# still can be performed as the alerts are stored in the database.
ignore_alerts: True
38 changes: 37 additions & 1 deletion target/communication/fi_ibex_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ def ibex_char_unrolled_reg_op_loop(self) -> None:
time.sleep(0.01)
self.target.write(json.dumps("CharUnrolledRegOpLoop").encode("ascii"))

def ibex_char_unrolled_reg_op_loop_chain(self) -> None:
""" Starts the ibex.char.unrolled_reg_op_loop_chain test.
"""
# IbexFi command.
self._ujson_ibex_fi_cmd()
# CharUnrolledRegOpLoopChain command.
time.sleep(0.01)
self.target.write(json.dumps("CharUnrolledRegOpLoopChain").encode("ascii"))

def ibex_char_unrolled_mem_op_loop(self) -> None:
""" Starts the ibex.char.unrolled_mem_op_loop test.
"""
Expand Down Expand Up @@ -167,7 +176,7 @@ def ibex_char_conditional_branch_bltu(self) -> None:
"""
# IbexFi command.
self._ujson_ibex_fi_cmd()
# CharCondBranchBgltu command.
# CharCondBranchBltu command.
time.sleep(0.01)
self.target.write(json.dumps("CharCondBranchBltu").encode("ascii"))

Expand Down Expand Up @@ -295,6 +304,33 @@ def ibex_char_hardened_check_eq_3_unimps(self) -> None:
time.sleep(0.01)
self.target.write(json.dumps("CharHardenedCheck3Unimps").encode("ascii"))

def ibex_char_hardened_check_eq_4_unimps(self) -> None:
""" Starts the ibex.fi.char.hardened_check_eq_4_unimps test.
"""
# IbexFi command.
self._ujson_ibex_fi_cmd()
# CharHardenedCheck4Unimps command.
time.sleep(0.01)
self.target.write(json.dumps("CharHardenedCheck4Unimps").encode("ascii"))

def ibex_char_hardened_check_eq_5_unimps(self) -> None:
""" Starts the ibex.fi.char.hardened_check_eq_5_unimps test.
"""
# IbexFi command.
self._ujson_ibex_fi_cmd()
# CharHardenedCheck5Unimps command.
time.sleep(0.01)
self.target.write(json.dumps("CharHardenedCheck5Unimps").encode("ascii"))

def ibex_char_hardened_check_eq_complement_branch(self) -> None:
""" Starts the ibex.fi.char.hardened_check_eq_complement_branch test.
"""
# IbexFi command.
self._ujson_ibex_fi_cmd()
# CharHardenedCheckComplementBranch command.
time.sleep(0.01)
self.target.write(json.dumps("CharHardenedCheckComplementBranch").encode("ascii"))

def read_response(self, max_tries: Optional[int] = 1) -> str:
""" Read response from Ibex FI framework.
Args:
Expand Down

0 comments on commit 298b11c

Please sign in to comment.