Update CryptoTest.php

pull/6286/head
Shlee 1 week 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;
use phpseclib\Crypt\RSA;
use phpseclib3\Crypt\PublicKeyLoader;
use phpseclib3\Crypt\RSA;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
@ -16,20 +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();
$keys = $rsa->createKey();
$privatekey = $keys['privatekey'];
$publickey = $keys['publickey'];
$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