Show quoted text
Sorry
Show quoted text> Are you trying to read the attached file or are you trying to parse it ?
Parse :)
Show quoted text> A small example perl script that demonstrates the problem would help
> a lot in seeing all the inputs and the outputs so I can at least
> identify where the problem is.
OK, I've tried to make it more abstract, but probably I was wrong.
Show quoted text> You also did not state which version you are using. Are you sure you
> are running the latest released on CPAN
I've just upgraded to latest 0.21
Well, my try #2.
You can see example file has ten zero bytes at the end (remember for future !)
And file begins with (in hex)
3080 0609 2A 86 48 86 F7 0D 01 07 03 A080 3080 ...
So it has sequence (30) indefinite (80), after that - object
identifier (0609 2A 86 48 86 F7 0D 01 07 03), then - Tag [0] field
(A0) indefinite (80), then indef.seq. (3080) again.
Some code (test.pl)
use Data::Dumper;
use Convert::ASN1;
binmode(STDOUT);
local $/;
my $asn = Convert::ASN1->new;
$asn->prepare('A ::= SEQUENCE { oid OBJECT IDENTIFIER, s [0] EXPLICIT ANY}
B ::= SEQUENCE OF ANY');
my $d = $asn->find('A')->decode(<>);
print Dumper($d);
print Dumper($asn->find('B')->decode($d->{'s'}));
Use "test.pl cpro.der > dump" and look into dump (hex view).
Second Dumper prints undef. And it is easy to say why - look at the
end of field "s" in first Dumper. I has only 4 zero bytes. But (do
remember?!) we have had 10 zero bytes at the end of original file.
Parsing type A we "open" 2 "containers" - first sequence and second
tag[0] - it must be 10-4=6 zero bytes at the end of "s".
Moreover, look at output of
$asn->prepare('A ::= SEQUENCE { oid OBJECT IDENTIFIER, s [0] EXPLICIT
SEQUENCE OF ANY}');
print Dumper( $asn->find('A')->decode(<>) );
- it prints normally parsed sequence in "s" !
I hope I've write a bit better :)
Sorry if I've messed you again, please ask anything - I'll try my best.
Thanx!