From 4e9795b8b44cf898b46b430a7d98cb75d79c7348 Mon Sep 17 00:00:00 2001 From: Spomky Date: Tue, 26 Oct 2021 13:24:24 +0200 Subject: [PATCH] spomky-labs/base64url removed in favor of paragonie/constant_time_encoding --- ECDHES.php | 12 ++++++------ Util/ConcatKDF.php | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ECDHES.php b/ECDHES.php index c9b4668..c95ec3e 100644 --- a/ECDHES.php +++ b/ECDHES.php @@ -14,7 +14,7 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use function array_key_exists; -use Base64Url\Base64Url; +use ParagonIE\ConstantTime\Base64UrlSafe; use Brick\Math\BigInteger; use function extension_loaded; use function function_exists; @@ -90,8 +90,8 @@ public function calculateAgreementKey(JWK $private_key, JWK $public_key): string return $this->convertDecToBin(EcDH::computeSharedKey($curve, $pub_key, $priv_key)); case 'X25519': - $sKey = Base64Url::decode($private_key->get('d')); - $recipientPublickey = Base64Url::decode($public_key->get('x')); + $sKey = Base64UrlSafe::decode($private_key->get('d')); + $recipientPublickey = Base64UrlSafe::decode($public_key->get('x')); return sodium_crypto_scalarmult($sKey, $recipientPublickey); @@ -234,7 +234,7 @@ private function getCurve(string $crv): Curve private function convertBase64ToBigInteger(string $value): BigInteger { - $data = unpack('H*', Base64Url::decode($value)); + $data = unpack('H*', Base64UrlSafe::decode($value)); if (!is_array($data) || !isset($data[1])) { throw new InvalidArgumentException('Unable to convert base64 to integer'); } @@ -295,8 +295,8 @@ private function createOKPKey(string $curve): JWK return new JWK([ 'kty' => 'OKP', 'crv' => $curve, - 'x' => Base64Url::encode($x), - 'd' => Base64Url::encode($d), + 'x' => Base64UrlSafe::encodeUnpadded($x), + 'd' => Base64UrlSafe::encodeUnpadded($d), ]); } diff --git a/Util/ConcatKDF.php b/Util/ConcatKDF.php index c53d22a..2c04248 100644 --- a/Util/ConcatKDF.php +++ b/Util/ConcatKDF.php @@ -13,7 +13,7 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption\Util; -use Base64Url\Base64Url; +use ParagonIE\ConstantTime\Base64UrlSafe; use InvalidArgumentException; /** @@ -34,8 +34,8 @@ class ConcatKDF */ public static function generate(string $Z, string $algorithm, int $encryption_key_size, string $apu = '', string $apv = ''): string { - $apu = !self::isEmpty($apu) ? Base64Url::decode($apu) : ''; - $apv = !self::isEmpty($apv) ? Base64Url::decode($apv) : ''; + $apu = !self::isEmpty($apu) ? Base64UrlSafe::decode($apu) : ''; + $apv = !self::isEmpty($apv) ? Base64UrlSafe::decode($apv) : ''; $encryption_segments = [ self::toInt32Bits(1), // Round number 1 $Z, // Z (shared secret)