diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 253540cc906ac..2090870ea92c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: branches: - main - '*.*.x' + - pyo3test tags: - '*.*' - '*.*.*' diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock index 08a18882aebca..93258bdfa8681 100644 --- a/src/rust/Cargo.lock +++ b/src/rust/Cargo.lock @@ -278,9 +278,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.21.0-beta.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0c41d899f822e5f39186d6da130a822a0a43edb19992b51bf4ef6cd0b4cfd1" +checksum = "a02a88a17e74cadbc8ce77855e1d6c8ad0ab82901a4a9b5046bd01c1c0bd95cd" dependencies = [ "cfg-if", "indoc", @@ -296,9 +296,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.21.0-beta.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5509c2aa78c7e770077e41ba86f806e60dcee812e924ccb2d6fe78c0a0128ce2" +checksum = "a5eb0b6ecba38961f6f4bd6cd5906dfab3cd426ff37b2eed5771006aa31656f1" dependencies = [ "once_cell", "target-lexicon", @@ -306,9 +306,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.21.0-beta.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6bb234a86ed619a661f3bb3c2493aaff9cb937e33e198d17f5f20a15881e155" +checksum = "ba8a6e48a29b5d22e4fdaf132d8ba8d3203ee9f06362d48f244346902a594ec3" dependencies = [ "libc", "pyo3-build-config", @@ -316,9 +316,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.21.0-beta.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0b787de2c6832eb1eb393c9f82f976a5a87bda979780d9b853878846a8d2e4b" +checksum = "4e80493c5965f94a747d0782a607b2328a4eea5391327b152b00e2f3b001cede" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -328,9 +328,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.21.0-beta.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e3b7beed357786d2afe845871964e824ad8af0df38a403f7d01cdc81aadb211" +checksum = "fcd7d86f42004025200e12a6a8119bd878329e6fddef8178eaafa4e4b5906c5b" dependencies = [ "heck", "proc-macro2", diff --git a/src/rust/src/backend/x25519.rs b/src/rust/src/backend/x25519.rs index f47f1dd68c5c7..1149e22dc237d 100644 --- a/src/rust/src/backend/x25519.rs +++ b/src/rust/src/backend/x25519.rs @@ -17,12 +17,64 @@ pub(crate) struct X25519PublicKey { pkey: openssl::pkey::PKey, } -#[pyo3::prelude::pyfunction] fn generate_key() -> CryptographyResult { Ok(X25519PrivateKey { pkey: openssl::pkey::PKey::generate_x25519()?, }) } +#[doc(hidden)] +mod generate_key { + pub(crate) struct MakeDef; + pub const DEF: ::pyo3::impl_::pymethods::PyMethodDef = MakeDef::DEF; + pub fn add_to_module( + module: &::pyo3::Bound<'_, ::pyo3::types::PyModule>, + ) -> ::pyo3::PyResult<()> { + use ::pyo3::prelude::PyModuleMethods; + use ::std::convert::Into; + module + .add_function( + ::pyo3::types::PyCFunction::internal_new( + module.py(), + &DEF, + module.into(), + )?, + ) + } +} +impl generate_key::MakeDef { + const DEF: ::pyo3::impl_::pymethods::PyMethodDef = ::pyo3::impl_::pymethods::PyMethodDef::noargs( + "generate_key\0", + ::pyo3::impl_::pymethods::PyCFunction({ + unsafe extern "C" fn trampoline( + _slf: *mut ::pyo3::ffi::PyObject, + _args: *mut ::pyo3::ffi::PyObject, + ) -> *mut ::pyo3::ffi::PyObject { + ::pyo3::impl_::trampoline::noargs( + _slf, + _args, + __pyfunction_generate_key, + ) + } + trampoline + }), + "generate_key()\n--\n\n\0", + ); +} +#[allow(non_snake_case)] +unsafe fn __pyfunction_generate_key<'py>( + py: ::pyo3::Python<'py>, + _slf: *mut ::pyo3::ffi::PyObject, +) -> ::pyo3::PyResult<*mut ::pyo3::ffi::PyObject> { + let _slf_ref = &_slf; + let function = generate_key; + #[allow(clippy::let_unit_value)] + let result = ::pyo3::impl_::wrap::map_result_into_ptr( + py, + ::pyo3::impl_::wrap::OkWrap::wrap(function()) + .map_err(::core::convert::Into::<::pyo3::PyErr>::into), + ); + result +} pub(crate) fn private_key_from_pkey( pkey: &openssl::pkey::PKeyRef, diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs index b503779133e06..5d373167a81e5 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -3,7 +3,7 @@ // for complete details. #![deny(rust_2018_idioms, clippy::undocumented_unsafe_blocks)] -#![allow(unknown_lints, non_local_definitions, clippy::result_large_err)] +#![allow(unknown_lints, non_local_definitions, clippy::result_large_err, dead_code, unused_imports)] #[cfg(CRYPTOGRAPHY_OPENSSL_300_OR_GREATER)] use crate::error::CryptographyResult;