Skip to content

Commit

Permalink
Fix OTP commands over CCID that do not return status.
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Oct 25, 2023
1 parent 6496393 commit 067d3bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/device/test_otp.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ def test_slot_configured(self, session, read_config):
assert not state.is_configured(SLOT.ONE)
assert not state.is_configured(SLOT.TWO)

def test_configure_ndef(self, session):
session.put_configuration(SLOT.ONE, StaticPasswordSlotConfiguration(b"a"))
session.set_ndef_configuration(SLOT.ONE)

@condition.min_version(3)
@pytest.mark.parametrize("slot", [SLOT.ONE, SLOT.TWO])
def test_slot_touch_triggered(self, session, read_config, slot):
Expand Down
4 changes: 4 additions & 0 deletions yubikit/yubiotp.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ def send_and_receive(self, slot, data, expected_len, event=None, on_keepalive=No


INS_CONFIG = 0x01
INS_YK2_STATUS = 0x03


class _YubiOtpSmartCardBackend(_Backend):
Expand All @@ -686,6 +687,9 @@ def close(self):

def write_update(self, slot, data):
status = self.protocol.send_apdu(0, INS_CONFIG, slot, 0, data)
if not status: # Some commands don't return status on some YubiKeys
status = self.protocol.send_apdu(0, INS_YK2_STATUS, 0, 0)

prev_prog_seq, self._prog_seq = self._prog_seq, status[3]
if self._prog_seq == prev_prog_seq + 1:
return status
Expand Down

0 comments on commit 067d3bd

Please sign in to comment.