1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-03 10:08:04 +01:00

Merge pull request #1128 from terrafrost/2.0-crypt-fix-old-openssl

Crypt: fix OpenSSL engine on <= PHP 5.3.6 (2.0 branch)
This commit is contained in:
terrafrost 2017-05-14 15:34:16 -05:00 committed by GitHub
commit ae41ac1ac3
2 changed files with 20 additions and 1 deletions

View File

@ -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;
}

View File

@ -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);