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.
Completed
Push — php72 ( 880eb0...efc120 )
by Joni
02:36
created
lib/JWX/JWE/KeyAlgorithm/AESGCMKWAlgorithm.php 2 patches
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -23,165 +23,165 @@
 block discarded – undo
23 23
  */
24 24
 abstract class AESGCMKWAlgorithm extends KeyManagementAlgorithm
25 25
 {
26
-    use RandomCEK;
27
-
28
-    /**
29
-     * Mapping from algorithm name to class name.
30
-     *
31
-     * @internal
32
-     *
33
-     * @var array
34
-     */
35
-    const MAP_ALGO_TO_CLASS = [
36
-        JWA::ALGO_A128GCMKW => A128GCMKWAlgorithm::class,
37
-        JWA::ALGO_A192GCMKW => A192GCMKWAlgorithm::class,
38
-        JWA::ALGO_A256GCMKW => A256GCMKWAlgorithm::class,
39
-    ];
40
-
41
-    /**
42
-     * Required IV size in bytes.
43
-     *
44
-     * @var int
45
-     */
46
-    const IV_SIZE = 12;
47
-
48
-    /**
49
-     * Authentication tag size in bytes.
50
-     *
51
-     * @var int
52
-     */
53
-    const AUTH_TAG_SIZE = 16;
54
-
55
-    /**
56
-     * Key encryption key.
57
-     *
58
-     * @var string
59
-     */
60
-    protected $_kek;
61
-
62
-    /**
63
-     * Initialization vector.
64
-     *
65
-     * @var string
66
-     */
67
-    protected $_iv;
68
-
69
-    /**
70
-     * Constructor.
71
-     *
72
-     * @param string $kek Key encryption key
73
-     * @param string $iv  Initialization vector
74
-     */
75
-    public function __construct(string $kek, string $iv)
76
-    {
77
-        if (strlen($kek) !== $this->_keySize()) {
78
-            throw new \LengthException('Invalid key size.');
79
-        }
80
-        if (self::IV_SIZE !== strlen($iv)) {
81
-            throw new \LengthException('Initialization vector must be 96 bits.');
82
-        }
83
-        $this->_kek = $kek;
84
-        $this->_iv = $iv;
85
-    }
86
-
87
-    /**
88
-     * Initialize from JWK.
89
-     *
90
-     * @param JWK    $jwk
91
-     * @param Header $header
92
-     *
93
-     * @throws \UnexpectedValueException
94
-     *
95
-     * @return self
96
-     */
97
-    public static function fromJWK(JWK $jwk, Header $header): KeyManagementAlgorithm
98
-    {
99
-        $jwk = SymmetricKeyJWK::fromJWK($jwk);
100
-        if (!$header->hasInitializationVector()) {
101
-            throw new \UnexpectedValueException('No initialization vector.');
102
-        }
103
-        $iv = $header->initializationVector()->initializationVector();
104
-        $alg = JWA::deriveAlgorithmName($header, $jwk);
105
-        if (!array_key_exists($alg, self::MAP_ALGO_TO_CLASS)) {
106
-            throw new \UnexpectedValueException("Unsupported algorithm '{$alg}'.");
107
-        }
108
-        $cls = self::MAP_ALGO_TO_CLASS[$alg];
109
-        return new $cls($jwk->key(), $iv);
110
-    }
111
-
112
-    /**
113
-     * Initialize from key encryption key with random IV.
114
-     *
115
-     * Key size must match the underlying cipher.
116
-     *
117
-     * @param string $key Key encryption key
118
-     *
119
-     * @return self
120
-     */
121
-    public static function fromKey(string $key): self
122
-    {
123
-        $iv = openssl_random_pseudo_bytes(self::IV_SIZE);
124
-        return new static($key, $iv);
125
-    }
126
-
127
-    /**
128
-     * {@inheritdoc}
129
-     */
130
-    public function headerParameters(): array
131
-    {
132
-        return array_merge(parent::headerParameters(),
133
-            [AlgorithmParameter::fromAlgorithm($this),
134
-                InitializationVectorParameter::fromString($this->_iv), ]);
135
-    }
136
-
137
-    /**
138
-     * Get GCM Cipher instance.
139
-     *
140
-     * @return Cipher
141
-     */
142
-    abstract protected function _getGCMCipher(): Cipher;
143
-
144
-    /**
145
-     * Get the required key size.
146
-     *
147
-     * @return int
148
-     */
149
-    abstract protected function _keySize(): int;
150
-
151
-    /**
152
-     * Get GCM instance.
153
-     *
154
-     * @return GCM
155
-     */
156
-    final protected function _getGCM(): GCM
157
-    {
158
-        return new GCM($this->_getGCMCipher(), self::AUTH_TAG_SIZE);
159
-    }
160
-
161
-    /**
162
-     * {@inheritdoc}
163
-     */
164
-    protected function _encryptKey(string $key, Header &$header): string
165
-    {
166
-        [$ciphertext, $auth_tag] = $this->_getGCM()
167
-            ->encrypt($key, '', $this->_kek, $this->_iv);
168
-        // insert authentication tag to the header
169
-        $header = $header->withParameters(
170
-            AuthenticationTagParameter::fromString($auth_tag));
171
-        return $ciphertext;
172
-    }
173
-
174
-    /**
175
-     * {@inheritdoc}
176
-     */
177
-    protected function _decryptKey(string $ciphertext, Header $header): string
178
-    {
179
-        if (!$header->hasAuthenticationTag()) {
180
-            throw new \RuntimeException(
181
-                "Header doesn't contain authentication tag.");
182
-        }
183
-        $auth_tag = $header->authenticationTag()->authenticationTag();
184
-        return $this->_getGCM()
185
-            ->decrypt($ciphertext, $auth_tag, '', $this->_kek, $this->_iv);
186
-    }
26
+	use RandomCEK;
27
+
28
+	/**
29
+	 * Mapping from algorithm name to class name.
30
+	 *
31
+	 * @internal
32
+	 *
33
+	 * @var array
34
+	 */
35
+	const MAP_ALGO_TO_CLASS = [
36
+		JWA::ALGO_A128GCMKW => A128GCMKWAlgorithm::class,
37
+		JWA::ALGO_A192GCMKW => A192GCMKWAlgorithm::class,
38
+		JWA::ALGO_A256GCMKW => A256GCMKWAlgorithm::class,
39
+	];
40
+
41
+	/**
42
+	 * Required IV size in bytes.
43
+	 *
44
+	 * @var int
45
+	 */
46
+	const IV_SIZE = 12;
47
+
48
+	/**
49
+	 * Authentication tag size in bytes.
50
+	 *
51
+	 * @var int
52
+	 */
53
+	const AUTH_TAG_SIZE = 16;
54
+
55
+	/**
56
+	 * Key encryption key.
57
+	 *
58
+	 * @var string
59
+	 */
60
+	protected $_kek;
61
+
62
+	/**
63
+	 * Initialization vector.
64
+	 *
65
+	 * @var string
66
+	 */
67
+	protected $_iv;
68
+
69
+	/**
70
+	 * Constructor.
71
+	 *
72
+	 * @param string $kek Key encryption key
73
+	 * @param string $iv  Initialization vector
74
+	 */
75
+	public function __construct(string $kek, string $iv)
76
+	{
77
+		if (strlen($kek) !== $this->_keySize()) {
78
+			throw new \LengthException('Invalid key size.');
79
+		}
80
+		if (self::IV_SIZE !== strlen($iv)) {
81
+			throw new \LengthException('Initialization vector must be 96 bits.');
82
+		}
83
+		$this->_kek = $kek;
84
+		$this->_iv = $iv;
85
+	}
86
+
87
+	/**
88
+	 * Initialize from JWK.
89
+	 *
90
+	 * @param JWK    $jwk
91
+	 * @param Header $header
92
+	 *
93
+	 * @throws \UnexpectedValueException
94
+	 *
95
+	 * @return self
96
+	 */
97
+	public static function fromJWK(JWK $jwk, Header $header): KeyManagementAlgorithm
98
+	{
99
+		$jwk = SymmetricKeyJWK::fromJWK($jwk);
100
+		if (!$header->hasInitializationVector()) {
101
+			throw new \UnexpectedValueException('No initialization vector.');
102
+		}
103
+		$iv = $header->initializationVector()->initializationVector();
104
+		$alg = JWA::deriveAlgorithmName($header, $jwk);
105
+		if (!array_key_exists($alg, self::MAP_ALGO_TO_CLASS)) {
106
+			throw new \UnexpectedValueException("Unsupported algorithm '{$alg}'.");
107
+		}
108
+		$cls = self::MAP_ALGO_TO_CLASS[$alg];
109
+		return new $cls($jwk->key(), $iv);
110
+	}
111
+
112
+	/**
113
+	 * Initialize from key encryption key with random IV.
114
+	 *
115
+	 * Key size must match the underlying cipher.
116
+	 *
117
+	 * @param string $key Key encryption key
118
+	 *
119
+	 * @return self
120
+	 */
121
+	public static function fromKey(string $key): self
122
+	{
123
+		$iv = openssl_random_pseudo_bytes(self::IV_SIZE);
124
+		return new static($key, $iv);
125
+	}
126
+
127
+	/**
128
+	 * {@inheritdoc}
129
+	 */
130
+	public function headerParameters(): array
131
+	{
132
+		return array_merge(parent::headerParameters(),
133
+			[AlgorithmParameter::fromAlgorithm($this),
134
+				InitializationVectorParameter::fromString($this->_iv), ]);
135
+	}
136
+
137
+	/**
138
+	 * Get GCM Cipher instance.
139
+	 *
140
+	 * @return Cipher
141
+	 */
142
+	abstract protected function _getGCMCipher(): Cipher;
143
+
144
+	/**
145
+	 * Get the required key size.
146
+	 *
147
+	 * @return int
148
+	 */
149
+	abstract protected function _keySize(): int;
150
+
151
+	/**
152
+	 * Get GCM instance.
153
+	 *
154
+	 * @return GCM
155
+	 */
156
+	final protected function _getGCM(): GCM
157
+	{
158
+		return new GCM($this->_getGCMCipher(), self::AUTH_TAG_SIZE);
159
+	}
160
+
161
+	/**
162
+	 * {@inheritdoc}
163
+	 */
164
+	protected function _encryptKey(string $key, Header &$header): string
165
+	{
166
+		[$ciphertext, $auth_tag] = $this->_getGCM()
167
+			->encrypt($key, '', $this->_kek, $this->_iv);
168
+		// insert authentication tag to the header
169
+		$header = $header->withParameters(
170
+			AuthenticationTagParameter::fromString($auth_tag));
171
+		return $ciphertext;
172
+	}
173
+
174
+	/**
175
+	 * {@inheritdoc}
176
+	 */
177
+	protected function _decryptKey(string $ciphertext, Header $header): string
178
+	{
179
+		if (!$header->hasAuthenticationTag()) {
180
+			throw new \RuntimeException(
181
+				"Header doesn't contain authentication tag.");
182
+		}
183
+		$auth_tag = $header->authenticationTag()->authenticationTag();
184
+		return $this->_getGCM()
185
+			->decrypt($ciphertext, $auth_tag, '', $this->_kek, $this->_iv);
186
+	}
187 187
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWE\KeyAlgorithm;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWE/KeyAlgorithm/A128KWAlgorithm.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -15,27 +15,27 @@
 block discarded – undo
15 15
  */
16 16
 class A128KWAlgorithm extends AESKWAlgorithm
17 17
 {
18
-    /**
19
-     * {@inheritdoc}
20
-     */
21
-    public function algorithmParamValue(): string
22
-    {
23
-        return JWA::ALGO_A128KW;
24
-    }
18
+	/**
19
+	 * {@inheritdoc}
20
+	 */
21
+	public function algorithmParamValue(): string
22
+	{
23
+		return JWA::ALGO_A128KW;
24
+	}
25 25
 
26
-    /**
27
-     * {@inheritdoc}
28
-     */
29
-    protected function _kekSize(): int
30
-    {
31
-        return 16;
32
-    }
26
+	/**
27
+	 * {@inheritdoc}
28
+	 */
29
+	protected function _kekSize(): int
30
+	{
31
+		return 16;
32
+	}
33 33
 
34
-    /**
35
-     * {@inheritdoc}
36
-     */
37
-    protected function _AESKWAlgo(): AESKeyWrapAlgorithm
38
-    {
39
-        return new AESKW128();
40
-    }
34
+	/**
35
+	 * {@inheritdoc}
36
+	 */
37
+	protected function _AESKWAlgo(): AESKeyWrapAlgorithm
38
+	{
39
+		return new AESKW128();
40
+	}
41 41
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWE\KeyAlgorithm;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWE/KeyAlgorithm/AESKWAlgorithm.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -20,121 +20,121 @@
 block discarded – undo
20 20
  */
21 21
 abstract class AESKWAlgorithm extends KeyManagementAlgorithm
22 22
 {
23
-    use RandomCEK;
23
+	use RandomCEK;
24 24
 
25
-    /**
26
-     * Mapping from algorithm name to class name.
27
-     *
28
-     * @internal
29
-     *
30
-     * @var array
31
-     */
32
-    const MAP_ALGO_TO_CLASS = [
33
-        JWA::ALGO_A128KW => A128KWAlgorithm::class,
34
-        JWA::ALGO_A192KW => A192KWAlgorithm::class,
35
-        JWA::ALGO_A256KW => A256KWAlgorithm::class,
36
-    ];
25
+	/**
26
+	 * Mapping from algorithm name to class name.
27
+	 *
28
+	 * @internal
29
+	 *
30
+	 * @var array
31
+	 */
32
+	const MAP_ALGO_TO_CLASS = [
33
+		JWA::ALGO_A128KW => A128KWAlgorithm::class,
34
+		JWA::ALGO_A192KW => A192KWAlgorithm::class,
35
+		JWA::ALGO_A256KW => A256KWAlgorithm::class,
36
+	];
37 37
 
38
-    /**
39
-     * Key encryption key.
40
-     *
41
-     * @var string
42
-     */
43
-    protected $_kek;
38
+	/**
39
+	 * Key encryption key.
40
+	 *
41
+	 * @var string
42
+	 */
43
+	protected $_kek;
44 44
 
45
-    /**
46
-     * Key wrapping algorithm.
47
-     *
48
-     * Lazily initialized.
49
-     *
50
-     * @var null|AESKeyWrapAlgorithm
51
-     */
52
-    protected $_kw;
45
+	/**
46
+	 * Key wrapping algorithm.
47
+	 *
48
+	 * Lazily initialized.
49
+	 *
50
+	 * @var null|AESKeyWrapAlgorithm
51
+	 */
52
+	protected $_kw;
53 53
 
54
-    /**
55
-     * Constructor.
56
-     *
57
-     * @param string $kek Key encryption key
58
-     */
59
-    public function __construct(string $kek)
60
-    {
61
-        if (strlen($kek) !== $this->_kekSize()) {
62
-            throw new \LengthException(
63
-                'Key encryption key must be ' . $this->_kekSize() . ' bytes.');
64
-        }
65
-        $this->_kek = $kek;
66
-    }
54
+	/**
55
+	 * Constructor.
56
+	 *
57
+	 * @param string $kek Key encryption key
58
+	 */
59
+	public function __construct(string $kek)
60
+	{
61
+		if (strlen($kek) !== $this->_kekSize()) {
62
+			throw new \LengthException(
63
+				'Key encryption key must be ' . $this->_kekSize() . ' bytes.');
64
+		}
65
+		$this->_kek = $kek;
66
+	}
67 67
 
68
-    /**
69
-     * Initialize from JWK.
70
-     *
71
-     * @param JWK    $jwk
72
-     * @param Header $header
73
-     *
74
-     * @throws \UnexpectedValueException
75
-     *
76
-     * @return self
77
-     */
78
-    public static function fromJWK(JWK $jwk, Header $header): KeyManagementAlgorithm
79
-    {
80
-        $jwk = SymmetricKeyJWK::fromJWK($jwk);
81
-        $alg = JWA::deriveAlgorithmName($header, $jwk);
82
-        if (!array_key_exists($alg, self::MAP_ALGO_TO_CLASS)) {
83
-            throw new \UnexpectedValueException("Unsupported algorithm '{$alg}'.");
84
-        }
85
-        $cls = self::MAP_ALGO_TO_CLASS[$alg];
86
-        return new $cls($jwk->key());
87
-    }
68
+	/**
69
+	 * Initialize from JWK.
70
+	 *
71
+	 * @param JWK    $jwk
72
+	 * @param Header $header
73
+	 *
74
+	 * @throws \UnexpectedValueException
75
+	 *
76
+	 * @return self
77
+	 */
78
+	public static function fromJWK(JWK $jwk, Header $header): KeyManagementAlgorithm
79
+	{
80
+		$jwk = SymmetricKeyJWK::fromJWK($jwk);
81
+		$alg = JWA::deriveAlgorithmName($header, $jwk);
82
+		if (!array_key_exists($alg, self::MAP_ALGO_TO_CLASS)) {
83
+			throw new \UnexpectedValueException("Unsupported algorithm '{$alg}'.");
84
+		}
85
+		$cls = self::MAP_ALGO_TO_CLASS[$alg];
86
+		return new $cls($jwk->key());
87
+	}
88 88
 
89
-    /**
90
-     * {@inheritdoc}
91
-     */
92
-    public function headerParameters(): array
93
-    {
94
-        return array_merge(parent::headerParameters(),
95
-            [AlgorithmParameter::fromAlgorithm($this)]);
96
-    }
89
+	/**
90
+	 * {@inheritdoc}
91
+	 */
92
+	public function headerParameters(): array
93
+	{
94
+		return array_merge(parent::headerParameters(),
95
+			[AlgorithmParameter::fromAlgorithm($this)]);
96
+	}
97 97
 
98
-    /**
99
-     * Get the size of the key encryption key in bytes.
100
-     *
101
-     * @return int
102
-     */
103
-    abstract protected function _kekSize(): int;
98
+	/**
99
+	 * Get the size of the key encryption key in bytes.
100
+	 *
101
+	 * @return int
102
+	 */
103
+	abstract protected function _kekSize(): int;
104 104
 
105
-    /**
106
-     * Get key wrapping algorithm instance.
107
-     *
108
-     * @return AESKeyWrapAlgorithm
109
-     */
110
-    abstract protected function _AESKWAlgo(): AESKeyWrapAlgorithm;
105
+	/**
106
+	 * Get key wrapping algorithm instance.
107
+	 *
108
+	 * @return AESKeyWrapAlgorithm
109
+	 */
110
+	abstract protected function _AESKWAlgo(): AESKeyWrapAlgorithm;
111 111
 
112
-    /**
113
-     * Get key wrapping algorithm.
114
-     *
115
-     * @return AESKeyWrapAlgorithm
116
-     */
117
-    protected function _kw(): AESKeyWrapAlgorithm
118
-    {
119
-        if (!isset($this->_kw)) {
120
-            $this->_kw = $this->_AESKWAlgo();
121
-        }
122
-        return $this->_kw;
123
-    }
112
+	/**
113
+	 * Get key wrapping algorithm.
114
+	 *
115
+	 * @return AESKeyWrapAlgorithm
116
+	 */
117
+	protected function _kw(): AESKeyWrapAlgorithm
118
+	{
119
+		if (!isset($this->_kw)) {
120
+			$this->_kw = $this->_AESKWAlgo();
121
+		}
122
+		return $this->_kw;
123
+	}
124 124
 
125
-    /**
126
-     * {@inheritdoc}
127
-     */
128
-    protected function _encryptKey(string $key, Header &$header): string
129
-    {
130
-        return $this->_kw()->wrap($key, $this->_kek);
131
-    }
125
+	/**
126
+	 * {@inheritdoc}
127
+	 */
128
+	protected function _encryptKey(string $key, Header &$header): string
129
+	{
130
+		return $this->_kw()->wrap($key, $this->_kek);
131
+	}
132 132
 
133
-    /**
134
-     * {@inheritdoc}
135
-     */
136
-    protected function _decryptKey(string $ciphertext, Header $header): string
137
-    {
138
-        return $this->_kw()->unwrap($ciphertext, $this->_kek);
139
-    }
133
+	/**
134
+	 * {@inheritdoc}
135
+	 */
136
+	protected function _decryptKey(string $ciphertext, Header $header): string
137
+	{
138
+		return $this->_kw()->unwrap($ciphertext, $this->_kek);
139
+	}
140 140
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWE\KeyAlgorithm;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWE/KeyAlgorithm/A192KWAlgorithm.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -15,27 +15,27 @@
 block discarded – undo
15 15
  */
16 16
 class A192KWAlgorithm extends AESKWAlgorithm
17 17
 {
18
-    /**
19
-     * {@inheritdoc}
20
-     */
21
-    public function algorithmParamValue(): string
22
-    {
23
-        return JWA::ALGO_A192KW;
24
-    }
18
+	/**
19
+	 * {@inheritdoc}
20
+	 */
21
+	public function algorithmParamValue(): string
22
+	{
23
+		return JWA::ALGO_A192KW;
24
+	}
25 25
 
26
-    /**
27
-     * {@inheritdoc}
28
-     */
29
-    protected function _kekSize(): int
30
-    {
31
-        return 24;
32
-    }
26
+	/**
27
+	 * {@inheritdoc}
28
+	 */
29
+	protected function _kekSize(): int
30
+	{
31
+		return 24;
32
+	}
33 33
 
34
-    /**
35
-     * {@inheritdoc}
36
-     */
37
-    protected function _AESKWAlgo(): AESKeyWrapAlgorithm
38
-    {
39
-        return new AESKW192();
40
-    }
34
+	/**
35
+	 * {@inheritdoc}
36
+	 */
37
+	protected function _AESKWAlgo(): AESKeyWrapAlgorithm
38
+	{
39
+		return new AESKW192();
40
+	}
41 41
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWE\KeyAlgorithm;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWE/KeyAlgorithm/DirectCEKAlgorithm.php 2 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -18,101 +18,101 @@
 block discarded – undo
18 18
  */
19 19
 class DirectCEKAlgorithm extends KeyManagementAlgorithm
20 20
 {
21
-    /**
22
-     * Content encryption key.
23
-     *
24
-     * @var string
25
-     */
26
-    protected $_cek;
21
+	/**
22
+	 * Content encryption key.
23
+	 *
24
+	 * @var string
25
+	 */
26
+	protected $_cek;
27 27
 
28
-    /**
29
-     * Constructor.
30
-     *
31
-     * @param string $cek Content encryption key
32
-     */
33
-    public function __construct(string $cek)
34
-    {
35
-        $this->_cek = $cek;
36
-    }
28
+	/**
29
+	 * Constructor.
30
+	 *
31
+	 * @param string $cek Content encryption key
32
+	 */
33
+	public function __construct(string $cek)
34
+	{
35
+		$this->_cek = $cek;
36
+	}
37 37
 
38
-    /**
39
-     * Initialize from JWK.
40
-     *
41
-     * @param JWK    $jwk
42
-     * @param Header $header
43
-     *
44
-     * @throws \UnexpectedValueException
45
-     *
46
-     * @return self
47
-     */
48
-    public static function fromJWK(JWK $jwk, Header $header): KeyManagementAlgorithm
49
-    {
50
-        $jwk = SymmetricKeyJWK::fromJWK($jwk);
51
-        $alg = JWA::deriveAlgorithmName($header);
52
-        if (JWA::ALGO_DIR !== $alg) {
53
-            throw new \UnexpectedValueException("Invalid algorithm '{$alg}'.");
54
-        }
55
-        return new self($jwk->key());
56
-    }
38
+	/**
39
+	 * Initialize from JWK.
40
+	 *
41
+	 * @param JWK    $jwk
42
+	 * @param Header $header
43
+	 *
44
+	 * @throws \UnexpectedValueException
45
+	 *
46
+	 * @return self
47
+	 */
48
+	public static function fromJWK(JWK $jwk, Header $header): KeyManagementAlgorithm
49
+	{
50
+		$jwk = SymmetricKeyJWK::fromJWK($jwk);
51
+		$alg = JWA::deriveAlgorithmName($header);
52
+		if (JWA::ALGO_DIR !== $alg) {
53
+			throw new \UnexpectedValueException("Invalid algorithm '{$alg}'.");
54
+		}
55
+		return new self($jwk->key());
56
+	}
57 57
 
58
-    /**
59
-     * Get content encryption key.
60
-     *
61
-     * @return string
62
-     */
63
-    public function cek(): string
64
-    {
65
-        return $this->_cek;
66
-    }
58
+	/**
59
+	 * Get content encryption key.
60
+	 *
61
+	 * @return string
62
+	 */
63
+	public function cek(): string
64
+	{
65
+		return $this->_cek;
66
+	}
67 67
 
68
-    /**
69
-     * {@inheritdoc}
70
-     */
71
-    public function cekForEncryption(int $length): string
72
-    {
73
-        if (strlen($this->_cek) !== $length) {
74
-            throw new \UnexpectedValueException('Invalid key length.');
75
-        }
76
-        return $this->_cek;
77
-    }
68
+	/**
69
+	 * {@inheritdoc}
70
+	 */
71
+	public function cekForEncryption(int $length): string
72
+	{
73
+		if (strlen($this->_cek) !== $length) {
74
+			throw new \UnexpectedValueException('Invalid key length.');
75
+		}
76
+		return $this->_cek;
77
+	}
78 78
 
79
-    /**
80
-     * {@inheritdoc}
81
-     */
82
-    public function algorithmParamValue(): string
83
-    {
84
-        return JWA::ALGO_DIR;
85
-    }
79
+	/**
80
+	 * {@inheritdoc}
81
+	 */
82
+	public function algorithmParamValue(): string
83
+	{
84
+		return JWA::ALGO_DIR;
85
+	}
86 86
 
87
-    /**
88
-     * {@inheritdoc}
89
-     */
90
-    public function headerParameters(): array
91
-    {
92
-        return array_merge(parent::headerParameters(),
93
-            [AlgorithmParameter::fromAlgorithm($this)]);
94
-    }
87
+	/**
88
+	 * {@inheritdoc}
89
+	 */
90
+	public function headerParameters(): array
91
+	{
92
+		return array_merge(parent::headerParameters(),
93
+			[AlgorithmParameter::fromAlgorithm($this)]);
94
+	}
95 95
 
96
-    /**
97
-     * {@inheritdoc}
98
-     */
99
-    protected function _encryptKey(string $key, Header &$header): string
100
-    {
101
-        if ($key !== $this->_cek) {
102
-            throw new \LogicException("Content encryption key doesn't match.");
103
-        }
104
-        return '';
105
-    }
96
+	/**
97
+	 * {@inheritdoc}
98
+	 */
99
+	protected function _encryptKey(string $key, Header &$header): string
100
+	{
101
+		if ($key !== $this->_cek) {
102
+			throw new \LogicException("Content encryption key doesn't match.");
103
+		}
104
+		return '';
105
+	}
106 106
 
107
-    /**
108
-     * {@inheritdoc}
109
-     */
110
-    protected function _decryptKey(string $ciphertext, Header $header): string
111
-    {
112
-        if ('' !== $ciphertext) {
113
-            throw new \UnexpectedValueException(
114
-                'Encrypted key must be an empty octet sequence.');
115
-        }
116
-        return $this->_cek;
117
-    }
107
+	/**
108
+	 * {@inheritdoc}
109
+	 */
110
+	protected function _decryptKey(string $ciphertext, Header $header): string
111
+	{
112
+		if ('' !== $ciphertext) {
113
+			throw new \UnexpectedValueException(
114
+				'Encrypted key must be an empty octet sequence.');
115
+		}
116
+		return $this->_cek;
117
+	}
118 118
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWE\KeyAlgorithm;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWE/KeyAlgorithm/PBES2HS512A256KWAlgorithm.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -15,35 +15,35 @@
 block discarded – undo
15 15
  */
16 16
 class PBES2HS512A256KWAlgorithm extends PBES2Algorithm
17 17
 {
18
-    /**
19
-     * {@inheritdoc}
20
-     */
21
-    public function algorithmParamValue(): string
22
-    {
23
-        return JWA::ALGO_PBES2_HS512_A256KW;
24
-    }
18
+	/**
19
+	 * {@inheritdoc}
20
+	 */
21
+	public function algorithmParamValue(): string
22
+	{
23
+		return JWA::ALGO_PBES2_HS512_A256KW;
24
+	}
25 25
 
26
-    /**
27
-     * {@inheritdoc}
28
-     */
29
-    protected function _hashAlgo(): string
30
-    {
31
-        return 'sha512';
32
-    }
26
+	/**
27
+	 * {@inheritdoc}
28
+	 */
29
+	protected function _hashAlgo(): string
30
+	{
31
+		return 'sha512';
32
+	}
33 33
 
34
-    /**
35
-     * {@inheritdoc}
36
-     */
37
-    protected function _keyLength(): int
38
-    {
39
-        return 32;
40
-    }
34
+	/**
35
+	 * {@inheritdoc}
36
+	 */
37
+	protected function _keyLength(): int
38
+	{
39
+		return 32;
40
+	}
41 41
 
42
-    /**
43
-     * {@inheritdoc}
44
-     */
45
-    protected function _kwAlgo(): AESKeyWrapAlgorithm
46
-    {
47
-        return new AESKW256();
48
-    }
42
+	/**
43
+	 * {@inheritdoc}
44
+	 */
45
+	protected function _kwAlgo(): AESKeyWrapAlgorithm
46
+	{
47
+		return new AESKW256();
48
+	}
49 49
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWE\KeyAlgorithm;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWE/KeyAlgorithm/RSAESPKCS1Algorithm.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@
 block discarded – undo
13 13
  */
14 14
 class RSAESPKCS1Algorithm extends RSAESKeyAlgorithm
15 15
 {
16
-    /**
17
-     * {@inheritdoc}
18
-     */
19
-    public function algorithmParamValue(): string
20
-    {
21
-        return JWA::ALGO_RSA1_5;
22
-    }
16
+	/**
17
+	 * {@inheritdoc}
18
+	 */
19
+	public function algorithmParamValue(): string
20
+	{
21
+		return JWA::ALGO_RSA1_5;
22
+	}
23 23
 
24
-    /**
25
-     * {@inheritdoc}
26
-     */
27
-    protected function _paddingScheme(): int
28
-    {
29
-        return OPENSSL_PKCS1_PADDING;
30
-    }
24
+	/**
25
+	 * {@inheritdoc}
26
+	 */
27
+	protected function _paddingScheme(): int
28
+	{
29
+		return OPENSSL_PKCS1_PADDING;
30
+	}
31 31
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWE\KeyAlgorithm;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWE/KeyAlgorithm/A256KWAlgorithm.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -15,27 +15,27 @@
 block discarded – undo
15 15
  */
16 16
 class A256KWAlgorithm extends AESKWAlgorithm
17 17
 {
18
-    /**
19
-     * {@inheritdoc}
20
-     */
21
-    public function algorithmParamValue(): string
22
-    {
23
-        return JWA::ALGO_A256KW;
24
-    }
18
+	/**
19
+	 * {@inheritdoc}
20
+	 */
21
+	public function algorithmParamValue(): string
22
+	{
23
+		return JWA::ALGO_A256KW;
24
+	}
25 25
 
26
-    /**
27
-     * {@inheritdoc}
28
-     */
29
-    protected function _kekSize(): int
30
-    {
31
-        return 32;
32
-    }
26
+	/**
27
+	 * {@inheritdoc}
28
+	 */
29
+	protected function _kekSize(): int
30
+	{
31
+		return 32;
32
+	}
33 33
 
34
-    /**
35
-     * {@inheritdoc}
36
-     */
37
-    protected function _AESKWAlgo(): AESKeyWrapAlgorithm
38
-    {
39
-        return new AESKW256();
40
-    }
34
+	/**
35
+	 * {@inheritdoc}
36
+	 */
37
+	protected function _AESKWAlgo(): AESKeyWrapAlgorithm
38
+	{
39
+		return new AESKW256();
40
+	}
41 41
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWE\KeyAlgorithm;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWE/KeyAlgorithm/PBES2HS384A192KWAlgorithm.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -15,35 +15,35 @@
 block discarded – undo
15 15
  */
16 16
 class PBES2HS384A192KWAlgorithm extends PBES2Algorithm
17 17
 {
18
-    /**
19
-     * {@inheritdoc}
20
-     */
21
-    public function algorithmParamValue(): string
22
-    {
23
-        return JWA::ALGO_PBES2_HS384_A192KW;
24
-    }
18
+	/**
19
+	 * {@inheritdoc}
20
+	 */
21
+	public function algorithmParamValue(): string
22
+	{
23
+		return JWA::ALGO_PBES2_HS384_A192KW;
24
+	}
25 25
 
26
-    /**
27
-     * {@inheritdoc}
28
-     */
29
-    protected function _hashAlgo(): string
30
-    {
31
-        return 'sha384';
32
-    }
26
+	/**
27
+	 * {@inheritdoc}
28
+	 */
29
+	protected function _hashAlgo(): string
30
+	{
31
+		return 'sha384';
32
+	}
33 33
 
34
-    /**
35
-     * {@inheritdoc}
36
-     */
37
-    protected function _keyLength(): int
38
-    {
39
-        return 24;
40
-    }
34
+	/**
35
+	 * {@inheritdoc}
36
+	 */
37
+	protected function _keyLength(): int
38
+	{
39
+		return 24;
40
+	}
41 41
 
42
-    /**
43
-     * {@inheritdoc}
44
-     */
45
-    protected function _kwAlgo(): AESKeyWrapAlgorithm
46
-    {
47
-        return new AESKW192();
48
-    }
42
+	/**
43
+	 * {@inheritdoc}
44
+	 */
45
+	protected function _kwAlgo(): AESKeyWrapAlgorithm
46
+	{
47
+		return new AESKW192();
48
+	}
49 49
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWE\KeyAlgorithm;
6 6
 
Please login to merge, or discard this patch.