-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81d067e
commit 4fa7307
Showing
20 changed files
with
1,027 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*.pyc | ||
_build | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
API Reference | ||
============= | ||
|
||
.. automodule:: nitrokey | ||
|
||
.. rubric:: Modules | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
nitrokey.nk3 | ||
nitrokey.nkpk | ||
nitrokey.trussed | ||
nitrokey.updates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
nitrokey.nk3 | ||
============ | ||
|
||
.. automodule:: nitrokey.nk3 | ||
|
||
.. rubric:: Submodules | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
nitrokey.nk3.secrets_app | ||
nitrokey.nk3.updates | ||
|
||
Accessing Nitrokey 3 Devices | ||
---------------------------- | ||
|
||
.. autofunction:: nitrokey.nk3.list | ||
|
||
.. autofunction:: nitrokey.nk3.open | ||
|
||
Nitrokey 3 Objects | ||
------------------ | ||
|
||
.. autoclass:: nitrokey.nk3.NK3 | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: nitrokey.nk3.NK3Bootloader | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
nitrokey.nk3.secrets\_app | ||
========================= | ||
|
||
.. automodule:: nitrokey.nk3.secrets_app | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
nitrokey.nk3.updates | ||
==================== | ||
|
||
.. automodule:: nitrokey.nk3.updates | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
nitrokey.nkpk | ||
============= | ||
|
||
.. automodule:: nitrokey.nkpk | ||
|
||
Accessing Nitrokey Passkey Devices | ||
---------------------------------- | ||
|
||
.. autofunction:: nitrokey.nkpk.list | ||
|
||
.. autofunction:: nitrokey.nkpk.open | ||
|
||
Nitrokey Passkey Objects | ||
------------------------ | ||
|
||
.. autoclass:: nitrokey.nkpk.NKPK | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: nitrokey.nkpk.NKPKBootloader | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
nitrokey.trussed.admin\_app | ||
=========================== | ||
|
||
.. automodule:: nitrokey.trussed.admin_app | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
nitrokey.trussed.provisioner\_app | ||
================================= | ||
|
||
.. automodule:: nitrokey.trussed.provisioner_app | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
nitrokey.trussed | ||
================ | ||
|
||
.. automodule:: nitrokey.trussed | ||
|
||
.. rubric:: Submodules | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
nitrokey.trussed.admin_app | ||
nitrokey.trussed.provisioner_app | ||
|
||
Trussed Device Objects | ||
---------------------- | ||
|
||
.. autoclass:: nitrokey.trussed.TrussedBase | ||
:members: | ||
:undoc-members: | ||
|
||
.. autoclass:: nitrokey.trussed.TrussedDevice | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: nitrokey.trussed.TrussedBootloader | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Update Container Objects | ||
------------------------ | ||
|
||
.. autofunction:: nitrokey.trussed.parse_firmware_image | ||
|
||
.. autoclass:: nitrokey.trussed.FirmwareContainer | ||
:members: | ||
:undoc-members: | ||
|
||
.. autoclass:: nitrokey.trussed.FirmwareMetadata | ||
:members: | ||
:undoc-members: | ||
|
||
.. autoclass:: nitrokey.trussed.Variant | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Utility Objects | ||
--------------- | ||
|
||
.. autoclass:: nitrokey.trussed.App | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: nitrokey.trussed.Fido2Certs | ||
:members: | ||
:undoc-members: | ||
|
||
.. autoclass:: nitrokey.trussed.Model | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: nitrokey.trussed.Uuid | ||
:members: | ||
:undoc-members: | ||
|
||
.. autoclass:: nitrokey.trussed.Version | ||
:members: | ||
:undoc-members: | ||
|
||
Trussed Exceptions | ||
------------------ | ||
|
||
.. autoclass:: nitrokey.trussed.TrussedException | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: nitrokey.trussed.TimeoutException | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
nitrokey.updates | ||
================ | ||
|
||
.. automodule:: nitrokey.updates | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
project = 'Nitrokey Python SDK' | ||
copyright = '2024, Nitrokey' | ||
author = 'Nitrokey' | ||
release = '0.1.0' | ||
extensions = [ | ||
'sphinx.ext.autodoc', | ||
] | ||
html_theme = 'alabaster' | ||
autodoc_class_signature = 'separated' | ||
autodoc_member_order = 'groupwise' | ||
autodoc_typehints = 'description' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Guides | ||
====== | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
Usage Guide | ||
=========== | ||
|
||
.. contents:: :local: | ||
|
||
The Nitrokey Python SDK currently supports Nitrokey 3 (:py:class:`nitrokey.nk3.NK3`) and Nitrokey Passkey (:py:class:`nitrokey.nkpk.NKPK`) devices. | ||
Both devices are based on the same platform, Trussed, and therefore share the same base class :py: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 :py:class:`nitrokey.nk3.NK3Bootloader` and :py:class:`nitrokey.nkpk.NKPKBootloader` (base class :py:class:`nitrokey.trussed.TrussedBootloader`). | ||
|
||
Listing and Opening Devices | ||
--------------------------- | ||
|
||
Use the :py:meth:`nitrokey.trussed.TrussedDevice.list` function to list and open all connected devices:: | ||
|
||
from nitrokey.nk3 import NK3 | ||
from nitrokey.nkpk import NKPK | ||
|
||
print("Connected Nitrokey devices:") | ||
for device in NK3.list(): | ||
print(f"- {device.name} at {device.path}") | ||
for device in NKPK.list(): | ||
print(f"- {device.name} at {device.path}") | ||
|
||
If you know the device path, use :py:meth:`nitrokey.trussed.TrussedDevice.open` instead:: | ||
|
||
from nitrokey.nk3 import NK3 | ||
from nitrokey.nkpk import NKPK | ||
|
||
path = "/dev/hidraw1" | ||
device = NK3.open(path) | ||
if device is not None: | ||
print(f"Found {device.name} at {path}") | ||
device = NKPK.open(path) | ||
if device is not None: | ||
print(f"Found {device.name} at {path}") | ||
|
||
Similar functions are available for :py:class:`nitrokey.nk3.NK3Bootloader` and :py:class:`nitrokey.nkpk.NKPKBootloader`. | ||
To list both normal and bootloader devices, use :py:meth:`nitrokey.nk3.list` and :py:meth:`nitrokey.nkpk.list`. | ||
|
||
.. note:: | ||
Currently, the devices returned by :py:meth:`nitrokey.trussed.TrussedDevice.list`, :py:meth:`nitrokey.nk3.list` and :py:meth:`nitrokey.nkpk.list` are only valid until the next call to any of the these functions. | ||
See `issue 31 <https://github.com/Nitrokey/nitrokey-sdk-py/issues/31>`_ for more information. | ||
|
||
Using Applications | ||
------------------ | ||
|
||
The Nitrokey Python SDK supports these applications for all Trussed devices: | ||
|
||
* :py:class:`nitrokey.trussed.admin_app.AdminApp`: access device metadata and manage device configuration state | ||
* :py:class:`nitrokey.trussed.provisioner_app.ProvisionerApp`: setup device in provisioner mode (only applicable for Hacker devices) | ||
|
||
The Nitrokey 3 also provides these applications: | ||
|
||
* :py:class:`nitrokey.nk3.secrets_app.SecretsApp`: securely store passwords and credentials | ||
|
||
See the API reference for the application classes for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Nitrokey Python SDK | ||
=================== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
guides/index | ||
api/index |
Oops, something went wrong.