1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-11-27 04:46:26 +01:00

RSA: add unit test

This commit is contained in:
terrafrost 2014-09-08 22:26:14 -05:00
parent 713393c8ad
commit 4329015629

View File

@ -259,4 +259,24 @@ Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB
$this->assertGreaterThanOrEqual(1, strlen("$rsa")); $this->assertGreaterThanOrEqual(1, strlen("$rsa"));
$this->assertFalse($rsa->getPublicKey()); $this->assertFalse($rsa->getPublicKey());
} }
/**
* make phpseclib generated XML keys be unsigned. this may need to be reverted
* if it is later learned that XML keys are, in fact, supposed to be signed
* @group github468
*/
public function testUnsignedXML()
{
$rsa = new Crypt_RSA();
$key = '<RSAKeyValue>
<Modulus>v5OxcEgxPUfa701NpxnScCmlRkbwSGBiTWobHkIWZEB+AlRTHaVoZg/D8l6YzR7VdQidG6gF+nuUMjY75dBXgY/XcyVq0Hccf1jTfgARuNuq4GGG3hnCJVi2QsOgcf9R7TeXn+p1RKIhjQoWCiEQeEBTotNbJhcabNcPGSEJw+s=</Modulus>
<Exponent>AQAB</Exponent>
</RSAKeyValue>';
$rsa->loadKey($key);
$newkey = $rsa->getPublicKey(CRYPT_RSA_PUBLIC_FORMAT_XML);
$this->assertSame($key, $newkey);
}
} }