Skip to content

Commit

Permalink
[capture] Enable uJSON for OTBN
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
nasahlpa committed Apr 17, 2024
1 parent c4575d2 commit 7d0dc05
Show file tree
Hide file tree
Showing 10 changed files with 503 additions and 503 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/fpga.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,65 @@ jobs:
name: traces_sha3_random_cw310_ujson
path: ./ci/projects/sha3_sca_random_cw310_ujson.html

otbn_sca_capture_cw310:
name: Capture OTBN SCA traces (CW310)
runs-on: [ubuntu-22.04-fpga, cw310]
timeout-minutes: 30

steps:
- uses: actions/checkout@v4
with:
lfs: true

- name: Install python dependencies
run: |
python3 -m pip install --user -r python-requirements.txt
mkdir -p ci/projects
- name: Capture OTBN Vertical Keygen traces (simpleserial)
working-directory: ci
run: |
../capture/capture_otbn.py -c cfg/ci_otbn_sca_vertical_keygen_cw310_simpleserial.yaml -p projects/otbn_sca_vertical_keygen_cw310_simpleserial
- name: Upload OTBN Vertical Keygen traces (simpleserial)
uses: actions/upload-artifact@v4
with:
name: traces_otbn_sca_vertical_keygen_cw310_simpleserial
path: ./ci/projects/otbn_sca_vertical_keygen_cw310_simpleserial.html

- name: Capture OTBN Vertical Keygen traces (ujson)
working-directory: ci
run: |
../capture/capture_otbn.py -c cfg/ci_otbn_sca_vertical_keygen_cw310_ujson.yaml -p projects/otbn_sca_vertical_keygen_cw310_ujson
- name: Upload OTBN Vertical Keygen traces (ujson)
uses: actions/upload-artifact@v4
with:
name: traces_otbn_sca_vertical_keygen_cw310_ujson
path: ./ci/projects/otbn_sca_vertical_keygen_cw310_ujson.html

- name: Capture OTBN Vertical Modinv traces (simpleserial)
working-directory: ci
run: |
../capture/capture_otbn.py -c cfg/ci_otbn_sca_vertical_modinv_cw310_simpleserial.yaml -p projects/otbn_sca_vertical_modinv_cw310_simpleserial
- name: Upload OTBN Vertical Modinv traces (simpleserial)
uses: actions/upload-artifact@v4
with:
name: traces_otbn_sca_vertical_modinv_cw310_simpleserial
path: ./ci/projects/otbn_sca_vertical_modinv_cw310_simpleserial.html

- name: Capture OTBN Vertical Modinv traces (ujson)
working-directory: ci
run: |
../capture/capture_otbn.py -c cfg/ci_otbn_sca_vertical_modinv_cw310_ujson.yaml -p projects/otbn_sca_vertical_modinv_cw310_ujson
- name: Upload OTBN Vertical Modinv traces (ujson)
uses: actions/upload-artifact@v4
with:
name: traces_otbn_sca_vertical_modinv_cw310_ujson
path: ./ci/projects/otbn_sca_vertical_modinv_cw310_ujson.html

sca_capture_cw305:
name: Capture AES SCA traces (CW305)
runs-on: [ubuntu-22.04-fpga, cw305]
Expand Down
584 changes: 161 additions & 423 deletions capture/capture_otbn.py

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions capture/configs/otbn_ecc256_keygen_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: True
fw_bin: ../objs/sca_ujson_fpga_cw310.bin
# target_clk_mult is a hardcoded value in the bitstream. Do not change.
target_clk_mult: 0.24
target_freq: 24000000
baudrate: 115200
output_len_bytes: 40
protocol: "ujson"
port: "/dev/ttyACM1"
husky:
sampling_rate: 200000000
num_segments: 10
num_cycles: 1075
offset_cycles: 0
scope_gain: 24
adc_mul: 1
decimate: 1
waverunner:
waverunner_ip: 100.107.71.10
num_segments: 1
num_samples: 6000
sample_offset: 0
capture:
scope_select: husky
show_plot: True
plot_traces: 100
num_traces: 1000000
trace_threshold: 110000
trace_db: ot_trace_library
test:
batch_prng_seed: 0
key_len_bytes: 40
text_len_bytes: 40
plain_text_len_bytes: 40
masks_on: True
# Currently, 'p256' is the only supported curve.
curve: p256
# Select the OTBN app to analyze. Currently available: 'keygen', 'modinv'
app: keygen
# For app = keygen: There are two fixed-vs-random test types, KEY and SEED
# Currently batch-mode capture only works with SEED
test_type: KEY
batch_mode: True
13 changes: 7 additions & 6 deletions capture/configs/otbn_vertical_keygen_sca_cw310.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@ target:
target_type: cw310
fpga_bitstream: "../objs/lowrisc_systems_chip_earlgrey_cw310_0.1.bit"
force_program_bitstream: True
fw_bin: "../objs/otbn_vertical_serial_fpga_cw310.bin"
# fw_bin: "../objs/otbn_vertical_serial_fpga_cw310.bin"
fw_bin: ../objs/sca_ujson_fpga_cw310.bin
# target_clk_mult is a hardcoded value in the bitstream. Do not change.
target_clk_mult: 0.24
target_freq: 24000000
baudrate: 115200
output_len_bytes: 40
protocol: "simpleserial"
# protocol: "ujson"
# port: "/dev/ttyACM4"
# protocol: "simpleserial"
protocol: "ujson"
port: "/dev/ttyACM4"
# Trigger source.
# hw: Precise, hardware-generated trigger - FPGA only.
# sw: Fully software-controlled trigger.
trigger: "hw"
husky:
sampling_rate: 200000000
num_segments: 20
num_segments: 1
num_cycles: 200
offset_cycles: 0
scope_gain: 24
adc_mul: 1
decimate: 1
waverunner:
waverunner_ip: 100.107.71.10
num_segments: 20
num_segments: 1
num_samples: 6000
sample_offset: 0
capture:
Expand Down
44 changes: 44 additions & 0 deletions ci/cfg/ci_otbn_sca_vertical_keygen_cw310_simpleserial.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
target:
target_type: cw310
fpga_bitstream: "../objs/lowrisc_systems_chip_earlgrey_cw310_0.1.bit"
force_program_bitstream: False
fw_bin: "../objs/otbn_vertical_serial_fpga_cw310.bin"
# target_clk_mult is a hardcoded value in the bitstream. Do not change.
target_clk_mult: 0.24
target_freq: 24000000
baudrate: 115200
output_len_bytes: 40
protocol: "simpleserial"
# Trigger source.
# hw: Precise, hardware-generated trigger - FPGA only.
# sw: Fully software-controlled trigger.
trigger: "hw"
husky:
sampling_rate: 200000000
num_segments: 1
num_cycles: 200
offset_cycles: 0
scope_gain: 24
adc_mul: 1
decimate: 1
capture:
scope_select: husky
show_plot: True
plot_traces: 10
num_traces: 100
trace_threshold: 10000
trace_db: ot_trace_library
test:
batch_prng_seed: 6
key_len_bytes: 40
text_len_bytes: 40
plain_text_len_bytes: 40
masks_off: False
# Currently, 'p256' is the only supported curve.
curve: p256
# Select the OTBN app to analyze. Currently available: 'keygen', 'modinv'
app: keygen
# For app = keygen: There are two fixed-vs-random test types, KEY and SEED
# Currently batch-mode capture only works with SEED
test_type: SEED
batch_mode: False
45 changes: 45 additions & 0 deletions ci/cfg/ci_otbn_sca_vertical_keygen_cw310_ujson.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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
# target_clk_mult is a hardcoded value in the bitstream. Do not change.
target_clk_mult: 0.24
target_freq: 24000000
baudrate: 115200
output_len_bytes: 40
protocol: "ujson"
port: "/dev/ttyACM_CW310_1"
# Trigger source.
# hw: Precise, hardware-generated trigger - FPGA only.
# sw: Fully software-controlled trigger.
trigger: "hw"
husky:
sampling_rate: 200000000
num_segments: 1
num_cycles: 200
offset_cycles: 0
scope_gain: 24
adc_mul: 1
decimate: 1
capture:
scope_select: husky
show_plot: True
plot_traces: 10
num_traces: 100
trace_threshold: 10000
trace_db: ot_trace_library
test:
batch_prng_seed: 6
key_len_bytes: 40
text_len_bytes: 40
plain_text_len_bytes: 40
masks_off: False
# Currently, 'p256' is the only supported curve.
curve: p256
# Select the OTBN app to analyze. Currently available: 'keygen', 'modinv'
app: keygen
# For app = keygen: There are two fixed-vs-random test types, KEY and SEED
# Currently batch-mode capture only works with SEED
test_type: SEED
batch_mode: False
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
target:
target_type: cw310
fpga_bitstream: "../objs/lowrisc_systems_chip_earlgrey_cw310_0.1.bit"
force_program_bitstream: True
force_program_bitstream: False
fw_bin: "../objs/otbn_vertical_serial_fpga_cw310.bin"
# target_clk_mult is a hardcoded value in the bitstream. Do not change.
target_clk_mult: 0.24
target_freq: 24000000
baudrate: 115200
output_len_bytes: 40
protocol: "simpleserial"
# protocol: "ujson"
# port: "/dev/ttyACM4"
# Trigger source.
# hw: Precise, hardware-generated trigger - FPGA only.
# sw: Fully software-controlled trigger.
trigger: "hw"
trigger: "sw"
husky:
sampling_rate: 200000000
num_segments: 20
Expand All @@ -23,16 +21,11 @@ husky:
scope_gain: 24
adc_mul: 1
decimate: 1
waverunner:
waverunner_ip: 100.107.71.10
num_segments: 20
num_samples: 6000
sample_offset: 0
capture:
scope_select: husky
show_plot: True
plot_traces: 100
num_traces: 1000
plot_traces: 10
num_traces: 100
trace_threshold: 10000
trace_db: ot_trace_library
test:
Expand Down
45 changes: 45 additions & 0 deletions ci/cfg/ci_otbn_sca_vertical_modinv_cw310_ujson.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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
# target_clk_mult is a hardcoded value in the bitstream. Do not change.
target_clk_mult: 0.24
target_freq: 24000000
baudrate: 115200
output_len_bytes: 40
protocol: "ujson"
port: "/dev/ttyACM_CW310_1"
# Trigger source.
# hw: Precise, hardware-generated trigger - FPGA only.
# sw: Fully software-controlled trigger.
trigger: "sw"
husky:
sampling_rate: 200000000
num_segments: 20
num_cycles: 1000
offset_cycles: 0
scope_gain: 24
adc_mul: 1
decimate: 1
capture:
scope_select: husky
show_plot: True
plot_traces: 10
num_traces: 100
trace_threshold: 10000
trace_db: ot_trace_library
test:
batch_prng_seed: 6
key_len_bytes: 40
text_len_bytes: 40
plain_text_len_bytes: 40
masks_off: False
# Currently, 'p256' is the only supported curve.
curve: p256
# Select the OTBN app to analyze. Currently available: 'keygen', 'modinv'
app: modinv
# For app = keygen: There are two fixed-vs-random test types, KEY and SEED
# Currently batch-mode capture only works with SEED
test_type: SEED
batch_mode: False
4 changes: 2 additions & 2 deletions objs/sca_ujson_fpga_cw310.bin
Git LFS file not shown
Loading

0 comments on commit 7d0dc05

Please sign in to comment.