Merge branch '3.0'

This commit is contained in:
terrafrost 2021-01-25 13:12:21 -06:00
commit 03e3db6ed2
6 changed files with 34 additions and 10 deletions

View File

@ -40,7 +40,7 @@ class Binary extends Base
/**
* Binary Field Integer factory
*
* @var \phpseclib3\Math\BinaryFields
* @var \phpseclib3\Math\BinaryField
*/
protected $factory;

View File

@ -45,7 +45,7 @@ class Montgomery extends Base
/**
* Prime Field Integer factory
*
* @var \phpseclib3\Math\PrimeFields
* @var \phpseclib3\Math\PrimeField
*/
protected $factory;

View File

@ -43,6 +43,7 @@ use phpseclib3\Exception\UnsupportedAlgorithmException;
use phpseclib3\File\ASN1\Element;
use phpseclib3\File\ASN1\Maps;
use phpseclib3\Math\BigInteger;
use phpseclib3\Crypt\PublicKeyLoader;
/**
* Pure-PHP X.509 Parser
@ -303,6 +304,18 @@ class X509
*/
private static $extensions = [];
/**
* @var ?array
* @access private
*/
private $ipAddresses = null;
/**
* @var ?array
* @access private
*/
private $domains = null;
/**
* Default Constructor.
*
@ -3690,14 +3703,11 @@ class X509
return false;
}
// If the key is private, compute identifier from its corresponding public key.
$key = new RSA();
if (!$key->load($raw)) {
return false; // Not an unencrypted RSA key.
}
if ($key->getPrivateKey() !== false) { // If private.
$key = PublicKeyLoader::load($raw);
if ($key instanceof PrivateKey) { // If private.
return $this->computeKeyIdentifier($key, $method);
}
$key = $raw; // Is a public key.
$key = $raw; // Is a public key.
break;
case $key instanceof X509:
if (isset($key->publicKey)) {

View File

@ -1139,7 +1139,7 @@ abstract class Engine implements \Serializable
* Splits BigInteger's into chunks of $split bits
*
* @param int $split
* @return \phpseclib3\Math\BigInteger\Engine[]
* @return \phpseclib3\Math\BigInteger\Engines\Engine[]
*/
public function bitwise_split($split)
{

View File

@ -119,7 +119,7 @@ class Identity implements PrivateKey
*/
public function withPublicKey($key)
{
if ($key instanceof ECDSA) {
if ($key instanceof EC) {
if (is_array($key->getCurve()) || !isset(self::$curveAliases[$key->getCurve()])) {
throw new UnsupportedAlgorithmException('The only supported curves are nistp256, nistp384, nistp512 and Ed25519');
}

View File

@ -1176,4 +1176,18 @@ qzFkAKWjJj4KjfrbZX4C0Spfxw==
$this->assertIsArray($r);
}
/**
* @group github1586
*/
public function testComputeKeyIdentifier()
{
$key = RSA::createKey(512);
$key = ASN1::extractBER("$key");
$key = ASN1::encodeDER($key, ['type' => ASN1::TYPE_BIT_STRING]);
$key = new Element($key);
$x509 = new X509;
$this->assertIsString($x509->computeKeyIdentifier($key));
}
}