Usage Guide

The Nitrokey Python SDK currently supports Nitrokey 3 (nitrokey.nk3.NK3) and Nitrokey Passkey (nitrokey.nkpk.NKPK) devices. Both devices are based on the same platform, Trussed, and therefore share the same base class nitrokey.trussed.TrussedDevice.

Trussed devices can be rebooted into a bootloader mode that is used to apply firmware updates. Devices in bootloader mode can be accessed using nitrokey.nk3.NK3Bootloader and nitrokey.nkpk.NKPKBootloader (base class nitrokey.trussed.TrussedBootloader).

Listing and Opening Devices

Use the nitrokey.trussed.list() function to list and open all connected devices:

import nitrokey.trussed

print("Connected Nitrokey devices:")
for device in nitrokey.trussed.list():
    print(f"- {device.name} at {device.path}")

If you know the device path, use nitrokey.trussed.open() instead:

import nitrokey.trussed

path = "/dev/hidraw1"
device = nitrokey.trussed.open(path)
if device is not None:
    print(f"Found {device.name} at {path}")
else:
    print(f"No device found at {path}")

If you know the model you want to connect to, you can also use the list and open functions in the nitrokey.nk3 or nitrokey.nkpk modules. If you also know the type of the device, you can use the list and open methods of the nitrokey.nk3.NK3, nitrokey.nkpk.NKPK, nitrokey.nk3.NK3Bootloader and nitrokey.nkpk.NKPKBootloader classes.

Using Applications

The Nitrokey Python SDK supports these applications for all Trussed devices:

The Nitrokey 3 also provides these applications:

See the API reference for the application classes for more information.