Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/Spomky-Labs/jose
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Morselli committed Aug 4, 2016
2 parents 460a3b8 + 91fff0f commit 206233c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/Algorithm/Signature/RSA.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Behaviour/EncrypterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
1 change: 0 additions & 1 deletion src/KeyConverter/RSAKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ final class RSAKey extends Sequence
*/
private $coefficient = null;


/**
* @param \Jose\Object\JWKInterface|string|array $data
*/
Expand Down
12 changes: 6 additions & 6 deletions src/Util/RSA.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
*/
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions tests/RFC7520/NestingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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' => '[email protected]',
'use' => 'enc',
'n' => 'wbdxI55VaanZXPY29Lg5hdmv2XhvqAhoxUkanfzf2-5zVUxa6prHRrI4pP1AhoqJRlZfYtWWd5mmHRG2pAHIlh0ySJ9wi0BioZBl1XP2e-C-FyXJGcTy0HdKQWlrfhTm42EW7Vv04r4gfao6uxjLGwfpGrZLarohiWCPnkNrg71S2CuNZSQBIPGjXfkmIy2tl_VWgGnL22GplyXj5YlBLdxXp3XeStsqo571utNfoUTU8E4qdzJ3U1DItoVkPGsMwlmmnJiwA7sXRItBCivR4M5qnZtdw-7v4WuR4779ubDuJ5nalMv2S66-RPcnFAzWSKxtBDnFJJDGIUe7Tzizjg1nms0Xq_yPub_UOlWn0ec85FCft1hACpWG8schrOBeNqHBODFskYpUc2LC5JA2TaPF2dA67dg1TTsC_FupfQ2kNGcE1LgprxKHcVWYQb86B-HozjHZcqtauBzFNV5tbTuB-TpkcvJfNcFLlH3b8mb-H_ox35FjqBSAjLKyoeqfKTpVjvXhd09knwgJf6VKq6UC418_TOljMVfFTWXUxlnfhOOnzW6HSSzD1c9WrCuVzsUMv54szidQ9wf1cYWf3g5qFDxDQKis99gcDaiCAwM3yEBIzuNeeCa5dartHDb1xEB_HcHSeYbghbMjGfasvKn0aZRsnTyC0xhWBlsolZE',
Expand Down

0 comments on commit 206233c

Please sign in to comment.