diff --git a/src/rust/src/backend/mod.rs b/src/rust/src/backend/mod.rs index 3cbf2e3b99b6..a447565d7229 100644 --- a/src/rust/src/backend/mod.rs +++ b/src/rust/src/backend/mod.rs @@ -2,8 +2,6 @@ // 2.0, and the BSD License. See the LICENSE file in the root of this repository // for complete details. -use pyo3::types::PyModuleMethods; - pub(crate) mod aead; pub(crate) mod cipher_registry; pub(crate) mod ciphers; @@ -24,9 +22,3 @@ pub(crate) mod utils; pub(crate) mod x25519; #[cfg(all(not(CRYPTOGRAPHY_IS_LIBRESSL), not(CRYPTOGRAPHY_IS_BORINGSSL)))] pub(crate) mod x448; - -pub(crate) fn add_to_module(module: &pyo3::Bound<'_, pyo3::types::PyModule>) -> pyo3::PyResult<()> { - module.add_submodule(&rsa::create_module(module.py())?)?; - - Ok(()) -} diff --git a/src/rust/src/backend/rsa.rs b/src/rust/src/backend/rsa.rs index 6636ab695a7c..3c01e74219fb 100644 --- a/src/rust/src/backend/rsa.rs +++ b/src/rust/src/backend/rsa.rs @@ -9,7 +9,7 @@ use crate::backend::{hashes, utils}; use crate::buf::CffiBuf; use crate::error::{CryptographyError, CryptographyResult}; use crate::{exceptions, types}; -use pyo3::types::{PyAnyMethods, PyModuleMethods}; +use pyo3::types::PyAnyMethods; #[pyo3::pyclass( frozen, @@ -814,16 +814,10 @@ impl RsaPublicNumbers { } } -pub(crate) fn create_module( - py: pyo3::Python<'_>, -) -> pyo3::PyResult> { - let m = pyo3::types::PyModule::new_bound(py, "rsa")?; - m.add_function(pyo3::wrap_pyfunction_bound!(generate_private_key, &m)?)?; - - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - - Ok(m) +#[pyo3::pymodule] +pub(crate) mod rsa { + #[pymodule_export] + use super::{ + generate_private_key, RsaPrivateKey, RsaPrivateNumbers, RsaPublicKey, RsaPublicNumbers, + }; } diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs index 766c9ed0d8e9..653df62705b9 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -183,6 +183,8 @@ mod _rust { #[pymodule_export] use crate::backend::poly1305::poly1305; #[pymodule_export] + use crate::backend::rsa::rsa; + #[pymodule_export] use crate::backend::x25519::x25519; #[cfg(all(not(CRYPTOGRAPHY_IS_LIBRESSL), not(CRYPTOGRAPHY_IS_BORINGSSL)))] #[pymodule_export] @@ -219,8 +221,6 @@ mod _rust { } } - crate::backend::add_to_module(openssl_mod)?; - Ok(()) } }