Convert-ASN1 - user specified tag and constructed value

Posted on Sun Aug 20 11:20:46 2006 by tippa
user specified tag and constructed value
Hi!
I don't get how to specify correctly, so that the decode() understand the constructed form of value, when there is some (user specified) tag before OCTET STRING.

For example this little sript:
---------------------------------------------
#!/usr/bin/perl use Convert::ASN1; my $asn = Convert::ASN1->new or warn $asn->error; my $asn1description = " str [1] OCTET STRING "; $asn->prepare($asn1description) or warn $asn->error; my $buf = pack('C*', 0x81, 0x0a, 0x04, 0x03, 0x61, 0x62, 0x63, 0x04, 0x03, 0x64, 0x65, 0x66 ); my $ret = $asn->decode($buf) or warn $asn->error; print "Result in HEX: " . unpack("H*", $ret->{str}) . ".\n";

---------------------------------------------
prints to the output:
"Result in HEX: 04036162630403646566."

If I specify the first octet in BER-encoded data as "0xa1", so that the "constructed bit" is 1, then I just get "decode error 2 12 at /usr/lib/perl5/site_perl/5.8.8/Convert/ASN1/_decode.pm line 232."

The output which I should like to have: "Result in HEX: 616263646566." (ascii "abcdef")

If I dont have the "[1]" in $asn1description, then the tag "24" works fine (as I expected).

So, what to do? Kave I missed something?

Best Regards tippa
Write a response