Skip to content

Commit

Permalink
Fix GMP object in BigNum
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinmo committed Feb 8, 2022
1 parent f9106f6 commit cef45b4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/SimpleJWT/Util/BigNum.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public function __construct($str, $base = 10) {
$this->value = gmp_init($str, 10);
return;
case 256:
$bytes = array_merge(unpack('C*', $str));
$arr = unpack('C*', $str);
assert($arr !== false);
$bytes = array_merge($arr);

$value = (new BigNum(0))->value;

Expand Down Expand Up @@ -213,8 +215,7 @@ protected function _div($a, $b) {
* @return \GMP a bignum representing base ^ exp
*/
function _pow($base, $exp) {
if ((is_resource($exp) && (get_resource_type($exp) == 'GMP integer'))
|| (is_object($exp) && (get_class($exp) == 'GMP')))
if (is_object($exp) && ($exp instanceof \GMP))
$exp = gmp_intval($exp);
return gmp_pow($base, $exp);
}
Expand Down

0 comments on commit cef45b4

Please sign in to comment.