[Composer] Upgrade to phpseclib version 3

- Create custom Key file format for Salmon Magic key
- Remove obsolete pemToME and MEtoPem Crypto methods
- Remove unused newECKeypair Crypto method
- Switch to constant-time Base64 encode/decode in Base64Url Strings methods
This commit is contained in:
Hypolite Petovan 2022-11-23 13:45:58 -05:00
parent a3fb499735
commit 55640eec87
13 changed files with 241 additions and 173 deletions

View file

@ -142,14 +142,9 @@ class Salmon extends \Friendica\BaseModule
throw new HTTPException\BadRequestException();
}
$key_info = explode('.', $key);
$this->logger->info('Key details', ['info' => $key]);
$m = Strings::base64UrlDecode($key_info[1]);
$e = Strings::base64UrlDecode($key_info[2]);
$this->logger->info('Key details', ['info' => $key_info]);
$pubkey = Crypto::meToPem($m, $e);
$pubkey = SalmonProtocol::magicKeyToPem($key);
// We should have everything we need now. Let's see if it verifies.

View file

@ -23,11 +23,9 @@ namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Util\Crypto;
use Friendica\Util\Strings;
use Friendica\Protocol\Salmon;
/**
* prints the public RSA key of a user
@ -47,9 +45,10 @@ class PublicRSAKey extends BaseModule
throw new BadRequestException();
}
Crypto::pemToMe($user['spubkey'], $modulus, $exponent);
$content = 'RSA' . '.' . Strings::base64UrlEncode($modulus, true) . '.' . Strings::base64UrlEncode($exponent, true);
System::httpExit($content, Response::TYPE_BLANK, 'application/magic-public-key');
System::httpExit(
Salmon::salmonKey($user['spubkey']),
Response::TYPE_BLANK,
'application/magic-public-key'
);
}
}