Skip to content

Commit 10727f1

Browse files
committed
Fix ECS
1 parent 0eece81 commit 10727f1

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

src/Component/Encryption/JWEBuilder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,11 @@ private function determineCEK(array &$additionalHeader): string
434434
}
435435

436436
switch ($this->keyManagementMode) {
437-
case KeyEncryption::MODE_ENCRYPT :
438-
case KeyEncryption::MODE_WRAP :
437+
case KeyEncryption::MODE_ENCRYPT:
438+
case KeyEncryption::MODE_WRAP:
439439
return $this->createCEK($this->contentEncryptionAlgorithm->getCEKSize());
440440

441-
case KeyEncryption::MODE_AGREEMENT :
441+
case KeyEncryption::MODE_AGREEMENT:
442442
if (count($this->recipients) !== 1) {
443443
throw new LogicException(
444444
'Unable to encrypt for multiple recipients using key agreement algorithms.'
@@ -465,7 +465,7 @@ private function determineCEK(array &$additionalHeader): string
465465
$additionalHeader
466466
);
467467

468-
case KeyEncryption::MODE_DIRECT :
468+
case KeyEncryption::MODE_DIRECT:
469469
if (count($this->recipients) !== 1) {
470470
throw new LogicException(
471471
'Unable to encrypt for multiple recipients using key agreement algorithms.'
@@ -483,7 +483,7 @@ private function determineCEK(array &$additionalHeader): string
483483

484484
return Base64UrlSafe::decodeNoPadding($k);
485485

486-
default :
486+
default:
487487
throw new InvalidArgumentException(sprintf(
488488
'Unsupported key management mode "%s".',
489489
$this->keyManagementMode

src/EncryptionAlgorithm/KeyEncryption/ECDHES/AbstractECDH.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ protected function calculateAgreementKey(JWK $private_key, JWK $public_key): str
7979
throw new InvalidArgumentException('Invalid key parameter "crv"');
8080
}
8181
switch ($crv) {
82-
case 'P-256' :
83-
case 'P-384' :
84-
case 'P-521' :
82+
case 'P-256':
83+
case 'P-384':
84+
case 'P-521':
8585
$curve = $this->getCurve($crv);
8686
if (function_exists('openssl_pkey_derive')) {
8787
try {
@@ -120,7 +120,7 @@ protected function calculateAgreementKey(JWK $private_key, JWK $public_key): str
120120

121121
return $this->convertDecToBin(EcDH::computeSharedKey($curve, $pub_key, $priv_key));
122122

123-
case 'X25519' :
123+
case 'X25519':
124124
$x = $public_key->get('x');
125125
if (! is_string($x)) {
126126
throw new InvalidArgumentException('Invalid key parameter "x"');
@@ -134,7 +134,7 @@ protected function calculateAgreementKey(JWK $private_key, JWK $public_key): str
134134

135135
return sodium_crypto_scalarmult($sKey, $recipientPublickey);
136136

137-
default :
137+
default:
138138
throw new InvalidArgumentException(sprintf('The curve "%s" is not supported', $crv));
139139
}
140140
}
@@ -156,20 +156,20 @@ protected function getKeysFromPublicKey(
156156
throw new InvalidArgumentException('Invalid key parameter "crv"');
157157
}
158158
switch ($crv) {
159-
case 'P-256' :
160-
case 'P-384' :
161-
case 'P-521' :
159+
case 'P-256':
160+
case 'P-384':
161+
case 'P-521':
162162
$private_key = $senderKey ?? ECKey::createECKey($crv);
163163

164164
break;
165165

166-
case 'X25519' :
166+
case 'X25519':
167167
$this->checkSodiumExtensionIsAvailable();
168168
$private_key = $senderKey ?? $this->createOKPKey('X25519');
169169

170170
break;
171171

172-
default :
172+
default:
173173
throw new InvalidArgumentException(sprintf('The curve "%s" is not supported', $crv));
174174
}
175175
$epk = $private_key->toPublic()
@@ -228,19 +228,19 @@ private function checkKey(JWK $key, bool $is_private): void
228228
throw new InvalidArgumentException('Invalid key parameter "crv"');
229229
}
230230
switch ($crv) {
231-
case 'P-256' :
232-
case 'P-384' :
233-
case 'P-521' :
231+
case 'P-256':
232+
case 'P-384':
233+
case 'P-521':
234234
if (! $key->has('y')) {
235235
throw new InvalidArgumentException('The key parameter "y" is missing.');
236236
}
237237

238238
break;
239239

240-
case 'X25519' :
240+
case 'X25519':
241241
break;
242242

243-
default :
243+
default:
244244
throw new InvalidArgumentException(sprintf('The curve "%s" is not supported', $crv));
245245
}
246246
if ($is_private === true && ! $key->has('d')) {
@@ -295,14 +295,14 @@ private function createOKPKey(string $curve): JWK
295295
$this->checkSodiumExtensionIsAvailable();
296296

297297
switch ($curve) {
298-
case 'X25519' :
298+
case 'X25519':
299299
$keyPair = sodium_crypto_box_keypair();
300300
$d = sodium_crypto_box_secretkey($keyPair);
301301
$x = sodium_crypto_box_publickey($keyPair);
302302

303303
break;
304304

305-
case 'Ed25519' :
305+
case 'Ed25519':
306306
$keyPair = sodium_crypto_sign_keypair();
307307
$secret = sodium_crypto_sign_secretkey($keyPair);
308308
$secretLength = mb_strlen($secret, '8bit');
@@ -311,7 +311,7 @@ private function createOKPKey(string $curve): JWK
311311

312312
break;
313313

314-
default :
314+
default:
315315
throw new InvalidArgumentException(sprintf('Unsupported "%s" curve', $curve));
316316
}
317317

0 commit comments

Comments
 (0)