Skip to content

Commit

Permalink
- finished support for DS, DLV, RRSIG and SIG
Browse files Browse the repository at this point in the history
- added tests for DS, DLV, RRSIG and SIG
  • Loading branch information
mike.pultz committed Sep 2, 2010
1 parent 22c54f3 commit ea729b5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 70 deletions.
9 changes: 6 additions & 3 deletions Net/DNS2/RR/DS.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected function rrFromString(array $rdata)
$this->keytag = array_shift($rdata);
$this->algorithm = array_shift($rdata);
$this->digesttype = array_shift($rdata);
$this->digest = implode(' ', $rdata);
$this->digest = implode('', $rdata);

return true;
}
Expand Down Expand Up @@ -160,10 +160,13 @@ protected function rrSet(Net_DNS2_Packet &$packet)
//
// copy the digest
//
$this->digest = unpack('H*', substr($this->rdata, 4, $digest_size));
$x = unpack('H*', substr($this->rdata, 4, $digest_size));
$this->digest = $x[1];

return true;
}

return true;
return false;
}

/**
Expand Down
20 changes: 9 additions & 11 deletions Net/DNS2/RR/RRSIG.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function rrFromString(array $rdata)

foreach ($rdata as $line) {

$this->signature .= $line . ' ';
$this->signature .= $line;
}
$this->signature = trim($this->signature);

Expand Down Expand Up @@ -185,16 +185,14 @@ protected function rrSet(Net_DNS2_Packet &$packet)
$this->origttl = $x['origttl'];

//
// TODO: I dont' think these are right; I think we need to change
// localtime() to gmdate() with a simple format and parse the output
// the dates are in GM time
//
$this->sigexp = gmdate('YmdHis', $x['sigexp']);
$this->sigincep = gmdate('YmdHis', $x['sigincep']);

$e = localtime($x['sigexp']);
$this->sigexp = sprintf("%d%02d%02d%02d%02d%02d", $e[5]+1900, $e[4]+1, $e[3], $e[2], $e[1], $e[0]);

$i = localtime($x['sigincep']);
$this->sigincep = sprintf("%d%02d%02d%02d%02d%02d", $i[5]+1900, $i[4]+1, $i[3], $i[2], $i[1], $i[0]);

//
// get the keytag
//
$this->keytag = $x['keytag'];

//
Expand Down Expand Up @@ -240,8 +238,8 @@ protected function rrGet(Net_DNS2_Packet &$packet)
$this->algorithm,
$this->labels,
$this->origttl,
gmmktime($e[4], $e[5], $e[6], $e[2] - 1, $e[3], $e[1] - 1900),
gmmktime($i[4], $i[5], $i[6], $i[2] - 1, $i[3], $i[1] - 1900),
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]),
$this->keytag
);

Expand Down
56 changes: 4 additions & 52 deletions Net/DNS2/RR/SIG.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
* / signature /
* / /
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* RRSIG has been disignated the replacement for SIG, and is physically identical
* in storage to SIG, so we just use the RRSIG class here.
*
* @category Networking
* @package Net_DNS2
Expand All @@ -79,59 +82,8 @@
* @see Net_DNS2_RR
*
*/
class Net_DNS2_RR_SIG extends Net_DNS2_RR
class Net_DNS2_RR_SIG extends Net_DNS2_RR_RRSIG
{
/**
* method to return the rdata portion of the packet as a string
*
* @return string
* @access protected
*
*/
protected function rrToString()
{
}

/**
* 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)
{
}

/**
* 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)
{
}

/**
* 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)
{
}
}

/*
Expand Down
2 changes: 1 addition & 1 deletion Net/DNS2/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DONE- update requests
APL, HIP, OPT

- dnssec
DNSKEY, DS, NSEC, NSEC3, NSEC3PARAM, RRSIG, SIG
NSEC, NSEC3, NSEC3PARAM


DONE - parse BIND style input and set all the appropriate values of the RR object
Expand Down
7 changes: 4 additions & 3 deletions tests/Net_DNS2_ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function testParser()
'ISDN' => 'example.com. 300 IN ISDN "150 862 028 003 217" 42',
'RT' => 'example.com. 300 IN RT 2 relay.prime.com.',
'NSAP' => 'example.com. 300 IN NSAP 0x47.0005.80.005a00.0000.0001.e133.aaaaaa000151.00',
'SIG' => 'example.com. 300 IN SIG DNSKEY 7 1 86400 20100827211706 20100822211706 57970 gov. KoWPhMtLHp8sWYZSgsMiYJKB9P71CQmh9CnxJCs5GutKfo7Jpw+nNnDLiNnsd6U1JSkf99rYRWCyOTAPC47xkHr+2Uh7n6HDJznfdCzRa/v9uwEcbXIxCZ7KfzNJewW3EvYAxDIrW6sY/4MAsjS5XM/O9LaWzw6pf7TX5obBbLI+zRECbPNTdY+RF6Fl9K0GVaEZJNYi2PRXnATwvwca2CNRWxeMT/dF5STUram3cWjH0Pkm19Gc1jbdzlZVDbUudDauWoHcc0mfH7PV1sMpe80NqK7yQ24AzAkXSiknO13itHsCe4LECUu0/OtnhHg2swwXaVTf5hqHYpzi3bQenw==',
'KEY' => 'example.com. 300 IN KEY 256 3 7 AwEAAYCXh/ZABi8kiJIDXYmyUlHzC0CHeBzqcpyZAIjC7dK1wkRYVcUvIlpTOpnOVVfcC3Py9Ui/x45qKb0LytvK7WYAe3WyOOwk5klwIqRC/0p4luafbd2yhRMF7quOBVqYrLoHwv8i9LrV+r8dhB7rXv/lkTSI6mEZsg5rDfee8Yy1',
'PX' => 'example.com. 300 IN PX 10 ab.net2.it. o-ab.prmd-net2.admdb.c-it.',
'AAAA' => 'example.com. 300 IN AAAA 1080:0:0:0:8:800:200c:417a',
Expand All @@ -70,15 +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wNEFZV3JYaGFrMVAvNGZlaDVNSU5WVHNXQkhTNlRZNW0xRmZMUEpybklHNW1FSHNidWkvdnhuQ1JmRUR4ZlU1V1E0cS9HUkZuaVl3SHB3PT0=',
'DNAME' => 'example.com. 300 IN DNAME frobozz-division.acme.example.',
// BROKEN 'DS' => 'example.com. 300 IN DS 21366 7 2 96EEB2FFD9B00CD4694E78278B5EFDAB0A80446567B69F634DA078F0 D90F01BA',
// BROKEN 'RRSIG' => 'example.com. 300 IN RRSIG DNSKEY 7 1 86400 20100827211706 20100822211706 57970 gov. KoWPhMtLHp8sWYZSgsMiYJKB9P71CQmh9CnxJCs5GutKfo7Jpw+nNnDL iNnsd6U1JSkf99rYRWCyOTAPC47xkHr+2Uh7n6HDJznfdCzRa/v9uwEc bXIxCZ7KfzNJewW3EvYAxDIrW6sY/4MAsjS5XM/O9LaWzw6pf7TX5obB bLI+zRECbPNTdY+RF6Fl9K0GVaEZJNYi2PRXnATwvwca2CNRWxeMT/dF5STUram3cWjH0Pkm19Gc1jbdzlZVDbUudDauWoHcc0mfH7PV1sMpe80N qK7yQ24AzAkXSiknO13itHsCe4LECUu0/OtnhHg2swwXaVTf5hqHYpzi 3bQenw==',
'DS' => 'example.com. 300 IN DS 21366 7 2 96eeb2ffd9b00cd4694e78278b5efdab0a80446567b69f634da078f0d90f01ba',
'RRSIG' => 'example.com. 300 IN RRSIG DNSKEY 7 1 86400 20100827211706 20100822211706 57970 gov. KoWPhMtLHp8sWYZSgsMiYJKB9P71CQmh9CnxJCs5GutKfo7Jpw+nNnDLiNnsd6U1JSkf99rYRWCyOTAPC47xkHr+2Uh7n6HDJznfdCzRa/v9uwEcbXIxCZ7KfzNJewW3EvYAxDIrW6sY/4MAsjS5XM/O9LaWzw6pf7TX5obBbLI+zRECbPNTdY+RF6Fl9K0GVaEZJNYi2PRXnATwvwca2CNRWxeMT/dF5STUram3cWjH0Pkm19Gc1jbdzlZVDbUudDauWoHcc0mfH7PV1sMpe80NqK7yQ24AzAkXSiknO13itHsCe4LECUu0/OtnhHg2swwXaVTf5hqHYpzi3bQenw==',
'SSHFP' => 'example.com. 300 IN SSHFP 2 1 123456789abcdef67890123456789abcdef67890',
'IPSECKEY' => 'example.com. 300 IN IPSECKEY 10 2 2 2001:db8:0:8002:0:0:2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==',
'DNSKEY' => 'example.com. 300 IN DNSKEY 256 3 7 AwEAAYCXh/ZABi8kiJIDXYmyUlHzC0CHeBzqcpyZAIjC7dK1wkRYVcUvIlpTOpnOVVfcC3Py9Ui/x45qKb0LytvK7WYAe3WyOOwk5klwIqRC/0p4luafbd2yhRMF7quOBVqYrLoHwv8i9LrV+r8dhB7rXv/lkTSI6mEZsg5rDfee8Yy1',
'DHCID' => 'example.com. 300 IN DHCID AAIBY2/AuCccgoJbsaxcQc9TUapptP69lOjxfNuVAA2kjEA=',
'SPF' => 'example.com. 300 IN SPF "v=spf1 ip4:192.168.0.1/24 mx ?all"',
'TKEY' => 'example.com. 300 IN TKEY gss.microsoft.com. 3 123456.',
// BROKEN 'DLV' => 'example.com. 300 IN DS 21366 7 2 96EEB2FFD9B00CD4694E78278B5EFDAB0A80446567B69F634DA078F0 D90F01BA',
//'DLV' => 'example.com. 300 IN DS 21366 7 2 96EEB2FFD9B00CD4694E78278B5EFDAB0A80446567B69F634DA078F0 D90F01BA',
);

foreach($rrs as $rr => $line) {
Expand Down

0 comments on commit ea729b5

Please sign in to comment.