backport more dynamic property fixes

This commit is contained in:
terrafrost 2022-08-22 06:07:52 -05:00
parent b1aef24a86
commit 0b9b0074c9
10 changed files with 63 additions and 7 deletions

View File

@ -217,6 +217,14 @@ abstract class SymmetricKey
*/
protected $key = false;
/**
* HMAC Key
*
* @see self::setupGCM()
* @var ?string
*/
protected $hKey = false;
/**
* The Initialization Vector
*
@ -3239,7 +3247,7 @@ abstract class SymmetricKey
private function setupGCM()
{
// don't keep on re-calculating $this->h
if (!$this->h || $this->h->key != $this->key) {
if (!$this->h || $this->hKey != $this->key) {
$cipher = new static('ecb');
$cipher->setKey($this->key);
$cipher->disablePadding();
@ -3247,7 +3255,7 @@ abstract class SymmetricKey
$this->h = self::$gcmField->newInteger(
Strings::switchEndianness($cipher->encrypt("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"))
);
$this->h->key = $this->key;
$this->hKey = $this->key;
}
if (strlen($this->nonce) == 12) {

View File

@ -138,6 +138,14 @@ class DES extends BlockCipher
*/
private $keys;
/**
* Key Cache "key"
*
* @see self::setupKey()
* @var array
*/
private $kl;
/**
* Shuffle table.
*

View File

@ -62,6 +62,13 @@ abstract class DH extends AsymmetricKey
*/
protected $base;
/**
* Public Key
*
* @var \phpseclib3\Math\BigInteger
*/
protected $publicKey;
/**
* Create DH parameters
*

View File

@ -123,6 +123,13 @@ abstract class EC extends AsymmetricKey
*/
protected $context;
/**
* Signature Format
*
* @var string
*/
protected $sigFormat;
/**
* Create public / private key pair.
*

View File

@ -38,6 +38,20 @@ use phpseclib3\Math\PrimeField;
*/
class KoblitzPrime extends Prime
{
/**
* Basis
*
* @var list<array{a: BigInteger, b: BigInteger}>
*/
protected $basis;
/**
* Beta
*
* @var PrimeField\Integer
*/
protected $beta;
// don't overwrite setCoefficients() with one that only accepts one parameter so that
// one might be able to switch between KoblitzPrime and Prime more easily (for benchmarking
// purposes).

View File

@ -171,6 +171,13 @@ class Hash
*/
private $pad;
/**
* Block Size
*
* @var int
*/
private $blockSize;
/**#@+
* UMAC variables
*

View File

@ -249,6 +249,13 @@ abstract class RSA extends AsymmetricKey
*/
private static $smallestPrime = 4096;
/**
* Public Exponent
*
* @var \phpseclib3\Math\BigInteger
*/
protected $publicExponent;
/**
* Sets the public exponent for key generation
*

View File

@ -51,9 +51,9 @@ class PrivateKey extends RSA implements Common\PrivateKey
/**
* Public Exponent
*
* @var mixed
* @var \phpseclib3\Math\BigInteger
*/
protected $publicExponent = false;
protected $privateExponent;
/**
* RSADP

View File

@ -64,7 +64,7 @@ abstract class EvalBarrett extends Base
$lhs->value = $x;
$rhs = new ' . $class . '();
$rhs->value = [' .
implode(',', array_map('self::float2string', $m->value)) . '];
implode(',', array_map(self::class . '::float2string', $m->value)) . '];
list(, $temp) = $lhs->divide($rhs);
return $temp->value;
';

View File

@ -48,8 +48,6 @@ class PrimeField extends FiniteField
// throw new \UnexpectedValueException('PrimeField requires a prime number be passed to the constructor');
//}
$this->modulo = $modulo;
$this->instanceID = self::$instanceCounter++;
Integer::setModulo($this->instanceID, $modulo);
Integer::setRecurringModuloFunction($this->instanceID, $modulo->createRecurringModuloFunction());