From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- library/vendor/Zend/Crypt/Math/BigInteger.php | 113 +++++++++++ .../vendor/Zend/Crypt/Math/BigInteger/Bcmath.php | 226 +++++++++++++++++++++ .../Zend/Crypt/Math/BigInteger/Exception.php | 35 ++++ library/vendor/Zend/Crypt/Math/BigInteger/Gmp.php | 219 ++++++++++++++++++++ .../Zend/Crypt/Math/BigInteger/Interface.php | 51 +++++ library/vendor/Zend/Crypt/Math/Exception.php | 35 ++++ 6 files changed, 679 insertions(+) create mode 100644 library/vendor/Zend/Crypt/Math/BigInteger.php create mode 100644 library/vendor/Zend/Crypt/Math/BigInteger/Bcmath.php create mode 100644 library/vendor/Zend/Crypt/Math/BigInteger/Exception.php create mode 100644 library/vendor/Zend/Crypt/Math/BigInteger/Gmp.php create mode 100644 library/vendor/Zend/Crypt/Math/BigInteger/Interface.php create mode 100644 library/vendor/Zend/Crypt/Math/Exception.php (limited to 'library/vendor/Zend/Crypt/Math') diff --git a/library/vendor/Zend/Crypt/Math/BigInteger.php b/library/vendor/Zend/Crypt/Math/BigInteger.php new file mode 100644 index 0000000..0b98cec --- /dev/null +++ b/library/vendor/Zend/Crypt/Math/BigInteger.php @@ -0,0 +1,113 @@ +_loadAdapter($extension); + } + + /** + * Redirect all public method calls to the wrapped extension object. + * + * @param string $methodName + * @param array $args + * @return mixed + * @throws Zend_Crypt_Math_BigInteger_Exception + */ + public function __call($methodName, $args) + { + if(!method_exists($this->_math, $methodName)) { + throw new Zend_Crypt_Math_BigInteger_Exception('invalid method call: ' . get_class($this->_math) . '::' . $methodName . '() does not exist'); + } + return call_user_func_array(array($this->_math, $methodName), $args); + } + + /** + * @param string $extension + * @throws Zend_Crypt_Math_BigInteger_Exception + */ + protected function _loadAdapter($extension = null) + { + if ($extension === null) { + if (extension_loaded('gmp')) { + $extension = 'gmp'; + //} elseif (extension_loaded('big_int')) { + // $extension = 'big_int'; + } else { + $extension = 'bcmath'; + } + } + if($extension == 'gmp' && extension_loaded('gmp')) { + $this->_math = new Zend_Crypt_Math_BigInteger_Gmp(); + //} elseif($extension == 'bigint' && extension_loaded('big_int')) { + // require_once 'Zend/Crypt_Math/BigInteger/Bigint.php'; + // $this->_math = new Zend_Crypt_Math_BigInteger_Bigint(); + } elseif ($extension == 'bcmath' && extension_loaded('bcmath')) { + $this->_math = new Zend_Crypt_Math_BigInteger_Bcmath(); + } else { + throw new Zend_Crypt_Math_BigInteger_Exception($extension . ' big integer precision math support not detected'); + } + } + +} diff --git a/library/vendor/Zend/Crypt/Math/BigInteger/Bcmath.php b/library/vendor/Zend/Crypt/Math/BigInteger/Bcmath.php new file mode 100644 index 0000000..2fb4a67 --- /dev/null +++ b/library/vendor/Zend/Crypt/Math/BigInteger/Bcmath.php @@ -0,0 +1,226 @@ + 0) { + $return = chr(bcmod($operand, 256)) . $return; + $operand = bcdiv($operand, 256); + } + if (ord($return[0]) > 127) { + $return = "\0" . $return; + } + return $return; + } + + /**public function integerToBinary($operand) + { + $return = ''; + while(bccomp($operand, '0')) { + $return .= chr(bcmod($operand, '256')); + $operand = bcdiv($operand, '256'); + } + return $return; + }**/ // Prior version for referenced offset + + /** + * @param string $operand + * @return string + */ + public function hexToDecimal($operand) + { + $return = '0'; + while(strlen($hex)) { + $hex = hexdec(substr($operand, 0, 4)); + $dec = bcadd(bcmul($return, 65536), $hex); + $operand = substr($operand, 4); + } + return $return; + } +} diff --git a/library/vendor/Zend/Crypt/Math/BigInteger/Exception.php b/library/vendor/Zend/Crypt/Math/BigInteger/Exception.php new file mode 100644 index 0000000..c1c865d --- /dev/null +++ b/library/vendor/Zend/Crypt/Math/BigInteger/Exception.php @@ -0,0 +1,35 @@ + '7') { + $bigInt = '00' . $bigInt; + } + $return = pack("H*", $bigInt); + return $return; + } + + /** + * @param string $operand + * @return string + */ + public function hexToDecimal($operand) + { + $return = '0'; + while(strlen($hex)) { + $hex = hexdec(substr($operand, 0, 4)); + $dec = gmp_add(gmp_mul($return, 65536), $hex); + $operand = substr($operand, 4); + } + return $return; + } + +} diff --git a/library/vendor/Zend/Crypt/Math/BigInteger/Interface.php b/library/vendor/Zend/Crypt/Math/BigInteger/Interface.php new file mode 100644 index 0000000..9fa9281 --- /dev/null +++ b/library/vendor/Zend/Crypt/Math/BigInteger/Interface.php @@ -0,0 +1,51 @@ +