R30143 - in /branches/1.6: phpgwapi/inc/class.auth.inc.php setup/inc/hook_config.inc.php

Author: ralfbecker
New Revision: 30143

URL: http://www.egroupware.org/viewvc/egroupware?rev=30143&view=rev
Log:
using since php<=5.0 available raw_output=true parameter for md5 and sha1 instead of deprecated and in newer distros no longer available mhash extension

Modified:
branches/1.6/phpgwapi/inc/class.auth.inc.php
branches/1.6/setup/inc/hook_config.inc.php

Modified: branches/1.6/phpgwapi/inc/class.auth.inc.php
URL: http://www.egroupware.org/viewvc/egroupware/branches/1.6/phpgwapi/inc/class.auth.inc.php?rev=30143&r1=30142&r2=30143&view=diff

— branches/1.6/phpgwapi/inc/class.auth.inc.php (original)
+++ branches/1.6/phpgwapi/inc/class.auth.inc.php Thu May 13 12:44:52 2010
@@ -187,28 +187,16 @@
$e_password = ‘{md5}’ . base64_encode(pack(“H*”,md5($password)));
break;
case ‘smd5’:

  •   		if(!function_exists('mhash'))
    
  •   		{
    
  •   			return False;
    
  •   		}
      		$salt = self::randomstring(8);
    
  •   		$hash = mhash(MHASH_MD5, $password . $salt);
    
  •   		$hash = md5($password . $salt,true);
      		$e_password = '{SMD5}' . base64_encode($hash . $salt);
      		break;
      	case 'sha':
    
  •   		if(!function_exists('mhash'))
    
  •   		{
    
  •   			return False;
    
  •   		}
    
  •   		$e_password = '{SHA}' . base64_encode(mhash(MHASH_SHA1, $password));
    
  •   		$e_password = '{SHA}' . base64_encode(sha1($password,true));
      		break;
      	case 'ssha':
    
  •   		if(!function_exists('mhash'))
    
  •   		{
    
  •   			return False;
    
  •   		}
      		$salt = self::randomstring(8);
    
  •   		$hash = mhash(MHASH_SHA1, $password . $salt);
    
  •   		$hash = sha1($password . $salt,true);
      		$e_password = '{SSHA}' . base64_encode($hash . $salt);
      		break;
      	case 'plain':
    

@@ -299,28 +287,14 @@
self::$error = ‘no ext crypt’;
break;
case ‘smd5’:

  •   		if(!function_exists('mhash'))
    
  •   		{
    
  •   			return False;
    
  •   		}
      		$salt = self::randomstring(8);
    
  •   		$hash = mhash(MHASH_MD5, $password . $salt);
    
  •   		$hash = md5($password . $salt,true);
      		return '{SMD5}' . base64_encode($hash . $salt);
      	case 'sha':
    
  •   		if(!function_exists('mhash'))
    
  •   		{
    
  •   			self::$error = 'no sha';
    
  •   			return False;
    
  •   		}
    
  •   		return '{SHA}' . base64_encode(mhash(MHASH_SHA1,$password));
    
  •   		return '{SHA}' . base64_encode(sha1($password,true));
      	case 'ssha':
    
  •   		if(!function_exists('mhash'))
    
  •   		{
    
  •   			self::$error = 'no ssha';
    
  •   			return False;
    
  •   		}
      		$salt = self::randomstring(8);
    
  •   		$hash = mhash(MHASH_SHA1, $password . $salt);
    
  •   		$hash = sha1($password . $salt,true);
      		return '{SSHA}' . base64_encode($hash . $salt);
      	case 'md5':
      	default:
    

@@ -387,7 +361,7 @@
$orig_hash = substr($hash, 0, 16);
$salt = substr($hash, 16);

  •   $new_hash = mhash(MHASH_MD5,$form_val . $salt);
    
  •   $new_hash = md5($form_val . $salt,true);
      //echo '<br>  DB: ' . base64_encode($orig_hash) . '<br>FORM: ' . base64_encode($new_hash);
    
      return strcmp($orig_hash,$new_hash) == 0;
    

@@ -404,7 +378,7 @@
{
/* Start with the first char after {SHA} */
$hash = base64_decode(substr($db_val,5));

  •   $new_hash = mhash(MHASH_SHA1,$form_val);
    
  •   $new_hash = sha1($form_val,true);
      //echo '<br>  DB: ' . base64_encode($orig_hash) . '<br>FORM: ' . base64_encode($new_hash);
    
      return strcmp($hash,$new_hash) == 0;
    

@@ -425,7 +399,7 @@
// SHA-1 hashes are 160 bits long
$orig_hash = substr($hash, 0, 20);
$salt = substr($hash, 20);

  •   $new_hash = mhash(MHASH_SHA1, $form_val . $salt);
    
  •   $new_hash = sha1($form_val . $salt,true);
    
      return strcmp($orig_hash,$new_hash) == 0;
    
    }

Modified: branches/1.6/setup/inc/hook_config.inc.php
URL: http://www.egroupware.org/viewvc/egroupware/branches/1.6/setup/inc/hook_config.inc.php?rev=30143&r1=30142&r2=30143&view=diff

— branches/1.6/setup/inc/hook_config.inc.php (original)
+++ branches/1.6/setup/inc/hook_config.inc.php Thu May 13 12:44:52 2010
@@ -146,17 +146,10 @@
{
$hashes = array(
‘des’ => ‘des’,

  •   'md5' => 'md5'
    
  • );
  • if(@function_exists(‘mhash’))
  • {
  •   $hashes += array(
    
  •   	'smd5' => 'smd5',
    
  •   	'sha'  => 'sha',
    
  •   	'ssha' => 'ssha'
    
  •   );
    
  • }
  • $hashes += array(
  •   'md5' => 'md5',
    
  •   'smd5' => 'smd5',
    
  •   'sha'  => 'sha',
    
  •   'ssha' => 'ssha',
      'plain' => 'plain',
    
    );
    /* Check for available crypt methods based on what is defined by php */
    @@ -173,7 +166,7 @@
    $hashes[‘ext_crypt’] = ‘ext_crypt’;
    }
  • while(list($key, $value) = each($hashes))
  • foreach($hashes as $key => $value)
    {
    if($config[‘ldap_encryption_type’] == $value)
    {
    @@ -214,19 +207,14 @@
    $hashes[‘crypt’] = ‘crypt’;
    }
  • if(@function_exists(‘mhash’))
  • {
  •   $hashes += array(
    
  •   	'smd5' => 'smd5',
    
  •   	'sha'  => 'sha',
    
  •   	'ssha' => 'ssha'
    
  •   );
    
  • }
    $hashes += array(
  •   'smd5' => 'smd5',
    
  •   'sha'  => 'sha',
    
  •   'ssha' => 'ssha',
      'plain' => 'plain',
    
    );
  • while(list($key, $value) = each($hashes))
  • foreach($hashes as $key => $value)
    {
    if($config[‘sql_encryption_type’] == $value)
    {


eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs