cvs: pear /Net_SMTP SMTP.php package.xml
| From: | Jon Parise | Date: | Tue, 14 Jan 2003 04:12:00 +0000 |
| Subject: | cvs: pear /Net_SMTP SMTP.php package.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8228@lists.php.net to get a copy of this message | ||
jon Mon Jan 13 23:12:00 2003 EDT
Modified files:
/pear/Net_SMTP SMTP.php package.xml
Log:
Use the CRAM-MD5 generation routines from the Auth_SASL package.
Index: pear/Net_SMTP/SMTP.php
diff -u pear/Net_SMTP/SMTP.php:1.20 pear/Net_SMTP/SMTP.php:1.21
--- pear/Net_SMTP/SMTP.php:1.20 Sun Jan 12 18:21:00 2003
+++ pear/Net_SMTP/SMTP.php Mon Jan 13 23:12:00 2003
@@ -368,41 +368,6 @@
return true;
}
- /**
- * Generate an HMAC MD5 digest string for the given key and data.
- *
- * This code was stolen from the Auth_SASL class.
- *
- * @author Richard Heyes <richard@php.net>
- *
- * @param string $key The secret key
- * @param string $data The data to protect
- * @return string The HMAC MD5 digest
- */
- function _HMAC_MD5($key, $data)
- {
- if (strlen($key) > 64) {
- $key = pack('H32', md5($pass));
- }
- if (strlen($key) < 64) {
- $key = str_pad($key, 64, chr(0));
- }
-
- $k_ipad = '';
- $k_opad = '';
-
- for ($i = 0; $i < 64; $i++) {
- $byte = ord($key{$i});
- $k_ipad .= chr($byte ^ 0x36);
- $k_opad .= chr($byte ^ 0x5C);
- }
-
- $inner = pack('H32', md5($k_ipad . $data));
- $digest = md5($k_opad . $inner);
-
- return $digest;
- }
-
/* Authenticates the user using the CRAM-MD5 method.
*
* @param string The userid to authenticate as.
@@ -414,6 +379,8 @@
*/
function _authCRAM_MD5($uid, $pwd)
{
+ include_once 'Auth/SASL.php';
+
if (PEAR::isError($error = $this->_put('AUTH', 'CRAM-MD5'))) {
return $error;
}
@@ -422,8 +389,9 @@
}
$challenge = base64_decode($this->_arguments[0]);
- $auth_str = base64_encode($uid . ' ' .
- $this->_HMAC_MD5($pwd, $challenge));
+ $cram = &Auth_SASL::factory('crammd5');
+ $auth_str = base64_encode($cram->getResponse($uid, $pwd, $challenge));
+
if (PEAR::isError($error = $this->_put($auth_str))) {
return $error;
}
@@ -488,6 +456,7 @@
}
$auth_str = base64_encode(chr(0) . $uid . chr(0) . $pwd);
+
if (PEAR::isError($error = $this->_put($auth_str))) {
return $error;
}
Index: pear/Net_SMTP/package.xml
diff -u pear/Net_SMTP/package.xml:1.12 pear/Net_SMTP/package.xml:1.13
--- pear/Net_SMTP/package.xml:1.12 Sun Jan 12 18:21:00 2003
+++ pear/Net_SMTP/package.xml Mon Jan 13 23:12:00 2003
@@ -38,6 +38,7 @@
</filelist>
<deps>
<dep type="pkg" rel="has">Net_Socket</dep>
+ <dep type="pkg" rel="has">Auth_SASL</dep>
</deps>
</release>
<changelog>