add class to calculate DSset for dnssec
authorStricted <info@stricted.de>
Sun, 22 Feb 2015 14:42:33 +0000 (15:42 +0100)
committerStricted <info@stricted.de>
Sun, 22 Feb 2015 14:42:33 +0000 (15:42 +0100)
lib/util/DNSSECUtil.class.php [new file with mode: 0644]
lib/util/ParseZone.class.php
templates/default/secList.tpl

diff --git a/lib/util/DNSSECUtil.class.php b/lib/util/DNSSECUtil.class.php
new file mode 100644 (file)
index 0000000..e34f800
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+namespace dns\util;
+
+/**
+ * @author      Jan Altensen (Stricted)
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+       }
+}
index 2806522a440bfe91aa2fb58a49f0dd6cb474674a..2a85663086014b1fead183f6364a98fcde9e05d1 100644 (file)
@@ -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;
index adb51040dfa903e0376edfa4273824be96ae3170..90d5ead51f24cd0ab3674c58ad8f917ae520e8f8 100644 (file)
@@ -32,9 +32,9 @@
                                                                                <td>{$record['public']|substr:0:20}&hellip;</td>
                                                                                <td>{$record['private']|substr:0:20}&hellip;</td>
                                                                                <td>
+                                                                                       <span class="fa fa-pencil ttips pointer" title="Edit"></span>&nbsp;
+                                                                                       <span class="fa fa{if $record['active']}-check{/if}-square-o ttips pointer toggleSec" toggle-id="{$record['id']}" title="{if $record['active']}{lang}button.disable{/lang}{else}{lang}button.enable{/lang}{/if}" data-disable-message="{lang}button.disable{/lang}" data-enable-message="{lang}button.enable{/lang}"></span>&nbsp;
                                                                                        <span class="fa fa-remove ttips pointer deleteSec" delete-id="{$record['id']}" delete-confirm="{lang}record.delete.message{/lang}" title="{lang}button.delete{/lang}"></span>
-                                                                                       <span class="fa fa{if $record['active']}-check{/if}-square-o ttips pointer toggleSec" toggle-id="{$record['id']}" title="{if $record['active']}{lang}button.disable{/lang}{else}{lang}button.enable{/lang}{/if}" data-disable-message="{lang}button.disable{/lang}" data-enable-message="{lang}button.enable{/lang}"></span>
-                                                                                       <span class="fa fa-pencil ttips pointer" title="Edit"></span>
                                                                                </td>
                                                                        </tr>
                                                                        {/foreach}