/** * @expectedException \LengthException */ public function testSmallModulo() { $plaintext = 'x'; $n = new BigInteger(base64_decode('272435F22706FA96DE26E980D22DFF67'), 256); $e = new BigInteger(base64_decode('158753FF2AF4D1E5BBAB574D5AE6B54D'), 256); $rsa = new RSA(); $rsa->load(array('n' => $n, 'e' => $e)); $rsa->encrypt($plaintext); }
public function testCreateKey() { extract(RSA::createKey(512)); $this->assertInstanceOf('\\phpseclib\\Crypt\\RSA', $privatekey); $this->assertInstanceOf('\\phpseclib\\Crypt\\RSA', $publickey); $this->assertNotEmpty("{$privatekey}"); $this->assertNotEmpty("{$publickey}"); return array($publickey, $privatekey); }
public function testPuttyPublicKey() { $key = '---- BEGIN SSH2 PUBLIC KEY ---- Comment: "rsa-key-20151023" AAAAB3NzaC1yc2EAAAABJQAAAIEAhC/CSqJ+8vgeQ4H7fJru29h/McqAC9zdGzw0 9QsifLQ7s5MvXCavhjUPYIfV0KsdLQydNPLJcbKpXmpVD9azo61zLXwsYr8d1eHr C/EwUYl8b0fAwEsEF3myb+ryzgA9ihY08Zs9NZdmt1Maa+I7lQcLX9F/65YdcAch ILaEujU= ---- END SSH2 PUBLIC KEY ----'; $rsa = new RSA(); $rsa->load($key); $this->assertSame($rsa->getLoadedFormat(), 'PuTTY'); $this->assertGreaterThanOrEqual(1, strlen("{$rsa}")); }