thomascube
2008-06-18 1fb78c57ccd93c5fd58c2c42a82824dae738417c
Revert changes from r994 and make cram-md5 work again (#1484819)

2 files modified
16 ■■■■■ changed files
program/include/rcube_imap.php 4 ●●●● patch | view | raw | blame | history
program/lib/imap.inc 12 ●●●●● patch | view | raw | blame | history
program/include/rcube_imap.php
@@ -102,7 +102,7 @@
   * @return boolean  TRUE on success, FALSE on failure
   * @access public
   */
  function connect($host, $user, $pass, $port=143, $use_ssl=null, $auth_type='check')
  function connect($host, $user, $pass, $port=143, $use_ssl=null, $auth_type=null)
    {
    global $ICL_SSL, $ICL_PORT, $IMAP_USE_INTERNAL_DATE;
    
@@ -119,7 +119,7 @@
    $ICL_PORT = $port;
    $IMAP_USE_INTERNAL_DATE = false;
    $this->conn = iil_Connect($host, $user, $pass, array('imap' => $auth_type));
    $this->conn = iil_Connect($host, $user, $pass, array('imap' => $auth_type ? $auth_type : 'check'));
    $this->host = $host;
    $this->user = $user;
    $this->pass = $pass;
program/lib/imap.inc
@@ -297,12 +297,10 @@
    }
    
    // generate hash
    $hash  = iil_xor($pass,$opad);
    $hash .= pack("H*", md5(iil_xor($pass, $ipad) . base64_decode($encChallenge)));
    $hash  = md5($hash);
    $hash  = md5(iil_xor($pass,$opad) . pack("H*", md5(iil_xor($pass, $ipad) . base64_decode($encChallenge))));
    
    // generate reply
    $reply = base64_encode('"' . $user . '" "' . $hash . '"');
    $reply = base64_encode($user . ' ' . $hash);
    
    // send result, get reply
    iil_PutLine($conn->fp, $reply);
@@ -544,9 +542,9 @@
        //do CRAM-MD5 authentication
        iil_PutLine($conn->fp, "a000 AUTHENTICATE CRAM-MD5");
        $line = trim(iil_ReadLine($conn->fp, 1024));
        $conn->message .= "$line\n";
        if ($line[0] == '+') {
            $conn->message .= 'Got challenge: ' . htmlspecialchars($line) . "\n";
@@ -556,7 +554,7 @@
            $conn->message .= "Tried CRAM-MD5: $result \n";
        } else {
            $conn->message .='No challenge ('.htmlspecialchars($line)."), try plain\n";
                $auth = 'plain';
            $auth = 'plain';
        }
    }