Skip to content

Add support for LEIA target#280

Open
GotoHack wants to merge 4120 commits into
newaetech:developfrom
h2lab:LEIA
Open

Add support for LEIA target#280
GotoHack wants to merge 4120 commits into
newaetech:developfrom
h2lab:LEIA

Conversation

@GotoHack

@GotoHack GotoHack commented Sep 4, 2020

Copy link
Copy Markdown

This add support for the LEIA by H2LAB target: an open hardware and open source device targeting smart card side-channel analysis (SCA) and evaluation, for educational and evaluation purpose. It implements a fully controlled ISO7816 stack with a dedicated custom hardware platform to acquire clean measurements for SCA characterization.

alex-dewar and others added 30 commits November 3, 2020 18:34
For SWO trace (without an external debugger).
Major issue with captures sometimes returning bad data
Max reads limited to 128 bytes if nano and fw_ver <= 0.23
@alex-dewar alex-dewar self-requested a review August 23, 2021 19:50

@alex-dewar alex-dewar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will need the following changes before merging in. Additionally, I'd like to test this locally, but I run into the following issues:

On first connect:

---------------------------------------------------------------------------
SerialException                           Traceback (most recent call last)
<ipython-input-1-dff1e27c4691> in <module>
      1 import chipwhisperer as cw
      2 cw.target_logger.setLevel(cw.logging.INFO)
----> 3 target = cw.target(None, cw.targets.LeiaTarget)

c:\users\adewa\code\chipwhisperer\software\chipwhisperer\__init__.py in target(scope, target_type, **kwargs)
    284     """
    285     target = target_type()
--> 286     target.con(scope, **kwargs)
    287 
    288     # need to check

c:\users\adewa\code\chipwhisperer\software\chipwhisperer\capture\targets\Leia.py in con(self, scope, **kwargs)
     34 
     35         try:
---> 36             self.open()
     37             self.connectStatus = True
     38 

C:\Users\adewa\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\smartleia\__init__.py in open(self)
    811                     break
    812         else:
--> 813             self.ser = self.serial_factory(self.device, timeout=1, baudrate=115200)
    814             while True:
    815                 d = self.read_all()

C:\Users\adewa\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\serial\serialwin32.py in __init__(self, *args, **kwargs)
     31         self._overlapped_read = None
     32         self._overlapped_write = None
---> 33         super(Serial, self).__init__(*args, **kwargs)
     34 
     35     def open(self):

C:\Users\adewa\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\serial\serialutil.py in __init__(self, port, baudrate, bytesize, parity, stopbits, timeout, xonxoff, rtscts, write_timeout, dsrdtr, inter_byte_timeout, exclusive, **kwargs)
    242 
    243         if port is not None:
--> 244             self.open()
    245 
    246     #  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

C:\Users\adewa\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\serial\serialwin32.py in open(self)
     62         if self._port_handle == win32.INVALID_HANDLE_VALUE:
     63             self._port_handle = None    # 'cause __del__ is called anyway
---> 64             raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
     65 
     66         try:

SerialException: could not open port 'COM18': PermissionError(13, 'Access is denied.', None, 5)

On second connection:

---------------------------------------------------------------------------
ConnectionError                           Traceback (most recent call last)
<ipython-input-2-78fdaec6a794> in <module>
      1 import chipwhisperer as cw
----> 2 target = cw.target(None, cw.targets.LeiaTarget)

c:\users\adewa\code\chipwhisperer\software\chipwhisperer\__init__.py in target(scope, target_type, **kwargs)
    284     """
    285     target = target_type()
--> 286     target.con(scope, **kwargs)
    287 
    288     # need to check

c:\users\adewa\code\chipwhisperer\software\chipwhisperer\capture\targets\Leia.py in con(self, scope, **kwargs)
     34 
     35         try:
---> 36             self.open()
     37             self.connectStatus = True
     38 

C:\Users\adewa\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\smartleia\__init__.py in open(self)

C:\Users\adewa\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\smartleia\__init__.py in _testWaitingFlag(self)

ConnectionError: Can not connect to LEIA.

On third connection:

---------------------------------------------------------------------------
SerialException                           Traceback (most recent call last)
<ipython-input-3-78fdaec6a794> in <module>
      1 import chipwhisperer as cw
----> 2 target = cw.target(None, cw.targets.LeiaTarget)

c:\users\adewa\code\chipwhisperer\software\chipwhisperer\__init__.py in target(scope, target_type, **kwargs)
    284     """
    285     target = target_type()
--> 286     target.con(scope, **kwargs)
    287 
    288     # need to check

c:\users\adewa\code\chipwhisperer\software\chipwhisperer\capture\targets\Leia.py in con(self, scope, **kwargs)
     34 
     35         try:
---> 36             self.open()
     37             self.connectStatus = True
     38 

C:\Users\adewa\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\smartleia\__init__.py in open(self)

C:\Users\adewa\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\serial\serialwin32.py in __init__(self, *args, **kwargs)
     31         self._overlapped_read = None
     32         self._overlapped_write = None
---> 33         super(Serial, self).__init__(*args, **kwargs)
     34 
     35     def open(self):

C:\Users\adewa\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\serial\serialutil.py in __init__(self, port, baudrate, bytesize, parity, stopbits, timeout, xonxoff, rtscts, write_timeout, dsrdtr, inter_byte_timeout, exclusive, **kwargs)
    242 
    243         if port is not None:
--> 244             self.open()
    245 
    246     #  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

C:\Users\adewa\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\serial\serialwin32.py in open(self)
     62         if self._port_handle == win32.INVALID_HANDLE_VALUE:
     63             self._port_handle = None    # 'cause __del__ is called anyway
---> 64             raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
     65 
     66         try:

SerialException: could not open port 'COM19': PermissionError(13, 'Access is denied.', None, 5)

Comment thread setup.py
'scipy',
'fastdtw',
'Cython',
'smartleia-target',

Copy link
Copy Markdown
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
Copy Markdown
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

from .SimpleSerial2 import SimpleSerial2, SimpleSerial2_CDC
from .CW305_ECC import CW305_ECC
from .CW310 import CW310
from .Leia import LeiaTarget

Copy link
Copy Markdown
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)

Comment thread software/requirements.txt
pyserial==3.4
fastdtw==0.3.4
Cython>=0.29.14
smartleia_target=>1.0.0

Copy link
Copy Markdown
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants