mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-17 02:35:10 +00:00
Merge branch 'gmp-1.0' into gmp-2.0
This commit is contained in:
commit
58768cb5aa
@ -360,8 +360,12 @@ class BigInteger
|
|||||||
case 256:
|
case 256:
|
||||||
switch (MATH_BIGINTEGER_MODE) {
|
switch (MATH_BIGINTEGER_MODE) {
|
||||||
case self::MODE_GMP:
|
case self::MODE_GMP:
|
||||||
$sign = $this->is_negative ? '-' : '';
|
$this->value = function_exists('gmp_import') ?
|
||||||
$this->value = gmp_init($sign . '0x' . bin2hex($x));
|
gmp_import($x) :
|
||||||
|
gmp_init('0x' . bin2hex($x));
|
||||||
|
if ($this->is_negative) {
|
||||||
|
$this->value = gmp_neg($this->value);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case self::MODE_BCMATH:
|
case self::MODE_BCMATH:
|
||||||
// round $len to the nearest 4 (thanks, DavidMJ!)
|
// round $len to the nearest 4 (thanks, DavidMJ!)
|
||||||
@ -548,9 +552,13 @@ class BigInteger
|
|||||||
return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : '';
|
return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (function_exists('gmp_export')) {
|
||||||
|
$temp = gmp_export($this->value);
|
||||||
|
} else {
|
||||||
$temp = gmp_strval(gmp_abs($this->value), 16);
|
$temp = gmp_strval(gmp_abs($this->value), 16);
|
||||||
$temp = (strlen($temp) & 1) ? '0' . $temp : $temp;
|
$temp = (strlen($temp) & 1) ? '0' . $temp : $temp;
|
||||||
$temp = pack('H*', $temp);
|
$temp = pack('H*', $temp);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->precision > 0 ?
|
return $this->precision > 0 ?
|
||||||
substr(str_pad($temp, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) :
|
substr(str_pad($temp, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) :
|
||||||
|
Loading…
Reference in New Issue
Block a user