1 | <?php |
||
16 | class KeyUsageExtension extends Extension |
||
17 | { |
||
18 | const DIGITAL_SIGNATURE = 0x100; |
||
19 | const NON_REPUDIATION = 0x080; |
||
20 | const KEY_ENCIPHERMENT = 0x040; |
||
21 | const DATA_ENCIPHERMENT = 0x020; |
||
22 | const KEY_AGREEMENT = 0x010; |
||
23 | const KEY_CERT_SIGN = 0x008; |
||
24 | const CRL_SIGN = 0x004; |
||
25 | const ENCIPHER_ONLY = 0x002; |
||
26 | const DECIPHER_ONLY = 0x001; |
||
27 | |||
28 | /** |
||
29 | * Key usage flags. |
||
30 | * |
||
31 | * @var int $_keyUsage |
||
32 | */ |
||
33 | protected $_keyUsage; |
||
34 | |||
35 | /** |
||
36 | * Constructor. |
||
37 | * |
||
38 | * @param bool $critical |
||
39 | * @param int $keyUsage |
||
40 | */ |
||
41 | 20 | public function __construct(bool $critical, int $keyUsage) |
|
46 | |||
47 | /** |
||
48 | * |
||
49 | * {@inheritdoc} |
||
50 | * @return self |
||
51 | */ |
||
52 | 16 | protected static function _fromDER(string $data, bool $critical): self |
|
58 | |||
59 | /** |
||
60 | * Check whether digitalSignature flag is set. |
||
61 | * |
||
62 | * @return bool |
||
63 | */ |
||
64 | 4 | public function isDigitalSignature(): bool |
|
68 | |||
69 | /** |
||
70 | * Check whether nonRepudiation/contentCommitment flag is set. |
||
71 | * |
||
72 | * @return bool |
||
73 | */ |
||
74 | 2 | public function isNonRepudiation(): bool |
|
78 | |||
79 | /** |
||
80 | * Check whether keyEncipherment flag is set. |
||
81 | * |
||
82 | * @return bool |
||
83 | */ |
||
84 | 3 | public function isKeyEncipherment(): bool |
|
88 | |||
89 | /** |
||
90 | * Check whether dataEncipherment flag is set. |
||
91 | * |
||
92 | * @return bool |
||
93 | */ |
||
94 | 2 | public function isDataEncipherment(): bool |
|
98 | |||
99 | /** |
||
100 | * Check whether keyAgreement flag is set. |
||
101 | * |
||
102 | * @return bool |
||
103 | */ |
||
104 | 2 | public function isKeyAgreement(): bool |
|
108 | |||
109 | /** |
||
110 | * Check whether keyCertSign flag is set. |
||
111 | * |
||
112 | * @return bool |
||
113 | */ |
||
114 | 23 | public function isKeyCertSign(): bool |
|
118 | |||
119 | /** |
||
120 | * Check whether cRLSign flag is set. |
||
121 | * |
||
122 | * @return bool |
||
123 | */ |
||
124 | 2 | public function isCRLSign(): bool |
|
128 | |||
129 | /** |
||
130 | * Check whether encipherOnly flag is set. |
||
131 | * |
||
132 | * @return bool |
||
133 | */ |
||
134 | 2 | public function isEncipherOnly(): bool |
|
138 | |||
139 | /** |
||
140 | * Check whether decipherOnly flag is set. |
||
141 | * |
||
142 | * @return bool |
||
143 | */ |
||
144 | 2 | public function isDecipherOnly(): bool |
|
148 | |||
149 | /** |
||
150 | * Check whether given flag is set. |
||
151 | * |
||
152 | * @param int $flag |
||
153 | * @return boolean |
||
154 | */ |
||
155 | 31 | protected function _flagSet(int $flag): bool |
|
159 | |||
160 | /** |
||
161 | * |
||
162 | * {@inheritdoc} |
||
163 | * @return BitString |
||
164 | */ |
||
165 | 27 | protected function _valueASN1(): BitString |
|
170 | } |
||
171 |