|
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\DNSSEC;
|
|
13
|
|
|
|
|
14
|
|
|
use Badcow\DNS\Rdata\RdataInterface;
|
|
15
|
|
|
use Badcow\DNS\Rdata\RdataTrait;
|
|
16
|
|
|
|
|
17
|
|
|
/**
|
|
18
|
|
|
* Class DnskeyRdata
|
|
19
|
|
|
*
|
|
20
|
|
|
* {@link https://tools.ietf.org/html/rfc4034#section-2.1}
|
|
21
|
|
|
*
|
|
22
|
|
|
* @package Badcow\DNS\Rdata
|
|
23
|
|
|
*/
|
|
24
|
|
|
class DnskeyRdata implements RdataInterface
|
|
25
|
|
|
{
|
|
26
|
|
|
use RdataTrait;
|
|
27
|
|
|
|
|
28
|
|
|
const TYPE = 'DNSKEY';
|
|
29
|
|
|
|
|
30
|
|
|
/**
|
|
31
|
|
|
* {@link https://tools.ietf.org/html/rfc4034#section-2.1.1}
|
|
32
|
|
|
*
|
|
33
|
|
|
* @var int
|
|
34
|
|
|
*/
|
|
35
|
|
|
private $flags;
|
|
36
|
|
|
|
|
37
|
|
|
/**
|
|
38
|
|
|
* The Protocol Field MUST have value 3, and the DNSKEY RR MUST be
|
|
39
|
|
|
* treated as invalid during signature verification if it is found to be
|
|
40
|
|
|
* some value other than 3.
|
|
41
|
|
|
* {@link https://tools.ietf.org/html/rfc4034#section-2.1.2}
|
|
42
|
|
|
*
|
|
43
|
|
|
* @var int
|
|
44
|
|
|
*/
|
|
45
|
|
|
private $protocol = 3;
|
|
46
|
|
|
|
|
47
|
|
|
/**
|
|
48
|
|
|
* The Algorithm field identifies the public key's cryptographic
|
|
49
|
|
|
* algorithm and determines the format of the Public Key field.
|
|
50
|
|
|
* {@link https://tools.ietf.org/html/rfc4034#section-2.1.3}
|
|
51
|
|
|
*
|
|
52
|
|
|
* @var int
|
|
53
|
|
|
*/
|
|
54
|
|
|
private $algorithm;
|
|
55
|
|
|
|
|
56
|
|
|
/**
|
|
57
|
|
|
* The Public Key field is a Base64 encoding of the Public Key.
|
|
58
|
|
|
* Whitespace is allowed within the Base64 text.
|
|
59
|
|
|
* {@link https://tools.ietf.org/html/rfc4034#section-2.1.4}
|
|
60
|
|
|
*
|
|
61
|
|
|
* @var string
|
|
62
|
|
|
*/
|
|
63
|
|
|
private $publicKey;
|
|
64
|
|
|
|
|
65
|
|
|
/**
|
|
66
|
|
|
* @return int
|
|
67
|
|
|
*/
|
|
68
|
|
|
public function getFlags()
|
|
69
|
|
|
{
|
|
70
|
|
|
return $this->flags;
|
|
71
|
|
|
}
|
|
72
|
|
|
|
|
73
|
|
|
/**
|
|
74
|
|
|
* @param int $flags
|
|
75
|
|
|
*/
|
|
76
|
3 |
|
public function setFlags($flags)
|
|
77
|
|
|
{
|
|
78
|
3 |
|
$this->flags = $flags;
|
|
79
|
3 |
|
}
|
|
80
|
|
|
|
|
81
|
|
|
/**
|
|
82
|
|
|
* @return int
|
|
83
|
|
|
*/
|
|
84
|
|
|
public function getProtocol()
|
|
85
|
|
|
{
|
|
86
|
|
|
return $this->protocol;
|
|
87
|
|
|
}
|
|
88
|
|
|
|
|
89
|
|
|
/**
|
|
90
|
|
|
* @return int
|
|
91
|
|
|
*/
|
|
92
|
|
|
public function getAlgorithm()
|
|
93
|
|
|
{
|
|
94
|
|
|
return $this->algorithm;
|
|
95
|
|
|
}
|
|
96
|
|
|
|
|
97
|
|
|
/**
|
|
98
|
|
|
* @param int $algorithm
|
|
99
|
|
|
*/
|
|
100
|
3 |
|
public function setAlgorithm($algorithm)
|
|
101
|
|
|
{
|
|
102
|
3 |
|
$this->algorithm = $algorithm;
|
|
103
|
3 |
|
}
|
|
104
|
|
|
|
|
105
|
|
|
/**
|
|
106
|
|
|
* @return string
|
|
107
|
|
|
*/
|
|
108
|
|
|
public function getPublicKey()
|
|
109
|
|
|
{
|
|
110
|
|
|
return $this->publicKey;
|
|
111
|
|
|
}
|
|
112
|
|
|
|
|
113
|
|
|
/**
|
|
114
|
|
|
* @param string $publicKey
|
|
115
|
|
|
*/
|
|
116
|
3 |
|
public function setPublicKey($publicKey)
|
|
117
|
|
|
{
|
|
118
|
3 |
|
$this->publicKey = $publicKey;
|
|
119
|
3 |
|
}
|
|
120
|
|
|
|
|
121
|
|
|
/**
|
|
122
|
|
|
* {@inheritdoc}
|
|
123
|
|
|
*/
|
|
124
|
3 |
|
public function output()
|
|
125
|
|
|
{
|
|
126
|
3 |
|
return sprintf(
|
|
127
|
3 |
|
'%s %s %s %s',
|
|
128
|
3 |
|
$this->flags,
|
|
129
|
3 |
|
$this->protocol,
|
|
130
|
3 |
|
$this->algorithm,
|
|
131
|
3 |
|
$this->publicKey
|
|
132
|
2 |
|
);
|
|
133
|
|
|
}
|
|
134
|
|
|
} |