wp/wp-includes/sodium_compat/src/Core32/Int32.php
changeset 19 3d72ae0968f4
parent 9 177826044cd9
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
   136      * @return ParagonIE_Sodium_Core32_Int32
   136      * @return ParagonIE_Sodium_Core32_Int32
   137      */
   137      */
   138     public function mask($m = 0)
   138     public function mask($m = 0)
   139     {
   139     {
   140         /** @var int $hi */
   140         /** @var int $hi */
   141         $hi = ($m >> 16) & 0xffff;
   141         $hi = ((int) $m >> 16);
       
   142         $hi &= 0xffff;
   142         /** @var int $lo */
   143         /** @var int $lo */
   143         $lo = ($m & 0xffff);
   144         $lo = ((int) $m) & 0xffff;
   144         return new ParagonIE_Sodium_Core32_Int32(
   145         return new ParagonIE_Sodium_Core32_Int32(
   145             array(
   146             array(
   146                 (int) ($this->limbs[0] & $hi),
   147                 (int) ($this->limbs[0] & $hi),
   147                 (int) ($this->limbs[1] & $lo)
   148                 (int) ($this->limbs[1] & $lo)
   148             ),
   149             ),
   166         for ($i = 0; $i < $a_l; ++$i) {
   167         for ($i = 0; $i < $a_l; ++$i) {
   167             $a_i = $a[$i];
   168             $a_i = $a[$i];
   168             for ($j = 0; $j < $a_l; ++$j) {
   169             for ($j = 0; $j < $a_l; ++$j) {
   169                 $b_j = $b[$j];
   170                 $b_j = $b[$j];
   170                 $product = ($a_i * $b_j) + $r[$i + $j];
   171                 $product = ($a_i * $b_j) + $r[$i + $j];
   171                 $carry = ($product >> $baseLog2 & 0xffff);
   172                 $carry = ((int) $product >> $baseLog2 & 0xffff);
   172                 $r[$i + $j] = ($product - (int) ($carry * $base)) & 0xffff;
   173                 $r[$i + $j] = ((int) $product - (int) ($carry * $base)) & 0xffff;
   173                 $r[$i + $j + 1] += $carry;
   174                 $r[$i + $j + 1] += $carry;
   174             }
   175             }
   175         }
   176         }
   176         return array_slice($r, 0, 5);
   177         return array_slice($r, 0, 5);
   177     }
   178     }