1 | <?php |
||
22 | class IPSECKEY implements RdataInterface |
||
23 | { |
||
24 | use RdataTrait; |
||
25 | |||
26 | const TYPE = 'IPSECKEY'; |
||
27 | const TYPE_CODE = 45; |
||
28 | const ALGORITHM_NONE = 0; |
||
29 | const ALGORITHM_DSA = 1; |
||
30 | const ALGORITHM_RSA = 2; |
||
31 | const ALGORITHM_ECDSA = 3; |
||
32 | |||
33 | /** |
||
34 | * This is an 8-bit precedence for this record. It is interpreted in |
||
35 | * the same way as the PREFERENCE field described in section 3.3.9 of |
||
36 | * RFC 1035. |
||
37 | * |
||
38 | * Gateways listed in IPSECKEY records with lower precedence are to be |
||
39 | * attempted first. Where there is a tie in precedence, the order |
||
40 | * should be non-deterministic. |
||
41 | * |
||
42 | * @var int |
||
43 | */ |
||
44 | private $precedence; |
||
45 | |||
46 | /** |
||
47 | * The gateway type field indicates the format of the information that |
||
48 | * is stored in the gateway field. |
||
49 | * |
||
50 | * The following values are defined: |
||
51 | * - 0: No gateway is present. |
||
52 | * - 1: A 4-byte IPv4 address is present. |
||
53 | * - 2: A 16-byte IPv6 address is present. |
||
54 | * - 3: A wire-encoded domain name is present. The wire-encoded format is |
||
55 | * self-describing, so the length is implicit. The domain name MUST |
||
56 | * NOT be compressed. (See Section 3.3 of RFC 1035.) |
||
57 | * |
||
58 | * @var int |
||
59 | */ |
||
60 | private $gatewayType; |
||
61 | |||
62 | /** |
||
63 | * 7-bit The algorithm type field identifies the public key's crypto- |
||
64 | * graphic algorithm and determines the format of the public key field. |
||
65 | * A value of 0 indicates that no key is present. |
||
66 | * |
||
67 | * The following values are defined: |
||
68 | * - 1: A DSA key is present, in the format defined in RFC 2536. |
||
69 | * - 2: A RSA key is present, in the format defined in RFC 3110. |
||
70 | * - 3: An ECDSA key is present, in the format defined in RFC 6605. |
||
71 | * |
||
72 | * @var int |
||
73 | */ |
||
74 | private $algorithm = 0; |
||
75 | |||
76 | /** |
||
77 | * The gateway field indicates a gateway to which an IPsec tunnel may be. |
||
78 | * created in order to reach the entity named by this resource record. |
||
79 | * |
||
80 | * There are three formats: |
||
81 | * |
||
82 | * A 32-bit IPv4 address is present in the gateway field. The data |
||
83 | * portion is an IPv4 address as described in section 3.4.1 of RFC 1035. |
||
84 | * This is a 32-bit number in network byte order. |
||
85 | * |
||
86 | * A 128-bit IPv6 address is present in the gateway field. The data |
||
87 | * portion is an IPv6 address as described in section 2.2 of RFC 3596 |
||
88 | * This is a 128-bit number in network byte order. |
||
89 | * |
||
90 | * The gateway field is a normal wire-encoded domain name, as described |
||
91 | * in section 3.3 of RFC 1035. Compression MUST NOT be used. |
||
92 | * |
||
93 | * @var string|null |
||
94 | */ |
||
95 | private $gateway; |
||
96 | |||
97 | /** |
||
98 | * Both the public key types defined in this document (RSA and DSA) |
||
99 | * inherit their public key formats from the corresponding KEY RR |
||
100 | * formats. Specifically, the public key field contains the |
||
101 | * algorithm-specific portion of the KEY RR RDATA, which is all the KEY |
||
102 | * RR DATA after the first four octets. This is the same portion of the |
||
103 | * KEY RR that must be specified by documents that define a DNSSEC |
||
104 | * algorithm. Those documents also specify a message digest to be used |
||
105 | * for generation of SIG RRs; that specification is not relevant for |
||
106 | * IPSECKEY RRs. |
||
107 | * |
||
108 | * @var string|null |
||
109 | */ |
||
110 | private $publicKey = null; |
||
111 | |||
112 | /** |
||
113 | * @return int |
||
114 | */ |
||
115 | 12 | public function getPrecedence(): int |
|
119 | |||
120 | /** |
||
121 | * @param int $precedence |
||
122 | * |
||
123 | * @throws \InvalidArgumentException |
||
124 | */ |
||
125 | 24 | public function setPrecedence(int $precedence): void |
|
132 | |||
133 | /** |
||
134 | * @return int |
||
135 | */ |
||
136 | 12 | public function getGatewayType(): int |
|
140 | |||
141 | /** |
||
142 | * @return int |
||
143 | */ |
||
144 | 12 | public function getAlgorithm(): int |
|
148 | |||
149 | /** |
||
150 | * @param int $algorithm |
||
151 | * |
||
152 | * @throws \InvalidArgumentException |
||
153 | */ |
||
154 | 24 | private function setAlgorithm(int $algorithm): void |
|
161 | |||
162 | /** |
||
163 | * @return string|null |
||
164 | */ |
||
165 | 12 | public function getGateway(): ?string |
|
169 | |||
170 | /** |
||
171 | * @param string|null $gateway either &null for no gateway, a fully qualified domain name, or an IPv4 or IPv6 address |
||
172 | * |
||
173 | * @throws \InvalidArgumentException |
||
174 | */ |
||
175 | 24 | public function setGateway(?string $gateway): void |
|
192 | |||
193 | /** |
||
194 | * @return string|null base64 encoded public key |
||
195 | */ |
||
196 | 12 | public function getPublicKey(): ?string |
|
200 | |||
201 | /** |
||
202 | * @param int $algorithm either IPSECKEY::ALGORITHM_NONE, IPSECKEY::ALGORITHM_DSA, IPSECKEY::ALGORITHM_RSA, or IPSECKEY::ALGORITHM_ECDSA |
||
203 | * @param string|null $publicKey base64 encoded public key |
||
204 | * |
||
205 | * @throws \InvalidArgumentException |
||
206 | */ |
||
207 | 24 | public function setPublicKey(int $algorithm, ?string $publicKey): void |
|
223 | |||
224 | /** |
||
225 | * {@inheritdoc} |
||
226 | */ |
||
227 | 12 | public function toText(): string |
|
241 | |||
242 | /** |
||
243 | * {@inheritdoc} |
||
244 | */ |
||
245 | 6 | public function toWire(): string |
|
263 | |||
264 | /** |
||
265 | * {@inheritdoc} |
||
266 | * |
||
267 | * @return IPSECKEY |
||
268 | */ |
||
269 | 6 | public static function fromText(string $text): RdataInterface |
|
283 | |||
284 | /** |
||
285 | * {@inheritdoc} |
||
286 | * |
||
287 | * @return IPSECKEY |
||
288 | */ |
||
289 | 6 | public static function fromWire(string $rdata): RdataInterface |
|
332 | } |
||
333 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.