shashikiran - 2013-07-05

Hi,

We are seeing BER decoding for a indefinite length parameters is failing with error 2.

Is decoding of indefinite length supported by asn.1 compiler ?

Here is sample program :

include <stdio.h>

include "asn1cfiles.h"

int main()
{
unsigned char buf[] = {0x30,0x80,0x30,0x22,0x04,0x10,0x27,0xee,0xc8,0x57,0x6e,
0x0e,0x20,0x3c,0xaa,0xbc,0xc9,0xc3,0x55,0x66,0xfd,0x84,0x04,0x04,0x87,0xfd,0xb9,
0x21,0x04,0x08,0xcb,0x5e,0x23,0x6f,0x16,0x6e,0x26,0x10,0x30,0x22,0x04,0x10,0xea,
0x6f,0x83,0x62,0xe7,0x97,0x46,0x82,0xa0,0x71,0xa4,0x4c,0xd2,0xc4,0xc3,0x76,0x04,
0x04,0x7f,0xf6,0x2a,0xfb,0x04,0x08,0x7e,0x07,0x51,0xdb,0x1f,0x59,0x9c,0x6a,0x30,
0x22,0x04,0x10,0x86,0xb1,0x1d,0xd6,0xf6,0xf3,0x6e,0x1e,0x6d,0xe8,0xa9,0x47,0x96,
0xfc,0xb1,0xae,0x04,0x04,0x6e,0x61,0x9e,0x7b,0x04,0x08,0xa3,0xc4,0x78,0x2f,0xd5,0x9e,
0x3a,0x4b,0x00,0x00};

asn_dec_rval_t rval; / Decoder return value /
SendAuthenticationInfoResponse_t Response = 0;
int bytes_read = 112;
rval = ber_decode(0, &asn_DEF_SendAuthenticationInfoResponse, (void
*)&Response, buf, bytes_read);
if (rval.code != RC_OK)
{
printf ("return value = %d\n",rval.code);
printf("Broken decoding at byte %ld \n", (long)rval.consumed);

printf ("Decoder Failed \n");
//return -1;
} else {
/ Return the number of bytes /
printf ("Decoder sucessful : decoded num of bytes = %d\n", bytes_read);
}
xer_fprint(stdout, &asn_DEF_SendAuthenticationInfoResponse, Response);

return 0;
}

Here is the asn.1 spec file:

    SendAuthenticationInfoResponse ::= SEQUENCE SIZE (1..5) OF
    SEQUENCE
    {
         rand       RandomChallenge,
         sres       SignedResponse,
         kc         CipherKey
     }

    RandomChallenge ::=      OCTET STRING (SIZE (16))
    SignedResponse ::=       OCTET STRING (SIZE (4))
    CipherKey      ::=      OCTET STRING (SIZE (8))

Any help is greatly appreciated.

Thanks,
-s