From 815f6098878b46223f125f3187863c069aa0ccdb Mon Sep 17 00:00:00 2001 From: terrafrost Date: Wed, 11 Sep 2013 11:48:40 -0500 Subject: [PATCH] RSA: check to see if MATH_BIGINTEGER_MODE_DISABLE is defined --- phpseclib/Crypt/RSA.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 1e990137..910c3a88 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -467,7 +467,14 @@ class Crypt_RSA { $this->configFile = CRYPT_RSA_OPENSSL_CONFIG; if ( !defined('CRYPT_RSA_MODE') ) { - switch (true) { + // Math/BigInteger's openssl requirements are a little less stringent than Crypt/RSA's. in particular, + // Math/BigInteger doesn't require an openssl.cfg file whereas Crypt/RSA does. so if Math/BigInteger + // can't use OpenSSL it can be pretty trivially assumed, then, that Crypt/RSA can't either. + if ( defined('MATH_BIGINTEGER_OPENSSL_DISABLE') ) { + define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL); + } + + switch ( !defined('CRYPT_RSA_MODE') ) { // ie. only run this if the above didn't set CRYPT_RSA_MODE already case extension_loaded('openssl') && version_compare(PHP_VERSION, '4.2.0', '>=') && file_exists($this->configFile): // some versions of XAMPP have mismatched versions of OpenSSL which causes it not to work ob_start();