From: Stricted Date: Sun, 22 Feb 2015 14:42:33 +0000 (+0100) Subject: add class to calculate DSset for dnssec X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=daff88c0871af4aeee0eff7f6d9a489f3c91afda;p=GitHub%2FStricted%2FDomain-Control-Panel.git add class to calculate DSset for dnssec --- diff --git a/lib/util/DNSSECUtil.class.php b/lib/util/DNSSECUtil.class.php new file mode 100644 index 0000000..e34f800 --- /dev/null +++ b/lib/util/DNSSECUtil.class.php @@ -0,0 +1,51 @@ + + * @copyright 2015 Jan Altensen (Stricted) + */ +class DNSSECUtil { + + function calculateDS ($owner, $algorithm, $publicKey) { + $owner = $this->convertOwner($owner); + $flags = '0101'; + $protocol = '03'; + $algorithm = '0'.dechex($algorithm); + $publicKey = bin2hex(base64_decode($publicKey)); + + $string = hex2bin($owner.$flags.$protocol.$algorithm.$publicKey); + + $sha1 = sha1($string); + $sha256 = hash('sha256', $string); + + return array('sha1' => $sha1, 'sha256' => $sha256); + } + + function convertOwner ($owner) { + $return = ''; + + $data = explode(".", $owner); + $return .= '0'.dechex(strlen($data[0])); + $data[0] = str_split($data[0]); + for ($i = 0; $i < count($data[0]); $i++) { + $byte = strtoupper(dechex(ord($data[0][$i]))); + $byte = str_repeat('0', 2 - strlen($byte)).$byte; + $return .= $byte; + } + + $return .= '0'.dechex(strlen($data[1])); + $data[1] = str_split($data[1]); + + for ($i = 0; $i < count($data[1]); $i++) { + $byte = strtoupper(dechex(ord($data[1][$i]))); + $byte = str_repeat('0', 2 - strlen($byte)).$byte; + $return .= $byte; + } + + $return .= '00'; + + return $return; + } +} diff --git a/lib/util/ParseZone.class.php b/lib/util/ParseZone.class.php index 2806522..2a85663 100644 --- a/lib/util/ParseZone.class.php +++ b/lib/util/ParseZone.class.php @@ -269,6 +269,7 @@ class ParseZone { if (!empty($matches[2])) { $this->soa['minimum'] = $matches[2]; $this->soa['ttl'] = $matches[2]; + $this->ttl = $this->soa['ttl']; } else { $this->soa['minimum'] = $this->ttl; diff --git a/templates/default/secList.tpl b/templates/default/secList.tpl index adb5104..90d5ead 100644 --- a/templates/default/secList.tpl +++ b/templates/default/secList.tpl @@ -32,9 +32,9 @@ {$record['public']|substr:0:20}… {$record['private']|substr:0:20}… +   +   - - {/foreach}