-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from paragonie/optimize
32-bit curve25519 speedup (important for WordPress)
- Loading branch information
Showing
4 changed files
with
194 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* Class Int64Test | ||
*/ | ||
class Int64TestTemp extends PHPUnit_Framework_TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
if (PHP_INT_SIZE === 8) { | ||
$this->markTestSkipped('Only relevant to 32-bit platforms.'); | ||
} | ||
ParagonIE_Sodium_Compat::$fastMult = true; | ||
} | ||
|
||
|
||
/** | ||
* @covers ParagonIE_Sodium_Core32_Int64::mulInt() | ||
* @covers ParagonIE_Sodium_Core32_Int64::mulInt64() | ||
* @throws SodiumException | ||
* @throws TypeError | ||
*/ | ||
public function testMult() | ||
{ | ||
for ($j = 0; $j < 64; ++$j) { | ||
$baseSmall = random_int(1, 65536); | ||
$base = new ParagonIE_Sodium_Core32_Int64(array(0, 0, 0, $baseSmall)); | ||
for ($i = 0; $i < 64; ++$i) { | ||
$value = random_int(1, 65536); | ||
$result = ($baseSmall * $value); | ||
$expected = array( | ||
0, | ||
0, | ||
($result >> 16) & 0xffff, | ||
$result & 0xffff | ||
); | ||
$this->assertSame( | ||
$expected, | ||
$base->mulInt($value)->limbs, | ||
$baseSmall . ' x ' . $value . ' = ' . $result | ||
); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters