From 417920456809214b45a10748d11bf04af318eb1e Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Thu, 4 Jan 2024 12:55:34 +0100 Subject: [PATCH 1/2] Fix detached and non-encoded non-UTF8 string --- src/Component/Signature/JWSBuilder.php | 8 ++-- ...essionTestCase.php => CompressionTest.php} | 2 +- ...php => ECDHESWithX25519EncryptionTest.php} | 2 +- ...ncrypterTestCase.php => EncrypterTest.php} | 2 +- ...estCase.php => InvalidCurveAttackTest.php} | 2 +- ...tenedTestCase.php => JWEFlattenedTest.php} | 2 +- ...WELoaderTestCase.php => JWELoaderTest.php} | 2 +- ...{JWESplitTestCase.php => JWESplitTest.php} | 2 +- ...GCMEncryptionProtectedContentOnlyTest.php} | 2 +- ...php => A128KWAndA128GCMEncryptionTest.php} | 2 +- ...onWithAdditionalAuthenticatedDataTest.php} | 2 +- ...dA128GCMEncryptionWithCompressionTest.php} | 2 +- ...WithSpecificProtectedHeaderValuesTest.php} | 2 +- ...56GCMKWAndA128CBC_HS256EncryptionTest.php} | 2 +- ...se.php => DirAndA128GCMEncryptionTest.php} | 2 +- ...CDH_ES_A128KWAndA128GCMEncryptionTest.php} | 2 +- ...CDH_ES_AndA128CBC_HS256EncryptionTest.php} | 2 +- ...hp => MultipleRecipientEncryptionTest.php} | 2 +- ..._A256KWAndA128CBC_HS256EncryptionTest.php} | 2 +- ... RSA1_5AndA128CBC_HS256EncryptionTest.php} | 2 +- ...p => RSA_OAEPAndA256GCMEncryptionTest.php} | 2 +- ...tionTestCase.php => RSAEncryptionTest.php} | 2 +- ...nTestCase.php => RSAKeyEncryptionTest.php} | 2 +- ...ase.php => RSAKeyWithoutAllPrimesTest.php} | 2 +- .../{NestingTestCase.php => NestingTest.php} | 2 +- ...eignJWTTestCase.php => ForeignJWTTest.php} | 2 +- ...tenedTestCase.php => JWSFlattenedTest.php} | 2 +- ...WSLoaderTestCase.php => JWSLoaderTest.php} | 2 +- ...{JWSSplitTestCase.php => JWSSplitTest.php} | 2 +- .../{JWSTestCase.php => JWSTest.php} | 2 +- ...estCase.php => MultipleSignaturesTest.php} | 2 +- .../{NestingTestCase.php => NestingTest.php} | 2 +- .../{SignerTestCase.php => SignerTest.php} | 38 +++++++++++++++++-- 33 files changed, 71 insertions(+), 37 deletions(-) rename tests/Component/Encryption/{CompressionTestCase.php => CompressionTest.php} (96%) rename tests/Component/Encryption/{ECDHESWithX25519EncryptionTestCase.php => ECDHESWithX25519EncryptionTest.php} (96%) rename tests/Component/Encryption/{EncrypterTestCase.php => EncrypterTest.php} (99%) rename tests/Component/Encryption/{InvalidCurveAttackTestCase.php => InvalidCurveAttackTest.php} (97%) rename tests/Component/Encryption/{JWEFlattenedTestCase.php => JWEFlattenedTest.php} (97%) rename tests/Component/Encryption/{JWELoaderTestCase.php => JWELoaderTest.php} (99%) rename tests/Component/Encryption/{JWESplitTestCase.php => JWESplitTest.php} (98%) rename tests/Component/Encryption/RFC7520/{A128KWAndA128GCMEncryptionProtectedContentOnlyTestCase.php => A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php} (98%) rename tests/Component/Encryption/RFC7520/{A128KWAndA128GCMEncryptionTestCase.php => A128KWAndA128GCMEncryptionTest.php} (99%) rename tests/Component/Encryption/RFC7520/{A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTestCase.php => A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php} (99%) rename tests/Component/Encryption/RFC7520/{A128KWAndA128GCMEncryptionWithCompressionTestCase.php => A128KWAndA128GCMEncryptionWithCompressionTest.php} (99%) rename tests/Component/Encryption/RFC7520/{A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTestCase.php => A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php} (99%) rename tests/Component/Encryption/RFC7520/{A256GCMKWAndA128CBC_HS256EncryptionTestCase.php => A256GCMKWAndA128CBC_HS256EncryptionTest.php} (99%) rename tests/Component/Encryption/RFC7520/{DirAndA128GCMEncryptionTestCase.php => DirAndA128GCMEncryptionTest.php} (98%) rename tests/Component/Encryption/RFC7520/{ECDH_ES_A128KWAndA128GCMEncryptionTestCase.php => ECDH_ES_A128KWAndA128GCMEncryptionTest.php} (99%) rename tests/Component/Encryption/RFC7520/{ECDH_ES_AndA128CBC_HS256EncryptionTestCase.php => ECDH_ES_AndA128CBC_HS256EncryptionTest.php} (98%) rename tests/Component/Encryption/RFC7520/{MultipleRecipientEncryptionTestCase.php => MultipleRecipientEncryptionTest.php} (99%) rename tests/Component/Encryption/RFC7520/{PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTestCase.php => PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php} (99%) rename tests/Component/Encryption/RFC7520/{RSA1_5AndA128CBC_HS256EncryptionTestCase.php => RSA1_5AndA128CBC_HS256EncryptionTest.php} (99%) rename tests/Component/Encryption/RFC7520/{RSA_OAEPAndA256GCMEncryptionTestCase.php => RSA_OAEPAndA256GCMEncryptionTest.php} (99%) rename tests/Component/Encryption/{RSAEncryptionTestCase.php => RSAEncryptionTest.php} (99%) rename tests/Component/Encryption/{RSAKeyEncryptionTestCase.php => RSAKeyEncryptionTest.php} (99%) rename tests/Component/Encryption/{RSAKeyWithoutAllPrimesTestCase.php => RSAKeyWithoutAllPrimesTest.php} (98%) rename tests/Component/NestedToken/{NestingTestCase.php => NestingTest.php} (99%) rename tests/Component/Signature/{ForeignJWTTestCase.php => ForeignJWTTest.php} (98%) rename tests/Component/Signature/{JWSFlattenedTestCase.php => JWSFlattenedTest.php} (94%) rename tests/Component/Signature/{JWSLoaderTestCase.php => JWSLoaderTest.php} (99%) rename tests/Component/Signature/{JWSSplitTestCase.php => JWSSplitTest.php} (97%) rename tests/Component/Signature/{JWSTestCase.php => JWSTest.php} (99%) rename tests/Component/Signature/RFC7520/{MultipleSignaturesTestCase.php => MultipleSignaturesTest.php} (98%) rename tests/Component/Signature/RFC7520/{NestingTestCase.php => NestingTest.php} (98%) rename tests/Component/Signature/{SignerTestCase.php => SignerTest.php} (93%) diff --git a/src/Component/Signature/JWSBuilder.php b/src/Component/Signature/JWSBuilder.php index 7adbdf38..5c1b91ef 100644 --- a/src/Component/Signature/JWSBuilder.php +++ b/src/Component/Signature/JWSBuilder.php @@ -69,9 +69,6 @@ public function create(): self */ public function withPayload(string $payload, bool $isPayloadDetached = false): self { - if (mb_detect_encoding($payload, 'UTF-8', true) === false) { - throw new InvalidArgumentException('The payload must be encoded in UTF-8'); - } $clone = clone $this; $clone->payload = $payload; $clone->isPayloadDetached = $isPayloadDetached; @@ -124,6 +121,11 @@ public function build(): JWS $encodedPayload = $this->isPayloadEncoded === false ? $this->payload : Base64UrlSafe::encodeUnpadded( $this->payload ); + + if ($this->isPayloadEncoded === false && $this->isPayloadDetached === false) { + mb_detect_encoding($this->payload, 'UTF-8', true) !== false || throw new InvalidArgumentException('The payload must be encoded in UTF-8'); + } + $jws = new JWS($this->payload, $encodedPayload, $this->isPayloadDetached); foreach ($this->signatures as $signature) { /** @var MacAlgorithm|SignatureAlgorithm $algorithm */ diff --git a/tests/Component/Encryption/CompressionTestCase.php b/tests/Component/Encryption/CompressionTest.php similarity index 96% rename from tests/Component/Encryption/CompressionTestCase.php rename to tests/Component/Encryption/CompressionTest.php index 7645fa18..c5fdcafe 100644 --- a/tests/Component/Encryption/CompressionTestCase.php +++ b/tests/Component/Encryption/CompressionTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class CompressionTestCase extends EncryptionTestCase +final class CompressionTest extends EncryptionTestCase { #[Test] public function getValidCompressionAlgorithm(): void diff --git a/tests/Component/Encryption/ECDHESWithX25519EncryptionTestCase.php b/tests/Component/Encryption/ECDHESWithX25519EncryptionTest.php similarity index 96% rename from tests/Component/Encryption/ECDHESWithX25519EncryptionTestCase.php rename to tests/Component/Encryption/ECDHESWithX25519EncryptionTest.php index 93880797..a86a0204 100644 --- a/tests/Component/Encryption/ECDHESWithX25519EncryptionTestCase.php +++ b/tests/Component/Encryption/ECDHESWithX25519EncryptionTest.php @@ -12,7 +12,7 @@ * * @internal */ -final class ECDHESWithX25519EncryptionTestCase extends EncryptionTestCase +final class ECDHESWithX25519EncryptionTest extends EncryptionTestCase { /** * @see https://tools.ietf.org/html/rfc7516#appendix-B diff --git a/tests/Component/Encryption/EncrypterTestCase.php b/tests/Component/Encryption/EncrypterTest.php similarity index 99% rename from tests/Component/Encryption/EncrypterTestCase.php rename to tests/Component/Encryption/EncrypterTest.php index 4344ffe3..9173f8ec 100644 --- a/tests/Component/Encryption/EncrypterTestCase.php +++ b/tests/Component/Encryption/EncrypterTest.php @@ -14,7 +14,7 @@ /** * @internal */ -final class EncrypterTestCase extends EncryptionTestCase +final class EncrypterTest extends EncryptionTestCase { #[Test] public function encryptWithJWTInput(): void diff --git a/tests/Component/Encryption/InvalidCurveAttackTestCase.php b/tests/Component/Encryption/InvalidCurveAttackTest.php similarity index 97% rename from tests/Component/Encryption/InvalidCurveAttackTestCase.php rename to tests/Component/Encryption/InvalidCurveAttackTest.php index 7bb6cb3f..64031348 100644 --- a/tests/Component/Encryption/InvalidCurveAttackTestCase.php +++ b/tests/Component/Encryption/InvalidCurveAttackTest.php @@ -10,7 +10,7 @@ /** * @internal */ -final class InvalidCurveAttackTestCase extends EncryptionTestCase +final class InvalidCurveAttackTest extends EncryptionTestCase { #[Test] public function curveCheckNegativeP256AttackPt1(): void diff --git a/tests/Component/Encryption/JWEFlattenedTestCase.php b/tests/Component/Encryption/JWEFlattenedTest.php similarity index 97% rename from tests/Component/Encryption/JWEFlattenedTestCase.php rename to tests/Component/Encryption/JWEFlattenedTest.php index 8b23d58d..fd4e21a3 100644 --- a/tests/Component/Encryption/JWEFlattenedTestCase.php +++ b/tests/Component/Encryption/JWEFlattenedTest.php @@ -11,7 +11,7 @@ /** * @internal */ -final class JWEFlattenedTestCase extends EncryptionTestCase +final class JWEFlattenedTest extends EncryptionTestCase { /** * @see https://tools.ietf.org/html/rfc7516#appendix-A.5 diff --git a/tests/Component/Encryption/JWELoaderTestCase.php b/tests/Component/Encryption/JWELoaderTest.php similarity index 99% rename from tests/Component/Encryption/JWELoaderTestCase.php rename to tests/Component/Encryption/JWELoaderTest.php index c4a98134..754e2592 100644 --- a/tests/Component/Encryption/JWELoaderTestCase.php +++ b/tests/Component/Encryption/JWELoaderTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class JWELoaderTestCase extends EncryptionTestCase +final class JWELoaderTest extends EncryptionTestCase { private ?JWELoader $jweLoader = null; diff --git a/tests/Component/Encryption/JWESplitTestCase.php b/tests/Component/Encryption/JWESplitTest.php similarity index 98% rename from tests/Component/Encryption/JWESplitTestCase.php rename to tests/Component/Encryption/JWESplitTest.php index 9113aeee..df9a154b 100644 --- a/tests/Component/Encryption/JWESplitTestCase.php +++ b/tests/Component/Encryption/JWESplitTest.php @@ -10,7 +10,7 @@ /** * @internal */ -final class JWESplitTestCase extends EncryptionTestCase +final class JWESplitTest extends EncryptionTestCase { #[Test] public function aJweObjectWithMoreThanOneRecipientCanBeSplittedIntoSeveralJweObjects(): void diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTestCase.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php similarity index 98% rename from tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTestCase.php rename to tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php index 30b1b7df..fae1ff62 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTestCase.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class A128KWAndA128GCMEncryptionProtectedContentOnlyTestCase extends EncryptionTestCase +final class A128KWAndA128GCMEncryptionProtectedContentOnlyTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTestCase.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTest.php similarity index 99% rename from tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTestCase.php rename to tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTest.php index 404898f0..5a42d8e8 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTestCase.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class A128KWAndA128GCMEncryptionTestCase extends EncryptionTestCase +final class A128KWAndA128GCMEncryptionTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTestCase.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php similarity index 99% rename from tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTestCase.php rename to tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php index 7e9243de..e0dbc176 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTestCase.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTestCase extends EncryptionTestCase +final class A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTestCase.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php similarity index 99% rename from tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTestCase.php rename to tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php index 6d063434..5311b9fe 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTestCase.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class A128KWAndA128GCMEncryptionWithCompressionTestCase extends EncryptionTestCase +final class A128KWAndA128GCMEncryptionWithCompressionTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTestCase.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php similarity index 99% rename from tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTestCase.php rename to tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php index cbc6f2fc..e62dd549 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTestCase.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTestCase extends EncryptionTestCase +final class A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTestCase.php b/tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php similarity index 99% rename from tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTestCase.php rename to tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php index aba8e934..8858445e 100644 --- a/tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTestCase.php +++ b/tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class A256GCMKWAndA128CBC_HS256EncryptionTestCase extends EncryptionTestCase +final class A256GCMKWAndA128CBC_HS256EncryptionTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTestCase.php b/tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTest.php similarity index 98% rename from tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTestCase.php rename to tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTest.php index a95337b2..9c98d011 100644 --- a/tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTestCase.php +++ b/tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class DirAndA128GCMEncryptionTestCase extends EncryptionTestCase +final class DirAndA128GCMEncryptionTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTestCase.php b/tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php similarity index 99% rename from tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTestCase.php rename to tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php index fae61ff5..0ac5faf7 100644 --- a/tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTestCase.php +++ b/tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class ECDH_ES_A128KWAndA128GCMEncryptionTestCase extends EncryptionTestCase +final class ECDH_ES_A128KWAndA128GCMEncryptionTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTestCase.php b/tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php similarity index 98% rename from tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTestCase.php rename to tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php index c7db6afa..045db225 100644 --- a/tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTestCase.php +++ b/tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class ECDH_ES_AndA128CBC_HS256EncryptionTestCase extends EncryptionTestCase +final class ECDH_ES_AndA128CBC_HS256EncryptionTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTestCase.php b/tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTest.php similarity index 99% rename from tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTestCase.php rename to tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTest.php index fad44426..eae257f3 100644 --- a/tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTestCase.php +++ b/tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTest.php @@ -15,7 +15,7 @@ * * @internal */ -final class MultipleRecipientEncryptionTestCase extends EncryptionTestCase +final class MultipleRecipientEncryptionTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTestCase.php b/tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php similarity index 99% rename from tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTestCase.php rename to tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php index 5cc1c831..fe8c16a2 100644 --- a/tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTestCase.php +++ b/tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php @@ -15,7 +15,7 @@ * * @internal */ -final class PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTestCase extends EncryptionTestCase +final class PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTestCase.php b/tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php similarity index 99% rename from tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTestCase.php rename to tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php index 0d1cabf8..8c879680 100644 --- a/tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTestCase.php +++ b/tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class RSA1_5AndA128CBC_HS256EncryptionTestCase extends EncryptionTestCase +final class RSA1_5AndA128CBC_HS256EncryptionTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTestCase.php b/tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php similarity index 99% rename from tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTestCase.php rename to tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php index dd731d6d..1a849130 100644 --- a/tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTestCase.php +++ b/tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class RSA_OAEPAndA256GCMEncryptionTestCase extends EncryptionTestCase +final class RSA_OAEPAndA256GCMEncryptionTest extends EncryptionTestCase { /** * Please note that we cannot the encryption and get the same result as the example (IV, TAG and other data are diff --git a/tests/Component/Encryption/RSAEncryptionTestCase.php b/tests/Component/Encryption/RSAEncryptionTest.php similarity index 99% rename from tests/Component/Encryption/RSAEncryptionTestCase.php rename to tests/Component/Encryption/RSAEncryptionTest.php index ae078148..2448a301 100644 --- a/tests/Component/Encryption/RSAEncryptionTestCase.php +++ b/tests/Component/Encryption/RSAEncryptionTest.php @@ -10,7 +10,7 @@ /** * @internal */ -final class RSAEncryptionTestCase extends EncryptionTestCase +final class RSAEncryptionTest extends EncryptionTestCase { /** * @see https://tools.ietf.org/html/rfc7516 diff --git a/tests/Component/Encryption/RSAKeyEncryptionTestCase.php b/tests/Component/Encryption/RSAKeyEncryptionTest.php similarity index 99% rename from tests/Component/Encryption/RSAKeyEncryptionTestCase.php rename to tests/Component/Encryption/RSAKeyEncryptionTest.php index ed10d443..c2006b3e 100644 --- a/tests/Component/Encryption/RSAKeyEncryptionTestCase.php +++ b/tests/Component/Encryption/RSAKeyEncryptionTest.php @@ -19,7 +19,7 @@ * * @internal */ -final class RSAKeyEncryptionTestCase extends EncryptionTestCase +final class RSAKeyEncryptionTest extends EncryptionTestCase { #[Test] public function invalidKey(): void diff --git a/tests/Component/Encryption/RSAKeyWithoutAllPrimesTestCase.php b/tests/Component/Encryption/RSAKeyWithoutAllPrimesTest.php similarity index 98% rename from tests/Component/Encryption/RSAKeyWithoutAllPrimesTestCase.php rename to tests/Component/Encryption/RSAKeyWithoutAllPrimesTest.php index 104501b6..a7b7fca2 100644 --- a/tests/Component/Encryption/RSAKeyWithoutAllPrimesTestCase.php +++ b/tests/Component/Encryption/RSAKeyWithoutAllPrimesTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class RSAKeyWithoutAllPrimesTestCase extends EncryptionTestCase +final class RSAKeyWithoutAllPrimesTest extends EncryptionTestCase { #[DataProvider('dataEncryptionAlgorithms')] #[Test] diff --git a/tests/Component/NestedToken/NestingTestCase.php b/tests/Component/NestedToken/NestingTest.php similarity index 99% rename from tests/Component/NestedToken/NestingTestCase.php rename to tests/Component/NestedToken/NestingTest.php index 238a83d2..f1589ce2 100644 --- a/tests/Component/NestedToken/NestingTestCase.php +++ b/tests/Component/NestedToken/NestingTest.php @@ -12,7 +12,7 @@ * * @internal */ -final class NestingTestCase extends NestedTokenTestCase +final class NestingTest extends NestedTokenTestCase { #[Test] public function decryption(): void diff --git a/tests/Component/Signature/ForeignJWTTestCase.php b/tests/Component/Signature/ForeignJWTTest.php similarity index 98% rename from tests/Component/Signature/ForeignJWTTestCase.php rename to tests/Component/Signature/ForeignJWTTest.php index cc7c814c..f5270cd6 100644 --- a/tests/Component/Signature/ForeignJWTTestCase.php +++ b/tests/Component/Signature/ForeignJWTTest.php @@ -10,7 +10,7 @@ /** * @internal */ -final class ForeignJWTTestCase extends SignatureTestCase +final class ForeignJWTTest extends SignatureTestCase { /* * The following test uses an assertion created with another library. diff --git a/tests/Component/Signature/JWSFlattenedTestCase.php b/tests/Component/Signature/JWSFlattenedTest.php similarity index 94% rename from tests/Component/Signature/JWSFlattenedTestCase.php rename to tests/Component/Signature/JWSFlattenedTest.php index 896e4bbd..48d75699 100644 --- a/tests/Component/Signature/JWSFlattenedTestCase.php +++ b/tests/Component/Signature/JWSFlattenedTest.php @@ -10,7 +10,7 @@ /** * @internal */ -final class JWSFlattenedTestCase extends SignatureTestCase +final class JWSFlattenedTest extends SignatureTestCase { /** * @see https://tools.ietf.org/html/rfc7516#appendix-A.5 diff --git a/tests/Component/Signature/JWSLoaderTestCase.php b/tests/Component/Signature/JWSLoaderTest.php similarity index 99% rename from tests/Component/Signature/JWSLoaderTestCase.php rename to tests/Component/Signature/JWSLoaderTest.php index d9fdfc42..4c8aef96 100644 --- a/tests/Component/Signature/JWSLoaderTestCase.php +++ b/tests/Component/Signature/JWSLoaderTest.php @@ -12,7 +12,7 @@ /** * @internal */ -final class JWSLoaderTestCase extends SignatureTestCase +final class JWSLoaderTest extends SignatureTestCase { private ?JWSLoader $jwsLoader = null; diff --git a/tests/Component/Signature/JWSSplitTestCase.php b/tests/Component/Signature/JWSSplitTest.php similarity index 97% rename from tests/Component/Signature/JWSSplitTestCase.php rename to tests/Component/Signature/JWSSplitTest.php index 1a1e4818..27b27ef8 100644 --- a/tests/Component/Signature/JWSSplitTestCase.php +++ b/tests/Component/Signature/JWSSplitTest.php @@ -10,7 +10,7 @@ /** * @internal */ -final class JWSSplitTestCase extends SignatureTestCase +final class JWSSplitTest extends SignatureTestCase { #[Test] public function aJwsObjectWithMoreThanOneRecipientCanBeSplittedIntoSeveralJwsObjects(): void diff --git a/tests/Component/Signature/JWSTestCase.php b/tests/Component/Signature/JWSTest.php similarity index 99% rename from tests/Component/Signature/JWSTestCase.php rename to tests/Component/Signature/JWSTest.php index 442877bb..f2c0c409 100644 --- a/tests/Component/Signature/JWSTestCase.php +++ b/tests/Component/Signature/JWSTest.php @@ -14,7 +14,7 @@ /** * @internal */ -final class JWSTestCase extends SignatureTestCase +final class JWSTest extends SignatureTestCase { #[Test] public function jWS(): void diff --git a/tests/Component/Signature/RFC7520/MultipleSignaturesTestCase.php b/tests/Component/Signature/RFC7520/MultipleSignaturesTest.php similarity index 98% rename from tests/Component/Signature/RFC7520/MultipleSignaturesTestCase.php rename to tests/Component/Signature/RFC7520/MultipleSignaturesTest.php index 894914b1..9f3e5f1d 100644 --- a/tests/Component/Signature/RFC7520/MultipleSignaturesTestCase.php +++ b/tests/Component/Signature/RFC7520/MultipleSignaturesTest.php @@ -13,7 +13,7 @@ * * @internal */ -final class MultipleSignaturesTestCase extends SignatureTestCase +final class MultipleSignaturesTest extends SignatureTestCase { #[Test] public function multipleSignatures(): void diff --git a/tests/Component/Signature/RFC7520/NestingTestCase.php b/tests/Component/Signature/RFC7520/NestingTest.php similarity index 98% rename from tests/Component/Signature/RFC7520/NestingTestCase.php rename to tests/Component/Signature/RFC7520/NestingTest.php index 93f7c81d..ac5f15f0 100644 --- a/tests/Component/Signature/RFC7520/NestingTestCase.php +++ b/tests/Component/Signature/RFC7520/NestingTest.php @@ -14,7 +14,7 @@ * * @internal */ -final class NestingTestCase extends SignatureTestCase +final class NestingTest extends SignatureTestCase { #[Test] public function signatureVerification(): void diff --git a/tests/Component/Signature/SignerTestCase.php b/tests/Component/Signature/SignerTest.php similarity index 93% rename from tests/Component/Signature/SignerTestCase.php rename to tests/Component/Signature/SignerTest.php index db1bd1bd..2e09279b 100644 --- a/tests/Component/Signature/SignerTestCase.php +++ b/tests/Component/Signature/SignerTest.php @@ -16,7 +16,7 @@ /** * @internal */ -final class SignerTestCase extends SignatureTestCase +final class SignerTest extends SignatureTestCase { #[Test] public function algParameterIsMissing(): void @@ -598,7 +598,7 @@ public function compactJSONWithUnencodedPayloadSucceeded(): void #[Test] public function compactJSONWithUnencodedDetachedPayload(): void { - $payload = '$.02'; + $payload = hex2bin('43a40763650d45edcfc7e22bda5bf3ea3039464a53617c83bbffd815f48bb7fade3cacb6c8885ca7ef923ae04cc0567a450473b6e8777640e159e5aba4f6d653fa00c06ca1d48ca826eb68e32d10378716406577a5f92d759e887a3d3d4c496e60cfa1a8700c08aa59b9f1d34039f16119deb8c30ec6195ef352ba7526fbff6fab47360a1e743dd86ba11878c8f9f7bbc901bf04d7843fd0125c310337afef704e1d281b879f0f5dfecd21b69b29d413a597efa2092cbe7ba0e1de5a996b845004047446524f199a08da259d1c5564984e4d8d65058c37577aa344e10e7f188202f330b8f61f66b22e530659d023203efbf91852ddc6babef9dbbf012149dc86678016a2c0351a432f6e652da6913e215c506eb68e0b71f2a2842ae75b7c605d5c1495d53610beff10b11e4991929e2dece56c8472ea8b6a4ee5d846123545efa4d234534d669c8031cb719cc1c8dee3c7072bdf9534616ecf3b53be8be1983734c1e91f6a33cc0d5c34aaecb043b65113fb55a335f8f65a023ae2dba2e8b1488ae1a505bdd7aabc794fffbf1e0ea0ce437df92ac8ad3a4b12e2d5d4bfbaf2f3a1e69f15fc44c3beb310e3bd302407bf265a752a4d09f1f0f5715d409a4b82a5e16748f22934d34592dc5995c16dc73fde436867e576033fcc47a4ff51d6a24b41311d41f8a4f1af78c81ad966dd3baab94b4140'); $protectedHeader = [ 'alg' => 'HS256', 'b64' => false, @@ -622,7 +622,7 @@ public function compactJSONWithUnencodedDetachedPayload(): void $jws = $this->getJWSSerializerManager() ->serialize('jws_compact', $jws, 0); static::assertSame( - 'eyJhbGciOiJIUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..A5dxf2s96_n5FLueVuW1Z_vh161FwXZC4YLPff6dmDY', + 'eyJhbGciOiJIUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..fSKLLXhwLhGW6L4hftrjw9EkAiIikH4KDn9YZ3FDlz8', $jws ); @@ -633,6 +633,38 @@ public function compactJSONWithUnencodedDetachedPayload(): void static::assertSame($protectedHeader, $loaded->getSignature(0)->getProtectedHeader()); } + /** + * @see https://tools.ietf.org/html/rfc7797#section-4 + * @see https://tools.ietf.org/html/rfc7797#section-4.2 + */ + #[Test] + public function compactJSONWithUnencodedAttachedPayloadButNotUTF8(): void + { + static::expectException(InvalidArgumentException::class); + static::expectExceptionMessage('The payload must be encoded in UTF-8'); + $payload = hex2bin('43a40763650d45edcfc7e22bda5bf3ea3039464a53617c83bbffd815f48bb7fade3cacb6c8885ca7ef923ae04cc0567a450473b6e8777640e159e5aba4f6d653fa00c06ca1d48ca826eb68e32d10378716406577a5f92d759e887a3d3d4c496e60cfa1a8700c08aa59b9f1d34039f16119deb8c30ec6195ef352ba7526fbff6fab47360a1e743dd86ba11878c8f9f7bbc901bf04d7843fd0125c310337afef704e1d281b879f0f5dfecd21b69b29d413a597efa2092cbe7ba0e1de5a996b845004047446524f199a08da259d1c5564984e4d8d65058c37577aa344e10e7f188202f330b8f61f66b22e530659d023203efbf91852ddc6babef9dbbf012149dc86678016a2c0351a432f6e652da6913e215c506eb68e0b71f2a2842ae75b7c605d5c1495d53610beff10b11e4991929e2dece56c8472ea8b6a4ee5d846123545efa4d234534d669c8031cb719cc1c8dee3c7072bdf9534616ecf3b53be8be1983734c1e91f6a33cc0d5c34aaecb043b65113fb55a335f8f65a023ae2dba2e8b1488ae1a505bdd7aabc794fffbf1e0ea0ce437df92ac8ad3a4b12e2d5d4bfbaf2f3a1e69f15fc44c3beb310e3bd302407bf265a752a4d09f1f0f5715d409a4b82a5e16748f22934d34592dc5995c16dc73fde436867e576033fcc47a4ff51d6a24b41311d41f8a4f1af78c81ad966dd3baab94b4140'); + $protectedHeader = [ + 'alg' => 'HS256', + 'b64' => false, + 'crit' => ['b64'], + ]; + + $key = new JWK([ + 'kty' => 'oct', + 'k' => 'AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow', + ]); + + $jwsBuilder = $this->getJWSBuilderFactory() + ->create(['HS256']); + $jwsVerifier = $this->getJWSVerifierFactory() + ->create(['HS256']); + $jws = $jwsBuilder + ->create() + ->withPayload($payload) + ->addSignature($key, $protectedHeader) + ->build(); + } + /** * The library is able to support multiple payload encoding and conversion in JSON if payload is detached. */ From 8ad2893a6adbc6ba10af61ef0b33179d462eaa63 Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Thu, 4 Jan 2024 12:59:33 +0100 Subject: [PATCH 2/2] Fix detached and non-encoded non-UTF8 string --- src/Component/Encryption/JWELoader.php | 3 +++ src/Component/Signature/JWS.php | 3 +++ src/Component/Signature/JWSBuilder.php | 4 +++- src/Component/Signature/JWSLoader.php | 3 +++ tests/Component/Signature/SignerTest.php | 12 ++++++++---- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Component/Encryption/JWELoader.php b/src/Component/Encryption/JWELoader.php index 9a6647fb..c3b26158 100644 --- a/src/Component/Encryption/JWELoader.php +++ b/src/Component/Encryption/JWELoader.php @@ -11,6 +11,9 @@ use RuntimeException; use Throwable; +/** + * @see \Jose\Tests\Component\Encryption\JWELoaderTest + */ class JWELoader { public function __construct( diff --git a/src/Component/Signature/JWS.php b/src/Component/Signature/JWS.php index 0da0e127..715ddcc1 100644 --- a/src/Component/Signature/JWS.php +++ b/src/Component/Signature/JWS.php @@ -8,6 +8,9 @@ use Jose\Component\Core\JWT; use function count; +/** + * @see \Jose\Tests\Component\Signature\JWSTest + */ class JWS implements JWT { /** diff --git a/src/Component/Signature/JWSBuilder.php b/src/Component/Signature/JWSBuilder.php index 5c1b91ef..b9b2c7a4 100644 --- a/src/Component/Signature/JWSBuilder.php +++ b/src/Component/Signature/JWSBuilder.php @@ -123,7 +123,9 @@ public function build(): JWS ); if ($this->isPayloadEncoded === false && $this->isPayloadDetached === false) { - mb_detect_encoding($this->payload, 'UTF-8', true) !== false || throw new InvalidArgumentException('The payload must be encoded in UTF-8'); + mb_detect_encoding($this->payload, 'UTF-8', true) !== false || throw new InvalidArgumentException( + 'The payload must be encoded in UTF-8' + ); } $jws = new JWS($this->payload, $encodedPayload, $this->isPayloadDetached); diff --git a/src/Component/Signature/JWSLoader.php b/src/Component/Signature/JWSLoader.php index 35fb2027..8889d2da 100644 --- a/src/Component/Signature/JWSLoader.php +++ b/src/Component/Signature/JWSLoader.php @@ -11,6 +11,9 @@ use Jose\Component\Signature\Serializer\JWSSerializerManager; use Throwable; +/** + * @see \Jose\Tests\Component\Signature\JWSLoaderTest + */ class JWSLoader { public function __construct( diff --git a/tests/Component/Signature/SignerTest.php b/tests/Component/Signature/SignerTest.php index 2e09279b..dbc63b0b 100644 --- a/tests/Component/Signature/SignerTest.php +++ b/tests/Component/Signature/SignerTest.php @@ -598,7 +598,9 @@ public function compactJSONWithUnencodedPayloadSucceeded(): void #[Test] public function compactJSONWithUnencodedDetachedPayload(): void { - $payload = hex2bin('43a40763650d45edcfc7e22bda5bf3ea3039464a53617c83bbffd815f48bb7fade3cacb6c8885ca7ef923ae04cc0567a450473b6e8777640e159e5aba4f6d653fa00c06ca1d48ca826eb68e32d10378716406577a5f92d759e887a3d3d4c496e60cfa1a8700c08aa59b9f1d34039f16119deb8c30ec6195ef352ba7526fbff6fab47360a1e743dd86ba11878c8f9f7bbc901bf04d7843fd0125c310337afef704e1d281b879f0f5dfecd21b69b29d413a597efa2092cbe7ba0e1de5a996b845004047446524f199a08da259d1c5564984e4d8d65058c37577aa344e10e7f188202f330b8f61f66b22e530659d023203efbf91852ddc6babef9dbbf012149dc86678016a2c0351a432f6e652da6913e215c506eb68e0b71f2a2842ae75b7c605d5c1495d53610beff10b11e4991929e2dece56c8472ea8b6a4ee5d846123545efa4d234534d669c8031cb719cc1c8dee3c7072bdf9534616ecf3b53be8be1983734c1e91f6a33cc0d5c34aaecb043b65113fb55a335f8f65a023ae2dba2e8b1488ae1a505bdd7aabc794fffbf1e0ea0ce437df92ac8ad3a4b12e2d5d4bfbaf2f3a1e69f15fc44c3beb310e3bd302407bf265a752a4d09f1f0f5715d409a4b82a5e16748f22934d34592dc5995c16dc73fde436867e576033fcc47a4ff51d6a24b41311d41f8a4f1af78c81ad966dd3baab94b4140'); + $payload = hex2bin( + '43a40763650d45edcfc7e22bda5bf3ea3039464a53617c83bbffd815f48bb7fade3cacb6c8885ca7ef923ae04cc0567a450473b6e8777640e159e5aba4f6d653fa00c06ca1d48ca826eb68e32d10378716406577a5f92d759e887a3d3d4c496e60cfa1a8700c08aa59b9f1d34039f16119deb8c30ec6195ef352ba7526fbff6fab47360a1e743dd86ba11878c8f9f7bbc901bf04d7843fd0125c310337afef704e1d281b879f0f5dfecd21b69b29d413a597efa2092cbe7ba0e1de5a996b845004047446524f199a08da259d1c5564984e4d8d65058c37577aa344e10e7f188202f330b8f61f66b22e530659d023203efbf91852ddc6babef9dbbf012149dc86678016a2c0351a432f6e652da6913e215c506eb68e0b71f2a2842ae75b7c605d5c1495d53610beff10b11e4991929e2dece56c8472ea8b6a4ee5d846123545efa4d234534d669c8031cb719cc1c8dee3c7072bdf9534616ecf3b53be8be1983734c1e91f6a33cc0d5c34aaecb043b65113fb55a335f8f65a023ae2dba2e8b1488ae1a505bdd7aabc794fffbf1e0ea0ce437df92ac8ad3a4b12e2d5d4bfbaf2f3a1e69f15fc44c3beb310e3bd302407bf265a752a4d09f1f0f5715d409a4b82a5e16748f22934d34592dc5995c16dc73fde436867e576033fcc47a4ff51d6a24b41311d41f8a4f1af78c81ad966dd3baab94b4140' + ); $protectedHeader = [ 'alg' => 'HS256', 'b64' => false, @@ -642,7 +644,9 @@ public function compactJSONWithUnencodedAttachedPayloadButNotUTF8(): void { static::expectException(InvalidArgumentException::class); static::expectExceptionMessage('The payload must be encoded in UTF-8'); - $payload = hex2bin('43a40763650d45edcfc7e22bda5bf3ea3039464a53617c83bbffd815f48bb7fade3cacb6c8885ca7ef923ae04cc0567a450473b6e8777640e159e5aba4f6d653fa00c06ca1d48ca826eb68e32d10378716406577a5f92d759e887a3d3d4c496e60cfa1a8700c08aa59b9f1d34039f16119deb8c30ec6195ef352ba7526fbff6fab47360a1e743dd86ba11878c8f9f7bbc901bf04d7843fd0125c310337afef704e1d281b879f0f5dfecd21b69b29d413a597efa2092cbe7ba0e1de5a996b845004047446524f199a08da259d1c5564984e4d8d65058c37577aa344e10e7f188202f330b8f61f66b22e530659d023203efbf91852ddc6babef9dbbf012149dc86678016a2c0351a432f6e652da6913e215c506eb68e0b71f2a2842ae75b7c605d5c1495d53610beff10b11e4991929e2dece56c8472ea8b6a4ee5d846123545efa4d234534d669c8031cb719cc1c8dee3c7072bdf9534616ecf3b53be8be1983734c1e91f6a33cc0d5c34aaecb043b65113fb55a335f8f65a023ae2dba2e8b1488ae1a505bdd7aabc794fffbf1e0ea0ce437df92ac8ad3a4b12e2d5d4bfbaf2f3a1e69f15fc44c3beb310e3bd302407bf265a752a4d09f1f0f5715d409a4b82a5e16748f22934d34592dc5995c16dc73fde436867e576033fcc47a4ff51d6a24b41311d41f8a4f1af78c81ad966dd3baab94b4140'); + $payload = hex2bin( + '43a40763650d45edcfc7e22bda5bf3ea3039464a53617c83bbffd815f48bb7fade3cacb6c8885ca7ef923ae04cc0567a450473b6e8777640e159e5aba4f6d653fa00c06ca1d48ca826eb68e32d10378716406577a5f92d759e887a3d3d4c496e60cfa1a8700c08aa59b9f1d34039f16119deb8c30ec6195ef352ba7526fbff6fab47360a1e743dd86ba11878c8f9f7bbc901bf04d7843fd0125c310337afef704e1d281b879f0f5dfecd21b69b29d413a597efa2092cbe7ba0e1de5a996b845004047446524f199a08da259d1c5564984e4d8d65058c37577aa344e10e7f188202f330b8f61f66b22e530659d023203efbf91852ddc6babef9dbbf012149dc86678016a2c0351a432f6e652da6913e215c506eb68e0b71f2a2842ae75b7c605d5c1495d53610beff10b11e4991929e2dece56c8472ea8b6a4ee5d846123545efa4d234534d669c8031cb719cc1c8dee3c7072bdf9534616ecf3b53be8be1983734c1e91f6a33cc0d5c34aaecb043b65113fb55a335f8f65a023ae2dba2e8b1488ae1a505bdd7aabc794fffbf1e0ea0ce437df92ac8ad3a4b12e2d5d4bfbaf2f3a1e69f15fc44c3beb310e3bd302407bf265a752a4d09f1f0f5715d409a4b82a5e16748f22934d34592dc5995c16dc73fde436867e576033fcc47a4ff51d6a24b41311d41f8a4f1af78c81ad966dd3baab94b4140' + ); $protectedHeader = [ 'alg' => 'HS256', 'b64' => false, @@ -656,9 +660,9 @@ public function compactJSONWithUnencodedAttachedPayloadButNotUTF8(): void $jwsBuilder = $this->getJWSBuilderFactory() ->create(['HS256']); - $jwsVerifier = $this->getJWSVerifierFactory() + $this->getJWSVerifierFactory() ->create(['HS256']); - $jws = $jwsBuilder + $jwsBuilder ->create() ->withPayload($payload) ->addSignature($key, $protectedHeader)