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

AsymetrticKey: add getComment() method

This commit is contained in:
terrafrost 2021-04-18 22:20:48 -05:00
parent 701881d3de
commit d9615a6fb9

View File

@ -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
*