Update CryptoTest.php

pull/6286/head
Shlee 11 months ago committed by GitHub
parent 0e0f3b9e95
commit 5d8e5b64aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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

Loading…
Cancel
Save