diff --git a/phpseclib/Crypt/Common/AsymmetricKey.php b/phpseclib/Crypt/Common/AsymmetricKey.php index 7fa451c7..993f39ca 100644 --- a/phpseclib/Crypt/Common/AsymmetricKey.php +++ b/phpseclib/Crypt/Common/AsymmetricKey.php @@ -115,6 +115,14 @@ abstract class AsymmetricKey */ protected static $engines = []; + /** + * Key Comment + * + * @var null|string + * @access private + */ + private $comment; + /** * The constructor */ @@ -173,8 +181,10 @@ abstract class AsymmetricKey } $components['format'] = $format; + $comment = isset($components['comment']) ? $components['comment'] : null; $new = static::onLoad($components); $new->format = $format; + $new->comment = $comment; return $new instanceof PrivateKey ? $new->withPassword($password) : $new; @@ -425,6 +435,19 @@ abstract class AsymmetricKey return $meta->getShortName(); } + /** + * Returns the key's comment + * + * Not all key formats support comments. If you want to set a comment use toString() + * + * @access public + * @return null|string + */ + public function getComment() + { + return $this->comment; + } + /** * Tests engine validity *