fido2.pcsc

Attributes

AID_FIDO

SW_SUCCESS

SW_UPDATE

SW1_MORE_DATA

Classes

CtapPcscDevice

CtapDevice implementation using pyscard (PCSC).

Module Contents

fido2.pcsc.AID_FIDO = b'\xa0\x00\x00\x06G/\x00\x01'
fido2.pcsc.SW_SUCCESS = (144, 0)
fido2.pcsc.SW_UPDATE = (145, 0)
fido2.pcsc.SW1_MORE_DATA = 97
class fido2.pcsc.CtapPcscDevice(connection, name)

Bases: fido2.ctap.CtapDevice

CtapDevice implementation using pyscard (PCSC).

This class is intended for use with NFC readers.

Parameters:
  • connection (smartcard.CardConnection.CardConnection)

  • name (str)

use_ext_apdu = False
connect()
__repr__()
property version: int

CTAPHID protocol version.

Return type:

int

property capabilities: fido2.hid.CAPABILITY

Capabilities supported by the device.

Return type:

fido2.hid.CAPABILITY

property product_name: str | None

Product name of device.

Return type:

Optional[str]

property serial_number: int | None

Serial number of device.

Return type:

Optional[int]

get_atr()

Get the ATR/ATS of the connected card.

Return type:

bytes

apdu_exchange(apdu, protocol=None)

Exchange data with smart card.

Parameters:
  • apdu (bytes) – byte string. data to exchange with card

  • protocol (Optional[int])

Returns:

byte string. response from card

Return type:

Tuple[bytes, int, int]

control_exchange(control_code, control_data=b'')

Sends control sequence to reader’s driver.

Parameters:
  • control_code (int) – int. code to send to reader driver.

  • control_data (bytes) – byte string. data to send to driver

Returns:

byte string. response

Return type:

bytes

call(cmd, data=b'', event=None, on_keepalive=None)

Sends a command to the authenticator, and reads the response.

Parameters:
  • cmd (int) – The integer value of the command.

  • data (bytes) – The payload of the command.

  • event (Optional[threading.Event]) – An optional threading.Event which can be used to cancel the invocation.

  • on_keepalive (Optional[Callable[[fido2.ctap.STATUS], None]]) – An optional callback to handle keep-alive messages from the authenticator. The function is only called once for consecutive keep-alive messages with the same status.

Returns:

The response from the authenticator.

Return type:

bytes

close()

Close the device, releasing any held resources.

Return type:

None

classmethod list_devices(name='')

Generates instances of cls for discoverable devices.

Parameters:

name (str)

Return type:

Iterator[CtapPcscDevice]