From 116ce156d1a786c12c94b99b4fac37b08ddee019 Mon Sep 17 00:00:00 2001 From: dishmaker <141624503+dishmaker@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:34:36 +0100 Subject: [PATCH] docs: add Tagged comments ISO/IEC 8825-1:2021 in CustomClasses --- der/src/asn1/custom_class.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/der/src/asn1/custom_class.rs b/der/src/asn1/custom_class.rs index 4e45e8282..ec5e1e8dc 100644 --- a/der/src/asn1/custom_class.rs +++ b/der/src/asn1/custom_class.rs @@ -164,7 +164,11 @@ where impl Tagged for CustomClassExplicit { 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) } } @@ -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 = ::TAG.is_constructed(); expected_tag_constructed(Class::from(CLASS), TagNumber(TAG), constructed) }