Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey authored and mmerklinger committed Sep 13, 2024
1 parent 7625efa commit 4367040
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pynitrokey/nk3/piv_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class PivApp:
def __init__(self, logfn: Optional[LogFn] = None):
self.log = logging.getLogger("pivapp")
readers = smartcard.System.readers()
chosen_connection = None
self.connection = None
chosen_connection: Optional[CardConnection] = None
for r in readers:
print(r)
connection = r.createConnection()
Expand Down Expand Up @@ -87,6 +86,7 @@ def __init__(self, logfn: Optional[LogFn] = None):
if sw1 != 0x90 or sw2 != 0x00:
continue
chosen_connection = connection

if not chosen_connection:
raise NoCardException("No PIV card found", -1)

Expand All @@ -113,12 +113,12 @@ def _send_receive_inner(self, data: bytes, log_info: str = "") -> bytes:
)

try:
result, sw1, sw2 = self.connection.transmit(list(data))
result_list, sw1, sw2 = self.connection.transmit(list(data))
except Exception as e:
self.logfn(f"Got exception: {e}")
raise

result = bytes(result)
result = bytes(result_list)
status_bytes = bytes([sw1, sw2])
self.logfn(f"Received [{status_bytes.hex()}] {result.hex()}")

Expand All @@ -137,12 +137,12 @@ def _send_receive_inner(self, data: bytes, log_info: str = "") -> bytes:
le = sw2 if sw2 != 0 else 0xFF
bytes_data = iso7816_compose(ins, p1, p2, le=le)
try:
result, sw1, sw2 = self.connection.transmit(list(bytes_data))
result_list, sw1, sw2 = self.connection.transmit(list(bytes_data))
except Exception as e:
self.logfn(f"Got exception: {e}")
raise
# Data order is different here than in APDU - SW is first, then the data if any
result = bytes(result)
result = bytes(result_list)
status_bytes = bytes([sw1, sw2])
self.logfn(f"Received [{status_bytes.hex()}] {bytes(result).hex()}")
if status_bytes[0] in [0x90, MORE_DATA_STATUS_BYTE]:
Expand Down Expand Up @@ -359,7 +359,7 @@ def serial(self) -> int:
return int.from_bytes(response, byteorder="big")

def reader(self) -> str:
reader: str = self.connection.getReader()
reader: str = self.connection.getReader() # type: ignore
return reader

def guid(self) -> bytes:
Expand Down

0 comments on commit 4367040

Please sign in to comment.