From c2e22b6c3806033f8a1935010cf875c1f243fa4a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 7 Nov 2020 19:08:35 +0100 Subject: [PATCH] Continued: - proper packages/namespaces and common BaseCryptoStream class - also $rngInstance must be here, too MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- framework/config-global.php | 6 +- .../streams/crypto/class_BaseCryptoStream.php | 67 +++++++++++++++++++ .../{ => mcrypt}/class_McryptStream.php | 7 +- .../{ => null}/class_NullCryptoStream.php | 7 +- .../{ => openssl}/class_OpenSslStream.php | 7 +- 5 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 framework/main/classes/streams/crypto/class_BaseCryptoStream.php rename framework/main/classes/streams/crypto/{ => mcrypt}/class_McryptStream.php (96%) rename framework/main/classes/streams/crypto/{ => null}/class_NullCryptoStream.php (91%) rename framework/main/classes/streams/crypto/{ => openssl}/class_OpenSslStream.php (96%) diff --git a/framework/config-global.php b/framework/config-global.php index 1a3819e9..8ba651e3 100644 --- a/framework/config-global.php +++ b/framework/config-global.php @@ -467,10 +467,10 @@ $cfg->setConfigEntry('thousands_separator', '.'); $cfg->setConfigEntry('decimals_separator', ','); // CFG: CRYPTO-MCRYPT-STREAM-CLASS -$cfg->setConfigEntry('crypto_mcrypt_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\McryptStream'); +$cfg->setConfigEntry('crypto_mcrypt_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\Mcrypt\McryptStream'); // CFG: CRYPTO-OPENSSL-STREAM-CLASS -$cfg->setConfigEntry('crypto_openssl_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\OpenSslStream'); +$cfg->setConfigEntry('crypto_openssl_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\OpenSsl\OpenSslStream'); // CFG: CRYPTO-NULL-STREAM-CLASS -$cfg->setConfigEntry('crypto_null_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\NullCryptoStream'); +$cfg->setConfigEntry('crypto_null_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\Null\NullCryptoStream'); diff --git a/framework/main/classes/streams/crypto/class_BaseCryptoStream.php b/framework/main/classes/streams/crypto/class_BaseCryptoStream.php new file mode 100644 index 00000000..b8ffcac0 --- /dev/null +++ b/framework/main/classes/streams/crypto/class_BaseCryptoStream.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseCryptoStream extends BaseStream { + /** + * Instance of a RNG + */ + private $rngInstance = NULL; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct (string $className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for RNG instance + * + * @param $rngInstance An instance of a random number generator (RNG) + * @return void + */ + protected final function setRngInstance (RandomNumberGenerator $rngInstance) { + $this->rngInstance = $rngInstance; + } + + /** + * Getter for RNG instance + * + * @return $rngInstance An instance of a random number generator (RNG) + */ + protected final function getRngInstance () { + return $this->rngInstance; + } + +} diff --git a/framework/main/classes/streams/crypto/class_McryptStream.php b/framework/main/classes/streams/crypto/mcrypt/class_McryptStream.php similarity index 96% rename from framework/main/classes/streams/crypto/class_McryptStream.php rename to framework/main/classes/streams/crypto/mcrypt/class_McryptStream.php index a704498d..265b1816 100644 --- a/framework/main/classes/streams/crypto/class_McryptStream.php +++ b/framework/main/classes/streams/crypto/mcrypt/class_McryptStream.php @@ -1,11 +1,12 @@ . */ -class McryptStream extends BaseStream implements EncryptableStream { +class McryptStream extends BaseCryptoStream implements EncryptableStream { /** * Protected constructor * diff --git a/framework/main/classes/streams/crypto/class_NullCryptoStream.php b/framework/main/classes/streams/crypto/null/class_NullCryptoStream.php similarity index 91% rename from framework/main/classes/streams/crypto/class_NullCryptoStream.php rename to framework/main/classes/streams/crypto/null/class_NullCryptoStream.php index 1c1fe4a7..6564497e 100644 --- a/framework/main/classes/streams/crypto/class_NullCryptoStream.php +++ b/framework/main/classes/streams/crypto/null/class_NullCryptoStream.php @@ -1,10 +1,11 @@ . */ -class NullCryptoStream extends BaseStream implements EncryptableStream { +class NullCryptoStream extends BaseCryptoStream implements EncryptableStream { /** * Protected constructor * diff --git a/framework/main/classes/streams/crypto/class_OpenSslStream.php b/framework/main/classes/streams/crypto/openssl/class_OpenSslStream.php similarity index 96% rename from framework/main/classes/streams/crypto/class_OpenSslStream.php rename to framework/main/classes/streams/crypto/openssl/class_OpenSslStream.php index c0efc047..b81bd1a1 100644 --- a/framework/main/classes/streams/crypto/class_OpenSslStream.php +++ b/framework/main/classes/streams/crypto/openssl/class_OpenSslStream.php @@ -1,11 +1,12 @@ . */ -class OpenSslStream extends BaseStream implements EncryptableStream { +class OpenSslStream extends BaseCryptoStream implements EncryptableStream { /** * Protected constructor * -- 2.39.5