- load des.inc file only when needed

release-0.6
alecpl 15 years ago
parent cd96fd6727
commit 44155cddc2

@ -30,7 +30,6 @@ require_once('lib/utf7.inc');
require_once('include/rcube_shared.inc'); require_once('include/rcube_shared.inc');
// fallback if not PHP modules are available // fallback if not PHP modules are available
@include_once('lib/des.inc');
@include_once('lib/utf8.class.php'); @include_once('lib/utf8.class.php');
// define constannts for input reading // define constannts for input reading

@ -1064,21 +1064,23 @@ class rcmail
mcrypt_generic_deinit($td); mcrypt_generic_deinit($td);
mcrypt_module_close($td); mcrypt_module_close($td);
} }
else if (function_exists('des')) else {
{ @include_once('lib/des.inc');
define('DES_IV_SIZE', 8);
$iv = ''; if (function_exists('des')) {
for ($i = 0; $i < constant('DES_IV_SIZE'); $i++) $des_iv_size = 8;
$iv .= sprintf("%c", mt_rand(0, 255)); $iv = '';
$cipher = $iv . des($this->config->get_crypto_key($key), $clear, 1, 1, $iv); for ($i = 0; $i < $des_iv_size; $i++)
} $iv .= sprintf("%c", mt_rand(0, 255));
else $cipher = $iv . des($this->config->get_crypto_key($key), $clear, 1, 1, $iv);
{ }
raise_error(array( else {
'code' => 500, 'type' => 'php', raise_error(array(
'file' => __FILE__, 'line' => __LINE__, 'code' => 500, 'type' => 'php',
'message' => "Could not perform encryption; make sure Mcrypt is installed or lib/des.inc is available" 'file' => __FILE__, 'line' => __LINE__,
), true, true); 'message' => "Could not perform encryption; make sure Mcrypt is installed or lib/des.inc is available"
), true, true);
}
} }
return $base64 ? base64_encode($cipher) : $cipher; return $base64 ? base64_encode($cipher) : $cipher;
@ -1110,20 +1112,22 @@ class rcmail
mcrypt_generic_deinit($td); mcrypt_generic_deinit($td);
mcrypt_module_close($td); mcrypt_module_close($td);
} }
else if (function_exists('des')) else {
{ @include_once('lib/des.inc');
define('DES_IV_SIZE', 8);
$iv = substr($cipher, 0, constant('DES_IV_SIZE')); if (function_exists('des')) {
$cipher = substr($cipher, constant('DES_IV_SIZE')); $des_iv_size = 8;
$clear = des($this->config->get_crypto_key($key), $cipher, 0, 1, $iv); $iv = substr($cipher, 0, $des_iv_size);
} $cipher = substr($cipher, $des_iv_size);
else $clear = des($this->config->get_crypto_key($key), $cipher, 0, 1, $iv);
{ }
raise_error(array( else {
'code' => 500, 'type' => 'php', raise_error(array(
'file' => __FILE__, 'line' => __LINE__, 'code' => 500, 'type' => 'php',
'message' => "Could not perform decryption; make sure Mcrypt is installed or lib/des.inc is available" 'file' => __FILE__, 'line' => __LINE__,
), true, true); 'message' => "Could not perform decryption; make sure Mcrypt is installed or lib/des.inc is available"
), true, true);
}
} }
/*- /*-

Loading…
Cancel
Save