mirror of
https://github.com/danog/phpseclib.git
synced 2024-12-02 17:52:59 +01:00
backport select type hinting changes from master branch
This commit is contained in:
parent
f24691dc55
commit
e0adfa1712
@ -326,9 +326,8 @@ abstract class DH extends AsymmetricKey
|
|||||||
* OnLoad Handler
|
* OnLoad Handler
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @param array $components
|
|
||||||
*/
|
*/
|
||||||
protected static function onLoad($components)
|
protected static function onLoad(array $components)
|
||||||
{
|
{
|
||||||
if (!isset($components['privateKey']) && !isset($components['publicKey'])) {
|
if (!isset($components['privateKey']) && !isset($components['publicKey'])) {
|
||||||
$new = new Parameters();
|
$new = new Parameters();
|
||||||
|
@ -214,9 +214,8 @@ abstract class DSA extends AsymmetricKey
|
|||||||
* OnLoad Handler
|
* OnLoad Handler
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @param array $components
|
|
||||||
*/
|
*/
|
||||||
protected static function onLoad($components)
|
protected static function onLoad(array $components)
|
||||||
{
|
{
|
||||||
if (!isset(self::$engines['PHP'])) {
|
if (!isset(self::$engines['PHP'])) {
|
||||||
self::useBestEngine();
|
self::useBestEngine();
|
||||||
|
@ -199,9 +199,8 @@ abstract class EC extends AsymmetricKey
|
|||||||
* OnLoad Handler
|
* OnLoad Handler
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @param array $components
|
|
||||||
*/
|
*/
|
||||||
protected static function onLoad($components)
|
protected static function onLoad(array $components)
|
||||||
{
|
{
|
||||||
if (!isset(self::$engines['PHP'])) {
|
if (!isset(self::$engines['PHP'])) {
|
||||||
self::useBestEngine();
|
self::useBestEngine();
|
||||||
|
@ -645,7 +645,7 @@ class Prime extends Base
|
|||||||
*
|
*
|
||||||
* @return int[]
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
private function getNAFPoints($point, $wnd)
|
private function getNAFPoints(array $point, $wnd)
|
||||||
{
|
{
|
||||||
if (isset($point['naf'])) {
|
if (isset($point['naf'])) {
|
||||||
return $point['naf'];
|
return $point['naf'];
|
||||||
|
@ -115,7 +115,7 @@ abstract class XML
|
|||||||
* @param bool $decode optional
|
* @param bool $decode optional
|
||||||
* @return \DOMNodeList
|
* @return \DOMNodeList
|
||||||
*/
|
*/
|
||||||
private static function query($xpath, $name, $error = null, $decode = true)
|
private static function query(\DOMXPath $xpath, $name, $error = null, $decode = true)
|
||||||
{
|
{
|
||||||
$query = '/';
|
$query = '/';
|
||||||
$names = explode('/', $name);
|
$names = explode('/', $name);
|
||||||
|
@ -422,9 +422,8 @@ abstract class RSA extends AsymmetricKey
|
|||||||
* OnLoad Handler
|
* OnLoad Handler
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @param array $components
|
|
||||||
*/
|
*/
|
||||||
protected static function onLoad($components)
|
protected static function onLoad(array $components)
|
||||||
{
|
{
|
||||||
$key = $components['isPublicKey'] ?
|
$key = $components['isPublicKey'] ?
|
||||||
new PublicKey() :
|
new PublicKey() :
|
||||||
|
@ -60,10 +60,9 @@ class PrivateKey extends RSA implements Common\PrivateKey
|
|||||||
*
|
*
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#section-5.1.2 RFC3447#section-5.1.2}.
|
* See {@link http://tools.ietf.org/html/rfc3447#section-5.1.2 RFC3447#section-5.1.2}.
|
||||||
*
|
*
|
||||||
* @param \phpseclib3\Math\BigInteger $c
|
|
||||||
* @return bool|\phpseclib3\Math\BigInteger
|
* @return bool|\phpseclib3\Math\BigInteger
|
||||||
*/
|
*/
|
||||||
private function rsadp($c)
|
private function rsadp(BigInteger $c)
|
||||||
{
|
{
|
||||||
if ($c->compare(self::$zero) < 0 || $c->compare($this->modulus) > 0) {
|
if ($c->compare(self::$zero) < 0 || $c->compare($this->modulus) > 0) {
|
||||||
throw new \OutOfRangeException('Ciphertext representative out of range');
|
throw new \OutOfRangeException('Ciphertext representative out of range');
|
||||||
@ -76,10 +75,9 @@ class PrivateKey extends RSA implements Common\PrivateKey
|
|||||||
*
|
*
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#section-5.2.1 RFC3447#section-5.2.1}.
|
* See {@link http://tools.ietf.org/html/rfc3447#section-5.2.1 RFC3447#section-5.2.1}.
|
||||||
*
|
*
|
||||||
* @param \phpseclib3\Math\BigInteger $m
|
|
||||||
* @return bool|\phpseclib3\Math\BigInteger
|
* @return bool|\phpseclib3\Math\BigInteger
|
||||||
*/
|
*/
|
||||||
private function rsasp1($m)
|
private function rsasp1(BigInteger $m)
|
||||||
{
|
{
|
||||||
if ($m->compare(self::$zero) < 0 || $m->compare($this->modulus) > 0) {
|
if ($m->compare(self::$zero) < 0 || $m->compare($this->modulus) > 0) {
|
||||||
throw new \OutOfRangeException('Signature representative out of range');
|
throw new \OutOfRangeException('Signature representative out of range');
|
||||||
@ -176,7 +174,7 @@ class PrivateKey extends RSA implements Common\PrivateKey
|
|||||||
* @param int $i
|
* @param int $i
|
||||||
* @return \phpseclib3\Math\BigInteger
|
* @return \phpseclib3\Math\BigInteger
|
||||||
*/
|
*/
|
||||||
private function blind($x, $r, $i)
|
private function blind(BigInteger $x, BigInteger $r, $i)
|
||||||
{
|
{
|
||||||
$x = $x->multiply($r->modPow($this->publicExponent, $this->primes[$i]));
|
$x = $x->multiply($r->modPow($this->publicExponent, $this->primes[$i]));
|
||||||
$x = $x->modPow($this->exponents[$i], $this->primes[$i]);
|
$x = $x->modPow($this->exponents[$i], $this->primes[$i]);
|
||||||
|
@ -364,7 +364,7 @@ class PublicKey extends RSA implements Common\PublicKey
|
|||||||
* @throws \LengthException if strlen($m) > $this->k - 2 * $this->hLen - 2
|
* @throws \LengthException if strlen($m) > $this->k - 2 * $this->hLen - 2
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function rsaes_oaep_encrypt($m)
|
private function rsaes_oaep_encrypt(BigInteger $m)
|
||||||
{
|
{
|
||||||
$mLen = strlen($m);
|
$mLen = strlen($m);
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@ class ANSI
|
|||||||
* @param string $char
|
* @param string $char
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function processCoordinate($last_attr, $cur_attr, $char)
|
private function processCoordinate(\stdClass $last_attr, \stdClass $cur_attr, $char)
|
||||||
{
|
{
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
|
@ -516,12 +516,8 @@ abstract class ASN1
|
|||||||
* @param array $special
|
* @param array $special
|
||||||
* @return array|bool|Element|string|null
|
* @return array|bool|Element|string|null
|
||||||
*/
|
*/
|
||||||
public static function asn1map($decoded, $mapping, $special = [])
|
public static function asn1map(array $decoded, $mapping, $special = [])
|
||||||
{
|
{
|
||||||
if (!is_array($decoded)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($mapping['explicit']) && is_array($decoded['content'])) {
|
if (isset($mapping['explicit']) && is_array($decoded['content'])) {
|
||||||
$decoded = $decoded['content'][0];
|
$decoded = $decoded['content'][0];
|
||||||
}
|
}
|
||||||
@ -854,7 +850,7 @@ abstract class ASN1
|
|||||||
* @param array $special
|
* @param array $special
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function encode_der($source, $mapping, $idx = null, $special = [])
|
private static function encode_der($source, array $mapping, $idx = null, array $special = [])
|
||||||
{
|
{
|
||||||
if ($source instanceof Element) {
|
if ($source instanceof Element) {
|
||||||
return $source->element;
|
return $source->element;
|
||||||
@ -1310,7 +1306,7 @@ abstract class ASN1
|
|||||||
*
|
*
|
||||||
* @param array $oids
|
* @param array $oids
|
||||||
*/
|
*/
|
||||||
public static function loadOIDs($oids)
|
public static function loadOIDs(array $oids)
|
||||||
{
|
{
|
||||||
self::$reverseOIDs += $oids;
|
self::$reverseOIDs += $oids;
|
||||||
self::$oids = array_flip(self::$reverseOIDs);
|
self::$oids = array_flip(self::$reverseOIDs);
|
||||||
@ -1324,7 +1320,7 @@ abstract class ASN1
|
|||||||
*
|
*
|
||||||
* @param array $filters
|
* @param array $filters
|
||||||
*/
|
*/
|
||||||
public static function setFilters($filters)
|
public static function setFilters(array $filters)
|
||||||
{
|
{
|
||||||
self::$filters = $filters;
|
self::$filters = $filters;
|
||||||
}
|
}
|
||||||
|
@ -507,7 +507,7 @@ class X509
|
|||||||
* @param int $format optional
|
* @param int $format optional
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function saveX509($cert, $format = self::FORMAT_PEM)
|
public function saveX509(array $cert, $format = self::FORMAT_PEM)
|
||||||
{
|
{
|
||||||
if (!is_array($cert) || !isset($cert['tbsCertificate'])) {
|
if (!is_array($cert) || !isset($cert['tbsCertificate'])) {
|
||||||
return false;
|
return false;
|
||||||
@ -577,7 +577,7 @@ class X509
|
|||||||
* @param array $root (by reference)
|
* @param array $root (by reference)
|
||||||
* @param string $path
|
* @param string $path
|
||||||
*/
|
*/
|
||||||
private function mapInExtensions(&$root, $path)
|
private function mapInExtensions(array &$root, $path)
|
||||||
{
|
{
|
||||||
$extensions = &$this->subArrayUnchecked($root, $path);
|
$extensions = &$this->subArrayUnchecked($root, $path);
|
||||||
|
|
||||||
@ -625,7 +625,7 @@ class X509
|
|||||||
* @param array $root (by reference)
|
* @param array $root (by reference)
|
||||||
* @param string $path
|
* @param string $path
|
||||||
*/
|
*/
|
||||||
private function mapOutExtensions(&$root, $path)
|
private function mapOutExtensions(array &$root, $path)
|
||||||
{
|
{
|
||||||
$extensions = &$this->subArray($root, $path, !empty($this->extensionValues));
|
$extensions = &$this->subArray($root, $path, !empty($this->extensionValues));
|
||||||
|
|
||||||
@ -786,7 +786,7 @@ class X509
|
|||||||
* @param array $root (by reference)
|
* @param array $root (by reference)
|
||||||
* @param string $path
|
* @param string $path
|
||||||
*/
|
*/
|
||||||
private function mapInDNs(&$root, $path)
|
private function mapInDNs(array &$root, $path)
|
||||||
{
|
{
|
||||||
$dns = &$this->subArray($root, $path);
|
$dns = &$this->subArray($root, $path);
|
||||||
|
|
||||||
@ -814,7 +814,7 @@ class X509
|
|||||||
* @param array $root (by reference)
|
* @param array $root (by reference)
|
||||||
* @param string $path
|
* @param string $path
|
||||||
*/
|
*/
|
||||||
private function mapOutDNs(&$root, $path)
|
private function mapOutDNs(array &$root, $path)
|
||||||
{
|
{
|
||||||
$dns = &$this->subArray($root, $path);
|
$dns = &$this->subArray($root, $path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user