From 10ce0b9b21e9508c7ba76aeb60ee78e863e7c132 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 18 Apr 2020 10:43:38 -0500 Subject: [PATCH] PuTTY: comments weren't settable via toString() method --- phpseclib/Crypt/Common/Formats/Keys/PuTTY.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php b/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php index afc85082..ccd06f75 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php @@ -200,14 +200,14 @@ abstract class PuTTY */ 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'; - $key.= $encryption; - $key.= "\r\nComment: " . self::$comment . "\r\n"; + $comment = isset($options['comment']) ? $options['comment'] : self::$comment; + + $key = "PuTTY-User-Key-File-2: " . $type . "\r\nEncryption: "; $key.= $encryption; + $key.= "\r\nComment: " . $comment . "\r\n"; $public = Strings::packSSH2('s', $type) . $public; - $comment = isset($options['comment']) ? $options['comment'] : self::$comment; $source = Strings::packSSH2('ssss', $type, $encryption, $comment, $public); $public = Base64::encode($public);