-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
support for PKCS7_NO_VERIFY in test_support.pkcs7_verify #12116
base: main
Are you sure you want to change the base?
Conversation
If you're interested in helping us design a public API for PKCS#7 verification, that's something we'd be interested in! |
Currently I am migrating a project from M2Crypto to cryptography. There is an API for verification of pkcs7: https://github.com/eventbrite/m2crypto/blob/0f61819722c07ecffd7cf47c25095b516bf2d85c/M2Crypto/SMIME.py#L207, which is quite similar to test_support.pkcs7_verify. I am willing to help, but since I am new to the cryptography project I would need some hints what you are expecting from such a public API that exceeds the complexity of M2Crypto's variant |
That's great to hear re:migration. It's definitely a use case we want to support. The big thing we'd be looking for in a public API is: Something that fits in place with the rest of our PKCS#7 APIs, something that is general enough to support many different verification use cases, and something that pushes users towards a secure result. Internal APIs like #11555 is a recent example of working through the API design to add PKCS#7 decrpytion APIs. |
Do you have in mind encapsuling the api in configurable objects as in x509 like Additionally I would appreciate some pointers which PKCS#7 verification usecases we should cover for starter. |
Hey, I've worked on the new On my side, my approach was simple: develop something that mimics Since decryption is to encryption what verifying is to signing, we should probably adopt the same approach, then improve the function with new features afterwards (maybe |
There's an AttributeError issue with cryptography==42.0.8 and pyopenssl==24.1.0, where PKCS7_NOVERIFY flag no longer exists in the cryptography module. This PR backports and optimizes (2x) some homemade code introduced in saas-17.3 as a fallback for PyOpenSSL. See: PR odoo#137572 We can investigate fixing the calls to cryptography.hazmat.bindings._rust.test_support.pkcs7_verify but it currently doesn't support the PKCS7_NO_VERIFY flag. The pyca team has a PR to re-introduce it in Rust, but at the moment it is not available. See: pyca/cryptography#12116 NO_VERIFY is useful because sometimes certificates are not valid, and yet we still have to read the invoice which is badly signed. We cannot take for granted that the Tax Agency checks valid certificates, since it doesn't even properly check the ASN1 structure. References: - PyOpenSSL doesn't support load_pkcs7_data anymore. pyca/pyopenssl@0fe822d - Cryptography has removed PKCS7_NOVERIFY: pyca/cryptography@615967b and is migrating PKCS7_verify to Rust: https://github.com/pyca/cryptography/blob/43.0.x/src/rust/src/types.rs#L333 - `asn1` library is pure Python and MIT licensed, but is slower than our homemade solution https://github.com/andrivet/python-asn1/blob/master/src/asn1.py
There's an AttributeError issue with cryptography==42.0.8 and pyopenssl==24.1.0, where PKCS7_NOVERIFY flag no longer exists in the cryptography module. This PR backports and optimizes (2x) some homemade code introduced in saas-17.3 as a fallback for PyOpenSSL. See: PR odoo#137572 We can investigate fixing the calls to cryptography.hazmat.bindings._rust.test_support.pkcs7_verify but it currently doesn't support the PKCS7_NO_VERIFY flag. The pyca team has a PR to re-introduce it in Rust, but at the moment it is not available. See: pyca/cryptography#12116 NO_VERIFY is useful because sometimes certificates are not valid, and yet we still have to read the invoice which is badly signed. We cannot take for granted that the Tax Agency checks valid certificates, since it doesn't even properly check the ASN1 structure. References: - PyOpenSSL doesn't support load_pkcs7_data anymore. pyca/pyopenssl@0fe822d - Cryptography has removed PKCS7_NOVERIFY: pyca/cryptography@615967b and is migrating PKCS7_verify to Rust: https://github.com/pyca/cryptography/blob/43.0.x/src/rust/src/types.rs#L333 - `asn1` library is pure Python and MIT licensed, but is slower than our homemade solution https://github.com/andrivet/python-asn1/blob/master/src/asn1.py
This PR adds support for Pkcs7Flags::NOVERIFY so that we can verify pkcs7 signatures without verifying the certificates.
M2Crypto also exposes this option but I would prefer to use cryptography ;)
It is needed when the verifying a signed apple wallet pass. Now I can verify it with the call
without the NoVerify option I get the error:
The unittests as in
cryptography/tests/hazmat/primitives/test_pkcs7.py
Line 412 in 7a20576
use ECPrivateKey but when using RSAPrivateKey I get the above error.