From b5b96f81eddf7a09fe8cae6c6c1a8c632d6a4edc Mon Sep 17 00:00:00 2001 From: Spomky Date: Sun, 21 Feb 2016 05:49:29 -0500 Subject: [PATCH] Applied fixes from StyleCI --- src/Factory/JWKFactory.php | 8 +- src/Util/ConcatKDF.php | 15 ++-- src/Util/GCM.php | 4 +- ...8GCMEncryptionProtectedContentOnlyTest.php | 18 ++--- .../A128KWAndA128GCMEncryptionTest.php | 19 ++--- ...ionWithAdditionalAuthenticatedDataTest.php | 19 ++--- ...ndA128GCMEncryptionWithCompressionTest.php | 21 +++-- ...nWithSpecificProtectedHeaderValuesTest.php | 18 ++--- ...256GCMKWAndA128CBC_HS256EncryptionTest.php | 25 +++--- tests/RFC7520/DirAndA128GCMEncryptionTest.php | 18 ++--- ...ECDH_ES_A128KWAndA128GCMEncryptionTest.php | 32 ++++---- ...ECDH_ES_AndA128CBC_HS256EncryptionTest.php | 32 ++++---- .../MultipleRecipientEncryptionTest.php | 80 +++++++++---------- ...2_A256KWAndA128CBC_HS256EncryptionTest.php | 28 +++---- .../RSA1_5AndA128CBC_HS256EncryptionTest.php | 30 ++++--- .../RSA_OAEPAndA256GCMEncryptionTest.php | 32 ++++---- tests/Unit/Objects/ConcatKDFTest.php | 37 +++++---- 17 files changed, 203 insertions(+), 233 deletions(-) diff --git a/src/Factory/JWKFactory.php b/src/Factory/JWKFactory.php index 4652ff84..b5682253 100644 --- a/src/Factory/JWKFactory.php +++ b/src/Factory/JWKFactory.php @@ -33,11 +33,11 @@ public static function createRandomECPrivateKey($curve, array $additional_values $privKey = $generator->createPrivateKey(); $values = [ - "kty" =>"EC", + 'kty' => 'EC', 'crv' => $curve, - 'x' => Base64Url::encode(self::convertDecToBin($privKey->getPoint()->getX())), - 'y' => Base64Url::encode(self::convertDecToBin($privKey->getPoint()->getY())), - 'd' => Base64Url::encode(self::convertDecToBin($privKey->getSecret())), + 'x' => Base64Url::encode(self::convertDecToBin($privKey->getPoint()->getX())), + 'y' => Base64Url::encode(self::convertDecToBin($privKey->getPoint()->getY())), + 'd' => Base64Url::encode(self::convertDecToBin($privKey->getSecret())), ]; $values = array_merge($values, $additional_values); diff --git a/src/Util/ConcatKDF.php b/src/Util/ConcatKDF.php index 74f93726..82d942d7 100644 --- a/src/Util/ConcatKDF.php +++ b/src/Util/ConcatKDF.php @@ -10,6 +10,7 @@ */ namespace Jose\Util; + use Base64Url\Base64Url; /** @@ -24,18 +25,18 @@ final class ConcatKDF /** * Key Derivation Function. * - * @param string $Z Shared secret - * @param string $algorithm Encryption algorithm - * @param int $encryption_key_size Size of the encryption key - * @param string $apu Agreement PartyUInfo (information about the producer) - * @param string $apv Agreement PartyVInfo (information about the recipient) + * @param string $Z Shared secret + * @param string $algorithm Encryption algorithm + * @param int $encryption_key_size Size of the encryption key + * @param string $apu Agreement PartyUInfo (information about the producer) + * @param string $apv Agreement PartyVInfo (information about the recipient) * * @return string */ public static function generate($Z, $algorithm, $encryption_key_size, $apu = '', $apv = '') { - $apu = !empty($apu)?Base64Url::decode($apu):''; - $apv = !empty($apv)?Base64Url::decode($apv):''; + $apu = !empty($apu) ? Base64Url::decode($apu) : ''; + $apv = !empty($apv) ? Base64Url::decode($apv) : ''; $encryption_segments = [ self::toInt32Bits(1), // Round number 1 $Z, // Z (shared secret) diff --git a/src/Util/GCM.php b/src/Util/GCM.php index ba47fc9a..11ca03e2 100644 --- a/src/Util/GCM.php +++ b/src/Util/GCM.php @@ -259,7 +259,7 @@ private static function getHash($H, $X) { $Y = []; $Y[0] = StringUtil::addPadding('', 16, "\0"); - $num_blocks = (int)(StringUtil::getStringLength($X) / 16); + $num_blocks = (int) (StringUtil::getStringLength($X) / 16); for ($i = 1; $i <= $num_blocks; $i++) { $Y[$i] = self::getProduct(self::getBitXor($Y[$i - 1], StringUtil::getSubString($X, ($i - 1) * 16, 16)), $H); } @@ -285,7 +285,7 @@ private static function getGCTR($K, $ICB, $X) $iv = str_repeat(chr(0), 16); // initialize to 16 byte string of "0"s mcrypt_generic_init($cipher, $K, $iv); - $n = (int)ceil(self::getLength($X) / 128); + $n = (int) ceil(self::getLength($X) / 128); $CB = []; $Y = []; $CB[1] = $ICB; diff --git a/tests/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php b/tests/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php index 025cc139..42e6ee4f 100644 --- a/tests/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php +++ b/tests/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php @@ -32,20 +32,20 @@ public function testA128KWAndA128GCMEncryptionProtectedContentOnly() $expected_payload = "You can trust us to stick with you through thick and thin\xe2\x80\x93to the bitter end. And you can trust us to keep any secret of yours\xe2\x80\x93closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo."; $private_key = new JWK([ - "kty" => "oct", - "kid" => "81b20965-8332-43d9-a468-82160ad91ac8", - "use" => "enc", - "alg" => "A128KW", - "k" => "GZy6sIZ6wl9NJOKB-jnmVQ", + 'kty' => 'oct', + 'kid' => '81b20965-8332-43d9-a468-82160ad91ac8', + 'use' => 'enc', + 'alg' => 'A128KW', + 'k' => 'GZy6sIZ6wl9NJOKB-jnmVQ', ]); $protected_headers = [ ]; $headers = [ - "enc" => "A128GCM", - "alg" => "A128KW", - "kid" => "81b20965-8332-43d9-a468-82160ad91ac8", + 'enc' => 'A128GCM', + 'alg' => 'A128KW', + 'kid' => '81b20965-8332-43d9-a468-82160ad91ac8', ]; $expected_flattened_json = '{"unprotected":{"alg":"A128KW","kid":"81b20965-8332-43d9-a468-82160ad91ac8","enc":"A128GCM"},"encrypted_key":"244YHfO_W7RMpQW81UjQrZcq5LSyqiPv","iv":"YihBoVOGsR1l7jCD","ciphertext":"qtPIMMaOBRgASL10dNQhOa7Gqrk7Eal1vwht7R4TT1uq-arsVCPaIeFwQfzrSS6oEUWbBtxEasE0vC6r7sphyVziMCVJEuRJyoAHFSP3eqQPb4Ic1SDSqyXjw_L3svybhHYUGyQuTmUQEDjgjJfBOifwHIsDsRPeBz1NomqeifVPq5GTCWFo5k_MNIQURR2Wj0AHC2k7JZfu2iWjUHLF8ExFZLZ4nlmsvJu_mvifMYiikfNfsZAudISOa6O73yPZtL04k_1FI7WDfrb2w7OqKLWDXzlpcxohPVOLQwpA3mFNRKdY-bQz4Z4KX9lfz1cne31N4-8BKmojpw-OdQjKdLOGkC445Fb_K1tlDQXw2sBF","tag":"e2m0Vm7JvjK2VpCKXS-kyg"}'; @@ -72,7 +72,6 @@ public function testA128KWAndA128GCMEncryptionProtectedContentOnly() $this->assertEquals($expected_tag, Base64Url::encode($loaded_flattened_json->getTag())); $this->assertEquals($expected_cek, Base64Url::encode($loaded_flattened_json->getContentEncryptionKey())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_iv, Base64Url::encode($loaded_json->getIV())); @@ -81,7 +80,6 @@ public function testA128KWAndA128GCMEncryptionProtectedContentOnly() $this->assertEquals($expected_tag, Base64Url::encode($loaded_json->getTag())); $this->assertEquals($expected_cek, Base64Url::encode($loaded_json->getContentEncryptionKey())); - $this->assertEquals($expected_payload, $loaded_flattened_json->getPayload()); $this->assertEquals($expected_payload, $loaded_json->getPayload()); } diff --git a/tests/RFC7520/A128KWAndA128GCMEncryptionTest.php b/tests/RFC7520/A128KWAndA128GCMEncryptionTest.php index 4b9135ac..15bde745 100644 --- a/tests/RFC7520/A128KWAndA128GCMEncryptionTest.php +++ b/tests/RFC7520/A128KWAndA128GCMEncryptionTest.php @@ -32,17 +32,17 @@ public function testA128KWAndA128GCMEncryption() $expected_payload = "You can trust us to stick with you through thick and thin\xe2\x80\x93to the bitter end. And you can trust us to keep any secret of yours\xe2\x80\x93closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo."; $private_key = new JWK([ - "kty" => "oct", - "kid" => "81b20965-8332-43d9-a468-82160ad91ac8", - "use" => "enc", - "alg" => "A128KW", - "k" => "GZy6sIZ6wl9NJOKB-jnmVQ", + 'kty' => 'oct', + 'kid' => '81b20965-8332-43d9-a468-82160ad91ac8', + 'use' => 'enc', + 'alg' => 'A128KW', + 'k' => 'GZy6sIZ6wl9NJOKB-jnmVQ', ]); $protected_headers = [ - "alg" => "A128KW", - "kid" => "81b20965-8332-43d9-a468-82160ad91ac8", - "enc" => "A128GCM", + 'alg' => 'A128KW', + 'kid' => '81b20965-8332-43d9-a468-82160ad91ac8', + 'enc' => 'A128GCM', ]; $expected_compact_json = 'eyJhbGciOiJBMTI4S1ciLCJraWQiOiI4MWIyMDk2NS04MzMyLTQzZDktYTQ2OC04MjE2MGFkOTFhYzgiLCJlbmMiOiJBMTI4R0NNIn0.CBI6oDw8MydIx1IBntf_lQcw2MmJKIQx.Qx0pmsDa8KnJc9Jo.AwliP-KmWgsZ37BvzCefNen6VTbRK3QMA4TkvRkH0tP1bTdhtFJgJxeVmJkLD61A1hnWGetdg11c9ADsnWgL56NyxwSYjU1ZEHcGkd3EkU0vjHi9gTlb90qSYFfeF0LwkcTtjbYKCsiNJQkcIp1yeM03OmuiYSoYJVSpf7ej6zaYcMv3WwdxDFl8REwOhNImk2Xld2JXq6BR53TSFkyT7PwVLuq-1GwtGHlQeg7gDT6xW0JqHDPn_H-puQsmthc9Zg0ojmJfqqFvETUxLAF-KjcBTS5dNy6egwkYtOt8EIHK-oEsKYtZRaa8Z7MOZ7UGxGIMvEmxrGCPeJa14slv2-gaqK0kEThkaSqdYw0FkQZF.ER7MWJZ1FBI_NKvn7Zb1Lw'; @@ -72,7 +72,6 @@ public function testA128KWAndA128GCMEncryption() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_compact_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_compact_json->getTag())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_flattened_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_flattened_json->getSharedProtectedHeaders()); $this->assertEquals($expected_cek, Base64Url::encode($loaded_flattened_json->getContentEncryptionKey())); @@ -80,7 +79,6 @@ public function testA128KWAndA128GCMEncryption() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_flattened_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_flattened_json->getTag())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_cek, Base64Url::encode($loaded_json->getContentEncryptionKey())); @@ -88,7 +86,6 @@ public function testA128KWAndA128GCMEncryption() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_json->getTag())); - $this->assertEquals($expected_payload, $loaded_compact_json->getPayload()); $this->assertEquals($expected_payload, $loaded_flattened_json->getPayload()); $this->assertEquals($expected_payload, $loaded_json->getPayload()); diff --git a/tests/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php b/tests/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php index c619c849..4479e7af 100644 --- a/tests/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php +++ b/tests/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php @@ -32,17 +32,17 @@ public function testA128KWAndA128GCMEncryptionWithAdditionalAuthenticatedData() $expected_payload = "You can trust us to stick with you through thick and thin\xe2\x80\x93to the bitter end. And you can trust us to keep any secret of yours\xe2\x80\x93closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo."; $private_key = new JWK([ - "kty" => "oct", - "kid" => "81b20965-8332-43d9-a468-82160ad91ac8", - "use" => "enc", - "alg" => "A128KW", - "k" => "GZy6sIZ6wl9NJOKB-jnmVQ", + 'kty' => 'oct', + 'kid' => '81b20965-8332-43d9-a468-82160ad91ac8', + 'use' => 'enc', + 'alg' => 'A128KW', + 'k' => 'GZy6sIZ6wl9NJOKB-jnmVQ', ]); $protected_headers = [ - "alg" => "A128KW", - "kid" => "81b20965-8332-43d9-a468-82160ad91ac8", - "enc" => "A128GCM", + 'alg' => 'A128KW', + 'kid' => '81b20965-8332-43d9-a468-82160ad91ac8', + 'enc' => 'A128GCM', ]; $expected_flattened_json = '{"protected":"eyJhbGciOiJBMTI4S1ciLCJraWQiOiI4MWIyMDk2NS04MzMyLTQzZDktYTQ2OC04MjE2MGFkOTFhYzgiLCJlbmMiOiJBMTI4R0NNIn0","encrypted_key":"4YiiQ_ZzH76TaIkJmYfRFgOV9MIpnx4X","aad":"WyJ2Y2FyZCIsW1sidmVyc2lvbiIse30sInRleHQiLCI0LjAiXSxbImZuIix7fSwidGV4dCIsIk1lcmlhZG9jIEJyYW5keWJ1Y2siXSxbIm4iLHt9LCJ0ZXh0IixbIkJyYW5keWJ1Y2siLCJNZXJpYWRvYyIsIk1yLiIsIiJdXSxbImJkYXkiLHt9LCJ0ZXh0IiwiVEEgMjk4MiJdLFsiZ2VuZGVyIix7fSwidGV4dCIsIk0iXV1d","iv":"veCx9ece2orS7c_N","ciphertext":"Z_3cbr0k3bVM6N3oSNmHz7Lyf3iPppGf3Pj17wNZqteJ0Ui8p74SchQP8xygM1oFRWCNzeIa6s6BcEtp8qEFiqTUEyiNkOWDNoF14T_4NFqF-p2Mx8zkbKxI7oPK8KNarFbyxIDvICNqBLba-v3uzXBdB89fzOI-Lv4PjOFAQGHrgv1rjXAmKbgkft9cB4WeyZw8MldbBhc-V_KWZslrsLNygon_JJWd_ek6LQn5NRehvApqf9ZrxB4aq3FXBxOxCys35PhCdaggy2kfUfl2OkwKnWUbgXVD1C6HxLIlqHhCwXDG59weHrRDQeHyMRoBljoV3X_bUTJDnKBFOod7nLz-cj48JMx3SnCZTpbQAkFV","tag":"vOaH_Rajnpy_3hOtqvZHRA"}'; @@ -62,7 +62,6 @@ public function testA128KWAndA128GCMEncryptionWithAdditionalAuthenticatedData() $loaded_json = Loader::load($expected_json); $this->assertEquals(0, $decrypter->decryptUsingKey($loaded_json, $private_key)); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_flattened_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_flattened_json->getSharedProtectedHeaders()); $this->assertEquals($expected_iv, Base64Url::encode($loaded_flattened_json->getIV())); @@ -71,7 +70,6 @@ public function testA128KWAndA128GCMEncryptionWithAdditionalAuthenticatedData() $this->assertEquals($expected_aad, $loaded_flattened_json->getAAD()); $this->assertEquals($expected_cek, Base64Url::encode($loaded_flattened_json->getContentEncryptionKey())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_iv, Base64Url::encode($loaded_json->getIV())); @@ -80,7 +78,6 @@ public function testA128KWAndA128GCMEncryptionWithAdditionalAuthenticatedData() $this->assertEquals($expected_aad, $loaded_json->getAAD()); $this->assertEquals($expected_cek, Base64Url::encode($loaded_json->getContentEncryptionKey())); - $this->assertEquals($expected_payload, $loaded_flattened_json->getPayload()); $this->assertEquals($expected_payload, $loaded_json->getPayload()); } diff --git a/tests/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php b/tests/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php index e2f7e7d6..0e0d85c6 100644 --- a/tests/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php +++ b/tests/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php @@ -32,18 +32,18 @@ public function testA128KWAndA128GCMEncryptionWithCompression() $expected_payload = "You can trust us to stick with you through thick and thin\xe2\x80\x93to the bitter end. And you can trust us to keep any secret of yours\xe2\x80\x93closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo."; $private_key = new JWK([ - "kty" => "oct", - "kid" => "81b20965-8332-43d9-a468-82160ad91ac8", - "use" => "enc", - "alg" => "A128KW", - "k" => "GZy6sIZ6wl9NJOKB-jnmVQ", + 'kty' => 'oct', + 'kid' => '81b20965-8332-43d9-a468-82160ad91ac8', + 'use' => 'enc', + 'alg' => 'A128KW', + 'k' => 'GZy6sIZ6wl9NJOKB-jnmVQ', ]); $protected_headers = [ - "alg" => "A128KW", - "kid" => "81b20965-8332-43d9-a468-82160ad91ac8", - "enc" => "A128GCM", - "zip" => "DEF", + 'alg' => 'A128KW', + 'kid' => '81b20965-8332-43d9-a468-82160ad91ac8', + 'enc' => 'A128GCM', + 'zip' => 'DEF', ]; $expected_compact_json = 'eyJhbGciOiJBMTI4S1ciLCJraWQiOiI4MWIyMDk2NS04MzMyLTQzZDktYTQ2OC04MjE2MGFkOTFhYzgiLCJlbmMiOiJBMTI4R0NNIiwiemlwIjoiREVGIn0.5vUT2WOtQxKWcekM_IzVQwkGgzlFDwPi.p9pUq6XHY0jfEZIl.HbDtOsdai1oYziSx25KEeTxmwnh8L8jKMFNc1k3zmMI6VB8hry57tDZ61jXyezSPt0fdLVfe6Jf5y5-JaCap_JQBcb5opbmT60uWGml8blyiMQmOn9J--XhhlYg0m-BHaqfDO5iTOWxPxFMUedx7WCy8mxgDHj0aBMG6152PsM-w5E_o2B3jDbrYBKhpYA7qi3AyijnCJ7BP9rr3U8kxExCpG3mK420TjOw.VILuUwuIxaLVmh5X-T7kmA'; @@ -73,7 +73,6 @@ public function testA128KWAndA128GCMEncryptionWithCompression() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_compact_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_compact_json->getTag())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_flattened_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_flattened_json->getSharedProtectedHeaders()); $this->assertEquals($expected_cek, Base64Url::encode($loaded_flattened_json->getContentEncryptionKey())); @@ -81,7 +80,6 @@ public function testA128KWAndA128GCMEncryptionWithCompression() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_flattened_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_flattened_json->getTag())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_cek, Base64Url::encode($loaded_json->getContentEncryptionKey())); @@ -89,7 +87,6 @@ public function testA128KWAndA128GCMEncryptionWithCompression() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_json->getTag())); - $this->assertEquals($expected_payload, $loaded_compact_json->getPayload()); $this->assertEquals($expected_payload, $loaded_flattened_json->getPayload()); $this->assertEquals($expected_payload, $loaded_json->getPayload()); diff --git a/tests/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php b/tests/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php index 76c2ed65..b245c390 100644 --- a/tests/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php +++ b/tests/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php @@ -32,20 +32,20 @@ public function testA128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValues( $expected_payload = "You can trust us to stick with you through thick and thin\xe2\x80\x93to the bitter end. And you can trust us to keep any secret of yours\xe2\x80\x93closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo."; $private_key = new JWK([ - "kty" => "oct", - "kid" => "81b20965-8332-43d9-a468-82160ad91ac8", - "use" => "enc", - "alg" => "A128KW", - "k" => "GZy6sIZ6wl9NJOKB-jnmVQ", + 'kty' => 'oct', + 'kid' => '81b20965-8332-43d9-a468-82160ad91ac8', + 'use' => 'enc', + 'alg' => 'A128KW', + 'k' => 'GZy6sIZ6wl9NJOKB-jnmVQ', ]); $protected_headers = [ - "enc" => "A128GCM", + 'enc' => 'A128GCM', ]; $headers = [ - "alg" => "A128KW", - "kid" => "81b20965-8332-43d9-a468-82160ad91ac8", + 'alg' => 'A128KW', + 'kid' => '81b20965-8332-43d9-a468-82160ad91ac8', ]; $expected_flattened_json = '{"protected":"eyJlbmMiOiJBMTI4R0NNIn0","unprotected":{"alg":"A128KW","kid":"81b20965-8332-43d9-a468-82160ad91ac8"},"encrypted_key":"jJIcM9J-hbx3wnqhf5FlkEYos0sHsF0H","iv":"WgEJsDS9bkoXQ3nR","ciphertext":"lIbCyRmRJxnB2yLQOTqjCDKV3H30ossOw3uD9DPsqLL2DM3swKkjOwQyZtWsFLYMj5YeLht_StAn21tHmQJuuNt64T8D4t6C7kC9OCCJ1IHAolUv4MyOt80MoPb8fZYbNKqplzYJgIL58g8N2v46OgyG637d6uuKPwhAnTGm_zWhqc_srOvgiLkzyFXPq1hBAURbc3-8BqeRb48iR1-_5g5UjWVD3lgiLCN_P7AW8mIiFvUNXBPJK3nOWL4teUPS8yHLbWeL83olU4UAgL48x-8dDkH23JykibVSQju-f7e-1xreHWXzWLHs1NqBbre0dEwK3HX_xM0LjUz77Krppgegoutpf5qaKg3l-_xMINmf","tag":"fNYLqpUe84KD45lvDiaBAQ"}'; @@ -72,7 +72,6 @@ public function testA128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValues( $this->assertEquals($expected_tag, Base64Url::encode($loaded_flattened_json->getTag())); $this->assertEquals($expected_cek, Base64Url::encode($loaded_flattened_json->getContentEncryptionKey())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_iv, Base64Url::encode($loaded_json->getIV())); @@ -81,7 +80,6 @@ public function testA128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValues( $this->assertEquals($expected_tag, Base64Url::encode($loaded_json->getTag())); $this->assertEquals($expected_cek, Base64Url::encode($loaded_json->getContentEncryptionKey())); - $this->assertEquals($expected_payload, $loaded_flattened_json->getPayload()); $this->assertEquals($expected_payload, $loaded_json->getPayload()); } diff --git a/tests/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php b/tests/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php index e0787a2b..84227016 100644 --- a/tests/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php +++ b/tests/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php @@ -32,24 +32,24 @@ public function testA256GCMKWAndA128CBC_HS256Encryption() $expected_payload = "You can trust us to stick with you through thick and thin\xe2\x80\x93to the bitter end. And you can trust us to keep any secret of yours\xe2\x80\x93closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo."; $private_key = new JWK([ - "kty" => "oct", - "kid" => "18ec08e1-bfa9-4d95-b205-2b4dd1d4321d", - "use" => "enc", - "alg" => "A256GCMKW", - "k" => "qC57l_uxcm7Nm3K-ct4GFjx8tM1U8CZ0NLBvdQstiS8", + 'kty' => 'oct', + 'kid' => '18ec08e1-bfa9-4d95-b205-2b4dd1d4321d', + 'use' => 'enc', + 'alg' => 'A256GCMKW', + 'k' => 'qC57l_uxcm7Nm3K-ct4GFjx8tM1U8CZ0NLBvdQstiS8', ]); $protected_headers = [ - "alg" => "A256GCMKW", - "kid" => "18ec08e1-bfa9-4d95-b205-2b4dd1d4321d", - "tag" => "kfPduVQ3T3H6vnewt--ksw", - "iv" => "KkYT0GX_2jHlfqN_", - "enc" => "A128CBC-HS256", + 'alg' => 'A256GCMKW', + 'kid' => '18ec08e1-bfa9-4d95-b205-2b4dd1d4321d', + 'tag' => 'kfPduVQ3T3H6vnewt--ksw', + 'iv' => 'KkYT0GX_2jHlfqN_', + 'enc' => 'A128CBC-HS256', ]; $expected_compact_json = 'eyJhbGciOiJBMjU2R0NNS1ciLCJraWQiOiIxOGVjMDhlMS1iZmE5LTRkOTUtYjIwNS0yYjRkZDFkNDMyMWQiLCJ0YWciOiJrZlBkdVZRM1QzSDZ2bmV3dC0ta3N3IiwiaXYiOiJLa1lUMEdYXzJqSGxmcU5fIiwiZW5jIjoiQTEyOENCQy1IUzI1NiJ9.lJf3HbOApxMEBkCMOoTnnABxs_CvTWUmZQ2ElLvYNok.gz6NjyEFNm_vm8Gj6FwoFQ.Jf5p9-ZhJlJy_IQ_byKFmI0Ro7w7G1QiaZpI8OaiVgD8EqoDZHyFKFBupS8iaEeVIgMqWmsuJKuoVgzR3YfzoMd3GxEm3VxNhzWyWtZKX0gxKdy6HgLvqoGNbZCzLjqcpDiF8q2_62EVAbr2uSc2oaxFmFuIQHLcqAHxy51449xkjZ7ewzZaGV3eFqhpco8o4DijXaG5_7kp3h2cajRfDgymuxUbWgLqaeNQaJtvJmSMFuEOSAzw9Hdeb6yhdTynCRmu-kqtO5Dec4lT2OMZKpnxc_F1_4yDJFcqb5CiDSmA-psB2k0JtjxAj4UPI61oONK7zzFIu4gBfjJCndsZfdvG7h8wGjV98QhrKEnR7xKZ3KCr0_qR1B-gxpNk3xWU.DKW7jrb4WaRSNfbXVPlT5g'; - /** + /* * There is an error in this vector * In the RFC7520, the tag is 'DKW7jrb4WaRSNfbXVPlT5g' (see figure 147), but the tag from the flattened representation is 'NvBveHr_vonkvflfnUrmBQ' * Same goes for the protected header. The values are good, but as the order is different, the protected header value is different and the tag is not validated. @@ -80,7 +80,6 @@ public function testA256GCMKWAndA128CBC_HS256Encryption() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_compact_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_compact_json->getTag())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_flattened_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_flattened_json->getSharedProtectedHeaders()); $this->assertEquals($expected_cek, Base64Url::encode($loaded_flattened_json->getContentEncryptionKey())); @@ -88,7 +87,6 @@ public function testA256GCMKWAndA128CBC_HS256Encryption() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_flattened_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_flattened_json->getTag())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_cek, Base64Url::encode($loaded_json->getContentEncryptionKey())); @@ -96,7 +94,6 @@ public function testA256GCMKWAndA128CBC_HS256Encryption() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_json->getTag())); - $this->assertEquals($expected_payload, $loaded_compact_json->getPayload()); $this->assertEquals($expected_payload, $loaded_flattened_json->getPayload()); $this->assertEquals($expected_payload, $loaded_json->getPayload()); diff --git a/tests/RFC7520/DirAndA128GCMEncryptionTest.php b/tests/RFC7520/DirAndA128GCMEncryptionTest.php index 6ce0189c..fea52794 100644 --- a/tests/RFC7520/DirAndA128GCMEncryptionTest.php +++ b/tests/RFC7520/DirAndA128GCMEncryptionTest.php @@ -32,17 +32,17 @@ public function testDirAndA128GCMEncryption() $expected_payload = "You can trust us to stick with you through thick and thin\xe2\x80\x93to the bitter end. And you can trust us to keep any secret of yours\xe2\x80\x93closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo."; $private_key = new JWK([ - "kty" => "oct", - "kid" => "77c7e2b8-6e13-45cf-8672-617b5b45243a", - "use" => "enc", - "alg" => "A128GCM", - "k" => "XctOhJAkA-pD9Lh7ZgW_2A", + 'kty' => 'oct', + 'kid' => '77c7e2b8-6e13-45cf-8672-617b5b45243a', + 'use' => 'enc', + 'alg' => 'A128GCM', + 'k' => 'XctOhJAkA-pD9Lh7ZgW_2A', ]); $protected_headers = [ - "alg" => "dir", - "kid" => "77c7e2b8-6e13-45cf-8672-617b5b45243a", - "enc" => "A128GCM", + 'alg' => 'dir', + 'kid' => '77c7e2b8-6e13-45cf-8672-617b5b45243a', + 'enc' => 'A128GCM', ]; $expected_compact_json = 'eyJhbGciOiJkaXIiLCJraWQiOiI3N2M3ZTJiOC02ZTEzLTQ1Y2YtODY3Mi02MTdiNWI0NTI0M2EiLCJlbmMiOiJBMTI4R0NNIn0..refa467QzzKx6QAB.JW_i_f52hww_ELQPGaYyeAB6HYGcR559l9TYnSovc23XJoBcW29rHP8yZOZG7YhLpT1bjFuvZPjQS-m0IFtVcXkZXdH_lr_FrdYt9HRUYkshtrMmIUAyGmUnd9zMDB2n0cRDIHAzFVeJUDxkUwVAE7_YGRPdcqMyiBoCO-FBdE-Nceb4h3-FtBP-c_BIwCPTjb9o0SbdcdREEMJMyZBH8ySWMVi1gPD9yxi-aQpGbSv_F9N4IZAxscj5g-NJsUPbjk29-s7LJAGb15wEBtXphVCgyy53CoIKLHHeJHXex45Uz9aKZSRSInZI-wjsY0yu3cT4_aQ3i1o-tiE-F8Ios61EKgyIQ4CWao8PFMj8TTnp.vbb32Xvllea2OtmHAdccRQ'; @@ -64,13 +64,11 @@ public function testDirAndA128GCMEncryption() $this->assertEquals($expected_iv, Base64Url::encode($loaded_compact_json->getIV())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_compact_json->getTag())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_iv, Base64Url::encode($loaded_json->getIV())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_json->getTag())); - $this->assertEquals($expected_payload, $loaded_compact_json->getPayload()); $this->assertEquals($expected_payload, $loaded_json->getPayload()); } diff --git a/tests/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php b/tests/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php index e4b40525..38019f28 100644 --- a/tests/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php +++ b/tests/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php @@ -32,25 +32,25 @@ public function testECDH_ES_A128KWAndA128GCMEncryption() $expected_payload = "You can trust us to stick with you through thick and thin\xe2\x80\x93to the bitter end. And you can trust us to keep any secret of yours\xe2\x80\x93closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo."; $private_key = new JWK([ - "kty" => "EC", - "kid" => "peregrin.took@tuckborough.example", - "use" => "enc", - "crv" => "P-384", - "x" => "YU4rRUzdmVqmRtWOs2OpDE_T5fsNIodcG8G5FWPrTPMyxpzsSOGaQLpe2FpxBmu2", - "y" => "A8-yxCHxkfBz3hKZfI1jUYMjUhsEveZ9THuwFjH2sCNdtksRJU7D5-SkgaFL1ETP", - "d" => "iTx2pk7wW-GqJkHcEkFQb2EFyYcO7RugmaW3mRrQVAOUiPommT0IdnYK2xDlZh-j", + 'kty' => 'EC', + 'kid' => 'peregrin.took@tuckborough.example', + 'use' => 'enc', + 'crv' => 'P-384', + 'x' => 'YU4rRUzdmVqmRtWOs2OpDE_T5fsNIodcG8G5FWPrTPMyxpzsSOGaQLpe2FpxBmu2', + 'y' => 'A8-yxCHxkfBz3hKZfI1jUYMjUhsEveZ9THuwFjH2sCNdtksRJU7D5-SkgaFL1ETP', + 'd' => 'iTx2pk7wW-GqJkHcEkFQb2EFyYcO7RugmaW3mRrQVAOUiPommT0IdnYK2xDlZh-j', ]); $protected_headers = [ - "alg" =>"ECDH-ES+A128KW", - "kid" =>"peregrin.took@tuckborough.example", - "epk" =>[ - "kty" =>"EC", - "crv" =>"P-384", - "x" =>"uBo4kHPw6kbjx5l0xowrd_oYzBmaz-GKFZu4xAFFkbYiWgutEK6iuEDsQ6wNdNg3", - "y" =>"sp3p5SGhZVC2faXumI-e9JU2Mo8KpoYrFDr5yPNVtW4PgEwZOyQTA-JdaY8tb7E0" + 'alg' => 'ECDH-ES+A128KW', + 'kid' => 'peregrin.took@tuckborough.example', + 'epk' => [ + 'kty' => 'EC', + 'crv' => 'P-384', + 'x' => 'uBo4kHPw6kbjx5l0xowrd_oYzBmaz-GKFZu4xAFFkbYiWgutEK6iuEDsQ6wNdNg3', + 'y' => 'sp3p5SGhZVC2faXumI-e9JU2Mo8KpoYrFDr5yPNVtW4PgEwZOyQTA-JdaY8tb7E0', ], - "enc" =>"A128GCM", + 'enc' => 'A128GCM', ]; $expected_compact_json = 'eyJhbGciOiJFQ0RILUVTK0ExMjhLVyIsImtpZCI6InBlcmVncmluLnRvb2tAdHVja2Jvcm91Z2guZXhhbXBsZSIsImVwayI6eyJrdHkiOiJFQyIsImNydiI6IlAtMzg0IiwieCI6InVCbzRrSFB3Nmtiang1bDB4b3dyZF9vWXpCbWF6LUdLRlp1NHhBRkZrYllpV2d1dEVLNml1RURzUTZ3TmROZzMiLCJ5Ijoic3AzcDVTR2haVkMyZmFYdW1JLWU5SlUyTW84S3BvWXJGRHI1eVBOVnRXNFBnRXdaT3lRVEEtSmRhWTh0YjdFMCJ9LCJlbmMiOiJBMTI4R0NNIn0.0DJjBXri_kBcC46IkU5_Jk9BqaQeHdv2.mH-G2zVqgztUtnW_.tkZuOO9h95OgHJmkkrfLBisku8rGf6nzVxhRM3sVOhXgz5NJ76oID7lpnAi_cPWJRCjSpAaUZ5dOR3Spy7QuEkmKx8-3RCMhSYMzsXaEwDdXta9Mn5B7cCBoJKB0IgEnj_qfo1hIi-uEkUpOZ8aLTZGHfpl05jMwbKkTe2yK3mjF6SBAsgicQDVCkcY9BLluzx1RmC3ORXaM0JaHPB93YcdSDGgpgBWMVrNU1ErkjcMqMoT_wtCex3w03XdLkjXIuEr2hWgeP-nkUZTPU9EoGSPj6fAS-bSz87RCPrxZdj_iVyC6QWcqAu07WNhjzJEPc4jVntRJ6K53NgPQ5p99l3Z408OUqj4ioYezbS6vTPlQ.WuGzxmcreYjpHGJoa17EBg'; @@ -87,7 +87,6 @@ public function testECDH_ES_A128KWAndA128GCMEncryption() $this->assertEquals($expected_tag, Base64Url::encode($loaded_flattened_json->getTag())); $this->assertEquals($expected_cek, Base64Url::encode($loaded_flattened_json->getContentEncryptionKey())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_iv, Base64Url::encode($loaded_json->getIV())); @@ -95,7 +94,6 @@ public function testECDH_ES_A128KWAndA128GCMEncryption() $this->assertEquals($expected_tag, Base64Url::encode($loaded_json->getTag())); $this->assertEquals($expected_cek, Base64Url::encode($loaded_json->getContentEncryptionKey())); - $this->assertEquals($expected_payload, $loaded_compact_json->getPayload()); $this->assertEquals($expected_payload, $loaded_flattened_json->getPayload()); $this->assertEquals($expected_payload, $loaded_json->getPayload()); diff --git a/tests/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php b/tests/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php index 68e7b277..c1b4422a 100644 --- a/tests/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php +++ b/tests/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php @@ -32,25 +32,25 @@ public function testECDH_ES_AndA128CBC_HS256Encryption() $expected_payload = "You can trust us to stick with you through thick and thin\xe2\x80\x93to the bitter end. And you can trust us to keep any secret of yours\xe2\x80\x93closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo."; $private_key = new JWK([ - "kty" => "EC", - "kid" => "meriadoc.brandybuck@buckland.example", - "use" => "enc", - "crv" => "P-256", - "x" => "Ze2loSV3wrroKUN_4zhwGhCqo3Xhu1td4QjeQ5wIVR0", - "y" => "HlLtdXARY_f55A3fnzQbPcm6hgr34Mp8p-nuzQCE0Zw", - "d" => "r_kHyZ-a06rmxM3yESK84r1otSg-aQcVStkRhA-iCM8", + 'kty' => 'EC', + 'kid' => 'meriadoc.brandybuck@buckland.example', + 'use' => 'enc', + 'crv' => 'P-256', + 'x' => 'Ze2loSV3wrroKUN_4zhwGhCqo3Xhu1td4QjeQ5wIVR0', + 'y' => 'HlLtdXARY_f55A3fnzQbPcm6hgr34Mp8p-nuzQCE0Zw', + 'd' => 'r_kHyZ-a06rmxM3yESK84r1otSg-aQcVStkRhA-iCM8', ]); $protected_headers = [ - "alg" => "ECDH-ES", - "kid" => "meriadoc.brandybuck@buckland.example", - "epk" => [ - "kty" => "EC", - "crv" => "P-256", - "x" => "mPUKT_bAWGHIhg0TpjjqVsP1rXWQu_vwVOHHtNkdYoA", - "y" => "8BQAsImGeAS46fyWw5MhYfGTT0IjBpFw2SS34Dv4Irs", + 'alg' => 'ECDH-ES', + 'kid' => 'meriadoc.brandybuck@buckland.example', + 'epk' => [ + 'kty' => 'EC', + 'crv' => 'P-256', + 'x' => 'mPUKT_bAWGHIhg0TpjjqVsP1rXWQu_vwVOHHtNkdYoA', + 'y' => '8BQAsImGeAS46fyWw5MhYfGTT0IjBpFw2SS34Dv4Irs', ], - "enc" => "A128CBC-HS256", + 'enc' => 'A128CBC-HS256', ]; $expected_compact_json = 'eyJhbGciOiJFQ0RILUVTIiwia2lkIjoibWVyaWFkb2MuYnJhbmR5YnVja0BidWNrbGFuZC5leGFtcGxlIiwiZXBrIjp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoibVBVS1RfYkFXR0hJaGcwVHBqanFWc1AxclhXUXVfdndWT0hIdE5rZFlvQSIsInkiOiI4QlFBc0ltR2VBUzQ2ZnlXdzVNaFlmR1RUMElqQnBGdzJTUzM0RHY0SXJzIn0sImVuYyI6IkExMjhDQkMtSFMyNTYifQ..yc9N8v5sYyv3iGQT926IUg.BoDlwPnTypYq-ivjmQvAYJLb5Q6l-F3LIgQomlz87yW4OPKbWE1zSTEFjDfhU9IPIOSA9Bml4m7iDFwA-1ZXvHteLDtw4R1XRGMEsDIqAYtskTTmzmzNa-_q4F_evAPUmwlO-ZG45Mnq4uhM1fm_D9rBtWolqZSF3xGNNkpOMQKF1Cl8i8wjzRli7-IXgyirlKQsbhhqRzkv8IcY6aHl24j03C-AR2le1r7URUhArM79BY8soZU0lzwI-sD5PZ3l4NDCCei9XkoIAfsXJWmySPoeRb2Ni5UZL4mYpvKDiwmyzGd65KqVw7MsFfI_K767G9C9Azp73gKZD0DyUn1mn0WW5LmyX_yJ-3AROq8p1WZBfG-ZyJ6195_JGG2m9Csg.WCCkNa-x4BeB9hIDIfFuhg'; @@ -74,14 +74,12 @@ public function testECDH_ES_AndA128CBC_HS256Encryption() $this->assertEquals($expected_iv, Base64Url::encode($loaded_compact_json->getIV())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_compact_json->getTag())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_cek, Base64Url::encode($loaded_json->getContentEncryptionKey())); $this->assertEquals($expected_iv, Base64Url::encode($loaded_json->getIV())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_json->getTag())); - $this->assertEquals($expected_payload, $loaded_compact_json->getPayload()); $this->assertEquals($expected_payload, $loaded_json->getPayload()); } diff --git a/tests/RFC7520/MultipleRecipientEncryptionTest.php b/tests/RFC7520/MultipleRecipientEncryptionTest.php index 2d4cf6ac..18d4848e 100644 --- a/tests/RFC7520/MultipleRecipientEncryptionTest.php +++ b/tests/RFC7520/MultipleRecipientEncryptionTest.php @@ -32,65 +32,65 @@ public function testMultipleRecipientEncryption() $expected_payload = "You can trust us to stick with you through thick and thin\xe2\x80\x93to the bitter end. And you can trust us to keep any secret of yours\xe2\x80\x93closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo."; $recipient_1_private_key = new JWK([ - "kty" => "RSA", - "kid" => "frodo.baggins@hobbiton.example", - "use" => "enc", - "n" => "maxhbsmBtdQ3CNrKvprUE6n9lYcregDMLYNeTAWcLj8NnPU9XIYegTHVHQjxKDSHP2l-F5jS7sppG1w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WK([ - "kty" => "EC", - "kid" => "peregrin.took@tuckborough.example", - "use" => "enc", - "crv" => "P-384", - "x" => "YU4rRUzdmVqmRtWOs2OpDE_T5fsNIodcG8G5FWPrTPMyxpzsSOGaQLpe2FpxBmu2", - "y" => "A8-yxCHxkfBz3hKZfI1jUYMjUhsEveZ9THuwFjH2sCNdtksRJU7D5-SkgaFL1ETP", - "d" => "iTx2pk7wW-GqJkHcEkFQb2EFyYcO7RugmaW3mRrQVAOUiPommT0IdnYK2xDlZh-j", + 'kty' => 'EC', + 'kid' => 'peregrin.took@tuckborough.example', + 'use' => 'enc', + 'crv' => 'P-384', + 'x' => 'YU4rRUzdmVqmRtWOs2OpDE_T5fsNIodcG8G5FWPrTPMyxpzsSOGaQLpe2FpxBmu2', + 'y' => 'A8-yxCHxkfBz3hKZfI1jUYMjUhsEveZ9THuwFjH2sCNdtksRJU7D5-SkgaFL1ETP', + 'd' => 'iTx2pk7wW-GqJkHcEkFQb2EFyYcO7RugmaW3mRrQVAOUiPommT0IdnYK2xDlZh-j', ]); $recipient_3_private_key = new JWK([ - "kty" => "oct", - "kid" => "18ec08e1-bfa9-4d95-b205-2b4dd1d4321d", - "use" => "enc", - "alg" => "A256GCMKW", - "k" => "qC57l_uxcm7Nm3K-ct4GFjx8tM1U8CZ0NLBvdQstiS8", + 'kty' => 'oct', + 'kid' => '18ec08e1-bfa9-4d95-b205-2b4dd1d4321d', + 'use' => 'enc', + 'alg' => 'A256GCMKW', + 'k' => 'qC57l_uxcm7Nm3K-ct4GFjx8tM1U8CZ0NLBvdQstiS8', ]); $protected_headers = [ - "enc" => "A128CBC-HS256", + 'enc' => 'A128CBC-HS256', ]; $headers = [ - "cty" => "text/plain", + 'cty' => 'text/plain', ]; $recipient_1_headers = [ - "alg" => "RSA1_5", - "kid" => "frodo.baggins@hobbiton.example", + 'alg' => 'RSA1_5', + 'kid' => 'frodo.baggins@hobbiton.example', ]; $recipient_2_headers = [ - "alg" => "ECDH-ES+A256KW", - "kid" => "peregrin.took@tuckborough.example", - "epk" => [ - "kty" => "EC", - "crv" => "P-384", - "x" => "Uzdvk3pi5wKCRc1izp5_r0OjeqT-I68i8g2b8mva8diRhsE2xAn2DtMRb25Ma2CX", - "y" => "VDrRyFJh-Kwd1EjAgmj5Eo-CTHAZ53MC7PjjpLioy3ylEjI1pOMbw91fzZ84pbfm", - ]]; + 'alg' => 'ECDH-ES+A256KW', + 'kid' => 'peregrin.took@tuckborough.example', + 'epk' => [ + 'kty' => 'EC', + 'crv' => 'P-384', + 'x' => 'Uzdvk3pi5wKCRc1izp5_r0OjeqT-I68i8g2b8mva8diRhsE2xAn2DtMRb25Ma2CX', + 'y' => 'VDrRyFJh-Kwd1EjAgmj5Eo-CTHAZ53MC7PjjpLioy3ylEjI1pOMbw91fzZ84pbfm', + ], ]; $recipient_3_headers = [ - "alg" => "A256GCMKW", - "kid" => "18ec08e1-bfa9-4d95-b205-2b4dd1d4321d", - "tag" => "59Nqh1LlYtVIhfD3pgRGvw", - "iv" => "AvpeoPZ9Ncn9mkBn", + 'alg' => 'A256GCMKW', + 'kid' => '18ec08e1-bfa9-4d95-b205-2b4dd1d4321d', + 'tag' => '59Nqh1LlYtVIhfD3pgRGvw', + 'iv' => 'AvpeoPZ9Ncn9mkBn', ]; $expected_json = '{"recipients":[{"encrypted_key":"dYOD28kab0Vvf4ODgxVAJXgHcSZICSOp8M51zjwj4w6Y5G4XJQsNNIBiqyvUUAOcpL7S7-cFe7Pio7gV_Q06WmCSa-vhW6me4bWrBf7cHwEQJdXihidAYWVajJIaKMXMvFRMV6iDlRr076DFthg2_AV0_tSiV6xSEIFqt1xnYPpmP91tc5WJDOGb-wqjw0-b-S1laS11QVbuP78dQ7Fa0zAVzzjHX-xvyM2wxj_otxr9clN1LnZMbeYSrRicJK5xodvWgkpIdkMHo4LvdhRRvzoKzlic89jFWPlnBq_V4n5trGuExtp_-dbHcGlihqc_wGgho9fLMK8JOArYLcMDNQ","header":{"alg":"RSA1_5","kid":"frodo.baggins@hobbiton.example"}},{"encrypted_key":"ExInT0io9BqBMYF6-maw5tZlgoZXThD1zWKsHixJuw_elY4gSSId_w","header":{"alg":"ECDH-ES+A256KW","kid":"peregrin.took@tuckborough.example","epk":{"kty":"EC","crv":"P-384","x":"Uzdvk3pi5wKCRc1izp5_r0OjeqT-I68i8g2b8mva8diRhsE2xAn2DtMRb25Ma2CX","y":"VDrRyFJh-Kwd1EjAgmj5Eo-CTHAZ53MC7PjjpLioy3ylEjI1pOMbw91fzZ84pbfm"}}},{"encrypted_key":"a7CclAejo_7JSuPB8zeagxXRam8dwCfmkt9-WyTpS1E","header":{"alg":"A256GCMKW","kid":"18ec08e1-bfa9-4d95-b205-2b4dd1d4321d","tag":"59Nqh1LlYtVIhfD3pgRGvw","iv":"AvpeoPZ9Ncn9mkBn"}}],"unprotected":{"cty":"text/plain"},"protected":"eyJlbmMiOiJBMTI4Q0JDLUhTMjU2In0","iv":"VgEIHY20EnzUtZFl2RpB1g","ciphertext":"ajm2Q-OpPXCr7-MHXicknb1lsxLdXxK_yLds0KuhJzfWK04SjdxQeSw2L9mu3a_k1C55kCQ_3xlkcVKC5yr__Is48VOoK0k63_QRM9tBURMFqLByJ8vOYQX0oJW4VUHJLmGhF-tVQWB7Kz8mr8zeE7txF0MSaP6ga7-siYxStR7_G07Thd1jh-zGT0wxM5g-VRORtq0K6AXpLlwEqRp7pkt2zRM0ZAXqSpe1O6FJ7FHLDyEFnD-zDIZukLpCbzhzMDLLw2-8I14FQrgi-iEuzHgIJFIJn2wh9Tj0cg_kOZy9BqMRZbmYXMY9YQjorZ_P_JYG3ARAIF3OjDNqpdYe-K_5Q5crGJSDNyij_ygEiItR5jssQVH2ofDQdLChtazE","tag":"BESYyFN7T09KY7i8zKs5_g"}'; @@ -113,7 +113,6 @@ public function testMultipleRecipientEncryption() $loaded_json = Loader::load($expected_json); $this->assertEquals(2, $decrypter->decryptUsingKey($loaded_json, $recipient_3_private_key)); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_iv, Base64Url::encode($loaded_json->getIV())); @@ -127,7 +126,6 @@ public function testMultipleRecipientEncryption() $this->assertEquals($expected_tag, Base64Url::encode($loaded_json->getTag())); $this->assertEquals($expected_cek, Base64Url::encode($loaded_json->getContentEncryptionKey())); - $this->assertEquals($expected_payload, $loaded_json->getPayload()); } } diff --git a/tests/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php b/tests/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php index e2473fff..43aa258b 100644 --- a/tests/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php +++ b/tests/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php @@ -35,34 +35,34 @@ public function testPBES2_HS512_A256KWAndA128CBC_HS256Encryption() 'kid' => '77c7e2b8-6e13-45cf-8672-617b5b45243a', 'use' => 'enc', 'alg' => 'A128GCM', - 'k' => 'XctOhJAkA-pD9Lh7ZgW_2A', - ],[ + 'k' => 'XctOhJAkA-pD9Lh7ZgW_2A', + ], [ 'kty' => 'oct', 'kid' => '81b20965-8332-43d9-a468-82160ad91ac8', 'use' => 'enc', 'alg' => 'A128KW', - 'k' => 'GZy6sIZ6wl9NJOKB-jnmVQ', - ],[ + 'k' => 'GZy6sIZ6wl9NJOKB-jnmVQ', + ], [ 'kty' => 'oct', 'kid' => '18ec08e1-bfa9-4d95-b205-2b4dd1d4321d', 'use' => 'enc', 'alg' => 'A256GCMKW', - 'k' => 'qC57l_uxcm7Nm3K-ct4GFjx8tM1U8CZ0NLBvdQstiS8', + 'k' => 'qC57l_uxcm7Nm3K-ct4GFjx8tM1U8CZ0NLBvdQstiS8', ], ]]; $private_key = new JWK([ - "kty" => "oct", - "use" => "enc", - "k" => Base64Url::encode("entrap_o\xe2\x80\x93peter_long\xe2\x80\x93credit_tun"), + 'kty' => 'oct', + 'use' => 'enc', + 'k' => Base64Url::encode("entrap_o\xe2\x80\x93peter_long\xe2\x80\x93credit_tun"), ]); $protected_headers = [ - "alg" => "PBES2-HS512+A256KW", - "p2s" => "8Q1SzinasR3xchYz6ZZcHA", - "p2c" => 8192, - "cty" => "jwk-set+json", - "enc" => "A128CBC-HS256", + 'alg' => 'PBES2-HS512+A256KW', + 'p2s' => '8Q1SzinasR3xchYz6ZZcHA', + 'p2c' => 8192, + 'cty' => 'jwk-set+json', + 'enc' => 'A128CBC-HS256', ]; $expected_compact_json = 'eyJhbGciOiJQQkVTMi1IUzUxMitBMjU2S1ciLCJwMnMiOiI4UTFTemluYXNSM3hjaFl6NlpaY0hBIiwicDJjIjo4MTkyLCJjdHkiOiJqd2stc2V0K2pzb24iLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.d3qNhUWfqheyPp4H8sjOWsDYajoej4c5Je6rlUtFPWdgtURtmeDV1g.VBiCzVHNoLiR3F4V82uoTQ.23i-Tb1AV4n0WKVSSgcQrdg6GRqsUKxjruHXYsTHAJLZ2nsnGIX86vMXqIi6IRsfywCRFzLxEcZBRnTvG3nhzPk0GDD7FMyXhUHpDjEYCNA_XOmzg8yZR9oyjo6lTF6si4q9FZ2EhzgFQCLO_6h5EVg3vR75_hkBsnuoqoM3dwejXBtIodN84PeqMb6asmas_dpSsz7H10fC5ni9xIz424givB1YLldF6exVmL93R3fOoOJbmk2GBQZL_SEGllv2cQsBgeprARsaQ7Bq99tT80coH8ItBjgV08AtzXFFsx9qKvC982KLKdPQMTlVJKkqtV4Ru5LEVpBZXBnZrtViSOgyg6AiuwaS-rCrcD_ePOGSuxvgtrokAKYPqmXUeRdjFJwafkYEkiuDCV9vWGAi1DH2xTafhJwcmywIyzi4BqRpmdn_N-zl5tuJYyuvKhjKv6ihbsV_k1hJGPGAxJ6wUpmwC4PTQ2izEm0TuSE8oMKdTw8V3kobXZ77ulMwDs4p.0HlwodAhOCILG5SQ2LQ9dg'; @@ -99,7 +99,6 @@ public function testPBES2_HS512_A256KWAndA128CBC_HS256Encryption() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_flattened_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_flattened_json->getTag())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_cek, Base64Url::encode($loaded_json->getContentEncryptionKey())); @@ -107,7 +106,6 @@ public function testPBES2_HS512_A256KWAndA128CBC_HS256Encryption() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_json->getTag())); - $this->assertEquals($expected_payload, $loaded_compact_json->getPayload()); $this->assertEquals($expected_payload, $loaded_flattened_json->getPayload()); $this->assertEquals($expected_payload, $loaded_json->getPayload()); diff --git a/tests/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php b/tests/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php index 1017bb8c..6eb0e12c 100644 --- a/tests/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php +++ b/tests/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php @@ -32,23 +32,23 @@ public function testRSA1_5AndA128CBC_HS256Encryption() $expected_payload = "You can trust us to stick with you through thick and thin\xe2\x80\x93to the bitter end. And you can trust us to keep any secret of yours\xe2\x80\x93closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo."; $private_key = new JWK([ - "kty" => "RSA", - "kid" => "frodo.baggins@hobbiton.example", - "use" => "enc", - "n" => "maxhbsmBtdQ3CNrKvprUE6n9lYcregDMLYNeTAWcLj8NnPU9XIYegTHVHQjxKDSHP2l-F5jS7sppG1wgdAqZyhnWvXhYNvcM7RfgKxqNx_xAHx6f3yy7s-M9PSNCwPC2lh6UAkR4I00EhV9lrypM9Pi4l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Wfgnb1PNmiuPUxO8OpI9KDIfu_acc6fg14nsNaJqXe6RESvhGPH2afjHqSy_Fd2vpzj85bQQ', + 'p' => '2DwQmZ43FoTnQ8IkUj3BmKRf5Eh2mizZA5xEJ2MinUE3sdTYKSLtaEoekX9vbBZuWxHdVhM6UnKCJ_2iNk8Z0ayLYHL0_G21aXf9-unynEpUsH7HHTklLpYAzOOx1ZgVljoxAdWNn3hiEFrjZLZGS7lOH-a3QQlDDQoJOJ2VFmU', + 'q' => 'te8LY4-W7IyaqH1ExujjMqkTAlTeRbv0VLQnfLY2xINnrWdwiQ93_VF099aP1ESeLja2nw-6iKIe-qT7mtCPozKfVtUYfz5HrJ_XY2kfexJINb9lhZHMv5p1skZpeIS-GPHCC6gRlKo1q-idn_qxyusfWv7WAxlSVfQfk8d6Et0', + 'dp' => 'UfYKcL_or492vVc0PzwLSplbg4L3-Z5wL48mwiswbpzOyIgd2xHTHQmjJpFAIZ8q-zf9RmgJXkDrFs9rkdxPtAsL1WYdeCT5c125Fkdg317JVRDo1inX7x2Kdh8ERCreW8_4zXItuTl_KiXZNU5lvMQjWbIw2eTx1lpsflo0rYU', + 'dq' => 'iEgcO-QfpepdH8FWd7mUFyrXdnOkXJBCogChY6YKuIHGc_p8Le9MbpFKESzEaLlN1Ehf3B6oGBl5Iz_ayUlZj2IoQZ82znoUrpa9fVYNot87ACfzIG7q9Mv7RiPAderZi03tkVXAdaBau_9vs5rS-7HMtxkVrxSUvJY14TkXlHE', + 'qi' => 'kC-lzZOqoFaZCr5l0tOVtREKoVqaAYhQiqIRGL-MzS4sCmRkxm5vZlXYx6RtE1n_AagjqajlkjieGlxTTThHD8Iga6foGBMaAr5uR1hGQpSc7Gl7CF1DZkBJMTQN6EshYzZfxW08mIO8M6Rzuh0beL6fG9mkDcIyPrBXx2bQ_mM', ]); $protected_headers = [ - "alg" => "RSA1_5", - "kid" => "frodo.baggins@hobbiton.example", - "enc" => "A128CBC-HS256", + 'alg' => 'RSA1_5', + 'kid' => 'frodo.baggins@hobbiton.example', + 'enc' => 'A128CBC-HS256', ]; $expected_compact_json = 'eyJhbGciOiJSU0ExXzUiLCJraWQiOiJmcm9kby5iYWdnaW5zQGhvYmJpdG9uLmV4YW1wbGUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.laLxI0j-nLH-_BgLOXMozKxmy9gffy2gTdvqzfTihJBuuzxg0V7yk1WClnQePFvG2K-pvSlWc9BRIazDrn50RcRai__3TDON395H3c62tIouJJ4XaRvYHFjZTZ2GXfz8YAImcc91Tfk0WXC2F5Xbb71ClQ1DDH151tlpH77f2ff7xiSxh9oSewYrcGTSLUeeCt36r1Kt3OSj7EyBQXoZlN7IxbyhMAfgIe7Mv1rOTOI5I8NQqeXXW8VlzNmoxaGMny3YnGir5Wf6Qt2nBq4qDaPdnaAuuGUGEecelIO1wx1BpyIfgvfjOhMBs9M8XL223Fg47xlGsMXdfuY-4jaqVw.bbd5sTkYwhAIqfHsx8DayA.0fys_TY_na7f8dwSfXLiYdHaA2DxUjD67ieF7fcVbIR62JhJvGZ4_FNVSiGc_raa0HnLQ6s1P2sv3Xzl1p1l_o5wR_RsSzrS8Z-wnI3Jvo0mkpEEnlDmZvDu_k8OWzJv7eZVEqiWKdyVzFhPpiyQU28GLOpRc2VbVbK4dQKPdNTjPPEmRqcaGeTWZVyeSUvf5k59yJZxRuSvWFf6KrNtmRdZ8R4mDOjHSrM_s8uwIFcqt4r5GX8TKaI0zT5CbL5Qlw3sRc7u_hg0yKVOiRytEAEs3vZkcfLkP6nbXdC_PkMdNS-ohP78T2O6_7uInMGhFeX4ctHG7VelHGiT93JfWDEQi5_V9UN1rhXNrYu-0fVMkZAKX3VWi7lzA6BP430m.kvKuFBXHe5mQr4lqgobAUg'; @@ -85,7 +85,6 @@ public function testRSA1_5AndA128CBC_HS256Encryption() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_flattened_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_flattened_json->getTag())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_cek, Base64Url::encode($loaded_json->getContentEncryptionKey())); @@ -93,7 +92,6 @@ public function testRSA1_5AndA128CBC_HS256Encryption() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_json->getTag())); - $this->assertEquals($expected_payload, $loaded_compact_json->getPayload()); $this->assertEquals($expected_payload, $loaded_flattened_json->getPayload()); $this->assertEquals($expected_payload, $loaded_json->getPayload()); diff --git a/tests/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php b/tests/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php index 1e59475c..bf4a306d 100644 --- a/tests/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php +++ b/tests/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php @@ -32,24 +32,24 @@ public function testRSA_OAEPAndA256GCMEncryption() $expected_payload = "You can trust us to stick with you through thick and thin\xe2\x80\x93to the bitter end. And you can trust us to keep any secret of yours\xe2\x80\x93closer than you keep it yourself. But you cannot trust us to let you face trouble alone, and go off without a word. We are your friends, Frodo."; $private_key = new JWK([ - "kty" => "RSA", - "kid" => "samwise.gamgee@hobbiton.example", - "use" => "enc", - "n" => "wbdxI55VaanZXPY29Lg5hdmv2XhvqAhoxUkanfzf2-5zVUxa6prHRrI4pP1AhoqJRlZfYtWWd5mmHRG2pAHIlh0ySJ9wi0BioZBl1XP2e-C-FyXJGcTy0HdKQWlrfhTm42EW7Vv04r4gfao6uxjLGwfpGrZLarohiWCPnkNrg71S2CuNZSQBIPGjXfkmIy2tl_VWgGnL22GplyXj5YlBLdxXp3XeStsqo571utNfoUTU8E4qdzJ3U1DItoVkPGsMwlmmnJiwA7sXRItBCivR4M5qnZtdw-7v4WuR4779ubDuJ5nalMv2S66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o0XfHCGvfqHLYjCO557HYQf72O9kLMCfd_1VBEqeD-1jjwELKDjck8kOBl5UvohK1oDfSP1DleAy-cnmL29DqWmhgwM1ip0CCNmkmsmDSlqkUXDi6sAaZuntyukyflI-qSQ3C_BafPyFaKrt1fgdyEwYa08pESKwwWisy7KnmoUvaJ3SaHmohFS78TJ25cfc10wZ9hQNOrIChZlkiOdFCtxDqdmCqNacnhgE3bZQjGp3n83ODSz9zwJcSUvODlXBPc2AycH6Ci5yjbxt4Ppox_5pjm6xnQkiPgj01GpsUssMmBN7iHVsrE7N2iznBNCeOUIQ", - "qi" => "FZhClBMywVVjnuUud-05qd5CYU0dK79akAgy9oX6RX6I3IIIPckCciRrokxglZn-omAY5CnCe4KdrnjFOT5YUZE7G_Pg44XgCXaarLQf4hl80oPEf6-jJ5Iy6wPRx7G2e8qLxnh9cOdf-kRqgOS3F48Ucvw3ma5V6KGMwQqWFeV31XtZ8l5cVI-I3NzBS7qltpUVgz2Ju021eyc7IlqgzR98qKONl27DuEES0aK0WE97jnsyO27Yp88Wa2RiBrEocM89QZI1seJiGDizHRUP4UZxw9zsXww46wy0P6f9grnYp7t8LkyDDk8eoI4KX6SNMNVcyVS9IWjlq8EzqZEKIA", + 'kty' => 'RSA', + 'kid' => 'samwise.gamgee@hobbiton.example', + 'use' => 'enc', + 'n' => 'wbdxI55VaanZXPY29Lg5hdmv2XhvqAhoxUkanfzf2-5zVUxa6prHRrI4pP1AhoqJRlZfYtWWd5mmHRG2pAHIlh0ySJ9wi0BioZBl1XP2e-C-FyXJGcTy0HdKQWlrfhTm42EW7Vv04r4gfao6uxjLGwfpGrZLarohiWCPnkNrg71S2CuNZSQBIPGjXfkmIy2tl_VWgGnL22GplyXj5YlBLdxXp3XeStsqo571utNfoUTU8E4qdzJ3U1DItoVkPGsMwlmmnJiwA7sXRItBCivR4M5qnZtdw-7v4WuR4779ubDuJ5nalMv2S66-RPcnFAzWSKxtBDnFJJDGIUe7Tzizjg1nms0Xq_yPub_UOl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EqeD-1jjwELKDjck8kOBl5UvohK1oDfSP1DleAy-cnmL29DqWmhgwM1ip0CCNmkmsmDSlqkUXDi6sAaZuntyukyflI-qSQ3C_BafPyFaKrt1fgdyEwYa08pESKwwWisy7KnmoUvaJ3SaHmohFS78TJ25cfc10wZ9hQNOrIChZlkiOdFCtxDqdmCqNacnhgE3bZQjGp3n83ODSz9zwJcSUvODlXBPc2AycH6Ci5yjbxt4Ppox_5pjm6xnQkiPgj01GpsUssMmBN7iHVsrE7N2iznBNCeOUIQ', + 'qi' => 'FZhClBMywVVjnuUud-05qd5CYU0dK79akAgy9oX6RX6I3IIIPckCciRrokxglZn-omAY5CnCe4KdrnjFOT5YUZE7G_Pg44XgCXaarLQf4hl80oPEf6-jJ5Iy6wPRx7G2e8qLxnh9cOdf-kRqgOS3F48Ucvw3ma5V6KGMwQqWFeV31XtZ8l5cVI-I3NzBS7qltpUVgz2Ju021eyc7IlqgzR98qKONl27DuEES0aK0WE97jnsyO27Yp88Wa2RiBrEocM89QZI1seJiGDizHRUP4UZxw9zsXww46wy0P6f9grnYp7t8LkyDDk8eoI4KX6SNMNVcyVS9IWjlq8EzqZEKIA', ]); $protected_headers = [ - "alg" => "RSA-OAEP", - "kid" => "samwise.gamgee@hobbiton.example", - "enc" => "A256GCM", + 'alg' => 'RSA-OAEP', + 'kid' => 'samwise.gamgee@hobbiton.example', + 'enc' => 'A256GCM', ]; $expected_compact_json = 'eyJhbGciOiJSU0EtT0FFUCIsImtpZCI6InNhbXdpc2UuZ2FtZ2VlQGhvYmJpdG9uLmV4YW1wbGUiLCJlbmMiOiJBMjU2R0NNIn0.rT99rwrBTbTI7IJM8fU3Eli7226HEB7IchCxNuh7lCiud48LxeolRdtFF4nzQibeYOl5S_PJsAXZwSXtDePz9hk-BbtsTBqC2UsPOdwjC9NhNupNNu9uHIVftDyucvI6hvALeZ6OGnhNV4v1zx2k7O1D89mAzfw-_kT3tkuorpDU-CpBENfIHX1Q58-Aad3FzMuo3Fn9buEP2yXakLXYa15BUXQsupM4A1GD4_H4Bd7V3u9h8Gkg8BpxKdUV9ScfJQTcYm6eJEBz3aSwIaK4T3-dwWpuBOhROQXBosJzS1asnuHtVMt2pKIIfux5BC6huIvmY7kzV7W7aIUrpYm_3H4zYvyMeq5pGqFmW2k8zpO878TRlZx7pZfPYDSXZyS0CfKKkMozT_qiCwZTSz4duYnt8hS4Z9sGthXn9uDqd6wycMagnQfOTs_lycTWmY-aqWVDKhjYNRf03NiwRtb5BE-tOdFwCASQj3uuAgPGrO2AWBe38UjQb0lvXn1SpyvYZ3WFc7WOJYaTa7A8DRn6MC6T-xDmMuxC0G7S2rscw5lQQU06MvZTlFOt0UvfuKBa03cxA_nIBIhLMjY2kOTxQMmpDPTr6Cbo8aKaOnx6ASE5Jx9paBpnNmOOKH35j_QlrQhDWUN6A2Gg8iFayJ69xDEdHAVCGRzN3woEI2ozDRs.-nBoKLH0YkLZPSI9.o4k2cnGN8rSSw3IDo1YuySkqeS_t2m1GXklSgqBdpACm6UJuJowOHC5ytjqYgRL-I-soPlwqMUf4UgRWWeaOGNw6vGW-xyM01lTYxrXfVzIIaRdhYtEMRBvBWbEwP7ua1DRfvaOjgZv6Ifa3brcAM64d8p5lhhNcizPersuhw5f-pGYzseva-TUaL8iWnctc-sSwy7SQmRkfhDjwbz0fz6kFovEgj64X1I5s7E6GLp5fnbYGLa1QUiML7Cc2GxgvI7zqWo0YIEc7aCflLG1-8BboVWFdZKLK9vNoycrYHumwzKluLWEbSVmaPpOslY2n525DxDfWaVFUfKQxMF56vn4B9QMpWAbnypNimbM8zVOw.UCGiqJxhBI3IFVdPalHHvA'; @@ -86,7 +86,6 @@ public function testRSA_OAEPAndA256GCMEncryption() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_flattened_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_flattened_json->getTag())); - $this->assertEquals($expected_ciphertext, Base64Url::encode($loaded_json->getCiphertext())); $this->assertEquals($protected_headers, $loaded_json->getSharedProtectedHeaders()); $this->assertEquals($expected_cek, Base64Url::encode($loaded_json->getContentEncryptionKey())); @@ -94,7 +93,6 @@ public function testRSA_OAEPAndA256GCMEncryption() $this->assertEquals($expected_encrypted_key, Base64Url::encode($loaded_json->getRecipient(0)->getEncryptedKey())); $this->assertEquals($expected_tag, Base64Url::encode($loaded_json->getTag())); - $this->assertEquals($expected_payload, $loaded_compact_json->getPayload()); $this->assertEquals($expected_payload, $loaded_flattened_json->getPayload()); $this->assertEquals($expected_payload, $loaded_json->getPayload()); diff --git a/tests/Unit/Objects/ConcatKDFTest.php b/tests/Unit/Objects/ConcatKDFTest.php index 5b634d3b..dd19a1a0 100644 --- a/tests/Unit/Objects/ConcatKDFTest.php +++ b/tests/Unit/Objects/ConcatKDFTest.php @@ -28,32 +28,32 @@ class ConcatKDFTest extends \PHPUnit_Framework_TestCase public function testConcatKDF() { $alice_key = new JWK([ - "kty" => "EC", - "crv" => "P-256", - "x" => "gI0GAILBdu7T53akrFmMyGcsF3n5dO7MmwNBHKW5SV0", - "y" => "SLW_xSffzlPWrHEVI30DHM_4egVwt3NQqeUD7nMFpps", - "d" => "0_NxaRPUMQoAJt50Gz8YiTr8gRTwyEaCumd-MToTmIo", + 'kty' => 'EC', + 'crv' => 'P-256', + 'x' => 'gI0GAILBdu7T53akrFmMyGcsF3n5dO7MmwNBHKW5SV0', + 'y' => 'SLW_xSffzlPWrHEVI30DHM_4egVwt3NQqeUD7nMFpps', + 'd' => '0_NxaRPUMQoAJt50Gz8YiTr8gRTwyEaCumd-MToTmIo', ]); $bob_key = new JWK([ - "kty" => "EC", - "crv" => "P-256", - "x" => "weNJy2HscCSM6AEDTDg04biOvhFhyyWvOHQfeF_PxMQ", - "y" => "e8lnCO-AlStT-NJVX-crhB7QRYhiix03illJOVAOyck", - "d" => "VEmDZpDXXK8p8N0Cndsxs924q6nS1RXFASRl6BfUqdw", + 'kty' => 'EC', + 'crv' => 'P-256', + 'x' => 'weNJy2HscCSM6AEDTDg04biOvhFhyyWvOHQfeF_PxMQ', + 'y' => 'e8lnCO-AlStT-NJVX-crhB7QRYhiix03illJOVAOyck', + 'd' => 'VEmDZpDXXK8p8N0Cndsxs924q6nS1RXFASRl6BfUqdw', ]); $expected_ephemeral_key = ['epk' => [ - "kty" => "EC", - "crv" => "P-256", - "x" => "gI0GAILBdu7T53akrFmMyGcsF3n5dO7MmwNBHKW5SV0", - "y" => "SLW_xSffzlPWrHEVI30DHM_4egVwt3NQqeUD7nMFpps", + 'kty' => 'EC', + 'crv' => 'P-256', + 'x' => 'gI0GAILBdu7T53akrFmMyGcsF3n5dO7MmwNBHKW5SV0', + 'y' => 'SLW_xSffzlPWrHEVI30DHM_4egVwt3NQqeUD7nMFpps', ]]; $complete_header = [ - "alg" => "ECDH-ES", - "enc" => "A128GCM", - "apu" => "QWxpY2U", - "apv" => "Qm9i", + 'alg' => 'ECDH-ES', + 'enc' => 'A128GCM', + 'apu' => 'QWxpY2U', + 'apv' => 'Qm9i', ]; $additional_header = []; @@ -82,7 +82,6 @@ public function testConcatKDF() $this->assertEquals($expected_kdf, Base64Url::encode($agreement_key)); $this->assertEquals($expected_kdf, Base64Url::encode($kdf)); $this->assertEquals($expected_ephemeral_key, $additional_header); - } /**