@@ -70,9 +70,9 @@ |
||
| 70 | 70 | */ |
| 71 | 71 | private static function cost(int $cost): int |
| 72 | 72 | { |
| 73 | - if ($cost < 0 || $cost > \pow(2, 32)) { |
|
| 74 | - throw new \InvalidArgumentException("Hashing cost parameter must between 0 and 2^32"); |
|
| 75 | - } |
|
| 73 | + if ($cost < 0 || $cost > \pow(2, 32)) { |
|
| 74 | + throw new \InvalidArgumentException("Hashing cost parameter must between 0 and 2^32"); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | return $cost; |
| 78 | 78 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $cost = \unpack('L*', $itr ^ \hash_hmac(static::CHKSUM, $ivr, $pass, true))[1]; |
| 58 | 58 | |
| 59 | 59 | // Derive key from password |
| 60 | - $key = \hash_pbkdf2(static::CHKSUM, ($pass . static::CIPHER), $ivr, $cost, 0, true); |
|
| 60 | + $key = \hash_pbkdf2(static::CHKSUM, ($pass.static::CIPHER), $ivr, $cost, 0, true); |
|
| 61 | 61 | |
| 62 | 62 | // Calculate verification checksum |
| 63 | 63 | $chk = \hash_hmac(static::CHKSUM, $msg, $key, true); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $ivr = \random_bytes(OpensslWrapper::ivsize(static::CIPHER)); |
| 84 | 84 | |
| 85 | 85 | // Derive key from password |
| 86 | - $key = \hash_pbkdf2(static::CHKSUM, ($pass . static::CIPHER), $ivr, $cost, 0, true); |
|
| 86 | + $key = \hash_pbkdf2(static::CHKSUM, ($pass.static::CIPHER), $ivr, $cost, 0, true); |
|
| 87 | 87 | |
| 88 | 88 | // Encrypt the plaintext |
| 89 | 89 | $msg = OpensslWrapper::encrypt($data, static::CIPHER, $key, $ivr); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $chk = \hash_hmac(static::CHKSUM, $msg, $key, true); |
| 96 | 96 | |
| 97 | 97 | // Return iv + checksum + iterations + cyphertext |
| 98 | - return $ivr . $chk . $itr . $msg; |
|
| 98 | + return $ivr.$chk.$itr.$msg; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |