Skip to content

Commit 2f3e066

Browse files
authored
crmf: fix infinite recursion in EncKeyWithIdChoice::tag (#1832)
1 parent c1d5fb8 commit 2f3e066

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

crmf/src/pop.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl<'a> ::der::Tagged for EncKeyWithIdChoice<'a> {
266266
fn tag(&self) -> ::der::Tag {
267267
match self {
268268
Self::String(_) => <Utf8StringRef<'a> as ::der::FixedTag>::TAG,
269-
Self::GeneralName(_) => self.tag(),
269+
Self::GeneralName(variant) => variant.tag(),
270270
}
271271
}
272272
}
@@ -298,3 +298,26 @@ pub struct PrivateKeyInfo {
298298
)]
299299
pub attrs: Option<Attributes>,
300300
}
301+
302+
#[cfg(test)]
303+
mod tests {
304+
use der::{Tag, TagNumber, asn1::Ia5String};
305+
use x509_cert::ext::pkix::name::GeneralName;
306+
307+
use super::EncKeyWithIdChoice;
308+
309+
#[test]
310+
fn enc_key_with_id_choice_tag() {
311+
use der::Tagged;
312+
let enc_key_choice = EncKeyWithIdChoice::GeneralName(GeneralName::DnsName(
313+
Ia5String::new("test").expect("valid Ia5String"),
314+
));
315+
assert_eq!(
316+
enc_key_choice.tag(),
317+
Tag::ContextSpecific {
318+
constructed: false,
319+
number: TagNumber(2)
320+
}
321+
);
322+
}
323+
}

0 commit comments

Comments
 (0)