SHA256: Fixed broken hashes on 64-bit PHP
authorDan
Thu, 02 Jul 2009 08:58:54 -0400
changeset 1030 23959360dcfd
parent 1029 1d9846ec37f5
child 1031 8a4b75e73137
SHA256: Fixed broken hashes on 64-bit PHP
includes/diffiehellman.php
--- a/includes/diffiehellman.php	Thu Jul 02 08:57:13 2009 -0400
+++ b/includes/diffiehellman.php	Thu Jul 02 08:58:54 2009 -0400
@@ -107,7 +107,8 @@
   function safe_add ($x, $y) {
     $lsw = ($x & 0xFFFF) + ($y & 0xFFFF);
     $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16);
-    return ($msw << 16) | ($lsw & 0xFFFF);
+    // 2009-07-02 Added & 0xFFFFFFFF here to fix problem on PHP w/ native 64-bit integer support (rev. 1030)
+    return (($msw << 16) | ($lsw & 0xFFFF)) & 0xFFFFFFFF;
   }
   function rshz($X, $n)
   {