GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( c4f121...b9594d )
by Joni
05:22
created
lib/JWX/JWK/Parameter/OtherPrimesInfoParameter.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@
 block discarded – undo
12 12
  */
13 13
 class OtherPrimesInfoParameter extends JWKParameter
14 14
 {
15
-    use ArrayParameterValue;
15
+	use ArrayParameterValue;
16 16
     
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param array[] ...$primes
21
-     */
22
-    public function __construct(...$primes)
23
-    {
24
-        parent::__construct(self::PARAM_OTHER_PRIMES_INFO, $primes);
25
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param array[] ...$primes
21
+	 */
22
+	public function __construct(...$primes)
23
+	{
24
+		parent::__construct(self::PARAM_OTHER_PRIMES_INFO, $primes);
25
+	}
26 26
 }
Please login to merge, or discard this patch.
lib/JWX/JWT/Claim/ExpirationTimeClaim.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@
 block discarded – undo
13 13
  */
14 14
 class ExpirationTimeClaim extends RegisteredClaim
15 15
 {
16
-    use NumericDateClaim;
17
-    use ReferenceTimeValidation;
16
+	use NumericDateClaim;
17
+	use ReferenceTimeValidation;
18 18
     
19
-    /**
20
-     * Constructor.
21
-     *
22
-     * @param int $exp_time Expiration time
23
-     */
24
-    public function __construct($exp_time)
25
-    {
26
-        // validate that claim is after the constraint (reference time)
27
-        parent::__construct(self::NAME_EXPIRATION_TIME, intval($exp_time),
28
-            new GreaterValidator());
29
-    }
19
+	/**
20
+	 * Constructor.
21
+	 *
22
+	 * @param int $exp_time Expiration time
23
+	 */
24
+	public function __construct($exp_time)
25
+	{
26
+		// validate that claim is after the constraint (reference time)
27
+		parent::__construct(self::NAME_EXPIRATION_TIME, intval($exp_time),
28
+			new GreaterValidator());
29
+	}
30 30
 }
Please login to merge, or discard this patch.
lib/JWX/JWT/Claim/RegisteredClaim.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -9,85 +9,85 @@
 block discarded – undo
9 9
  */
10 10
 abstract class RegisteredClaim extends Claim
11 11
 {
12
-    // JWT claims
13
-    const NAME_ISSUER = "iss";
14
-    const NAME_SUBJECT = "sub";
15
-    const NAME_AUDIENCE = "aud";
16
-    const NAME_EXPIRATION_TIME = "exp";
17
-    const NAME_NOT_BEFORE = "nbf";
18
-    const NAME_ISSUED_AT = "iat";
19
-    const NAME_JWT_ID = "jti";
12
+	// JWT claims
13
+	const NAME_ISSUER = "iss";
14
+	const NAME_SUBJECT = "sub";
15
+	const NAME_AUDIENCE = "aud";
16
+	const NAME_EXPIRATION_TIME = "exp";
17
+	const NAME_NOT_BEFORE = "nbf";
18
+	const NAME_ISSUED_AT = "iat";
19
+	const NAME_JWT_ID = "jti";
20 20
     
21
-    // OpenID claims
22
-    const NAME_FULL_NAME = "name";
23
-    const NAME_GIVEN_NAME = "given_name";
24
-    const NAME_FAMILY_NAME = "family_name";
25
-    const NAME_MIDDLE_NAME = "middle_name";
26
-    const NAME_NICKNAME = "nickname";
27
-    const NAME_PREFERRED_USERNAME = "preferred_username";
28
-    const NAME_PROFILE_URL = "profile";
29
-    const NAME_PICTURE_URL = "picture";
30
-    const NAME_WEBSITE_URL = "website";
31
-    const NAME_EMAIL = "email";
32
-    const NAME_EMAIL_VERIFIED = "email_verified";
33
-    const NAME_GENDER = "gender";
34
-    const NAME_BIRTHDATE = "birthdate";
35
-    const NAME_TIMEZONE = "zoneinfo";
36
-    const NAME_LOCALE = "locale";
37
-    const NAME_PHONE_NUMBER = "phone_number";
38
-    const NAME_PHONE_NUMBER_VERIFIED = "phone_number_verified";
39
-    const NAME_ADDRESS = "address";
40
-    const NAME_UPDATED_AT = "updated_at";
41
-    const NAME_AUTHORIZED_PARTY = "azp";
42
-    const NAME_NONCE = "nonce";
43
-    const NAME_AUTH_TIME = "auth_time";
44
-    const NAME_ACCESS_TOKEN_HASH = "at_hash";
45
-    const NAME_CODE_HASH = "c_hash";
46
-    const NAME_ACR = "acr";
47
-    const NAME_AMR = "amr";
48
-    const NAME_SUB_JWK = "sub_jwk";
21
+	// OpenID claims
22
+	const NAME_FULL_NAME = "name";
23
+	const NAME_GIVEN_NAME = "given_name";
24
+	const NAME_FAMILY_NAME = "family_name";
25
+	const NAME_MIDDLE_NAME = "middle_name";
26
+	const NAME_NICKNAME = "nickname";
27
+	const NAME_PREFERRED_USERNAME = "preferred_username";
28
+	const NAME_PROFILE_URL = "profile";
29
+	const NAME_PICTURE_URL = "picture";
30
+	const NAME_WEBSITE_URL = "website";
31
+	const NAME_EMAIL = "email";
32
+	const NAME_EMAIL_VERIFIED = "email_verified";
33
+	const NAME_GENDER = "gender";
34
+	const NAME_BIRTHDATE = "birthdate";
35
+	const NAME_TIMEZONE = "zoneinfo";
36
+	const NAME_LOCALE = "locale";
37
+	const NAME_PHONE_NUMBER = "phone_number";
38
+	const NAME_PHONE_NUMBER_VERIFIED = "phone_number_verified";
39
+	const NAME_ADDRESS = "address";
40
+	const NAME_UPDATED_AT = "updated_at";
41
+	const NAME_AUTHORIZED_PARTY = "azp";
42
+	const NAME_NONCE = "nonce";
43
+	const NAME_AUTH_TIME = "auth_time";
44
+	const NAME_ACCESS_TOKEN_HASH = "at_hash";
45
+	const NAME_CODE_HASH = "c_hash";
46
+	const NAME_ACR = "acr";
47
+	const NAME_AMR = "amr";
48
+	const NAME_SUB_JWK = "sub_jwk";
49 49
     
50
-    /**
51
-     * Mapping from registered claim name to class name.
52
-     *
53
-     * @internal
54
-     *
55
-     * @var array
56
-     */
57
-    const MAP_NAME_TO_CLASS = array(
58
-        /* @formatter:off */
59
-        self::NAME_ISSUER => IssuerClaim::class,
60
-        self::NAME_SUBJECT => SubjectClaim::class,
61
-        self::NAME_AUDIENCE => AudienceClaim::class,
62
-        self::NAME_EXPIRATION_TIME => ExpirationTimeClaim::class,
63
-        self::NAME_NOT_BEFORE => NotBeforeClaim::class,
64
-        self::NAME_ISSUED_AT => IssuedAtClaim::class,
65
-        self::NAME_JWT_ID => JWTIDClaim::class
66
-        /* @formatter:on */
67
-    );
50
+	/**
51
+	 * Mapping from registered claim name to class name.
52
+	 *
53
+	 * @internal
54
+	 *
55
+	 * @var array
56
+	 */
57
+	const MAP_NAME_TO_CLASS = array(
58
+		/* @formatter:off */
59
+		self::NAME_ISSUER => IssuerClaim::class,
60
+		self::NAME_SUBJECT => SubjectClaim::class,
61
+		self::NAME_AUDIENCE => AudienceClaim::class,
62
+		self::NAME_EXPIRATION_TIME => ExpirationTimeClaim::class,
63
+		self::NAME_NOT_BEFORE => NotBeforeClaim::class,
64
+		self::NAME_ISSUED_AT => IssuedAtClaim::class,
65
+		self::NAME_JWT_ID => JWTIDClaim::class
66
+		/* @formatter:on */
67
+	);
68 68
     
69
-    /**
70
-     * Constructor.
71
-     *
72
-     * Defined here for type strictness. Parameters are passed to the
73
-     * superclass.
74
-     *
75
-     * @param mixed ...$args
76
-     */
77
-    public function __construct(...$args)
78
-    {
79
-        parent::__construct((string) $args[0], $args[1],
80
-            isset($args[2]) ? $args[2] : null);
81
-    }
69
+	/**
70
+	 * Constructor.
71
+	 *
72
+	 * Defined here for type strictness. Parameters are passed to the
73
+	 * superclass.
74
+	 *
75
+	 * @param mixed ...$args
76
+	 */
77
+	public function __construct(...$args)
78
+	{
79
+		parent::__construct((string) $args[0], $args[1],
80
+			isset($args[2]) ? $args[2] : null);
81
+	}
82 82
     
83
-    /**
84
-     * Initialize concrete claim instance from a JSON value.
85
-     *
86
-     * @param mixed $value
87
-     * @return RegisteredClaim
88
-     */
89
-    public static function fromJSONValue($value)
90
-    {
91
-        return new static($value);
92
-    }
83
+	/**
84
+	 * Initialize concrete claim instance from a JSON value.
85
+	 *
86
+	 * @param mixed $value
87
+	 * @return RegisteredClaim
88
+	 */
89
+	public static function fromJSONValue($value)
90
+	{
91
+		return new static($value);
92
+	}
93 93
 }
Please login to merge, or discard this patch.
lib/JWX/JWT/Parameter/ReplicatedClaimParameter.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@
 block discarded – undo
11 11
  */
12 12
 class ReplicatedClaimParameter extends JWTParameter
13 13
 {
14
-    /**
15
-     * Constructor.
16
-     *
17
-     * @param Claim $claim
18
-     */
19
-    public function __construct(Claim $claim)
20
-    {
21
-        parent::__construct($claim->name(), $claim->value());
22
-    }
14
+	/**
15
+	 * Constructor.
16
+	 *
17
+	 * @param Claim $claim
18
+	 */
19
+	public function __construct(Claim $claim)
20
+	{
21
+		parent::__construct($claim->name(), $claim->value());
22
+	}
23 23
 }
Please login to merge, or discard this patch.
lib/JWX/Parameter/Feature/ArrayParameterValue.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,25 +7,25 @@
 block discarded – undo
7 7
  */
8 8
 trait ArrayParameterValue
9 9
 {
10
-    /**
11
-     * Constructor.
12
-     *
13
-     * @param mixed ...$values
14
-     */
15
-    abstract public function __construct(...$values);
10
+	/**
11
+	 * Constructor.
12
+	 *
13
+	 * @param mixed ...$values
14
+	 */
15
+	abstract public function __construct(...$values);
16 16
     
17
-    /**
18
-     * Initialize from a JSON value.
19
-     *
20
-     * @param array $value
21
-     * @return static
22
-     */
23
-    public static function fromJSONValue($value)
24
-    {
25
-        if (!is_array($value)) {
26
-            throw new \UnexpectedValueException(
27
-                get_called_class() . " expects an array parameter.");
28
-        }
29
-        return new static(...$value);
30
-    }
17
+	/**
18
+	 * Initialize from a JSON value.
19
+	 *
20
+	 * @param array $value
21
+	 * @return static
22
+	 */
23
+	public static function fromJSONValue($value)
24
+	{
25
+		if (!is_array($value)) {
26
+			throw new \UnexpectedValueException(
27
+				get_called_class() . " expects an array parameter.");
28
+		}
29
+		return new static(...$value);
30
+	}
31 31
 }
Please login to merge, or discard this patch.
lib/JWX/JWS/Algorithm/HMACAlgorithm.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -18,92 +18,92 @@
 block discarded – undo
18 18
  */
19 19
 abstract class HMACAlgorithm extends SignatureAlgorithm
20 20
 {
21
-    /**
22
-     * Shared secret key.
23
-     *
24
-     * @var string $_key
25
-     */
26
-    protected $_key;
21
+	/**
22
+	 * Shared secret key.
23
+	 *
24
+	 * @var string $_key
25
+	 */
26
+	protected $_key;
27 27
     
28
-    /**
29
-     * Mapping from algorithm name to class name.
30
-     *
31
-     * @internal
32
-     *
33
-     * @var array
34
-     */
35
-    const MAP_ALGO_TO_CLASS = array(
36
-        /* @formatter:off */
37
-        JWA::ALGO_HS256 => HS256Algorithm::class, 
38
-        JWA::ALGO_HS384 => HS384Algorithm::class, 
39
-        JWA::ALGO_HS512 => HS512Algorithm::class
40
-        /* @formatter:on */
41
-    );
28
+	/**
29
+	 * Mapping from algorithm name to class name.
30
+	 *
31
+	 * @internal
32
+	 *
33
+	 * @var array
34
+	 */
35
+	const MAP_ALGO_TO_CLASS = array(
36
+		/* @formatter:off */
37
+		JWA::ALGO_HS256 => HS256Algorithm::class, 
38
+		JWA::ALGO_HS384 => HS384Algorithm::class, 
39
+		JWA::ALGO_HS512 => HS512Algorithm::class
40
+		/* @formatter:on */
41
+	);
42 42
     
43
-    /**
44
-     * Get algorithm name recognized by the Hash extension.
45
-     *
46
-     * @return string
47
-     */
48
-    abstract protected function _hashAlgo(): string;
43
+	/**
44
+	 * Get algorithm name recognized by the Hash extension.
45
+	 *
46
+	 * @return string
47
+	 */
48
+	abstract protected function _hashAlgo(): string;
49 49
     
50
-    /**
51
-     * Constructor.
52
-     *
53
-     * @param string $key Shared secret key
54
-     */
55
-    public function __construct(string $key)
56
-    {
57
-        $this->_key = $key;
58
-    }
50
+	/**
51
+	 * Constructor.
52
+	 *
53
+	 * @param string $key Shared secret key
54
+	 */
55
+	public function __construct(string $key)
56
+	{
57
+		$this->_key = $key;
58
+	}
59 59
     
60
-    /**
61
-     *
62
-     * {@inheritdoc}
63
-     */
64
-    public static function fromJWK(JWK $jwk, Header $header): self
65
-    {
66
-        $jwk = SymmetricKeyJWK::fromJWK($jwk);
67
-        $alg = JWA::deriveAlgorithmName($header, $jwk);
68
-        if (!array_key_exists($alg, self::MAP_ALGO_TO_CLASS)) {
69
-            throw new \UnexpectedValueException("Unsupported algorithm '$alg'.");
70
-        }
71
-        $cls = self::MAP_ALGO_TO_CLASS[$alg];
72
-        return new $cls($jwk->key());
73
-    }
60
+	/**
61
+	 *
62
+	 * {@inheritdoc}
63
+	 */
64
+	public static function fromJWK(JWK $jwk, Header $header): self
65
+	{
66
+		$jwk = SymmetricKeyJWK::fromJWK($jwk);
67
+		$alg = JWA::deriveAlgorithmName($header, $jwk);
68
+		if (!array_key_exists($alg, self::MAP_ALGO_TO_CLASS)) {
69
+			throw new \UnexpectedValueException("Unsupported algorithm '$alg'.");
70
+		}
71
+		$cls = self::MAP_ALGO_TO_CLASS[$alg];
72
+		return new $cls($jwk->key());
73
+	}
74 74
     
75
-    /**
76
-     *
77
-     * {@inheritdoc}
78
-     */
79
-    public function computeSignature(string $data): string
80
-    {
81
-        $result = @hash_hmac($this->_hashAlgo(), $data, $this->_key, true);
82
-        if (false === $result) {
83
-            $err = error_get_last();
84
-            $msg = isset($err) && __FILE__ == $err['file'] ? $err['message'] : null;
85
-            throw new \RuntimeException($msg ?? 'hash_hmac() failed.');
86
-        }
87
-        return $result;
88
-    }
75
+	/**
76
+	 *
77
+	 * {@inheritdoc}
78
+	 */
79
+	public function computeSignature(string $data): string
80
+	{
81
+		$result = @hash_hmac($this->_hashAlgo(), $data, $this->_key, true);
82
+		if (false === $result) {
83
+			$err = error_get_last();
84
+			$msg = isset($err) && __FILE__ == $err['file'] ? $err['message'] : null;
85
+			throw new \RuntimeException($msg ?? 'hash_hmac() failed.');
86
+		}
87
+		return $result;
88
+	}
89 89
     
90
-    /**
91
-     *
92
-     * {@inheritdoc}
93
-     */
94
-    public function validateSignature(string $data, string $signature): bool
95
-    {
96
-        return $this->computeSignature($data) === $signature;
97
-    }
90
+	/**
91
+	 *
92
+	 * {@inheritdoc}
93
+	 */
94
+	public function validateSignature(string $data, string $signature): bool
95
+	{
96
+		return $this->computeSignature($data) === $signature;
97
+	}
98 98
     
99
-    /**
100
-     *
101
-     * @see \JWX\JWS\SignatureAlgorithm::headerParameters()
102
-     * @return \JWX\JWT\Parameter\JWTParameter[]
103
-     */
104
-    public function headerParameters(): array
105
-    {
106
-        return array_merge(parent::headerParameters(),
107
-            array(AlgorithmParameter::fromAlgorithm($this)));
108
-    }
99
+	/**
100
+	 *
101
+	 * @see \JWX\JWS\SignatureAlgorithm::headerParameters()
102
+	 * @return \JWX\JWT\Parameter\JWTParameter[]
103
+	 */
104
+	public function headerParameters(): array
105
+	{
106
+		return array_merge(parent::headerParameters(),
107
+			array(AlgorithmParameter::fromAlgorithm($this)));
108
+	}
109 109
 }
Please login to merge, or discard this patch.
lib/JWX/JWS/Algorithm/HS256Algorithm.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -13,21 +13,21 @@
 block discarded – undo
13 13
  */
14 14
 class HS256Algorithm extends HMACAlgorithm
15 15
 {
16
-    /**
17
-     *
18
-     * {@inheritdoc}
19
-     */
20
-    protected function _hashAlgo(): string
21
-    {
22
-        return "sha256";
23
-    }
16
+	/**
17
+	 *
18
+	 * {@inheritdoc}
19
+	 */
20
+	protected function _hashAlgo(): string
21
+	{
22
+		return "sha256";
23
+	}
24 24
     
25
-    /**
26
-     *
27
-     * {@inheritdoc}
28
-     */
29
-    public function algorithmParamValue(): string
30
-    {
31
-        return JWA::ALGO_HS256;
32
-    }
25
+	/**
26
+	 *
27
+	 * {@inheritdoc}
28
+	 */
29
+	public function algorithmParamValue(): string
30
+	{
31
+		return JWA::ALGO_HS256;
32
+	}
33 33
 }
Please login to merge, or discard this patch.
lib/JWX/JWS/Algorithm/OpenSSLSignatureAlgorithm.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -12,90 +12,90 @@
 block discarded – undo
12 12
  */
13 13
 abstract class OpenSSLSignatureAlgorithm extends SignatureAlgorithm
14 14
 {
15
-    /**
16
-     * Public key.
17
-     *
18
-     * @var \JWX\JWK\Asymmetric\PublicKeyJWK $_publicKey
19
-     */
20
-    protected $_publicKey;
15
+	/**
16
+	 * Public key.
17
+	 *
18
+	 * @var \JWX\JWK\Asymmetric\PublicKeyJWK $_publicKey
19
+	 */
20
+	protected $_publicKey;
21 21
     
22
-    /**
23
-     * Private key.
24
-     *
25
-     * @var \JWX\JWK\Asymmetric\PrivateKeyJWK|null $_privateKey
26
-     */
27
-    protected $_privateKey;
22
+	/**
23
+	 * Private key.
24
+	 *
25
+	 * @var \JWX\JWK\Asymmetric\PrivateKeyJWK|null $_privateKey
26
+	 */
27
+	protected $_privateKey;
28 28
     
29
-    /**
30
-     * Get the message digest method name supported by OpenSSL.
31
-     *
32
-     * @return string
33
-     */
34
-    abstract protected function _mdMethod(): string;
29
+	/**
30
+	 * Get the message digest method name supported by OpenSSL.
31
+	 *
32
+	 * @return string
33
+	 */
34
+	abstract protected function _mdMethod(): string;
35 35
     
36
-    /**
37
-     *
38
-     * @see \JWX\JWS\SignatureAlgorithm::computeSignature()
39
-     * @throws \LogicException If private key was not provided
40
-     * @throws \RuntimeException For generic errors
41
-     * @return string
42
-     */
43
-    public function computeSignature(string $data): string
44
-    {
45
-        /**
46
-         * NOTE: OpenSSL uses PKCS #1 v1.5 padding by default, so no explicit
47
-         * padding is required by sign and verify operations.
48
-         */
49
-        if (!isset($this->_privateKey)) {
50
-            throw new \LogicException("Private key not set.");
51
-        }
52
-        $key = openssl_pkey_get_private($this->_privateKey->toPEM()->string());
53
-        if (!$key) {
54
-            throw new \RuntimeException(
55
-                "openssl_pkey_get_private() failed: " .
56
-                     $this->_getLastOpenSSLError());
57
-        }
58
-        $result = @openssl_sign($data, $signature, $key, $this->_mdMethod());
59
-        if (!$result) {
60
-            throw new \RuntimeException(
61
-                "openssl_sign() failed: " . $this->_getLastOpenSSLError());
62
-        }
63
-        return $signature;
64
-    }
36
+	/**
37
+	 *
38
+	 * @see \JWX\JWS\SignatureAlgorithm::computeSignature()
39
+	 * @throws \LogicException If private key was not provided
40
+	 * @throws \RuntimeException For generic errors
41
+	 * @return string
42
+	 */
43
+	public function computeSignature(string $data): string
44
+	{
45
+		/**
46
+		 * NOTE: OpenSSL uses PKCS #1 v1.5 padding by default, so no explicit
47
+		 * padding is required by sign and verify operations.
48
+		 */
49
+		if (!isset($this->_privateKey)) {
50
+			throw new \LogicException("Private key not set.");
51
+		}
52
+		$key = openssl_pkey_get_private($this->_privateKey->toPEM()->string());
53
+		if (!$key) {
54
+			throw new \RuntimeException(
55
+				"openssl_pkey_get_private() failed: " .
56
+					 $this->_getLastOpenSSLError());
57
+		}
58
+		$result = @openssl_sign($data, $signature, $key, $this->_mdMethod());
59
+		if (!$result) {
60
+			throw new \RuntimeException(
61
+				"openssl_sign() failed: " . $this->_getLastOpenSSLError());
62
+		}
63
+		return $signature;
64
+	}
65 65
     
66
-    /**
67
-     *
68
-     * @see \JWX\JWS\SignatureAlgorithm::validateSignature()
69
-     * @throws \RuntimeException For generic errors
70
-     * @return bool
71
-     */
72
-    public function validateSignature(string $data, string $signature): bool
73
-    {
74
-        $key = openssl_pkey_get_public($this->_publicKey->toPEM()->string());
75
-        if (!$key) {
76
-            throw new \RuntimeException(
77
-                "openssl_pkey_get_public() failed: " .
78
-                     $this->_getLastOpenSSLError());
79
-        }
80
-        $result = @openssl_verify($data, $signature, $key, $this->_mdMethod());
81
-        if (false === $result || -1 == $result) {
82
-            throw new \RuntimeException(
83
-                "openssl_verify() failed: " . $this->_getLastOpenSSLError());
84
-        }
85
-        return $result == 1;
86
-    }
66
+	/**
67
+	 *
68
+	 * @see \JWX\JWS\SignatureAlgorithm::validateSignature()
69
+	 * @throws \RuntimeException For generic errors
70
+	 * @return bool
71
+	 */
72
+	public function validateSignature(string $data, string $signature): bool
73
+	{
74
+		$key = openssl_pkey_get_public($this->_publicKey->toPEM()->string());
75
+		if (!$key) {
76
+			throw new \RuntimeException(
77
+				"openssl_pkey_get_public() failed: " .
78
+					 $this->_getLastOpenSSLError());
79
+		}
80
+		$result = @openssl_verify($data, $signature, $key, $this->_mdMethod());
81
+		if (false === $result || -1 == $result) {
82
+			throw new \RuntimeException(
83
+				"openssl_verify() failed: " . $this->_getLastOpenSSLError());
84
+		}
85
+		return $result == 1;
86
+	}
87 87
     
88
-    /**
89
-     * Get the last OpenSSL error message.
90
-     *
91
-     * @return string|null
92
-     */
93
-    protected function _getLastOpenSSLError()
94
-    {
95
-        $msg = null;
96
-        while (false !== ($err = openssl_error_string())) {
97
-            $msg = $err;
98
-        }
99
-        return $msg;
100
-    }
88
+	/**
89
+	 * Get the last OpenSSL error message.
90
+	 *
91
+	 * @return string|null
92
+	 */
93
+	protected function _getLastOpenSSLError()
94
+	{
95
+		$msg = null;
96
+		while (false !== ($err = openssl_error_string())) {
97
+			$msg = $err;
98
+		}
99
+		return $msg;
100
+	}
101 101
 }
Please login to merge, or discard this patch.
lib/JWX/JWS/Algorithm/HS384Algorithm.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -13,21 +13,21 @@
 block discarded – undo
13 13
  */
14 14
 class HS384Algorithm extends HMACAlgorithm
15 15
 {
16
-    /**
17
-     *
18
-     * {@inheritdoc}
19
-     */
20
-    protected function _hashAlgo(): string
21
-    {
22
-        return "sha384";
23
-    }
16
+	/**
17
+	 *
18
+	 * {@inheritdoc}
19
+	 */
20
+	protected function _hashAlgo(): string
21
+	{
22
+		return "sha384";
23
+	}
24 24
     
25
-    /**
26
-     *
27
-     * {@inheritdoc}
28
-     */
29
-    public function algorithmParamValue(): string
30
-    {
31
-        return JWA::ALGO_HS384;
32
-    }
25
+	/**
26
+	 *
27
+	 * {@inheritdoc}
28
+	 */
29
+	public function algorithmParamValue(): string
30
+	{
31
+		return JWA::ALGO_HS384;
32
+	}
33 33
 }
Please login to merge, or discard this patch.