2015-05-26 05:30:38 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @author Jim Wigginton <terrafrost@php.net>
|
|
|
|
* @copyright 2013 Jim Wigginton
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
*/
|
|
|
|
|
2015-05-26 05:36:10 +02:00
|
|
|
use phpseclib\Crypt\RSA;
|
2015-05-26 05:30:38 +02:00
|
|
|
|
|
|
|
class Unit_Crypt_RSA_ModeTest extends PhpseclibTestCase
|
|
|
|
{
|
|
|
|
public function testEncryptionModeNone()
|
|
|
|
{
|
|
|
|
$plaintext = 'a';
|
|
|
|
|
2015-05-26 05:36:10 +02:00
|
|
|
$rsa = new RSA();
|
2015-05-26 05:30:38 +02:00
|
|
|
|
|
|
|
extract($rsa->createKey());
|
|
|
|
$rsa->loadKey($publickey);
|
|
|
|
|
2015-05-26 05:36:10 +02:00
|
|
|
$rsa->setEncryptionMode(RSA::ENCRYPTION_NONE);
|
2015-05-26 05:30:38 +02:00
|
|
|
$a = $rsa->encrypt($plaintext);
|
|
|
|
$b = $rsa->encrypt($plaintext);
|
|
|
|
|
|
|
|
$this->assertEquals($a, $b);
|
|
|
|
|
|
|
|
$rsa->loadKey($privatekey);
|
|
|
|
$this->assertEquals(trim($rsa->decrypt($a), "\0"), $plaintext);
|
|
|
|
}
|
|
|
|
}
|