From 91fff0f17d4ecdd25f179a613d42a385c93483f5 Mon Sep 17 00:00:00 2001 From: Spomky Date: Thu, 4 Aug 2016 17:56:48 +0200 Subject: [PATCH] Applied fixes from StyleCI (#117) --- src/Algorithm/Signature/RSA.php | 2 -- src/Behaviour/EncrypterTrait.php | 1 + src/KeyConverter/RSAKey.php | 1 - src/Util/RSA.php | 12 ++++++------ tests/RFC7520/NestingTest.php | 6 +++--- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Algorithm/Signature/RSA.php b/src/Algorithm/Signature/RSA.php index 4805c2d2..2a1c970d 100644 --- a/src/Algorithm/Signature/RSA.php +++ b/src/Algorithm/Signature/RSA.php @@ -52,10 +52,8 @@ public function verify(JWKInterface $key, $input, $signature) $pub = RSAKey::toPublic(new RSAKey($key)); if ($this->getSignatureMethod() === self::SIGNATURE_PSS) { - return JoseRSA::verify($pub, $input, $signature, $this->getAlgorithm()); } else { - return 1 === openssl_verify($input, $signature, $pub->toPEM(), $this->getAlgorithm()); } } diff --git a/src/Behaviour/EncrypterTrait.php b/src/Behaviour/EncrypterTrait.php index a0c042fb..59f80296 100644 --- a/src/Behaviour/EncrypterTrait.php +++ b/src/Behaviour/EncrypterTrait.php @@ -34,6 +34,7 @@ abstract protected function checkKeyUsage(Object\JWKInterface $key, $usage); * @param string $algorithm */ abstract protected function checkKeyAlgorithm(Object\JWKInterface $key, $algorithm); + /** * @return \Jose\Algorithm\JWAManagerInterface */ diff --git a/src/KeyConverter/RSAKey.php b/src/KeyConverter/RSAKey.php index 1b83c2b2..07428af3 100644 --- a/src/KeyConverter/RSAKey.php +++ b/src/KeyConverter/RSAKey.php @@ -64,7 +64,6 @@ final class RSAKey extends Sequence */ private $coefficient = null; - /** * @param \Jose\Object\JWKInterface|string|array $data */ diff --git a/src/Util/RSA.php b/src/Util/RSA.php index 0ac97a50..7cb89f25 100644 --- a/src/Util/RSA.php +++ b/src/Util/RSA.php @@ -238,7 +238,7 @@ private static function encodeEMSAPSS($m, $emBits, Hash $hash) $emLen = ($emBits + 1) >> 3; $sLen = $hash->getLength(); $mHash = $hash->hash($m); - Assertion::greaterThan($emLen , $hash->getLength() + $sLen + 2); + Assertion::greaterThan($emLen, $hash->getLength() + $sLen + 2); $salt = random_bytes($sLen); $m2 = "\0\0\0\0\0\0\0\0".$mHash.$salt; $h = $hash->hash($m2); @@ -255,10 +255,10 @@ private static function encodeEMSAPSS($m, $emBits, Hash $hash) /** * EMSA-PSS-VERIFY. * - * @param string $m - * @param string $em - * @param int $emBits - * @param \Jose\Util\Hash $hash + * @param string $m + * @param string $em + * @param int $emBits + * @param \Jose\Util\Hash $hash * * @return string */ @@ -298,7 +298,7 @@ private static function verifyEMSAPSS($m, $em, $emBits, Hash $hash) public static function encrypt(RSAKey $key, $plaintext, $hash_algorithm) { /** - * @var $hash Hash + * @var Hash */ $hash = Hash::$hash_algorithm(); $length = $key->getModulusLength() - 2 * $hash->getLength() - 2; diff --git a/tests/RFC7520/NestingTest.php b/tests/RFC7520/NestingTest.php index 8a4e5ca1..e04d4068 100644 --- a/tests/RFC7520/NestingTest.php +++ b/tests/RFC7520/NestingTest.php @@ -28,11 +28,11 @@ public function testSignatureVerification() $payload = [ 'iss' => 'hobbiton.example', 'exp' => 1300819380, - 'http://example.com/is_root' => true + 'http://example.com/is_root' => true, ]; $signature_key = new JWK([ - 'kty' =>'RSA', + 'kty' => 'RSA', 'kid' => 'hobbiton.example', 'use' => 'sig', 'n' => 'kNrPIBDXMU6fcyv5i-QHQAQ-K8gsC3HJb7FYhYaw8hXbNJa-t8q0lDKwLZgQXYV-ffWxXJv5GGrlZE4GU52lfMEegTDzYTrRQ3tepgKFjMGg6Iy6fkl1ZNsx2gEonsnlShfzA9GJwRTmtKPbk1s-hwx1IU5AT-AIelNqBgcF2vE5W25_SGGBoaROVdUYxqETDggM1z5cKV4ZjDZ8-lh4oVB07bkac6LQdHpJUUySH_Er20DXx30Kyi97PciXKTS-QKXnmm8ivyRCmux22ZoPUind2BKC5OiG4MwALhaL2Z2k8CsRdfy-7dg7z41Rp6D0ZeEvtaUp4bX4aKraL4rTfw', @@ -69,7 +69,7 @@ public function testDecryption() $payload = 'eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJob2JiaXRvbi5leGFtcGxlIiwiZXhwIjoxMzAwODE5MzgwLCJodHRwOi8vZXhhbXBsZS5jb20vaXNfcm9vdCI6dHJ1ZX0.dPpMqwRZxFYi1UfcDAaf8M99o7kwUWtiXZ-ByvVuJih4MhJ_aZqciprz0OWaIAkIvn1qskChirjKvY9ESZNUCP4JjvfyPS-nqjJxYoA5ztWOyFk2cZNIPXjcJXSQwXPO9tEe-v4VSqgD0aKHqPxYog4N6Cz1lKph1U1sYDSI67_bLL7elg_vkjfMp5_W5l5LuUYGMeh6hxQIaIUXf9EwV2JmvTMuZ-vBOWy0Sniy1EFo72CRTvmtrIf5AROo5MNliY3KtUxeP-SOmD-LEYwW9SlkohYzMVAZDDOrVbv7KVRHpeYNaK75KEQqdCEEkS_rskZS-Qtt_nlegTWh1mEYaA'; $encryption_key = new JWK([ - 'kty' =>'RSA', + 'kty' => 'RSA', 'kid' => 'samwise.gamgee@hobbiton.example', 'use' => 'enc', 'n' => 'wbdxI55VaanZXPY29Lg5hdmv2XhvqAhoxUkanfzf2-5zVUxa6prHRrI4pP1AhoqJRlZfYtWWd5mmHRG2pAHIlh0ySJ9wi0BioZBl1XP2e-C-FyXJGcTy0HdKQWlrfhTm42EW7Vv04r4gfao6uxjLGwfpGrZLarohiWCPnkNrg71S2CuNZSQBIPGjXfkmIy2tl_VWgGnL22GplyXj5YlBLdxXp3XeStsqo571utNfoUTU8E4qdzJ3U1DItoVkPGsMwlmmnJiwA7sXRItBCivR4M5qnZtdw-7v4WuR4779ubDuJ5nalMv2S66-RPcnFAzWSKxtBDnFJJDGIUe7Tzizjg1nms0Xq_yPub_UOlWn0ec85FCft1hACpWG8schrOBeNqHBODFskYpUc2LC5JA2TaPF2dA67dg1TTsC_FupfQ2kNGcE1LgprxKHcVWYQb86B-HozjHZcqtauBzFNV5tbTuB-TpkcvJfNcFLlH3b8mb-H_ox35FjqBSAjLKyoeqfKTpVjvXhd09knwgJf6VKq6UC418_TOljMVfFTWXUxlnfhOOnzW6HSSzD1c9WrCuVzsUMv54szidQ9wf1cYWf3g5qFDxDQKis99gcDaiCAwM3yEBIzuNeeCa5dartHDb1xEB_HcHSeYbghbMjGfasvKn0aZRsnTyC0xhWBlsolZE',