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

RSA: fixes to last non-merge commit

This commit is contained in:
terrafrost 2015-10-16 10:31:43 -05:00
parent a9705fdba7
commit ad55d3cd75
6 changed files with 22 additions and 4 deletions

View File

@ -1009,6 +1009,7 @@ class RSA
* @see self::getPrivateKey()
* @access private
* @param string $type optional
* @return mixed
*/
function _getPrivatePublicKey($type = 'PKCS8')
{
@ -2177,4 +2178,4 @@ class RSA
return $this->_rsassa_pss_verify($message, $signature);
}
}
}
}

View File

@ -56,6 +56,10 @@ class OpenSSH
*/
static function load($key, $password = '')
{
if (!is_string($key)) {
return false;
}
$parts = explode(' ', $key, 3);
$key = isset($parts[1]) ? base64_decode($parts[1]) : false;

View File

@ -134,6 +134,10 @@ abstract class PKCS
*/
static function load($key, $password = '')
{
if (!is_string($key)) {
return false;
}
$components = array('isPublicKey' => strpos($key, 'PUBLIC') !== false);
/* Although PKCS#1 proposes a format that public and private keys can use, encrypting them is

View File

@ -76,6 +76,10 @@ class PuTTY
*/
static function load($key, $password = '')
{
if (!is_string($key)) {
return false;
}
static $one;
if (!isset($one)) {
$one = new BigInteger(1);
@ -88,7 +92,7 @@ class PuTTY
return false;
}
$encryption = trim(preg_replace('#Encryption: (.+)#', '$1', $key[1]));
$comment = trim(preg_replace('#Comment: (.+)#', '$1', $key[2]));
$components['comment'] = trim(preg_replace('#Comment: (.+)#', '$1', $key[2]));
$publicLength = trim(preg_replace('#Public-Lines: (\d+)#', '$1', $key[3]));
$public = base64_decode(implode('', array_map('trim', array_slice($key, 4, $publicLength))));

View File

@ -40,6 +40,10 @@ class XML
*/
static function load($key, $password = '')
{
if (!is_string($key)) {
return false;
}
$components = array(
'isPublicKey' => false,
'primes' => array(),

View File

@ -7,6 +7,7 @@
use phpseclib\Crypt\RSA;
use phpseclib\Crypt\RSA\PKCS1;
use phpseclib\Crypt\RSA\PuTTY;
use phpseclib\Math\BigInteger;
class Unit_Crypt_RSA_LoadKeyTest extends PhpseclibTestCase
@ -368,8 +369,8 @@ Private-MAC: 03e2cb74e1d67652fbad063d2ed0478f31bdf256
$rsa = new RSA();
$key = array(
'e' => BigInteger('10001', 16),
'n' => BigInteger('aa18aba43b50deef38598faf87d2ab634e4571c130a9bca7b878267414faab8b471bd8965f5c9fc3' .
'e' => new BigInteger('10001', 16),
'n' => new BigInteger('aa18aba43b50deef38598faf87d2ab634e4571c130a9bca7b878267414faab8b471bd8965f5c9fc3' .
'818485eaf529c26246f3055064a8de19c8c338be5496cbaeb059dc0b358143b44a35449eb2641131' .
'21a455bd7fde3fac919e94b56fb9bb4f651cdb23ead439d6cd523eb08191e75b35fd13a7419b3090' .
'f24787bd4f4e1967', 16)