| 1 |
Escaped mutants: |
| 2 |
================ |
| 3 |
|
| 4 |
1) /home/florent/PhpstormProjects/aes-key-wrap/src/A128KW.php:11 [M] ProtectedVisibility |
| 5 |
|
| 6 |
--- Original |
| 7 |
+++ New |
| 8 |
@@ @@ |
| 9 |
final class A128KW implements Wrapper |
| 10 |
{ |
| 11 |
use AESKW; |
| 12 |
- protected static function getMethod() : string |
| 13 |
+ private static function getMethod() : string |
| 14 |
{ |
| 15 |
return 'aes-128-ecb'; |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
2) /home/florent/PhpstormProjects/aes-key-wrap/src/A192KW.php:11 [M] ProtectedVisibility |
| 21 |
|
| 22 |
--- Original |
| 23 |
+++ New |
| 24 |
@@ @@ |
| 25 |
final class A192KW implements Wrapper |
| 26 |
{ |
| 27 |
use AESKW; |
| 28 |
- protected static function getMethod() : string |
| 29 |
+ private static function getMethod() : string |
| 30 |
{ |
| 31 |
return 'aes-192-ecb'; |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
3) /home/florent/PhpstormProjects/aes-key-wrap/src/A256KW.php:11 [M] ProtectedVisibility |
| 37 |
|
| 38 |
--- Original |
| 39 |
+++ New |
| 40 |
@@ @@ |
| 41 |
final class A256KW implements Wrapper |
| 42 |
{ |
| 43 |
use AESKW; |
| 44 |
- protected static function getMethod() : string |
| 45 |
+ private static function getMethod() : string |
| 46 |
{ |
| 47 |
return 'aes-256-ecb'; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
4) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:31 [M] MBString |
| 53 |
|
| 54 |
--- Original |
| 55 |
+++ New |
| 56 |
@@ @@ |
| 57 |
{ |
| 58 |
$A = self::getInitialValue($key, $padding_enabled); |
| 59 |
self::checkKeySize($key, $padding_enabled); |
| 60 |
- $P = mb_str_split($key, 8, '8bit'); |
| 61 |
+ $P = str_split($key, 8); |
| 62 |
$N = count($P); |
| 63 |
$C = []; |
| 64 |
if ($N === 1) { |
| 65 |
|
| 66 |
|
| 67 |
5) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:38 [M] IncrementInteger |
| 68 |
|
| 69 |
--- Original |
| 70 |
+++ New |
| 71 |
@@ @@ |
| 72 |
if ($N === 1) { |
| 73 |
$B = self::encrypt($kek, $A . $P[0]); |
| 74 |
$C[0] = self::getMSB($B); |
| 75 |
- $C[1] = self::getLSB($B); |
| 76 |
+ $C[2] = self::getLSB($B); |
| 77 |
} elseif ($N > 1) { |
| 78 |
$R = $P; |
| 79 |
for ($j = 0; $j <= 5; ++$j) { |
| 80 |
|
| 81 |
|
| 82 |
6) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:39 [M] GreaterThan |
| 83 |
|
| 84 |
--- Original |
| 85 |
+++ New |
| 86 |
@@ @@ |
| 87 |
$B = self::encrypt($kek, $A . $P[0]); |
| 88 |
$C[0] = self::getMSB($B); |
| 89 |
$C[1] = self::getLSB($B); |
| 90 |
- } elseif ($N > 1) { |
| 91 |
+ } elseif ($N >= 1) { |
| 92 |
$R = $P; |
| 93 |
for ($j = 0; $j <= 5; ++$j) { |
| 94 |
for ($i = 1; $i <= $N; ++$i) { |
| 95 |
|
| 96 |
|
| 97 |
7) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:62 [M] FalseValue |
| 98 |
|
| 99 |
--- Original |
| 100 |
+++ New |
| 101 |
@@ @@ |
| 102 |
* |
| 103 |
* @return string The key unwrapped |
| 104 |
*/ |
| 105 |
- public static function unwrap(string $kek, string $key, bool $padding_enabled = false) : string |
| 106 |
+ public static function unwrap(string $kek, string $key, bool $padding_enabled = true) : string |
| 107 |
{ |
| 108 |
$P = mb_str_split($key, 8, '8bit'); |
| 109 |
$A = $P[0]; |
| 110 |
|
| 111 |
|
| 112 |
8) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:64 [M] MBString |
| 113 |
|
| 114 |
--- Original |
| 115 |
+++ New |
| 116 |
@@ @@ |
| 117 |
*/ |
| 118 |
public static function unwrap(string $kek, string $key, bool $padding_enabled = false) : string |
| 119 |
{ |
| 120 |
- $P = mb_str_split($key, 8, '8bit'); |
| 121 |
+ $P = str_split($key, 8); |
| 122 |
$A = $P[0]; |
| 123 |
$N = count($P); |
| 124 |
if ($N < 2) { |
| 125 |
|
| 126 |
|
| 127 |
9) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:110 [M] FalseValue |
| 128 |
|
| 129 |
--- Original |
| 130 |
+++ New |
| 131 |
@@ @@ |
| 132 |
{ |
| 133 |
if ($padding_enabled === false) { |
| 134 |
$bin = hex2bin('A6A6A6A6A6A6A6A6'); |
| 135 |
- if ($bin === false) { |
| 136 |
+ if ($bin === true) { |
| 137 |
throw new InvalidArgumentException('Unable to convert the data'); |
| 138 |
} |
| 139 |
return $bin; |
| 140 |
|
| 141 |
|
| 142 |
10) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:117 [M] MBString |
| 143 |
|
| 144 |
--- Original |
| 145 |
+++ New |
| 146 |
@@ @@ |
| 147 |
} |
| 148 |
return $bin; |
| 149 |
} |
| 150 |
- $MLI = mb_strlen($key, '8bit'); |
| 151 |
+ $MLI = strlen($key); |
| 152 |
$iv = hex2bin('A65959A6') . self::toXBits(32, $MLI); |
| 153 |
$n = (int) ceil($MLI / 8); |
| 154 |
$key = str_pad($key, 8 * $n, "\x00", STR_PAD_RIGHT); |
| 155 |
|
| 156 |
|
| 157 |
11) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:120 [M] DecrementInteger |
| 158 |
|
| 159 |
--- Original |
| 160 |
+++ New |
| 161 |
@@ @@ |
| 162 |
} |
| 163 |
$MLI = mb_strlen($key, '8bit'); |
| 164 |
$iv = hex2bin('A65959A6') . self::toXBits(32, $MLI); |
| 165 |
- $n = (int) ceil($MLI / 8); |
| 166 |
+ $n = (int) ceil($MLI / 7); |
| 167 |
$key = str_pad($key, 8 * $n, "\x00", STR_PAD_RIGHT); |
| 168 |
return $iv; |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
12) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:120 [M] IncrementInteger |
| 173 |
|
| 174 |
--- Original |
| 175 |
+++ New |
| 176 |
@@ @@ |
| 177 |
} |
| 178 |
$MLI = mb_strlen($key, '8bit'); |
| 179 |
$iv = hex2bin('A65959A6') . self::toXBits(32, $MLI); |
| 180 |
- $n = (int) ceil($MLI / 8); |
| 181 |
+ $n = (int) ceil($MLI / 9); |
| 182 |
$key = str_pad($key, 8 * $n, "\x00", STR_PAD_RIGHT); |
| 183 |
return $iv; |
| 184 |
} |
| 185 |
|
| 186 |
|
| 187 |
13) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:120 [M] RoundingFamily |
| 188 |
|
| 189 |
--- Original |
| 190 |
+++ New |
| 191 |
@@ @@ |
| 192 |
} |
| 193 |
$MLI = mb_strlen($key, '8bit'); |
| 194 |
$iv = hex2bin('A65959A6') . self::toXBits(32, $MLI); |
| 195 |
- $n = (int) ceil($MLI / 8); |
| 196 |
+ $n = (int) round($MLI / 8); |
| 197 |
$key = str_pad($key, 8 * $n, "\x00", STR_PAD_RIGHT); |
| 198 |
return $iv; |
| 199 |
} |
| 200 |
|
| 201 |
|
| 202 |
14) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:143 [M] MBString |
| 203 |
|
| 204 |
--- Original |
| 205 |
+++ New |
| 206 |
@@ @@ |
| 207 |
if (hex2bin('A65959A6') !== self::getMSB($iv)) { |
| 208 |
return false; |
| 209 |
} |
| 210 |
- $n = mb_strlen($key, '8bit') / 8; |
| 211 |
+ $n = strlen($key) / 8; |
| 212 |
$MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 213 |
if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 214 |
return false; |
| 215 |
|
| 216 |
|
| 217 |
15) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:143 [M] IncrementInteger |
| 218 |
|
| 219 |
--- Original |
| 220 |
+++ New |
| 221 |
@@ @@ |
| 222 |
if (hex2bin('A65959A6') !== self::getMSB($iv)) { |
| 223 |
return false; |
| 224 |
} |
| 225 |
- $n = mb_strlen($key, '8bit') / 8; |
| 226 |
+ $n = mb_strlen($key, '8bit') / 9; |
| 227 |
$MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 228 |
if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 229 |
return false; |
| 230 |
|
| 231 |
|
| 232 |
16) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:144 [M] UnwrapLtrim |
| 233 |
|
| 234 |
--- Original |
| 235 |
+++ New |
| 236 |
@@ @@ |
| 237 |
return false; |
| 238 |
} |
| 239 |
$n = mb_strlen($key, '8bit') / 8; |
| 240 |
- $MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 241 |
+ $MLI = (int) hexdec(bin2hex(self::getLSB($iv))); |
| 242 |
if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 243 |
return false; |
| 244 |
} |
| 245 |
|
| 246 |
|
| 247 |
17) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:144 [M] CastInt |
| 248 |
|
| 249 |
--- Original |
| 250 |
+++ New |
| 251 |
@@ @@ |
| 252 |
return false; |
| 253 |
} |
| 254 |
$n = mb_strlen($key, '8bit') / 8; |
| 255 |
- $MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 256 |
+ $MLI = hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 257 |
if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 258 |
return false; |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
18) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:146 [M] DecrementInteger |
| 263 |
|
| 264 |
--- Original |
| 265 |
+++ New |
| 266 |
@@ @@ |
| 267 |
} |
| 268 |
$n = mb_strlen($key, '8bit') / 8; |
| 269 |
$MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 270 |
- if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 271 |
+ if (!(7 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 272 |
return false; |
| 273 |
} |
| 274 |
$b = 8 * $n - $MLI; |
| 275 |
|
| 276 |
|
| 277 |
19) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:146 [M] IncrementInteger |
| 278 |
|
| 279 |
--- Original |
| 280 |
+++ New |
| 281 |
@@ @@ |
| 282 |
} |
| 283 |
$n = mb_strlen($key, '8bit') / 8; |
| 284 |
$MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 285 |
- if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 286 |
+ if (!(9 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 287 |
return false; |
| 288 |
} |
| 289 |
$b = 8 * $n - $MLI; |
| 290 |
|
| 291 |
|
| 292 |
20) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:146 [M] IncrementInteger |
| 293 |
|
| 294 |
--- Original |
| 295 |
+++ New |
| 296 |
@@ @@ |
| 297 |
} |
| 298 |
$n = mb_strlen($key, '8bit') / 8; |
| 299 |
$MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 300 |
- if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 301 |
+ if (!(8 * ($n - 2) < $MLI && $MLI <= 8 * $n)) { |
| 302 |
return false; |
| 303 |
} |
| 304 |
$b = 8 * $n - $MLI; |
| 305 |
|
| 306 |
|
| 307 |
21) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:146 [M] LessThan |
| 308 |
|
| 309 |
--- Original |
| 310 |
+++ New |
| 311 |
@@ @@ |
| 312 |
} |
| 313 |
$n = mb_strlen($key, '8bit') / 8; |
| 314 |
$MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 315 |
- if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 316 |
+ if (!(8 * ($n - 1) <= $MLI && $MLI <= 8 * $n)) { |
| 317 |
return false; |
| 318 |
} |
| 319 |
$b = 8 * $n - $MLI; |
| 320 |
|
| 321 |
|
| 322 |
22) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:146 [M] DecrementInteger |
| 323 |
|
| 324 |
--- Original |
| 325 |
+++ New |
| 326 |
@@ @@ |
| 327 |
} |
| 328 |
$n = mb_strlen($key, '8bit') / 8; |
| 329 |
$MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 330 |
- if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 331 |
+ if (!(8 * ($n - 1) < $MLI && $MLI <= 7 * $n)) { |
| 332 |
return false; |
| 333 |
} |
| 334 |
$b = 8 * $n - $MLI; |
| 335 |
|
| 336 |
|
| 337 |
23) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:146 [M] IncrementInteger |
| 338 |
|
| 339 |
--- Original |
| 340 |
+++ New |
| 341 |
@@ @@ |
| 342 |
} |
| 343 |
$n = mb_strlen($key, '8bit') / 8; |
| 344 |
$MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 345 |
- if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 346 |
+ if (!(8 * ($n - 1) < $MLI && $MLI <= 9 * $n)) { |
| 347 |
return false; |
| 348 |
} |
| 349 |
$b = 8 * $n - $MLI; |
| 350 |
|
| 351 |
|
| 352 |
24) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:146 [M] LessThanOrEqualTo |
| 353 |
|
| 354 |
--- Original |
| 355 |
+++ New |
| 356 |
@@ @@ |
| 357 |
} |
| 358 |
$n = mb_strlen($key, '8bit') / 8; |
| 359 |
$MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 360 |
- if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 361 |
+ if (!(8 * ($n - 1) < $MLI && $MLI < 8 * $n)) { |
| 362 |
return false; |
| 363 |
} |
| 364 |
$b = 8 * $n - $MLI; |
| 365 |
|
| 366 |
|
| 367 |
25) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:146 [M] LogicalAnd |
| 368 |
|
| 369 |
--- Original |
| 370 |
+++ New |
| 371 |
@@ @@ |
| 372 |
} |
| 373 |
$n = mb_strlen($key, '8bit') / 8; |
| 374 |
$MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 375 |
- if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 376 |
+ if (!(8 * ($n - 1) < $MLI || $MLI <= 8 * $n)) { |
| 377 |
return false; |
| 378 |
} |
| 379 |
$b = 8 * $n - $MLI; |
| 380 |
|
| 381 |
|
| 382 |
26) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:150 [M] DecrementInteger |
| 383 |
|
| 384 |
--- Original |
| 385 |
+++ New |
| 386 |
@@ @@ |
| 387 |
if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 388 |
return false; |
| 389 |
} |
| 390 |
- $b = 8 * $n - $MLI; |
| 391 |
+ $b = 7 * $n - $MLI; |
| 392 |
for ($i = 0; $i < $b; ++$i) { |
| 393 |
if (mb_substr($key, $MLI + $i, 1, '8bit') !== "\x00") { |
| 394 |
return false; |
| 395 |
|
| 396 |
|
| 397 |
27) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:150 [M] Multiplication |
| 398 |
|
| 399 |
--- Original |
| 400 |
+++ New |
| 401 |
@@ @@ |
| 402 |
if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 403 |
return false; |
| 404 |
} |
| 405 |
- $b = 8 * $n - $MLI; |
| 406 |
+ $b = 8 / $n - $MLI; |
| 407 |
for ($i = 0; $i < $b; ++$i) { |
| 408 |
if (mb_substr($key, $MLI + $i, 1, '8bit') !== "\x00") { |
| 409 |
return false; |
| 410 |
|
| 411 |
|
| 412 |
28) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:151 [M] LessThanNegotiation |
| 413 |
|
| 414 |
--- Original |
| 415 |
+++ New |
| 416 |
@@ @@ |
| 417 |
return false; |
| 418 |
} |
| 419 |
$b = 8 * $n - $MLI; |
| 420 |
- for ($i = 0; $i < $b; ++$i) { |
| 421 |
+ for ($i = 0; $i >= $b; ++$i) { |
| 422 |
if (mb_substr($key, $MLI + $i, 1, '8bit') !== "\x00") { |
| 423 |
return false; |
| 424 |
} |
| 425 |
|
| 426 |
|
| 427 |
29) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:151 [M] For_ |
| 428 |
|
| 429 |
--- Original |
| 430 |
+++ New |
| 431 |
@@ @@ |
| 432 |
return false; |
| 433 |
} |
| 434 |
$b = 8 * $n - $MLI; |
| 435 |
- for ($i = 0; $i < $b; ++$i) { |
| 436 |
+ for ($i = 0; false; ++$i) { |
| 437 |
if (mb_substr($key, $MLI + $i, 1, '8bit') !== "\x00") { |
| 438 |
return false; |
| 439 |
} |
| 440 |
|
| 441 |
|
| 442 |
30) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:152 [M] MBString |
| 443 |
|
| 444 |
--- Original |
| 445 |
+++ New |
| 446 |
@@ @@ |
| 447 |
} |
| 448 |
$b = 8 * $n - $MLI; |
| 449 |
for ($i = 0; $i < $b; ++$i) { |
| 450 |
- if (mb_substr($key, $MLI + $i, 1, '8bit') !== "\x00") { |
| 451 |
+ if (substr($key, $MLI + $i, 1) !== "\x00") { |
| 452 |
return false; |
| 453 |
} |
| 454 |
} |
| 455 |
|
| 456 |
|
| 457 |
31) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:156 [M] MBString |
| 458 |
|
| 459 |
--- Original |
| 460 |
+++ New |
| 461 |
@@ @@ |
| 462 |
return false; |
| 463 |
} |
| 464 |
} |
| 465 |
- $key = mb_substr($key, 0, $MLI, '8bit'); |
| 466 |
+ $key = substr($key, 0, $MLI); |
| 467 |
return true; |
| 468 |
} |
| 469 |
private static function checkKeySize(string $key, bool $padding_enabled) : void |
| 470 |
|
| 471 |
|
| 472 |
32) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:166 [M] MBString |
| 473 |
|
| 474 |
--- Original |
| 475 |
+++ New |
| 476 |
@@ @@ |
| 477 |
if ($key === '') { |
| 478 |
throw new InvalidArgumentException('Bad key size'); |
| 479 |
} |
| 480 |
- if ($padding_enabled === false && mb_strlen($key, '8bit') % 8 !== 0) { |
| 481 |
+ if ($padding_enabled === false && strlen($key) % 8 !== 0) { |
| 482 |
throw new InvalidArgumentException('Bad key size'); |
| 483 |
} |
| 484 |
} |
| 485 |
|
| 486 |
|
| 487 |
33) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:174 [M] FalseValue |
| 488 |
|
| 489 |
--- Original |
| 490 |
+++ New |
| 491 |
@@ @@ |
| 492 |
private static function toXBits(int $bits, int $value) : string |
| 493 |
{ |
| 494 |
$bin = hex2bin(str_pad(dechex($value), $bits / 4, '0', STR_PAD_LEFT)); |
| 495 |
- if ($bin === false) { |
| 496 |
+ if ($bin === true) { |
| 497 |
throw new InvalidArgumentException('Unable to convert the data'); |
| 498 |
} |
| 499 |
return $bin; |
| 500 |
|
| 501 |
|
| 502 |
34) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:183 [M] MBString |
| 503 |
|
| 504 |
--- Original |
| 505 |
+++ New |
| 506 |
@@ @@ |
| 507 |
} |
| 508 |
private static function getMSB(string $value) : string |
| 509 |
{ |
| 510 |
- return mb_substr($value, 0, mb_strlen($value, '8bit') / 2, '8bit'); |
| 511 |
+ return mb_substr($value, 0, strlen($value) / 2, '8bit'); |
| 512 |
} |
| 513 |
private static function getLSB(string $value) : string |
| 514 |
{ |
| 515 |
|
| 516 |
|
| 517 |
35) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:183 [M] MBString |
| 518 |
|
| 519 |
--- Original |
| 520 |
+++ New |
| 521 |
@@ @@ |
| 522 |
} |
| 523 |
private static function getMSB(string $value) : string |
| 524 |
{ |
| 525 |
- return mb_substr($value, 0, mb_strlen($value, '8bit') / 2, '8bit'); |
| 526 |
+ return substr($value, 0, mb_strlen($value, '8bit') / 2); |
| 527 |
} |
| 528 |
private static function getLSB(string $value) : string |
| 529 |
{ |
| 530 |
|
| 531 |
|
| 532 |
36) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:188 [M] MBString |
| 533 |
|
| 534 |
--- Original |
| 535 |
+++ New |
| 536 |
@@ @@ |
| 537 |
} |
| 538 |
private static function getLSB(string $value) : string |
| 539 |
{ |
| 540 |
- return mb_substr($value, mb_strlen($value, '8bit') / 2, null, '8bit'); |
| 541 |
+ return mb_substr($value, strlen($value) / 2, null, '8bit'); |
| 542 |
} |
| 543 |
private static function encrypt(string $kek, string $data) : string |
| 544 |
{ |
| 545 |
|
| 546 |
|
| 547 |
37) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:188 [M] MBString |
| 548 |
|
| 549 |
--- Original |
| 550 |
+++ New |
| 551 |
@@ @@ |
| 552 |
} |
| 553 |
private static function getLSB(string $value) : string |
| 554 |
{ |
| 555 |
- return mb_substr($value, mb_strlen($value, '8bit') / 2, null, '8bit'); |
| 556 |
+ return substr($value, mb_strlen($value, '8bit') / 2, null); |
| 557 |
} |
| 558 |
private static function encrypt(string $kek, string $data) : string |
| 559 |
{ |
| 560 |
|
| 561 |
|
| 562 |
38) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:194 [M] FalseValue |
| 563 |
|
| 564 |
--- Original |
| 565 |
+++ New |
| 566 |
@@ @@ |
| 567 |
private static function encrypt(string $kek, string $data) : string |
| 568 |
{ |
| 569 |
$result = openssl_encrypt($data, self::getMethod(), $kek, OPENSSL_ZERO_PADDING | OPENSSL_RAW_DATA); |
| 570 |
- if ($result === false) { |
| 571 |
+ if ($result === true) { |
| 572 |
throw new InvalidArgumentException('Unable to encrypt the data'); |
| 573 |
} |
| 574 |
return $result; |
| 575 |
|
| 576 |
|
| 577 |
39) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:204 [M] FalseValue |
| 578 |
|
| 579 |
--- Original |
| 580 |
+++ New |
| 581 |
@@ @@ |
| 582 |
private static function decrypt(string $kek, string $data) : string |
| 583 |
{ |
| 584 |
$result = openssl_decrypt($data, self::getMethod(), $kek, OPENSSL_ZERO_PADDING | OPENSSL_RAW_DATA); |
| 585 |
- if ($result === false) { |
| 586 |
+ if ($result === true) { |
| 587 |
throw new InvalidArgumentException('Unable to decrypt the data'); |
| 588 |
} |
| 589 |
return $result; |
| 590 |
} |
| 591 |
} |
| 592 |
|
| 593 |
|
| 594 |
Timed Out mutants: |
| 595 |
================== |
| 596 |
|
| 597 |
1) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:41 [M] Increment |
| 598 |
|
| 599 |
--- Original |
| 600 |
+++ New |
| 601 |
@@ @@ |
| 602 |
$C[1] = self::getLSB($B); |
| 603 |
} elseif ($N > 1) { |
| 604 |
$R = $P; |
| 605 |
- for ($j = 0; $j <= 5; ++$j) { |
| 606 |
+ for ($j = 0; $j <= 5; --$j) { |
| 607 |
for ($i = 1; $i <= $N; ++$i) { |
| 608 |
$B = self::encrypt($kek, $A . $R[$i - 1]); |
| 609 |
$t = $i + $j * $N; |
| 610 |
|
| 611 |
|
| 612 |
2) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:77 [M] Decrement |
| 613 |
|
| 614 |
--- Original |
| 615 |
+++ New |
| 616 |
@@ @@ |
| 617 |
$A = self::getMSB($B); |
| 618 |
} else { |
| 619 |
$R = $P; |
| 620 |
- for ($j = 5; $j >= 0; --$j) { |
| 621 |
+ for ($j = 5; $j >= 0; ++$j) { |
| 622 |
for ($i = $N - 1; $i >= 1; --$i) { |
| 623 |
$t = $i + $j * ($N - 1); |
| 624 |
$B = self::decrypt($kek, (self::toXBits(64, $t) ^ $A) . $R[$i]); |
| 625 |
|
| 626 |
|
| 627 |
Skipped mutants: |
| 628 |
================ |
| 629 |
|
| 630 |
Not Covered mutants: |
| 631 |
==================== |
| 632 |
|
| 633 |
1) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:111 [M] Throw_ |
| 634 |
|
| 635 |
--- Original |
| 636 |
+++ New |
| 637 |
@@ @@ |
| 638 |
if ($padding_enabled === false) { |
| 639 |
$bin = hex2bin('A6A6A6A6A6A6A6A6'); |
| 640 |
if ($bin === false) { |
| 641 |
- throw new InvalidArgumentException('Unable to convert the data'); |
| 642 |
+ new InvalidArgumentException('Unable to convert the data'); |
| 643 |
} |
| 644 |
return $bin; |
| 645 |
} |
| 646 |
|
| 647 |
|
| 648 |
2) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:147 [M] FalseValue |
| 649 |
|
| 650 |
--- Original |
| 651 |
+++ New |
| 652 |
@@ @@ |
| 653 |
$n = mb_strlen($key, '8bit') / 8; |
| 654 |
$MLI = (int) hexdec(bin2hex(ltrim(self::getLSB($iv), "\x00"))); |
| 655 |
if (!(8 * ($n - 1) < $MLI && $MLI <= 8 * $n)) { |
| 656 |
- return false; |
| 657 |
+ return true; |
| 658 |
} |
| 659 |
$b = 8 * $n - $MLI; |
| 660 |
for ($i = 0; $i < $b; ++$i) { |
| 661 |
|
| 662 |
|
| 663 |
3) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:153 [M] FalseValue |
| 664 |
|
| 665 |
--- Original |
| 666 |
+++ New |
| 667 |
@@ @@ |
| 668 |
$b = 8 * $n - $MLI; |
| 669 |
for ($i = 0; $i < $b; ++$i) { |
| 670 |
if (mb_substr($key, $MLI + $i, 1, '8bit') !== "\x00") { |
| 671 |
- return false; |
| 672 |
+ return true; |
| 673 |
} |
| 674 |
} |
| 675 |
$key = mb_substr($key, 0, $MLI, '8bit'); |
| 676 |
|
| 677 |
|
| 678 |
4) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:175 [M] Throw_ |
| 679 |
|
| 680 |
--- Original |
| 681 |
+++ New |
| 682 |
@@ @@ |
| 683 |
{ |
| 684 |
$bin = hex2bin(str_pad(dechex($value), $bits / 4, '0', STR_PAD_LEFT)); |
| 685 |
if ($bin === false) { |
| 686 |
- throw new InvalidArgumentException('Unable to convert the data'); |
| 687 |
+ new InvalidArgumentException('Unable to convert the data'); |
| 688 |
} |
| 689 |
return $bin; |
| 690 |
} |
| 691 |
|
| 692 |
|
| 693 |
5) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:195 [M] Throw_ |
| 694 |
|
| 695 |
--- Original |
| 696 |
+++ New |
| 697 |
@@ @@ |
| 698 |
{ |
| 699 |
$result = openssl_encrypt($data, self::getMethod(), $kek, OPENSSL_ZERO_PADDING | OPENSSL_RAW_DATA); |
| 700 |
if ($result === false) { |
| 701 |
- throw new InvalidArgumentException('Unable to encrypt the data'); |
| 702 |
+ new InvalidArgumentException('Unable to encrypt the data'); |
| 703 |
} |
| 704 |
return $result; |
| 705 |
} |
| 706 |
|
| 707 |
|
| 708 |
6) /home/florent/PhpstormProjects/aes-key-wrap/src/AESKW.php:205 [M] Throw_ |
| 709 |
|
| 710 |
--- Original |
| 711 |
+++ New |
| 712 |
@@ @@ |
| 713 |
{ |
| 714 |
$result = openssl_decrypt($data, self::getMethod(), $kek, OPENSSL_ZERO_PADDING | OPENSSL_RAW_DATA); |
| 715 |
if ($result === false) { |
| 716 |
- throw new InvalidArgumentException('Unable to decrypt the data'); |
| 717 |
+ new InvalidArgumentException('Unable to decrypt the data'); |
| 718 |
} |
| 719 |
return $result; |
| 720 |
} |
| 721 |
} |