Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for LEIA target #280

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'scipy',
'fastdtw',
'Cython',
'smartleia-target',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to make this optional, since smartleia does pull in a bunch of other stuff

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I don't think this is available on pypi, so I'm assuming this will fail

'tqdm'
],
project_urls={
Expand Down
73 changes: 73 additions & 0 deletions software/chipwhisperer/capture/targets/Leia.py
Original file line number Diff line number Diff line change
@@ -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__()

1 change: 1 addition & 0 deletions software/chipwhisperer/capture/targets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .SimpleSerial2 import SimpleSerial2, SimpleSerial2_CDC
from .CW305_ECC import CW305_ECC
from .CW310 import CW310
from .Leia import LeiaTarget
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here (just a try except block would be fine, and log as info if the import fails)


try:
from .sakura_g import SakuraG #needs ftdi module
Expand Down
1 change: 1 addition & 0 deletions software/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here - this isn't on pypi, so it needs to be removed

pypandoc==1.3.3
tqdm>=4.40.0

Expand Down