Skip to content

Commit

Permalink
Fixes #10294 -- correct accidental change to exchange kwarg (#10295) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Jan 30, 2024
1 parent 92fa9f2 commit 002e886
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/rust/src/backend/dh.rs
Expand Up @@ -154,11 +154,11 @@ impl DHPrivateKey {
fn exchange<'p>(
&self,
py: pyo3::Python<'p>,
public_key: &DHPublicKey,
peer_public_key: &DHPublicKey,
) -> CryptographyResult<&'p pyo3::types::PyBytes> {
let mut deriver = openssl::derive::Deriver::new(&self.pkey)?;
deriver
.set_peer(&public_key.pkey)
.set_peer(&peer_public_key.pkey)
.map_err(|_| pyo3::exceptions::PyValueError::new_err("Error computing shared key."))?;

Ok(pyo3::types::PyBytes::new_with(py, deriver.len()?, |b| {
Expand Down
6 changes: 3 additions & 3 deletions src/rust/src/backend/ec.rs
Expand Up @@ -232,7 +232,7 @@ impl ECPrivateKey {
&self,
py: pyo3::Python<'p>,
algorithm: &pyo3::PyAny,
public_key: &ECPublicKey,
peer_public_key: &ECPublicKey,
) -> CryptographyResult<&'p pyo3::types::PyBytes> {
if !algorithm.is_instance(types::ECDH.get(py)?)? {
return Err(CryptographyError::from(
Expand All @@ -249,12 +249,12 @@ impl ECPrivateKey {
// ECPublicKey object.
#[cfg(CRYPTOGRAPHY_OPENSSL_300_OR_GREATER)]
deriver
.set_peer_ex(&public_key.pkey, false)
.set_peer_ex(&peer_public_key.pkey, false)
.map_err(|_| pyo3::exceptions::PyValueError::new_err("Error computing shared key."))?;

#[cfg(not(CRYPTOGRAPHY_OPENSSL_300_OR_GREATER))]
deriver
.set_peer(&public_key.pkey)
.set_peer(&peer_public_key.pkey)
.map_err(|_| pyo3::exceptions::PyValueError::new_err("Error computing shared key."))?;

Ok(pyo3::types::PyBytes::new_with(py, deriver.len()?, |b| {
Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/backend/x25519.rs
Expand Up @@ -65,10 +65,10 @@ impl X25519PrivateKey {
fn exchange<'p>(
&self,
py: pyo3::Python<'p>,
public_key: &X25519PublicKey,
peer_public_key: &X25519PublicKey,
) -> CryptographyResult<&'p pyo3::types::PyBytes> {
let mut deriver = openssl::derive::Deriver::new(&self.pkey)?;
deriver.set_peer(&public_key.pkey)?;
deriver.set_peer(&peer_public_key.pkey)?;

Ok(pyo3::types::PyBytes::new_with(py, deriver.len()?, |b| {
let n = deriver.derive(b).map_err(|_| {
Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/backend/x448.rs
Expand Up @@ -64,10 +64,10 @@ impl X448PrivateKey {
fn exchange<'p>(
&self,
py: pyo3::Python<'p>,
public_key: &X448PublicKey,
peer_public_key: &X448PublicKey,
) -> CryptographyResult<&'p pyo3::types::PyBytes> {
let mut deriver = openssl::derive::Deriver::new(&self.pkey)?;
deriver.set_peer(&public_key.pkey)?;
deriver.set_peer(&peer_public_key.pkey)?;

Ok(pyo3::types::PyBytes::new_with(py, deriver.len()?, |b| {
let n = deriver.derive(b).map_err(|_| {
Expand Down

0 comments on commit 002e886

Please sign in to comment.