diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 27e34b75..19d0a020 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -317,6 +317,9 @@ class Blowfish extends Base function isValidEngine($engine) { if ($engine == self::ENGINE_OPENSSL) { + if (version_compare(PHP_VERSION, '5.3.7') < 0 && $this->key_length != 16) { + return false; + } if ($this->key_length < 16) { return false; } diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index 51033320..4812010c 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -145,7 +145,23 @@ class RC4 extends Base function isValidEngine($engine) { if ($engine == Base::ENGINE_OPENSSL) { - $this->cipher_name_openssl = 'rc4-40'; + if (version_compare(PHP_VERSION, '5.3.7') >= 0) { + $this->cipher_name_openssl = 'rc4-40'; + } else { + switch (strlen($this->key)) { + case 5: + $this->cipher_name_openssl = 'rc4-40'; + break; + case 8: + $this->cipher_name_openssl = 'rc4-64'; + break; + case 16: + $this->cipher_name_openssl = 'rc4'; + break; + default: + return false; + } + } } return parent::isValidEngine($engine);