Subject: | [0] EXPLICIT |
Date: | Wed, 27 May 2009 20:27:05 +0400 |
To: | bug-Convert-ASN1 [...] rt.cpan.org |
From: | Leo Cherepanov <grey.leo [...] gmail.com> |
Hello.
Something strange happens parsing tagged fields.
May be I can not "cook" :) it ?..
Here is an example
use strict;
use warnings;
use Convert::ASN1; #ver. 0.22
use Data::Dumper;
my $b='A0820003020109'; # hex
my $der= pack('H'.length($b),$b);
# schema (asn1dump)
# 0 3: [0] {
# 4 1: INTEGER 9
# : }
my $asn = Convert::ASN1->new;
$asn->prepare(<<ASN1);
Test1 ::= CHOICE {
test ANY
}
Test2 ::= CHOICE {
test [0] ANY
}
Test3 ::= CHOICE {
test [0] EXPLICIT ANY
}
Test4 ::= CHOICE {
test [0] INTEGER
}
Test5 ::= CHOICE {
test [0] EXPLICIT INTEGER
}
ASN1
my $node;
binmode(STDOUT);
for(1 .. 5){
$node=$asn->find("Test$_");
print Dumper($node->decode($der));
}
It prints
$VAR1 = {
'test' => 000000 # original hex string is really here, but
been ate by gmail
};
$VAR1 = undef;
$VAR1 = {};
$VAR1 = undef;
$VAR1 = {};
So, without EXPLICIT addition it fails totally (undef), but with
EXPLICIT it fails anyway.
Thank you!