From 819a1652462915ebe0c6d1b97e91a19cab8dce2e Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 26 Jun 2017 23:19:30 -0500 Subject: [PATCH] RSA: add enableBlinding() / disableBlinding() static methods --- phpseclib/Crypt/RSA.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index f7150911..bd2c77df 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -249,6 +249,14 @@ class RSA extends AsymmetricKey */ private static $smallestPrime = 4096; + /** + * Enable Blinding? + * + * @var bool + * @access private + */ + private static $enableBlinding = true; + /** * The constructor * @@ -885,7 +893,7 @@ class RSA extends AsymmetricKey $num_primes = count($this->primes); - if (defined('CRYPT_RSA_DISABLE_BLINDING')) { + if (!static::$enableBlinding) { $m_i = [ 1 => $x->modPow($this->exponents[1], $this->primes[1]), 2 => $x->modPow($this->exponents[2], $this->primes[2]) @@ -943,6 +951,26 @@ class RSA extends AsymmetricKey return $m; } + /** + * Enable RSA Blinding + * + * @access public + */ + public static function enableBlinding() + { + static::$enableBlinding = true; + } + + /** + * Disable RSA Blinding + * + * @access public + */ + public static function disableBlinding() + { + static::$enableBlinding = false; + } + /** * Performs RSA Blinding *