added missing upstream files
[tridge/bind9.git] / contrib / pkcs11-keygen / keydump.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Getopt::Std;
5 use Crypt::OpenSSL::RSA;
6 use Net::DNS::SEC;
7
8 my %option;
9 getopts('k:p:o:h',\%option);
10
11 $option{h} || (not defined $option{k}) || (not defined $option{p}) || (not defined $option{o}) && die "usage: keydump.pl -k Kxxx.key -p Kxxx.priv -o pem\n";
12
13 my $rsa = Net::DNS::SEC::Private->new($option{p});
14
15 open(PFILE, "> $option{o}");
16 print PFILE $rsa->dump_rsa_private_der;
17 close(PFILE);
18
19 open(KFILE, "< $option{k}");
20 my @fc = <KFILE>;
21 close(KFILE);
22
23 my $keyrr = Net::DNS::RR->new(join "", @fc);
24
25 print $keyrr->flags;
26