Merge branch '2.0'

This commit is contained in:
terrafrost 2016-10-02 08:18:16 -05:00
commit 711079764e
3 changed files with 23 additions and 22 deletions

View File

@ -5,6 +5,7 @@ php:
- 5.5 - 5.5
- 5.6 - 5.6
- 7.0 - 7.0
- 7.1
- hhvm - hhvm
env: env:
@ -25,7 +26,7 @@ install:
- cd .. - cd ..
- eval `ssh-agent -s` - eval `ssh-agent -s`
- travis/setup-secure-shell.sh - travis/setup-secure-shell.sh
- sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' -a '$TRAVIS_PHP_VERSION' != '7.0' ]; then travis/install-php-extensions.sh; fi" - sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' -a `php -r "echo (int) version_compare(PHP_VERSION, '7.0', '<');"` = "1" ]; then travis/install-php-extensions.sh; fi"
- travis/setup-composer.sh - travis/setup-composer.sh
script: script:

View File

@ -796,7 +796,7 @@ abstract class SymmetricKey
$this->changed = false; $this->changed = false;
} }
if ($this->enchanged) { if ($this->enchanged) {
mcrypt_generic_init($this->enmcrypt, $this->key, $this->_getIV($this->encryptIV)); @mcrypt_generic_init($this->enmcrypt, $this->key, $this->_getIV($this->encryptIV));
$this->enchanged = false; $this->enchanged = false;
} }
@ -829,15 +829,15 @@ abstract class SymmetricKey
if ($len >= $block_size) { if ($len >= $block_size) {
if ($this->enbuffer['enmcrypt_init'] === false || $len > $this->cfb_init_len) { if ($this->enbuffer['enmcrypt_init'] === false || $len > $this->cfb_init_len) {
if ($this->enbuffer['enmcrypt_init'] === true) { if ($this->enbuffer['enmcrypt_init'] === true) {
mcrypt_generic_init($this->enmcrypt, $this->key, $iv); @mcrypt_generic_init($this->enmcrypt, $this->key, $iv);
$this->enbuffer['enmcrypt_init'] = false; $this->enbuffer['enmcrypt_init'] = false;
} }
$ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % $block_size)); $ciphertext.= @mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % $block_size));
$iv = substr($ciphertext, -$block_size); $iv = substr($ciphertext, -$block_size);
$len%= $block_size; $len%= $block_size;
} else { } else {
while ($len >= $block_size) { while ($len >= $block_size) {
$iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size); $iv = @mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size);
$ciphertext.= $iv; $ciphertext.= $iv;
$len-= $block_size; $len-= $block_size;
$i+= $block_size; $i+= $block_size;
@ -846,7 +846,7 @@ abstract class SymmetricKey
} }
if ($len) { if ($len) {
$iv = mcrypt_generic($this->ecb, $iv); $iv = @mcrypt_generic($this->ecb, $iv);
$block = $iv ^ substr($plaintext, -$len); $block = $iv ^ substr($plaintext, -$len);
$iv = substr_replace($iv, $block, 0, $len); $iv = substr_replace($iv, $block, 0, $len);
$ciphertext.= $block; $ciphertext.= $block;
@ -856,10 +856,10 @@ abstract class SymmetricKey
return $ciphertext; return $ciphertext;
} }
$ciphertext = mcrypt_generic($this->enmcrypt, $plaintext); $ciphertext = @mcrypt_generic($this->enmcrypt, $plaintext);
if (!$this->continuousBuffer) { if (!$this->continuousBuffer) {
mcrypt_generic_init($this->enmcrypt, $this->key, $this->_getIV($this->encryptIV)); @mcrypt_generic_init($this->enmcrypt, $this->key, $this->_getIV($this->encryptIV));
} }
return $ciphertext; return $ciphertext;
@ -1107,7 +1107,7 @@ abstract class SymmetricKey
$this->changed = false; $this->changed = false;
} }
if ($this->dechanged) { if ($this->dechanged) {
mcrypt_generic_init($this->demcrypt, $this->key, $this->_getIV($this->decryptIV)); @mcrypt_generic_init($this->demcrypt, $this->key, $this->_getIV($this->decryptIV));
$this->dechanged = false; $this->dechanged = false;
} }
@ -1135,12 +1135,12 @@ abstract class SymmetricKey
} }
if ($len >= $block_size) { if ($len >= $block_size) {
$cb = substr($ciphertext, $i, $len - $len % $block_size); $cb = substr($ciphertext, $i, $len - $len % $block_size);
$plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; $plaintext.= @mcrypt_generic($this->ecb, $iv . $cb) ^ $cb;
$iv = substr($cb, -$block_size); $iv = substr($cb, -$block_size);
$len%= $block_size; $len%= $block_size;
} }
if ($len) { if ($len) {
$iv = mcrypt_generic($this->ecb, $iv); $iv = @mcrypt_generic($this->ecb, $iv);
$plaintext.= $iv ^ substr($ciphertext, -$len); $plaintext.= $iv ^ substr($ciphertext, -$len);
$iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len);
$pos = $len; $pos = $len;
@ -1149,10 +1149,10 @@ abstract class SymmetricKey
return $plaintext; return $plaintext;
} }
$plaintext = mdecrypt_generic($this->demcrypt, $ciphertext); $plaintext = @mdecrypt_generic($this->demcrypt, $ciphertext);
if (!$this->continuousBuffer) { if (!$this->continuousBuffer) {
mcrypt_generic_init($this->demcrypt, $this->key, $this->_getIV($this->decryptIV)); @mcrypt_generic_init($this->demcrypt, $this->key, $this->_getIV($this->decryptIV));
} }
return $this->paddable ? $this->_unpad($plaintext) : $plaintext; return $this->paddable ? $this->_unpad($plaintext) : $plaintext;
@ -1630,7 +1630,7 @@ abstract class SymmetricKey
case self::ENGINE_MCRYPT: case self::ENGINE_MCRYPT:
return $this->cipher_name_mcrypt && return $this->cipher_name_mcrypt &&
extension_loaded('mcrypt') && extension_loaded('mcrypt') &&
in_array($this->cipher_name_mcrypt, mcrypt_list_algorithms()); in_array($this->cipher_name_mcrypt, @mcrypt_list_algorithms());
case self::ENGINE_INTERNAL: case self::ENGINE_INTERNAL:
return true; return true;
} }
@ -1709,13 +1709,13 @@ abstract class SymmetricKey
if ($this->engine != self::ENGINE_MCRYPT && $this->enmcrypt) { if ($this->engine != self::ENGINE_MCRYPT && $this->enmcrypt) {
// Closing the current mcrypt resource(s). _mcryptSetup() will, if needed, // Closing the current mcrypt resource(s). _mcryptSetup() will, if needed,
// (re)open them with the module named in $this->cipher_name_mcrypt // (re)open them with the module named in $this->cipher_name_mcrypt
mcrypt_module_close($this->enmcrypt); @mcrypt_module_close($this->enmcrypt);
mcrypt_module_close($this->demcrypt); @mcrypt_module_close($this->demcrypt);
$this->enmcrypt = null; $this->enmcrypt = null;
$this->demcrypt = null; $this->demcrypt = null;
if ($this->ecb) { if ($this->ecb) {
mcrypt_module_close($this->ecb); @mcrypt_module_close($this->ecb);
$this->ecb = null; $this->ecb = null;
} }
} }
@ -1829,19 +1829,19 @@ abstract class SymmetricKey
self::MODE_STREAM => MCRYPT_MODE_STREAM, self::MODE_STREAM => MCRYPT_MODE_STREAM,
); );
$this->demcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); $this->demcrypt = @mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], '');
$this->enmcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); $this->enmcrypt = @mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], '');
// we need the $ecb mcrypt resource (only) in MODE_CFB with enableContinuousBuffer() // we need the $ecb mcrypt resource (only) in MODE_CFB with enableContinuousBuffer()
// to workaround mcrypt's broken ncfb implementation in buffered mode // to workaround mcrypt's broken ncfb implementation in buffered mode
// see: {@link http://phpseclib.sourceforge.net/cfb-demo.phps} // see: {@link http://phpseclib.sourceforge.net/cfb-demo.phps}
if ($this->mode == self::MODE_CFB) { if ($this->mode == self::MODE_CFB) {
$this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, ''); $this->ecb = @mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, '');
} }
} // else should mcrypt_generic_deinit be called? } // else should mcrypt_generic_deinit be called?
if ($this->mode == self::MODE_CFB) { if ($this->mode == self::MODE_CFB) {
mcrypt_generic_init($this->ecb, $this->key, str_repeat("\0", $this->block_size)); @mcrypt_generic_init($this->ecb, $this->key, str_repeat("\0", $this->block_size));
} }
} }

View File

@ -20,7 +20,7 @@ then
PHPUNIT_ARGS="$PHPUNIT_ARGS -d zend.enable_gc=0" PHPUNIT_ARGS="$PHPUNIT_ARGS -d zend.enable_gc=0"
fi fi
if [ "$TRAVIS_PHP_VERSION" = 'hhvm' -o "$TRAVIS_PHP_VERSION" = '7.0' ] if [ "$TRAVIS_PHP_VERSION" = 'hhvm' -o `php -r "echo (int) version_compare(PHP_VERSION, '7.0', '>=');"` = "1" ]
then then
find tests -type f -name "*Test.php" | \ find tests -type f -name "*Test.php" | \
parallel --gnu --keep-order \ parallel --gnu --keep-order \