forked from extern/egroupware
Make the mcrypt algorithm and mode used configurable in setup/config.php
This commit is contained in:
parent
9f98fbb9a8
commit
96cd727fa5
88
admin/inc/hook_config.inc.php
Normal file
88
admin/inc/hook_config.inc.php
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
/**************************************************************************\
|
||||||
|
* phpGroupWare *
|
||||||
|
* http://www.phpgroupware.org *
|
||||||
|
* Written by Mark Peters <skeeter@phpgroupware.org> *
|
||||||
|
* -------------------------------------------- *
|
||||||
|
* 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 .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n";
|
||||||
|
$listed[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$out = '<option value="tripledes">TRIPLEDES</option>' . "\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 .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n";
|
||||||
|
$listed[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$out = '<option value="cbc" selected>CBC</option>' . "\n";
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
?>
|
@ -138,10 +138,32 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr bgcolor="{th_bg}">
|
||||||
|
<td colspan="2"><font color="{th_text}"><b>{lang_Mcrypt_Settings_(requires_mcrypt_PHP_extension)}</b></font></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr bgcolor="{row_off}">
|
<tr bgcolor="{row_off}">
|
||||||
<td>{lang_Enter_some_random_text_for_app_session_<br>encryption_(requires_mcrypt)}:</td>
|
<td>{lang_Enter_some_random_text_for_app_session_encryption}:</td>
|
||||||
<td><input name="newsettings[encryptkey]" value="{value_encryptkey}" size="40"></td>
|
<td><input name="newsettings[encryptkey]" value="{value_encryptkey}" size="40"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr bgcolor="{row_on}">
|
||||||
|
<td>{lang_Mcrypt_algorithm_(default_TRIPLEDES)}:</td>
|
||||||
|
<td>
|
||||||
|
<select name="newsettings[mcrypt_algo]">
|
||||||
|
{hook_encryptalgo}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr bgcolor="{row_off}">
|
||||||
|
<td>{lang_Mcrypt_mode_(default_CBC)}:</td>
|
||||||
|
<td>
|
||||||
|
<select name="newsettings[mcrypt_mode]">
|
||||||
|
{hook_encryptmode}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<!-- END body -->
|
<!-- END body -->
|
||||||
|
|
||||||
<!-- BEGIN footer -->
|
<!-- BEGIN footer -->
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
function crypto($vars)
|
function crypto($vars)
|
||||||
{
|
{
|
||||||
/* _debug_array(mcrypt_list_algorithms()); */
|
|
||||||
$key = $vars[0];
|
$key = $vars[0];
|
||||||
$iv = $vars[1];
|
$iv = $vars[1];
|
||||||
if ($GLOBALS['phpgw_info']['server']['mcrypt_enabled'] && extension_loaded('mcrypt'))
|
if ($GLOBALS['phpgw_info']['server']['mcrypt_enabled'] && extension_loaded('mcrypt'))
|
||||||
@ -51,6 +50,12 @@
|
|||||||
$this->mode = $GLOBALS['phpgw_info']['server']['mcrypt_mode'];
|
$this->mode = $GLOBALS['phpgw_info']['server']['mcrypt_mode'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->debug)
|
||||||
|
{
|
||||||
|
echo '<br>crypto: algorithm=' . $this->algo;
|
||||||
|
echo '<br>crypto: mode =' . $this->mode;
|
||||||
|
}
|
||||||
|
|
||||||
$this->enabled = True;
|
$this->enabled = True;
|
||||||
$this->mcrypt_version = $GLOBALS['phpgw_info']['server']['versions']['mcrypt'];
|
$this->mcrypt_version = $GLOBALS['phpgw_info']['server']['versions']['mcrypt'];
|
||||||
if ($this->mcrypt_version == 'old')
|
if ($this->mcrypt_version == 'old')
|
||||||
|
Loading…
Reference in New Issue
Block a user