Guard cryptography internals monkey patch and add ECC verification tests#15
Draft
Copilot wants to merge 5 commits intodependabot/pip/cryptography-46.0.5from
Draft
Guard cryptography internals monkey patch and add ECC verification tests#15Copilot wants to merge 5 commits intodependabot/pip/cryptography-46.0.5from
Copilot wants to merge 5 commits intodependabot/pip/cryptography-46.0.5from
Conversation
… workflow Co-authored-by: smlu <4377556+smlu@users.noreply.github.com>
…mport Co-authored-by: smlu <4377556+smlu@users.noreply.github.com>
Co-authored-by: smlu <4377556+smlu@users.noreply.github.com>
Co-authored-by: smlu <4377556+smlu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Make keys.py resilient to cryptography internals removal
Guard cryptography internals monkey patch and add ECC verification tests
Feb 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cryptography 46.0.0+ removed internal OpenSSL EC APIs that pymrtd monkey-patches to support unnamed elliptic curves. This PR guards the import and conditionally applies the patch based on availability.
Changes
src/pymrtd/pki/keys.pycryptography.hazmat.backends.openssl.ecimports in try/except ImportErrorexcept Exceptionin patched initializertests/test_ecc_verification.py(new).github/workflows/pytest.yml(new)Example
Both paths maintain identical external behavior for verification operations.
Original prompt
Summary
Create a new branch (based on dependabot/pip/cryptography-46.0.5) and open a pull request that: (1) makes keys.py resilient to cryptography internals being removed (guard the internal import and only apply the monkey patch when internals are available), (2) adds ECC verification tests that exercise both X9.62 (DER) signatures and plain (r||s) ECDSA signatures using generated keys, and (3) ensures the tests run in CI by adding a GitHub Actions workflow that runs pytest. The PR should target the repository ZeroPass/pymrtd.
Files to add/modify
Suggested patch (style should be adapted to the repo):
Test file contents: