Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Jan 31, 2025
1 parent 40c8207 commit 0f875ef
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/rust/src/backend/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,12 @@ pub(crate) fn load_der_private_key_bytes<'p>(
password: Option<&[u8]>,
unsafe_skip_rsa_key_validation: bool,
) -> CryptographyResult<pyo3::Bound<'p, pyo3::PyAny>> {
let pkey = if let Ok(pkey) = cryptography_key_parsing::pkcs8::parse_private_key(data) {
Some(pkey)
} else if let Ok(pkey) = cryptography_key_parsing::dsa::parse_pkcs1_private_key(data) {
Some(pkey)
} else if let Ok(pkey) = cryptography_key_parsing::ec::parse_pkcs1_private_key(data, None) {
Some(pkey)
} else if let Ok(pkey) = cryptography_key_parsing::rsa::parse_pkcs1_private_key(data) {
Some(pkey)
} else {
None
};
if let Some(pkey) = pkey {
let pkey = cryptography_key_parsing::pkcs8::parse_private_key(data)
.or_else(|_| cryptography_key_parsing::dsa::parse_pkcs1_private_key(data))
.or_else(|_| cryptography_key_parsing::ec::parse_pkcs1_private_key(data, None))
.or_else(|_| cryptography_key_parsing::rsa::parse_pkcs1_private_key(data));

if let Ok(pkey) = pkey {
if password.is_some() {
return Err(CryptographyError::from(
pyo3::exceptions::PyTypeError::new_err(
Expand Down

0 comments on commit 0f875ef

Please sign in to comment.