help-libtasn1
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: asn1Decoding(1) fails to decode a CHOICE?


From: Ivan Shmakov
Subject: Re: asn1Decoding(1) fails to decode a CHOICE?
Date: Sat, 06 Oct 2012 20:58:02 +0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

>>>>> Nikos Mavrogiannopoulos <address@hidden> writes:
>>>>> On 10/04/2012 08:09 AM, Ivan Shmakov wrote:

 >> It seems like asn1Decoding(1) (as of 2.13 debian 2; though there
 >> don't seem to be any relevant entries in the log [1] in between 2.13
 >> and 2.14) fails to decode a CHOICE.  Consider, e. g.:

 >> $ asn1Decoding \
 >>       <(printf %s\\n \
 >>             'Example { } DEFINITIONS EXPLICIT TAGS ::=' \
 >>             BEGIN \
 >>             'Foo ::= CHOICE { bar [0] INTEGER, baz [1] INTEGER }' \
 >>             END) \
 >>       <(printf '\x80\x01\x2a') \
 >>       Example.Foo 
 >> Parse: done.

 > Is the structure you have correct?

        If it's the input data that's meant here, then I presume so.
        I've generated it with Perl's Convert::ASN1 module, like:

$ perl -we 'use strict;
            require Convert::ASN1;
            require IO::Handle;
            my $asn
                = Convert::ASN1->new ();
            $asn->prepare (q {
                Foo ::= CHOICE { bar [0] INTEGER, baz [1] INTEGER }
            })
                or die ();
            my $out
                = \*STDOUT;
            binmode ($out);
            my $enc
                = $asn->encode ({ qw (baz 42) })
                or die ($asn->error ());
            print $out ($enc);' \
      | od -t x1 

        I haven't yet checked it against the specification.

 > Where is the actual integer stored?

        The integer is 42 decimal, or 2A hexadecimal, and it's stored as
        the third (and the last) octet of the sequence.

[…]

 > The asn1Coding tool is pretty primitive and needs a lot of changes to
 > be of any use.

        Perhaps it'd be simpler to implement a better tool on top of
        Perl's Convert::ASN1 instead…

-- 
FSF associate member #7257




reply via email to

[Prev in Thread] Current Thread [Next in Thread]