diff options
| author | J08nY | 2023-02-17 18:38:52 +0100 |
|---|---|---|
| committer | J08nY | 2023-02-17 18:38:52 +0100 |
| commit | 254678c4efcd10cf043ada7531aaaeb84210ec8a (patch) | |
| tree | 42a821f9a7a4e7993a10b689d16bb598bd9af56c | |
| parent | e575b24819b3025839ebee83d6a65bbf2874cf0c (diff) | |
| download | pyecsca-254678c4efcd10cf043ada7531aaaeb84210ec8a.tar.gz pyecsca-254678c4efcd10cf043ada7531aaaeb84210ec8a.tar.zst pyecsca-254678c4efcd10cf043ada7531aaaeb84210ec8a.zip | |
Fix for ECTester applet for 304.
| -rw-r--r-- | pyecsca/sca/target/ectester.py | 12 | ||||
| -rw-r--r-- | pyecsca/sca/target/leia.py | 4 |
2 files changed, 9 insertions, 7 deletions
diff --git a/pyecsca/sca/target/ectester.py b/pyecsca/sca/target/ectester.py index 1ba162d..e360224 100644 --- a/pyecsca/sca/target/ectester.py +++ b/pyecsca/sca/target/ectester.py @@ -514,6 +514,7 @@ class ECTesterTarget(ISO7816Target, ABC): # pragma: no cover AID_CURRENT_VERSION = bytes([0x30, 0x33, 0x33]) # Version v0.3.3 AID_SUFFIX_221 = bytes([0x62]) AID_SUFFIX_222 = bytes([0x78]) + AID_SUFFIX_304 = bytes([0x94]) chunking: bool @@ -561,13 +562,10 @@ class ECTesterTarget(ISO7816Target, ABC): # pragma: no cover """ version_bytes = bytearray(latest_version) for _ in range(count_back): - aid_222 = self.AID_PREFIX + version_bytes + self.AID_SUFFIX_222 - if self.select(aid_222): - break - else: - aid_221 = self.AID_PREFIX + version_bytes + self.AID_SUFFIX_221 - if self.select(aid_221): - break + for aid_suffix in (self.AID_SUFFIX_304, self.AID_SUFFIX_222, self.AID_SUFFIX_221): + aid = self.AID_PREFIX + version_bytes + aid_suffix + if self.select(aid): + return True # Count down by versions if version_bytes[2] == 0x30: if version_bytes[1] == 0x30: diff --git a/pyecsca/sca/target/leia.py b/pyecsca/sca/target/leia.py index cb72955..f4d5643 100644 --- a/pyecsca/sca/target/leia.py +++ b/pyecsca/sca/target/leia.py @@ -16,6 +16,10 @@ class LEIATarget(ISO7816Target): # pragma: no cover def atr(self) -> bytes: return self.leia.get_ATR().normalized() + @property + def card_present(self) -> bool: + return self.leia.is_card_inserted() + def select(self, aid: bytes) -> bool: apdu = CommandAPDU(0x00, 0xA4, 0x04, 0x00, aid) resp = self.send_apdu(apdu) |
