diff --git a/src/Algorithm/ContentEncryption/AESGCM.php b/src/Algorithm/ContentEncryption/AESGCM.php index 522a995b..8e0b12a5 100644 --- a/src/Algorithm/ContentEncryption/AESGCM.php +++ b/src/Algorithm/ContentEncryption/AESGCM.php @@ -12,7 +12,6 @@ namespace Jose\Algorithm\ContentEncryption; use AESGCM\AESGCM as GCM; -use Crypto\Cipher; use Jose\Algorithm\ContentEncryptionAlgorithmInterface; abstract class AESGCM implements ContentEncryptionAlgorithmInterface @@ -42,31 +41,9 @@ public function decryptContent($data, $cek, $iv, $aad, $encoded_protected_header $calculated_aad .= '.'.$aad; } - if (version_compare(PHP_VERSION, '7.1.0') >= 0) { - return openssl_decrypt($data, $this->getMode($cek), $cek, OPENSSL_RAW_DATA, $iv, $tag, $calculated_aad); - } elseif (class_exists('\Crypto\Cipher')) { - $cipher = Cipher::aes(Cipher::MODE_GCM, $this->getKeySize()); - $cipher->setTag($tag); - $cipher->setAAD($calculated_aad); - - $plaintext = $cipher->decrypt($data, $cek, $iv); - - return $plaintext; - } - return GCM::decrypt($cek, $iv, $data, $calculated_aad, $tag); } - /** - * @param string $k - * - * @return string - */ - private function getMode($k) - { - return 'aes-'.(8 * mb_strlen($k, '8bit')).'-gcm'; - } - /** * @return int */ diff --git a/src/Algorithm/KeyEncryption/AESGCMKW.php b/src/Algorithm/KeyEncryption/AESGCMKW.php index 623efbc3..d5172d41 100644 --- a/src/Algorithm/KeyEncryption/AESGCMKW.php +++ b/src/Algorithm/KeyEncryption/AESGCMKW.php @@ -14,7 +14,6 @@ use AESGCM\AESGCM; use Assert\Assertion; use Base64Url\Base64Url; -use Crypto\Cipher; use Jose\Object\JWKInterface; /** @@ -50,31 +49,9 @@ public function unwrapKey(JWKInterface $key, $encrypted_cek, array $header) $tag = Base64Url::decode($header['tag']); $iv = Base64Url::decode($header['iv']); - if (version_compare(PHP_VERSION, '7.1.0') >= 0) { - return openssl_decrypt($encrypted_cek, $this->getMode($kek), $kek, OPENSSL_RAW_DATA, $iv, $tag, null); - } elseif (class_exists('\Crypto\Cipher')) { - $cipher = Cipher::aes(Cipher::MODE_GCM, $this->getKeySize()); - $cipher->setTag($tag); - $cipher->setAAD(null); - - $cek = $cipher->decrypt($encrypted_cek, $kek, $iv); - - return $cek; - } - return AESGCM::decrypt($kek, $iv, $encrypted_cek, null, $tag); } - /** - * @param string $k - * - * @return string - */ - private function getMode($k) - { - return 'aes-'.(8 * mb_strlen($k, '8bit')).'-gcm'; - } - /** * {@inheritdoc} */ diff --git a/src/Loader.php b/src/Loader.php index a61802f7..5bb6b31f 100644 --- a/src/Loader.php +++ b/src/Loader.php @@ -174,7 +174,6 @@ private function fromFlattenedSerializationRecipientToSerialization($input) } } - return $recipients; } @@ -200,7 +199,6 @@ private function fromFlattenedSerializationSignatureToSerialization($input) } $temp['signatures'] = [$signature]; - return $temp; } @@ -243,7 +241,6 @@ private function fromCompactSerializationRecipientToSerialization(array $parts) } } - return $recipients; } @@ -264,7 +261,6 @@ private function fromCompactSerializationSignatureToSerialization(array $parts) 'signature' => $parts[2], ]]; - return $temp; } } diff --git a/src/Signer.php b/src/Signer.php index 37e46679..66933d23 100644 --- a/src/Signer.php +++ b/src/Signer.php @@ -74,7 +74,6 @@ private function computeSignature(Object\JWSInterface $jws, Object\SignatureInte $input ); - $signature = Object\Signature::createSignatureFromLoadedData( $value, $signature->getEncodedProtectedHeaders(), diff --git a/tests/Unit/Objects/PublicJWKSetTest.php b/tests/Unit/Objects/PublicJWKSetTest.php index 02574140..50c0275f 100644 --- a/tests/Unit/Objects/PublicJWKSetTest.php +++ b/tests/Unit/Objects/PublicJWKSetTest.php @@ -83,7 +83,6 @@ public function testWithMultipleKeySets() $public_jwkset->removeKey(0); $this->assertEquals(7, $public_jwkset->countKeys()); - $this->assertEquals(7, count($public_jwkset->toPEM())); foreach ($public_jwkset as $key) {