Completed
Pull Request — master (#49)
by Sam
01:29
created

RRSIG::setAlgorithm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of Badcow DNS Library.
5
 *
6
 * (c) Samuel Williams <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Badcow\DNS\Rdata;
13
14
class RRSIG implements RdataInterface
15
{
16
    use RdataTrait;
17
18
    const TYPE = 'RRSIG';
19
20
    /**
21
     *  The Type Covered field identifies the type of the RRset that is
22
     * covered by this RRSIG record. E.G. A, MX, AAAA, etc.
23
     *
24
     * @var string
25
     */
26
    private $typeCovered;
27
28
    /**
29
     * The Algorithm field identifies the public key's cryptographic
30
     * algorithm and determines the format of the Public Key field.
31
     * {@link https://tools.ietf.org/html/rfc4034#section-3.1.2}.
32
     *
33
     * @var int
34
     */
35
    private $algorithm;
36
37
    /**
38
     * The Labels field specifies the number of labels in the original RRSIG
39
     * RR owner name.
40
     * {@link https://tools.ietf.org/html/rfc4034#section-3.1.3}.
41
     *
42
     * @var int
43
     */
44
    private $labels;
45
46
    /**
47
     * The Original TTL field specifies the TTL of the covered RRset as it
48
     * appears in the authoritative zone.
49
     * {@link https://tools.ietf.org/html/rfc4034#section-3.1.4}.
50
     *
51
     * @var int
52
     */
53
    private $originalTtl;
54
55
    /**
56
     * 32-bit unsigned integer specifying the expiration date of a signature.
57
     * {@link https://tools.ietf.org/html/rfc4034#section-3.1.5}.
58
     *
59
     * @var int
60
     */
61
    private $signatureExpiration;
62
63
    /**
64
     * 32-bit unsigned integer specifying the inception date of a signature.
65
     * {@link https://tools.ietf.org/html/rfc4034#section-3.1.5}.
66
     *
67
     * @var int
68
     */
69
    private $signatureInception;
70
71
    /**
72
     * The Key Tag field contains the key tag value of the DNSKEY RR that
73
     * validates this signature, in network byte order.
74
     * {@link https://tools.ietf.org/html/rfc4034#section-3.1.6}.
75
     *
76
     * @var int
77
     */
78
    private $keyTag;
79
80
    /**
81
     * The Signer's Name field value identifies the owner name of the DNSKEY\
82
     * RR that a validator is supposed to use to validate this signature.
83
     * The Signer's Name field MUST contain the name of the zone of the
84
     * covered RRset.
85
     * {@link https://tools.ietf.org/html/rfc4034#section-3.1.7}.
86
     *
87
     * @var string
88
     */
89
    private $signersName;
90
91
    /**
92
     * The Signature field contains the cryptographic signature that covers
93
     * the RRSIG RDATA (excluding the Signature field) and the RRset
94
     * specified by the RRSIG owner name, RRSIG class, and RRSIG Type
95
     * Covered field.
96
     * {@link https://tools.ietf.org/html/rfc4034#section-3.1.8}.
97
     *
98
     * @var string
99
     */
100
    private $signature;
101
102
    /**
103
     * @return string
104
     */
105 2
    public function getTypeCovered(): string
106
    {
107 2
        return $this->typeCovered;
108
    }
109
110
    /**
111
     * @param string $typeCovered
112
     */
113 4
    public function setTypeCovered(string $typeCovered): void
114
    {
115 4
        $this->typeCovered = $typeCovered;
116 4
    }
117
118
    /**
119
     * @return int
120
     */
121 2
    public function getAlgorithm(): int
122
    {
123 2
        return $this->algorithm;
124
    }
125
126
    /**
127
     * @param int $algorithm
128
     */
129 4
    public function setAlgorithm(int $algorithm): void
130
    {
131 4
        $this->algorithm = $algorithm;
132 4
    }
133
134
    /**
135
     * @return int
136
     */
137 2
    public function getLabels(): int
138
    {
139 2
        return $this->labels;
140
    }
141
142
    /**
143
     * @param int $labels
144
     */
145 4
    public function setLabels(int $labels)
146
    {
147 4
        $this->labels = $labels;
148 4
    }
149
150
    /**
151
     * @return int
152
     */
153 2
    public function getOriginalTtl(): int
154
    {
155 2
        return $this->originalTtl;
156
    }
157
158
    /**
159
     * @param int $originalTtl
160
     */
161 4
    public function setOriginalTtl(int $originalTtl): void
162
    {
163 4
        $this->originalTtl = $originalTtl;
164 4
    }
165
166
    /**
167
     * @return int
168
     */
169 2
    public function getSignatureExpiration(): int
170
    {
171 2
        return $this->signatureExpiration;
172
    }
173
174
    /**
175
     * @param int $signatureExpiration
176
     */
177 4
    public function setSignatureExpiration(int $signatureExpiration): void
178
    {
179 4
        $this->signatureExpiration = $signatureExpiration;
180 4
    }
181
182
    /**
183
     * @return int
184
     */
185 2
    public function getSignatureInception(): int
186
    {
187 2
        return $this->signatureInception;
188
    }
189
190
    /**
191
     * @param int $signatureInception
192
     */
193 4
    public function setSignatureInception(int $signatureInception): void
194
    {
195 4
        $this->signatureInception = $signatureInception;
196 4
    }
197
198
    /**
199
     * @return int
200
     */
201 2
    public function getKeyTag(): int
202
    {
203 2
        return $this->keyTag;
204
    }
205
206
    /**
207
     * @param int $keyTag
208
     */
209 4
    public function setKeyTag(int $keyTag): void
210
    {
211 4
        $this->keyTag = $keyTag;
212 4
    }
213
214
    /**
215
     * @return string
216
     */
217 2
    public function getSignersName(): string
218
    {
219 2
        return $this->signersName;
220
    }
221
222
    /**
223
     * @param string $signersName
224
     */
225 4
    public function setSignersName(string $signersName): void
226
    {
227 4
        $this->signersName = $signersName;
228 4
    }
229
230
    /**
231
     * @return string
232
     */
233 2
    public function getSignature(): string
234
    {
235 2
        return $this->signature;
236
    }
237
238
    /**
239
     * @param string $signature
240
     */
241 4
    public function setSignature(string $signature): void
242
    {
243 4
        $this->signature = $signature;
244 4
    }
245
246
    /**
247
     * {@inheritdoc}
248
     */
249 2
    public function output(): string
250
    {
251 2
        return sprintf(
252 2
            '%s %s %s %s %s %s %s %s %s',
253 2
            $this->typeCovered,
254 2
            $this->algorithm,
255 2
            $this->labels,
256 2
            $this->originalTtl,
257 2
            $this->signatureExpiration,
258 2
            $this->signatureInception,
259 2
            $this->keyTag,
260 2
            $this->signersName,
261 2
            $this->signature
262
        );
263
    }
264
}
265