Skip to content

Commit 4acfbe1

Browse files
committed
cleanup
1 parent dbddaf4 commit 4acfbe1

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

‎src/rust/src/backend/keys.rs‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,12 @@ pub(crate) fn load_der_private_key_bytes<'p>(
3535
password: Option<&[u8]>,
3636
unsafe_skip_rsa_key_validation: bool,
3737
) -> CryptographyResult<pyo3::Bound<'p, pyo3::PyAny>> {
38-
let pkey = if let Ok(pkey) = cryptography_key_parsing::pkcs8::parse_private_key(data) {
39-
Some(pkey)
40-
} else if let Ok(pkey) = cryptography_key_parsing::dsa::parse_pkcs1_private_key(data) {
41-
Some(pkey)
42-
} else if let Ok(pkey) = cryptography_key_parsing::ec::parse_pkcs1_private_key(data, None) {
43-
Some(pkey)
44-
} else if let Ok(pkey) = cryptography_key_parsing::rsa::parse_pkcs1_private_key(data) {
45-
Some(pkey)
46-
} else {
47-
None
48-
};
49-
if let Some(pkey) = pkey {
38+
let pkey = cryptography_key_parsing::pkcs8::parse_private_key(data)
39+
.or_else(|_| cryptography_key_parsing::dsa::parse_pkcs1_private_key(data))
40+
.or_else(|_| cryptography_key_parsing::ec::parse_pkcs1_private_key(data, None))
41+
.or_else(|_| cryptography_key_parsing::rsa::parse_pkcs1_private_key(data));
42+
43+
if let Ok(pkey) = pkey {
5044
if password.is_some() {
5145
return Err(CryptographyError::from(
5246
pyo3::exceptions::PyTypeError::new_err(

0 commit comments

Comments
 (0)