diff --git a/setup.py b/setup.py index a51d8510a..0cfa547b7 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ 'scipy', 'fastdtw', 'Cython', + 'smartleia-target', 'tqdm' ], project_urls={ diff --git a/software/chipwhisperer/capture/targets/Leia.py b/software/chipwhisperer/capture/targets/Leia.py new file mode 100644 index 000000000..7acd8637f --- /dev/null +++ b/software/chipwhisperer/capture/targets/Leia.py @@ -0,0 +1,73 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# ================================================= + +import smartleia_target as LEIATarget +from ._base import TargetTemplate +from chipwhisperer.common.utils.util import dict_to_str + +class LeiaTarget( LEIATarget.TargetController, TargetTemplate): + _name= 'LEIA Java Smartcard Target' + + connectStatus = False + + def __init__(self): + LEIATarget.TargetController.__init__(self) + + def __del__(self): + """Close system if needed""" + + self.close() + + def getStatus(self): + return self.connectStatus + + def dis(self): + """Disconnect from target""" + + self.close() + self.connectStatus = False + + def con(self, scope=None, **kwargs): + """Connect to target""" + + try: + self.open() + self.connectStatus = True + + except: + self.dis() + raise + + @property + def output_len(self): + """The length of the output expected from the crypto algorithm (in bytes)""" + + return len(self.getExpected()) + + @output_len.setter + def output_len(self, length): + #FIXME + return 16 + + def _con(self, scope=None): + self.con() + + def reinit(self): + pass + + def validateSettings(self): + # FIXME + # return [("warn", "Target Module", "You can't use module \"" + self.getName() + "\"", "Specify other module", "57a3924d-3794-4ca6-9693-46a7b5243727")] + return [] + + def _dict_repr(self): + raise NotImplementedError("Must define target-specific properties.") + + def __repr__(self): + return dict_to_str(self._dict_repr()) + + def __str__(self): + return self.__repr__() + diff --git a/software/chipwhisperer/capture/targets/__init__.py b/software/chipwhisperer/capture/targets/__init__.py index 84161cac7..114110673 100644 --- a/software/chipwhisperer/capture/targets/__init__.py +++ b/software/chipwhisperer/capture/targets/__init__.py @@ -13,6 +13,7 @@ from .SimpleSerial2 import SimpleSerial2, SimpleSerial2_CDC from .CW305_ECC import CW305_ECC from .CW310 import CW310 +from .Leia import LeiaTarget try: from .sakura_g import SakuraG #needs ftdi module diff --git a/software/requirements.txt b/software/requirements.txt index 12ae54ff2..480178bbb 100644 --- a/software/requirements.txt +++ b/software/requirements.txt @@ -14,6 +14,7 @@ sphinxcontrib-images>=0.9.1 pyserial==3.4 fastdtw==0.3.4 Cython>=0.29.14 +smartleia_target=>1.0.0 pypandoc==1.3.3 tqdm>=4.40.0