Skip to content

Commit

Permalink
bump pyo3 0.17->0.21
Browse files Browse the repository at this point in the history
  • Loading branch information
jvmncs committed Apr 9, 2024
1 parent 3e5d213 commit 14e1832
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 125 deletions.
51 changes: 33 additions & 18 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ crate-type = ["cdylib"]
hpke-rs = { version = "0.2", features = ["hazmat"] }
hpke-rs-crypto = { version = "0.2" }
hpke-rs-rust-crypto = { version = "0.2" }
pyo3 = { version = "0.17", features = ["extension-module"] }
pyo3 = { version = "0.21", features = ["extension-module"] }
rand = { version = "0.8" }
22 changes: 11 additions & 11 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,38 @@ impl PyContext {
fn seal<'p>(
&mut self,
py: Python<'p>,
aad: &PyBytes,
plain_txt: &PyBytes,
) -> PyResult<&'p PyBytes> {
aad: &Bound<'p, PyBytes>,
plain_txt: &Bound<'p, PyBytes>,
) -> PyResult<Bound<'p, PyBytes>> {
let aad = aad.as_bytes();
let plain_txt = plain_txt.as_bytes();
let cipher_txt = self.ctx.seal(aad, plain_txt).map_err(handle_hpke_error)?;
Ok(PyBytes::new(py, cipher_txt.as_slice()))
Ok(PyBytes::new_bound(py, cipher_txt.as_slice()))
}

fn open<'p>(
&mut self,
py: Python<'p>,
aad: &PyBytes,
cipher_txt: &PyBytes,
) -> PyResult<&'p PyBytes> {
aad: &Bound<'p, PyBytes>,
cipher_txt: &Bound<'p, PyBytes>,
) -> PyResult<Bound<'p, PyBytes>> {
let aad = aad.as_bytes();
let cipher_txt = cipher_txt.as_bytes();
let plain_txt = self.ctx.open(aad, cipher_txt).map_err(handle_hpke_error)?;
Ok(PyBytes::new(py, plain_txt.as_slice()))
Ok(PyBytes::new_bound(py, plain_txt.as_slice()))
}

fn export<'p>(
&self,
py: Python<'p>,
exporter_context: &PyBytes,
exporter_context: &Bound<'p, PyBytes>,
length: usize,
) -> PyResult<&'p PyBytes> {
) -> PyResult<Bound<'p, PyBytes>> {
let exporter_context = exporter_context.as_bytes();
let exporter_secret = self
.ctx
.export(exporter_context, length)
.map_err(handle_hpke_error)?;
Ok(PyBytes::new(py, exporter_secret.as_slice()))
Ok(PyBytes::new_bound(py, exporter_secret.as_slice()))
}
}
6 changes: 0 additions & 6 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ create_exception!(
PyException,
"Unable to collect enough randomness."
);
create_exception!(
errors,
LockPoisoned,
PyException,
"A concurrency issue with an RwLock."
);

#[inline(always)]
pub(crate) fn handle_hpke_error(e: HpkeError) -> PyErr {
Expand Down
Loading

0 comments on commit 14e1832

Please sign in to comment.