beanit / asn1bean

ASN1bean (formerly known as jASN1) is a Java ASN.1 BER and DER encoding/decoding library
https://www.beanit.com/asn1/
Apache License 2.0
110 stars 45 forks source link

MAP-ExtensionDataTypes cannot be parsed #8

Closed dmv736 closed 6 years ago

dmv736 commented 6 years ago

I am trying to compile MAP-ExtensionDataTypes defined in: https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1585

But I receive following errors:

Parsing ".\MAP-ExtensionDataTypes.asn1" line 24:49: expecting R_BRACE, found 'OPTIONAL' line 25:43: expecting ASSIGN_OP, found '}' line 62:12: expecting R_BRACE, found ',' Exception in thread "main" java.lang.NullPointerException at org.openmuc.jasn1.compiler.parser.ASNParser.assignment(ASNParser.java:845) at org.openmuc.jasn1.compiler.parser.ASNParser.module_body(ASNParser.java:307) at org.openmuc.jasn1.compiler.parser.ASNParser.module_definition(ASNParser.java:187) at org.openmuc.jasn1.compiler.parser.ASNParser.module_definitions(ASNParser.java:63) at org.openmuc.jasn1.compiler.Compiler.getJavaModelFromAsn1File(Compiler.java:99) at org.openmuc.jasn1.compiler.Compiler.main(Compiler.java:82)

Do you know what causes this?

perjd commented 6 years ago

I am getting similar log messages when compiling the ASN.1 modules defined for the PKIX in RFC-5912 (https://tools.ietf.org/html/rfc5912). My ASN.1 understanding is at a beginner's level, but it looks like there is a problem with "optional type references", e.g. '&Params OPTIONAL' in the following structure:

DIGEST-ALGORITHM ::= CLASS { &id OBJECT IDENTIFIER UNIQUE, &Params OPTIONAL, &paramPresence ParamOptions DEFAULT absent } WITH SYNTAX { IDENTIFIER &id [PARAMS [TYPE &Params] ARE &paramPresence ] }

jasn1 version used: 1.9.0

perjd commented 6 years ago

Any chance for a fix for this problem in the near future? Is there a workaround that I could use to make jasn1 work for OCSP-2013-08 or OCSP-2013-88?

sfeuerhahn commented 6 years ago

I finally fixed this in 427302e. Let me know if you still have problems. Sorry for the late response

romanovs commented 6 years ago

in the original message of this issue I can see strange logs like: _line 25:43: expecting ASSIGN_OP, found '}' line 62:12: expecting RBRACE, found ','

Is it ok? Are they warning or errors? I think you fixed only the first log line: _line 24:49: expecting RBRACE, found 'OPTIONAL'

and the original issue with NullPointerException still exists

sfeuerhahn commented 6 years ago

Thanks for letting me know. Commit 06896e3 should now fix the 2nd issue.

romanovs commented 6 years ago

thank you! now logs look much cleaner. But still. From the same specification, could you please take a look at these issues, which end with the NPE (ASNParser.java:770): Attribute-ASN1Module.asn line 211:18: expecting R_BRACE, found '{' line 211:24: unexpected token: 0 line 211:25: expecting ASSIGN_OP, found ',' line 211:34: unexpected token: 0 line 211:35: expecting ASSIGN_OP, found '}' line 212:19: unexpected token: { line 212:20: expecting ASSIGN_OP, found 'hour' line 212:36: unexpected token: 59 line 212:38: expecting ASSIGN_OP, found '}' line 218:19: expecting R_BRACE, found ''1111111'B' line 220:1: expecting ASSIGN_OP, found '}'

defaultIntervalsOfDay IntervalsOfDay ::= { 211: {intervalStart {hour 0, minute 0}, 212: intervalEnd {hour 23, minute 59}} } defaultWeekMask WeekMask ::= { 218: {daysOfWeek '1111111'B, 219: intervalsOfDay defaultIntervalsOfDay} }

CAP-datatypes.asn: line 102:3: unexpected token: errorCode line 187:25: unexpected token: CAMELOperationLocalvalue

ReturnError ::= SEQUENCE { invokeID InvokeIdType, 102: errorCode ERROR, parameter ReturnErrorParameter OPTIONAL } 187: OperationLocalvalue ::= CAMELOperationLocalvalue

Thanks

sfeuerhahn commented 6 years ago

can you post the asn1 files you are having trouble with?

romanovs commented 6 years ago

Regards

Attribute-ASN1Module.asn.txt CAP-datatypes.asn.txt

sfeuerhahn commented 6 years ago

I commited a fix 3adcf60 and removed a few value definitions which the compiler has trouble with and which are ignored anyways:

-defaultIntervalsOfDay IntervalsOfDay ::= {

-defaultStopTime StopTime ::= continual:NULL +--defaultStopTime StopTime ::= continual:NULL

-defaultWeekMask WeekMask ::= {

-leg1 LegType ::= '01'H -leg2 LegType ::= '02'H +--leg1 LegType ::= '01'H +--leg2 LegType ::= '02'H

now it is missing a module for import

romanovs commented 6 years ago

yes, the bunch of asn1 files consists of 52 files. They are asn1-files related to the topic starter's link (3gpp spec). I attached a ZIP-file with all of them.

3GPP-CDR.zip

Regards

sfeuerhahn commented 6 years ago

ok thanks. The compile errors I am getting seem to be caused by value definitions. So if you remove those it may be compiling without errors. In the future I will try to change jASN1 so that it no longer throws errors on those value definitions

regards