Reputation: 11
We have received a specifications document for CDR encoded in TLV from a vendor and we are trying to build a parser for it. According to them, their CDR is formatted as per ASN.1 BER encoding. However when asked for ASN.1 specification file, they said they didn't have it and that their document is all they had.
Although not that versed into ASN.1 syntax, I am trying to reverse engineer that specs into ASN.1 specifications.
Their tags and length can be coded either over 1 or 2 bytes.
Let me share the first few bytes of some sample records:
804e 8060 8002 805c 010100 02089999999999999999 ...
804e 8066 8002 8062 010101 02089999999999999999 ...
First of all, is this really compliant to BER ASN.1? Because after reading A Layman's Guide to a Subset of ASN.1, BER, and DER, for a tag to be 2-bytes (or more) the bits 5-1 of the first byte must be set to 1, and 804e and 8002 don't fit this.
Secondly, how can I convert the above format into an ASN.1 specification?
Thank you.
Upvotes: 1
Views: 1174
Reputation: 1978
It's common for CDR data to consist of some non-ASN.1 data (file headers and record headers) along with ASN.1 data. For example, 3GPP TS 32.297.
You can parse BER only to a limited degree without the specification. If any implicit tagging is used (almost certainly it is), you won't know the actual types. You also won't know the semantics of any of the values you do know the types of.
You most certainly cannot infer the specification from a sample of encoded data, anymore than you can determine all legal English sentences by looking at one sentence. In particular, any use of a CHOICE type would be perplexing, to say the least.
Insist on receiving the ASN.1 specification or being told what standard is being used, if one is.
Upvotes: 2
Reputation: 10008
First of all, is this really compliant to BER ASN.1?
You can use https://asn1.io/asn1playground/ (you don't need a specification to decode a BER value)
Secondly, how can I convert the above format into an ASN.1 specification?
No.
Upvotes: 1