|
@@ -62,7 +62,7 @@ discard block |
|
|
block discarded – undo |
|
62
|
62
|
$msg = Str::substr($data, $isz + $hsz + $tsz + 4); |
|
63
|
63
|
|
|
64
|
64
|
// Calculate verification checksum |
|
65
|
|
- $chk = \hash_hmac($algo, ($msg . $itr . $ivr), $pass, true); |
|
|
65
|
+ $chk = \hash_hmac($algo, ($msg.$itr.$ivr), $pass, true); |
|
66
|
66
|
|
|
67
|
67
|
// Verify HMAC before decrypting |
|
68
|
68
|
if (!Str::equal($chk, $sum)) { |
|
@@ -73,7 +73,7 @@ discard block |
|
|
block discarded – undo |
|
73
|
73
|
$cost = \unpack('N', $itr ^ \hash_hmac($algo, $ivr, $pass, true))[1]; |
|
74
|
74
|
|
|
75
|
75
|
// Derive key from password using pbkdf2 |
|
76
|
|
- $key = \hash_pbkdf2($algo, ($pass . $cipher), $ivr, $cost, 0, true); |
|
|
76
|
+ $key = \hash_pbkdf2($algo, ($pass.$cipher), $ivr, $cost, 0, true); |
|
77
|
77
|
|
|
78
|
78
|
// Decrypt message and return |
|
79
|
79
|
return parent::openssl_decrypt($msg, $cipher, $key, $ivr, $tag); |
|
@@ -97,7 +97,7 @@ discard block |
|
|
block discarded – undo |
|
97
|
97
|
|
|
98
|
98
|
// Derive key from password with hash_pbkdf2 function. |
|
99
|
99
|
// Append CIPHER to password beforehand so that cross-method decryptions will fail at checksum step |
|
100
|
|
- $key = \hash_pbkdf2($algo, ($pass . $cipher), $ivr, $cost, 0, true); |
|
|
100
|
+ $key = \hash_pbkdf2($algo, ($pass.$cipher), $ivr, $cost, 0, true); |
|
101
|
101
|
|
|
102
|
102
|
// Create a placeholder for the authentication tag to be passed by reference |
|
103
|
103
|
$tag = ''; |
|
@@ -109,9 +109,9 @@ discard block |
|
|
block discarded – undo |
|
109
|
109
|
$itr = \pack('N', $cost) ^ \hash_hmac($algo, $ivr, $pass, true); |
|
110
|
110
|
|
|
111
|
111
|
// Generate the ciphertext checksum to prevent bit tampering |
|
112
|
|
- $chk = \hash_hmac($algo, ($msg . $itr . $ivr), $pass, true); |
|
|
112
|
+ $chk = \hash_hmac($algo, ($msg.$itr.$ivr), $pass, true); |
|
113
|
113
|
|
|
114
|
114
|
// Return iv + checksum + tag + iterations + cyphertext |
|
115
|
|
- return $ivr . $chk . $tag . $itr . $msg; |
|
|
115
|
+ return $ivr.$chk.$tag.$itr.$msg; |
|
116
|
116
|
} |
|
117
|
117
|
} |