From 58fbbde8c830ec651b97d4ab140641ff92e6cc2c Mon Sep 17 00:00:00 2001 From: roundcube Date: Mon, 3 Oct 2005 20:25:31 +0000 Subject: Minor bugfixes and SMTP support git-svn-id: https://svn.roundcube.net/trunk@17 208e9e7b-5314-0410-a742-e7e81cd9613c --- roundcubemail/program/lib/Auth/SASL/Common.php | 74 ++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 roundcubemail/program/lib/Auth/SASL/Common.php (limited to 'roundcubemail/program/lib/Auth/SASL/Common.php') diff --git a/roundcubemail/program/lib/Auth/SASL/Common.php b/roundcubemail/program/lib/Auth/SASL/Common.php new file mode 100755 index 000000000..e7a18e2de --- /dev/null +++ b/roundcubemail/program/lib/Auth/SASL/Common.php @@ -0,0 +1,74 @@ + | +// +-----------------------------------------------------------------------+ +// +// $Id$ + +/** +* Common functionality to SASL mechanisms +* +* @author Richard Heyes +* @access public +* @version 1.0 +* @package Auth_SASL +*/ + +class Auth_SASL_Common +{ + /** + * Function which implements HMAC MD5 digest + * + * @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($key)); + } + + if (strlen($key) < 64) { + $key = str_pad($key, 64, chr(0)); + } + + $k_ipad = substr($key, 0, 64) ^ str_repeat(chr(0x36), 64); + $k_opad = substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64); + + $inner = pack('H32', md5($k_ipad . $data)); + $digest = md5($k_opad . $inner); + + return $digest; + } +} +?> -- cgit v1.2.3