| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -require __DIR__ . '/vendor/autoload.php'; | |
| 3 | +require __DIR__.'/vendor/autoload.php'; | |
| 4 | 4 | |
| 5 | 5 |  foreach (hash_algos() as $algo) {
 | 
| 6 | 6 |      foreach (openssl_get_cipher_methods() as $meth) {
 | 
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 |  foreach (hash_algos() as $algo) {
 | 
| 6 | 6 |      foreach (openssl_get_cipher_methods() as $meth) {
 | 
| 7 | 7 | // Skip any unsupported ciphers | 
| 8 | -        if (!\openssl_cipher_iv_length($meth)) {
 | |
| 8 | +        if (!\openssl_cipher_iv_length($meth)) { | |
| 9 | 9 | continue; | 
| 10 | 10 | } | 
| 11 | 11 | |
| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -require __DIR__ . '/vendor/autoload.php'; | |
| 4 | -require __DIR__ . '/tests/AesBase.php'; | |
| 5 | 3 | \ No newline at end of file | 
| 4 | +require __DIR__.'/vendor/autoload.php'; | |
| 5 | +require __DIR__.'/tests/AesBase.php'; | |
| 6 | 6 | \ No newline at end of file | 
| @@ -24,8 +24,8 @@ | ||
| 24 | 24 | * @link https://github.com/mmeyer2k/dcrypt | 
| 25 | 25 | * @link https://apigen.ci/github/mmeyer2k/dcrypt/namespace-Dcrypt.html | 
| 26 | 26 | */ | 
| 27 | -class AesOfb extends AesCbc | |
| 28 | -{
 | |
| 27 | +class AesOfb extends AesCbc | |
| 28 | +{ | |
| 29 | 29 | /** | 
| 30 | 30 | * AES-256 cipher identifier that will be passed to openssl | 
| 31 | 31 | * | 
| @@ -44,7 +44,7 @@ discard block | ||
| 44 | 44 | $msg = Str::substr($data, $isz + $hsz + $tsz + 4); | 
| 45 | 45 | |
| 46 | 46 | // Calculate verification checksum | 
| 47 | - $chk = \hash_hmac($algo, ($msg . $itr . $ivr), $pass, true); | |
| 47 | + $chk = \hash_hmac($algo, ($msg.$itr.$ivr), $pass, true); | |
| 48 | 48 | |
| 49 | 49 | // Verify HMAC before decrypting | 
| 50 | 50 |          if (!Str::equal($chk, $sum)) {
 | 
| @@ -55,7 +55,7 @@ discard block | ||
| 55 | 55 |          $cost = \unpack('N', $itr ^ \hash_hmac($algo, $ivr, $pass, true))[1];
 | 
| 56 | 56 | |
| 57 | 57 | // Derive key from password | 
| 58 | - $key = \hash_pbkdf2($algo, ($pass . $cipher), $ivr, $cost, 0, true); | |
| 58 | + $key = \hash_pbkdf2($algo, ($pass.$cipher), $ivr, $cost, 0, true); | |
| 59 | 59 | |
| 60 | 60 | // Decrypt message and return | 
| 61 | 61 | return OpensslWrapper::decrypt($msg, $cipher, $key, $ivr, $tag); | 
| @@ -68,7 +68,7 @@ discard block | ||
| 68 | 68 | |
| 69 | 69 | // Derive key from password with hash_pbkdf2 function. | 
| 70 | 70 | // Append CIPHER to password beforehand so that cross-method decryptions will fail at checksum step | 
| 71 | - $key = \hash_pbkdf2($algo, ($pass . $cipher), $ivr, $cost, 0, true); | |
| 71 | + $key = \hash_pbkdf2($algo, ($pass.$cipher), $ivr, $cost, 0, true); | |
| 72 | 72 | |
| 73 | 73 | // Create a placeholder for the authentication tag to be passed by reference | 
| 74 | 74 | $tag = ''; | 
| @@ -80,10 +80,10 @@ discard block | ||
| 80 | 80 |          $itr = \pack('N', $cost) ^ \hash_hmac($algo, $ivr, $pass, true);
 | 
| 81 | 81 | |
| 82 | 82 | // Generate the ciphertext checksum to prevent bit tampering | 
| 83 | - $chk = \hash_hmac($algo, ($msg . $itr . $ivr), $pass, true); | |
| 83 | + $chk = \hash_hmac($algo, ($msg.$itr.$ivr), $pass, true); | |
| 84 | 84 | |
| 85 | 85 | // Return iv + checksum + iterations + cyphertext + tag | 
| 86 | - return $ivr . $chk . $tag . $itr . $msg; | |
| 86 | + return $ivr.$chk.$tag.$itr.$msg; | |
| 87 | 87 | } | 
| 88 | 88 | |
| 89 | 89 | /** | 
| @@ -14,8 +14,8 @@ discard block | ||
| 14 | 14 | |
| 15 | 15 | namespace Dcrypt; | 
| 16 | 16 | |
| 17 | -class OpensslStatic | |
| 18 | -{
 | |
| 17 | +class OpensslStatic | |
| 18 | +{ | |
| 19 | 19 | public static function decrypt(string $data, string $pass, string $cipher, string $algo): string | 
| 20 | 20 |      {
 | 
| 21 | 21 | // Calculate the hash checksum size in bytes for the specified algo | 
| @@ -47,7 +47,7 @@ discard block | ||
| 47 | 47 | $chk = \hash_hmac($algo, ($msg . $itr . $ivr), $pass, true); | 
| 48 | 48 | |
| 49 | 49 | // Verify HMAC before decrypting | 
| 50 | -        if (!Str::equal($chk, $sum)) {
 | |
| 50 | +        if (!Str::equal($chk, $sum)) { | |
| 51 | 51 |              throw new \InvalidArgumentException('Decryption can not proceed due to invalid cyphertext checksum.');
 | 
| 52 | 52 | } | 
| 53 | 53 | |
| @@ -102,7 +102,7 @@ discard block | ||
| 102 | 102 | ]; | 
| 103 | 103 | |
| 104 | 104 |          foreach ($needle_tips as $needle) {
 | 
| 105 | -            if (strpos($cipher, $needle)) {
 | |
| 105 | +            if (strpos($cipher, $needle)) { | |
| 106 | 106 | return true; | 
| 107 | 107 | } | 
| 108 | 108 | } | 
| @@ -24,8 +24,8 @@ | ||
| 24 | 24 | * @link https://github.com/mmeyer2k/dcrypt | 
| 25 | 25 | * @link https://apigen.ci/github/mmeyer2k/dcrypt/namespace-Dcrypt.html | 
| 26 | 26 | */ | 
| 27 | -class AesGcm extends AesCbc | |
| 28 | -{
 | |
| 27 | +class AesGcm extends AesCbc | |
| 28 | +{ | |
| 29 | 29 | /** | 
| 30 | 30 | * AES-256 cipher identifier that will be passed to openssl | 
| 31 | 31 | * |