RSA: CS adjustments

This commit is contained in:
terrafrost 2015-10-01 16:11:23 -05:00
parent 5bddb49c62
commit fd99814e79
6 changed files with 43 additions and 43 deletions

View File

@ -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;
}
}
}

View File

@ -170,4 +170,4 @@ class PKCS1 extends PKCS
return $RSAPublicKey;
}
}
}

View File

@ -206,4 +206,4 @@ class PKCS8 extends PKCS
return $RSAPublicKey;
}
}
}

View File

@ -249,4 +249,4 @@ class PuTTY
return $key;
}
}
}

View File

@ -90,4 +90,4 @@ class Raw
{
return array('e' => clone $e, 'n' => clone $n);
}
}
}

View File

@ -139,4 +139,4 @@ class XML
' <Exponent>' . base64_encode($e->toBytes()) . "</Exponent>\r\n" .
'</RSAKeyValue>';
}
}
}