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

nitropy - invalid module error with latest python cryptography module #512

Closed
tcanabrava opened this issue Mar 20, 2024 · 23 comments
Closed

Comments

@tcanabrava
Copy link

Trying to update my nitrokey 3 firmware fails with:

command line tool to interact with Nitrokey devices 0.4.45
Critical error:
An unhandled exception occurred
        Exception encountered: ModuleNotFoundError("No module named 'cryptography.hazmat.backends.openssl.rsa'")

python-cryptography 42.0.5 installed, downgrading to 41 fixes the problem.

@sosthene-nitrokey sosthene-nitrokey transferred this issue from Nitrokey/nitrokey-3-firmware Mar 20, 2024
@sosthene-nitrokey
Copy link
Contributor

Thank you for reporting this issue. I can reproduce it. I will investigate.

I moved it to the proper repository.

@jans23
Copy link
Member

jans23 commented Mar 20, 2024

Do you really mean nitrocli or nitropy?

@sosthene-nitrokey
Copy link
Contributor

It's nitropy.

@sosthene-nitrokey sosthene-nitrokey changed the title nitrocli - invalid module error with latest python cryptography module nitropy - invalid module error with latest python cryptography module Mar 20, 2024
@robin-nitrokey
Copy link
Member

This is a duplicate of: #510

We depend on spsdk >=2.0,<2.1, which in turn depends on cryptography>=3.4.4,<41.1. How did you install pynitrokey? cryptography 42.0.5 should not be selected as a compatible dependency.

@sosthene-nitrokey
Copy link
Contributor

This appears to be an issue of the packaging on arch-linux.

@dvzrv
Copy link

dvzrv commented Mar 20, 2024

This appears to be an issue of the packaging on arch-linux.

We actually ignore the dependency declarations for spsdk, as there is not much else we can do as downstream. (also upstream pretty much ignores external contributors and I have given up on interacting with them)

In pynitrokey 0.4.45 the dependencies are still different though:

"cryptography >=41.0.4,<44",
"ecdsa",
"fido2 >=1.1.2,<2",
"intelhex",
"nkdfu",
"python-dateutil ~= 2.7.0",
"pyusb",
"requests",
"spsdk >=1.11.0,<1.12.0",

I don't see a way for us to block upgrades to cryptography on something like spsdk (there are dozens of other dependents).

@robin-nitrokey
Copy link
Member

I think this will be fixed by #499. @dvzrv Can you check if installing from the current master branch fixes the problem?

@sosthene-nitrokey
Copy link
Contributor

spsdk 2.1 still has a requirement of cryptography <= 41

@sosthene-nitrokey
Copy link
Contributor

Despite that it still seems to work for spsdk 2.1 and cryptography 42.0.5

@sosthene-nitrokey
Copy link
Contributor

sosthene-nitrokey commented Mar 20, 2024

The way forward seems to be: make a new release of nitropy.

Then for the arch packaging: Update spsdk to 2.1 and package the new release.

Meanwhile the workarounds can be to downgrade cryptography

@dvzrv
Copy link

dvzrv commented Mar 20, 2024 via email

@robin-nitrokey
Copy link
Member

@dvzrv Do these hazmat imports really originate from pynitrokey? AFAIS, they were only in spsdk <= 2.0.0.

@sosthene-nitrokey
Copy link
Contributor

= 42 (due to the hazmat changes mentioned in my other ticket).

Which changes? I tested with spsdk 2.1 and cryptography 42.0.5 and all appears to work, even though spskdk does not claim support for cryptography 42, in practice it appears to work.

@sosthene-nitrokey
Copy link
Contributor

There are other uses of hazmat in nitropy itself, but they are for primitives that are still available with 42.0.5.

@dvzrv
Copy link

dvzrv commented Mar 20, 2024 via email

@dvzrv
Copy link

dvzrv commented Mar 20, 2024

I just tried to run tests for spsdk 2.0.1 (188 fail due to cryptographic primitives being elsewhere) and 2.1.0 (250 fail due to cryptographic primitives being elsewhere).

Upstream develops behind closed doors, so although there may be some fixes for cryptography >=42 somewhere, there is nothing for me to even cherry-pick or backport (releases are just single commit code-dumps changing the entire repository).

A month ago upstream hinted at some new version in nxp-mcuxpresso/spsdk#64 but that yet has to materialize.

In the meantime I'll just do nothing, because there is nothing for me to do.

@dvzrv
Copy link

dvzrv commented Mar 21, 2024

According to upstream a new release will be made on 2024-03-27 which supports cryptography 42:
nxp-mcuxpresso/spsdk#64 (comment)

This would be 2.1.1 and I'll try to upgrade to it in the hopes that it will be still compatible with pynitrokey.

@sosthene-nitrokey
Copy link
Contributor

sosthene-nitrokey commented Mar 21, 2024

We're in the process of trying to vendor the parts of spsdk that we need in pynitrokey for a new release to avoid such issues in the future.

Since I based the vendored on the latest spsdk master branch I can see that it's not actually fully compatible already.

@dosenpils
Copy link

@dvzrv I was wondering if you noticed that SPSDK v2.1.1 has been released?

@dvzrv
Copy link

dvzrv commented Mar 31, 2024

@dvzrv I was wondering if you noticed that SPSDK v2.1.1 has been released?

Yes. Just been a tad busy the past days.

@dvzrv
Copy link

dvzrv commented Mar 31, 2024

@monogatron: An updated spsdk is now in testing. please provide signoffs

@dosenpils
Copy link

@dvzrv I was wondering if you noticed that SPSDK v2.1.1 has been released?

Yes. Just been a tad busy the past days.

@dvzrv: Yes, I can fully understand that the XZ story had top priority. The question wasn't meant to give the impression that I'm an annoyed user waiting for an update - just to explain a little more so that no misunderstandings arise. Thank you for your work and yours! :)

@robin-nitrokey
Copy link
Member

This should be fixed when using up-to-date versions of pynitrokey and spsdk. Please open a new issue if you run into other compatibility problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants