Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace libusbsio with hidapi #35

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- Update `protobuf` dependency to 5.26
- Vendor `spsdk` dependency to reduce the total number of dependencies
- Replace `libusbsio` dependency with `hidapi`

## [v0.1.0](https://github.com/Nitrokey/nitrokey-sdk-py/releases/tag/v0.1.0) (2024-07-29)

Expand Down
110 changes: 98 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tlv8 = "^0.10"
# lpc55
crcmod = "^1.7"
cryptography = ">=42"
libusbsio = "^2.1"
hidapi = "^0.14"

# nrf52
ecdsa = "^0.19"
Expand Down Expand Up @@ -59,8 +59,3 @@ mypy_path = "stubs"
show_error_codes = true
python_version = "3.9"
strict = true

# libusbsio is used by lpc55_upload, will be replaced eventually
[[tool.mypy.overrides]]
module = ["libusbsio.*"]
ignore_missing_imports = true
7 changes: 2 additions & 5 deletions src/nitrokey/trussed/_bootloader/lpc55.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from .lpc55_upload.mboot.properties import PropertyTag
from .lpc55_upload.sbfile.sb2.images import BootImageV21
from .lpc55_upload.utils.interfaces.device.usb_device import UsbDevice
from .lpc55_upload.utils.usbfilter import USBDeviceFilter

RKTH = bytes.fromhex("050aad3e77791a81e59c5b2ba5a158937e9460ee325d8ccba09734b8fdebb171")
KEK = bytes([0xAA] * 32)
Expand Down Expand Up @@ -101,9 +100,8 @@ def update(

@classmethod
def _list_vid_pid(cls: type[T], vid: int, pid: int) -> list[T]:
device_filter = USBDeviceFilter(f"0x{vid:x}:0x{pid:x}")
devices = []
for device in UsbDevice.enumerate(device_filter):
for device in UsbDevice.enumerate(vid=vid, pid=pid):
try:
devices.append(cls(device))
except ValueError:
Expand All @@ -114,8 +112,7 @@ def _list_vid_pid(cls: type[T], vid: int, pid: int) -> list[T]:

@classmethod
def _open(cls: type[T], path: str) -> Optional[T]:
device_filter = USBDeviceFilter(path)
devices = UsbDevice.enumerate(device_filter)
devices = UsbDevice.enumerate(path=path)
if len(devices) == 0:
logger.warn(f"No HID device at {path}")
return None
Expand Down
Loading