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

RSA: update unit test file

This commit is contained in:
terrafrost 2014-04-18 11:41:08 -05:00
parent 317efaf28a
commit d9d224572b

View File

@ -36,7 +36,8 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=
-----END RSA PRIVATE KEY-----';
$this->assertTrue($rsa->loadKey($key) && is_string($rsa->getPrivateKey()));
$this->assertTrue($rsa->loadKey($key));
$this->assertInternalType('string', $rsa->getPrivateKey());
}
public function testPKCS1SpacesKey()
@ -58,7 +59,8 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
-----END RSA PRIVATE KEY-----';
$key = str_replace(array("\r", "\n", "\r\n"), ' ', $key);
$this->assertTrue($rsa->loadKey($key) && is_string($rsa->getPrivateKey()));
$this->assertTrue($rsa->loadKey($key));
$this->assertInternalType('string', $rsa->getPrivateKey());
}
public function testPKCS1NoHeaderKey()
@ -77,7 +79,8 @@ X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl
U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=';
$this->assertTrue($rsa->loadKey($key) && is_string($rsa->getPrivateKey()));
$this->assertTrue($rsa->loadKey($key));
$this->assertInternalType('string', $rsa->getPrivateKey());
}
public function testPKCS1NoWhitespaceNoHeaderKey()
@ -95,7 +98,9 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
'X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl' .
'U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ' .
'37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=';
$this->assertTrue($rsa->loadKey($key) && is_string($rsa->getPrivateKey()));
$this->assertTrue($rsa->loadKey($key));
$this->assertInternalType('string', $rsa->getPrivateKey());
}
public function testRawPKCS1Key()
@ -115,7 +120,8 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
'37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=';
$key = base64_decode($key);
$this->assertTrue($rsa->loadKey($key) && is_string($rsa->getPrivateKey()));
$this->assertTrue($rsa->loadKey($key));
$this->assertInternalType('string', $rsa->getPrivateKey());
}
public function testPubKey1()
@ -131,7 +137,9 @@ gPiUWOPatVkt7+Bs3h5Ramxh7XjBOXeulmCpGSynXNcpZ/06+vofGi/2MlpQZNhH
Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB
-----END RSA PUBLIC KEY-----';
$this->assertTrue($rsa->loadKey($key) && is_string($rsa->getPublicKey()) && $rsa->getPrivateKey() === false);
$this->assertTrue($rsa->loadKey($key));
$this->assertInternalType('string', $rsa->getPublicKey());
$this->assertFalse($rsa->getPrivateKey());
}
public function testPubKey2()
@ -148,10 +156,12 @@ lmCpGSynXNcpZ/06+vofGi/2MlpQZNhHAo8eayMp6FcvNucIpUndo1X8dKMv3Y26
ZQIDAQAB
-----END PUBLIC KEY-----';
$this->assertTrue($rsa->loadKey($key) && is_string($rsa->getPublicKey()) && $rsa->getPrivateKey() === false);
$this->assertTrue($rsa->loadKey($key));
$this->assertInternalType('string', $rsa->getPublicKey());
$this->assertFalse($rsa->getPrivateKey());
}
public function testPubKey3()
public function testSSHPubKey()
{
$rsa = new Crypt_RSA();
@ -160,7 +170,9 @@ ZQIDAQAB
'GkVb1/3j+skZ6UtW+5u09lHNsj6tQ51s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZw== ' .
'phpseclib-generated-key';
$this->assertTrue($rsa->loadKey($key) && is_string($rsa->getPublicKey()) && $rsa->getPrivateKey() === false);
$this->assertTrue($rsa->loadKey($key));
$this->assertInternalType('string', $rsa->getPublicKey());
$this->assertFalse($rsa->getPrivateKey());
}
public function testSetPrivate()
@ -176,6 +188,9 @@ gPiUWOPatVkt7+Bs3h5Ramxh7XjBOXeulmCpGSynXNcpZ/06+vofGi/2MlpQZNhH
Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB
-----END RSA PUBLIC KEY-----';
$this->assertTrue($rsa->loadKey($key) && $rsa->setPrivateKey() && is_string("$rsa") && $rsa->getPublicKey() === false);
$this->assertTrue($rsa->loadKey($key));
$this->assertTrue($rsa->setPrivateKey());
$this->assertGreaterThanOrEqual(1, strlen("$rsa"));
$this->assertFalse($rsa->getPublicKey());
}
}