Skip to content

Commit 8eed98f

Browse files
committed
handling mixed types with Cow
1 parent edc74c1 commit 8eed98f

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
@@ -779,11 +779,11 @@ fn verify_der<'p>(
779779
// in the signed data, then the provided content. If None of these are available, raise
780780
// an error. TODO: what should the order be?
781781
let data = match signer_info.authenticated_attributes {
782-
Some(attrs) => &asn1::write_single(&attrs)?,
782+
Some(attrs) => Cow::Owned(asn1::write_single(&attrs)?),
783783
None => match content {
784-
Some(data) => data,
784+
Some(data) => Cow::Borrowed(data),
785785
None => match signed_data.content_info.content {
786-
pkcs7::Content::Data(Some(data)) => data.into_inner(),
786+
pkcs7::Content::Data(Some(data)) => Cow::Borrowed(data.into_inner()),
787787
_ => {
788788
return Err(CryptographyError::from(
789789
pyo3::exceptions::PyValueError::new_err(
@@ -801,7 +801,7 @@ fn verify_der<'p>(
801801
certificate.call_method0(pyo3::intern!(py, "public_key"))?,
802802
&signer_info.digest_encryption_algorithm,
803803
signer_info.encrypted_digest,
804-
data,
804+
&data,
805805
)?;
806806

807807
// Verify the certificate

0 commit comments

Comments
 (0)