Skip to content

Commit 0acafbb

Browse files
committed
feat: add SensitiveParameter attribute to security-critical parameters
1 parent 953b2c8 commit 0acafbb

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/JWK.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class JWK
5252
*
5353
* @uses parseKey
5454
*/
55-
public static function parseKeySet(array $jwks, ?string $defaultAlg = null): array
55+
public static function parseKeySet(#[\SensitiveParameter] array $jwks, ?string $defaultAlg = null): array
5656
{
5757
$keys = [];
5858

@@ -93,7 +93,7 @@ public static function parseKeySet(array $jwks, ?string $defaultAlg = null): arr
9393
*
9494
* @uses createPemFromModulusAndExponent
9595
*/
96-
public static function parseKey(array $jwk, ?string $defaultAlg = null): ?Key
96+
public static function parseKey(#[\SensitiveParameter] array $jwk, ?string $defaultAlg = null): ?Key
9797
{
9898
if (empty($jwk)) {
9999
throw new InvalidArgumentException('JWK must not be empty');

src/JWT.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class JWT
9595
*/
9696
public static function decode(
9797
string $jwt,
98-
$keyOrKeyArray,
98+
#[\SensitiveParameter] $keyOrKeyArray,
9999
?stdClass &$headers = null
100100
): stdClass {
101101
// Validate JWT
@@ -208,7 +208,7 @@ public static function decode(
208208
*/
209209
public static function encode(
210210
array $payload,
211-
$key,
211+
#[\SensitiveParameter] $key,
212212
string $alg,
213213
?string $keyId = null,
214214
?array $head = null
@@ -246,7 +246,7 @@ public static function encode(
246246
*/
247247
public static function sign(
248248
string $msg,
249-
$key,
249+
#[\SensitiveParameter] $key,
250250
string $alg
251251
): string {
252252
if (empty(static::$supported_algs[$alg])) {
@@ -313,7 +313,7 @@ public static function sign(
313313
private static function verify(
314314
string $msg,
315315
string $signature,
316-
$keyMaterial,
316+
#[\SensitiveParameter] $keyMaterial,
317317
string $alg
318318
): bool {
319319
if (empty(static::$supported_algs[$alg])) {
@@ -467,7 +467,7 @@ public static function urlsafeB64Encode(string $input): string
467467
* @return Key
468468
*/
469469
private static function getKey(
470-
$keyOrKeyArray,
470+
#[\SensitiveParameter] $keyOrKeyArray,
471471
?string $kid
472472
): Key {
473473
if ($keyOrKeyArray instanceof Key) {

src/Key.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Key
1414
* @param string $algorithm
1515
*/
1616
public function __construct(
17-
private $keyMaterial,
17+
#[\SensitiveParameter] private $keyMaterial,
1818
private string $algorithm
1919
) {
2020
if (

0 commit comments

Comments
 (0)