diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index 9ce21b58..c5d314f0 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -117,7 +117,7 @@ class Crypt_Hash { * @var String * @access private */ - var $key = ''; + var $key = false; /** * Outer XOR (Internal HMAC) @@ -170,7 +170,7 @@ class Crypt_Hash { * @access public * @param String $key */ - function setKey($key) + function setKey($key = false) { $this->key = $key; } @@ -296,7 +296,7 @@ class Crypt_Hash { { $mode = is_array($this->hash) ? CRYPT_HASH_MODE_INTERNAL : CRYPT_HASH_MODE; - if (!empty($this->key)) { + if (!empty($this->key) || is_string($this->key)) { switch ( $mode ) { case CRYPT_HASH_MODE_MHASH: $output = mhash($this->hash, $text, $this->key); diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index e63d1bd3..672c6835 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -399,7 +399,7 @@ class Crypt_RSA { * @var String * @access private */ - var $password = ''; + var $password = false; /** * Components @@ -695,7 +695,7 @@ class Crypt_RSA { return false; } $key = "PuTTY-User-Key-File-2: ssh-rsa\r\nEncryption: "; - $encryption = (!empty($this->password)) ? 'aes256-cbc' : 'none'; + $encryption = (!empty($this->password) || is_string($this->password)) ? 'aes256-cbc' : 'none'; $key.= $encryption; $key.= "\r\nComment: " . CRYPT_RSA_COMMENT . "\r\n"; $public = pack('Na*Na*Na*', @@ -712,7 +712,7 @@ class Crypt_RSA { strlen($raw['privateExponent']), $raw['privateExponent'], strlen($raw['prime1']), $raw['prime1'], strlen($raw['prime2']), $raw['prime2'], strlen($raw['coefficient']), $raw['coefficient'] ); - if (empty($this->password)) { + if (empty($this->password) && !is_string($this->password)) { $source.= pack('Na*', strlen($private), $private); $hashkey = 'putty-private-key-file-mac-key'; } else { @@ -775,7 +775,7 @@ class Crypt_RSA { $RSAPrivateKey = pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey); - if (!empty($this->password)) { + if (!empty($this->password) || is_string($this->password)) { $iv = $this->_random(8); $symkey = pack('H*', md5($this->password . $iv)); // symkey is short for symmetric key $symkey.= substr(pack('H*', md5($symkey . $this->password . $iv)), 0, 8); @@ -1347,14 +1347,14 @@ class Crypt_RSA { * Sets the password * * Private keys can be encrypted with a password. To unset the password, pass in the empty string or false. - * Or rather, pass in $password such that empty($password) is true. + * Or rather, pass in $password such that empty($password) && !is_string($password) is true. * * @see createKey() * @see loadKey() * @access public * @param String $password */ - function setPassword($password) + function setPassword($password = false) { $this->password = $password; } diff --git a/phpseclib/File/ANSI.php b/phpseclib/File/ANSI.php index 3f4d9bde..29ad949e 100644 --- a/phpseclib/File/ANSI.php +++ b/phpseclib/File/ANSI.php @@ -396,7 +396,7 @@ class File_ANSI { case 33: $front = 'yellow'; break; case 34: $front = 'blue'; break; case 35: $front = 'magenta'; break; - case 36: $front = 'cryan'; break; + case 36: $front = 'cyan'; break; case 37: $front = 'white'; break; case 40: $back = 'black'; break; @@ -405,7 +405,7 @@ class File_ANSI { case 43: $back = 'yellow'; break; case 44: $back = 'blue'; break; case 45: $back = 'magenta'; break; - case 46: $back = 'cryan'; break; + case 46: $back = 'cyan'; break; case 47: $back = 'white'; break; default: @@ -479,6 +479,12 @@ class File_ANSI { } } + /** + * Returns the current screen without preformating + * + * @access private + * @return String + */ function _getScreen() { $output = ''; @@ -496,11 +502,23 @@ class File_ANSI { return rtrim($output); } + /** + * Returns the current screen + * + * @access public + * @return String + */ function getScreen() { return '
' . $this->_getScreen() . ''; } + /** + * Returns the current screen and the x previous lines + * + * @access public + * @return String + */ function getHistory() { $scrollback = '';