Skip to content

Commit

Permalink
Merge branch 'main' of github.com:vernamlab/SCLA_API_MQP
Browse files Browse the repository at this point in the history
  • Loading branch information
Trye1243 committed Apr 17, 2024
2 parents e259953 + c4b6f08 commit 898b194
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
17 changes: 13 additions & 4 deletions Testing/CWScopeTesting.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down Expand Up @@ -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)
8 changes: 4 additions & 4 deletions WPI_SCA_LIBRARY/CWScope.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions doc/cwscope.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit 898b194

Please sign in to comment.