diff --git a/cw/simple_capture_aes_sca.py b/cw/simple_capture_aes_sca.py index 3ab04dff6..f0a482c63 100755 --- a/cw/simple_capture_aes_sca.py +++ b/cw/simple_capture_aes_sca.py @@ -21,7 +21,6 @@ from util import device, plot, trace_util - def abort_handler_during_loop(project, sig, frame): # Handler for ctrl-c keyboard interrupts # TODO: Has to be modified according to database (i.e. CW project atm) used @@ -31,7 +30,6 @@ def abort_handler_during_loop(project, sig, frame): sys.exit(0) - if __name__ == '__main__': # Load configuration from file with open('simple_capture_aes_sca.yaml') as f: @@ -87,7 +85,7 @@ def abort_handler_during_loop(project, sig, frame): cwfpgahusky.target.simpleserial_write('p', text) # TODO: Useful code line for batch capture - #cwfpgahusky..simpleserial_write("s", capture_cfg["batch_prng_seed"].to_bytes(4, "little")) + # cwfpgahusky..simpleserial_write("s", capture_cfg["batch_prng_seed"].to_bytes(4, "little")) # Arm scope cwfpgahusky.scope.arm() @@ -104,7 +102,8 @@ def abort_handler_during_loop(project, sig, frame): print("Warning: Timeout happened during capture") # Get response and verify - response = cwfpgahusky.target.simpleserial_read('r', cwfpgahusky.target.output_len, ack=False) + response = cwfpgahusky.target.simpleserial_read('r', + cwfpgahusky.target.output_len, ack=False) if binascii.b2a_hex(response) != binascii.b2a_hex(cipher.encrypt(bytes(text))): raise RuntimeError(f'Bad ciphertext: {response} != {cipher.encrypt(bytes(text))}.') diff --git a/cw/util/trace_util.py b/cw/util/trace_util.py index 81bc4d0a2..27405ae4f 100644 --- a/cw/util/trace_util.py +++ b/cw/util/trace_util.py @@ -4,6 +4,7 @@ import numpy as np + def check_range(waves, bits_per_sample): """ The ADC output is in the interval [0, 2**bits_per_sample-1]. Check that the recorded traces are within [1, 2**bits_per_sample-2] to ensure the ADC doesn't saturate. """