aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ08nY2023-02-17 17:21:27 +0100
committerJ08nY2023-02-17 17:21:27 +0100
commit6cbb129e1f7dfa4d4ca248f2f246781433a4fc4d (patch)
tree8e6aed52e85b1075526ed2fcce0c9da422d07f83
parent9efa088d462899c94afd06fbad25003c403a6cee (diff)
downloadpyecsca-6cbb129e1f7dfa4d4ca248f2f246781433a4fc4d.tar.gz
pyecsca-6cbb129e1f7dfa4d4ca248f2f246781433a4fc4d.tar.zst
pyecsca-6cbb129e1f7dfa4d4ca248f2f246781433a4fc4d.zip
-rw-r--r--.github/workflows/lint.yml2
-rw-r--r--.github/workflows/test.yml4
-rw-r--r--pyecsca/sca/target/__init__.py18
-rw-r--r--pyecsca/sca/target/ectester.py20
-rw-r--r--setup.py2
5 files changed, 31 insertions, 15 deletions
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 048772a..0d02c48 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -40,7 +40,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
- pip install -e ".[picoscope_sdk, picoscope_alt, chipwhisperer, smartcard, gmp, test, dev]"
+ pip install -e ".[picoscope_sdk, picoscope_alt, chipwhisperer, smartcard, leia, gmp, test, dev]"
- name: Typecheck
run: |
make typecheck
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index b58efa2..42eb8ba 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -50,8 +50,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
- if [ $USE_GMP == 1 ]; then pip install -e ".[picoscope_sdk, picoscope_alt, chipwhisperer, smartcard, gmp, test, dev]"; fi
- if [ $USE_GMP == 0 ]; then pip install -e ".[picoscope_sdk, picoscope_alt, chipwhisperer, smartcard, test, dev]"; fi
+ if [ $USE_GMP == 1 ]; then pip install -e ".[picoscope_sdk, picoscope_alt, chipwhisperer, smartcard, leia, gmp, test, dev]"; fi
+ if [ $USE_GMP == 0 ]; then pip install -e ".[picoscope_sdk, picoscope_alt, chipwhisperer, smartcard, leia, test, dev]"; fi
- name: Test
run: |
make test
diff --git a/pyecsca/sca/target/__init__.py b/pyecsca/sca/target/__init__.py
index f1555dd..bc9a54d 100644
--- a/pyecsca/sca/target/__init__.py
+++ b/pyecsca/sca/target/__init__.py
@@ -7,8 +7,9 @@ from .simpleserial import *
from .binary import *
from .flash import *
-has_chipwhisperer = False
-has_pyscard = False
+has_chipwhisperer: bool = False
+has_pyscard: bool = False
+has_leia: bool = False
try:
import chipwhisperer
@@ -24,9 +25,20 @@ try:
except ImportError: # pragma: no cover
pass
+try:
+ import smartleia
+
+ has_leia = True
+except ImportError: # pragma: no cover
+ pass
+
+from .ectester import ECTesterTarget # noqa
+
if has_pyscard:
from .PCSC import *
- from .ectester import ECTesterTarget
+
+if has_leia:
+ from .leia import *
if has_chipwhisperer:
from .chipwhisperer import *
diff --git a/pyecsca/sca/target/ectester.py b/pyecsca/sca/target/ectester.py
index 74c4a95..f1a3639 100644
--- a/pyecsca/sca/target/ectester.py
+++ b/pyecsca/sca/target/ectester.py
@@ -10,8 +10,7 @@ from typing import Optional, Mapping, List, Union
from public import public
from .ISO7816 import CommandAPDU, ResponseAPDU, ISO7816, ISO7816Target, CardProtocol, CardConnectionException
-from .leia import LEIATarget
-from .PCSC import PCSCTarget
+from . import has_leia, has_pyscard
from ...ec.model import ShortWeierstrassModel
from ...ec.params import DomainParameters
from ...ec.point import Point
@@ -985,11 +984,16 @@ class ECTesterTarget(ISO7816Target, ABC): # pragma: no cover
return RunModeResponse(resp)
-@public
-class ECTesterTargetPCSC(ECTesterTarget, PCSCTarget):
- pass
+if has_pyscard:
+ from .PCSC import PCSCTarget
+ @public
+ class ECTesterTargetPCSC(ECTesterTarget, PCSCTarget):
+ pass
-@public
-class ECTesterTargetLEIA(ECTesterTarget, LEIATarget):
- pass
+if has_leia:
+ from .leia import LEIATarget
+
+ @public
+ class ECTesterTargetLEIA(ECTesterTarget, LEIATarget):
+ pass
diff --git a/setup.py b/setup.py
index 97ca299..e7b1df4 100644
--- a/setup.py
+++ b/setup.py
@@ -52,6 +52,6 @@ setup(
"gmp": ["gmpy2"],
"dev": ["mypy", "flake8", "interrogate", "pyinstrument", "black", "types-setuptools"],
"test": ["nose2", "parameterized", "coverage"],
- "doc": ["sphinx", "sphinx-autodoc-typehints", "nbsphinx"]
+ "doc": ["sphinx", "sphinx-autodoc-typehints", "nbsphinx", "sphinx-paramlinks"]
}
)