Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » TITAN ASN.1 compiler / BER decoder/ AUTOMATIC TAGS?
TITAN ASN.1 compiler / BER decoder/ AUTOMATIC TAGS? [message #1805403] Sat, 13 April 2019 21:33 Go to next message
Harald Welte is currently offline Harald WelteFriend
Messages: 140
Registered: July 2017
Location: Berlin, Germany
Senior Member

In Osmocom, we wanted to use TITAN also for 3G related tests, not just for 2G. In order to do that, we need support for (among other things) RANAP, which is specified in ASN.1 APER. WE do have an industry-proven ASN.1 compiler/runtime that can do the APER/BER transcoding. However, I simply cannot get TITAN to parse the BER generated by this compiler. Other BER decoders (using the same ASN.1 syntax) can decode that BER without any trouble. Maybe the'yre too tolerant? Or maybe TITAN is too strict?

The error message is:
RANAP_Selftests.ttcn:49: Dynamic test case error: While BER-decoding type '@RANAPMIN.RANAP-PDU': While decoding '@RANAPMIN.RANAP-PDU' type: Alternative 'initiatingMessage': While decoding '@RANAPMIN.InitiatingMessage' type: Component 'value_': While checking tags (expecting [2]): Tag mismatch: Received: [UNIVERSAL 16].


So TITAN is expecting a context-speciifc tag "2" , rather than the UNIVERSAL 16 (used for SEQUENCE). I wonder why that is?

I've been trying to wrap my head around this the first time in June last year, but gave up. I finally found the time to debug a bit further. In order to reduce the complexity, I created a rather simple test case at http://git.osmocom.org/osmo-ttcn3-hacks/tree/asn-test/ranap/min?h=laforge/iu which I also have attached here.

The APER original is '000f4010000001001740095046239134707780f3'O, the BER transcoded value is 'a01c80010f8101013014a0123010800117810101800846239134707780f3'O or in other ("unber") format:

<C O="0" T="[0]" TL="2" V="28">
    <P O="2" T="[0]" TL="2" V="1">&#x0f;</P>
    <P O="5" T="[1]" TL="2" V="1">&#x01;</P>
    <C O="8" T="[UNIVERSAL 16]" TL="2" V="20" A="SEQUENCE">
        <C O="10" T="[0]" TL="2" V="18">
            <C O="12" T="[UNIVERSAL 16]" TL="2" V="16" A="SEQUENCE">
                <P O="14" T="[0]" TL="2" V="1">&#x17;</P>
                <P O="17" T="[1]" TL="2" V="1">&#x01;</P>
                <P O="20" T="[0]" TL="2" V="8">&#x46;&#x23;&#x91;&#x34;&#x70;&#x77;&#x80;&#xf3;</P>
            </C O="30" T="[UNIVERSAL 16]" A="SEQUENCE" L="18">
        </C O="30" T="[0]" L="20">
    </C O="30" T="[UNIVERSAL 16]" A="SEQUENCE" L="22">
</C O="30" T="[0]" L="30">


So
* at offset 0 we have the overall container of the InitiatingMessage
* at offset 2 we have the procedureCode
* at offset 5 we have the criticality
* at offset 8 we have the ProtocolIE-Container
* at offset 12 we have the PermanentNAS-UE-ID
* at offset 14 we have the ProtocolIE-ID
* at offset 17 we have the criticality
* at offset 20 we have the PermanentNAS-UE-ID/IMSI

I honestly believe the "constructed" UNIVERSAL 16 at ofset 8 to be correct, as the ProtocolIE-Container is a SEQUENCE, and SEQUENCE shall be encoded as UNIVERSAL 16, right?

Anyone with detailed ASN.1 BER knowledge who can help?
Re: TITAN ASN.1 compiler / BER decoder/ AUTOMATIC TAGS? [message #1805436 is a reply to message #1805403] Mon, 15 April 2019 10:00 Go to previous messageGo to next message
Harald Welte is currently offline Harald WelteFriend
Messages: 140
Registered: July 2017
Location: Berlin, Germany
Senior Member

It seems like there was a problem in the BER encoder of the [unnamed] prorprieetary ASN.1 compiler I used. It turns out being proprietary doesn't mean it's free of bugs :P

In the end, it may also very well be that the BER rules permit for multiple alternatives (BER is not very strict, unlike DER) and we're seeing an incompatibility.

In any case, I've verified that TITAN is able to consume the BER encoding of OSS Nokalva, so at least those two implementations seem to agree on the BER encoding.

Please don't spend any time following-up on this until I have concluded that in fact there is a problem in TITAN.
Re: TITAN ASN.1 compiler / BER decoder/ AUTOMATIC TAGS? [message #1805441 is a reply to message #1805403] Mon, 15 April 2019 10:38 Go to previous messageGo to next message
Lenard Nagy is currently offline Lenard NagyFriend
Messages: 54
Registered: September 2016
Member
Hi Harald,

First of all, I can not tell You why this BER-encoded PDU is wrong, but I checked it against another BER-decoder from OSS Nokalva (https://asn1.io/asn1playground/) and it sports the same error:

OSS ASN-1Step Version 8.3
Copyright (C) 2018 OSS Nokalva, Inc. All rights reserved.
This product is licensed for use by "OSS Nokalva, Inc."

C0043I: 0 error messages, 0 warning messages and 0 informatory messages issued.


ASN1STEP: Decoding PDU #1 :

RANAP-PDU CHOICE
initiatingMessage InitiatingMessage SEQUENCE: tag = [0] constructed; length = 28
procedureCode ProcedureCode INTEGER: tag = [0] primitive; length = 1
15
criticality Criticality ENUMERATED: tag = [1] primitive; length = 1
1
D0033E: Tag mismatch or tag not expected: [UNIVERSAL 16] (expected tag [2]); check field 'value' (type: OpenType) of field 'initiatingMessage' (type: InitiatingMessage) of PDU #1 'RANAP-PDU'.
*SKIPPED*: tag = [UNIVERSAL 16] constructed; length = 20
<skipped>
D0049E: Field omitted: "value"; check field 'initiatingMessage' (type: InitiatingMessage) of PDU #1 'RANAP-PDU'.
S0012E: Decoding of PDU #1 failed with the return code '5'.

So I think the encoded hex-string must be faulty.

Regards,
Lenard
Re: TITAN ASN.1 compiler / BER decoder/ AUTOMATIC TAGS? [message #1805814 is a reply to message #1805441] Wed, 24 April 2019 14:37 Go to previous messageGo to next message
Harald Welte is currently offline Harald WelteFriend
Messages: 140
Registered: July 2017
Location: Berlin, Germany
Senior Member

Just for your information: the supplier of the asn.1 compiler I used recognized that this is a problem and has meanwhile released a fixed version. Sorry for the noise here.
Re: TITAN ASN.1 compiler / BER decoder/ AUTOMATIC TAGS? [message #1805815 is a reply to message #1805814] Wed, 24 April 2019 14:56 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Hi Harald,

thank you for your feedback.

Best regards
Elemer
Re: TITAN ASN.1 compiler / BER decoder/ AUTOMATIC TAGS? [message #1805817 is a reply to message #1805815] Wed, 24 April 2019 15:34 Go to previous message
Gyorgy Rethy is currently offline Gyorgy RethyFriend
Messages: 31
Registered: April 2015
Member
The reason is:
RANAP-PDU-Descriptions {
...
DEFINITIONS AUTOMATIC TAGS ::=

Automatic tagging is assigning to each SEQUENCE/SET/CHOICE field, without a manually assigned tag, the subsequent context specific implicit tag, starting with [0]. This implicit tag at encoding overwrites the "original" tag of the field, i.e. the type identification tag (in case of explicit tagging the context specific tag would wrap the "type tag").

So, in RANAP Initiating message:
InitiatingMessage ::= SEQUENCE {
procedureCode RANAP-ELEMENTARY-PROCEDURE.&procedureCode ({RANAP-ELEMENTARY-PROCEDURES}),
criticality RANAP-ELEMENTARY-PROCEDURE.&criticality ({RANAP-ELEMENTARY-PROCEDURES}{@procedureCode}),
value RANAP-ELEMENTARY-PROCEDURE.&InitiatingMessage ({RANAP-ELEMENTARY-PROCEDURES}{@procedureCode})
}
automatic tagging will assign the context-specific tag [2] to the field "value", which overwrites the [UNIVERSAL 16] tag of the information element's InitiatingMessage type, identified by the actual value of the procedureCode field .
Previous Topic:Error at Run configuration
Next Topic:How to convert JSON into TTCN-3
Goto Forum:
  


Current Time: Thu Apr 25 17:23:34 GMT 2024

Powered by FUDForum. Page generated in 0.03637 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top