mirror of
https://github.com/friendica/friendica
synced 2025-04-29 10:24:23 +02:00
[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:
parent
a3fb499735
commit
55640eec87
13 changed files with 241 additions and 173 deletions
|
@ -25,9 +25,11 @@ use Friendica\Core\Logger;
|
|||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\Salmon\Format\Magic;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\XML;
|
||||
use phpseclib3\Crypt\PublicKeyLoader;
|
||||
|
||||
/**
|
||||
* Salmon Protocol class
|
||||
|
@ -243,7 +245,19 @@ class Salmon
|
|||
*/
|
||||
public static function salmonKey(string $pubkey): string
|
||||
{
|
||||
Crypto::pemToMe($pubkey, $modulus, $exponent);
|
||||
return 'RSA' . '.' . Strings::base64UrlEncode($modulus, true) . '.' . Strings::base64UrlEncode($exponent, true);
|
||||
\phpseclib3\Crypt\RSA::addFileFormat(Magic::class);
|
||||
|
||||
return PublicKeyLoader::load($pubkey)->toString('Magic');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $magic Magic key format starting with "RSA."
|
||||
* @return string
|
||||
*/
|
||||
public static function magicKeyToPem(string $magic): string
|
||||
{
|
||||
\phpseclib3\Crypt\RSA::addFileFormat(Magic::class);
|
||||
|
||||
return (string) PublicKeyLoader::load($magic);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue