1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-14 18:15:39 +01:00

Merge branch '3.0'

This commit is contained in:
terrafrost 2021-02-02 20:39:16 -06:00
commit 1e42ae8138
2 changed files with 41 additions and 1 deletions

View File

@ -237,7 +237,7 @@ abstract class SymmetricKey
* @var string * @var string
* @access private * @access private
*/ */
private $iv = false; protected $iv = false;
/** /**
* A "sliding" Initialization Vector * A "sliding" Initialization Vector

View File

@ -59,6 +59,7 @@ use phpseclib3\Crypt\Common\BlockCipher;
use phpseclib3\Common\Functions\Strings; use phpseclib3\Common\Functions\Strings;
use phpseclib3\Exception\BadModeException; use phpseclib3\Exception\BadModeException;
use phpseclib3\Exception\InsufficientSetupException; use phpseclib3\Exception\InsufficientSetupException;
use phpseclib3\Exception\InconsistentSetupException;
use phpseclib3\Exception\BadDecryptionException; use phpseclib3\Exception\BadDecryptionException;
/** /**
@ -490,6 +491,45 @@ class Rijndael extends BlockCipher
return pack('N*', ...$temp); return pack('N*', ...$temp);
} }
/**
* Setup the self::ENGINE_INTERNAL $engine
*
* (re)init, if necessary, the internal cipher $engine and flush all $buffers
* Used (only) if $engine == self::ENGINE_INTERNAL
*
* _setup() will be called each time if $changed === true
* typically this happens when using one or more of following public methods:
*
* - setKey()
*
* - setIV()
*
* - disableContinuousBuffer()
*
* - First run of encrypt() / decrypt() with no init-settings
*
* {@internal setup() is always called before en/decryption.}
*
* {@internal Could, but not must, extend by the child Crypt_* class}
*
* @see self::setKey()
* @see self::setIV()
* @see self::disableContinuousBuffer()
* @access private
*/
protected function setup()
{
if (!$this->changed) {
return;
}
parent::setup();
if (is_string($this->iv) && strlen($this->iv) != $this->block_size) {
throw new InconsistentSetupException('The IV length (' . strlen($this->iv) . ') does not match the block size (' . $this->block_size . ')');
}
}
/** /**
* Setup the key (expansion) * Setup the key (expansion)
* *