Skip to content

Workaround for unsupported RELATIVE-OID #97

@scy

Description

@scy

Hi there! First of all, thanks for this library.

I have a DTD for a standard I don’t control. It uses the RELATIVE-OID type, which is not supported by asn1tools, probably because the underlying pyasn not supporting it yet.

For my application I need to be able to decode and encode messages with RELATIVE-OID fields. However, I could live with handling them as bytes values and splitting them on my own or whatever. Which is why I’ve tried simply hacking RELATIVE-OID ::= [UNIVERSAL 13] OCTET STRING into the DTD. This will parse successfully, but when I try to decode a message, I get:

[stack abridged to only include the asn1tools part]
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/compiler.py", line 163, in decode
    decoded = type_.decode(data)
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/codecs/ber.py", line 1482, in decode
    return self._type.decode(bytearray(data), 0)[0]
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/codecs/ber.py", line 1423, in decode
    values, end_offset = self.inner.decode(data, offset)
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/codecs/ber.py", line 1120, in decode
    decoded, offset = member.decode(data, offset)
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/codecs/ber.py", line 717, in decode
    decoded_element, offset = self.element_type.decode(data, offset)
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/codecs/ber.py", line 1423, in decode
    values, end_offset = self.inner.decode(data, offset)
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/codecs/ber.py", line 1120, in decode
    decoded, offset = member.decode(data, offset)
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/codecs/ber.py", line 594, in decode
    end_offset)
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/codecs/ber.py", line 659, in decode_member
    raise e
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/codecs/ber.py", line 647, in decode_member
    value, offset = member.decode(data, offset)
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/codecs/ber.py", line 1423, in decode
    values, end_offset = self.inner.decode(data, offset)
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/codecs/ber.py", line 1412, in decode
    offset = self.decode_tag(data, offset)
  File "/home/scy/.local/lib/python3.6/site-packages/asn1tools/codecs/ber.py", line 397, in decode_tag
    offset)
asn1tools.codecs.DecodeTagError: path: Expected RELATIVE-OID with tag '2d' at offset 10, but got '0d'.

So, the message that I’m receiving encodes RELATIVE-OID with a tag of 0d (i.e. universal primitive 13), but asn1tools expects 2d (universal constructed 13), right?

My knowledge of ASN.1 is pretty limited and I openly admit that I don’t really know what I’m doing. Can you help me out?

My project is commercial but rather time-critical right now. (Read: I need to fix this somehow within the next 24 hours.) I’m open to discussing compensation for your time if you’d like and I’ve already tried to contact you via Twitter about it. Of course I know that this is an open source project and I can’t expect anything, I’m merely asking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions