Commit version 24.12.13800
This commit is contained in:
@ -195,9 +195,7 @@ class Net_DNS2_RR_AMTRELAY extends Net_DNS2_RR
|
||||
break;
|
||||
|
||||
case self::AMTRELAY_TYPE_DOMAIN:
|
||||
$doffset = $packet->offset + $offset;
|
||||
$this->relay = Net_DNS2_Packet::label($packet, $doffset);
|
||||
|
||||
$this->relay = Net_DNS2_Names::unpack($this->rdata, $offset);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -245,7 +243,8 @@ class Net_DNS2_RR_AMTRELAY extends Net_DNS2_RR
|
||||
break;
|
||||
|
||||
case self::AMTRELAY_TYPE_DOMAIN:
|
||||
$data .= pack('Ca*', strlen($this->relay), $this->relay);
|
||||
$data .= Net_DNS2_Names::pack($this->relay);
|
||||
$packet->offset += 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -86,7 +86,7 @@ class Net_DNS2_RR_APL extends Net_DNS2_RR
|
||||
];
|
||||
|
||||
$address = $this->_trimZeros(
|
||||
$i['address_family'], $i['afd_part']
|
||||
intval($i['address_family']), $i['afd_part']
|
||||
);
|
||||
|
||||
$i['afd_length'] = count(explode('.', $address));
|
||||
@ -217,7 +217,7 @@ class Net_DNS2_RR_APL extends Net_DNS2_RR
|
||||
);
|
||||
|
||||
foreach ($address as $b) {
|
||||
$data .= chr($b);
|
||||
$data .= chr(intval($b));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
|
@ -90,8 +90,6 @@ class Net_DNS2_RR_CERT extends Net_DNS2_RR
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
* @param array $rr a array with parsed RR values
|
||||
*
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public function __construct(Net_DNS2_Packet &$packet = null, array $rr = null)
|
||||
{
|
||||
|
@ -130,7 +130,7 @@ class Net_DNS2_RR_EUI48 extends Net_DNS2_RR
|
||||
$a = explode('-', $this->address);
|
||||
foreach ($a as $b) {
|
||||
|
||||
$data .= chr(hexdec($b));
|
||||
$data .= chr(intval(hexdec($b)));
|
||||
}
|
||||
|
||||
$packet->offset += 6;
|
||||
|
@ -131,7 +131,7 @@ class Net_DNS2_RR_EUI64 extends Net_DNS2_RR
|
||||
$a = explode('-', $this->address);
|
||||
foreach ($a as $b) {
|
||||
|
||||
$data .= chr(hexdec($b));
|
||||
$data .= chr(intval(hexdec($b)));
|
||||
}
|
||||
|
||||
$packet->offset += 8;
|
||||
|
@ -89,8 +89,8 @@ class Net_DNS2_RR_HINFO extends Net_DNS2_RR
|
||||
|
||||
$offset = $packet->offset;
|
||||
|
||||
$this->cpu = Net_DNS2_Packet::label($packet, $offset);
|
||||
$this->os = Net_DNS2_Packet::label($packet, $offset);
|
||||
$this->cpu = Net_DNS2_Names::unpack($packet->rdata, $offset);
|
||||
$this->os = Net_DNS2_Names::unpack($packet->rdata, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -113,7 +113,7 @@ class Net_DNS2_RR_HINFO extends Net_DNS2_RR
|
||||
{
|
||||
if (strlen($this->cpu) > 0) {
|
||||
|
||||
$data = pack('Ca*Ca*', strlen($this->cpu), $this->cpu, strlen($this->os), $this->os);
|
||||
$data = Net_DNS2_Names::pack($this->cpu) . Net_DNS2_Names::pack($this->os);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
|
@ -91,14 +91,15 @@ class Net_DNS2_RR_ISDN extends Net_DNS2_RR
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$this->isdnaddress = Net_DNS2_Packet::label($packet, $packet->offset);
|
||||
$offset = $packet->offset;
|
||||
$this->isdnaddress = Net_DNS2_Names::unpack($packet->rdata, $offset);
|
||||
|
||||
//
|
||||
// look for a SA (sub address) - it's optional
|
||||
//
|
||||
if ( (strlen($this->isdnaddress) + 1) < $this->rdlength) {
|
||||
|
||||
$this->sa = Net_DNS2_Packet::label($packet, $packet->offset);
|
||||
$this->sa = Net_DNS2_Names::unpack($packet->rdata, $offset);
|
||||
} else {
|
||||
|
||||
$this->sa = '';
|
||||
@ -125,11 +126,10 @@ class Net_DNS2_RR_ISDN extends Net_DNS2_RR
|
||||
{
|
||||
if (strlen($this->isdnaddress) > 0) {
|
||||
|
||||
$data = chr(strlen($this->isdnaddress)) . $this->isdnaddress;
|
||||
$data = Net_DNS2_Names::pack($this->isdnaddress);
|
||||
if (!empty($this->sa)) {
|
||||
|
||||
$data .= chr(strlen($this->sa));
|
||||
$data .= $this->sa;
|
||||
$data .= Net_DNS2_Names::pack($this->sa);
|
||||
}
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
@ -20,8 +20,7 @@
|
||||
/**
|
||||
* KX Resource Record - RFC2230 section 3.1
|
||||
*
|
||||
* This class is almost identical to MX, except that the the exchanger
|
||||
* domain is not compressed, it's added as a label
|
||||
* This class is almost identical to MX
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | PREFERENCE |
|
||||
@ -95,7 +94,7 @@ class Net_DNS2_RR_KX extends Net_DNS2_RR
|
||||
// get the exchange entry server)
|
||||
//
|
||||
$offset = $packet->offset + 2;
|
||||
$this->exchange = Net_DNS2_Packet::label($packet, $offset);
|
||||
$this->exchange = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -117,12 +116,11 @@ class Net_DNS2_RR_KX extends Net_DNS2_RR
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->exchange) > 0) {
|
||||
|
||||
$data = pack('nC', $this->preference, strlen($this->exchange)) .
|
||||
$this->exchange;
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
$data = pack('n', $this->preference);
|
||||
$packet->offset += 2;
|
||||
|
||||
$data .= $packet->compress($this->exchange, $packet->offset);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -76,8 +76,7 @@ class Net_DNS2_RR_LOC extends Net_DNS2_RR
|
||||
/*
|
||||
* used for quick power-of-ten lookups
|
||||
*/
|
||||
private $_powerOfTen = [ 1, 10, 100, 1000, 10000, 100000,
|
||||
1000000,10000000,100000000,1000000000 ];
|
||||
private $_powerOfTen = [ 0.01, 0.1, 1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 0, 0, 0, 0, 0 ];
|
||||
|
||||
/*
|
||||
* some conversion values
|
||||
@ -140,9 +139,9 @@ class Net_DNS2_RR_LOC extends Net_DNS2_RR
|
||||
//
|
||||
// latitude
|
||||
//
|
||||
$latdeg = $x[1];
|
||||
$latmin = (isset($x[3])) ? $x[3] : 0;
|
||||
$latsec = (isset($x[5])) ? $x[5] : 0;
|
||||
$latdeg = floatval($x[1]);
|
||||
$latmin = floatval((isset($x[3])) ? $x[3] : 0);
|
||||
$latsec = floatval((isset($x[5])) ? $x[5] : 0);
|
||||
$lathem = strtoupper($x[6]);
|
||||
|
||||
$this->latitude = $this->_dms2d($latdeg, $latmin, $latsec, $lathem);
|
||||
@ -150,9 +149,9 @@ class Net_DNS2_RR_LOC extends Net_DNS2_RR
|
||||
//
|
||||
// longitude
|
||||
//
|
||||
$londeg = $x[7];
|
||||
$lonmin = (isset($x[9])) ? $x[9] : 0;
|
||||
$lonsec = (isset($x[11])) ? $x[11] : 0;
|
||||
$londeg = floatval($x[7]);
|
||||
$lonmin = floatval((isset($x[9])) ? $x[9] : 0);
|
||||
$lonsec = floatval((isset($x[11])) ? $x[11] : 0);
|
||||
$lonhem = strtoupper($x[12]);
|
||||
|
||||
$this->longitude = $this->_dms2d($londeg, $lonmin, $lonsec, $lonhem);
|
||||
@ -198,6 +197,7 @@ class Net_DNS2_RR_LOC extends Net_DNS2_RR
|
||||
// version must be 0 per RFC 1876 section 2
|
||||
//
|
||||
$this->version = $x['ver'];
|
||||
|
||||
if ($this->version == 0) {
|
||||
|
||||
$this->size = $this->_precsizeNtoA($x['size']);
|
||||
@ -307,10 +307,9 @@ class Net_DNS2_RR_LOC extends Net_DNS2_RR
|
||||
*/
|
||||
private function _precsizeNtoA($prec)
|
||||
{
|
||||
$mantissa = (($prec >> 4) & 0x0f) % 10;
|
||||
$exponent = (($prec >> 0) & 0x0f) % 10;
|
||||
$mantissa = $prec >> 4;
|
||||
|
||||
return $mantissa * $this->_powerOfTen[$exponent];
|
||||
return strval($mantissa * $this->_powerOfTen[$prec & 0x0F]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -326,22 +325,24 @@ class Net_DNS2_RR_LOC extends Net_DNS2_RR
|
||||
private function _precsizeAtoN($prec)
|
||||
{
|
||||
$exponent = 0;
|
||||
while ($prec >= 10) {
|
||||
|
||||
$prec /= 10;
|
||||
++$exponent;
|
||||
while($prec > $this->_powerOfTen[1 + $exponent]) {
|
||||
|
||||
$exponent++;
|
||||
}
|
||||
|
||||
return ($prec << 4) | ($exponent & 0x0f);
|
||||
$mantissa = intval(0.5 + ($prec / $this->_powerOfTen[$exponent]));
|
||||
|
||||
return ($mantissa & 0xF) << 4 | $exponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert lat/lng in deg/min/sec/hem to decimal value
|
||||
*
|
||||
* @param integer $deg the degree value
|
||||
* @param integer $min the minutes value
|
||||
* @param integer $sec the seconds value
|
||||
* @param string $hem the hemisphere (N/E/S/W)
|
||||
* @param float $deg the degree value
|
||||
* @param float $min the minutes value
|
||||
* @param float $sec the seconds value
|
||||
* @param string $hem the hemisphere (N/E/S/W)
|
||||
*
|
||||
* @return float the decinmal value
|
||||
* @access private
|
||||
|
@ -138,9 +138,9 @@ class Net_DNS2_RR_NAPTR extends Net_DNS2_RR
|
||||
|
||||
$offset = $packet->offset + 4;
|
||||
|
||||
$this->flags = Net_DNS2_Packet::label($packet, $offset);
|
||||
$this->services = Net_DNS2_Packet::label($packet, $offset);
|
||||
$this->regexp = Net_DNS2_Packet::label($packet, $offset);
|
||||
$this->flags = Net_DNS2_Names::unpack($packet->rdata, $offset);
|
||||
$this->services = Net_DNS2_Names::unpack($packet->rdata, $offset);
|
||||
$this->regexp = Net_DNS2_Names::unpack($packet->rdata, $offset);
|
||||
|
||||
$this->replacement = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
@ -167,9 +167,9 @@ class Net_DNS2_RR_NAPTR extends Net_DNS2_RR
|
||||
|
||||
$data = pack('nn', $this->order, $this->preference);
|
||||
|
||||
$data .= chr(strlen($this->flags)) . $this->flags;
|
||||
$data .= chr(strlen($this->services)) . $this->services;
|
||||
$data .= chr(strlen($this->regexp)) . $this->regexp;
|
||||
$data .= Net_DNS2_Names::pack($this->flags);
|
||||
$data .= Net_DNS2_Names::pack($this->services);
|
||||
$data .= Net_DNS2_Names::pack($this->regexp);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
|
@ -33,7 +33,6 @@ class Net_DNS2_RR_NSEC3PARAM extends Net_DNS2_RR
|
||||
/*
|
||||
* Algorithm to use
|
||||
*
|
||||
* TODO: same as the NSEC3
|
||||
*/
|
||||
public $algorithm;
|
||||
|
||||
|
@ -248,8 +248,8 @@ class Net_DNS2_RR_RRSIG extends Net_DNS2_RR
|
||||
$this->algorithm,
|
||||
$this->labels,
|
||||
$this->origttl,
|
||||
gmmktime($e[4], $e[5], $e[6], $e[2], $e[3], $e[1]),
|
||||
gmmktime($i[4], $i[5], $i[6], $i[2], $i[3], $i[1]),
|
||||
gmmktime(intval($e[4]), intval($e[5]), intval($e[6]), intval($e[2]), intval($e[3]), intval($e[1])),
|
||||
gmmktime(intval($i[4]), intval($i[5]), intval($i[6]), intval($i[2]), intval($i[3]), intval($i[1])),
|
||||
$this->keytag
|
||||
);
|
||||
|
||||
|
@ -251,8 +251,8 @@ class Net_DNS2_RR_SIG extends Net_DNS2_RR
|
||||
$this->algorithm,
|
||||
$this->labels,
|
||||
$this->origttl,
|
||||
gmmktime($e[4], $e[5], $e[6], $e[2], $e[3], $e[1]),
|
||||
gmmktime($i[4], $i[5], $i[6], $i[2], $i[3], $i[1]),
|
||||
gmmktime(intval($e[4]), intval($e[5]), intval($e[6]), intval($e[2]), intval($e[3]), intval($e[1])),
|
||||
gmmktime(intval($i[4]), intval($i[5]), intval($i[6]), intval($i[2]), intval($i[3]), intval($i[1])),
|
||||
$this->keytag
|
||||
);
|
||||
|
||||
@ -267,7 +267,7 @@ class Net_DNS2_RR_SIG extends Net_DNS2_RR
|
||||
$data .= $name;
|
||||
}
|
||||
|
||||
$data .= chr('0');
|
||||
$data .= chr(0);
|
||||
|
||||
//
|
||||
// if the signature is empty, and $this->private_key is an instance of a
|
||||
|
@ -84,8 +84,8 @@ class Net_DNS2_RR_TALINK extends Net_DNS2_RR
|
||||
|
||||
$offset = $packet->offset;
|
||||
|
||||
$this->previous = Net_DNS2_Packet::label($packet, $offset);
|
||||
$this->next = Net_DNS2_Packet::label($packet, $offset);
|
||||
$this->previous = Net_DNS2_Packet::expand($packet, $offset);
|
||||
$this->next = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -108,12 +108,7 @@ class Net_DNS2_RR_TALINK extends Net_DNS2_RR
|
||||
{
|
||||
if ( (strlen($this->previous) > 0) || (strlen($this->next) > 0) ) {
|
||||
|
||||
$data = chr(strlen($this->previous)) . $this->previous .
|
||||
chr(strlen($this->next)) . $this->next;
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
return $packet->compress($this->previous, $packet->offset) . $packet->compress($this->next, $packet->offset);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -213,6 +213,8 @@ class Net_DNS2_RR_TKEY extends Net_DNS2_RR
|
||||
{
|
||||
if (strlen($this->algorithm) > 0) {
|
||||
|
||||
$offset = 0;
|
||||
|
||||
//
|
||||
// make sure the size values are correct
|
||||
//
|
||||
@ -222,7 +224,7 @@ class Net_DNS2_RR_TKEY extends Net_DNS2_RR
|
||||
//
|
||||
// add the algorithm without compression
|
||||
//
|
||||
$data = Net_DNS2_Packet::pack($this->algorithm);
|
||||
$data = $packet->compress($this->algorithm, $packet->offset);
|
||||
|
||||
//
|
||||
// pack in the inception, expiration, mode, error and key size
|
||||
|
@ -62,7 +62,7 @@ class Net_DNS2_RR_TLSA extends Net_DNS2_RR
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->cert_usage . ' ' . $this->selector . ' ' .
|
||||
$this->matching_type . ' ' . base64_encode($this->certificate);
|
||||
$this->matching_type . ' ' . implode('', unpack('H*', $this->certificate));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +79,7 @@ class Net_DNS2_RR_TLSA extends Net_DNS2_RR
|
||||
$this->cert_usage = array_shift($rdata);
|
||||
$this->selector = array_shift($rdata);
|
||||
$this->matching_type = array_shift($rdata);
|
||||
$this->certificate = base64_decode(implode('', $rdata));
|
||||
$this->certificate = pack('H*', implode('', $rdata));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -132,9 +132,7 @@ class Net_DNS2_RR_TLSA extends Net_DNS2_RR
|
||||
{
|
||||
if (strlen($this->certificate) > 0) {
|
||||
|
||||
$data = pack(
|
||||
'CCC', $this->cert_usage, $this->selector, $this->matching_type
|
||||
) . $this->certificate;
|
||||
$data = pack('CCCa*', $this->cert_usage, $this->selector, $this->matching_type, $this->certificate);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
|
@ -306,7 +306,7 @@ class Net_DNS2_RR_TSIG extends Net_DNS2_RR
|
||||
//
|
||||
// add the name without compressing
|
||||
//
|
||||
$sig_data .= Net_DNS2_Packet::pack($this->name);
|
||||
$sig_data .= Net_DNS2_Names::canonical($this->name);
|
||||
|
||||
//
|
||||
// add the class and TTL
|
||||
@ -318,7 +318,7 @@ class Net_DNS2_RR_TSIG extends Net_DNS2_RR
|
||||
//
|
||||
// add the algorithm name without compression
|
||||
//
|
||||
$sig_data .= Net_DNS2_Packet::pack(strtolower($this->algorithm));
|
||||
$sig_data .= Net_DNS2_Names::canonical(strtolower($this->algorithm));
|
||||
|
||||
//
|
||||
// add the rest of the values
|
||||
@ -343,7 +343,7 @@ class Net_DNS2_RR_TSIG extends Net_DNS2_RR
|
||||
//
|
||||
// compress the algorithm
|
||||
//
|
||||
$data = Net_DNS2_Packet::pack(strtolower($this->algorithm));
|
||||
$data = $packet->compress(strtolower($this->algorithm), $offset);
|
||||
|
||||
//
|
||||
// pack the time, fudge and mac size
|
||||
@ -363,6 +363,7 @@ class Net_DNS2_RR_TSIG extends Net_DNS2_RR
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$this->other_length = 0;
|
||||
|
@ -87,13 +87,13 @@ class Net_DNS2_RR_TXT extends Net_DNS2_RR
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$length = $packet->offset + $this->rdlength;
|
||||
|
||||
$offset = $packet->offset;
|
||||
$limit = $offset + $this->rdlength;
|
||||
|
||||
while ($length > $offset) {
|
||||
|
||||
$this->text[] = Net_DNS2_Packet::label($packet, $offset);
|
||||
while($offset < $limit) {
|
||||
|
||||
$this->text[] = Net_DNS2_Names::unpack($packet->rdata, $offset);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -115,11 +115,11 @@ class Net_DNS2_RR_TXT extends Net_DNS2_RR
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
$data = null;
|
||||
$data = '';
|
||||
|
||||
foreach ($this->text as $t) {
|
||||
foreach($this->text as $text) {
|
||||
|
||||
$data .= chr(strlen($t)) . $t;
|
||||
$data .= Net_DNS2_Names::pack($text);
|
||||
}
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
@ -171,7 +171,7 @@ class Net_DNS2_RR_WKS extends Net_DNS2_RR
|
||||
|
||||
if ($n == 8) {
|
||||
|
||||
$data .= chr(bindec($string));
|
||||
$data .= chr(intval(bindec($string)));
|
||||
$string = '';
|
||||
$n = 0;
|
||||
}
|
||||
|
@ -78,7 +78,10 @@ class Net_DNS2_RR_X25 extends Net_DNS2_RR
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$this->psdnaddress = Net_DNS2_Packet::label($packet, $packet->offset);
|
||||
$offset = $packet->offset;
|
||||
|
||||
$this->psdnaddress = Net_DNS2_Names::unpack($packet->rdata, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -100,7 +103,7 @@ class Net_DNS2_RR_X25 extends Net_DNS2_RR
|
||||
{
|
||||
if (strlen($this->psdnaddress) > 0) {
|
||||
|
||||
$data = chr(strlen($this->psdnaddress)) . $this->psdnaddress;
|
||||
$data = Net_DNS2_Names::pack($this->psdnaddress);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
|
162
libs/pear/Net/DNS2/RR/ZONEMD.php
Normal file
162
libs/pear/Net/DNS2/RR/ZONEMD.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* Copyright (c) 2022, Mike Pultz <mike@mikepultz.com>. All rights reserved.
|
||||
*
|
||||
* See LICENSE for more details.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2022 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link https://netdns2.com/
|
||||
* @since File available since Release 1.5.3
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* ZONEMD Resource Record - RFC8976 section 2.2
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Serial |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Scheme |Hash Algorithm | |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
||||
* | Digest |
|
||||
* / /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_ZONEMD extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* ZONEMD schemes - there is currently only one defined.
|
||||
*/
|
||||
const ZONEMD_SCHEME_SIMPLE = 1;
|
||||
|
||||
/*
|
||||
* ZONEMD hash algorithms
|
||||
*/
|
||||
const ZONEMD_HASH_ALGORITHM_SHA384 = 1;
|
||||
const ZONEMD_HASH_ALGORITHM_SHA512 = 2;
|
||||
|
||||
/*
|
||||
* the serial number from the zone's SOA record
|
||||
*/
|
||||
public $serial;
|
||||
|
||||
/*
|
||||
* the methods by which data is collated and presented as input to the hashing function.
|
||||
*/
|
||||
public $scheme;
|
||||
|
||||
/*
|
||||
* the cryptographic hash algorithm used to construct the digest.
|
||||
*/
|
||||
public $hash_algorithm;
|
||||
|
||||
/*
|
||||
* the output of the hash algorithm.
|
||||
*/
|
||||
public $digest;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->serial . ' ' . $this->scheme . ' ' . $this->hash_algorithm .
|
||||
' ' . implode('', unpack('H*', $this->digest));
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->serial = array_shift($rdata);
|
||||
$this->scheme = array_shift($rdata);
|
||||
$this->hash_algorithm = array_shift($rdata);
|
||||
|
||||
//
|
||||
// digest must be provided as base64 encoded.
|
||||
//
|
||||
$this->digest = pack('H*', implode('', $rdata));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the serial, scheme, and hash algorithm
|
||||
//
|
||||
$x = unpack('Nserial/Cscheme/Chash_algorithm', $this->rdata);
|
||||
|
||||
$this->serial = $x['serial'];
|
||||
$this->scheme = $x['scheme'];
|
||||
$this->hash_algorithm = $x['hash_algorithm'];
|
||||
|
||||
//
|
||||
// copy the digest
|
||||
//
|
||||
$this->digest = substr($this->rdata, 6, $this->rdlength - 6);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->digest) > 0) {
|
||||
|
||||
$data = pack('NCCa*', $this->serial, $this->scheme, $this->hash_algorithm, $this->digest);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user