Subversion Repositories oidplus

Rev

Rev 846 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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