Python Library for Nitrokey FIDO2 & Nitrokey Start.
Project description
pynitrokey
A command line interface for the Nitrokey FIDO2, Nitrokey Start, Nitrokey 3 and NetHSM.
Current state
Update to the latest firmware versions on the Nitrokey Start and Nitrokey FIDO2 devices was tested. Windows support for Nitrokey Start is not added yet.
Additional features:
- handle
status
command for displaying touch button status (2.0.0 firmware and later); - firmware signing adjusted for Nitrokey FIDO2 bootloader
- monitor command with timestamps
Installation
Linux, Unix
sudo apt install python3-pip
pip3 install --user pynitrokey
To access Nitrokey Start and FIDO2 devices without superuser rights, you need to install the Nitrokey udev rules that are shipped with libnitrokey
. You can also install them manually:
wget https://raw.githubusercontent.com/Nitrokey/libnitrokey/master/data/41-nitrokey.rules
sudo mv 41-nitrokey.rules /etc/udev/rules.d/
Windows
Generally Windows support and the installer are experimental - please use with caution.
Known issues:
- Support for Nitrokey Start under Windows 10 is not working without installing libusb libraries (to be described).
- The installer does not remove a previous installation (manually remove it using
settings -> programs and apps
)
How to install:
- Download the latest
.msi
installer from releases - Double-click the installer and click through (
Next
andFinish
) - Open the command console in the administrator mode (Windows 10: press the right mouse button on the Menu Start and select "Windows PowerShell (Admin)" from the menu).
- Enter
nitropy
Without administrator privileges nitropy
might not be able to communicate to device.
MacOS
To install nitropy on MacOS
pip3 install pynitrokey
- Without
penv
:nitropy
can be found here:/usr/local/bin/nitropy
- With
penv
:/Users/[USER_NAME]/.pyenv/versions/[PYENV_NAME]/bin/nitropy
Make sure you have libnitrokey installed to connect Nitrokey Pro and Nitrokey Storage devices.
Nitrokey FIDO2
Firmware Update
Automatic firmware update is recommended via https://update.nitrokey.com. Alternatively, it is also possible to update the Nitrokey FIDO2 using:
nitropy fido2 update
Your Nitrokey FIDO2 is now updated to the latest firmware.
Nitrokey Start
Firmware Update
Verify device connection
nitropy start list
FSIJ-1.2.15-87042524: Nitrokey Nitrokey Start (RTM.10)
Start update process, logs saved to upgrade.log, handy in case of failure
nitropy start update
Does not ask for confirmation nor the default Admin PIN, handy for batch calls
nitropy start update -p 12345678 -y
Following will flash files from the local disk, instead of downloading them
nitropy start update --regnual $(FIRMWARE_DIR)/regnual.bin --gnuk ${FIRMWARE_DIR}/gnuk.bin
Switching ID
nitropy start set-identity [0,1,2]
Where 0, 1 and 2 are the available IDs.
Alternative MI switching method
pynitrokey
installation is not always possible, hence describing below alternative method to change the Identity on the Nitrokey Start. It suffices to have any CCID application installed, and send the following APDU 00 85 00 {ID}
(hex), where ID
is in range [0;2]
. After receiving this command Nitrokey Start will reboot with the selected identity.
Here is how to do it using GnuPG:
# Setting ID to 2
$ gpg-connect-agent --hex "scd apdu 00 85 00 02" /bye
ERR 65539 Unknown version in packet <Unspecified source>
# Alternative error messsage
ERR 65572 Bad certificate <Unspecified source>
The error message here is expected due to immediate reboot of the device, and with losing the connection.
When the ID change is attempted to be done immediately, the following response could be received:
ERR 100663406 Card removed <SCD>
To restore the communication, either kill the gpg-agent
or run gpg --card-status
again.
Tip: alternative gpg-connect-agent reloadagent /bye
is not sufficient.
NetHSM
A guide on how to use nitropy
to access a NetHSM is available on
docs.nitrokey.com.
Nitrokey 3
A guide on how to use nitropy
with Nitrokey 3 device is available on docs.nitrokey.com.
Development
Information for developers and contributors can be found in the Developer Guide.
Maintainers
Current maintainers can be found in MAINTAINERS.md file.
License
Licensed similarly to upstream, under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pynitrokey-0.4.18.tar.gz
.
File metadata
- Download URL: pynitrokey-0.4.18.tar.gz
- Upload date:
- Size: 176.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.27.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ebaccb357bce565487203c6adf62eb2c8a08b9247bc80438f21242f8617cc4a |
|
MD5 | a2fc039c748cdb662d537dcb7006372c |
|
BLAKE2b-256 | 0b508d149a7e8dba32acae882e627fd1d21765ba8106b83467bd3ef827c05183 |
File details
Details for the file pynitrokey-0.4.18-py3-none-any.whl
.
File metadata
- Download URL: pynitrokey-0.4.18-py3-none-any.whl
- Upload date:
- Size: 286.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.27.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26fcf38a5df2d6aefb19913608cbb7e2f848c64db9834e98ea618cce06497d5c |
|
MD5 | 8202ac15edb57b5da5a015f958046e90 |
|
BLAKE2b-256 | fb6f435864b57a6ddac0b35435dd68d94e0927c52560a84a8dad30a7fe79291a |