asn1bean icon indicating copy to clipboard operation
asn1bean copied to clipboard

Implemented decodeString method in BerOctetString

Open elFarto opened this issue 7 months ago • 0 comments

A decodeString method is introduced to allow the decoding of constructed strings. This method requires that a tag is passed in so that it can be determined at runtime whether the string is constructed or not.

Obviously this method needs changes to the compiler to make use of it. I have those changes, but they're intermingled with all the other changes I had to make to get the X.400 ASN1 files I have compiling. This is the only change I needed to make to the parsing library itself.

The changes to the compiler I have produce code like this:

if (berTag.equals(BerIA5String.tag) || berTag.equals(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, BerTag.IA5_STRING_TAG)) {
   data = new IA5TextData();
   vByteCount += data.decodeString(is, berTag);

This isn't a particually nice way to solve this issue, but I didn't see any easier solution given how this library is architected (i.e. assuming a single tag for a value). I'm not an expert in ASN.1, but it's possible that the primitive field in the BerTag shouldn't be apart of the equals method, but we'd still need to pass the tag into the decode method so it knows what it's decoding.

elFarto avatar May 19 '25 09:05 elFarto