Skip to content

Commit 6a8694f

Browse files
committed
refactor: add #[SensitiveParameter] whenever necessary
1 parent 97e32f4 commit 6a8694f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

system/Encryption/Handlers/OpenSSLHandler.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace CodeIgniter\Encryption\Handlers;
1515

1616
use CodeIgniter\Encryption\Exceptions\EncryptionException;
17+
use SensitiveParameter;
1718

1819
/**
1920
* Encryption handling for OpenSSL library
@@ -84,7 +85,7 @@ class OpenSSLHandler extends BaseHandler
8485
/**
8586
* {@inheritDoc}
8687
*/
87-
public function encrypt($data, $params = null)
88+
public function encrypt(#[SensitiveParameter] $data, #[SensitiveParameter] $params = null)
8889
{
8990
// Allow key override
9091
if ($params !== null) {
@@ -120,7 +121,7 @@ public function encrypt($data, $params = null)
120121
/**
121122
* {@inheritDoc}
122123
*/
123-
public function decrypt($data, $params = null)
124+
public function decrypt($data, #[SensitiveParameter] $params = null)
124125
{
125126
// Allow key override
126127
if ($params !== null) {
@@ -169,7 +170,7 @@ public function decrypt($data, $params = null)
169170
*
170171
* @throws EncryptionException
171172
*/
172-
protected function decryptWithKey($data, $key)
173+
protected function decryptWithKey($data, #[SensitiveParameter] $key)
173174
{
174175
// derive a secret key
175176
$authKey = \hash_hkdf($this->digest, $key, 0, $this->authKeyInfo);

system/Encryption/Handlers/SodiumHandler.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace CodeIgniter\Encryption\Handlers;
1515

1616
use CodeIgniter\Encryption\Exceptions\EncryptionException;
17+
use SensitiveParameter;
1718

1819
/**
1920
* SodiumHandler uses libsodium in encryption.
@@ -45,7 +46,7 @@ class SodiumHandler extends BaseHandler
4546
/**
4647
* {@inheritDoc}
4748
*/
48-
public function encrypt($data, $params = null)
49+
public function encrypt(#[SensitiveParameter] $data, #[SensitiveParameter] $params = null)
4950
{
5051
$this->parseParams($params);
5152

@@ -76,7 +77,7 @@ public function encrypt($data, $params = null)
7677
/**
7778
* {@inheritDoc}
7879
*/
79-
public function decrypt($data, $params = null)
80+
public function decrypt($data, #[SensitiveParameter] $params = null)
8081
{
8182
$this->parseParams($params);
8283

@@ -124,7 +125,7 @@ public function decrypt($data, $params = null)
124125
*
125126
* @throws EncryptionException
126127
*/
127-
protected function decryptWithKey($data, $key)
128+
protected function decryptWithKey($data, #[SensitiveParameter] $key)
128129
{
129130
if (mb_strlen($data, '8bit') < (SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES)) {
130131
// message was truncated
@@ -165,7 +166,7 @@ protected function decryptWithKey($data, $key)
165166
*
166167
* @throws EncryptionException If key is empty
167168
*/
168-
protected function parseParams($params)
169+
protected function parseParams(#[SensitiveParameter] $params)
169170
{
170171
if ($params === null) {
171172
return;

0 commit comments

Comments
 (0)