diff --git a/src/rust/src/asn1.rs b/src/rust/src/asn1.rs index 5d8f2e1a95f2..6bed105518d8 100644 --- a/src/rust/src/asn1.rs +++ b/src/rust/src/asn1.rs @@ -8,7 +8,6 @@ use asn1::SimpleAsn1Readable; use cryptography_x509::certificate::Certificate; use cryptography_x509::common::{DssSignature, SubjectPublicKeyInfo, Time}; use cryptography_x509::name::Name; -use pyo3::basic::CompareOp; use pyo3::types::IntoPyDict; use pyo3::ToPyObject; @@ -68,7 +67,7 @@ pub(crate) fn py_uint_to_big_endian_bytes<'p>( v: &'p pyo3::types::PyLong, ) -> pyo3::PyResult<&'p [u8]> { let zero = (0).to_object(py); - if v.rich_compare(zero, CompareOp::Lt)?.is_true()? { + if v.lt(zero)? { return Err(pyo3::exceptions::PyValueError::new_err( "Negative integers are not supported", )); diff --git a/src/rust/src/backend/ec.rs b/src/rust/src/backend/ec.rs index 96e42f4ec3ec..885a5cbf4dc2 100644 --- a/src/rust/src/backend/ec.rs +++ b/src/rust/src/backend/ec.rs @@ -6,7 +6,6 @@ use crate::backend::utils; use crate::error::{CryptographyError, CryptographyResult}; use crate::{exceptions, types}; use foreign_types_shared::ForeignTypeRef; -use pyo3::basic::CompareOp; use pyo3::ToPyObject; #[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.ec")] @@ -214,9 +213,7 @@ fn public_key_from_numbers( let py_y = numbers.getattr(pyo3::intern!(py, "y"))?; let zero = (0).to_object(py); - if py_x.rich_compare(&zero, CompareOp::Lt)?.is_true()? - || py_y.rich_compare(&zero, CompareOp::Lt)?.is_true()? - { + if py_x.lt(&zero)? || py_y.lt(&zero)? { return Err(CryptographyError::from( pyo3::exceptions::PyValueError::new_err( "Invalid EC key. Both x and y must be non-negative.",