Skip to content

Commit

Permalink
docs: add Tagged comments ISO/IEC 8825-1:2021 in CustomClasses
Browse files Browse the repository at this point in the history
  • Loading branch information
dishmaker authored Dec 2, 2024
1 parent fd9b041 commit 116ce15
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion der/src/asn1/custom_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ where

impl<const TAG: u16, T, const CLASS: u8> Tagged for CustomClassExplicit<TAG, T, CLASS> {
fn tag(&self) -> Tag {
expected_tag_constructed(Class::from(CLASS), TagNumber(TAG), true)
// ISO/IEC 8825-1:2021
// 8.14.3 If implicit tagging (see Rec. ITU-T X.680 | ISO/IEC 8824-1, 31.2.7) was not used in the definition of the type, the
// encoding shall be constructed and the contents octets shall be the complete base encoding [Encode].
let constructed = true;
expected_tag_constructed(Class::from(CLASS), TagNumber(TAG), constructed)
}
}

Expand All @@ -173,6 +177,10 @@ where
T: FixedTag,
{
fn tag(&self) -> Tag {
// ISO/IEC 8825-1:2021
// 8.14.4 If implicit tagging was used in the definition of the type, then:
// a) the encoding shall be constructed if the base encoding is constructed, and shall be primitive otherwise; and
// b) the contents octets shall be the same as the contents octets [EncodeValue] of the base encoding.
let constructed = <T as FixedTag>::TAG.is_constructed();
expected_tag_constructed(Class::from(CLASS), TagNumber(TAG), constructed)
}
Expand Down

0 comments on commit 116ce15

Please sign in to comment.