Skip to content

Commit

Permalink
no more unwrap for parameter checks
Browse files Browse the repository at this point in the history
  • Loading branch information
nitneuqr committed Nov 24, 2024
1 parent 8ef2ac0 commit 4ba77de
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/rust/src/pkcs7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,26 +351,26 @@ fn check_decrypt_parameters<'p>(

// Check if all options are from the PKCS7Options enum
let pkcs7_option_type = types::PKCS7_TEXT.get(py)?.get_type();
if !options
.iter()
.all(|opt| opt.is_instance(&pkcs7_option_type).unwrap())
{
return Err(CryptographyError::from(
pyo3::exceptions::PyValueError::new_err("options must be from the PKCS7Options enum"),
));
for opt in options.iter() {
if !opt.is_instance(&pkcs7_option_type)? {
return Err(CryptographyError::from(
pyo3::exceptions::PyValueError::new_err(
"options must be from the PKCS7Options enum",
),
));
}
}

// Check if any option is not PKCS7Options::Text
let text_option = types::PKCS7_TEXT.get(py)?;
if options
.iter()
.any(|opt| !opt.eq(text_option.clone()).unwrap())
{
return Err(CryptographyError::from(
pyo3::exceptions::PyValueError::new_err(
"Only the following options are supported for decryption: Text",
),
));
for opt in options.iter() {
if !opt.eq(text_option.clone())? {
return Err(CryptographyError::from(
pyo3::exceptions::PyValueError::new_err(
"Only the following options are supported for decryption: Text",
),
));
}
}

// Check if certificate's public key is an RSA public key
Expand Down

0 comments on commit 4ba77de

Please sign in to comment.