Which Python features and APIs depend on RSA and elliptic-curve keys

Python's ssl module, cryptography package and certificate handling rely on RSA, DH and ECC keys through the OpenSSL build each one is linked against. Python 3.15 added group and signature controls, but the facts do not show a Python default that uses post-quantum key exchange.

On this page

Which Python connections and signatures rely on RSA and ECC keys today

Python TLS connections, certificate signatures and cryptography package keys depend on RSA, Diffie-Hellman or elliptic-curve algorithms through the OpenSSL build each component is linked against, and the facts checked here do not show a default post-quantum key exchange in Python. The ssl module requires OpenSSL 1.1.1 or newer since Python 3.10 (PEP 644), so its key agreement and certificate algorithms come from whichever OpenSSL the interpreter was built with. For Python 3.15, the latest stable release as of 2026-12-03, the facts show that SSLContext.set_groups() can name post-quantum groups, but they do not show post-quantum groups as the default. This page covers dependencies only: which components rely on which public-key algorithms. It does not cover how to configure them or what the project plans to do.

Assessors inventorying Python 3.14 or 3.15 services should record three separate components. The first is the interpreter's ssl module, which uses the system or bundled OpenSSL. The second is the cryptography package, which the installation docs say ships statically linked wheels with its own bundled OpenSSL, so a pip-installed copy does not share the ssl module's library. The changelog lists bundled OpenSSL 4.1.1 in cryptography 51.0.0, released 2026-12-01. The third is hashlib, which uses OpenSSL where available and falls back to a HACL* implementation for some hash algorithms since Python 3.12. Hashes are not public-key primitives, but the same inventory should note which OpenSSL build supplies them.

For the ssl module, record the default context settings as dependencies rather than as a security assessment. ssl.create_default_context() requires certificate verification with the CA set loaded, and its default cipher list since Python 3.10 limits TLS 1.2 and earlier to forward-secret AES and ChaCha20 suites at security level 2, which prohibits RSA and DH keys under 2048 bits and ECC keys under 224 bits. The docs warn that these defaults may become more restrictive without deprecation, so record the Python version with the inventory. Also record that set_ecdh_curve() controlled key agreement before 3.15, and that the 3.15 get_groups() method requires OpenSSL 3.5 or later. Confirm the OpenSSL version of each deployed build before relying on any group list.

Which Python components depend on public-key algorithms, by version

This table lists the Python components that rely on RSA, Diffie-Hellman, ECDH or ECDSA keys, the version each fact applies to, and the source checked. Read the rows by component, since the ssl module depends on the OpenSSL build it is linked against while the cryptography package uses its own bundled OpenSSL. The main takeaway is that the algorithms in use depend on the Python version, the linked OpenSSL and the package version, so confirm each one in your own environment.

ComponentVersion or edition it applies toWhat it depends on (RSA, DH, ECDH, ECDSA)Source and date checked
ssl: TLS key agreementPython 3.10 and later, with OpenSSL 1.1.1 or newer; set_groups() from Python 3.15ECDH curves through OpenSSL; set_ecdh_curve() before 3.15, set_groups() in 3.15Python ssl docs, checked 2026-12-04
ssl: certificate signaturesPython 3.10 and later; signature restriction methods added in Python 3.15RSA or ECDSA certificate signatures through OpenSSL; restriction via set_client_sigalgs() and set_server_sigalgs() in 3.15Python 3.15 What's New, checked 2026-12-04
ssl: cipher and version defaultsPython 3.10 and later; TLS 1.3 cipher restriction via set_ciphersuites() in 3.15Default cipher list requires security level 2, which prohibits RSA and DH keys under 2048 bits and ECC keys under 224 bitsPython ssl docs, checked 2026-12-04
cryptography package with bundled OpenSSLVersion 51.0.0 (released 2026-12-01) bundles OpenSSL 4.1.1; pip wheels for macOS, Windows and LinuxRSA key generation (2048 or 4096 bits recommended, 1024 and below considered breakable); ECDSA and ECDH through its bundled OpenSSLcryptography installation docs and cryptography RSA docs, checked 2026-12-04
hashlib fallback behaviorPython 3.12 and later; falls back to HACL* for MD5, SHA1, SHA2 and SHA3 when linked OpenSSL lacks themHash functions only, not public-key algorithms; FIPS builds may block algorithmsPython hashlib docs, checked 2026-12-04
PEP 761 release signingPython 3.14 and 3.15 release artifactsSigstore signatures replace PGP for new release series; the signing key type is not stated in the cited sourcesPEP 761 and Python 3.15.1 release page, checked 2026-12-04

Where RSA, DH and ECC keys appear in a Python TLS connection

A Python TLS connection uses public-key algorithms in three places: key agreement, certificate signatures during verification, and the libraries that build those operations. Each card below names one of these places and says what to confirm in your own environment.

TLS key agreement via set_ecdh_curve

Before Python 3.15, the key agreement group on a server-side SSLContext is controlled with set_ecdh_curve(), and the ssl docs use prime256v1 as the example. The docs note this setting does not apply to client sockets, so key agreement on outbound connections is governed by OpenSSL defaults. Check which side of your connection you control, and confirm the group your Python version negotiates with a test handshake. An ECDH curve here is a classic elliptic-curve key, not a post-quantum one.

Python ssl docs

TLS key agreement via set_groups in 3.15

Python 3.15 adds SSLContext.set_groups(), which sets the groups allowed for key agreement and accepts several groups, including finite-field and post-quantum groups alongside ECDH curves. The same release adds SSLSocket.group() to report the group used on a connection. Reading the negotiated group after a handshake is the most direct way to confirm what a deployment actually uses, and the docs say these calls depend on a minimum OpenSSL version.

Python 3.15 What's New

Certificate signatures in default verification

ssl.create_default_context() with server authentication sets verify_mode to CERT_REQUIRED and loads CA certificates, so every server certificate's signature is checked during the handshake. The signature algorithm on those certificates, RSA or ECDSA, is determined by the issuing CA and the server, not by Python. Inventory the certificate chains your clients accept, and confirm the signature algorithms they use. Python 3.15 adds set_client_sigalgs() and set_server_sigalgs() to restrict these from code.

Python ssl docs

Weak-key limits in the default cipher list

The default cipher list since Python 3.10 uses security level 2, which the docs say prohibits RSA and DH keys under 2048 bits and ECC keys under 224 bits. This is a floor on classical key sizes, not a post-quantum control. The docs also warn that create_default_context() defaults may become more restrictive at any time without deprecation, so pin your expected settings in code and test after upgrades.

Python ssl docs

RSA keys in the cryptography package

A pip-installed cryptography package uses its own statically linked OpenSSL rather than the one the ssl module uses, so the two can differ in version and algorithm support. The cryptography RSA docs say keys of 1024 bits and below are considered breakable and recommend 2048 or 4096 bits for new keys. Its changelog lists bundled OpenSSL 4.1.1 in cryptography 51.0.0, released 2026-12-01. Check the version installed in each environment, since it sets which algorithms are available.

cryptography install docs

SHA-3 depends on OpenSSL

PEP 644 removed the built-in SHA-3 implementation, so SHA-3 and SHAKE in hashlib require OpenSSL. The hashlib docs add that since Python 3.12 a HACL* fallback covers MD5, SHA1, SHA2 and SHA3 when the linked OpenSSL lacks them, and that FIPS builds may block algorithms. Confirm in each build which hash functions are actually available, because a signature scheme that depends on SHA-3 will fail on a build that cannot provide it.

PEP 644

How the answer changes with the OpenSSL build and the cryptography package

In this situation the ssl module can use the group-based controls that Python 3.15 added. SSLContext.set_groups() sets the groups allowed for key agreement, and it accepts multiple groups, including finite-field and post-quantum groups alongside ECDH curves. SSLContext.get_groups() lists the groups the linked OpenSSL makes available, and the 3.15 What's New page states that it requires OpenSSL 3.5 or later. OpenSSL 3.5.0 changed its default TLS supported groups to include and prefer hybrid post-quantum KEM groups, and its default key shares offer X25519MLKEM768 and X25519, so a build in this situation may negotiate hybrid key exchange without any extra configuration.

  • Build check: Confirm the linked OpenSSL version with ssl.OPENSSL_VERSION and confirm that get_groups() returns entries on that interpreter.
  • Group selection: Use set_groups() with the OpenSSL group list format to restrict key agreement, and set_ecdh_curve() is no longer the only control.
  • Negotiated group: SSLSocket.group() returns the key agreement group used on a connection, and the What's New page says it requires OpenSSL 3.2 or later.
  • Defaults: The create_default_context() settings can change to more restrictive values without prior deprecation, so record the effective defaults after each upgrade.
  • Patch level: The CPython tracker shows the 3.14 and 3.15 Windows builds and the macOS installer moving to OpenSSL 3.5.8, and a later pull request moved the 3.15 macOS installer to 3.5.9. Confirm the patch level of your own installer rather than assuming it.

Check that the interpreter you test is the one your service runs, and record the OPENSSL_VERSION string next to the group list it reports.

Where public-key algorithms sit in a Python TLS handshake

The diagram starts with a Python program creating an ssl context, which links to the OpenSSL build the interpreter was compiled against. That OpenSSL performs key agreement (ECDH groups, or the groups chosen by set_groups() on Python 3.15) and verifies the RSA or ECDSA signature on the server certificate. Separately, a cryptography package installed with pip carries its own statically linked OpenSSL and does not use the one ssl uses. Check which OpenSSL your Python build reports and whether your code calls cryptography for keys or signatures.

Key agreement and certificate checks run in the OpenSSL the ssl module links to.

What an assessor should check first in a Python estate

The sequence below establishes which Python runtime, OpenSSL build and cryptography package are in use, and which TLS settings and key sizes each one applies. Each step closes with a record an assessor can keep as evidence for the public-key dependencies in this estate.

  1. Record the Python and OpenSSL versions

    Run the Python interpreter on each host and record the minor version with sys.version. Then run import ssl and print ssl.OPENSSL_VERSION to see the OpenSSL build the ssl module is linked against. Python 3.10 and later require OpenSSL 1.1.1 or newer, so the TLS algorithms available depend on this build. Confirm the version with the operating system or container image owner, because a distribution can patch OpenSSL without changing its version string. The record is a table listing each host or image, its Python minor version and its ssl.OPENSSL_VERSION output.

  2. Check for explicit curve and group settings

    Search the codebase and deployment configuration for calls to set_ecdh_curve(), set_groups() and set_client_sigalgs(). Set_ecdh_curve() is the control for key agreement before Python 3.15, and the ssl documentation's example curve does not apply to client sockets. Set_groups() and set_client_sigalgs() arrived in Python 3.15, so a call to either on an older runtime will fail or not exist. Note each call with its file, the interpreter version it targets and the value passed. The record is a list of every call site, or a statement that none were found, with the search method used.

  3. Inventory installed cryptography packages and RSA key sizes

    Run pip list or pip show cryptography in each environment and record the installed version. A pip-installed cryptography package ships its own bundled OpenSSL, which can differ from the OpenSSL the ssl module uses, so record both. Next, find every place that generates or loads RSA keys and note the key_size used. The cryptography RSA documentation calls keys of 1024 bits and below breakable and recommends 2048 or 4096 bits for new keys. Flag any key below 2048 bits for owner review. The record is a table of environment, cryptography version, bundled OpenSSL version and RSA key sizes found.

  4. Record reliance on create_default_context()

    Find each call to ssl.create_default_context() and record which purpose it targets, such as SERVER_AUTH or CLIENT_AUTH. For server authentication, the defaults require certificate verification and load CA certificates, and recent Python versions add strict X.509 verify flags. The cipher choice is also a default, and the documentation states that the default protocol, options and cipher settings may change to more restrictive values at any time without prior deprecation. Therefore, run the settings check against each runtime version in use and record the resulting minimum TLS version, cipher list and verify mode, rather than assuming they match the documentation. The record is one line per call site with its purpose, the Python version tested and the verified settings.

  5. Confirm the signing and hashing dependencies

    Check whether the estate uses SHA-3 or SHAKE through hashlib. Python 3.10 and later rely on OpenSSL for these, because the built-in SHA-3 implementation was removed. Also check whether any environment runs a FIPS-compliant build or OpenSSL FIPS mode, since the hashlib documentation says some algorithms may be missing or blocked there. Record which algorithms each service calls and whether the runtime provides them. The record is a list of hash and signature calls per service, with the runtime that was tested for each.

  6. Check the signing status of the runtime itself

    Confirm how the Python runtime you deploy was signed and verified. PEP 761 makes Sigstore the only signing method for new release series, and the Python 3.15.1 release page lists a .sigstore file beside each download. Record the verification method your team uses for each interpreter installer or image, and the release it came from. The record is a list of interpreter sources, their versions and the verification step applied to each.

What the Python project and its dependencies have not published

The Python documentation and the cryptography changelog describe what exists, but they leave several questions about public-key defaults and post-quantum coverage unanswered. Each card below names one gap, why it matters for Python's RSA and elliptic-curve dependencies, and what to ask the project or vendor before relying on a setting.

Post-quantum groups in ssl defaults

The Python 3.15 ssl documentation describes set_groups() and get_groups(), but the sources checked do not say whether create_default_context() or any release selects a post-quantum group by default. Key agreement in a default connection may still be ECDH on a classical curve. Ask the Python project whether any release changes the default group list, and check the group actually negotiated on a live connection with SSLSocket.group().

Python ssl docs

ML-KEM and ML-DSA outside the ssl module

The cryptography package ships its own bundled OpenSSL, so its ML-KEM and ML-DSA classes do not change what the ssl module negotiates or verifies. A pip-installed cryptography and the Python ssl module can therefore run different cryptographic code with different algorithm support. Confirm which OpenSSL build each installed package loads, and do not treat cryptography's ML-DSA support as coverage for TLS connections.

cryptography installation docs

SLH-DSA and X25519MLKEM768 in cryptography

The cryptography 51.0.0 changelog entry adds composite ML-DSA-44 with Ed25519 keys in OpenSSH format. The changelog read for this page mentions no SLH-DSA or X25519MLKEM768 entries, so their absence there is not evidence either way for later releases. Ask the cryptography maintainers whether SLH-DSA or a hybrid X25519MLKEM768 key exchange is planned, and in which release.

cryptography changelog

Roadmap for signature defaults

The sources checked describe the ssl and cryptography defaults as they stand today, and the ssl documentation warns that default protocol, option and cipher settings may become more restrictive without prior deprecation. No published roadmap was found that says when classical signature algorithms in default certificate verification or signing would change. Ask the Python project for any written plan on signature defaults, and track the ssl documentation and What's New pages for changes.

Python 3.15 What's New

Hashlib behavior in FIPS builds

The hashlib documentation says algorithms may be missing or blocked in a FIPS-compliant build or when OpenSSL FIPS mode excludes them, and it does not list which algorithms a given build exposes. Public-key support is also tied to the OpenSSL build, so the same Python version may behave differently across platforms. Ask the distributor of each Python build for its OpenSSL version and FIPS status, and test the algorithms your code calls.

Python hashlib docs

What breaks when Python's key settings change

The first risk for an assessor is that the defaults you inventory today may not be the defaults you have tomorrow. The ssl module documentation warns that the protocol, option and cipher settings produced by ssl.create_default_context() may change to more restrictive values at any time without prior deprecation. A connection that completes with today's defaults could fail after an interpreter upgrade, or could negotiate a different group or cipher without any code change. Teams that need stable behavior should pin what they depend on explicitly rather than relying on the default. In practice that means setting minimum_version and maximum_version on the SSLContext, and using set_ciphers() for TLS 1.2 and earlier and set_ciphersuites() for TLS 1.3, which Python 3.15 added. On Python 3.15 and later, set_groups() pins the key agreement groups as well. Confirm the exact pinned values in your own code and record them in the inventory, because a default you did not write down is one you cannot audit.

The second point concerns a control many engineers reach for first. The ssl docs name set_ecdh_curve(), with prime256v1 as the example, as the pre-3.15 way to choose the key agreement curve, but the docs note that it does not apply to client sockets. A server that calls it may believe it has restricted key agreement while clients still negotiate according to their own defaults, so an inventory built from server configuration alone will misstate the client side. Check each side of each connection separately. Python 3.15's set_groups() extends the older control, accepts a list of groups, and includes finite-field and post-quantum groups in addition to ECDH curves. The SSLSocket.group() method reports which group a connection actually used, which is the evidence an assessor should ask for. The SSLSocket.group() method requires OpenSSL 3.2 or later, and SSLContext.get_groups() requires OpenSSL 3.5 or later, so confirm the OpenSSL version before relying on either.

The third point is that the answer depends on which library you ask. The ssl module uses the OpenSSL build it is linked against, while a pip-installed cryptography package ships statically linked wheels with its own bundled OpenSSL. The cryptography changelog lists bundled OpenSSL 4.1.1 in version 51.0.0, released 2026-12-01, so the two paths can report different algorithm support, different defaults and different key agreement behavior on the same machine. Record the OpenSSL version reported by ssl.OPENSSL_VERSION and the cryptography version separately, and note which one each finding came from. When the two disagree, the question is not which one is right in general but which one carries the connection or signature in question. Confirm that with a test that exercises the actual code path, not a version string alone.

Questions assessors ask about Python's RSA and ECC dependencies

Is Python quantum safe?

No product can be called quantum safe on the strength of its language runtime alone, and the sources checked do not support that claim for Python. What they do show is that Python's TLS and certificate behavior depends on the OpenSSL build it is linked against, and that Python 3.15 added controls for key agreement groups and signature algorithms. Whether a given Python deployment can use post-quantum algorithms depends on the OpenSSL version, the Python release and the way the application configures SSLContext. Ask the vendor or project for a dated statement, and inventory your own builds to confirm what each one actually offers.

Which Python and OpenSSL versions expose set_groups()?

SSLContext.set_groups() was added in Python 3.15, which the 3.15 What's New page says was released on 9 October 2026. The Python 3.15 ssl docs say each new method is marked as added in version 3.15, and that set_groups() replaces and extends set_ecdh_curve() by listing several key agreement groups, including finite-field and post-quantum groups. The What's New page also says SSLContext.get_groups() requires OpenSSL 3.5 or later and SSLSocket.group() requires OpenSSL 3.2 or later. Confirm the OpenSSL version on each host with python3 -c "import ssl; print(ssl.OPENSSL_VERSION)", since the sources checked do not list an OpenSSL minimum for set_groups() itself.

Are the cryptography package's RSA defaults enough?

The sources do not describe the defaults as enough or not enough, so treat this as a question to answer from the documentation and your own policy. The cryptography RSA documentation says generate_private_key() rejects key sizes below 512 bits, considers keys of 1024 bits and below breakable, and recommends 2048 or 4096 bits for new keys with public exponent 65537. Check each call site for the key_size value it passes instead of relying on the library default. Also note that a pip-installed cryptography ships its own bundled OpenSSL, separate from the one the ssl module uses, so RSA behavior in your application may not match what ssl negotiates.

Does hashlib depend on OpenSSL?

Partly. The hashlib documentation says it uses OpenSSL where available, and since Python 3.12 it falls back to a HACL* implementation for MD5, SHA1, SHA2 or SHA3 algorithms that the linked OpenSSL does not provide. The documentation also says some algorithms may be missing or blocked in a FIPS-compliant build or when OpenSSL FIPS mode excludes them. So hashlib's available algorithm list depends on the build and environment. Note that hashlib covers hashing rather than public-key signatures, and PEP 644 states that SHA-3 and SHAKE require OpenSSL because the built-in SHA-3 implementation was removed. Check hashlib.algorithms_available on each target build.

Are Python release artifacts signed with the method the project recommends?

Yes for the releases the sources cover. PEP 761 deprecates PGP signatures for CPython releases starting with 3.14 and makes Sigstore the only signing method for new release series, so 3.14 and 3.15 artifacts are verified with Sigstore signatures. The Python 3.15.1 release page, dated 21 October 2026, lists a .sigstore file beside each download. Older releases may still carry PGP signatures, so check the release you install. Verify the Sigstore bundle against the artifact before you deploy it, and record the verification step in your software supply chain evidence.

Can DeployOpen run the Python cryptography inventory in our environment?

DeployOpen can plan and carry out this work inside your own infrastructure as a fixed-scope engagement, with scope, deliverables and timelines agreed in writing before work starts. The inventory would cover which Python builds, OpenSSL versions and cryptography package versions run in your estate, which ssl and hashlib settings they use, and where public-key dependencies appear in your code. DeployOpen prepares evidence for your compliance assessments, but it does not issue audit reports or attestations. A quote follows from the written scope, and DeployOpen does not publish a price list. Ask for the inventory method, the data it collects and where that data is stored before you agree the scope.

How DeployOpen helps assess Python's public-key dependencies

DeployOpen scopes the Python environments, ssl configuration, and cryptography package versions in your estate, then tests which RSA, Diffie-Hellman and elliptic-curve settings are in use. Each engagement ends with a documented inventory that your security and compliance teams can review and retest.

How we scope

  • Agree in writing which Python versions, services and deployments are in scope before work starts.
  • Identify which OpenSSL build each Python runtime links against, since ssl behavior depends on it.
  • Confirm whether pip-installed cryptography uses its own bundled OpenSSL, which may differ from the ssl module.

How we build

  • Review ssl context settings, including minimum TLS version, cipher lists and certificate verification flags.
  • Test key agreement groups and certificate signature algorithms against the settings your deployments actually use.
  • Check RSA key sizes and elliptic-curve parameters in code that calls the cryptography package directly.

How we hand over

  • Deliver a dependency inventory listing each public-key use, the module or API involved, and the version it applies to.
  • Document which findings are confirmed by testing and which need confirmation from vendor or project documentation.
  • Provide written fixes with a retest so you can verify each change against the same inventory.

How we support

  • Offer ongoing support as a retainer for upgrades to new Python releases and OpenSSL builds.
  • Run continuous testing when your Python versions, dependencies or ssl settings change after handover.
  • Prepare inventory updates for each release cycle so your records stay aligned with what runs in production.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.