if (!isset($this->nickname)) {\r
throw new Exception("Must specify a nickname");\r
}\r
- if (!function_exists('mhash')) {\r
- require_once(INSTALLDIR.'/plugins/Msn/extlib/compat/mhash.php');\r
- }\r
\r
return true;\r
}\r
+++ /dev/null
-<?php
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.0 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available at through the world-wide-web at |
-// | http://www.php.net/license/3_0.txt. |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to |
-// | license@php.net so we can mail you a copy immediately. |
-// +----------------------------------------------------------------------+
-// | Authors: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: mhash.php,v 1.1 2005/05/10 07:56:44 aidan Exp $
-
-
-if (!defined('MHASH_CRC32')) {
- define('MHASH_CRC32', 0);
-}
-
-if (!defined('MHASH_MD5')) {
- define('MHASH_MD5', 1);
-}
-
-if (!defined('MHASH_SHA1')) {
- define('MHASH_SHA1', 2);
-}
-
-if (!defined('MHASH_HAVAL256')) {
- define('MHASH_HAVAL256', 3);
-}
-
-if (!defined('MHASH_RIPEMD160')) {
- define('MHASH_RIPEMD160', 5);
-}
-
-if (!defined('MHASH_TIGER')) {
- define('MHASH_TIGER', 7);
-}
-
-if (!defined('MHASH_GOST')) {
- define('MHASH_GOST', 8);
-}
-
-if (!defined('MHASH_CRC32B')) {
- define('MHASH_CRC32B', 9);
-}
-
-if (!defined('MHASH_HAVAL192')) {
- define('MHASH_HAVAL192', 11);
-}
-
-if (!defined('MHASH_HAVAL160')) {
- define('MHASH_HAVAL160', 12);
-}
-
-if (!defined('MHASH_HAVAL128')) {
- define('MHASH_HAVAL128', 13);
-}
-
-if (!defined('MHASH_TIGER128')) {
- define('MHASH_TIGER128', 14);
-}
-
-if (!defined('MHASH_TIGER160')) {
- define('MHASH_TIGER160', 15);
-}
-
-if (!defined('MHASH_MD4')) {
- define('MHASH_MD4', 16);
-}
-
-if (!defined('MHASH_SHA256')) {
- define('MHASH_SHA256', 17);
-}
-
-if (!defined('MHASH_ADLER32')) {
- define('MHASH_ADLER32', 18);
-}
-
-
-/**
- * Replace mhash()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.mhash
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.1.0
- * @require PHP 4.0.0 (user_error)
- */
-if (!function_exists('mhash')) {
- function mhash($hashtype, $data, $key = '')
- {
- switch ($hashtype) {
- case MHASH_MD5:
- $key = str_pad((strlen($key) > 64 ? pack("H*", md5($key)) : $key), 64, chr(0x00));
- $k_opad = $key ^ (str_pad('', 64, chr(0x5c)));
- $k_ipad = $key ^ (str_pad('', 64, chr(0x36)));
- return pack("H*", md5($k_opad . pack("H*", md5($k_ipad . $data))));
-
- default:
- return false;
-
- break;
- }
- }
-}
-
-?>
This class uses MSNP15.\r
\r
In addition to PHP5, the additional php modules required are:\r
-curl pcre mhash mcrypt bcmath\r
+curl pcre mcrypt bcmath\r
\r
*/\r
\r
// Check support\r
if (!function_exists('curl_init')) throw new Exception("curl module not found!\n");\r
if (!function_exists('preg_match')) throw new Exception("pcre module not found!\n");\r
- if (!function_exists('mhash')) throw new Exception("mhash module not found!\n");\r
if (!function_exists('mcrypt_cbc')) throw new Exception("mcrypt module not found!\n");\r
if (!function_exists('bcmod')) throw new Exception("bcmath module not found!\n");\r
\r
if(!empty($message)) {\r
$this->debug_message($message);\r
}\r
- $this->callHandler('ConnectFailed');\r
+ $this->callHandler('ConnectFailed', $message);\r
$this->NSRetryWait($this->retry_wait);\r
}\r
\r
*/\r
\r
private function derive_key($key, $magic) {\r
- $hash1 = mhash(MHASH_SHA1, $magic, $key);\r
- $hash2 = mhash(MHASH_SHA1, $hash1.$magic, $key);\r
- $hash3 = mhash(MHASH_SHA1, $hash1, $key);\r
- $hash4 = mhash(MHASH_SHA1, $hash3.$magic, $key);\r
+ $hash1 = $this->mhash_sha1($magic, $key);\r
+ $hash2 = $this->mhash_sha1($hash1.$magic, $key);\r
+ $hash3 = $this->mhash_sha1($hash1, $key);\r
+ $hash4 = $this->mhash_sha1($hash3.$magic, $key);\r
return $hash2.substr($hash4, 0, 4);\r
}\r
\r
$key3 = $this->derive_key($key1, 'WS-SecureConversationSESSION KEY ENCRYPTION');\r
\r
// get hash of challenge using key2\r
- $hash = mhash(MHASH_SHA1, $challenge, $key2);\r
+ $hash = $this->mhash_sha1($challenge, $key2);\r
\r
// get 8 bytes random data\r
$iv = substr(base64_encode(rand(1000,9999).rand(1000,9999)), 2, 8);\r
$buf .= "$h_str $a_str\n";\r
return $buf;\r
}\r
+\r
+ function mhash_sha1($data, $key)\r
+ {\r
+ if (extension_loaded("mhash"))\r
+ return mhash(MHASH_SHA1, $data, $key);\r
+\r
+ if (function_exists("hash_hmac"))\r
+ return hash_hmac('sha1', $data, $key, true);\r
+\r
+ // RFC 2104 HMAC implementation for php. Hacked by Lance Rushing\r
+ $b = 64;\r
+ if (strlen($key) > $b)\r
+ $key = pack("H*", sha1($key));\r
+ $key = str_pad($key, $b, chr(0x00));\r
+ $ipad = str_pad("", $b, chr(0x36));\r
+ $opad = str_pad("", $b, chr(0x5c));\r
+ $k_ipad = $key ^ $ipad ;\r
+ $k_opad = $key ^ $opad;\r
+\r
+ $sha1_value = sha1($k_opad . pack("H*", sha1($k_ipad . $data)));\r
+\r
+ $hash_data = '';\r
+ $str = join('',explode('\x', $sha1_value));\r
+ $len = strlen($str);\r
+ for ($i = 0; $i < $len; $i += 2)\r
+ $hash_data .= chr(hexdec(substr($str, $i, 2)));\r
+ return $hash_data;\r
+ }\r
}\r
/**\r
* Called by callback to log failure during connect\r
*\r
+ * @param string $message error message reported\r
* @return void\r
*/\r
- public function handle_connect_failed() {\r
- common_log(LOG_NOTICE, 'MSN connect failed, retrying');\r
+ public function handle_connect_failed($message) {\r
+ common_log(LOG_NOTICE, 'MSN connect failed, retrying: ' . $message);\r
}\r
\r
/**\r