From fd99814e7921a737ea8c5b8645261808859ba0f5 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 1 Oct 2015 16:11:23 -0500 Subject: [PATCH] RSA: CS adjustments --- phpseclib/Crypt/RSA/OpenSSH.php | 76 ++++++++++++++++----------------- phpseclib/Crypt/RSA/PKCS1.php | 2 +- phpseclib/Crypt/RSA/PKCS8.php | 2 +- phpseclib/Crypt/RSA/PuTTY.php | 2 +- phpseclib/Crypt/RSA/Raw.php | 2 +- phpseclib/Crypt/RSA/XML.php | 2 +- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/phpseclib/Crypt/RSA/OpenSSH.php b/phpseclib/Crypt/RSA/OpenSSH.php index a52f7bab..96af6485 100644 --- a/phpseclib/Crypt/RSA/OpenSSH.php +++ b/phpseclib/Crypt/RSA/OpenSSH.php @@ -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; } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/RSA/PKCS1.php b/phpseclib/Crypt/RSA/PKCS1.php index 454c3dfa..8ce8b115 100644 --- a/phpseclib/Crypt/RSA/PKCS1.php +++ b/phpseclib/Crypt/RSA/PKCS1.php @@ -170,4 +170,4 @@ class PKCS1 extends PKCS return $RSAPublicKey; } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/RSA/PKCS8.php b/phpseclib/Crypt/RSA/PKCS8.php index aa35409a..84a473d3 100644 --- a/phpseclib/Crypt/RSA/PKCS8.php +++ b/phpseclib/Crypt/RSA/PKCS8.php @@ -206,4 +206,4 @@ class PKCS8 extends PKCS return $RSAPublicKey; } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/RSA/PuTTY.php b/phpseclib/Crypt/RSA/PuTTY.php index 95734fc1..014eaa47 100644 --- a/phpseclib/Crypt/RSA/PuTTY.php +++ b/phpseclib/Crypt/RSA/PuTTY.php @@ -249,4 +249,4 @@ class PuTTY return $key; } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/RSA/Raw.php b/phpseclib/Crypt/RSA/Raw.php index 51cfca6b..47ebc3a0 100644 --- a/phpseclib/Crypt/RSA/Raw.php +++ b/phpseclib/Crypt/RSA/Raw.php @@ -90,4 +90,4 @@ class Raw { return array('e' => clone $e, 'n' => clone $n); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/RSA/XML.php b/phpseclib/Crypt/RSA/XML.php index f3a57ea7..b2ae953b 100644 --- a/phpseclib/Crypt/RSA/XML.php +++ b/phpseclib/Crypt/RSA/XML.php @@ -139,4 +139,4 @@ class XML ' ' . base64_encode($e->toBytes()) . "\r\n" . ''; } -} \ No newline at end of file +}