mirror of
https://github.com/danog/tgseclib.git
synced 2024-11-27 04:34:45 +01:00
RSA: CS adjustments
This commit is contained in:
parent
5bddb49c62
commit
fd99814e79
@ -56,48 +56,48 @@ class OpenSSH
|
||||
*/
|
||||
static function load($key, $password = '')
|
||||
{
|
||||
$parts = explode(' ', $key, 3);
|
||||
$parts = explode(' ', $key, 3);
|
||||
|
||||
$key = isset($parts[1]) ? base64_decode($parts[1]) : false;
|
||||
if ($key === false) {
|
||||
return false;
|
||||
}
|
||||
$key = isset($parts[1]) ? base64_decode($parts[1]) : false;
|
||||
if ($key === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$comment = isset($parts[2]) ? $parts[2] : false;
|
||||
$comment = isset($parts[2]) ? $parts[2] : false;
|
||||
|
||||
$cleanup = substr($key, 0, 11) == "\0\0\0\7ssh-rsa";
|
||||
$cleanup = substr($key, 0, 11) == "\0\0\0\7ssh-rsa";
|
||||
|
||||
if (strlen($key) <= 4) {
|
||||
return false;
|
||||
}
|
||||
extract(unpack('Nlength', self::_string_shift($key, 4)));
|
||||
$publicExponent = new BigInteger(self::_string_shift($key, $length), -256);
|
||||
if (strlen($key) <= 4) {
|
||||
return false;
|
||||
}
|
||||
extract(unpack('Nlength', self::_string_shift($key, 4)));
|
||||
$modulus = new BigInteger(self::_string_shift($key, $length), -256);
|
||||
if (strlen($key) <= 4) {
|
||||
return false;
|
||||
}
|
||||
extract(unpack('Nlength', self::_string_shift($key, 4)));
|
||||
$publicExponent = new BigInteger(self::_string_shift($key, $length), -256);
|
||||
if (strlen($key) <= 4) {
|
||||
return false;
|
||||
}
|
||||
extract(unpack('Nlength', self::_string_shift($key, 4)));
|
||||
$modulus = new BigInteger(self::_string_shift($key, $length), -256);
|
||||
|
||||
if ($cleanup && strlen($key)) {
|
||||
if (strlen($key) <= 4) {
|
||||
return false;
|
||||
}
|
||||
extract(unpack('Nlength', self::_string_shift($key, 4)));
|
||||
$realModulus = new BigInteger(self::_string_shift($key, $length), -256);
|
||||
return strlen($key) ? false : array(
|
||||
'isPublicKey' => true,
|
||||
'modulus' => $realModulus,
|
||||
'publicExponent' => $modulus,
|
||||
'comment' => $comment
|
||||
);
|
||||
} else {
|
||||
return strlen($key) ? false : array(
|
||||
'isPublicKey' => true,
|
||||
'modulus' => $modulus,
|
||||
'publicExponent' => $publicExponent,
|
||||
'comment' => $comment
|
||||
);
|
||||
}
|
||||
if ($cleanup && strlen($key)) {
|
||||
if (strlen($key) <= 4) {
|
||||
return false;
|
||||
}
|
||||
extract(unpack('Nlength', self::_string_shift($key, 4)));
|
||||
$realModulus = new BigInteger(self::_string_shift($key, $length), -256);
|
||||
return strlen($key) ? false : array(
|
||||
'isPublicKey' => true,
|
||||
'modulus' => $realModulus,
|
||||
'publicExponent' => $modulus,
|
||||
'comment' => $comment
|
||||
);
|
||||
} else {
|
||||
return strlen($key) ? false : array(
|
||||
'isPublicKey' => true,
|
||||
'modulus' => $modulus,
|
||||
'publicExponent' => $publicExponent,
|
||||
'comment' => $comment
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,4 +139,4 @@ class OpenSSH
|
||||
$string = substr($string, $index);
|
||||
return $substr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,4 +170,4 @@ class PKCS1 extends PKCS
|
||||
|
||||
return $RSAPublicKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,4 +206,4 @@ class PKCS8 extends PKCS
|
||||
|
||||
return $RSAPublicKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -249,4 +249,4 @@ class PuTTY
|
||||
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,4 +90,4 @@ class Raw
|
||||
{
|
||||
return array('e' => clone $e, 'n' => clone $n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,4 +139,4 @@ class XML
|
||||
' <Exponent>' . base64_encode($e->toBytes()) . "</Exponent>\r\n" .
|
||||
'</RSAKeyValue>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user