Skip to content

Handle InternalError in KexMLKEM768X25519 and KexCurve25519 is_available - #2716

Open
JakkulaVeerababu wants to merge 1 commit into
paramiko:mainfrom
JakkulaVeerababu:fix/mlkem-fips-internalerror-2712
Open

JakkulaVeerababu wants to merge 1 commit into
paramiko:mainfrom
JakkulaVeerababu:fix/mlkem-fips-internalerror-2712

Conversation

@JakkulaVeerababu

Copy link
Copy Markdown

Summary

Fixes #2712 (and related #2442).

In environments where ML-KEM or X25519 is unsupported by the underlying OpenSSL provider (such as FIPS mode or custom provider configurations), cryptography raises cryptography.exceptions.InternalError when attempting key generation (generate()), rather than UnsupportedAlgorithm.

Because Transport evaluates available key exchanges during class initialization at module import time, an unhandled InternalError in KexMLKEM768X25519.is_available() aborts import paramiko before any SSH connection can be established.

Changes

  1. In paramiko/kex_mlkem.py: catch (UnsupportedAlgorithm, InternalError) in KexMLKEM768X25519.is_available().
  2. In paramiko/kex_curve25519.py: catch (UnsupportedAlgorithm, InternalError) in KexCurve25519.is_available().
  3. In tests/test_kex.py: add KexAvailabilityTest verifying is_available() returns False when InternalError or UnsupportedAlgorithm is raised during key generation.
  4. In sites/www/changelog.rst: add changelog entry for :bug:2712.

Under OpenSSL FIPS mode or with providers that do not implement ML-KEM or X25519, key generation raises cryptography.exceptions.InternalError rather than UnsupportedAlgorithm. Because Transport initializes algorithms at import time, unhandled InternalError aborts importing paramiko.

Catch InternalError alongside UnsupportedAlgorithm in is_available() so unavailable algorithms are gracefully excluded from preferred key exchanges.

Fixes paramiko#2712.
@JakkulaVeerababu

Copy link
Copy Markdown
Author

@bitprophet could you take a look when you have time? It catches InternalError in the is_available checks of KexMLKEM768X25519 and KexCurve25519, so importing paramiko no longer fails when OpenSSL doesn't support ML-KEM or X25519 (fixes #2712). Thanks!

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.

[BUG] - Paramiko 5.1.0 import fails under FIPS during ML-KEM availability detection

1 participant