2019-07-27 22:28:18 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DH Public Key
|
|
|
|
*
|
|
|
|
* @author Jim Wigginton <terrafrost@php.net>
|
|
|
|
* @copyright 2015 Jim Wigginton
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
* @link http://phpseclib.sourceforge.net
|
|
|
|
*/
|
|
|
|
|
2022-06-04 15:31:21 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-11-07 05:41:40 +00:00
|
|
|
namespace phpseclib3\Crypt\DH;
|
2019-07-27 22:28:18 +00:00
|
|
|
|
2019-11-07 05:41:40 +00:00
|
|
|
use phpseclib3\Crypt\Common;
|
2022-01-30 15:34:42 +00:00
|
|
|
use phpseclib3\Crypt\DH;
|
2019-07-27 22:28:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* DH Public Key
|
|
|
|
*
|
|
|
|
* @author Jim Wigginton <terrafrost@php.net>
|
|
|
|
*/
|
|
|
|
class PublicKey extends DH
|
|
|
|
{
|
|
|
|
use Common\Traits\Fingerprint;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the public key
|
|
|
|
*
|
|
|
|
* @param array $options optional
|
|
|
|
*/
|
2022-06-04 15:31:21 +00:00
|
|
|
public function toString(string $type, array $options = []): string
|
2019-07-27 22:28:18 +00:00
|
|
|
{
|
|
|
|
$type = self::validatePlugin('Keys', $type, 'savePublicKey');
|
|
|
|
|
|
|
|
return $type::savePublicKey($this->prime, $this->base, $this->publicKey, $options);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the public key as a BigInteger
|
|
|
|
*/
|
2022-06-04 15:31:21 +00:00
|
|
|
public function toBigInteger(): \phpseclib3\Math\BigInteger
|
2019-07-27 22:28:18 +00:00
|
|
|
{
|
|
|
|
return $this->publicKey;
|
|
|
|
}
|
|
|
|
}
|