From d9615a6fb970d9933866ca8b4036ec3407b020b6 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 18 Apr 2021 22:20:48 -0500 Subject: [PATCH] AsymetrticKey: add getComment() method --- phpseclib/Crypt/Common/AsymmetricKey.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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 *