mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-02-13 17:18:42 +00:00
RSA: fixes to last non-merge commit
This commit is contained in:
parent
a9705fdba7
commit
ad55d3cd75
@ -1009,6 +1009,7 @@ class RSA
|
|||||||
* @see self::getPrivateKey()
|
* @see self::getPrivateKey()
|
||||||
* @access private
|
* @access private
|
||||||
* @param string $type optional
|
* @param string $type optional
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function _getPrivatePublicKey($type = 'PKCS8')
|
function _getPrivatePublicKey($type = 'PKCS8')
|
||||||
{
|
{
|
||||||
|
@ -56,6 +56,10 @@ class OpenSSH
|
|||||||
*/
|
*/
|
||||||
static function load($key, $password = '')
|
static function load($key, $password = '')
|
||||||
{
|
{
|
||||||
|
if (!is_string($key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$parts = explode(' ', $key, 3);
|
$parts = explode(' ', $key, 3);
|
||||||
|
|
||||||
$key = isset($parts[1]) ? base64_decode($parts[1]) : false;
|
$key = isset($parts[1]) ? base64_decode($parts[1]) : false;
|
||||||
|
@ -134,6 +134,10 @@ abstract class PKCS
|
|||||||
*/
|
*/
|
||||||
static function load($key, $password = '')
|
static function load($key, $password = '')
|
||||||
{
|
{
|
||||||
|
if (!is_string($key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$components = array('isPublicKey' => strpos($key, 'PUBLIC') !== false);
|
$components = array('isPublicKey' => strpos($key, 'PUBLIC') !== false);
|
||||||
|
|
||||||
/* Although PKCS#1 proposes a format that public and private keys can use, encrypting them is
|
/* Although PKCS#1 proposes a format that public and private keys can use, encrypting them is
|
||||||
|
@ -76,6 +76,10 @@ class PuTTY
|
|||||||
*/
|
*/
|
||||||
static function load($key, $password = '')
|
static function load($key, $password = '')
|
||||||
{
|
{
|
||||||
|
if (!is_string($key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static $one;
|
static $one;
|
||||||
if (!isset($one)) {
|
if (!isset($one)) {
|
||||||
$one = new BigInteger(1);
|
$one = new BigInteger(1);
|
||||||
@ -88,7 +92,7 @@ class PuTTY
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$encryption = trim(preg_replace('#Encryption: (.+)#', '$1', $key[1]));
|
$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]));
|
$publicLength = trim(preg_replace('#Public-Lines: (\d+)#', '$1', $key[3]));
|
||||||
$public = base64_decode(implode('', array_map('trim', array_slice($key, 4, $publicLength))));
|
$public = base64_decode(implode('', array_map('trim', array_slice($key, 4, $publicLength))));
|
||||||
|
@ -40,6 +40,10 @@ class XML
|
|||||||
*/
|
*/
|
||||||
static function load($key, $password = '')
|
static function load($key, $password = '')
|
||||||
{
|
{
|
||||||
|
if (!is_string($key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$components = array(
|
$components = array(
|
||||||
'isPublicKey' => false,
|
'isPublicKey' => false,
|
||||||
'primes' => array(),
|
'primes' => array(),
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
use phpseclib\Crypt\RSA;
|
use phpseclib\Crypt\RSA;
|
||||||
use phpseclib\Crypt\RSA\PKCS1;
|
use phpseclib\Crypt\RSA\PKCS1;
|
||||||
|
use phpseclib\Crypt\RSA\PuTTY;
|
||||||
use phpseclib\Math\BigInteger;
|
use phpseclib\Math\BigInteger;
|
||||||
|
|
||||||
class Unit_Crypt_RSA_LoadKeyTest extends PhpseclibTestCase
|
class Unit_Crypt_RSA_LoadKeyTest extends PhpseclibTestCase
|
||||||
@ -368,8 +369,8 @@ Private-MAC: 03e2cb74e1d67652fbad063d2ed0478f31bdf256
|
|||||||
$rsa = new RSA();
|
$rsa = new RSA();
|
||||||
|
|
||||||
$key = array(
|
$key = array(
|
||||||
'e' => BigInteger('10001', 16),
|
'e' => new BigInteger('10001', 16),
|
||||||
'n' => BigInteger('aa18aba43b50deef38598faf87d2ab634e4571c130a9bca7b878267414faab8b471bd8965f5c9fc3' .
|
'n' => new BigInteger('aa18aba43b50deef38598faf87d2ab634e4571c130a9bca7b878267414faab8b471bd8965f5c9fc3' .
|
||||||
'818485eaf529c26246f3055064a8de19c8c338be5496cbaeb059dc0b358143b44a35449eb2641131' .
|
'818485eaf529c26246f3055064a8de19c8c338be5496cbaeb059dc0b358143b44a35449eb2641131' .
|
||||||
'21a455bd7fde3fac919e94b56fb9bb4f651cdb23ead439d6cd523eb08191e75b35fd13a7419b3090' .
|
'21a455bd7fde3fac919e94b56fb9bb4f651cdb23ead439d6cd523eb08191e75b35fd13a7419b3090' .
|
||||||
'f24787bd4f4e1967', 16)
|
'f24787bd4f4e1967', 16)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user