From c5448f3d94ec5ab4962ac22f662fdb7d654bc333 Mon Sep 17 00:00:00 2001 From: Mike Pultz Date: Thu, 8 Oct 2020 11:16:29 -0400 Subject: [PATCH] - added the SHA256, SHA384, and GOST digest defines to Lookups.php. - fixed Net_DNS2_RR_DS so it will be able to support other digest definitions without any other changes. --- Net/DNS2/Lookups.php | 8 +- Net/DNS2/RR/DS.php | 32 ++----- package.php | 2 + package.xml | 200 +++++++++++++++++++++++-------------------- 4 files changed, 122 insertions(+), 120 deletions(-) diff --git a/Net/DNS2/Lookups.php b/Net/DNS2/Lookups.php index e7586dc..aa496f1 100644 --- a/Net/DNS2/Lookups.php +++ b/Net/DNS2/Lookups.php @@ -204,6 +204,9 @@ class Net_DNS2_Lookups */ const DNSSEC_DIGEST_RES = 0; const DNSSEC_DIGEST_SHA1 = 1; + const DNSSEC_DIGEST_SHA256 = 2; + const DNSSEC_DIGEST_GOST = 3; + const DNSSEC_DIGEST_SHA384 = 4; /* * The packet id used when sending requests @@ -491,7 +494,10 @@ class Net_DNS2_Lookups public static $digest_id_to_name = [ self::DNSSEC_DIGEST_RES => 'RES', - self::DNSSEC_DIGEST_SHA1 => 'SHA-1' + self::DNSSEC_DIGEST_SHA1 => 'SHA-1', + self::DNSSEC_DIGEST_SHA256 => 'SHA-256', + self::DNSSEC_DIGEST_GOST => 'GOST-R-34.11-94', + self::DNSSEC_DIGEST_SHA384 => 'SHA-384' ]; /* diff --git a/Net/DNS2/RR/DS.php b/Net/DNS2/RR/DS.php index 80d8132..401f483 100644 --- a/Net/DNS2/RR/DS.php +++ b/Net/DNS2/RR/DS.php @@ -61,8 +61,7 @@ class Net_DNS2_RR_DS extends Net_DNS2_RR */ protected function rrToString() { - return $this->keytag . ' ' . $this->algorithm . ' ' . - $this->digesttype . ' ' . $this->digest; + return $this->keytag . ' ' . $this->algorithm . ' ' . $this->digesttype . ' ' . $this->digest; } /** @@ -100,30 +99,12 @@ protected function rrSet(Net_DNS2_Packet &$packet) // // unpack the keytag, algorithm and digesttype // - $x = unpack('nkeytag/Calgorithm/Cdigesttype', $this->rdata); + $x = unpack('nkeytag/Calgorithm/Cdigesttype/H*digest', $this->rdata); $this->keytag = $x['keytag']; $this->algorithm = $x['algorithm']; $this->digesttype = $x['digesttype']; - - // - // figure out the digest size - // - $digest_size = 0; - if ($this->digesttype == 1) { - - $digest_size = 20; // SHA1 - - } else if ($this->digesttype == 2) { - - $digest_size = 32; // SHA256 - } - - // - // copy the digest - // - $x = unpack('H*', substr($this->rdata, 4, $digest_size)); - $this->digest = $x[1]; + $this->digest = $x['digest']; return true; } @@ -146,16 +127,13 @@ protected function rrGet(Net_DNS2_Packet &$packet) { if (strlen($this->digest) > 0) { - $data = pack( - 'nCCH*', - $this->keytag, $this->algorithm, $this->digesttype, $this->digest - ); + $data = pack('nCCH*', $this->keytag, $this->algorithm, $this->digesttype, $this->digest); $packet->offset += strlen($data); return $data; } - + return null; } } diff --git a/package.php b/package.php index 362e295..344f15f 100644 --- a/package.php +++ b/package.php @@ -42,11 +42,13 @@ "- added Net_DNS2::closeSockets(), which lets you close all cached network sockets in the resolver object.\n" . "- added Net_DNS2::getSockets(), which returns the local sockets cache array.\n" . "- added date_created and date_last_used to the Net_DNS2_Socket object, to track usage stats on each socket object.\n" . +"- added the SHA256, SHA384, and GOST digest defines to Lookups.php.\n" . "- dropped the Net_DNS2_Socket_Sockets, and switch to just using the streams code. There's no speed difference anymore.\n" . "- fixed a bug in Net_DNS2_Packet::compress() and Net_DNS2_Packet::expand() related to dot literals in compressed names.\n" . "- fixed a display issue in the IPSECKEY RR when displaying hostname / domain names in the gateway field.\n" . "- fixed a couple inconsistencies in the docs.\n" . "- fixed a PHP 7.4 bug in Sockets.php; accessing a null value as an array throws an exception now.\n" . +"- fixed Net_DNS2_RR_DS so it will be able to support other digest definitions without any other changes.\n" . "- the Net_DNS2_RR_NIMLOC class was incorrectly named Net_DNS2_RR_NIMLOCK.\n" . "- Net_DNS2_PrivateKey was using the wrong member variable name for the key_format value.\n" . "- changed all references to array() to [].\n" . diff --git a/package.xml b/package.xml index d28c770..e3bb326 100644 --- a/package.xml +++ b/package.xml @@ -15,8 +15,8 @@ This release is (in most cases) 2x - 10x faster than Net_DNS, as well as include mike@mikepultz.com yes - 2020-10-04 - + 2020-10-08 + 1.5.0 1.5.0 @@ -28,103 +28,111 @@ This release is (in most cases) 2x - 10x faster than Net_DNS, as well as include BSD License - added the AMTRELAY resource record type (RFC 8777). +- added Net_DNS2_RR::asArray(), which returns the same values as __toString(), but as an array for easier access. +- added Net_DNS2::closeSockets(), which lets you close all cached network sockets in the resolver object. +- added Net_DNS2::getSockets(), which returns the local sockets cache array. +- added date_created and date_last_used to the Net_DNS2_Socket object, to track usage stats on each socket object. +- added the SHA256, SHA384, and GOST digest defines to Lookups.php. - dropped the Net_DNS2_Socket_Sockets, and switch to just using the streams code. There's no speed difference anymore. +- fixed a bug in Net_DNS2_Packet::compress() and Net_DNS2_Packet::expand() related to dot literals in compressed names. - fixed a display issue in the IPSECKEY RR when displaying hostname / domain names in the gateway field. -- the Net_DNS2_RR_NIMLOC class was incorrectly named Net_DNS2_RR_NIMLOCK. - fixed a couple inconsistencies in the docs. - fixed a PHP 7.4 bug in Sockets.php; accessing a null value as an array throws an exception now. +- fixed Net_DNS2_RR_DS so it will be able to support other digest definitions without any other changes. +- the Net_DNS2_RR_NIMLOC class was incorrectly named Net_DNS2_RR_NIMLOCK. - Net_DNS2_PrivateKey was using the wrong member variable name for the key_format value. -- added Net_DNS2_RR::asArray(), which returns the same values as __toString(), but as an array for easier access. +- changed all references to array() to []. - removed all sorts of license noise from the files. +- updated the test cases to use PHPUnit v9+. - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -544,18 +552,26 @@ Initial Beta release of Net_DNS2 stable stable - 2020-10-04 + 2020-10-08 BSD License - added the AMTRELAY resource record type (RFC 8777). +- added Net_DNS2_RR::asArray(), which returns the same values as __toString(), but as an array for easier access. +- added Net_DNS2::closeSockets(), which lets you close all cached network sockets in the resolver object. +- added Net_DNS2::getSockets(), which returns the local sockets cache array. +- added date_created and date_last_used to the Net_DNS2_Socket object, to track usage stats on each socket object. +- added the SHA256, SHA384, and GOST digest defines to Lookups.php. - dropped the Net_DNS2_Socket_Sockets, and switch to just using the streams code. There's no speed difference anymore. +- fixed a bug in Net_DNS2_Packet::compress() and Net_DNS2_Packet::expand() related to dot literals in compressed names. - fixed a display issue in the IPSECKEY RR when displaying hostname / domain names in the gateway field. -- the Net_DNS2_RR_NIMLOC class was incorrectly named Net_DNS2_RR_NIMLOCK. - fixed a couple inconsistencies in the docs. - fixed a PHP 7.4 bug in Sockets.php; accessing a null value as an array throws an exception now. +- fixed Net_DNS2_RR_DS so it will be able to support other digest definitions without any other changes. +- the Net_DNS2_RR_NIMLOC class was incorrectly named Net_DNS2_RR_NIMLOCK. - Net_DNS2_PrivateKey was using the wrong member variable name for the key_format value. -- added Net_DNS2_RR::asArray(), which returns the same values as __toString(), but as an array for easier access. +- changed all references to array() to []. - removed all sorts of license noise from the files. +- updated the test cases to use PHPUnit v9+.