Skip to content

Commit 5616fce

Browse files
committed
[capture] Enable uJSON for OTBN
This commit enables communication with the OTBN SCA code over uJSON. Currently, the ECC256 Keygen SCA test is supported. The device code is located in lowRISC/opentitan#22190. Signed-off-by: Pascal Nasahl <[email protected]>
1 parent c4575d2 commit 5616fce

9 files changed

+456
-508
lines changed

.github/workflows/fpga.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,65 @@ jobs:
148148
name: traces_sha3_random_cw310_ujson
149149
path: ./ci/projects/sha3_sca_random_cw310_ujson.html
150150

151+
otbn_sca_capture_cw310:
152+
name: Capture OTBN SCA traces (CW310)
153+
runs-on: [ubuntu-22.04-fpga, cw310]
154+
timeout-minutes: 30
155+
156+
steps:
157+
- uses: actions/checkout@v4
158+
with:
159+
lfs: true
160+
161+
- name: Install python dependencies
162+
run: |
163+
python3 -m pip install --user -r python-requirements.txt
164+
mkdir -p ci/projects
165+
166+
- name: Capture OTBN Vertical Keygen traces (simpleserial)
167+
working-directory: ci
168+
run: |
169+
../capture/capture_otbn.py -c cfg/ci_otbn_sca_vertical_keygen_cw310_simpleserial.yaml -p projects/otbn_sca_vertical_keygen_cw310_simpleserial
170+
171+
- name: Upload OTBN Vertical Keygen traces (simpleserial)
172+
uses: actions/upload-artifact@v4
173+
with:
174+
name: traces_otbn_sca_vertical_keygen_cw310_simpleserial
175+
path: ./ci/projects/otbn_sca_vertical_keygen_cw310_simpleserial.html
176+
177+
- name: Capture OTBN Vertical Keygen traces (ujson)
178+
working-directory: ci
179+
run: |
180+
../capture/capture_otbn.py -c cfg/ci_otbn_sca_vertical_keygen_cw310_ujson.yaml -p projects/otbn_sca_vertical_keygen_cw310_ujson
181+
182+
- name: Upload OTBN Vertical Keygen traces (ujson)
183+
uses: actions/upload-artifact@v4
184+
with:
185+
name: traces_otbn_sca_vertical_keygen_cw310_ujson
186+
path: ./ci/projects/otbn_sca_vertical_keygen_cw310_ujson.html
187+
188+
- name: Capture OTBN Vertical Modinv traces (simpleserial)
189+
working-directory: ci
190+
run: |
191+
../capture/capture_otbn.py -c cfg/ci_otbn_sca_vertical_modinv_cw310_simpleserial.yaml -p projects/otbn_sca_vertical_modinv_cw310_simpleserial
192+
193+
- name: Upload OTBN Vertical Modinv traces (simpleserial)
194+
uses: actions/upload-artifact@v4
195+
with:
196+
name: traces_otbn_sca_vertical_modinv_cw310_simpleserial
197+
path: ./ci/projects/otbn_sca_vertical_modinv_cw310_simpleserial.html
198+
199+
- name: Capture OTBN Vertical Modinv traces (ujson)
200+
working-directory: ci
201+
run: |
202+
../capture/capture_otbn.py -c cfg/ci_otbn_sca_vertical_modinv_cw310_ujson.yaml -p projects/otbn_sca_vertical_modinv_cw310_ujson
203+
204+
- name: Upload OTBN Vertical Modinv traces (ujson)
205+
uses: actions/upload-artifact@v4
206+
with:
207+
name: traces_otbn_sca_vertical_modinv_cw310_ujson
208+
path: ./ci/projects/otbn_sca_vertical_modinv_cw310_ujson.html
209+
151210
sca_capture_cw305:
152211
name: Capture AES SCA traces (CW305)
153212
runs-on: [ubuntu-22.04-fpga, cw305]

capture/capture_otbn.py

Lines changed: 161 additions & 423 deletions
Large diffs are not rendered by default.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
target:
2+
target_type: cw310
3+
fpga_bitstream: "../objs/lowrisc_systems_chip_earlgrey_cw310_0.1.bit"
4+
force_program_bitstream: True
5+
fw_bin: ../objs/sca_ujson_fpga_cw310.bin
6+
# target_clk_mult is a hardcoded value in the bitstream. Do not change.
7+
target_clk_mult: 0.24
8+
target_freq: 24000000
9+
baudrate: 115200
10+
output_len_bytes: 40
11+
protocol: "ujson"
12+
port: "/dev/ttyACM1"
13+
husky:
14+
sampling_rate: 200000000
15+
num_segments: 10
16+
num_cycles: 1075
17+
offset_cycles: 0
18+
scope_gain: 24
19+
adc_mul: 1
20+
decimate: 1
21+
waverunner:
22+
waverunner_ip: 100.107.71.10
23+
num_segments: 1
24+
num_samples: 6000
25+
sample_offset: 0
26+
capture:
27+
scope_select: husky
28+
show_plot: True
29+
plot_traces: 100
30+
num_traces: 1000000
31+
trace_threshold: 110000
32+
trace_db: ot_trace_library
33+
test:
34+
batch_prng_seed: 0
35+
key_len_bytes: 40
36+
text_len_bytes: 40
37+
plain_text_len_bytes: 40
38+
masks_on: True
39+
# Currently, 'p256' is the only supported curve.
40+
curve: p256
41+
# Select the OTBN app to analyze. Currently available: 'keygen', 'modinv'
42+
app: keygen
43+
# For app = keygen: There are two fixed-vs-random test types, KEY and SEED
44+
# Currently batch-mode capture only works with SEED
45+
test_type: KEY
46+
batch_mode: True

capture/configs/otbn_vertical_keygen_sca_cw310.yaml renamed to ci/cfg/ci_otbn_sca_vertical_keygen_cw310_simpleserial.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
11
target:
22
target_type: cw310
33
fpga_bitstream: "../objs/lowrisc_systems_chip_earlgrey_cw310_0.1.bit"
4-
force_program_bitstream: True
4+
force_program_bitstream: False
55
fw_bin: "../objs/otbn_vertical_serial_fpga_cw310.bin"
66
# target_clk_mult is a hardcoded value in the bitstream. Do not change.
77
target_clk_mult: 0.24
88
target_freq: 24000000
99
baudrate: 115200
1010
output_len_bytes: 40
1111
protocol: "simpleserial"
12-
# protocol: "ujson"
13-
# port: "/dev/ttyACM4"
1412
# Trigger source.
1513
# hw: Precise, hardware-generated trigger - FPGA only.
1614
# sw: Fully software-controlled trigger.
1715
trigger: "hw"
1816
husky:
1917
sampling_rate: 200000000
20-
num_segments: 20
18+
num_segments: 1
2119
num_cycles: 200
2220
offset_cycles: 0
2321
scope_gain: 24
2422
adc_mul: 1
2523
decimate: 1
26-
waverunner:
27-
waverunner_ip: 100.107.71.10
28-
num_segments: 20
29-
num_samples: 6000
30-
sample_offset: 0
3124
capture:
3225
scope_select: husky
3326
show_plot: True
34-
plot_traces: 100
35-
num_traces: 1000
27+
plot_traces: 10
28+
num_traces: 100
3629
trace_threshold: 10000
3730
trace_db: ot_trace_library
3831
test:
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
target:
2+
target_type: cw310
3+
fpga_bitstream: "../objs/lowrisc_systems_chip_earlgrey_cw310_0.1.bit"
4+
force_program_bitstream: False
5+
fw_bin: ../objs/sca_ujson_fpga_cw310.bin
6+
# target_clk_mult is a hardcoded value in the bitstream. Do not change.
7+
target_clk_mult: 0.24
8+
target_freq: 24000000
9+
baudrate: 115200
10+
output_len_bytes: 40
11+
protocol: "ujson"
12+
port: "/dev/ttyACM_CW310_1"
13+
# Trigger source.
14+
# hw: Precise, hardware-generated trigger - FPGA only.
15+
# sw: Fully software-controlled trigger.
16+
trigger: "hw"
17+
husky:
18+
sampling_rate: 200000000
19+
num_segments: 1
20+
num_cycles: 200
21+
offset_cycles: 0
22+
scope_gain: 24
23+
adc_mul: 1
24+
decimate: 1
25+
capture:
26+
scope_select: husky
27+
show_plot: True
28+
plot_traces: 10
29+
num_traces: 100
30+
trace_threshold: 10000
31+
trace_db: ot_trace_library
32+
test:
33+
batch_prng_seed: 6
34+
key_len_bytes: 40
35+
text_len_bytes: 40
36+
plain_text_len_bytes: 40
37+
masks_off: False
38+
# Currently, 'p256' is the only supported curve.
39+
curve: p256
40+
# Select the OTBN app to analyze. Currently available: 'keygen', 'modinv'
41+
app: keygen
42+
# For app = keygen: There are two fixed-vs-random test types, KEY and SEED
43+
# Currently batch-mode capture only works with SEED
44+
test_type: SEED
45+
batch_mode: False

capture/configs/otbn_vertical_modinv_sca_cw310.yaml renamed to ci/cfg/ci_otbn_sca_vertical_modinv_cw310_simpleserial.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
target:
22
target_type: cw310
33
fpga_bitstream: "../objs/lowrisc_systems_chip_earlgrey_cw310_0.1.bit"
4-
force_program_bitstream: True
4+
force_program_bitstream: False
55
fw_bin: "../objs/otbn_vertical_serial_fpga_cw310.bin"
66
# target_clk_mult is a hardcoded value in the bitstream. Do not change.
77
target_clk_mult: 0.24
88
target_freq: 24000000
99
baudrate: 115200
1010
output_len_bytes: 40
1111
protocol: "simpleserial"
12-
# protocol: "ujson"
13-
# port: "/dev/ttyACM4"
1412
# Trigger source.
1513
# hw: Precise, hardware-generated trigger - FPGA only.
1614
# sw: Fully software-controlled trigger.
17-
trigger: "hw"
15+
trigger: "sw"
1816
husky:
1917
sampling_rate: 200000000
2018
num_segments: 20
@@ -23,16 +21,11 @@ husky:
2321
scope_gain: 24
2422
adc_mul: 1
2523
decimate: 1
26-
waverunner:
27-
waverunner_ip: 100.107.71.10
28-
num_segments: 20
29-
num_samples: 6000
30-
sample_offset: 0
3124
capture:
3225
scope_select: husky
3326
show_plot: True
34-
plot_traces: 100
35-
num_traces: 1000
27+
plot_traces: 10
28+
num_traces: 100
3629
trace_threshold: 10000
3730
trace_db: ot_trace_library
3831
test:
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
target:
2+
target_type: cw310
3+
fpga_bitstream: "../objs/lowrisc_systems_chip_earlgrey_cw310_0.1.bit"
4+
force_program_bitstream: False
5+
fw_bin: ../objs/sca_ujson_fpga_cw310.bin
6+
# target_clk_mult is a hardcoded value in the bitstream. Do not change.
7+
target_clk_mult: 0.24
8+
target_freq: 24000000
9+
baudrate: 115200
10+
output_len_bytes: 40
11+
protocol: "ujson"
12+
port: "/dev/ttyACM_CW310_1"
13+
# Trigger source.
14+
# hw: Precise, hardware-generated trigger - FPGA only.
15+
# sw: Fully software-controlled trigger.
16+
trigger: "sw"
17+
husky:
18+
sampling_rate: 200000000
19+
num_segments: 20
20+
num_cycles: 1000
21+
offset_cycles: 0
22+
scope_gain: 24
23+
adc_mul: 1
24+
decimate: 1
25+
capture:
26+
scope_select: husky
27+
show_plot: True
28+
plot_traces: 10
29+
num_traces: 100
30+
trace_threshold: 10000
31+
trace_db: ot_trace_library
32+
test:
33+
batch_prng_seed: 6
34+
key_len_bytes: 40
35+
text_len_bytes: 40
36+
plain_text_len_bytes: 40
37+
masks_off: False
38+
# Currently, 'p256' is the only supported curve.
39+
curve: p256
40+
# Select the OTBN app to analyze. Currently available: 'keygen', 'modinv'
41+
app: modinv
42+
# For app = keygen: There are two fixed-vs-random test types, KEY and SEED
43+
# Currently batch-mode capture only works with SEED
44+
test_type: SEED
45+
batch_mode: False

objs/sca_ujson_fpga_cw310.bin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:b79fa7125b748b00bc231ecb563e266edf4213eb27ef2318b35315d5c32169b1
3-
size 304188
2+
oid sha256:435a989c52dcde6cc2d0cf3b5ffbb1eac4d499c9964d1ce44e5a30ba279ad510
3+
size 326668

0 commit comments

Comments
 (0)