Skip to content

Commit eccdd11

Browse files
authored
cms: fixup content-type comparison (#1978)
When producing a document with inline content, the Content-Type comparison would compared against the oid of the attribute and not its value.
1 parent de5d5fe commit eccdd11

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cms/src/builder.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,17 @@ impl Builder for SignerInfoBuilder<'_> {
254254
attr.oid.cmp(&const_oid::db::rfc5911::ID_CONTENT_TYPE) == Ordering::Equal
255255
});
256256
if let Some(signed_attributes_content_type) = signed_attributes_content_type {
257+
if signed_attributes_content_type.values.len() != 1 {
258+
return Err(der::Error::from(ErrorKind::Failed).into());
259+
}
260+
let Some(value) = signed_attributes_content_type.values.get(0) else {
261+
return Err(der::Error::from(ErrorKind::Failed).into());
262+
};
263+
264+
let value = value.decode_as::<ObjectIdentifier>()?;
265+
257266
// Check against `eContentType`
258-
if signed_attributes_content_type.oid != econtent_type {
267+
if value != econtent_type {
259268
// Mismatch between content types: encapsulated content info <-> signed attributes.
260269
return Err(der::Error::from(ErrorKind::Failed).into());
261270
}

0 commit comments

Comments
 (0)