[php-pear-Crypt-CHAP] Replace use of deprecated mhash functions by hash

Remi Collet remi at fedoraproject.org
Fri Aug 27 19:27:51 UTC 2010


commit 5656155963e031a1a41456aa107daf365899acfb
Author: remi <fedora at famillecollet.com>
Date:   Fri Aug 27 21:27:37 2010 +0200

    Replace use of deprecated mhash functions by hash

 Crypt_CHAP-hash.patch    |   88 ++++++++++++++++++++++++++++++++++++++++++++++
 php-pear-Crypt-CHAP.spec |   14 ++++++-
 2 files changed, 100 insertions(+), 2 deletions(-)
---
diff --git a/Crypt_CHAP-hash.patch b/Crypt_CHAP-hash.patch
new file mode 100644
index 0000000..52eca59
--- /dev/null
+++ b/Crypt_CHAP-hash.patch
@@ -0,0 +1,88 @@
+diff -up Crypt_CHAP-1.0.2/CHAP.php.orig Crypt_CHAP-1.0.2/CHAP.php
+--- Crypt_CHAP-1.0.2/CHAP.php.orig	2010-08-27 21:02:38.000000000 +0200
++++ Crypt_CHAP-1.0.2/CHAP.php	2010-08-27 21:03:07.000000000 +0200
+@@ -148,7 +148,7 @@ class Crypt_CHAP_MD5 extends Crypt_CHAP 
+  * Generate MS-CHAPv1 Packets. MS-CHAP doesen't use the plaintext password, it uses the
+  * NT-HASH wich is stored in the SAM-Database or in the smbpasswd, if you are using samba.
+  * The NT-HASH is MD4(str2unicode(plaintextpass)). 
+- * You need the mhash extension for this class.
++ * You need the hash extension for this class.
+  * 
+  * @package Crypt_CHAP 
+  */
+@@ -164,13 +164,13 @@ class Crypt_CHAP_MSv1 extends Crypt_CHAP
+     /**
+      * Constructor
+      *
+-     * Loads the mhash extension
++     * Loads the hash extension
+      * @return void
+      */
+     function Crypt_CHAP_MSv1()
+     {
+         $this->Crypt_CHAP();
+-        $this->loadExtension('mhash');        
++        $this->loadExtension('hash');        
+     }
+     
+     /**
+@@ -182,9 +182,9 @@ class Crypt_CHAP_MSv1 extends Crypt_CHAP
+     function ntPasswordHash($password = null) 
+     {
+         if (isset($password)) {
+-            return mhash(MHASH_MD4, $this->str2unicode($password));
++            return pack('H*',hash('md4', $this->str2unicode($password)));
+         } else {
+-            return mhash(MHASH_MD4, $this->str2unicode($this->password));
++            return pack('H*',hash('md4', $this->str2unicode($this->password)));
+         }
+     }
+     
+@@ -431,7 +431,7 @@ class Crypt_CHAP_MSv2 extends Crypt_CHAP
+      */    
+     function ntPasswordHashHash($nthash) 
+     {
+-        return mhash(MHASH_MD4, $nthash);
++        return pack('H*',hash('md4', $nthash));
+     }
+     
+     /**
+@@ -443,7 +443,7 @@ class Crypt_CHAP_MSv2 extends Crypt_CHAP
+      */   
+     function challengeHash() 
+     {
+-        return substr(mhash(MHASH_SHA1, $this->peerChallenge . $this->authChallenge . $this->username), 0, 8);
++        return substr(pack('H*',hash('sha1', $this->peerChallenge . $this->authChallenge . $this->username)), 0, 8);
+     }    
+ 
+     /**
+diff -up Crypt_CHAP-1.0.2/php-pear-Crypt-CHAP.xml.orig Crypt_CHAP-1.0.2/php-pear-Crypt-CHAP.xml
+--- Crypt_CHAP-1.0.2/php-pear-Crypt-CHAP.xml.orig	2010-08-27 21:02:27.000000000 +0200
++++ Crypt_CHAP-1.0.2/php-pear-Crypt-CHAP.xml	2010-08-27 21:03:59.000000000 +0200
+@@ -8,7 +8,7 @@ Currently these types of CHAP are suppor
+ * CHAP-MD5
+ * MS-CHAPv1
+ * MS-CHAPv2
+-For MS-CHAP the mhash and mcrypt extensions must be loaded.</description>
++For MS-CHAP the hash and mcrypt extensions must be loaded.</description>
+  <lead>
+   <name>Michael Bretterklieber</name>
+   <user>mbretter</user>
+@@ -32,7 +32,7 @@ For MS-CHAP the mhash and mcrypt extensi
+  <contents>
+   <dir name="/">
+    <file baseinstalldir="Crypt" md5sum="fe7a2da083c9c0929892d764ae935abd" name="tests/chaptest.php" role="test" />
+-   <file baseinstalldir="Crypt" md5sum="4fefea861d62ae26bedb1f18af5ad99c" name="CHAP.php" role="php" />
++   <file baseinstalldir="Crypt" md5sum="f2c64bac12b6c63c1f9da85c1ab64a87" name="CHAP.php" role="php" />
+   </dir>
+  </contents>
+  <dependencies>
+@@ -46,7 +46,7 @@ For MS-CHAP the mhash and mcrypt extensi
+   </required>
+   <optional>
+    <extension>
+-    <name>mhash</name>
++    <name>hash</name>
+    </extension>
+    <extension>
+     <name>mcrypt</name>
diff --git a/php-pear-Crypt-CHAP.spec b/php-pear-Crypt-CHAP.spec
index 9b50792..36201a3 100644
--- a/php-pear-Crypt-CHAP.spec
+++ b/php-pear-Crypt-CHAP.spec
@@ -3,15 +3,19 @@
 
 Name:           php-pear-Crypt-CHAP
 Version:        1.0.2
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Class to generate CHAP packets
 
 Group:          Development/Languages
 License:        BSD
 URL:            http://pear.php.net/package/Crypt_CHAP
 Source0:        http://pear.php.net/get/%{pear_name}-%{version}.tgz
-BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
+# Replace use of deprecated mhash functions by hash
+# See http://pear.php.net/bugs/17828
+Patch0:         %{pear_name}-hash.patch
+
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch:      noarch
 BuildRequires:  php-pear >= 1:1.4.9-1.2
 Requires:       php-pear(PEAR) php-mcrypt
@@ -37,6 +41,8 @@ cd %{pear_name}-%{version}
 # package.xml is V2
 mv ../package.xml %{name}.xml
 
+%patch0 -p1 -b .hash
+
 
 %build
 cd %{pear_name}-%{version}
@@ -80,6 +86,10 @@ fi
 
 
 %changelog
+* Fri Aug 27 2010 Remi Collet <Fedora at FamilleCollet.com> - 1.0.2-3
+- add patch for deprecated mhash extension 
+  Upstream bug is http://pear.php.net/bugs/17828
+
 * Thu Aug 26 2010 Remi Collet <Fedora at FamilleCollet.com> - 1.0.2-2
 - clean define
 - set date.timezone during build


More information about the scm-commits mailing list