ykman.pcsc

Attributes

YK_READER_NAME

Exceptions

CancelledException

Raised when the caller cancels an operation.

Classes

REINSERT_STATUS

Create a collection of name/value pairs.

YkmanDevice

YubiKey device reference, with optional PID

ScardSmartCardConnection

A connection to a YubiKey

ScardYubiKeyDevice

YubiKey Smart card device

Functions

kill_scdaemon()

kill_yubikey_agent()

list_readers()

list_devices([name_filter])

Package Contents

class ykman.pcsc.REINSERT_STATUS(*args, **kwds)[source]

Bases: enum.Enum

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

REMOVE = 1
REINSERT = 2
exception ykman.pcsc.CancelledException[source]

Bases: Exception

Raised when the caller cancels an operation.

class ykman.pcsc.YkmanDevice(transport, fingerprint, pid)[source]

Bases: yubikit.core.YubiKeyDevice

YubiKey device reference, with optional PID

Parameters:
property pid: yubikit.core.PID | None

Return the PID of the YubiKey, if available.

Return type:

yubikit.core.PID | None

reinsert(reinsert_cb=None, event=None)[source]

Wait for the user to remove and reinsert the YubiKey.

This may be required to perform certain operations, such as FIDO reset.

This method will attempt to verify that the same YubiKey is reinserted, but it will only fail when this is definitely not the case (eg. if the serial number does not match).

Parameters:
Return type:

None

and should be reinserted. :param event: Optional event to cancel (throws CancelledException).

__repr__()[source]
ykman.pcsc.YK_READER_NAME = 'yubico yubikey'
class ykman.pcsc.ScardSmartCardConnection(connection)[source]

Bases: yubikit.core.smartcard.SmartCardConnection

A connection to a YubiKey

connection
property transport

Get the transport type of the connection (USB or NFC)

close()[source]

Close the device, releasing any held resources.

send_and_receive(apdu)[source]

Sends a command APDU and returns the response data and sw

class ykman.pcsc.ScardYubiKeyDevice(reader)[source]

Bases: ykman.base.YkmanDevice

YubiKey Smart card device

reader
supports_connection(connection_type)[source]

Check if a YubiKeyDevice supports a specific Connection type

open_connection(connection_type)[source]

Opens a connection to the YubiKey

ykman.pcsc.kill_scdaemon()[source]
ykman.pcsc.kill_yubikey_agent()[source]
ykman.pcsc.list_readers()[source]
ykman.pcsc.list_devices(name_filter=None)[source]