[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
asn1Decoding(1) fails to decode a CHOICE?
From: |
Ivan Shmakov |
Subject: |
asn1Decoding(1) fails to decode a CHOICE? |
Date: |
Thu, 04 Oct 2012 13:09:40 +0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
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.
Decoding: DER_ERROR
asn1Decoding:
DECODING RESULT:
$
On the contrary, Perl's Convert::ASN1 [2] decodes it just fine:
$ perl -we 'use strict;
require Convert::ASN1;
require Data::Dump;
my $asn = Convert::ASN1->new ();
$asn->prepare (q {
Foo ::= CHOICE { bar [0] INTEGER, baz [1] INTEGER }
}) or die ();
foreach my $enc ("\x80\x01\x2a", "\x81\x01\x2a") {
my $dec
= $asn->decode ($enc)
or die ($asn->error ());
print STDOUT (Data::Dump::dump ($enc, $dec), "\n");
}'
("\x80\1*", { bar => 42 })
("\x81\1*", { baz => 42 })
$
Also, the documentation doesn't seem to mention on how to encode
a CHOICE with asn1Coding(1) [3], and just omitting the “unused”
element(s) leads to a failure.
[1] http://git.savannah.gnu.org/gitweb/?p=libtasn1.git;a=shortlog
[2] http://search.cpan.org/dist/Convert-ASN1/
[3]
http://www.gnu.org/software/libtasn1/manual/html_node/Invoking-asn1Coding.html
--
FSF associate member #7257
- asn1Decoding(1) fails to decode a CHOICE?,
Ivan Shmakov <=
- Re: asn1Decoding(1) fails to decode a CHOICE?, Nikos Mavrogiannopoulos, 2012/10/06
- Re: asn1Decoding(1) fails to decode a CHOICE?, Ivan Shmakov, 2012/10/06
- Re: asn1Decoding(1) fails to decode a CHOICE?, Nikos Mavrogiannopoulos, 2012/10/06
- Re: asn1Decoding(1) fails to decode a CHOICE?, Ivan Shmakov, 2012/10/06
- Re: asn1Decoding(1) fails to decode a CHOICE?, Nikos Mavrogiannopoulos, 2012/10/07
- Re: asn1Decoding(1) fails to decode a CHOICE?, Ivan Shmakov, 2012/10/07
- Re: asn1Decoding(1) fails to decode a CHOICE?, Nikos Mavrogiannopoulos, 2012/10/07
- PRIVATE tags handling, Ivan Shmakov, 2012/10/08
- [SOLVED] PRIVATE tags handling, Ivan Shmakov, 2012/10/08
asn1Coding(1) a CHOICE, Ivan Shmakov, 2012/10/08