Skip to content

Commit 66168f8

Browse files
committed
Don't build dh code on BoringSSL
It doesn't support DH via EVP
1 parent ed04457 commit 66168f8

File tree

2 files changed

+8
-3
lines changed
  • src
    • cryptography/hazmat/primitives/asymmetric
    • rust/src/backend

2 files changed

+8
-3
lines changed

src/cryptography/hazmat/primitives/asymmetric/dh.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ def parameter_numbers(self) -> DHParameterNumbers:
154154

155155

156156
DHParametersWithSerialization = DHParameters
157-
DHParameters.register(rust_openssl.dh.DHParameters)
157+
if hasattr(rust_openssl, "dh"):
158+
DHParameters.register(rust_openssl.dh.DHParameters)
158159

159160

160161
class DHPublicKey(metaclass=abc.ABCMeta):
@@ -195,7 +196,8 @@ def __eq__(self, other: object) -> bool:
195196

196197

197198
DHPublicKeyWithSerialization = DHPublicKey
198-
DHPublicKey.register(rust_openssl.dh.DHPublicKey)
199+
if hasattr(rust_openssl, "dh"):
200+
DHPublicKey.register(rust_openssl.dh.DHPublicKey)
199201

200202

201203
class DHPrivateKey(metaclass=abc.ABCMeta):
@@ -244,4 +246,5 @@ def private_bytes(
244246

245247

246248
DHPrivateKeyWithSerialization = DHPrivateKey
247-
DHPrivateKey.register(rust_openssl.dh.DHPrivateKey)
249+
if hasattr(rust_openssl, "dh"):
250+
DHPrivateKey.register(rust_openssl.dh.DHPrivateKey)

src/rust/src/backend/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
33
// for complete details.
44

5+
#[cfg(not(CRYPTOGRAPHY_IS_BORINGSSL))]
56
pub(crate) mod dh;
67
pub(crate) mod dsa;
78
#[cfg(any(not(CRYPTOGRAPHY_IS_LIBRESSL), CRYPTOGRAPHY_LIBRESSL_370_OR_GREATER))]
@@ -19,6 +20,7 @@ pub(crate) mod x25519;
1920
pub(crate) mod x448;
2021

2122
pub(crate) fn add_to_module(module: &pyo3::prelude::PyModule) -> pyo3::PyResult<()> {
23+
#[cfg(not(CRYPTOGRAPHY_IS_BORINGSSL))]
2224
module.add_submodule(dh::create_module(module.py())?)?;
2325
module.add_submodule(dsa::create_module(module.py())?)?;
2426

0 commit comments

Comments
 (0)