Skip to content

Commit

Permalink
handling mixed types with Cow
Browse files Browse the repository at this point in the history
  • Loading branch information
nitneuqr committed Jan 15, 2025
1 parent 2dcf7b6 commit f2f9be4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/rust/src/pkcs7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,11 +775,11 @@ fn verify_der<'p>(
// in the signed data, then the provided content. If None of these are available, raise
// an error. TODO: what should the order be?
let data = match signer_info.authenticated_attributes {
Some(attrs) => &asn1::write_single(&attrs)?,
Some(attrs) => Cow::Owned(asn1::write_single(&attrs)?),
None => match content {
Some(data) => data,
Some(data) => Cow::Borrowed(data),
None => match signed_data.content_info.content {
pkcs7::Content::Data(Some(data)) => data.into_inner(),
pkcs7::Content::Data(Some(data)) => Cow::Borrowed(data.into_inner()),
_ => {
return Err(CryptographyError::from(
pyo3::exceptions::PyValueError::new_err(
Expand All @@ -797,7 +797,7 @@ fn verify_der<'p>(
certificate.call_method0(pyo3::intern!(py, "public_key"))?,
&signer_info.digest_encryption_algorithm,
signer_info.encrypted_digest,
data,
&data,
)?;

// Verify the certificate
Expand Down

0 comments on commit f2f9be4

Please sign in to comment.