Skip to content

Commit

Permalink
Fix encoding of optional TaggedImplicit object
Browse files Browse the repository at this point in the history
  • Loading branch information
yestyle committed Jul 21, 2024
1 parent 64502e4 commit 00de85f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/asn1_types/tagged/implicit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ where
}

fn write_der_content(&self, writer: &mut dyn std::io::Write) -> SerializeResult<usize> {
self.inner.write_der(writer)
self.inner.write_der_content(writer)
}
}

Expand Down
11 changes: 11 additions & 0 deletions tests/to_der.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,17 @@ fn to_der_tagged_implicit() {
assert!(tagged.eq(&t2));
}

#[test]
fn to_der_tagged_implicit_optional() {
// TaggedValue API
let tagged = Some(TaggedValue::implicit(Integer::from(2)));
let v = tagged.to_der_vec().expect("serialization failed");
assert_eq!(&v, &hex!("81 01 02"));
let (_, t2) = OptTaggedImplicit::<Integer, Error, 1>::from_der(&v)
.expect("decoding serialized object failed");
assert!(tagged.eq(&t2));
}

#[test]
fn to_der_teletexstring() {
test_simple_string!(TeletexString, "abcdef");
Expand Down

0 comments on commit 00de85f

Please sign in to comment.