Skip to content

Commit

Permalink
[otbn, sca] optimized some parameters to speed things up
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Tempelmeier <[email protected]>
  • Loading branch information
m-temp committed Jan 25, 2023
1 parent b4802fa commit bed7225
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions cw/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def capture_ecdsa_secret_keygen(ot, ktp, fw_bin, pll_frequency, capture_cfg):
"""
# Currently, we need to reprogram the firmware before every sign operation
# TODO: Investigate if this is needed.
reset_firmware = True
reset_firmware = False

# OTBN operations are long. CW-Husky can store only 131070 samples
# in the non-stream mode. In case we want to collect more samples,
Expand Down Expand Up @@ -1069,7 +1069,7 @@ def capture_ecdsa_secret_keygen(ot, ktp, fw_bin, pll_frequency, capture_cfg):

# Generate a new random mask for each trace.
mask = ktp.next_text()
print(f'mask = {mask.hex()}')
tqdm.write(f'mask = {mask.hex()}')

# Loop to collect each section of the power trace
for ii in range(num_sections):
Expand Down Expand Up @@ -1097,13 +1097,13 @@ def capture_ecdsa_secret_keygen(ot, ktp, fw_bin, pll_frequency, capture_cfg):
ret = ot.scope.capture(poll_done=True)
# If getting inconsistent results (e.g. variable number of cycles),
# adding a sufficient sleep below here appears to fix things
time.sleep(1)
#time.sleep(1) # we cannot afford 1 second per run.
if ret:
raise RuntimeError('Timeout during capture')

# Check the number of cycles where the trigger signal was high.
cycles = ot.scope.adc.trig_count
print("Observed number of cycles: %d" % cycles)
tqdm.write("Observed number of cycles: %d" % cycles)

# Append the section into the waves array
waves = np.append(waves, ot.scope.get_last_trace(as_int=True))
Expand Down
6 changes: 4 additions & 2 deletions cw/capture_ecdsa_skgen_cw310.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ capture:
# Output length (most likely unused).
output_len_bytes: 40
# Samples per trace
num_samples: 262140
# num_samples: 262140
# Fifo Size is 131070
num_samples: 131070 # max num samples to avoid multiple runs per trace
# Offset in samples
offset: 0
# scope gain in db - 13 for non-stream mode, 32.5 for stream mode
scope_gain: 32.5
num_traces: 1
num_traces: 100
project_name: projects/opentitan_ecdsa_keygen
waverunner_ip: 192.168.1.228
# As OTBN operations are long, we may need to overwrite the following
Expand Down

0 comments on commit bed7225

Please sign in to comment.