Skip to content

ASN1ObjectIdentifier.encode() writes the first sub-identifier as one byte (2.48 → 0x80, 2.999.3 loses a byte) #267

Open

Description

@bardrop

ASN1ObjectIdentifier.encode() writes the first sub-identifier (40 * X + Y) as one byte. When the first arc is 2, Y has no upper bound, so this value can be 128 or more, and then it needs base-128 encoding like the other arcs (X.690 8.19.4). Arcs like this are in use: 2.48 (cybersecurity), 2.49 (alerting), and the example arc 2.999.

ASN1ObjectIdentifier.fromIdentifierString('2.48').encode()     // 06 01 80    -> should be 06 02 81 00
ASN1ObjectIdentifier.fromIdentifierString('2.999.3').encode()  // 06 02 37 03 -> should be 06 03 88 37 03

Decoding is already correct (06 03 88 37 03 → 2.999.3), so a decode → encode round trip changes the OID.

The fix is to run objectIdentifier[0] * 40 + objectIdentifier[1] through the same base-128 loop as the other arcs in lib/asn1/primitives/asn1_object_identifier.dart. For reference, the same bug in asn1lib is wstrange/asn1lib#81. pointycastle 4.0.0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions