Skip to content

Commit

Permalink
[fi] Add new OTBN FI command handlers
Browse files Browse the repository at this point in the history
This commit adds new command handlers for OTBN 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 34b6da6 commit f5f53b8
Show file tree
Hide file tree
Showing 8 changed files with 367 additions and 0 deletions.
43 changes: 43 additions & 0 deletions fault_injection/configs/pen.global_fi.otbn.char.beq.cw310.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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"
# 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
# Number of iterations for the parameter sweep.
num_iterations: 10000
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: "otbn_char_beq"
expected_result: '{"result":0,"insn_cnt":509,"err_otbn":0,"err_ibx":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
46 changes: 46 additions & 0 deletions fault_injection/configs/pen.global_fi.otbn.char.bn.wsrr.cw310.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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"
# 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
# Number of iterations for the parameter sweep.
num_iterations: 10000
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: "otbn_char_bn_wsrr"
# Dummy output as the test loads random data into the registers and returns
# them. A manual analysis needs to be conducted. The data below is just one
# example return:
expected_result: '{"res":0,"data":[1585161835,1395318448,2890819879,3136712568,770063824,2219904489,764659899,2486702447,4037540400,614377115,3197968746,3829183170,1217208500,2984391055,4204045979,3927849647,3154664099,1671909360,94406326,3952627616,3582590200,4190037997,2304031004,157144328,2260103769,2919798203,629100303,3335127767,1440583584,2806852168,253589472,1537510966,1833180752,738448520,857273198,3289363885,498312428,3956290796,165909034,2913103314,2520476051,1448274901,3051828369,1983483801,2287854020,1978131893,4197424509,1469036442,3778472960,1161382771,2495963230,2240442244,2058555455,4136769679,3939870669,4092271700,2946102449,1386662328,53933539,4069738070,1327264499,1177709886,4102007707,26243035,1095943202,3261427667,4081923136,656438830,920667429,3095485880,2925329630,3652937,4177988481,50094604,2703235463,3783326350,4037243375,3558349942,1153310057,3250570353,4208616314,1819758050,3564207168,848976619,2600757162,568767768,2928096480,1450335113,3503423304,1017499235,1538753346,365937573,1133187581,1161223460,508607669,3496451951,738347764,1592189018,1647073599,1466728303,888090145,2529417802,2416650464,243400432,1801322509,3875158167,2953017432,4032346342,1697418690,999598008,3539076319,3610751307,2272045055,2144075239,3115213856,2628046382,2887380138,2802550532,1330416942,3655833823,879856714,2349899852,907392561,3741950774,210289938,2752030681,3944634147,195960501,3557282938,2919884685,1294423341,1303043892,4155891137,2338665283,4177365229,3514649298,3143155664,4258812579,3034871739,3914477780,4244620410,2059688501,1074845932,1536903886,692295108,3059503351,3358862935,559181213,1644829944,4106525676,1012374772,4293212879,4293239457,954252643,631746646,3723899561,99403874,1799391813,669598107,3438552951,3734811336,4219762328,2461633293,2411639906,3331409284,3684554611,3070708463,3128889882,3730910557,769212611,3162133429,841669367,3960539475,1338151511,4001478471,157261863,652788060,177310084,4025058916,3220744880,1262531191,1954448459,3238153237,3846456280,2418505546,4142869129,3002632989,1721131344,910168114,2765616614,359261424,4022711666,1221656863,1632020259,1310255932,1547888502,4113262317,4027386150,1064630737,3855526843,1247192136,2434404035,547924336,4254830988,2883213590,2066157666,3939717086,2145542305,4077520884,1979083085,2665542397,2384144748,1552116798,280162933,3569673330,3067616959,3276087245,2374279083,189903255,3579058140,1424028086,2573541785,3485254217,3162775746,52441843,2650601396,345063869,1495226838,922624296,2586256062,335114986,3866297221,2711827532,738263943,1297957690,174637235,3851308727,1327129801,1646735295,4263996392,503547172,1110112700,825403378,151195603,1209092073,2498478637,3082734316,11266459,3093576862,2024216790,732247215,2971124300,2875710264,1731820720,915635070,3738937671],"insn_cnt":1089,"err_otbn":0,"err_ibx":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
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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"
# 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
# Number of iterations for the parameter sweep.
num_iterations: 10000
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: "otbn_char_dmem_access"
expected_result: '{"res":0,"data":[1752170618,3418933566,771316262,4010052340,2483697855,667193667,4142343277,258919171,1568367398,2083390144,822779226,1460736182,2472577306,1592644756,3462497725,2727813326,4031028770,2013723758,893979386,1311732921,1428641407,4120548177,4056821378,4020034490,2386760574,3343172890,2293757165,2262723144,748249686,1401292733,807848246,3730046934,2619074860,2032943536,1085649462,2671920459,1622914787,1912311726,3391365577,4256333020,2233440140,1440072100,2102472527,4219498733,3628925464,2016031521,496835627,2100551899,1954377022,1322324621,4133891729,2763881761,2199950666,3696470864,223672220,1879127539,3154836533,3664663838,2994899182,464953814,2783894004,7829331,3278890329,1538924890,1667118926,411767882,1164559549,1652414630,3064362610,2023222856,1688489707,308279992,64438546,2854554286,3758103254,3165512448,3555303949,1496873998,1089353835,4285534125,1223513568,974584991,2344229968,766618146,1942701401,1139369403,75412658,52415182,2255817440,3526010056,2536578112,3569007285,2081641394,1516189644,265179347,813865141,747614792,168407506,108663204,4292691240,794894046,2237659246,377116394,820426910,1638793281,3097826007,3558814448,960610601,1930477156,1671537109,250494443,2586076563,946256704,3267121137,3189486529,3964200644,888992584,3495652898,1529411913,2598903086,3513281746,3231295608,2803605408,3100054487,645745023,2355743283,1480423879,2172027945,1266942366,3913525525,1092007188,623760003,1328680366,1682389994,2525476757,91894463,999873799,233141538,3150195604,548149341,3209425774,3888891766,2765385373,3567370867,3377184759,3299905540,3255715595,3329689998,2822181885,3284805046,4229950334,825123374,1038376279,2470646264,4218773437,3746395077,1448724516,3262565001,1661122272,1877452977,857694292,772569637,802843685,2125455361,3406777056,1764727446,920060882,4025369693,1349100798,2657217694,3394126751,687787461,576621678,1479550633,2357376939,1082544701,2007372129,1976310578,3156904125,592833811,3705765941,359181864,2221615505,881896932,4111468059,3200275311,2017758330,2983828617,2458693710,1318909501,761916836,3033935028,3438888195,3544373064,49464920,28038751,3663653666,762100395,1461355421,2489968999,365663631,1685236111,1515268868,3440084261,3377173686,2531354775,3364444857,355319372,3977655639,2562537247,2632720970,2322265413,4165295828,1717227322,191431321,3846398043,1421641274,1737581554,899970312,3106177760,3829243285,3798641989,1615864806,3367735900,3225082500,4154605851,3694669111,3189306406,2529953284,1801951682,1348275831,559991528,3520078732,3214041459,2057586075,2195673018,3287101809,2946758789,3811293796,2432574270,4201292549,1274171431,1009532021,1331756015,4233976805,1172338183,3572168806,2894879080,4008636142,117835012,185207048,252579084,319951120,387323156,454695192,522067228],"insn_cnt":271,"err_otbn":0,"err_ibx":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
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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"
# 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
# Number of iterations for the parameter sweep.
num_iterations: 10000
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: "otbn_char_dmem_write"
expected_result: '{"result":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"insn_cnt":1,"err_otbn":0,"err_ibx":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
43 changes: 43 additions & 0 deletions fault_injection/configs/pen.global_fi.otbn.char.jal.cw310.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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"
# 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
# Number of iterations for the parameter sweep.
num_iterations: 10000
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: "otbn_char_jal"
expected_result: '{"result":0,"insn_cnt":505,"err_otbn":0,"err_ibx":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
43 changes: 43 additions & 0 deletions fault_injection/configs/pen.global_fi.otbn.char.lw.cw310.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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"
# 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
# Number of iterations for the parameter sweep.
num_iterations: 10000
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: "otbn_char_lw"
expected_result: '{"result":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"insn_cnt":1084,"err_otbn":0,"err_ibx":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
43 changes: 43 additions & 0 deletions fault_injection/configs/pen.global_fi.otbn.char.rf.cw310.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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"
# 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
# Number of iterations for the parameter sweep.
num_iterations: 10000
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: "otbn_char_rf"
expected_result: '{"res":0,"faulty_gpr":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"faulty_wdr":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"err_otbn":0,"err_ibx":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
63 changes: 63 additions & 0 deletions target/communication/fi_otbn_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,69 @@ def _ujson_otbn_fi_cmd(self) -> None:
time.sleep(0.01)
self.target.write(json.dumps("OtbnFi").encode("ascii"))

def otbn_char_dmem_access(self) -> None:
""" Starts the otbn.fi.char.dmem.access test.
"""
# OtbnFi command.
self._ujson_otbn_fi_cmd()
# CharDmemAccess command.
time.sleep(0.01)
self.target.write(json.dumps("CharDmemAccess").encode("ascii"))

def otbn_char_dmem_write(self) -> None:
""" Starts the otbn.fi.char.dmem.write test.
"""
# OtbnFi command.
self._ujson_otbn_fi_cmd()
# CharDmemWrite command.
time.sleep(0.01)
self.target.write(json.dumps("CharDmemWrite").encode("ascii"))

def otbn_char_rf(self) -> None:
""" Starts the otbn.fi.char.rf test.
"""
# OtbnFi command.
self._ujson_otbn_fi_cmd()
# CharRF command.
time.sleep(0.01)
self.target.write(json.dumps("CharRF").encode("ascii"))

def otbn_char_beq(self) -> None:
""" Starts the otbn.fi.char.beq test.
"""
# OtbnFi command.
self._ujson_otbn_fi_cmd()
# CharBeq command.
time.sleep(0.01)
self.target.write(json.dumps("CharBeq").encode("ascii"))

def otbn_char_jal(self) -> None:
""" Starts the otbn.fi.char.jal test.
"""
# OtbnFi command.
self._ujson_otbn_fi_cmd()
# CharJal command.
time.sleep(0.01)
self.target.write(json.dumps("CharJal").encode("ascii"))

def otbn_char_bn_wsrr(self) -> None:
""" Starts the otbn.fi.char.bn.wsrr test.
"""
# OtbnFi command.
self._ujson_otbn_fi_cmd()
# CharBnWsrr command.
time.sleep(0.01)
self.target.write(json.dumps("CharBnWsrr").encode("ascii"))

def otbn_char_lw(self) -> None:
""" Starts the otbn.fi.char.lw test.
"""
# OtbnFi command.
self._ujson_otbn_fi_cmd()
# CharLw command.
time.sleep(0.01)
self.target.write(json.dumps("CharLw").encode("ascii"))

def otbn_char_unrolled_reg_op_loop(self) -> None:
""" Starts the otbn.fi.char.unrolled.reg.op.loop test.
"""
Expand Down

0 comments on commit f5f53b8

Please sign in to comment.