|
| 1 | +<?php |
| 2 | + |
| 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) |
| 34 | + { |
| 35 | + $this->keytag = 0xffff & unpack("n", substr($wire,-3,2)) ; |
| 36 | + } |
| 37 | + else |
| 38 | + { |
| 39 | + $sum=0; |
| 40 | + for($i = 0; $i < strlen($wire); $i++) |
| 41 | + { |
| 42 | + $a = unpack("C", substr($wire,$i,1)); |
| 43 | + $sum += ($i & 1) ? $a[1] : $a[1] << 8; |
| 44 | + } |
| 45 | + $this->keytag = 0xffff & ($sum + ($sum >> 16)); |
| 46 | + } |
| 47 | + } |
| 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 | +} |
0 commit comments