Skip to content
New issue

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

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

Already on GitHub? # to your account

During select cards might respond with 61nn #231

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) -> Tuple[bytes, int, int]:
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