1 | <?php |
||
17 | final class Encrypter implements EncrypterInterface |
||
18 | { |
||
19 | use Behaviour\HasKeyChecker; |
||
20 | use Behaviour\HasJWAManager; |
||
21 | use Behaviour\HasCompressionManager; |
||
22 | use Behaviour\CommonCipheringMethods; |
||
23 | use Behaviour\EncrypterTrait; |
||
24 | |||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | */ |
||
28 | public static function createEncrypter(array $key_encryption_algorithms, array $content_encryption_algorithms, array $compression_methods = ['DEF', 'ZLIB', 'GZ']) |
||
34 | |||
35 | /** |
||
36 | * Decrypter constructor. |
||
37 | * |
||
38 | * @param string[]|\Jose\Algorithm\KeyEncryptionAlgorithmInterface[] $key_encryption_algorithms |
||
39 | * @param string[]|\Jose\Algorithm\ContentEncryptionAlgorithmInterface[] $content_encryption_algorithms |
||
40 | * @param string[]|\Jose\Compression\CompressionInterface[] $compression_methods |
||
41 | */ |
||
42 | public function __construct(array $key_encryption_algorithms, array $content_encryption_algorithms, array $compression_methods) |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | public function encrypt(Object\JWEInterface &$jwe) |
||
75 | |||
76 | /** |
||
77 | * @param \Jose\Object\JWEInterface $jwe |
||
78 | * @param \Jose\Object\RecipientInterface $recipient |
||
79 | * @param string $cek |
||
80 | * @param \Jose\Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm |
||
81 | * @param array $additional_headers |
||
82 | */ |
||
83 | private function processRecipient(Object\JWEInterface $jwe, Object\RecipientInterface &$recipient, $cek, Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm, array &$additional_headers) |
||
100 | |||
101 | /** |
||
102 | * @param \Jose\Object\JWEInterface $jwe |
||
103 | * @param \Jose\Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm |
||
104 | * @param string $cek |
||
105 | * @param string $iv |
||
106 | * @param \Jose\Compression\CompressionInterface|null $compression_method |
||
107 | */ |
||
108 | private function encryptJWE(Object\JWEInterface &$jwe, Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm, $cek, $iv, Compression\CompressionInterface $compression_method = null) |
||
125 | |||
126 | /** |
||
127 | * @param \Jose\Algorithm\KeyEncryptionAlgorithmInterface $key_encryption_algorithm |
||
128 | * @param \Jose\Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm |
||
129 | * @param \Jose\Object\JWKInterface $recipient_key |
||
130 | */ |
||
131 | private function checkKeys(Algorithm\KeyEncryptionAlgorithmInterface $key_encryption_algorithm, Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm, Object\JWKInterface $recipient_key) |
||
140 | |||
141 | /** |
||
142 | * @param string $payload |
||
143 | * @param \Jose\Compression\CompressionInterface|null $compression_method |
||
144 | * |
||
145 | * @return string |
||
146 | */ |
||
147 | private function preparePayload($payload, Compression\CompressionInterface $compression_method = null) |
||
160 | |||
161 | /** |
||
162 | * @param array $complete_headers |
||
163 | * @param string $cek |
||
164 | * @param \Jose\Algorithm\KeyEncryptionAlgorithmInterface $key_encryption_algorithm |
||
165 | * @param \Jose\Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm |
||
166 | * @param \Jose\Object\JWKInterface $recipient_key |
||
167 | * @param array $additional_headers |
||
168 | * |
||
169 | * @return string|null |
||
170 | */ |
||
171 | private function getEncryptedKey(array $complete_headers, $cek, Algorithm\KeyEncryptionAlgorithmInterface $key_encryption_algorithm, Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm, array &$additional_headers, Object\JWKInterface $recipient_key) |
||
181 | |||
182 | /** |
||
183 | * @param array $complete_headers |
||
184 | * @param string $cek |
||
185 | * @param \Jose\Algorithm\KeyEncryption\KeyAgreementWrappingInterface $key_encryption_algorithm |
||
186 | * @param \Jose\Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm |
||
187 | * @param array $additional_headers |
||
188 | * @param \Jose\Object\JWKInterface $recipient_key |
||
189 | * |
||
190 | * @return string |
||
191 | */ |
||
192 | private function getEncryptedKeyFromKeyAgreementAndKeyWrappingAlgorithm(array $complete_headers, $cek, Algorithm\KeyEncryption\KeyAgreementWrappingInterface $key_encryption_algorithm, Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm, array &$additional_headers, Object\JWKInterface $recipient_key) |
||
198 | |||
199 | /** |
||
200 | * @param array $complete_headers |
||
201 | * @param string $cek |
||
202 | * @param \Jose\Algorithm\KeyEncryption\KeyEncryptionInterface $key_encryption_algorithm |
||
203 | * @param \Jose\Object\JWKInterface $recipient_key |
||
204 | * @param array $additional_headers |
||
205 | * |
||
206 | * @return string |
||
207 | */ |
||
208 | private function getEncryptedKeyFromKeyEncryptionAlgorithm(array $complete_headers, $cek, Algorithm\KeyEncryption\KeyEncryptionInterface $key_encryption_algorithm, Object\JWKInterface $recipient_key, array &$additional_headers) |
||
212 | |||
213 | /** |
||
214 | * @param array $complete_headers |
||
215 | * @param string $cek |
||
216 | * @param \Jose\Algorithm\KeyEncryption\KeyWrappingInterface $key_encryption_algorithm |
||
217 | * @param \Jose\Object\JWKInterface $recipient_key |
||
218 | * @param array $additional_headers |
||
219 | * |
||
220 | * @return string |
||
221 | */ |
||
222 | private function getEncryptedKeyFromKeyWrappingAlgorithm(array $complete_headers, $cek, Algorithm\KeyEncryption\KeyWrappingInterface $key_encryption_algorithm, Object\JWKInterface $recipient_key, &$additional_headers) |
||
226 | |||
227 | /** |
||
228 | * @param array $complete_headers |
||
229 | * |
||
230 | * @return \Jose\Algorithm\KeyEncryptionAlgorithmInterface |
||
231 | */ |
||
232 | private function findKeyEncryptionAlgorithm(array $complete_headers) |
||
240 | |||
241 | /** |
||
242 | * @param int $size |
||
243 | * |
||
244 | * @return string |
||
245 | */ |
||
246 | private function createIV($size) |
||
250 | } |
||
251 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: