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

Reduce deprecation warnings from cryptography module #445

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dkg
Copy link
Contributor

@dkg dkg commented Jun 14, 2023

Modern versions of the python cryptography module deprecate IDEA, CAST5, and Blowfish.

These changes ensure that the CryptographyDeprecationWarnings will be produced only when handling or producing material that uses one of those algorithms explicitly.

dkg added 2 commits June 28, 2023 15:38
If someone actually wants to use IDEA, CAST5, or Blowfish, we want to
see the CryptographyDeprecationWarning objects emitted by
cryptography.hazmat.primitives.ciphers.  But if we're just looking up
a non-deprecated cipher we should just return it directly.

This avoids the following kinds of warnings:

pgpy/pgpy/constants.py:191: CryptographyDeprecationWarning: IDEA has been deprecated
  bs = {SymmetricKeyAlgorithm.IDEA: algorithms.IDEA,
pgpy/pgpy/constants.py:193: CryptographyDeprecationWarning: CAST5 has been deprecated
  SymmetricKeyAlgorithm.CAST5: algorithms.CAST5,
pgpy/pgpy/constants.py:194: CryptographyDeprecationWarning: Blowfish has been deprecated
  SymmetricKeyAlgorithm.Blowfish: algorithms.Blowfish,
…suite

Once CAST5 is deprecated, a deprecation warning might arise in
addition to the warnings about already-protected secret keys might not
be the first warning.

Instead, we have the test look through the warnings and validate the
content of any matching warning.
@dkg dkg force-pushed the cryptography-deprecations branch from 995fd58 to fb885e6 Compare June 28, 2023 19:41
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.

None yet

1 participant