[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/GMP/ -> DefaultEngine.php (source)

   1  <?php
   2  
   3  /**
   4   * GMP Modular Exponentiation Engine
   5   *
   6   * PHP version 5 and 7
   7   *
   8   * @author    Jim Wigginton <terrafrost@php.net>
   9   * @copyright 2017 Jim Wigginton
  10   * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
  11   * @link      http://pear.php.net/package/Math_BigInteger
  12   */
  13  
  14  namespace phpseclib3\Math\BigInteger\Engines\GMP;
  15  
  16  use phpseclib3\Math\BigInteger\Engines\GMP;
  17  
  18  /**
  19   * GMP Modular Exponentiation Engine
  20   *
  21   * @author  Jim Wigginton <terrafrost@php.net>
  22   */
  23  abstract class DefaultEngine extends GMP
  24  {
  25      /**
  26       * Performs modular exponentiation.
  27       *
  28       * @param GMP $x
  29       * @param GMP $e
  30       * @param GMP $n
  31       * @return GMP
  32       */
  33      protected static function powModHelper(GMP $x, GMP $e, GMP $n)
  34      {
  35          $temp = new GMP();
  36          $temp->value = gmp_powm($x->value, $e->value, $n->value);
  37  
  38          return $x->normalize($temp);
  39      }
  40  }