diff --git a/src/Illuminate/Encryption/Encrypter.php b/src/Illuminate/Encryption/Encrypter.php index 5bb2bc2af887..ff9d88f8ca41 100755 --- a/src/Illuminate/Encryption/Encrypter.php +++ b/src/Illuminate/Encryption/Encrypter.php @@ -152,11 +152,9 @@ public function decrypt($payload, $unserialize = true) $iv = base64_decode($payload['iv']); - $tag = empty($payload['tag']) ? null : base64_decode($payload['tag']); - - if (self::$supportedCiphers[strtolower($this->cipher)]['aead'] && strlen($tag) !== 16) { - throw new DecryptException('Could not decrypt the data.'); - } + $this->ensureTagIsValid( + $tag = empty($payload['tag']) ? null : base64_decode($payload['tag']) + ); // Here we will decrypt the value. If we are able to successfully decrypt it // we will then unserialize it and return it out to the caller. If we are @@ -248,6 +246,23 @@ protected function validMac(array $payload) ); } + /** + * Ensure the given tag is a valid tag given the selected cipher. + * + * @param string $tag + * @return void + */ + protected function ensureTagIsValid($tag) + { + if (self::$supportedCiphers[strtolower($this->cipher)]['aead'] && strlen($tag) !== 16) { + throw new DecryptException('Could not decrypt the data.'); + } + + if (! self::$supportedCiphers[strtolower($this->cipher)]['aead'] && is_string($tag)) { + throw new DecryptException('Unable to use tag because the cipher algorithm does not support AEAD.'); + } + } + /** * Get the encryption key that the encrypter is currently using. * diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index a00833e3b33c..f5f2d073d313 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -35,7 +35,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '9.4.1'; + const VERSION = '9.5.0'; /** * The base path for the Laravel installation. diff --git a/src/Illuminate/Http/Client/PendingRequest.php b/src/Illuminate/Http/Client/PendingRequest.php index 40e1d9d88f9b..b784e35bc9c4 100644 --- a/src/Illuminate/Http/Client/PendingRequest.php +++ b/src/Illuminate/Http/Client/PendingRequest.php @@ -1041,11 +1041,11 @@ protected function sinkStubHandler($sink) public function runBeforeSendingCallbacks($request, array $options) { return tap($request, function ($request) use ($options) { - $this->beforeSendingCallbacks->each->__invoke( - (new Request($request))->withData($options['laravel_data']), - $options, - $this - ); + $this->beforeSendingCallbacks->each(function ($callback) use ($request, $options) { + call_user_func( + $callback, (new Request($request))->withData($options['laravel_data']), $options, $this + ); + }); }); }