Skip to content

Move FFDH to decrepit - #15643

Open
reaperhulk wants to merge 5 commits into
mainfrom
claude/bold-wozniak-56l0iz
Open

reaperhulk wants to merge 5 commits into
mainfrom
claude/bold-wozniak-56l0iz

Conversation

@reaperhulk

Copy link
Copy Markdown
Member

Addresses #15603.

Diffie-Hellman over finite fields (FFDH) was deprecated in 50.0.0 on the way to removal, but some protocols mandate it with no alternative to negotiate into. This moves it into cryptography.hazmat.decrepit.asymmetric.dh, following the pattern used for the decrepit ciphers and modes, and keeps every existing deprecation warning with reworded text: FFDH is deprecated and will only be available from the decrepit module starting in 53.0.0.

What moved

  • cryptography.hazmat.decrepit.asymmetric.dh now holds generate_parameters, the DHParameters / DHPrivateKey / DHPublicKey ABCs, the three numbers classes, and load_pem_parameters / load_der_parameters (these can only load FFDH parameters, so they belong with it). Nothing in the decrepit module warns.
  • cryptography.hazmat.primitives.asymmetric.dh becomes a shim that re-exports the same objects via utils.deprecated, so isinstance checks against either path keep working. The warning class is DeprecatedIn51 with removal targeted at 53.0.0, matching the two-release window.
  • serialization.load_pem_parameters / load_der_parameters stay deprecated, with the "has been moved to ... and will be removed from ... in 53.0.0" wording the Camellia and CFB/OFB moves used.
  • The Rust warning emitted when the generic key loading APIs (and X.509 public_key()) hand back a DH key is kept and reworded the same way. DEPRECATED_IN_50 in types.rs was only used there and is removed.
  • asymmetric.types now takes the DH types from the decrepit module instead of the _DHPublicKey / _DHPrivateKey private aliases, which are dropped.

Bug fixed along the way

The old shim (and dsa.py today, not touched here) called utils.deprecated(DHParameters, ..., name="DHParametersWithSerialization") after utils.deprecated(DHParameters, ..., name="DHParameters") had already replaced the module global with the _DeprecatedValue marker, so the ...WithSerialization aliases resolved to the marker object instead of the class. The new shim reads every value from the decrepit module directly, and the new test covers all ten names.

Docs and tests

  • New docs/hazmat/decrepit/dh.rst documents the decrepit module (with versionadded:: 51.0.0 markers and doctests for the parameter loaders). The old primitives/asymmetric/dh.rst keeps its content with a "moved to decrepit" warning, as the cipher and mode pages do, so older changelog cross-references still resolve under nitpicky mode.
  • Tests import from the decrepit module and no longer need to suppress warnings when building fixtures. TestFFDHDeprecation checks the old module names, the serialization loaders, the generic key loaders, and that the decrepit path is warning-free.

One design point for reviewers

Loading FFDH keys through load_pem_private_key and friends still warns, as requested ("keep the warnings"). The decrepit module deliberately does not grow its own PEM/DER key loaders in this PR, so if the intent for 53.0.0 is that the generic loaders stop returning DH keys, a follow-up would need to add those; if instead the generic loaders should keep working and return the decrepit types, the Rust warning can simply be removed later.

nox -e local passes in full. nox -e docs builds cleanly under -W; the only doctest failures locally are in unrelated pages (Argon2, AES-GCM-SIV, SHAKE squeeze) because the container's system OpenSSL 3.0.13 lacks them.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TmnZQpY2o4HeBNFN5tfqYE


Generated by Claude Code

Diffie-Hellman over finite fields was deprecated in 50.0.0 with the
intent to remove it, but some protocols mandate it with no alternative
to negotiate into (see #15603). Move it into
cryptography.hazmat.decrepit.asymmetric.dh, alongside the parameter
loaders, which are FFDH-only.

The names in cryptography.hazmat.primitives.asymmetric.dh,
load_pem_parameters/load_der_parameters in serialization, and loading
FFDH keys with the generic key loading APIs still warn, but the warning
now says FFDH has moved to decrepit and will only be available there
starting in 53.0.0.

The deprecated DH shim now takes every value from the decrepit module
directly: previously the *WithSerialization aliases wrapped the
deprecation marker of the base name rather than the class, because each
utils.deprecated call replaces the module global it names.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TmnZQpY2o4HeBNFN5tfqYE
Historical changelog entries link to the classes at their original
documentation path, and Sphinx runs in nitpicky mode, so the page keeps
documenting them (as the decrepit cipher and mode pages do) with a
warning pointing at the decrepit module.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TmnZQpY2o4HeBNFN5tfqYE
The BoringSSL CI jobs failed because the new tests built DH parameters
without the `dh_supported` guard the other DH tests use. Also use the
3072-bit fixture rather than generating 512-bit parameters, which FIPS
builds reject.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TmnZQpY2o4HeBNFN5tfqYE
Comment thread docs/hazmat/primitives/asymmetric/dh.rst Outdated
Comment thread docs/hazmat/decrepit/dh.rst
"algorithm."
"Diffie-Hellman over finite fields (FFDH) is deprecated and has been "
"moved to cryptography.hazmat.decrepit.asymmetric.dh. Starting in "
"53.0.0 it will only be available from that module."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, I really feel like this is moving backwards on the deprecation, and therefore suggests we're prepared to carry it forever, which I really don't want to be.

The old primitives page is now a short stub pointing at the decrepit
module instead of a full copy of the reference. Historical changelog
entries cross-reference the decrepit page so Sphinx's nitpicky build
still resolves them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TmnZQpY2o4HeBNFN5tfqYE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants