Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
reaperhulk committed Mar 26, 2024
1 parent 627775e commit 981db40
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- '*.*.x'
- pyo3test
tags:
- '*.*'
- '*.*.*'
Expand Down
20 changes: 10 additions & 10 deletions src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 53 additions & 1 deletion src/rust/src/backend/x25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,64 @@ pub(crate) struct X25519PublicKey {
pkey: openssl::pkey::PKey<openssl::pkey::Public>,
}

#[pyo3::prelude::pyfunction]
fn generate_key() -> CryptographyResult<X25519PrivateKey> {
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<openssl::pkey::Private>,
Expand Down
2 changes: 1 addition & 1 deletion src/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 981db40

Please sign in to comment.