Skip to content

Commit

Permalink
During select cards might respond with 61nn
Browse files Browse the repository at this point in the history
Closes Yubico#230
  • Loading branch information
gergof committed Sep 18, 2024
1 parent 35c2d92 commit 4c2b401
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fido2/pcsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def control_exchange(self, control_code: int, control_data: bytes = b"") -> byte

def _select(self) -> None:
apdu = b"\x00\xa4\x04\x00" + struct.pack("!B", len(AID_FIDO)) + AID_FIDO
resp, sw1, sw2 = self.apdu_exchange(apdu)
resp, sw1, sw2 = self._chained_apdu_exchange(apdu)
if (sw1, sw2) != SW_SUCCESS:
raise ValueError("FIDO applet selection failure.")
if resp == b"U2F_V2":
Expand Down Expand Up @@ -165,7 +165,7 @@ def _chain_apdus(
resp += lres
return resp, sw1, sw2

def _call_apdu(self, apdu: bytes) -> bytes:
def _chained_apdu_exchange(self, apdu: bytes) -> bytes:
if len(apdu) >= 7 and apdu[4] == 0:
# Extended APDU
data_len = struct.unpack("!H", apdu[5:7])[0]
Expand All @@ -178,7 +178,10 @@ def _call_apdu(self, apdu: bytes) -> bytes:
data = apdu[5 : 5 + data_len]
(cla, ins, p1, p2) = apdu[:4]

resp, sw1, sw2 = self._chain_apdus(cla, ins, p1, p2, data)
return self._chain_apdus(cla, ins, p1, p2, data)

def _call_apdu(self, apdu: bytes) -> bytes:
resp, sw1, sw2 = self._chained_apdu_exchange(apdu)
return resp + struct.pack("!BB", sw1, sw2)

def _call_cbor(
Expand Down

0 comments on commit 4c2b401

Please # to comment.