1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-04 18:48:24 +01:00

PuTTY: comments weren't settable via toString() method

This commit is contained in:
terrafrost 2020-04-18 10:43:38 -05:00
parent 92d0cd837e
commit 10ce0b9b21

View File

@ -200,14 +200,14 @@ abstract class PuTTY
*/ */
protected static function wrapPrivateKey($public, $private, $type, $password, array $options = []) protected static function wrapPrivateKey($public, $private, $type, $password, array $options = [])
{ {
$key = "PuTTY-User-Key-File-2: " . $type . "\r\nEncryption: ";
$encryption = (!empty($password) || is_string($password)) ? 'aes256-cbc' : 'none'; $encryption = (!empty($password) || is_string($password)) ? 'aes256-cbc' : 'none';
$key.= $encryption; $comment = isset($options['comment']) ? $options['comment'] : self::$comment;
$key.= "\r\nComment: " . self::$comment . "\r\n";
$key = "PuTTY-User-Key-File-2: " . $type . "\r\nEncryption: "; $key.= $encryption;
$key.= "\r\nComment: " . $comment . "\r\n";
$public = Strings::packSSH2('s', $type) . $public; $public = Strings::packSSH2('s', $type) . $public;
$comment = isset($options['comment']) ? $options['comment'] : self::$comment;
$source = Strings::packSSH2('ssss', $type, $encryption, $comment, $public); $source = Strings::packSSH2('ssss', $type, $encryption, $comment, $public);
$public = Base64::encode($public); $public = Base64::encode($public);