summaryrefslogtreecommitdiffstats
path: root/vendor/web-token/jwt-util-ecc/Math.php
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2024-05-27 13:08:29 +0200
committerAnton Luka Šijanec <anton@sijanec.eu>2024-05-27 13:08:29 +0200
commit75160b12821f7f4299cce7f0b69c83c1502ae071 (patch)
tree27e25e4ccaef45f0c58b22831164050d1af1d4db /vendor/web-token/jwt-util-ecc/Math.php
parentprvi-commit (diff)
download1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip
Diffstat (limited to 'vendor/web-token/jwt-util-ecc/Math.php')
-rw-r--r--vendor/web-token/jwt-util-ecc/Math.php194
1 files changed, 97 insertions, 97 deletions
diff --git a/vendor/web-token/jwt-util-ecc/Math.php b/vendor/web-token/jwt-util-ecc/Math.php
index e5732da..7d3f5ea 100644
--- a/vendor/web-token/jwt-util-ecc/Math.php
+++ b/vendor/web-token/jwt-util-ecc/Math.php
@@ -1,97 +1,97 @@
-<?php
-
-declare(strict_types=1);
-
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2014-2018 Spomky-Labs
- *
- * This software may be modified and distributed under the terms
- * of the MIT license. See the LICENSE file for details.
- */
-
-namespace Jose\Component\Core\Util\Ecc;
-
-/**
- * @internal
- */
-class Math
-{
- public static function cmp(\GMP $first, \GMP $other): int
- {
- return \gmp_cmp($first, $other);
- }
-
- public static function equals(\GMP $first, \GMP $other): bool
- {
- return 0 === \gmp_cmp($first, $other);
- }
-
- public static function mod(\GMP $number, \GMP $modulus): \GMP
- {
- return \gmp_mod($number, $modulus);
- }
-
- public static function add(\GMP $augend, \GMP $addend): \GMP
- {
- return \gmp_add($augend, $addend);
- }
-
- public static function sub(\GMP $minuend, \GMP $subtrahend): \GMP
- {
- return \gmp_sub($minuend, $subtrahend);
- }
-
- public static function mul(\GMP $multiplier, \GMP $multiplicand): \GMP
- {
- return \gmp_mul($multiplier, $multiplicand);
- }
-
- public static function pow(\GMP $base, int $exponent): \GMP
- {
- return \gmp_pow($base, $exponent);
- }
-
- public static function bitwiseAnd(\GMP $first, \GMP $other): \GMP
- {
- return \gmp_and($first, $other);
- }
-
- public static function bitwiseXor(\GMP $first, \GMP $other): \GMP
- {
- return \gmp_xor($first, $other);
- }
-
- public static function toString(\GMP $value): string
- {
- return \gmp_strval($value);
- }
-
- public static function inverseMod(\GMP $a, \GMP $m): \GMP
- {
- return \gmp_invert($a, $m);
- }
-
- public static function baseConvert(string $number, int $from, int $to): string
- {
- return \gmp_strval(\gmp_init($number, $from), $to);
- }
-
- public static function rightShift(\GMP $number, int $positions): \GMP
- {
- return \gmp_div($number, \gmp_pow(\gmp_init(2, 10), $positions));
- }
-
- public static function stringToInt(string $s): \GMP
- {
- $result = \gmp_init(0, 10);
- $sLen = \mb_strlen($s, '8bit');
-
- for ($c = 0; $c < $sLen; ++$c) {
- $result = \gmp_add(\gmp_mul(256, $result), \gmp_init(\ord($s[$c]), 10));
- }
-
- return $result;
- }
-}
+<?php
+
+declare(strict_types=1);
+
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2018 Spomky-Labs
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ */
+
+namespace Jose\Component\Core\Util\Ecc;
+
+/**
+ * @internal
+ */
+class Math
+{
+ public static function cmp(\GMP $first, \GMP $other): int
+ {
+ return \gmp_cmp($first, $other);
+ }
+
+ public static function equals(\GMP $first, \GMP $other): bool
+ {
+ return 0 === \gmp_cmp($first, $other);
+ }
+
+ public static function mod(\GMP $number, \GMP $modulus): \GMP
+ {
+ return \gmp_mod($number, $modulus);
+ }
+
+ public static function add(\GMP $augend, \GMP $addend): \GMP
+ {
+ return \gmp_add($augend, $addend);
+ }
+
+ public static function sub(\GMP $minuend, \GMP $subtrahend): \GMP
+ {
+ return \gmp_sub($minuend, $subtrahend);
+ }
+
+ public static function mul(\GMP $multiplier, \GMP $multiplicand): \GMP
+ {
+ return \gmp_mul($multiplier, $multiplicand);
+ }
+
+ public static function pow(\GMP $base, int $exponent): \GMP
+ {
+ return \gmp_pow($base, $exponent);
+ }
+
+ public static function bitwiseAnd(\GMP $first, \GMP $other): \GMP
+ {
+ return \gmp_and($first, $other);
+ }
+
+ public static function bitwiseXor(\GMP $first, \GMP $other): \GMP
+ {
+ return \gmp_xor($first, $other);
+ }
+
+ public static function toString(\GMP $value): string
+ {
+ return \gmp_strval($value);
+ }
+
+ public static function inverseMod(\GMP $a, \GMP $m): \GMP
+ {
+ return \gmp_invert($a, $m);
+ }
+
+ public static function baseConvert(string $number, int $from, int $to): string
+ {
+ return \gmp_strval(\gmp_init($number, $from), $to);
+ }
+
+ public static function rightShift(\GMP $number, int $positions): \GMP
+ {
+ return \gmp_div($number, \gmp_pow(\gmp_init(2, 10), $positions));
+ }
+
+ public static function stringToInt(string $s): \GMP
+ {
+ $result = \gmp_init(0, 10);
+ $sLen = \mb_strlen($s, '8bit');
+
+ for ($c = 0; $c < $sLen; ++$c) {
+ $result = \gmp_add(\gmp_mul(256, $result), \gmp_init(\ord($s[$c]), 10));
+ }
+
+ return $result;
+ }
+}