summaryrefslogtreecommitdiffstats
path: root/contrib/pkcs11-keygen/keydump.pl
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/pkcs11-keygen/keydump.pl')
-rwxr-xr-xcontrib/pkcs11-keygen/keydump.pl26
1 files changed, 26 insertions, 0 deletions
diff --git a/contrib/pkcs11-keygen/keydump.pl b/contrib/pkcs11-keygen/keydump.pl
new file mode 100755
index 0000000..acbb00c
--- /dev/null
+++ b/contrib/pkcs11-keygen/keydump.pl
@@ -0,0 +1,26 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Getopt::Std;
+use Crypt::OpenSSL::RSA;
+use Net::DNS::SEC;
+
+my %option;
+getopts('k:p:o:h',\%option);
+
+$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";
+
+my $rsa = Net::DNS::SEC::Private->new($option{p});
+
+open(PFILE, "> $option{o}");
+print PFILE $rsa->dump_rsa_private_der;
+close(PFILE);
+
+open(KFILE, "< $option{k}");
+my @fc = <KFILE>;
+close(KFILE);
+
+my $keyrr = Net::DNS::RR->new(join "", @fc);
+
+print $keyrr->flags;
+