diff --git a/src/rust/src/backend/mod.rs b/src/rust/src/backend/mod.rs index 1f703485b9707..bf9f1d024457f 100644 --- a/src/rust/src/backend/mod.rs +++ b/src/rust/src/backend/mod.rs @@ -47,7 +47,6 @@ pub(crate) fn add_to_module(module: &pyo3::Bound<'_, pyo3::types::PyModule>) -> module.add_submodule(&hashes::create_module(module.py())?)?; module.add_submodule(&hmac::create_module(module.py())?)?; module.add_submodule(&kdf::create_module(module.py())?)?; - 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 6636ab695a7c4..3c01e74219fb6 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 e4285fce2b981..1e8a04e311cf3 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -148,6 +148,8 @@ mod _rust { #[pymodule_export] use super::super::{is_fips_enabled, openssl_version, openssl_version_text}; #[pymodule_export] + use crate::backend::rsa::rsa; + #[pymodule_export] use crate::error::{capture_error_stack, raise_openssl_error, OpenSSLError}; #[pymodule_init]