Putting in a
print "$data"statement after your $data assignment quickly shows that you may have the pack statement incorrect. I would expect to see "0" - the hex equivalent of '30' after it's 'pack'd. 30 is an ASN.1 SEQUENCE data type, which would be the start of your ASN.1 prepare method.
$data = pack("H*",$data); print "$data\n";
That 'works' better for me in that the data is now as I'd expect the hex translation to be. Of course, the ASN.1 prepare statement you're using doesn't look correct to me. Your data: 3084 ... starts with 30 (which would be 'PasswordPolicyResponseValue ::= SEQUENCE') but the 84 isn't an ASN.1 type that I know.
UPDATE: Been a while since I worked with this for SNMP decodes - 84 is the length of the SEQUENCE and your $data certainly isn't 0x84 (132) octets long.
Have a look at http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One which explains ASN.1 coding. The example they give translates to your app with the following:
... $asn->prepare(" FooQuestion ::= SEQUENCE { trackingNumber INTEGER, question IA5String } ") or die($asn->error); $data = "3013020105160e416e79626f64792074686572653f"; $data = pack("H*",$data); print "$data\n" ...
That should run successfully as an example for you.
{C} > test 0‼Ç☺♣♦♫Anybody there? $VAR1 = \{ 'question' => 'Anybody there?', 'trackingNumber' => 5 };
In reply to Re: Using Convert::ASN1 to decode an LDAP control
by VinsWorldcom
in thread Using Convert::ASN1 to decode an LDAP control
by Latro
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |