Nitrokey / pynitrokey

Python client for Nitrokey devices
Apache License 2.0
94 stars 28 forks source link

ImportError: cannot import name 'MbootUSBInterface' from 'spsdk.mboot.interfaces.usb' #521

Closed monogatron closed 2 months ago

monogatron commented 3 months ago

Before upgrading from python-pynitrokey v0.4.45-2 to v0.4.46-1 I got this error

$ nitropy list
Command line tool to interact with Nitrokey devices 0.4.45
:: 'Nitrokey FIDO2' keys
:: 'Nitrokey Start' keys:
:: 'Nitrokey 3' keys
Critical error:
An unhandled exception occurred
        Exception encountered: ModuleNotFoundError("No module named 'cryptography.hazmat.backends.openssl.rsa'")

which is related to this issue #512. Today I installed v0.4.46-1 which causes this error

$ nitropy list
Traceback (most recent call last):
  File "/usr/bin/nitropy", line 5, in <module>
    from pynitrokey.cli import main
  File "/usr/lib/python3.11/site-packages/pynitrokey/cli/__init__.py", line 26, in <module>
    from pynitrokey.cli.nk3 import nk3
  File "/usr/lib/python3.11/site-packages/pynitrokey/cli/nk3/__init__.py", line 20, in <module>
    from pynitrokey.nk3.bootloader import Nitrokey3Bootloader
  File "/usr/lib/python3.11/site-packages/pynitrokey/nk3/bootloader.py", line 14, in <module>
    from pynitrokey.trussed.bootloader.lpc55 import NitrokeyTrussedBootloaderLpc55
  File "/usr/lib/python3.11/site-packages/pynitrokey/trussed/bootloader/lpc55.py", line 17, in <module>
    from spsdk.mboot.interfaces.usb import MbootUSBInterface
ImportError: cannot import name 'MbootUSBInterface' from 'spsdk.mboot.interfaces.usb' (/usr/lib/python3.11/site-packages/spsdk/mboot/interfaces/usb.py)

I cannot even run nitropy at all. Whether with or with out any options I got the error mentioned above. Don't know if this is also related to #512 since it is complaining about something with spsdk too.

robin-nitrokey commented 3 months ago

@monogatron How did you install pynitrokey? What version of spsdk do you use? pynitrokey 0.4.46 requires spsdk 2.0 or newer. This error looks like you are still using an older spsdk version.

monogatron commented 3 months ago

Sorry, forgot to mention it: I'm using the "system version" which is provided by official arch repos. Same for spsdk...its version is atm v1.11.0. If this is the case, then it might be fixed soon. Accordingly to what dvzrv wrote in 512, the update comes around 27-03-24 (eta). EDIT: Even if pynitrokey actually requires spsdk the package python-pynitrokey was installable without --forcing it

robin-nitrokey commented 3 months ago

I see. As a workaround, you can also install pynitrokey via pipx or use the binary attached to the latest release until the spsdk package is updated in Arch.

pjhfggij commented 3 months ago

same issue. @monogatron has your u2f stopped working as well by any chance? I couldn't login at all on Monday with nitrokey 3a mini (although a backup nitrokey 3a works fine).

monogatron commented 3 months ago

I cannot really tell, since I'm only use the nk 3c for testing purpose until now. Didn't migrate from my yubikey yet.

monogatron commented 2 months ago

I close this issue since it's got resolved now with spsdk >= v2.0