Skip to content

Commit

Permalink
spomky-labs/base64url removed in favor of paragonie/constant_time_enc…
Browse files Browse the repository at this point in the history
…oding
  • Loading branch information
Spomky committed Oct 26, 2021
1 parent 736c2c5 commit 4e9795b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions ECDHES.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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),
]);
}

Expand Down
6 changes: 3 additions & 3 deletions Util/ConcatKDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Jose\Component\Encryption\Algorithm\KeyEncryption\Util;

use Base64Url\Base64Url;
use ParagonIE\ConstantTime\Base64UrlSafe;
use InvalidArgumentException;

/**
Expand All @@ -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)
Expand Down

0 comments on commit 4e9795b

Please sign in to comment.