- 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,22 +1064,24 @@ 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);
if (function_exists('des')) {
$des_iv_size = 8;
$iv = ''; $iv = '';
for ($i = 0; $i < constant('DES_IV_SIZE'); $i++) for ($i = 0; $i < $des_iv_size; $i++)
$iv .= sprintf("%c", mt_rand(0, 255)); $iv .= sprintf("%c", mt_rand(0, 255));
$cipher = $iv . des($this->config->get_crypto_key($key), $clear, 1, 1, $iv); $cipher = $iv . des($this->config->get_crypto_key($key), $clear, 1, 1, $iv);
} }
else else {
{
raise_error(array( raise_error(array(
'code' => 500, 'type' => 'php', 'code' => 500, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__, 'file' => __FILE__, 'line' => __LINE__,
'message' => "Could not perform encryption; make sure Mcrypt is installed or lib/des.inc is available" 'message' => "Could not perform encryption; make sure Mcrypt is installed or lib/des.inc is available"
), true, true); ), true, true);
} }
}
return $base64 ? base64_encode($cipher) : $cipher; return $base64 ? base64_encode($cipher) : $cipher;
} }
@ -1110,21 +1112,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 = substr($cipher, 0, constant('DES_IV_SIZE')); if (function_exists('des')) {
$cipher = substr($cipher, constant('DES_IV_SIZE')); $des_iv_size = 8;
$iv = substr($cipher, 0, $des_iv_size);
$cipher = substr($cipher, $des_iv_size);
$clear = des($this->config->get_crypto_key($key), $cipher, 0, 1, $iv); $clear = des($this->config->get_crypto_key($key), $cipher, 0, 1, $iv);
} }
else else {
{
raise_error(array( raise_error(array(
'code' => 500, 'type' => 'php', 'code' => 500, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__, 'file' => __FILE__, 'line' => __LINE__,
'message' => "Could not perform decryption; make sure Mcrypt is installed or lib/des.inc is available" 'message' => "Could not perform decryption; make sure Mcrypt is installed or lib/des.inc is available"
), true, true); ), true, true);
} }
}
/*- /*-
* Trim PHP's padding and the canary byte; see note in * Trim PHP's padding and the canary byte; see note in

Loading…
Cancel
Save