|
1 | 1 | <?php
|
| 2 | +namespace Metaregistrar\DNS { |
| 3 | + class dnsDNSKEYresult extends dnsResult |
| 4 | + { |
| 5 | + private $flags; |
| 6 | + private $algorithm; |
| 7 | + private $protocol; |
| 8 | + private $sep; |
| 9 | + private $zonekey; |
| 10 | + private $keylength; |
| 11 | + private $publickey; |
| 12 | + private $publickeybase64; |
| 13 | + private $keytag; |
2 | 14 |
|
3 |
| -class dnsDNSKEYresult extends dnsResult |
4 |
| -{ |
5 |
| - private $flags; |
6 |
| - private $algorithm; |
7 |
| - private $protocol; |
8 |
| - private $sep; |
9 |
| - private $zonekey; |
10 |
| - private $keylength; |
11 |
| - private $publickey; |
12 |
| - private $publickeybase64; |
13 |
| - private $keytag; |
14 |
| - |
15 |
| - public function __construct($flags, $protocol, $algorithm, $pubkey) |
16 |
| - { |
17 |
| - $this->setKeytag($flags,$protocol,$algorithm,$pubkey); |
18 |
| - $this->setKeylength(strlen($pubkey)); |
19 |
| - $this->setFlags($flags); |
20 |
| - $this->setProtocol($protocol); |
21 |
| - $this->setAlgorithm($algorithm); |
22 |
| - $this->setPublicKey($pubkey); |
23 |
| - $this->setPublicKeyBase64(base64_encode($pubkey)); |
24 |
| - $this->sep = false; |
25 |
| - $this->zonekey = false; |
26 |
| - } |
27 |
| - |
28 |
| - /* |
29 |
| - private function setKeytag($flags,$protocol,$algorithm, $pubkey) |
30 |
| - { |
31 |
| - $sum=0; |
32 |
| - $wire = pack("ncc", $flags, $protocol, $algorithm) . $pubkey; |
33 |
| - if ($algorithm == 1) |
| 15 | + public function __construct($flags, $protocol, $algorithm, $pubkey) |
34 | 16 | {
|
35 |
| - $this->keytag = 0xffff & unpack("n", substr($wire,-3,2)) ; |
36 |
| - } |
37 |
| - else |
| 17 | + parent::__construct(); |
| 18 | + //$this->setKeytag($flags, $protocol, $algorithm, $pubkey); |
| 19 | + $this->setKeylength(strlen($pubkey)); |
| 20 | + $this->setFlags($flags); |
| 21 | + $this->setProtocol($protocol); |
| 22 | + $this->setAlgorithm($algorithm); |
| 23 | + $this->setPublicKey($pubkey); |
| 24 | + $this->setPublicKeyBase64(base64_encode($pubkey)); |
| 25 | + $this->sep = false; |
| 26 | + $this->zonekey = false; |
| 27 | + } |
| 28 | + |
| 29 | + /* |
| 30 | + private function setKeytag($flags,$protocol,$algorithm, $pubkey) |
38 | 31 | {
|
39 | 32 | $sum=0;
|
40 |
| - for($i = 0; $i < strlen($wire); $i++) |
| 33 | + $wire = pack("ncc", $flags, $protocol, $algorithm) . $pubkey; |
| 34 | + if ($algorithm == 1) |
| 35 | + { |
| 36 | + $this->keytag = 0xffff & unpack("n", substr($wire,-3,2)) ; |
| 37 | + } |
| 38 | + else |
41 | 39 | {
|
42 |
| - $a = unpack("C", substr($wire,$i,1)); |
43 |
| - $sum += ($i & 1) ? $a[1] : $a[1] << 8; |
| 40 | + $sum=0; |
| 41 | + for($i = 0; $i < strlen($wire); $i++) |
| 42 | + { |
| 43 | + $a = unpack("C", substr($wire,$i,1)); |
| 44 | + $sum += ($i & 1) ? $a[1] : $a[1] << 8; |
| 45 | + } |
| 46 | + $this->keytag = 0xffff & ($sum + ($sum >> 16)); |
44 | 47 | }
|
45 |
| - $this->keytag = 0xffff & ($sum + ($sum >> 16)); |
| 48 | + } |
| 49 | + */ |
| 50 | + public function setKeytag($keytag) |
| 51 | + { |
| 52 | + $this->keytag = $keytag; |
| 53 | + } |
| 54 | + |
| 55 | + public function getKeytag() |
| 56 | + { |
| 57 | + return $this->keytag; |
| 58 | + } |
| 59 | + |
| 60 | + public function setKeylength($keylength) |
| 61 | + { |
| 62 | + $this->keylength = $keylength; |
| 63 | + } |
| 64 | + |
| 65 | + public function getKeylength() |
| 66 | + { |
| 67 | + return $this->keylength; |
| 68 | + } |
| 69 | + |
| 70 | + public function setFlags($flags) |
| 71 | + { |
| 72 | + $this->flags = $flags; |
| 73 | + } |
| 74 | + |
| 75 | + public function getFlags() |
| 76 | + { |
| 77 | + return $this->flags; |
| 78 | + } |
| 79 | + |
| 80 | + public function setAlgorithm($algorithm) |
| 81 | + { |
| 82 | + $this->algorithm = $algorithm; |
| 83 | + } |
| 84 | + |
| 85 | + public function getAlgorithm() |
| 86 | + { |
| 87 | + return $this->algorithm; |
| 88 | + } |
| 89 | + |
| 90 | + public function setProtocol($protocol) |
| 91 | + { |
| 92 | + $this->protocol = $protocol; |
| 93 | + } |
| 94 | + |
| 95 | + public function getProtocol() |
| 96 | + { |
| 97 | + return $this->protocol; |
| 98 | + } |
| 99 | + |
| 100 | + public function setZoneKey($bool) |
| 101 | + { |
| 102 | + $this->zonekey = $bool; |
| 103 | + } |
| 104 | + |
| 105 | + public function getZoneKey() |
| 106 | + { |
| 107 | + return $this->zonekey; |
| 108 | + } |
| 109 | + |
| 110 | + public function setSep($bool) |
| 111 | + { |
| 112 | + $this->sep = $bool; |
| 113 | + } |
| 114 | + |
| 115 | + public function getSep() |
| 116 | + { |
| 117 | + return $this->sep; |
| 118 | + } |
| 119 | + |
| 120 | + public function setPublicKey($key) |
| 121 | + { |
| 122 | + $this->publickey = $key; |
| 123 | + } |
| 124 | + |
| 125 | + public function getPublicKey() |
| 126 | + { |
| 127 | + return $this->publickey; |
| 128 | + } |
| 129 | + |
| 130 | + public function setPublicKeyBase64($key) |
| 131 | + { |
| 132 | + $this->publickeybase64 = $key; |
| 133 | + } |
| 134 | + |
| 135 | + public function getPublicKeyBase64() |
| 136 | + { |
| 137 | + return $this->publickeybase64; |
46 | 138 | }
|
47 | 139 | }
|
48 |
| - */ |
49 |
| - public function setKeytag($keytag) |
50 |
| - { |
51 |
| - $this->keytag = $keytag; |
52 |
| - } |
53 |
| - |
54 |
| - public function getKeytag() |
55 |
| - { |
56 |
| - return $this->keytag; |
57 |
| - } |
58 |
| - |
59 |
| - public function setKeylength($keylength) |
60 |
| - { |
61 |
| - $this->keylength = $keylength; |
62 |
| - } |
63 |
| - |
64 |
| - public function getKeylength() |
65 |
| - { |
66 |
| - return $this->keylength; |
67 |
| - } |
68 |
| - |
69 |
| - public function setFlags($flags) |
70 |
| - { |
71 |
| - $this->flags = $flags; |
72 |
| - } |
73 |
| - |
74 |
| - public function getFlags() |
75 |
| - { |
76 |
| - return $this->flags; |
77 |
| - } |
78 |
| - |
79 |
| - public function setAlgorithm($algorithm) |
80 |
| - { |
81 |
| - $this->algorithm = $algorithm; |
82 |
| - } |
83 |
| - |
84 |
| - public function getAlgorithm() |
85 |
| - { |
86 |
| - return $this->algorithm; |
87 |
| - } |
88 |
| - |
89 |
| - public function setProtocol($protocol) |
90 |
| - { |
91 |
| - $this->protocol = $protocol; |
92 |
| - } |
93 |
| - |
94 |
| - public function getProtocol() |
95 |
| - { |
96 |
| - return $this->protocol; |
97 |
| - } |
98 |
| - |
99 |
| - public function setZoneKey($bool) |
100 |
| - { |
101 |
| - $this->zonekey = $bool; |
102 |
| - } |
103 |
| - |
104 |
| - public function getZoneKey() |
105 |
| - { |
106 |
| - return $this->zonekey; |
107 |
| - } |
108 |
| - |
109 |
| - public function setSep($bool) |
110 |
| - { |
111 |
| - $this->sep = $bool; |
112 |
| - } |
113 |
| - |
114 |
| - public function getSep() |
115 |
| - { |
116 |
| - return $this->sep; |
117 |
| - } |
118 |
| - |
119 |
| - public function setPublicKey($key) |
120 |
| - { |
121 |
| - $this->publickey = $key; |
122 |
| - } |
123 |
| - |
124 |
| - public function getPublicKey() |
125 |
| - { |
126 |
| - return $this->publickey; |
127 |
| - } |
128 |
| - |
129 |
| - public function setPublicKeyBase64($key) |
130 |
| - { |
131 |
| - $this->publickeybase64 = $key; |
132 |
| - } |
133 |
| - |
134 |
| - public function getPublicKeyBase64() |
135 |
| - { |
136 |
| - return $this->publickeybase64; |
137 |
| - } |
138 | 140 | }
|
0 commit comments