Skip to content

Commit f2f9be4

Browse files
committed
handling mixed types with Cow
1 parent 2dcf7b6 commit f2f9be4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/rust/src/pkcs7.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -775,11 +775,11 @@ fn verify_der<'p>(
775775
// in the signed data, then the provided content. If None of these are available, raise
776776
// an error. TODO: what should the order be?
777777
let data = match signer_info.authenticated_attributes {
778-
Some(attrs) => &asn1::write_single(&attrs)?,
778+
Some(attrs) => Cow::Owned(asn1::write_single(&attrs)?),
779779
None => match content {
780-
Some(data) => data,
780+
Some(data) => Cow::Borrowed(data),
781781
None => match signed_data.content_info.content {
782-
pkcs7::Content::Data(Some(data)) => data.into_inner(),
782+
pkcs7::Content::Data(Some(data)) => Cow::Borrowed(data.into_inner()),
783783
_ => {
784784
return Err(CryptographyError::from(
785785
pyo3::exceptions::PyValueError::new_err(
@@ -797,7 +797,7 @@ fn verify_der<'p>(
797797
certificate.call_method0(pyo3::intern!(py, "public_key"))?,
798798
&signer_info.digest_encryption_algorithm,
799799
signer_info.encrypted_digest,
800-
data,
800+
&data,
801801
)?;
802802

803803
// Verify the certificate

0 commit comments

Comments
 (0)