From 96cd727fa5552edaa06f758a41e23fb2a98486ae Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Thu, 20 Dec 2001 17:58:48 +0000 Subject: [PATCH] Make the mcrypt algorithm and mode used configurable in setup/config.php --- admin/inc/hook_config.inc.php | 88 ++++++++++++++++++++++++++++++ admin/templates/default/config.tpl | 56 +++++++++++++------ phpgwapi/inc/class.crypto.inc.php | 7 ++- 3 files changed, 133 insertions(+), 18 deletions(-) create mode 100644 admin/inc/hook_config.inc.php diff --git a/admin/inc/hook_config.inc.php b/admin/inc/hook_config.inc.php new file mode 100644 index 0000000000..9c074a3d02 --- /dev/null +++ b/admin/inc/hook_config.inc.php @@ -0,0 +1,88 @@ + * + * -------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; either version 2 of the License, or (at your * + * option) any later version. * + \**************************************************************************/ + + /* $Id$ */ + + function encryptalgo($config) + { + if(@function_exists('mcrypt_list_algorithms')) + { + if(!isset($config['mcrypt_algo'])) + { + $config['mcrypt_algo'] = 'tripledes'; /* MCRYPT_TRIPLEDES */ + } + $algos = mcrypt_list_algorithms(); + + while (list ($key, $value) = each ($algos)) + { + /* Only show each once - seems this is a problem in some installs */ + if(!in_array($value,$listed)) + { + if ($config['mcrypt_algo'] == $value) + { + $selected = ' selected'; + } + else + { + $selected = ''; + } + $descr = strtoupper($value); + + $out .= '' . "\n"; + $listed[] = $value; + } + } + } + else + { + $out = '' . "\n";; + } + return $out; + } + + function encryptmode($config) + { + if(@function_exists('mcrypt_list_modes')) + { + if(!isset($config['mcrypt_mode'])) + { + $config['mcrypt_mode'] = 'cbc'; /* MCRYPT_MODE_CBC */ + } + $modes = mcrypt_list_modes(); + + while (list ($key, $value) = each ($modes)) + { + /* Only show each once - seems this is a problem in some installs */ + if(!in_array($value,$listed)) + { + if ($config['mcrypt_mode'] == $value) + { + $selected = ' selected'; + } + else + { + $selected = ''; + } + $descr = strtoupper($value); + + $out .= '' . "\n"; + $listed[] = $value; + } + } + } + else + { + $out = '' . "\n"; + } + return $out; + } +?> diff --git a/admin/templates/default/config.tpl b/admin/templates/default/config.tpl index a86d6dc7c6..697b2b10e9 100644 --- a/admin/templates/default/config.tpl +++ b/admin/templates/default/config.tpl @@ -19,12 +19,12 @@ @@ -55,7 +55,7 @@ {lang_Maximum_account_id_(e.g._65535_or_1000000)}: - + @@ -63,7 +63,7 @@ @@ -83,7 +83,7 @@ @@ -94,7 +94,7 @@ - {lang_If_no_ACL_records_for_user_or_any_group_the_user_is_a_member_of}: + {lang_If_no_ACL_records_for_user_or_any_group_the_user_is_a_member_of}: + {lang_LDAP_accounts_context}: - + {lang_LDAP_groups_context}: - + {lang_LDAP_rootdn}: - + {lang_LDAP_root_password}: - + - {lang_LDAP_encryption_type}: + {lang_LDAP_encryption_type}: + + + {lang_Mcrypt_algorithm_(default_TRIPLEDES)}: + + + + + + + {lang_Mcrypt_mode_(default_CBC)}: + + + + diff --git a/phpgwapi/inc/class.crypto.inc.php b/phpgwapi/inc/class.crypto.inc.php index 7fe182bebf..b1c0c9e4b6 100644 --- a/phpgwapi/inc/class.crypto.inc.php +++ b/phpgwapi/inc/class.crypto.inc.php @@ -37,7 +37,6 @@ function crypto($vars) { - /* _debug_array(mcrypt_list_algorithms()); */ $key = $vars[0]; $iv = $vars[1]; if ($GLOBALS['phpgw_info']['server']['mcrypt_enabled'] && extension_loaded('mcrypt')) @@ -51,6 +50,12 @@ $this->mode = $GLOBALS['phpgw_info']['server']['mcrypt_mode']; } + if($this->debug) + { + echo '
crypto: algorithm=' . $this->algo; + echo '
crypto: mode =' . $this->mode; + } + $this->enabled = True; $this->mcrypt_version = $GLOBALS['phpgw_info']['server']['versions']['mcrypt']; if ($this->mcrypt_version == 'old')