On 10/06/2012 03:58 PM, 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.


I don't see any integer there with "openssl asn1parse".

>  > 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…


Could be but I've never needed that tool. Maybe given its limitations it
is a good idea to even remove it. When I need to generate structures I
use libtasn1 directly.

regards,
Nikos

Reply via email to