mirror of
https://github.com/danog/phpseclib.git
synced 2024-12-15 02:17:04 +01:00
Merge branch '3.0'
This commit is contained in:
commit
e56f60ff3c
@ -24,7 +24,7 @@ use phpseclib3\Crypt\DSA;
|
||||
use phpseclib3\Crypt\ECDSA;
|
||||
|
||||
/**
|
||||
* Base Class for all stream cipher classes
|
||||
* Base Class for all asymmetric cipher classes
|
||||
*
|
||||
* @package AsymmetricKey
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
@ -173,8 +173,8 @@ abstract class AsymmetricKey
|
||||
}
|
||||
|
||||
$components['format'] = $format;
|
||||
|
||||
$new = static::onLoad($components);
|
||||
$new->format = $format;
|
||||
return $new instanceof PrivateKey ?
|
||||
$new->withPassword($password) :
|
||||
$new;
|
||||
@ -304,7 +304,7 @@ abstract class AsymmetricKey
|
||||
* Returns the format of the loaded key.
|
||||
*
|
||||
* If the key that was loaded wasn't in a valid or if the key was auto-generated
|
||||
* with RSA::createKey() then this will return false.
|
||||
* with RSA::createKey() then this will throw an exception.
|
||||
*
|
||||
* @see self::load()
|
||||
* @access public
|
||||
@ -312,8 +312,8 @@ abstract class AsymmetricKey
|
||||
*/
|
||||
public function getLoadedFormat()
|
||||
{
|
||||
if ($this->format === false) {
|
||||
return false;
|
||||
if (empty($this->format)) {
|
||||
throw new NoKeyLoadedException('This key was created with createKey - it was not loaded with load. Therefore there is no "loaded format"');
|
||||
}
|
||||
|
||||
$meta = new \ReflectionClass($this->format);
|
||||
|
@ -95,7 +95,7 @@ abstract class DSA extends AsymmetricKey
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected $format;
|
||||
protected $sigFormat;
|
||||
|
||||
/**
|
||||
* Signature Format (Short)
|
||||
@ -263,7 +263,7 @@ abstract class DSA extends AsymmetricKey
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
$this->format = self::validatePlugin('Signature', 'ASN1');
|
||||
$this->sigFormat = self::validatePlugin('Signature', 'ASN1');
|
||||
$this->shortFormat = 'ASN1';
|
||||
|
||||
parent::__construct();
|
||||
@ -329,7 +329,7 @@ abstract class DSA extends AsymmetricKey
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->shortFormat = $format;
|
||||
$new->format = self::validatePlugin('Signature', $format);
|
||||
$new->sigFormat = self::validatePlugin('Signature', $format);
|
||||
return $new;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class PrivateKey extends DSA implements Common\PrivateKey
|
||||
*/
|
||||
public function sign($message)
|
||||
{
|
||||
$format = $this->format;
|
||||
$format = $this->sigFormat;
|
||||
|
||||
if (self::$engines['OpenSSL'] && in_array($this->hash->getHash(), openssl_get_md_methods())) {
|
||||
$signature = '';
|
||||
|
@ -40,7 +40,7 @@ class PublicKey extends DSA implements Common\PublicKey
|
||||
*/
|
||||
public function verify($message, $signature)
|
||||
{
|
||||
$format = $this->format;
|
||||
$format = $this->sigFormat;
|
||||
|
||||
$params = $format::load($signature);
|
||||
if ($params === false || count($params) != 2) {
|
||||
|
@ -244,7 +244,7 @@ abstract class EC extends AsymmetricKey
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
$this->format = self::validatePlugin('Signature', 'ASN1');
|
||||
$this->sigFormat = self::validatePlugin('Signature', 'ASN1');
|
||||
$this->shortFormat = 'ASN1';
|
||||
|
||||
parent::__construct();
|
||||
@ -383,7 +383,7 @@ abstract class EC extends AsymmetricKey
|
||||
|
||||
$new = clone $this;
|
||||
$new->shortFormat = $format;
|
||||
$new->format = self::validatePlugin('Signature', $format);
|
||||
$new->sigFormat = self::validatePlugin('Signature', $format);
|
||||
return $new;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ class PrivateKey extends EC implements Common\PrivateKey
|
||||
$order = $this->curve->getOrder();
|
||||
|
||||
$shortFormat = $this->shortFormat;
|
||||
$format = $this->format;
|
||||
$format = $this->sigFormat;
|
||||
if ($format === false) {
|
||||
return false;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class PublicKey extends EC implements Common\PublicKey
|
||||
}
|
||||
|
||||
$shortFormat = $this->shortFormat;
|
||||
$format = $this->format;
|
||||
$format = $this->sigFormat;
|
||||
if ($format === false) {
|
||||
return false;
|
||||
}
|
||||
|
@ -407,7 +407,6 @@ abstract class RSA extends AsymmetricKey
|
||||
new PublicKey :
|
||||
new PrivateKey;
|
||||
|
||||
$key->format = $components['format'];
|
||||
$key->modulus = $components['modulus'];
|
||||
$key->publicExponent = $components['publicExponent'];
|
||||
$key->k = $key->modulus->getLengthInBytes();
|
||||
|
Loading…
Reference in New Issue
Block a user