includes/diffiehellman.php
changeset 1030 23959360dcfd
parent 801 eb8b23f11744
child 1080 6358f769ecb1
equal deleted inserted replaced
1029:1d9846ec37f5 1030:23959360dcfd
   105   var $chrsz = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode  */
   105   var $chrsz = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode  */
   106   
   106   
   107   function safe_add ($x, $y) {
   107   function safe_add ($x, $y) {
   108     $lsw = ($x & 0xFFFF) + ($y & 0xFFFF);
   108     $lsw = ($x & 0xFFFF) + ($y & 0xFFFF);
   109     $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16);
   109     $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16);
   110     return ($msw << 16) | ($lsw & 0xFFFF);
   110     // 2009-07-02 Added & 0xFFFFFFFF here to fix problem on PHP w/ native 64-bit integer support (rev. 1030)
       
   111     return (($msw << 16) | ($lsw & 0xFFFF)) & 0xFFFFFFFF;
   111   }
   112   }
   112   function rshz($X, $n)
   113   function rshz($X, $n)
   113   {
   114   {
   114     // equivalent to $X >>> $n in javascript
   115     // equivalent to $X >>> $n in javascript
   115     // pulled from http://www.tapouillo.com/firefox_extension/sourcecode.txt, public domain
   116     // pulled from http://www.tapouillo.com/firefox_extension/sourcecode.txt, public domain