Skip to content

Commit 2ad2e97

Browse files
committed
feat(encryption): Remove previousKeysFallbackEnabled property and related logic
1 parent 772bc29 commit 2ad2e97

File tree

6 files changed

+3
-34
lines changed

6 files changed

+3
-34
lines changed

app/Config/Encryption.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ class Encryption extends BaseConfig
2323
*/
2424
public string $key = '';
2525

26-
/**
27-
* --------------------------------------------------------------------------
28-
* Previous Encryption Keys fallback enabled
29-
* --------------------------------------------------------------------------
30-
* If you want to enable decryption using previous keys, set this to true.
31-
* See the user guide for more info.
32-
*/
33-
public bool $previousKeysFallbackEnabled = false;
34-
3526
/**
3627
* --------------------------------------------------------------------------
3728
* Previous Encryption Keys

env

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@
5555

5656
# encryption.key =
5757

58-
# Previous keys fallback is disabled by default.
59-
# If you want to enable it, uncomment the line below.
60-
# encryption.previousKeysFallbackEnabled = true
58+
# Previous keys fallback; comma-separated list
6159
# encryption.previousKeys =
6260

6361
#--------------------------------------------------------------------

system/Config/BaseConfig.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ public function __construct()
133133
if ($this instanceof Encryption) {
134134
if ($property === 'key') {
135135
$this->{$property} = $this->parseEncryptionKey($this->{$property});
136-
} elseif ($property === 'previousKeysFallbackEnabled') {
137-
// previousKeysFallbackEnabled must be boolean
138-
$this->{$property} = (bool) $this->{$property};
139136
} elseif ($property === 'previousKeys') {
140137
$keysArray = array_map('trim', explode(',', $this->{$property}));
141138
$parsedKeys = [];

system/Encryption/Encryption.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ class Encryption
5353
*/
5454
protected $key;
5555

56-
/**
57-
* Whether to fall back to previous keys when decryption fails.
58-
*/
59-
protected bool $previousKeysFallbackEnabled = false;
60-
6156
/**
6257
* Comma-separated list of previous keys for fallback decryption.
6358
*
@@ -104,7 +99,6 @@ public function __construct(?EncryptionConfig $config = null)
10499
$config ??= new EncryptionConfig();
105100

106101
$this->key = $config->key;
107-
$this->previousKeysFallbackEnabled = $config->previousKeysFallbackEnabled;
108102
$this->previousKeys = $config->previousKeys;
109103
$this->driver = $config->driver;
110104
$this->digest = $config->digest ?? 'SHA512';
@@ -131,7 +125,6 @@ public function initialize(?EncryptionConfig $config = null)
131125
{
132126
if ($config instanceof EncryptionConfig) {
133127
$this->key = $config->key;
134-
$this->previousKeysFallbackEnabled = $config->previousKeysFallbackEnabled ?? false;
135128
$this->previousKeys = $config->previousKeys ?? '';
136129
$this->driver = $config->driver;
137130
$this->digest = $config->digest ?? 'SHA512';

system/Encryption/Handlers/OpenSSLHandler.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ class OpenSSLHandler extends BaseHandler
5555
*/
5656
protected $key = '';
5757

58-
/**
59-
* Whether to fall back to previous keys when decryption fails.
60-
*/
61-
protected bool $previousKeysFallbackEnabled = false;
62-
6358
/**
6459
* List of previous keys for fallback decryption.
6560
*
@@ -146,7 +141,7 @@ public function decrypt($data, $params = null)
146141
$exception = $e;
147142
}
148143

149-
if ($result === false && $this->previousKeysFallbackEnabled && $this->previousKeys !== '') {
144+
if ($result === false && $this->previousKeys !== '') {
150145
foreach (explode(',', $this->previousKeys) as $previousKey) {
151146
try {
152147
$result = $this->decryptWithKey($data, $previousKey);

system/Encryption/Handlers/SodiumHandler.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ class SodiumHandler extends BaseHandler
3030
*/
3131
protected $key = '';
3232

33-
/**
34-
* Whether to fall back to previous keys when decryption fails.
35-
*/
36-
protected bool $previousKeysFallbackEnabled = false;
37-
3833
/**
3934
* List of previous keys for fallback decryption.
4035
*
@@ -101,7 +96,7 @@ public function decrypt($data, $params = null)
10196
sodium_memzero($this->key);
10297
}
10398

104-
if ($result === false && $this->previousKeysFallbackEnabled && $this->previousKeys !== '') {
99+
if ($result === false && $this->previousKeys !== '') {
105100
foreach (explode(',', $this->previousKeys) as $previousKey) {
106101
try {
107102
$result = $this->decryptWithKey($data, $previousKey);

0 commit comments

Comments
 (0)