nitrokey 0.4.2__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nitrokey-0.4.2 → nitrokey-0.5.0}/PKG-INFO +13 -12
- {nitrokey-0.4.2 → nitrokey-0.5.0}/README.md +8 -8
- {nitrokey-0.4.2 → nitrokey-0.5.0}/pyproject.toml +43 -20
- nitrokey-0.5.0/src/nitrokey/checksum.py +76 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/nk3/__init__.py +7 -4
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/nk3/_bootloader.py +8 -1
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/nk3/_device.py +20 -11
- nitrokey-0.5.0/src/nitrokey/nk3/credential_exchange_format.py +412 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/nk3/secrets_app.py +261 -70
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/nkpk.py +27 -14
- nitrokey-0.5.0/src/nitrokey/trussed/__init__.py +96 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_base.py +26 -3
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/__init__.py +13 -28
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55.py +47 -18
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/crypto/certificate.py +6 -20
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/crypto/hash.py +3 -9
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/crypto/keys.py +5 -19
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/crypto/symmetric.py +1 -2
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/crypto/types.py +2 -5
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/exceptions.py +1 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/mboot/commands.py +1 -3
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/mboot/mcuboot.py +50 -165
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/mboot/memories.py +6 -20
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/mboot/properties.py +37 -95
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/mboot/protocol/base.py +1 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/mboot/protocol/bulk_protocol.py +1 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/sbfile/misc.py +2 -4
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/sbfile/sb2/commands.py +37 -81
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/sbfile/sb2/headers.py +3 -8
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/sbfile/sb2/images.py +2 -12
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/sbfile/sb2/sections.py +5 -23
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/crypto/cert_blocks.py +16 -37
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/crypto/rkht.py +3 -9
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/exceptions.py +1 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/interfaces/commands.py +1 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/interfaces/device/base.py +3 -5
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/interfaces/device/usb_device.py +6 -15
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/interfaces/protocol/protocol_base.py +3 -5
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/misc.py +6 -9
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/spsdk_enum.py +7 -13
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52.py +21 -28
- nitrokey-0.5.0/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/dfu.py +156 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/dfu_cc_pb2.py +1 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/dfu_cc_pb2.pyi +2 -6
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/dfu_transport.py +1 -3
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/dfu_transport_serial.py +27 -63
- nitrokey-0.5.0/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/ihex_parser.py +65 -0
- nitrokey-0.5.0/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/init_packet_pb.py +192 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/manifest.py +85 -7
- nitrokey-0.5.0/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/nrfhex.py +127 -0
- nitrokey-0.5.0/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/package.py +702 -0
- nitrokey-0.5.0/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/signing.py +251 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/lister/enumerated_device.py +2 -4
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/lister/unix/unix_lister.py +1 -1
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/lister/windows/constants.py +5 -7
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/lister/windows/lister_win32.py +11 -21
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/lister/windows/structures.py +12 -20
- nitrokey-0.5.0/src/nitrokey/trussed/_connection/__init__.py +86 -0
- nitrokey-0.5.0/src/nitrokey/trussed/_connection/ccid.py +160 -0
- nitrokey-0.5.0/src/nitrokey/trussed/_connection/ctaphid.py +100 -0
- nitrokey-0.5.0/src/nitrokey/trussed/_device.py +140 -0
- nitrokey-0.5.0/src/nitrokey/trussed/_exceptions.py +70 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_utils.py +77 -5
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/admin_app.py +53 -53
- nitrokey-0.5.0/src/nitrokey/trussed/nrfutils.py +97 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/provisioner_app.py +4 -9
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/updates.py +29 -73
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/updates.py +14 -14
- nitrokey-0.4.2/src/nitrokey/trussed/__init__.py +0 -63
- nitrokey-0.4.2/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/init_packet_pb.py +0 -92
- nitrokey-0.4.2/src/nitrokey/trussed/_device.py +0 -137
- nitrokey-0.4.2/src/nitrokey/trussed/_exceptions.py +0 -15
- {nitrokey-0.4.2 → nitrokey-0.5.0}/LICENSES/Apache-2.0.txt +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/LICENSES/MIT.txt +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/_helpers.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/py.typed +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/README.md +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/crypto/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/crypto/hmac.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/mboot/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/mboot/error_codes.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/mboot/exceptions.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/mboot/interfaces/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/mboot/interfaces/usb.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/mboot/protocol/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/sbfile/sb2/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/abstract.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/crypto/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/interfaces/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/interfaces/device/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/lpc55_upload/utils/interfaces/protocol/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/README.md +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/dfu/dfu-cc.proto +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/exceptions.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/lister/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/lister/device_lister.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/lister/lister_backend.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/lister/unix/__init__.py +0 -0
- {nitrokey-0.4.2 → nitrokey-0.5.0}/src/nitrokey/trussed/_bootloader/nrf52_upload/lister/windows/__init__.py +0 -0
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nitrokey
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Nitrokey Python SDK
|
|
5
5
|
License-Expression: Apache-2.0 OR MIT
|
|
6
6
|
License-File: LICENSES/Apache-2.0.txt
|
|
7
7
|
License-File: LICENSES/MIT.txt
|
|
8
8
|
Author: Nitrokey
|
|
9
9
|
Author-email: pypi@nitrokey.com
|
|
10
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.11, <4
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Provides-Extra: ccid
|
|
18
18
|
Requires-Dist: crcmod (>=1.7,<2)
|
|
19
19
|
Requires-Dist: cryptography (>=41)
|
|
20
|
-
Requires-Dist: fido2 (>=
|
|
20
|
+
Requires-Dist: fido2 (>=2,<3)
|
|
21
21
|
Requires-Dist: hidapi (>=0.14,<0.15)
|
|
22
22
|
Requires-Dist: protobuf (>=5.26,<7)
|
|
23
|
+
Requires-Dist: pyscard (>=2,<3) ; extra == "ccid"
|
|
23
24
|
Requires-Dist: pyserial (>=3.5,<4)
|
|
24
25
|
Requires-Dist: requests (>=2.16,<3)
|
|
25
26
|
Requires-Dist: semver (>=3,<4)
|
|
@@ -74,7 +75,7 @@ for device in nitrokey.trussed.list():
|
|
|
74
75
|
|
|
75
76
|
## Compatibility
|
|
76
77
|
|
|
77
|
-
The Nitrokey Python SDK currently requires Python 3.
|
|
78
|
+
The Nitrokey Python SDK currently requires Python 3.11 or later.
|
|
78
79
|
Support for old Python versions may be dropped in minor releases.
|
|
79
80
|
|
|
80
81
|
## Related Projects
|
|
@@ -90,7 +91,7 @@ Support for old Python versions may be dropped in minor releases.
|
|
|
90
91
|
|
|
91
92
|
The following software is required for the development of the SDK:
|
|
92
93
|
|
|
93
|
-
- Python 3.
|
|
94
|
+
- Python 3.11 or newer
|
|
94
95
|
- [poetry](https://python-poetry.org/)
|
|
95
96
|
- GNU Make
|
|
96
97
|
- git
|
|
@@ -129,12 +130,12 @@ Releases are published using Github Actions.
|
|
|
129
130
|
To create a new release:
|
|
130
131
|
1. Update the `version` field in `pyproject.toml` manually or using `poetry version`.
|
|
131
132
|
2. Update the [changelog](./CHANGELOG.md) for the release.
|
|
132
|
-
3.
|
|
133
|
-
4.
|
|
134
|
-
5.
|
|
135
|
-
6. Create a
|
|
136
|
-
7.
|
|
137
|
-
8.
|
|
133
|
+
3. Commit these changes, create a PR and merge into `main`.
|
|
134
|
+
4. [Trigger the `full.yaml` workflow](https://github.com/Nitrokey/nitrokey-sdk-py/actions/workflows/full.yaml) for the release branch to run the full compatibility tests.
|
|
135
|
+
5. Create a signed tag with the version number and a `v` prefix, for example `v0.2.4`, and push it to this repository.
|
|
136
|
+
6. [Create a new release](https://github.com/Nitrokey/nitrokey-sdk-py/releases/new) for this tag and copy the relevant parts from the [changelog](./CHANGELOG.md) to the release description.
|
|
137
|
+
7. Wait for the deployment action to run and approve the deployment to [PyPI](https://pypi.org/p/nitrokey).
|
|
138
|
+
8. Update the `NITROKEY_SDK_PY_VERSION` and `NITROKEY_SDK_PY_CHECKSUM` variables in the `Makefile` of the [nitrokey-documentation](https://github.com/nitrokey/nitrokey-documentation) repository to update the documentation on docs.nitrokey.com.
|
|
138
139
|
|
|
139
140
|
All commits to `main` are automatically deployed to [TestPyPI](https://test.pypi.org/p/nitrokey).
|
|
140
141
|
It is also possible to publish release candidates (pre-releases) with a suffix like `-rc.1`.
|
|
@@ -45,7 +45,7 @@ for device in nitrokey.trussed.list():
|
|
|
45
45
|
|
|
46
46
|
## Compatibility
|
|
47
47
|
|
|
48
|
-
The Nitrokey Python SDK currently requires Python 3.
|
|
48
|
+
The Nitrokey Python SDK currently requires Python 3.11 or later.
|
|
49
49
|
Support for old Python versions may be dropped in minor releases.
|
|
50
50
|
|
|
51
51
|
## Related Projects
|
|
@@ -61,7 +61,7 @@ Support for old Python versions may be dropped in minor releases.
|
|
|
61
61
|
|
|
62
62
|
The following software is required for the development of the SDK:
|
|
63
63
|
|
|
64
|
-
- Python 3.
|
|
64
|
+
- Python 3.11 or newer
|
|
65
65
|
- [poetry](https://python-poetry.org/)
|
|
66
66
|
- GNU Make
|
|
67
67
|
- git
|
|
@@ -100,12 +100,12 @@ Releases are published using Github Actions.
|
|
|
100
100
|
To create a new release:
|
|
101
101
|
1. Update the `version` field in `pyproject.toml` manually or using `poetry version`.
|
|
102
102
|
2. Update the [changelog](./CHANGELOG.md) for the release.
|
|
103
|
-
3.
|
|
104
|
-
4.
|
|
105
|
-
5.
|
|
106
|
-
6. Create a
|
|
107
|
-
7.
|
|
108
|
-
8.
|
|
103
|
+
3. Commit these changes, create a PR and merge into `main`.
|
|
104
|
+
4. [Trigger the `full.yaml` workflow](https://github.com/Nitrokey/nitrokey-sdk-py/actions/workflows/full.yaml) for the release branch to run the full compatibility tests.
|
|
105
|
+
5. Create a signed tag with the version number and a `v` prefix, for example `v0.2.4`, and push it to this repository.
|
|
106
|
+
6. [Create a new release](https://github.com/Nitrokey/nitrokey-sdk-py/releases/new) for this tag and copy the relevant parts from the [changelog](./CHANGELOG.md) to the release description.
|
|
107
|
+
7. Wait for the deployment action to run and approve the deployment to [PyPI](https://pypi.org/p/nitrokey).
|
|
108
|
+
8. Update the `NITROKEY_SDK_PY_VERSION` and `NITROKEY_SDK_PY_CHECKSUM` variables in the `Makefile` of the [nitrokey-documentation](https://github.com/nitrokey/nitrokey-documentation) repository to update the documentation on docs.nitrokey.com.
|
|
109
109
|
|
|
110
110
|
All commits to `main` are automatically deployed to [TestPyPI](https://test.pypi.org/p/nitrokey).
|
|
111
111
|
It is also possible to publish release candidates (pre-releases) with a suffix like `-rc.1`.
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "nitrokey"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.5.0"
|
|
8
8
|
description = "Nitrokey Python SDK"
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "Nitrokey", email = "pypi@nitrokey.com" },
|
|
@@ -14,12 +14,12 @@ readme = "README.md"
|
|
|
14
14
|
packages = [
|
|
15
15
|
{ include = "nitrokey", from = "src" },
|
|
16
16
|
]
|
|
17
|
-
requires-python = ">=3.
|
|
17
|
+
requires-python = ">=3.11, <4"
|
|
18
18
|
dynamic = ["classifiers"]
|
|
19
19
|
|
|
20
20
|
dependencies = [
|
|
21
21
|
"cryptography >=41",
|
|
22
|
-
"fido2 >=
|
|
22
|
+
"fido2 >=2, <3",
|
|
23
23
|
"requests >=2.16, <3",
|
|
24
24
|
"semver >=3, <4",
|
|
25
25
|
"tlv8 >=0.10, <0.11",
|
|
@@ -41,26 +41,30 @@ classifiers = [
|
|
|
41
41
|
"Intended Audience :: Developers",
|
|
42
42
|
]
|
|
43
43
|
|
|
44
|
+
[project.optional-dependencies]
|
|
45
|
+
ccid = ["pyscard >=2, <3"]
|
|
46
|
+
|
|
44
47
|
[tool.poetry.group.dev]
|
|
45
48
|
optional = true
|
|
46
49
|
|
|
47
50
|
[tool.poetry.group.dev.dependencies]
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
flake8 = "^7.1"
|
|
51
|
-
isort = "^5.13.2"
|
|
52
|
-
mypy = "^1.4"
|
|
51
|
+
fake-winreg = "^1.9"
|
|
52
|
+
mypy = "^1.20"
|
|
53
53
|
rstcheck = { version = "^6", extras = ["sphinx"] }
|
|
54
|
+
ruff = "^0.14"
|
|
54
55
|
sphinx = "^7"
|
|
56
|
+
ty = "^0.0.29"
|
|
55
57
|
types-protobuf = ">=5.26, <7"
|
|
56
58
|
types-requests = "^2.16"
|
|
57
|
-
|
|
59
|
+
# fake-winreg does not work with wrapt v2 so we need to add an additional upper bound
|
|
60
|
+
wrapt = "<2"
|
|
58
61
|
|
|
59
62
|
[tool.uv]
|
|
60
63
|
dev-dependencies = [
|
|
61
64
|
# These dependencies are required for running the type checks.
|
|
62
|
-
"fake-winreg >=1.
|
|
63
|
-
"mypy >=1.
|
|
65
|
+
"fake-winreg >=1.9, <2",
|
|
66
|
+
"mypy >=1.20, <2",
|
|
67
|
+
"ty >=0.0.29, <0.0.30",
|
|
64
68
|
"types-protobuf >=5.26, <7",
|
|
65
69
|
"types-requests >=2.16, <3",
|
|
66
70
|
|
|
@@ -73,20 +77,39 @@ dev-dependencies = [
|
|
|
73
77
|
# fake-winreg does not work with wrapt v2 so we need to add an additional upper bound
|
|
74
78
|
"wrapt <2",
|
|
75
79
|
]
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
[tool.isort]
|
|
81
|
-
py_version = "310"
|
|
82
|
-
profile = "black"
|
|
80
|
+
exclude-newer = "7 days"
|
|
81
|
+
# Can be used to update packages to a version more recent what exclude-newer allows
|
|
82
|
+
exclude-newer-package = { }
|
|
83
83
|
|
|
84
84
|
[tool.mypy]
|
|
85
85
|
mypy_path = "stubs"
|
|
86
86
|
show_error_codes = true
|
|
87
|
-
python_version = "3.
|
|
87
|
+
python_version = "3.11"
|
|
88
88
|
strict = true
|
|
89
89
|
|
|
90
90
|
[tool.rstcheck]
|
|
91
|
-
ignore_directives = ["autoclass", "autofunction", "automodule"]
|
|
91
|
+
ignore_directives = ["autoclass", "autodata", "autofunction", "automodule"]
|
|
92
92
|
ignore_substitutions = ["nitrokey_sdk_version"]
|
|
93
|
+
|
|
94
|
+
[tool.ruff]
|
|
95
|
+
line-length = 100
|
|
96
|
+
|
|
97
|
+
[tool.ruff.format]
|
|
98
|
+
skip-magic-trailing-comma = true
|
|
99
|
+
|
|
100
|
+
[tool.ruff.lint]
|
|
101
|
+
select = ["ANN", "B", "C", "E", "F", "W", "I", "RUF100"]
|
|
102
|
+
ignore = ["ANN401", "E501"]
|
|
103
|
+
|
|
104
|
+
[tool.ruff.lint.isort]
|
|
105
|
+
split-on-trailing-comma = false
|
|
106
|
+
|
|
107
|
+
[tool.ruff.lint.mccabe]
|
|
108
|
+
max-complexity = 30
|
|
109
|
+
|
|
110
|
+
[tool.ty.environment]
|
|
111
|
+
extra-paths = ["stubs"]
|
|
112
|
+
|
|
113
|
+
[tool.ty.rules]
|
|
114
|
+
# some type: ignore comments are only needed for mypy so ty should not report them as unused
|
|
115
|
+
unused-type-ignore-comment = "ignore"
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
import io
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class _FileEndings(str, Enum):
|
|
7
|
+
IHEX = ".ihex"
|
|
8
|
+
BIN = ".bin"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class FirmwareChecksum:
|
|
12
|
+
def __init__(self, name: str, content: bytes) -> None:
|
|
13
|
+
self.name = name.lower()
|
|
14
|
+
self.content = content
|
|
15
|
+
|
|
16
|
+
def _hash_ihex(self, ihex_content: bytes) -> bytes:
|
|
17
|
+
segments = [] # list of (address, bytes)
|
|
18
|
+
base_addr = 0
|
|
19
|
+
|
|
20
|
+
with io.StringIO(ihex_content.decode()) as f:
|
|
21
|
+
for lineno, line in enumerate(f, 1):
|
|
22
|
+
line = line.strip()
|
|
23
|
+
if not line:
|
|
24
|
+
continue
|
|
25
|
+
if line[0] != ":":
|
|
26
|
+
raise ValueError(f"Line {lineno}: missing ':' start code")
|
|
27
|
+
|
|
28
|
+
raw = bytes.fromhex(line[1:])
|
|
29
|
+
byte_count = raw[0]
|
|
30
|
+
addr = int.from_bytes(raw[1:3], "big")
|
|
31
|
+
rec_type = raw[3]
|
|
32
|
+
data = raw[4 : 4 + byte_count]
|
|
33
|
+
checksum = raw[4 + byte_count]
|
|
34
|
+
|
|
35
|
+
calc = (-(sum(raw[: 4 + byte_count]))) & 0xFF
|
|
36
|
+
if calc != checksum:
|
|
37
|
+
raise ValueError(
|
|
38
|
+
f"Line {lineno}: bad checksum (got {checksum:02X}, expected {calc:02X})"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
if rec_type == 0x00: # data
|
|
42
|
+
segments.append((base_addr + addr, data))
|
|
43
|
+
elif rec_type == 0x01: # EOF
|
|
44
|
+
break
|
|
45
|
+
elif rec_type == 0x02: # EAS
|
|
46
|
+
seg_val = int.from_bytes(data, "big")
|
|
47
|
+
base_addr = seg_val << 4
|
|
48
|
+
else:
|
|
49
|
+
raise ValueError(f"Line {lineno}: unknown record type {rec_type:02X}")
|
|
50
|
+
|
|
51
|
+
if not segments:
|
|
52
|
+
return hashlib.sha256(b"").digest()
|
|
53
|
+
|
|
54
|
+
min_addr = min(addr for addr, _ in segments)
|
|
55
|
+
max_addr = max(addr + len(d) for addr, d in segments)
|
|
56
|
+
|
|
57
|
+
out = bytearray(b"\xff" * (max_addr - min_addr))
|
|
58
|
+
for addr, d in segments:
|
|
59
|
+
start = addr - min_addr
|
|
60
|
+
out[start : start + len(d)] = d
|
|
61
|
+
|
|
62
|
+
return self._hash_bin(out)
|
|
63
|
+
|
|
64
|
+
def _hash_bin(self, bin_content: bytes | bytearray) -> bytes:
|
|
65
|
+
return hashlib.sha256(bin_content).digest()
|
|
66
|
+
|
|
67
|
+
def calculate_checksum(self) -> bytes:
|
|
68
|
+
""".bin firmwares are using with the NRF52 chipsets while .ihex is used with LPC55.
|
|
69
|
+
For NRF52 firmware, the checksum is made by a direct cryptographic hash over the file.
|
|
70
|
+
For LPC55 firmware, the metadata and certificate block is ignored during checksum calculation"""
|
|
71
|
+
if self.name.endswith(_FileEndings.IHEX):
|
|
72
|
+
return self._hash_ihex(self.content)
|
|
73
|
+
elif self.name.endswith(_FileEndings.BIN):
|
|
74
|
+
return self._hash_bin(self.content)
|
|
75
|
+
|
|
76
|
+
raise ValueError("Invalid file ending for firmware")
|
|
@@ -9,9 +9,10 @@ from typing import List, Optional, Union
|
|
|
9
9
|
|
|
10
10
|
from nitrokey.trussed._bootloader import ModelData
|
|
11
11
|
from nitrokey.trussed._bootloader.nrf52 import SignatureKey
|
|
12
|
+
from nitrokey.trussed._connection import Transport
|
|
12
13
|
|
|
13
|
-
from ._bootloader import NK3Bootloader as NK3Bootloader
|
|
14
|
-
from ._device import NK3 as NK3
|
|
14
|
+
from ._bootloader import NK3Bootloader as NK3Bootloader
|
|
15
|
+
from ._device import NK3 as NK3
|
|
15
16
|
|
|
16
17
|
_PID_NK3_DEVICE = 0x42B2
|
|
17
18
|
_PID_NK3_LPC55_BOOTLOADER = 0x42DD
|
|
@@ -35,10 +36,12 @@ _NK3_DATA = ModelData(
|
|
|
35
36
|
)
|
|
36
37
|
|
|
37
38
|
|
|
38
|
-
def list(
|
|
39
|
+
def list(
|
|
40
|
+
transport: Transport | None = None, exclusive: bool = True
|
|
41
|
+
) -> List[Union[NK3, NK3Bootloader]]:
|
|
39
42
|
devices: List[Union[NK3, NK3Bootloader]] = []
|
|
40
43
|
devices.extend(NK3Bootloader.list())
|
|
41
|
-
devices.extend(NK3.list())
|
|
44
|
+
devices.extend(NK3.list(transport=transport, exclusive=exclusive))
|
|
42
45
|
return devices
|
|
43
46
|
|
|
44
47
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# http://opensource.org/licenses/MIT>, at your option. This file may not be
|
|
6
6
|
# copied, modified, or distributed except according to those terms.
|
|
7
7
|
|
|
8
|
-
from typing import List, Optional, Sequence
|
|
8
|
+
from typing import TYPE_CHECKING, List, Optional, Sequence
|
|
9
9
|
|
|
10
10
|
from nitrokey import _VID_NITROKEY
|
|
11
11
|
from nitrokey.trussed._base import Model
|
|
@@ -85,3 +85,10 @@ class NK3BootloaderNrf52(TrussedBootloaderNrf52, NK3Bootloader):
|
|
|
85
85
|
from . import _NK3_DATA
|
|
86
86
|
|
|
87
87
|
return _NK3_DATA.nrf52_signature_keys
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
if TYPE_CHECKING:
|
|
91
|
+
from contextlib import AbstractContextManager
|
|
92
|
+
|
|
93
|
+
_ACM_NRF52: type[AbstractContextManager[NK3BootloaderNrf52]] = NK3BootloaderNrf52
|
|
94
|
+
_ACM_LPC55: type[AbstractContextManager[NK3BootloaderLpc55]] = NK3BootloaderLpc55
|
|
@@ -5,19 +5,16 @@
|
|
|
5
5
|
# http://opensource.org/licenses/MIT>, at your option. This file may not be
|
|
6
6
|
# copied, modified, or distributed except according to those terms.
|
|
7
7
|
|
|
8
|
-
from typing import List
|
|
9
|
-
|
|
10
|
-
from fido2.hid import CtapHidDevice
|
|
8
|
+
from typing import TYPE_CHECKING, List
|
|
11
9
|
|
|
12
10
|
from nitrokey import _VID_NITROKEY
|
|
13
11
|
from nitrokey.trussed import Fido2Certs, Model, TrussedDevice, Version
|
|
12
|
+
from nitrokey.trussed._connection import Connection
|
|
14
13
|
|
|
15
14
|
FIDO2_CERTS = [
|
|
16
15
|
Fido2Certs(
|
|
17
16
|
start=Version(0, 1, 0),
|
|
18
|
-
hashes=[
|
|
19
|
-
"ad8fd1d16f59104b9e06ef323cc03f777ed5303cd421a101c9cb00bb3fdf722d",
|
|
20
|
-
],
|
|
17
|
+
hashes=["ad8fd1d16f59104b9e06ef323cc03f777ed5303cd421a101c9cb00bb3fdf722d"],
|
|
21
18
|
),
|
|
22
19
|
Fido2Certs(
|
|
23
20
|
start=Version(1, 0, 3),
|
|
@@ -33,8 +30,8 @@ FIDO2_CERTS = [
|
|
|
33
30
|
class NK3(TrussedDevice):
|
|
34
31
|
"""A Nitrokey 3 device running the firmware."""
|
|
35
32
|
|
|
36
|
-
def __init__(self,
|
|
37
|
-
super().__init__(
|
|
33
|
+
def __init__(self, connection: Connection) -> None:
|
|
34
|
+
super().__init__(connection, FIDO2_CERTS)
|
|
38
35
|
|
|
39
36
|
@property
|
|
40
37
|
def model(self) -> Model:
|
|
@@ -51,11 +48,23 @@ class NK3(TrussedDevice):
|
|
|
51
48
|
return "Nitrokey 3"
|
|
52
49
|
|
|
53
50
|
@classmethod
|
|
54
|
-
def
|
|
55
|
-
return cls(
|
|
51
|
+
def from_connection(cls, connection: Connection) -> "NK3":
|
|
52
|
+
return cls(connection)
|
|
56
53
|
|
|
57
54
|
@classmethod
|
|
58
|
-
def
|
|
55
|
+
def list_ctaphid(cls) -> List["NK3"]:
|
|
59
56
|
from . import _PID_NK3_DEVICE
|
|
60
57
|
|
|
61
58
|
return cls._list_vid_pid(_VID_NITROKEY, _PID_NK3_DEVICE)
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def list_ccid(cls, exclusive: bool = True) -> List["NK3"]:
|
|
62
|
+
return cls._list_pcsc_atr(
|
|
63
|
+
list(bytes.fromhex("3B8F01805D4E6974726F6B657900000000006A")), exclusive
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if TYPE_CHECKING:
|
|
68
|
+
from contextlib import AbstractContextManager
|
|
69
|
+
|
|
70
|
+
_: type[AbstractContextManager[NK3]] = NK3
|