Skip to content

Use cryptography's non-deprecated CFB location when available#1034

Open
okke-formsma wants to merge 1 commit into
IdentityPython:masterfrom
okke-formsma:fix/lazy-aescipher-postfix-mode
Open

Use cryptography's non-deprecated CFB location when available#1034
okke-formsma wants to merge 1 commit into
IdentityPython:masterfrom
okke-formsma:fix/lazy-aescipher-postfix-mode

Conversation

@okke-formsma

@okke-formsma okke-formsma commented Jul 7, 2026

Copy link
Copy Markdown

Fixes #1033.

CFB moved from cryptography.hazmat.primitives.ciphers.modes to cryptography.hazmat.decrepit.ciphers.modes in cryptography 47, which is also exactly when the old location started emitting CryptographyDeprecationWarning on attribute access.

This prefers the new location when it exists, falling back to the old one on cryptography < 47 where decrepit does not exist yet. That removes the warning both at import time and when AESCipher is actually used with cfb mode, for every supported cryptography version.

All 7 existing tests in test_92_aes.py pass unchanged, tested against cryptography 43.0.3 and 49.0.0.

CFB moved from cryptography.hazmat.primitives.ciphers.modes to
cryptography.hazmat.decrepit.ciphers.modes in cryptography 47, which is
also exactly when the old location started emitting
CryptographyDeprecationWarning on attribute access. Prefer the new
location when it exists, falling back to the old one on cryptography < 47
where decrepit does not exist yet.

This removes the warning both at import time and when AESCipher is
actually used with cfb mode, for every supported cryptography version.

Fixes IdentityPython#1033
@okke-formsma okke-formsma force-pushed the fix/lazy-aescipher-postfix-mode branch from 8b98fe3 to 5b8dd74 Compare July 7, 2026 11:03
@okke-formsma okke-formsma changed the title Resolve AESCipher.POSTFIX_MODE lazily to avoid warning on import Use cryptography's non-deprecated CFB location when available Jul 7, 2026
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 this pull request may close these issues.

CryptographyDeprecationWarning: CFB warning fires on import even when AESCipher isn't used

1 participant