From f780640ecf726809314035936ce1114686de1f75 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 12 May 2020 22:03:06 -0500 Subject: [PATCH] move more common elements to StreamCipher class --- phpseclib/Crypt/Common/StreamCipher.php | 22 ++++++++++++++++++++++ phpseclib/Crypt/RC4.php | 24 ------------------------ phpseclib/Crypt/Salsa20.php | 21 --------------------- 3 files changed, 22 insertions(+), 45 deletions(-) diff --git a/phpseclib/Crypt/Common/StreamCipher.php b/phpseclib/Crypt/Common/StreamCipher.php index bb176cfe..f4d076d0 100644 --- a/phpseclib/Crypt/Common/StreamCipher.php +++ b/phpseclib/Crypt/Common/StreamCipher.php @@ -24,6 +24,28 @@ namespace phpseclib3\Crypt\Common; */ abstract class StreamCipher extends SymmetricKey { + /** + * Block Length of the cipher + * + * Stream ciphers do not have a block size + * + * @see \phpseclib3\Crypt\Common\SymmetricKey::block_size + * @var int + * @access private + */ + protected $block_size = 0; + + /** + * Default Constructor. + * + * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct() + * @return \phpseclib3\Crypt\Common\StreamCipher + */ + public function __construct() + { + parent::__construct('stream'); + } + /** * Stream ciphers not use an IV * diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index 8d791f6c..a460970e 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -63,18 +63,6 @@ class RC4 extends StreamCipher const DECRYPT = 1; /**#@-*/ - /** - * Block Length of the cipher - * - * RC4 is a stream cipher - * so we the block_size to 0 - * - * @see \phpseclib3\Crypt\Common\SymmetricKey::block_size - * @var int - * @access private - */ - protected $block_size = 0; - /** * Key Length (in bytes) * @@ -111,18 +99,6 @@ class RC4 extends StreamCipher */ private $stream; - /** - * Default Constructor. - * - * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct() - * @return \phpseclib3\Crypt\RC4 - * @access public - */ - public function __construct() - { - parent::__construct('stream'); - } - /** * Test for engine validity * diff --git a/phpseclib/Crypt/Salsa20.php b/phpseclib/Crypt/Salsa20.php index 9d35dafa..4bc71262 100644 --- a/phpseclib/Crypt/Salsa20.php +++ b/phpseclib/Crypt/Salsa20.php @@ -50,16 +50,6 @@ class Salsa20 extends StreamCipher */ protected $key_length = 32; // = 256 bits - /** - * Block Length of the cipher - * - * Salsa20 is a stream cipher - * so we the block_size to 0 - * - * @var int - */ - protected $block_size = 0; - /**#@+ * @access private * @see \phpseclib3\Crypt\Salsa20::crypt() @@ -96,17 +86,6 @@ class Salsa20 extends StreamCipher */ protected $usingGeneratedPoly1305Key = false; - /** - * Default Constructor. - * - * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct() - * @return \phpseclib3\Crypt\Salsa20 - */ - public function __construct() - { - parent::__construct('stream'); - } - /** * Salsa20 uses a nonce *