Simplify code that was randomly overly complicated (#12158)

This commit is contained in:
Alex Gaynor 2024-12-17 19:13:35 -05:00 committed by GitHub
parent b2283262f8
commit 88e85851da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 9 deletions

View file

@ -32,7 +32,7 @@ check-sdist==1.2.0 ; python_full_version >= '3.8'
# via cryptography (pyproject.toml)
click==8.1.7
# via cryptography (pyproject.toml)
colorama==0.4.6 ; (platform_system != 'Windows' and sys_platform == 'win32') or platform_system == 'Windows' or os_name == 'nt'
colorama==0.4.6 ; os_name == 'nt' or (platform_system == 'Windows' and sys_platform != 'win32') or sys_platform == 'win32'
# via
# build
# click

View file

@ -221,17 +221,14 @@ impl CertificateSigningRequest {
}
#[getter]
fn is_signature_valid(
slf: pyo3::PyRef<'_, Self>,
py: pyo3::Python<'_>,
) -> CryptographyResult<bool> {
let public_key = slf.public_key(py)?;
fn is_signature_valid(&self, py: pyo3::Python<'_>) -> CryptographyResult<bool> {
let public_key = self.public_key(py)?;
Ok(sign::verify_signature_with_signature_algorithm(
py,
public_key,
&slf.raw.borrow_dependent().signature_alg,
slf.raw.borrow_dependent().signature.as_bytes(),
&asn1::write_single(&slf.raw.borrow_dependent().csr_info)?,
&self.raw.borrow_dependent().signature_alg,
self.raw.borrow_dependent().signature.as_bytes(),
&asn1::write_single(&self.raw.borrow_dependent().csr_info)?,
)
.is_ok())
}