From 9567503f688547071192388836746d1105a5c753 Mon Sep 17 00:00:00 2001 From: SamKarkache <93103617+SamKarkache@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:02:30 -0400 Subject: [PATCH 1/2] fix cw capture bug --- Testing/CWScopeTesting.py | 17 +++++++++++++---- WPI_SCA_LIBRARY/CWScope.py | 8 ++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Testing/CWScopeTesting.py b/Testing/CWScopeTesting.py index 256f7e9..ccab28a 100644 --- a/Testing/CWScopeTesting.py +++ b/Testing/CWScopeTesting.py @@ -1,8 +1,10 @@ import time +import numpy as np + from WPI_SCA_LIBRARY.CWScope import * -firmware_path = "C:\\Users\\samka\\PycharmProjects\\MQP\\SCLA_API_MQP\\WPI_SCA_LIBRARY\\firmware\\simpleserial-aes-CWLITEARM-SS_2_1.hex" +firmware_path = "C:\\Users\\samka\\PycharmProjects\\SCLA_API_MQP\\WPI_SCA_LIBRARY\\firmware\\simpleserial-aes-CWLITEARM-SS_2_1.hex" def benchmark_capture_procedures(): @@ -40,11 +42,18 @@ def benchmark_capture_procedures(): plt.ylabel("Time (s)") plt.show() -benchmark_capture_procedures() - def test_cw_to_file_format(): scope = CWScope(firmware_path, gain=25, num_samples=3000, offset=0, target_type=cw.targets.SimpleSerial2, target_programmer=cw.programmers.STM32FProgrammer) - file = FileParent("AnotherFile", "C:\\Users\\samka\\PycharmProjects\\MQP\\SCLA_API_MQP\\", existing=True) + + file = FileParent("AnotherFile", "C:\\Users\\samka\\PycharmProjects\\SCLA_API_MQP\\", existing=True) scope.cw_to_file_framework(1000, file, "TestExperiment") + + +scope = CWScope(firmware_path, gain=25, num_samples=3000, offset=0, target_type=cw.targets.SimpleSerial2, target_programmer=cw.programmers.STM32FProgrammer) +ktp = cw.ktp.Basic() + +# keys = [ktp.next()[0]] * 1000 +# texts = [ktp.next()[1]] * 1000 +# scope.standard_capture_traces(1000, keys, texts) diff --git a/WPI_SCA_LIBRARY/CWScope.py b/WPI_SCA_LIBRARY/CWScope.py index 722b4b9..a1d876e 100644 --- a/WPI_SCA_LIBRARY/CWScope.py +++ b/WPI_SCA_LIBRARY/CWScope.py @@ -50,8 +50,8 @@ def disconnect(self): self.target.dis() def standard_capture_traces(self, num_traces: int, - experiment_keys: np.ndarray = None, - experiment_texts: np.ndarray = None, + experiment_keys: list = None, + experiment_texts: list = None, fixed_key: bool = True, fixed_pt: bool = False) -> (np.ndarray, np.ndarray, np.ndarray, np.ndarray): """ @@ -131,8 +131,8 @@ def standard_capture_traces(self, num_traces: int, return traces, keys, texts, ciphertexts - def capture_traces_tvla(self, num_traces: int, group_a_keys: np.ndarray = None, group_a_texts: np.ndarray = None, - group_b_keys: np.ndarray = None, group_b_texts: np.ndarray = None, + def capture_traces_tvla(self, num_traces: int, group_a_keys: list = None, group_a_texts: list= None, + group_b_keys: list = None, group_b_texts: list = None, ktp: any = cwtvla.ktp.FixedVRandomText()) -> (np.ndarray, np.ndarray): """ Captures fixed and random trace set needed for TVLA. From c4b6f087e8e833fa1fab20ab82193abdb396c325 Mon Sep 17 00:00:00 2001 From: SamKarkache <93103617+SamKarkache@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:14:25 -0400 Subject: [PATCH 2/2] fixed documentation to reflect bug fix --- doc/cwscope.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/cwscope.rst b/doc/cwscope.rst index 2cd4538..4033a15 100644 --- a/doc/cwscope.rst +++ b/doc/cwscope.rst @@ -40,10 +40,10 @@ higher-level API calls :type num_traces: int :param experiment_keys: A collection of keys to use for the capture of each trace. If not specified, the procedure will use the cw basic key generation `key = cw.ktp.Basic()[0]` - :type experiment_keys: np.ndarray + :type experiment_keys: list :param experiment_texts: A collection of texts to use for the capture of each trace. If not specified, the procedure will use the cw basic plaintext generation `text = cw.ktp.Basic()[1]` - :type experiment_texts: np.ndarray + :type experiment_texts: list :param fixed_key: Whether to use a fixed key for cw.ktp key generation. Ignored if a collection of keys are supplied. :type fixed_key: bool :param fixed_pt: Whether to use a fixed plaintext for cw.ktp text generation. Ignored if a collection of texts are supplied. @@ -61,13 +61,13 @@ higher-level API calls :param num_traces: The number of traces to capture for each set :type num_traces: int :param group_a_keys: An array of keys for group A - :type group_a_keys: np.ndarray + :type group_a_keys: list :param group_a_texts: An array of texts for group A - :type group_a_texts: np.ndarray + :type group_a_texts: list :param group_b_keys: An array of keys for group B - :type group_b_keys: np.ndarray + :type group_b_keys: list :param group_b_texts: An array of texts for group B - :type group_b_texts: np.ndarray + :type group_b_texts: list :param ktp: the key text pair algorithm, defaults to cwtvla.ktp.FixedVRandomText(). This is ignored if keys or texts for group A and group B are provided. :rtype: (np.ndarray, np.ndarray)