Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Convert-ASN1 CPAN distribution.

Report information
The Basics
Id: 46417
Status: resolved
Priority: 0/
Queue: Convert-ASN1

People
Owner: Nobody in particular
Requestors: grey.leo [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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!
This is fixed in 0.24 Convert::ASN1 has always defaulted to IMPLICIT tagging, which is why Test2 and Test4 fail Test3 and Test5 now both work 0.24 has a constructor option to default to explicit tagging. With that enabled all tests succeed to decode. This is the output with $Data::Dumper::Useqq=1; $VAR1 = { "test" => "\240\202\0\3\2\1\t" }; $VAR1 = { "test" => "\2\1\t" }; $VAR1 = { "test" => "\2\1\t" }; $VAR1 = { "test" => 9 }; $VAR1 = { "test" => 9 };