Merge pull request #6286 from pixelfed/shleeable-patch-17

Refactor: Update Crypto to phpseclib3 - Low risk
pull/6311/head^2
dansup 5 days ago committed by GitHub
commit b7813cca7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -34,7 +34,7 @@
"league/oauth2-client": "^2.8",
"league/uri": "^7.4",
"pbmedia/laravel-ffmpeg": "^8.0",
"phpseclib/phpseclib": "~2.0",
"phpseclib/phpseclib": "~3.0",
"pixelfed/fractal": "^0.18.0",
"pixelfed/laravel-snowflake": "^2.0",
"pragmarx/google2fa": "^8.0",

@ -2,7 +2,8 @@
namespace Tests\Unit;
use phpseclib\Crypt\RSA;
use phpseclib3\Crypt\PublicKeyLoader;
use phpseclib3\Crypt\RSA;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
@ -16,18 +17,18 @@ class CryptoTest extends TestCase
#[Test]
public function libraryInstalled()
{
$this->assertTrue(class_exists('\phpseclib\Crypt\RSA'));
$this->assertTrue(class_exists('\phpseclib3\Crypt\RSA'));
}
#[Test]
public function RSASigning()
{
$rsa = new RSA();
extract($rsa->createKey());
$rsa->loadKey($privatekey);
$private = RSA::createKey();
$publicKey = $private->getPublicKey();
$plaintext = 'pixelfed rsa test';
$signature = $rsa->sign($plaintext);
$rsa->loadKey($publickey);
$this->assertTrue($rsa->verify($plaintext, $signature));
$signature = $private->sign($plaintext);
$this->assertTrue($publicKey->verify($plaintext, $signature));
}
}

Loading…
Cancel
Save