1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Platine Webauth |
5
|
|
|
* |
6
|
|
|
* Platine Webauthn is the implementation of webauthn specifications |
7
|
|
|
* |
8
|
|
|
* This content is released under the MIT License (MIT) |
9
|
|
|
* |
10
|
|
|
* Copyright (c) 2020 Platine Webauth |
11
|
|
|
* Copyright (c) Jakob Bennemann <[email protected]> |
12
|
|
|
* |
13
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
14
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
15
|
|
|
* in the Software without restriction, including without limitation the rights |
16
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
17
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
18
|
|
|
* furnished to do so, subject to the following conditions: |
19
|
|
|
* |
20
|
|
|
* The above copyright notice and this permission notice shall be included in all |
21
|
|
|
* copies or substantial portions of the Software. |
22
|
|
|
* |
23
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
24
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
25
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
26
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
27
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
28
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
29
|
|
|
* SOFTWARE. |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
declare(strict_types=1); |
33
|
|
|
|
34
|
|
|
namespace Platine\Webauthn\Entity; |
35
|
|
|
|
36
|
|
|
use JsonSerializable; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @class Flag |
40
|
|
|
* @package Platine\Webauthn\Entity |
41
|
|
|
*/ |
42
|
|
|
class Flag implements JsonSerializable |
43
|
|
|
{ |
44
|
|
|
/** |
45
|
|
|
* The bit 0 |
46
|
|
|
* @var bool |
47
|
|
|
*/ |
48
|
|
|
protected bool $bit0 = false; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* The bit 1 |
52
|
|
|
* @var bool |
53
|
|
|
*/ |
54
|
|
|
protected bool $bit1 = false; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* The bit 2 |
58
|
|
|
* @var bool |
59
|
|
|
*/ |
60
|
|
|
protected bool $bit2 = false; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* The bit 3 |
64
|
|
|
* @var bool |
65
|
|
|
*/ |
66
|
|
|
protected bool $bit3 = false; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* The bit 4 |
70
|
|
|
* @var bool |
71
|
|
|
*/ |
72
|
|
|
protected bool $bit4 = false; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* The bit 5 |
76
|
|
|
* @var bool |
77
|
|
|
*/ |
78
|
|
|
protected bool $bit5 = false; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* The bit 6 |
82
|
|
|
* @var bool |
83
|
|
|
*/ |
84
|
|
|
protected bool $bit6 = false; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* The bit 7 |
88
|
|
|
* @var bool |
89
|
|
|
*/ |
90
|
|
|
protected bool $bit7 = false; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* User present flag |
94
|
|
|
* @var bool |
95
|
|
|
*/ |
96
|
|
|
protected bool $userPresent = false; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* User verified flag |
100
|
|
|
* @var bool |
101
|
|
|
*/ |
102
|
|
|
protected bool $userVerified = false; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* The flag for attested data include |
106
|
|
|
* @var bool |
107
|
|
|
*/ |
108
|
|
|
protected bool $attestedDataIncluded = false; |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* The flag for extension data include |
112
|
|
|
* @var bool |
113
|
|
|
*/ |
114
|
|
|
protected bool $extensionDataIncluded = false; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Create new instance |
118
|
|
|
* @param int $binaryFlag |
119
|
|
|
*/ |
120
|
|
|
public function __construct(int $binaryFlag) |
121
|
|
|
{ |
122
|
|
|
$this->bit0 = !! ($binaryFlag & 1); |
123
|
|
|
$this->bit1 = !! ($binaryFlag & 2); |
124
|
|
|
$this->bit2 = !! ($binaryFlag & 4); |
125
|
|
|
$this->bit3 = !! ($binaryFlag & 8); |
126
|
|
|
$this->bit4 = !! ($binaryFlag & 16); |
127
|
|
|
$this->bit5 = !! ($binaryFlag & 32); |
128
|
|
|
$this->bit6 = !! ($binaryFlag & 64); |
129
|
|
|
$this->bit7 = !! ($binaryFlag & 128); |
130
|
|
|
|
131
|
|
|
$this->userPresent = $this->bit0; |
132
|
|
|
$this->userVerified = $this->bit2; |
133
|
|
|
$this->attestedDataIncluded = $this->bit6; |
134
|
|
|
$this->extensionDataIncluded = $this->bit7; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* |
139
|
|
|
* @return bool |
140
|
|
|
*/ |
141
|
|
|
public function isBit0(): bool |
142
|
|
|
{ |
143
|
|
|
return $this->bit0; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* |
148
|
|
|
* @return bool |
149
|
|
|
*/ |
150
|
|
|
public function isBit1(): bool |
151
|
|
|
{ |
152
|
|
|
return $this->bit1; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* |
157
|
|
|
* @return bool |
158
|
|
|
*/ |
159
|
|
|
public function isBit2(): bool |
160
|
|
|
{ |
161
|
|
|
return $this->bit2; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* |
166
|
|
|
* @return bool |
167
|
|
|
*/ |
168
|
|
|
public function isBit3(): bool |
169
|
|
|
{ |
170
|
|
|
return $this->bit3; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* |
175
|
|
|
* @return bool |
176
|
|
|
*/ |
177
|
|
|
public function isBit4(): bool |
178
|
|
|
{ |
179
|
|
|
return $this->bit4; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* |
184
|
|
|
* @return bool |
185
|
|
|
*/ |
186
|
|
|
public function isBit5(): bool |
187
|
|
|
{ |
188
|
|
|
return $this->bit5; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* |
193
|
|
|
* @return bool |
194
|
|
|
*/ |
195
|
|
|
public function isBit6(): bool |
196
|
|
|
{ |
197
|
|
|
return $this->bit6; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* |
202
|
|
|
* @return bool |
203
|
|
|
*/ |
204
|
|
|
public function isBit7(): bool |
205
|
|
|
{ |
206
|
|
|
return $this->bit7; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* |
211
|
|
|
* @return bool |
212
|
|
|
*/ |
213
|
|
|
public function isUserPresent(): bool |
214
|
|
|
{ |
215
|
|
|
return $this->userPresent; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* |
220
|
|
|
* @return bool |
221
|
|
|
*/ |
222
|
|
|
public function isUserVerified(): bool |
223
|
|
|
{ |
224
|
|
|
return $this->userVerified; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* |
229
|
|
|
* @return bool |
230
|
|
|
*/ |
231
|
|
|
public function isAttestedDataIncluded(): bool |
232
|
|
|
{ |
233
|
|
|
return $this->attestedDataIncluded; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* |
238
|
|
|
* @return bool |
239
|
|
|
*/ |
240
|
|
|
public function isExtensionDataIncluded(): bool |
241
|
|
|
{ |
242
|
|
|
return $this->extensionDataIncluded; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* {@inheritdoc} |
247
|
|
|
* @return mixed |
248
|
|
|
*/ |
249
|
|
|
public function jsonSerialize(): mixed |
250
|
|
|
{ |
251
|
|
|
return get_object_vars($this); |
252
|
|
|
} |
253
|
|
|
} |
254
|
|
|
|