Skip to content

Commit

Permalink
Don't use Sodium mixer on HHVM. Allow master/nightly to fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-security committed Oct 6, 2017
1 parent cc73417 commit 2c5ea6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ matrix:
env: USE_PSALM=1
- php: "hhvm"
env: USE_PSALM=1
allow_failures:
- php: "master"
- php: "nightly"

before_script:
- travis_retry composer self-update
Expand Down
7 changes: 4 additions & 3 deletions lib/RandomLib/Mixer/SodiumMixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function getStrength()
*/
public static function test()
{
return is_callable('sodium_crypto_stream') && is_callable('sodium_crypto_generichash');
return is_callable('sodium_crypto_stream') && is_callable('sodium_crypto_generichash') && !defined('HHVM_VERSION');
}
/**
* Get the block size (the size of the individual blocks used for the mixing)
Expand All @@ -67,7 +67,7 @@ protected function getPartSize()
*/
protected function mixParts1($part1, $part2)
{
return \sodium_crypto_generichash($part1 . $part2, '', $this->getPartSize());
return (string) \sodium_crypto_generichash($part1 . $part2, '', $this->getPartSize());
}

/**
Expand All @@ -83,10 +83,11 @@ protected function mixParts1($part1, $part2)
protected function mixParts2($part1, $part2)
{
// Pre-hash the two inputs into a 448-bit output
/** @var string $hash */
$hash = \sodium_crypto_generichash($part1 . $part2, '', 56);

// Use salsa20 to expand into a pseudorandom string
return \sodium_crypto_stream(
return (string) \sodium_crypto_stream(
$this->getPartSize(),
Util::safeSubstr($hash, 0, 24),
Util::safeSubstr($hash, 0, 32)
Expand Down

0 comments on commit 2c5ea6c

Please sign in to comment.