Subject: | support for bind's new private key file |
Somewhere near bind 9.7 they started adding new fields to the
private-key file format to track dates. This patch adds support for
those new fields (and no longer dies when trying to parse the file).
Subject: | v0.16-v1.3-private-key-format.patch |
diff --git a/SEC/Private.pm b/SEC/Private.pm
index 52dd298..bcdc5b8 100644
--- a/SEC/Private.pm
+++ b/SEC/Private.pm
@@ -26,7 +26,8 @@ sub new {
my $self={};
my ($Modulus,$PublicExponent,$PrivateExponent,$Prime1,
$Prime2,$Exponent1,$Exponent2,$Coefficient,
- $prime_p,$subprime_q,$base_g,$private_val_x,$public_val_y);
+ $prime_p,$subprime_q,$base_g,$private_val_x,$public_val_y,
+ $Created, $Publish, $Activate);
bless ($self,$class);
@@ -51,7 +52,7 @@ sub new {
while (<KEYFH>) {
if (/Private-key-format: (v\d*\.\d*)/) {
- if ($1 ne "v1.2") {
+ if ($1 ne "v1.2" && $1 ne "v1.3") {
croak "Private Key Format not regognized";
}
}elsif (/^Algorithm:\s*(\d*)/) {
@@ -87,7 +88,14 @@ sub new {
$private_val_x=decode_base64($1);
} elsif (/^Public_value\(y\):\s*(\S+)/) {
$public_val_y=decode_base64($1);
- }
+ } elsif (/^Created\(y\):\s*(\S+)/) {
+ $Created=$1;
+ } elsif (/^Publish\(y\):\s*(\S+)/) {
+ $Publish=$1;
+ } elsif (/^Activate\(y\):\s*(\S+)/) {
+ $Activate=$1;
+ }
+
}
close(KEYFH);
@@ -130,6 +138,14 @@ sub new {
$private_dsa->set_pub_key($public_val_y);
$self->{"privatekey"}=$private_dsa;
}
+
+ if (defined($Created)) {
+ # new fields in v1.3
+ $self->{'created'} = $Created;
+ $self->{'publish'} = $Publish;
+ $self->{'activate'} = $Activate;
+ }
+
return $self;
}
@@ -162,6 +178,24 @@ sub signame {
}
+sub created {
+ my $self=shift;
+ return $self->{'created'} if (exists($self->{'created'}));
+}
+
+
+sub publish {
+ my $self=shift;
+ return $self->{'publish'} if (exists($self->{'publish'}));
+}
+
+
+sub activate {
+ my $self=shift;
+ return $self->{'activate'} if (exists($self->{'activate'}));
+}
+
+
# Little helper function to put a BigInt into a binary (unsigned,
#network order )
@@ -356,14 +390,19 @@ or Crypt::OpenSSL::DSA object. This is really only relevant to the
Net::DNS::RR::SIG class.
-=head2 algorithm, keytag, signame
+=head2 algorithm, keytag, signame, created, publish, activate
$private->algorithm
$private->keytag
$private->signame
+ $private->created
+ $private->publish
+ $private->activate
Returns components as determined from the filename and needed by
-Net::DNS::RR::RRSIG.
+Net::DNS::RR::RRSIG. The 'created', 'publish' and 'activate'
+components are only available in version 1.3 or higher formatted
+files.
=head1 RSASHA1 specific helper functions