I can dump the data, but it doesnt really help me figuring out how a ASN.1 bitstring is stored in a perl variable.
The minimal example (The "key.pem.pub" file is the public part of an RSA key generated by openssl genrsa).
#!/usr/bin/perl -w
use Data::Dumper;
use Convert::PEM;
my $pem = Convert::PEM->new(
Name => "PUBLIC KEY",
ASN => qq(
AlgorithmIdentifier ::= SEQUENCE {
algorithm OBJECT IDENTIFIER,
parameters ANY DEFINED BY algorithm OPTIONAL }
SubjectPublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier,
subjectPublicKey BIT STRING
}
))
or die "New failed: ", Convert::PEM->errstr;
my $key = $pem->read(Filename => "key.pem.pub")
or die "Decryption failed: ", $pem->errstr;
print "$key->{algorithm}\n";
print "$key->{subjectPublicKey}\n";
print Dumper($key->{subjectPublicKey});
The output is (as seen in vi) not very pretty :
HASH(0x9745798)
ARRAY(0x97457a8)
$VAR1 = [
'0<82>^A^H^B<82>^A^A^@²tº]u<9b>|M?)^?Ræ<9c>Úö)B<86>úçh<99><
+94>ñ7^P«®Êð<83>r^XßNϵd<86>D^K^V^Bý^A^G AÿÒN©<99>ï¨:<9b><94>^^k
<85>xö4*%ÿ§^Sö<91>º"<83>
a^S<82>Ö³[u.×Ù<86>FQ<82>ËN^F#ê<9b>·¼Ô0^\iºÍCt¡ý<8f>õë!4Wc<95> Àêá÷^W
+7>åé<
^SùD^\*¤<96>Ñ^¯<92>Á^_«Ö1RZ<81>^N^Q<82><83>
^A!^O^A^QÙz}Ù°ï<
ï¼<9e>ä^XZu1r^Wæ^_ç¡ê¼<94>]^F<83>éûvô<8c>¸ùüý<99>fÿ\\7v<83>Ù<91><89>8<
+96>~<96>b<8e>ßÞ$;r<91>Ê4ßÞ\'̲)þ^Fl~õ]Êá]`20ý^?^^¿.!òzy0<9a>^L<90><80
+><9f>e<9b>^B^A#',
2144
];
The BIT STRING is supposed to be the DER encoding of some other ASN.1 structure.
Thank you. |