Skip to content

Conversation

dishmaker
Copy link
Contributor

@dishmaker dishmaker commented Jun 23, 2025

Resolves #1835

I made sure it does not add any runtime overhead, even when using the "clarify" feature.

This PR is initial support.
In future I'd like to add Sequence field names in comments, as well as OID pretty-printing.

Examples

Rust:

        hex!(
            "30 51" // tag: SEQUENCE len: 81 type: OneAsymmetricKey
                "02 01" // tag: INTEGER type: u8
                        "01"
                "30 0D" // tag: SEQUENCE len: 13 type: AlgorithmIdentifier
                        "06 07" // tag: OBJECT IDENTIFIER type: ObjectIdentifier
                                "2A 03 04 05 06 07 08"
                        "A0 02" // tag: CONTEXT-SPECIFIC [0] (constructed) type: AnyRef
                                "AA BB"
                "04 1C" // tag: OCTET STRING len: 28 type: OctetStringRef
                        "00 11 22 33 00 11 22 33 00 11 22 33 00 11 22 33
                         00 11 22 33 00 11 22 33 00 11 22 33"
                "" // end: OctetStringRef
                "A1 1F" // tag: CONTEXT-SPECIFIC [1] (constructed) len: 31 type: ContextSpecificRef<BitStringRef>
                        "03 1D" // tag: BIT STRING len: 29 type: BitStringRef
                                "00"
                                "44 55 66 77 44 55 66 77 44 55 66 77 44 55 66 77
                                 44 55 66 77 44 55 66 77 44 55 66 77"
                        "" // end: BitStringRef
                "" // end: ContextSpecificRef<BitStringRef>
            "" // end: OneAsymmetricKey
        );

XML:

30 51 <!-- tag: SEQUENCE len: 81 type: OneAsymmetricKey -->
        02 01 <!-- tag: INTEGER type: u8 -->
                01
        30 0D <!-- tag: SEQUENCE len: 13 type: AlgorithmIdentifier -->
                06 07 <!-- tag: OBJECT IDENTIFIER type: ObjectIdentifier -->
                        2A 03 04 05 06 07 08
                A0 02 <!-- tag: CONTEXT-SPECIFIC [0] (constructed) type: AnyRef -->
                        AA BB
        04 1C <!-- tag: OCTET STRING len: 28 type: OctetStringRef -->
                00 11 22 33 00 11 22 33 00 11 22 33 00 11 22 33
                00 11 22 33 00 11 22 33 00 11 22 33
         <!-- end: OctetStringRef -->
        A1 1F <!-- tag: CONTEXT-SPECIFIC [1] (constructed) len: 31 type: ContextSpecificRef<BitStringRef> -->
                03 1D <!-- tag: BIT STRING len: 29 type: BitStringRef -->
                        00
                        44 55 66 77 44 55 66 77 44 55 66 77 44 55 66 77
                        44 55 66 77 44 55 66 77 44 55 66 77
                 <!-- end: BitStringRef -->
         <!-- end: ContextSpecificRef<BitStringRef> -->
 <!-- end: OneAsymmetricKey -->

@dishmaker dishmaker changed the title der: clarify writer draft [WIP] der: clarify writer draft Jun 23, 2025
@dishmaker dishmaker changed the title [WIP] der: clarify writer draft der: clarify writer: add pretty-printing DER hex with comments Jul 11, 2025
@dishmaker dishmaker marked this pull request as ready for review July 11, 2025 12:37
@dishmaker dishmaker force-pushed the dishmaker/der_clarify branch from bafcc37 to 78f1035 Compare July 21, 2025 09:41
@dishmaker dishmaker force-pushed the dishmaker/der_clarify branch from 78f1035 to 6abcbf8 Compare July 21, 2025 09:45
@dishmaker
Copy link
Contributor Author

I removed the dependency on tynm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

der: add ClarifyWriter
2 participants