first commit

This commit is contained in:
Robot 2023-10-09 11:38:00 +02:00
commit f6ad788c3e
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
34 changed files with 2564 additions and 0 deletions

63
README.md Normal file
View File

@ -0,0 +1,63 @@
```
███████╗██╗ ██╗██████╗ ███████╗██████╗
██╔════╝██║ ██║██╔══██╗██╔════╝██╔══██╗
███████╗██║ ██║██████╔╝█████╗ ██████╔╝
╚════██║██║ ██║██╔═══╝ ██╔══╝ ██╔══██╗
███████║╚██████╔╝██║ ███████╗██║ ██║
╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝███████╗
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗╚════██║
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║███████║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝╚══════╝
```
### What is JCB Super Powers?
The Joomla Component Builder (JCB) Super Power features are designed to enhance JCB's functionality and streamline the development process. These Super Powers enable developers to efficiently manage and share their custom powers across multiple JCB instances through repositories hosted on [https://git.vdm.dev/[username]/[repository-name]](https://git.vdm.dev). JCB Super Powers are managed using a combination of layers, events, tasks, methods, switches, and algorithms, which work together to provide powerful customization and extensibility options. More details on JCB Super Powers can be found in the [Super Powers Documentation](https://git.vdm.dev/joomla/super-powers/wiki).
In summary, JCB Super Powers offer a flexible and efficient way to manage and share functionalities between JCB instances. By utilizing a sophisticated system of layers, events, tasks, methods, switches, and algorithms, developers can seamlessly integrate JCB core powers and their custom powers. For more information on how to work with JCB Super Powers, refer to the [Super Powers User Guide](https://git.vdm.dev/joomla/super-powers/wiki).
### What can I find here?
This repository contains an index (see below) of all the approved powers within the JCB GUI. During the compilation of a component, these powers are automatically added to the repository, ensuring a well-organized and accessible collection of functionalities.
# Index of powers
- **Namespace**: [VDM\Joomla\FOF\Encrypt](#vdm-joomla-fof-encrypt)
- **interface Randvalinterface** | [Details](src/ba82e88a-254d-4ba4-99a3-ea69ed814f5c) | [Code](src/ba82e88a-254d-4ba4-99a3-ea69ed814f5c/code.php) | [Settings](src/ba82e88a-254d-4ba4-99a3-ea69ed814f5c/settings.json) | Super__ba82e88a_254d_4ba4_99a3_ea69ed814f5c__Power
- **class AES** | [Details](src/99175f6d-dba8-4086-8a65-5c4ec175e61d) | [Code](src/99175f6d-dba8-4086-8a65-5c4ec175e61d/code.php) | [Settings](src/99175f6d-dba8-4086-8a65-5c4ec175e61d/settings.json) | Super__99175f6d_dba8_4086_8a65_5c4ec175e61d__Power
- **class Randval** | [Details](src/eef08a1d-5367-4464-8d07-d47c479fb76f) | [Code](src/eef08a1d-5367-4464-8d07-d47c479fb76f/code.php) | [Settings](src/eef08a1d-5367-4464-8d07-d47c479fb76f/settings.json) | Super__eef08a1d_5367_4464_8d07_d47c479fb76f__Power
- **Namespace**: [VDM\Joomla\FOF\Utils](#vdm-joomla-fof-utils)
- **class Phpfunc** | [Details](src/470a08ee-6b31-4a2b-98d9-5b64757a3b34) | [Code](src/470a08ee-6b31-4a2b-98d9-5b64757a3b34/code.php) | [Settings](src/470a08ee-6b31-4a2b-98d9-5b64757a3b34/settings.json) | Super__470a08ee_6b31_4a2b_98d9_5b64757a3b34__Power
- **Namespace**: [VDM\Joomla\FOF\Encrypt\AES](#vdm-joomla-fof-encrypt-aes)
- **interface AesInterface** | [Details](src/7f753585-6e3b-4b81-bd29-3b7bdf0e3769) | [Code](src/7f753585-6e3b-4b81-bd29-3b7bdf0e3769/code.php) | [Settings](src/7f753585-6e3b-4b81-bd29-3b7bdf0e3769/settings.json) | Super__7f753585_6e3b_4b81_bd29_3b7bdf0e3769__Power
- **abstract class Abstraction** | [Details](src/4c89df31-8b94-40bb-94fc-7ec378145044) | [Code](src/4c89df31-8b94-40bb-94fc-7ec378145044/code.php) | [Settings](src/4c89df31-8b94-40bb-94fc-7ec378145044/settings.json) | Super__4c89df31_8b94_40bb_94fc_7ec378145044__Power
- **class Mcrypt** | [Details](src/25da88d3-f7b2-4666-977f-e68ff731d1e8) | [Code](src/25da88d3-f7b2-4666-977f-e68ff731d1e8/code.php) | [Settings](src/25da88d3-f7b2-4666-977f-e68ff731d1e8/settings.json) | Super__25da88d3_f7b2_4666_977f_e68ff731d1e8__Power
- **class Openssl** | [Details](src/885cc1cf-1904-483c-aecc-6af916c329e7) | [Code](src/885cc1cf-1904-483c-aecc-6af916c329e7/code.php) | [Settings](src/885cc1cf-1904-483c-aecc-6af916c329e7/settings.json) | Super__885cc1cf_1904_483c_aecc_6af916c329e7__Power
---
```
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,43 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Mcrypt (Details)
> namespace: **VDM\Joomla\FOF\Encrypt\AES**
> extends: **Abstraction**
```uml
@startuml
class Mcrypt #Gold {
+ setEncryptionMode($mode = 'cbc', $strength = 128)
+ encrypt($plainText, $key, ...)
+ decrypt($cipherText, $key)
+ isSupported(Phpfunc $phpfunc = null)
+ getBlockSize()
}
note right of Mcrypt::encrypt
arguments:
$plainText
$key
$iv = null
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,178 @@
<?php
/**
* @package FrameworkOnFramework
* @subpackage Encryption
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
* - Do not use this in new projects.
* - Expect no updates.
* - This is outdated.
* - Not best choice for encryption.
* - Use phpseclib/phpseclib version 3 Instead.
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
*/
namespace VDM\Joomla\FOF\Encrypt\AES;
use VDM\Joomla\FOF\Encrypt\Randval;
use VDM\Joomla\FOF\Utils\Phpfunc;
use VDM\Joomla\FOF\Encrypt\AES\AesInterface;
use VDM\Joomla\FOF\Encrypt\AES\Abstraction;
/**
* Mcrypt AES encryption class
*
* @package FrameworkOnFramework
* @since 1.0
* @deprecated Use phpseclib/phpseclib version 3 Instead.
*/
class Mcrypt extends Abstraction implements AesInterface
{
protected $cipherType = MCRYPT_RIJNDAEL_128;
protected $cipherMode = MCRYPT_MODE_CBC;
public function setEncryptionMode($mode = 'cbc', $strength = 128)
{
switch ((int) $strength)
{
default:
case '128':
$this->cipherType = MCRYPT_RIJNDAEL_128;
break;
case '192':
$this->cipherType = MCRYPT_RIJNDAEL_192;
break;
case '256':
$this->cipherType = MCRYPT_RIJNDAEL_256;
break;
}
switch (strtolower($mode))
{
case 'ecb':
$this->cipherMode = MCRYPT_MODE_ECB;
break;
default:
case 'cbc':
$this->cipherMode = MCRYPT_MODE_CBC;
break;
}
}
public function encrypt($plainText, $key, $iv = null)
{
$iv_size = $this->getBlockSize();
$key = $this->resizeKey($key, $iv_size);
$iv = $this->resizeKey($iv, $iv_size);
if (empty($iv))
{
$randVal = new Randval();
$iv = $randVal->generate($iv_size);
}
$cipherText = mcrypt_encrypt($this->cipherType, $key, $plainText, $this->cipherMode, $iv);
$cipherText = $iv . $cipherText;
return $cipherText;
}
public function decrypt($cipherText, $key)
{
$iv_size = $this->getBlockSize();
$key = $this->resizeKey($key, $iv_size);
$iv = substr($cipherText, 0, $iv_size);
$cipherText = substr($cipherText, $iv_size);
$plainText = mcrypt_decrypt($this->cipherType, $key, $cipherText, $this->cipherMode, $iv);
return $plainText;
}
public function isSupported(Phpfunc $phpfunc = null)
{
if (!is_object($phpfunc) || !($phpfunc instanceof $phpfunc))
{
$phpfunc = new Phpfunc();
}
if (!$phpfunc->function_exists('mcrypt_get_key_size'))
{
return false;
}
if (!$phpfunc->function_exists('mcrypt_get_iv_size'))
{
return false;
}
if (!$phpfunc->function_exists('mcrypt_create_iv'))
{
return false;
}
if (!$phpfunc->function_exists('mcrypt_encrypt'))
{
return false;
}
if (!$phpfunc->function_exists('mcrypt_decrypt'))
{
return false;
}
if (!$phpfunc->function_exists('mcrypt_list_algorithms'))
{
return false;
}
if (!$phpfunc->function_exists('hash'))
{
return false;
}
if (!$phpfunc->function_exists('hash_algos'))
{
return false;
}
$algorightms = $phpfunc->mcrypt_list_algorithms();
if (!in_array('rijndael-128', $algorightms))
{
return false;
}
if (!in_array('rijndael-192', $algorightms))
{
return false;
}
if (!in_array('rijndael-256', $algorightms))
{
return false;
}
$algorightms = $phpfunc->hash_algos();
if (!in_array('sha256', $algorightms))
{
return false;
}
return true;
}
public function getBlockSize()
{
return mcrypt_get_iv_size($this->cipherType, $this->cipherMode);
}
}

View File

@ -0,0 +1,143 @@
protected $cipherType = MCRYPT_RIJNDAEL_128;
protected $cipherMode = MCRYPT_MODE_CBC;
public function setEncryptionMode($mode = 'cbc', $strength = 128)
{
switch ((int) $strength)
{
default:
case '128':
$this->cipherType = MCRYPT_RIJNDAEL_128;
break;
case '192':
$this->cipherType = MCRYPT_RIJNDAEL_192;
break;
case '256':
$this->cipherType = MCRYPT_RIJNDAEL_256;
break;
}
switch (strtolower($mode))
{
case 'ecb':
$this->cipherMode = MCRYPT_MODE_ECB;
break;
default:
case 'cbc':
$this->cipherMode = MCRYPT_MODE_CBC;
break;
}
}
public function encrypt($plainText, $key, $iv = null)
{
$iv_size = $this->getBlockSize();
$key = $this->resizeKey($key, $iv_size);
$iv = $this->resizeKey($iv, $iv_size);
if (empty($iv))
{
$randVal = new Randval();
$iv = $randVal->generate($iv_size);
}
$cipherText = mcrypt_encrypt($this->cipherType, $key, $plainText, $this->cipherMode, $iv);
$cipherText = $iv . $cipherText;
return $cipherText;
}
public function decrypt($cipherText, $key)
{
$iv_size = $this->getBlockSize();
$key = $this->resizeKey($key, $iv_size);
$iv = substr($cipherText, 0, $iv_size);
$cipherText = substr($cipherText, $iv_size);
$plainText = mcrypt_decrypt($this->cipherType, $key, $cipherText, $this->cipherMode, $iv);
return $plainText;
}
public function isSupported(Phpfunc $phpfunc = null)
{
if (!is_object($phpfunc) || !($phpfunc instanceof $phpfunc))
{
$phpfunc = new Phpfunc();
}
if (!$phpfunc->function_exists('mcrypt_get_key_size'))
{
return false;
}
if (!$phpfunc->function_exists('mcrypt_get_iv_size'))
{
return false;
}
if (!$phpfunc->function_exists('mcrypt_create_iv'))
{
return false;
}
if (!$phpfunc->function_exists('mcrypt_encrypt'))
{
return false;
}
if (!$phpfunc->function_exists('mcrypt_decrypt'))
{
return false;
}
if (!$phpfunc->function_exists('mcrypt_list_algorithms'))
{
return false;
}
if (!$phpfunc->function_exists('hash'))
{
return false;
}
if (!$phpfunc->function_exists('hash_algos'))
{
return false;
}
$algorightms = $phpfunc->mcrypt_list_algorithms();
if (!in_array('rijndael-128', $algorightms))
{
return false;
}
if (!in_array('rijndael-192', $algorightms))
{
return false;
}
if (!in_array('rijndael-256', $algorightms))
{
return false;
}
$algorightms = $phpfunc->hash_algos();
if (!in_array('sha256', $algorightms))
{
return false;
}
return true;
}
public function getBlockSize()
{
return mcrypt_get_iv_size($this->cipherType, $this->cipherMode);
}

View File

@ -0,0 +1,29 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "4c89df31-8b94-40bb-94fc-7ec378145044",
"guid": "25da88d3-f7b2-4666-977f-e68ff731d1e8",
"implements": [
"7f753585-6e3b-4b81-bd29-3b7bdf0e3769"
],
"load_selection": null,
"name": "Mcrypt",
"power_version": "1.0.0",
"system_name": "FOF.Encrypt.AES.Mcrypt",
"type": "class",
"use_selection": {
"use_selection0": {
"use": "eef08a1d-5367-4464-8d07-d47c479fb76f",
"as": "default"
},
"use_selection1": {
"use": "470a08ee-6b31-4a2b-98d9-5b64757a3b34",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\FOF\\Encrypt.AES.Mcrypt",
"description": "Mcrypt AES encryption class\r\n\r\n@package FrameworkOnFramework\r\n@since 1.0\r\n@deprecated Use phpseclib\/phpseclib version 3 Instead. ",
"licensing_template": "\/**\r\n * @package FrameworkOnFramework\r\n * @subpackage Encryption\r\n * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos \/ Akeeba Ltd. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n * @note\t This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.\r\n * @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.\r\n * - Do not use this in new projects.\r\n * - Expect no updates.\r\n * - This is outdated.\r\n * - Not best choice for encryption.\r\n * - Use phpseclib\/phpseclib version 3 Instead.\r\n * - Checkout the JCB Crypt Suite. <https:\/\/git.vdm.dev\/joomla\/phpseclib>\r\n *\/",
"head": "",
"composer": ""
}

View File

@ -0,0 +1,36 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Phpfunc (Details)
> namespace: **VDM\Joomla\FOF\Utils**
```uml
@startuml
class Phpfunc #Gold {
+ __call(string $func, array $args) : mixed
}
note right of Phpfunc::__call
Magic call to intercept any function pass to it.
return: mixed
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,44 @@
<?php
/**
* @package FrameworkOnFramework
* @subpackage Utilities
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
*/
namespace VDM\Joomla\FOF\Utils;
/**
* Intercept calls to PHP functions.
*
* @method function_exists(string $function)
* @method mcrypt_list_algorithms()
* @method hash_algos()
* @method extension_loaded(string $ext)
* @method mcrypt_create_iv(int $bytes, int $source)
* @method openssl_get_cipher_methods()
*
* @package FrameworkOnFramework
* @since 1.0
*/
class Phpfunc
{
/**
*
* Magic call to intercept any function pass to it.
*
* @param string $func The function to call.
*
* @param array $args Arguments passed to the function.
*
* @return mixed The result of the function call.
*
*/
public function __call($func, $args)
{
return call_user_func_array($func, $args);
}
}

View File

@ -0,0 +1,15 @@
/**
*
* Magic call to intercept any function pass to it.
*
* @param string $func The function to call.
*
* @param array $args Arguments passed to the function.
*
* @return mixed The result of the function call.
*
*/
public function __call($func, $args)
{
return call_user_func_array($func, $args);
}

View File

@ -0,0 +1,18 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "470a08ee-6b31-4a2b-98d9-5b64757a3b34",
"implements": null,
"load_selection": null,
"name": "Phpfunc",
"power_version": "1.0.0",
"system_name": "FOF.Utils.Phpfunc",
"type": "class",
"use_selection": null,
"namespace": "VDM\\Joomla\\FOF\\Utils.Phpfunc",
"description": "Intercept calls to PHP functions.\r\n\r\n@method function_exists(string $function)\r\n@method mcrypt_list_algorithms()\r\n@method hash_algos()\r\n@method extension_loaded(string $ext)\r\n@method mcrypt_create_iv(int $bytes, int $source)\r\n@method openssl_get_cipher_methods()\r\n\r\n@package FrameworkOnFramework\r\n@since 1.0",
"licensing_template": "\/**\r\n * @package FrameworkOnFramework\r\n * @subpackage Utilities\r\n * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos \/ Akeeba Ltd. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n * @note\t This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.\r\n * @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.\r\n *\/",
"head": "",
"composer": ""
}

View File

@ -0,0 +1,43 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class Abstraction (Details)
> namespace: **VDM\Joomla\FOF\Encrypt\AES**
```uml
@startuml
abstract Abstraction #Orange {
+ resizeKey(string $key, int $size) : null|string
# getZeroPadding(string $string, int $blockSize) : string
}
note right of Abstraction::resizeKey
Trims or zero-pads a key / IV
return: null|string
end note
note right of Abstraction::getZeroPadding
Returns null bytes to append to the string so that it's zero padded to the specified block size
return: string
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,100 @@
<?php
/**
* @package FrameworkOnFramework
* @subpackage Encryption
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
* - Do not use this in new projects.
* - Expect no updates.
* - This is outdated.
* - Not best choice for encryption.
* - Use phpseclib/phpseclib version 3 Instead.
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
*/
namespace VDM\Joomla\FOF\Encrypt\AES;
/**
* Abstract AES encryption class
*
* @package FrameworkOnFramework
* @since 1.0
* @deprecated Use phpseclib/phpseclib version 3 Instead.
*/
abstract class Abstraction
{
/**
* Trims or zero-pads a key / IV
*
* @param string $key The key or IV to treat
* @param int $size The block size of the currently used algorithm
*
* @return null|string Null if $key is null, treated string of $size byte length otherwise
*/
public function resizeKey($key, $size)
{
if (empty($key))
{
return null;
}
$keyLength = strlen($key);
if (function_exists('mb_strlen'))
{
$keyLength = mb_strlen($key, 'ASCII');
}
if ($keyLength == $size)
{
return $key;
}
if ($keyLength > $size)
{
if (function_exists('mb_substr'))
{
return mb_substr($key, 0, $size, 'ASCII');
}
return substr($key, 0, $size);
}
return $key . str_repeat("\0", ($size - $keyLength));
}
/**
* Returns null bytes to append to the string so that it's zero padded to the specified block size
*
* @param string $string The binary string which will be zero padded
* @param int $blockSize The block size
*
* @return string The zero bytes to append to the string to zero pad it to $blockSize
*/
protected function getZeroPadding($string, $blockSize)
{
$stringSize = strlen($string);
if (function_exists('mb_strlen'))
{
$stringSize = mb_strlen($string, 'ASCII');
}
if ($stringSize == $blockSize)
{
return '';
}
if ($stringSize < $blockSize)
{
return str_repeat("\0", $blockSize - $stringSize);
}
$paddingBytes = $stringSize % $blockSize;
return str_repeat("\0", $blockSize - $paddingBytes);
}
}

View File

@ -0,0 +1,71 @@
/**
* Trims or zero-pads a key / IV
*
* @param string $key The key or IV to treat
* @param int $size The block size of the currently used algorithm
*
* @return null|string Null if $key is null, treated string of $size byte length otherwise
*/
public function resizeKey($key, $size)
{
if (empty($key))
{
return null;
}
$keyLength = strlen($key);
if (function_exists('mb_strlen'))
{
$keyLength = mb_strlen($key, 'ASCII');
}
if ($keyLength == $size)
{
return $key;
}
if ($keyLength > $size)
{
if (function_exists('mb_substr'))
{
return mb_substr($key, 0, $size, 'ASCII');
}
return substr($key, 0, $size);
}
return $key . str_repeat("\0", ($size - $keyLength));
}
/**
* Returns null bytes to append to the string so that it's zero padded to the specified block size
*
* @param string $string The binary string which will be zero padded
* @param int $blockSize The block size
*
* @return string The zero bytes to append to the string to zero pad it to $blockSize
*/
protected function getZeroPadding($string, $blockSize)
{
$stringSize = strlen($string);
if (function_exists('mb_strlen'))
{
$stringSize = mb_strlen($string, 'ASCII');
}
if ($stringSize == $blockSize)
{
return '';
}
if ($stringSize < $blockSize)
{
return str_repeat("\0", $blockSize - $stringSize);
}
$paddingBytes = $stringSize % $blockSize;
return str_repeat("\0", $blockSize - $paddingBytes);
}

View File

@ -0,0 +1,18 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "4c89df31-8b94-40bb-94fc-7ec378145044",
"implements": null,
"load_selection": null,
"name": "Abstraction",
"power_version": "1.0.0",
"system_name": "FOF.Encrypt.AES.Abstraction",
"type": "abstract class",
"use_selection": null,
"namespace": "VDM\\Joomla\\FOF\\Encrypt.AES.Abstraction",
"description": "Abstract AES encryption class\r\n\r\n@package FrameworkOnFramework\r\n@since 1.0\r\n@deprecated Use phpseclib\/phpseclib version 3 Instead. ",
"licensing_template": "\/**\r\n * @package FrameworkOnFramework\r\n * @subpackage Encryption\r\n * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos \/ Akeeba Ltd. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n * @note\t This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.\r\n * @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.\r\n * - Do not use this in new projects.\r\n * - Expect no updates.\r\n * - This is outdated.\r\n * - Not best choice for encryption.\r\n * - Use phpseclib\/phpseclib version 3 Instead.\r\n * - Checkout the JCB Crypt Suite. <https:\/\/git.vdm.dev\/joomla\/phpseclib>\r\n *\/",
"head": "",
"composer": ""
}

View File

@ -0,0 +1,84 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# interface AesInterface (Details)
> namespace: **VDM\Joomla\FOF\Encrypt\AES**
```uml
@startuml
interface AesInterface #Lavender {
+ setEncryptionMode(string $mode = 'cbc', int $strength = 128) : mixed
+ encrypt(string $plainText, string $key, ...) : string
+ decrypt(string $cipherText, string $key) : string
+ getBlockSize() : int
+ isSupported(FOFUtilsPhpfunc $phpfunc = null) : bool
}
note right of AesInterface::setEncryptionMode
Sets the AES encryption mode.
WARNING: The strength is deprecated as it has a different effect in MCrypt and OpenSSL. MCrypt was abandoned in
2003 before the Rijndael-128 algorithm was officially the Advanced Encryption Standard (AES). MCrypt also offered
Rijndael-192 and Rijndael-256 algorithms with different block sizes. These are NOT used in AES. OpenSSL, however,
implements AES correctly. It always uses a 128-bit (16 byte) block. The 192 and 256 bit strengths refer to the
key size, not the block size. Therefore using different strengths in MCrypt and OpenSSL will result in different
and incompatible ciphertexts.
TL;DR: Always use $strength = 128!
return: mixed
end note
note right of AesInterface::encrypt
Encrypts a string. Returns the raw binary ciphertext.
WARNING: The plaintext is zero-padded to the algorithm's block size. You are advised to store the size of the
plaintext and trim the string to that length upon decryption.
return: string
arguments:
string $plainText
string $key
null|string $iv = null
end note
note right of AesInterface::decrypt
Decrypts a string. Returns the raw binary plaintext.
$ciphertext MUST start with the IV followed by the ciphertext, even for EBC data (the first block of data is
dropped in EBC mode since there is no concept of IV in EBC).
WARNING: The returned plaintext is zero-padded to the algorithm's block size during encryption. You are advised
to trim the string to the original plaintext's length upon decryption. While rtrim($decrypted, "\0") sounds
appealing it's NOT the correct approach for binary data (zero bytes may actually be part of your plaintext, not
just padding!).
return: string
end note
note right of AesInterface::getBlockSize
Returns the encryption block size in bytes
return: int
end note
note right of AesInterface::isSupported
Is this adapter supported?
return: bool
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,95 @@
<?php
/**
* @package FrameworkOnFramework
* @subpackage Encryption
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
* - Do not use this in new projects.
* - Expect no updates.
* - This is outdated.
* - Not best choice for encryption.
* - Use phpseclib/phpseclib version 3 Instead.
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
*/
namespace VDM\Joomla\FOF\Encrypt\AES;
/**
* Interface for AES encryption adapters
*
* @package FrameworkOnFramework
* @since 1.0
* @deprecated Use phpseclib/phpseclib version 3 Instead.
*/
interface AesInterface
{
/**
* Sets the AES encryption mode.
*
* WARNING: The strength is deprecated as it has a different effect in MCrypt and OpenSSL. MCrypt was abandoned in
* 2003 before the Rijndael-128 algorithm was officially the Advanced Encryption Standard (AES). MCrypt also offered
* Rijndael-192 and Rijndael-256 algorithms with different block sizes. These are NOT used in AES. OpenSSL, however,
* implements AES correctly. It always uses a 128-bit (16 byte) block. The 192 and 256 bit strengths refer to the
* key size, not the block size. Therefore using different strengths in MCrypt and OpenSSL will result in different
* and incompatible ciphertexts.
*
* TL;DR: Always use $strength = 128!
*
* @param string $mode Choose between CBC (recommended) or ECB
* @param int $strength Bit strength of the key (128, 192 or 256 bits). DEPRECATED. READ NOTES ABOVE.
*
* @return mixed
*/
public function setEncryptionMode($mode = 'cbc', $strength = 128);
/**
* Encrypts a string. Returns the raw binary ciphertext.
*
* WARNING: The plaintext is zero-padded to the algorithm's block size. You are advised to store the size of the
* plaintext and trim the string to that length upon decryption.
*
* @param string $plainText The plaintext to encrypt
* @param string $key The raw binary key (will be zero-padded or chopped if its size is different than the block size)
* @param null|string $iv The initialization vector (for CBC mode algorithms)
*
* @return string The raw encrypted binary string.
*/
public function encrypt($plainText, $key, $iv = null);
/**
* Decrypts a string. Returns the raw binary plaintext.
*
* $ciphertext MUST start with the IV followed by the ciphertext, even for EBC data (the first block of data is
* dropped in EBC mode since there is no concept of IV in EBC).
*
* WARNING: The returned plaintext is zero-padded to the algorithm's block size during encryption. You are advised
* to trim the string to the original plaintext's length upon decryption. While rtrim($decrypted, "\0") sounds
* appealing it's NOT the correct approach for binary data (zero bytes may actually be part of your plaintext, not
* just padding!).
*
* @param string $cipherText The ciphertext to encrypt
* @param string $key The raw binary key (will be zero-padded or chopped if its size is different than the block size)
*
* @return string The raw unencrypted binary string.
*/
public function decrypt($cipherText, $key);
/**
* Returns the encryption block size in bytes
*
* @return int
*/
public function getBlockSize();
/**
* Is this adapter supported?
*
* @param FOFUtilsPhpfunc $phpfunc
*
* @return bool
*/
public function isSupported(FOFUtilsPhpfunc $phpfunc = null);
}

View File

@ -0,0 +1,66 @@
/**
* Sets the AES encryption mode.
*
* WARNING: The strength is deprecated as it has a different effect in MCrypt and OpenSSL. MCrypt was abandoned in
* 2003 before the Rijndael-128 algorithm was officially the Advanced Encryption Standard (AES). MCrypt also offered
* Rijndael-192 and Rijndael-256 algorithms with different block sizes. These are NOT used in AES. OpenSSL, however,
* implements AES correctly. It always uses a 128-bit (16 byte) block. The 192 and 256 bit strengths refer to the
* key size, not the block size. Therefore using different strengths in MCrypt and OpenSSL will result in different
* and incompatible ciphertexts.
*
* TL;DR: Always use $strength = 128!
*
* @param string $mode Choose between CBC (recommended) or ECB
* @param int $strength Bit strength of the key (128, 192 or 256 bits). DEPRECATED. READ NOTES ABOVE.
*
* @return mixed
*/
public function setEncryptionMode($mode = 'cbc', $strength = 128);
/**
* Encrypts a string. Returns the raw binary ciphertext.
*
* WARNING: The plaintext is zero-padded to the algorithm's block size. You are advised to store the size of the
* plaintext and trim the string to that length upon decryption.
*
* @param string $plainText The plaintext to encrypt
* @param string $key The raw binary key (will be zero-padded or chopped if its size is different than the block size)
* @param null|string $iv The initialization vector (for CBC mode algorithms)
*
* @return string The raw encrypted binary string.
*/
public function encrypt($plainText, $key, $iv = null);
/**
* Decrypts a string. Returns the raw binary plaintext.
*
* $ciphertext MUST start with the IV followed by the ciphertext, even for EBC data (the first block of data is
* dropped in EBC mode since there is no concept of IV in EBC).
*
* WARNING: The returned plaintext is zero-padded to the algorithm's block size during encryption. You are advised
* to trim the string to the original plaintext's length upon decryption. While rtrim($decrypted, "\0") sounds
* appealing it's NOT the correct approach for binary data (zero bytes may actually be part of your plaintext, not
* just padding!).
*
* @param string $cipherText The ciphertext to encrypt
* @param string $key The raw binary key (will be zero-padded or chopped if its size is different than the block size)
*
* @return string The raw unencrypted binary string.
*/
public function decrypt($cipherText, $key);
/**
* Returns the encryption block size in bytes
*
* @return int
*/
public function getBlockSize();
/**
* Is this adapter supported?
*
* @param FOFUtilsPhpfunc $phpfunc
*
* @return bool
*/
public function isSupported(FOFUtilsPhpfunc $phpfunc = null);

View File

@ -0,0 +1,18 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "7f753585-6e3b-4b81-bd29-3b7bdf0e3769",
"implements": null,
"load_selection": null,
"name": "AesInterface",
"power_version": "1.0.0",
"system_name": "FOF.Encrypt.AES.AesInterface",
"type": "interface",
"use_selection": null,
"namespace": "VDM\\Joomla\\FOF\\Encrypt.AES.AesInterface",
"description": "Interface for AES encryption adapters\r\n\r\n@package FrameworkOnFramework\r\n@since 1.0\r\n@deprecated Use phpseclib\/phpseclib version 3 Instead. ",
"licensing_template": "\/**\r\n * @package FrameworkOnFramework\r\n * @subpackage Encryption\r\n * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos \/ Akeeba Ltd. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n * @note\t This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.\r\n * @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.\r\n * - Do not use this in new projects.\r\n * - Expect no updates.\r\n * - This is outdated.\r\n * - Not best choice for encryption.\r\n * - Use phpseclib\/phpseclib version 3 Instead.\r\n * - Checkout the JCB Crypt Suite. <https:\/\/git.vdm.dev\/joomla\/phpseclib>\r\n *\/",
"head": "",
"composer": ""
}

View File

@ -0,0 +1,52 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Openssl (Details)
> namespace: **VDM\Joomla\FOF\Encrypt\AES**
> extends: **Abstraction**
```uml
@startuml
class Openssl #Gold {
# $openSSLOptions
# $method
+ __construct()
+ setEncryptionMode($mode = 'cbc', $strength = 128)
+ encrypt($plainText, $key, ...)
+ decrypt($cipherText, $key)
+ isSupported(Phpfunc $phpfunc = null)
+ getBlockSize() : int
}
note right of Openssl::encrypt
arguments:
$plainText
$key
$iv = null
end note
note right of Openssl::getBlockSize
return: int
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,193 @@
<?php
/**
* @package FrameworkOnFramework
* @subpackage Encryption
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
* - Do not use this in new projects.
* - Expect no updates.
* - This is outdated.
* - Not best choice for encryption.
* - Use phpseclib/phpseclib version 3 Instead.
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
*/
namespace VDM\Joomla\FOF\Encrypt\AES;
use VDM\Joomla\FOF\Encrypt\Randval;
use VDM\Joomla\FOF\Utils\Phpfunc;
use VDM\Joomla\FOF\Encrypt\AES\AesInterface;
use VDM\Joomla\FOF\Encrypt\AES\Abstraction;
/**
* Openssl AES encryption class
*
* @package FrameworkOnFramework
* @since 1.0
* @deprecated Use phpseclib/phpseclib version 3 Instead.
*/
class Openssl extends Abstraction implements AesInterface
{
/**
* The OpenSSL options for encryption / decryption
*
* @var int
*/
protected $openSSLOptions = 0;
/**
* The encryption method to use
*
* @var string
*/
protected $method = 'aes-128-cbc';
public function __construct()
{
$this->openSSLOptions = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING;
}
public function setEncryptionMode($mode = 'cbc', $strength = 128)
{
static $availableAlgorithms = null;
static $defaultAlgo = 'aes-128-cbc';
if (!is_array($availableAlgorithms))
{
$availableAlgorithms = openssl_get_cipher_methods();
foreach (array('aes-256-cbc', 'aes-256-ecb', 'aes-192-cbc',
'aes-192-ecb', 'aes-128-cbc', 'aes-128-ecb') as $algo)
{
if (in_array($algo, $availableAlgorithms))
{
$defaultAlgo = $algo;
break;
}
}
}
$strength = (int) $strength;
$mode = strtolower($mode);
if (!in_array($strength, array(128, 192, 256)))
{
$strength = 256;
}
if (!in_array($mode, array('cbc', 'ebc')))
{
$mode = 'cbc';
}
$algo = 'aes-' . $strength . '-' . $mode;
if (!in_array($algo, $availableAlgorithms))
{
$algo = $defaultAlgo;
}
$this->method = $algo;
}
public function encrypt($plainText, $key, $iv = null)
{
$iv_size = $this->getBlockSize();
$key = $this->resizeKey($key, $iv_size);
$iv = $this->resizeKey($iv, $iv_size);
if (empty($iv))
{
$randVal = new Randval();
$iv = $randVal->generate($iv_size);
}
$plainText .= $this->getZeroPadding($plainText, $iv_size);
$cipherText = openssl_encrypt($plainText, $this->method, $key, $this->openSSLOptions, $iv);
$cipherText = $iv . $cipherText;
return $cipherText;
}
public function decrypt($cipherText, $key)
{
$iv_size = $this->getBlockSize();
$key = $this->resizeKey($key, $iv_size);
$iv = substr($cipherText, 0, $iv_size);
$cipherText = substr($cipherText, $iv_size);
$plainText = openssl_decrypt($cipherText, $this->method, $key, $this->openSSLOptions, $iv);
return $plainText;
}
public function isSupported(Phpfunc $phpfunc = null)
{
if (!is_object($phpfunc) || !($phpfunc instanceof $phpfunc))
{
$phpfunc = new Phpfunc();
}
if (!$phpfunc->function_exists('openssl_get_cipher_methods'))
{
return false;
}
if (!$phpfunc->function_exists('openssl_random_pseudo_bytes'))
{
return false;
}
if (!$phpfunc->function_exists('openssl_cipher_iv_length'))
{
return false;
}
if (!$phpfunc->function_exists('openssl_encrypt'))
{
return false;
}
if (!$phpfunc->function_exists('openssl_decrypt'))
{
return false;
}
if (!$phpfunc->function_exists('hash'))
{
return false;
}
if (!$phpfunc->function_exists('hash_algos'))
{
return false;
}
$algorightms = $phpfunc->openssl_get_cipher_methods();
if (!in_array('aes-128-cbc', $algorightms))
{
return false;
}
$algorightms = $phpfunc->hash_algos();
if (!in_array('sha256', $algorightms))
{
return false;
}
return true;
}
/**
* @return int
*/
public function getBlockSize()
{
return openssl_cipher_iv_length($this->method);
}
}

View File

@ -0,0 +1,158 @@
/**
* The OpenSSL options for encryption / decryption
*
* @var int
*/
protected $openSSLOptions = 0;
/**
* The encryption method to use
*
* @var string
*/
protected $method = 'aes-128-cbc';
public function __construct()
{
$this->openSSLOptions = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING;
}
public function setEncryptionMode($mode = 'cbc', $strength = 128)
{
static $availableAlgorithms = null;
static $defaultAlgo = 'aes-128-cbc';
if (!is_array($availableAlgorithms))
{
$availableAlgorithms = openssl_get_cipher_methods();
foreach (array('aes-256-cbc', 'aes-256-ecb', 'aes-192-cbc',
'aes-192-ecb', 'aes-128-cbc', 'aes-128-ecb') as $algo)
{
if (in_array($algo, $availableAlgorithms))
{
$defaultAlgo = $algo;
break;
}
}
}
$strength = (int) $strength;
$mode = strtolower($mode);
if (!in_array($strength, array(128, 192, 256)))
{
$strength = 256;
}
if (!in_array($mode, array('cbc', 'ebc')))
{
$mode = 'cbc';
}
$algo = 'aes-' . $strength . '-' . $mode;
if (!in_array($algo, $availableAlgorithms))
{
$algo = $defaultAlgo;
}
$this->method = $algo;
}
public function encrypt($plainText, $key, $iv = null)
{
$iv_size = $this->getBlockSize();
$key = $this->resizeKey($key, $iv_size);
$iv = $this->resizeKey($iv, $iv_size);
if (empty($iv))
{
$randVal = new Randval();
$iv = $randVal->generate($iv_size);
}
$plainText .= $this->getZeroPadding($plainText, $iv_size);
$cipherText = openssl_encrypt($plainText, $this->method, $key, $this->openSSLOptions, $iv);
$cipherText = $iv . $cipherText;
return $cipherText;
}
public function decrypt($cipherText, $key)
{
$iv_size = $this->getBlockSize();
$key = $this->resizeKey($key, $iv_size);
$iv = substr($cipherText, 0, $iv_size);
$cipherText = substr($cipherText, $iv_size);
$plainText = openssl_decrypt($cipherText, $this->method, $key, $this->openSSLOptions, $iv);
return $plainText;
}
public function isSupported(Phpfunc $phpfunc = null)
{
if (!is_object($phpfunc) || !($phpfunc instanceof $phpfunc))
{
$phpfunc = new Phpfunc();
}
if (!$phpfunc->function_exists('openssl_get_cipher_methods'))
{
return false;
}
if (!$phpfunc->function_exists('openssl_random_pseudo_bytes'))
{
return false;
}
if (!$phpfunc->function_exists('openssl_cipher_iv_length'))
{
return false;
}
if (!$phpfunc->function_exists('openssl_encrypt'))
{
return false;
}
if (!$phpfunc->function_exists('openssl_decrypt'))
{
return false;
}
if (!$phpfunc->function_exists('hash'))
{
return false;
}
if (!$phpfunc->function_exists('hash_algos'))
{
return false;
}
$algorightms = $phpfunc->openssl_get_cipher_methods();
if (!in_array('aes-128-cbc', $algorightms))
{
return false;
}
$algorightms = $phpfunc->hash_algos();
if (!in_array('sha256', $algorightms))
{
return false;
}
return true;
}
/**
* @return int
*/
public function getBlockSize()
{
return openssl_cipher_iv_length($this->method);
}

View File

@ -0,0 +1,29 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "4c89df31-8b94-40bb-94fc-7ec378145044",
"guid": "885cc1cf-1904-483c-aecc-6af916c329e7",
"implements": [
"7f753585-6e3b-4b81-bd29-3b7bdf0e3769"
],
"load_selection": null,
"name": "Openssl",
"power_version": "1.0.0",
"system_name": "FOF.Encrypt.AES.Openssl",
"type": "class",
"use_selection": {
"use_selection0": {
"use": "eef08a1d-5367-4464-8d07-d47c479fb76f",
"as": "default"
},
"use_selection1": {
"use": "470a08ee-6b31-4a2b-98d9-5b64757a3b34",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\FOF\\Encrypt.AES.Openssl",
"description": "Openssl AES encryption class\r\n\r\n@package FrameworkOnFramework\r\n@since 1.0\r\n@deprecated Use phpseclib\/phpseclib version 3 Instead. ",
"licensing_template": "\/**\r\n * @package FrameworkOnFramework\r\n * @subpackage Encryption\r\n * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos \/ Akeeba Ltd. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n * @note\t This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.\r\n * @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.\r\n * - Do not use this in new projects.\r\n * - Expect no updates.\r\n * - This is outdated.\r\n * - Not best choice for encryption.\r\n * - Use phpseclib\/phpseclib version 3 Instead.\r\n * - Checkout the JCB Crypt Suite. <https:\/\/git.vdm.dev\/joomla\/phpseclib>\r\n *\/",
"head": "",
"composer": ""
}

View File

@ -0,0 +1,96 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class AES (Details)
> namespace: **VDM\Joomla\FOF\Encrypt**
```uml
@startuml
class AES #Gold {
# $key
# $adapter
+ __construct(string $key, int $strength = 128, ...)
+ setPassword(string $password, bool $legacyMode = false)
+ encryptString(string $stringToEncrypt, bool $base64encoded = true) : string
+ decryptString(string $stringToDecrypt, bool $base64encoded = true) : string
+ {static} isSupported(Phpfunc $phpfunc = null) : boolean
+ getExpandedKey($blockSize, $iv) : string
hash_pbkdf2($algo, $password, ...)
}
note right of AES::__construct
Initialise the AES encryption object.
Note: If the key is not 16 bytes this class will do a stupid key expansion for legacy reasons (produce the
SHA-256 of the key string and throw away half of it).
arguments:
string $key
int $strength = 128
string $mode = 'cbc'
Phpfunc $phpfunc = null
string $priority = 'openssl'
end note
note right of AES::setPassword
Sets the password for this instance.
WARNING: Do not use the legacy mode, it's insecure
end note
note right of AES::encryptString
Encrypts a string using AES
the raw string is the IV (initialisation vector) which
is necessary for decoding the string.
return: string
end note
note right of AES::decryptString
Decrypts a ciphertext into a plaintext string using AES
the IV (initialisation vector).
return: string
end note
note right of AES::isSupported
Is AES encryption supported by this PHP installation?
return: boolean
end note
note right of AES::getExpandedKey
return: string
end note
note right of AES::hash_pbkdf2
arguments:
$algo
$password
$salt
$count
$length
$raw_output = false
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,300 @@
<?php
/**
* @package FrameworkOnFramework
* @subpackage Encryption
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
* - Do not use this in new projects.
* - Expect no updates.
* - This is outdated.
* - Not best choice for encryption.
* - Use phpseclib/phpseclib version 3 Instead.
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
*/
namespace VDM\Joomla\FOF\Encrypt;
use VDM\Joomla\FOF\Encrypt\AES\AesInterface;
use VDM\Joomla\FOF\Encrypt\AES\Mcrypt;
use VDM\Joomla\FOF\Encrypt\AES\Openssl;
use VDM\Joomla\FOF\Utils\Phpfunc;
/**
* AES encryption class
*
* @package FrameworkOnFramework
* @since 1.0
* @deprecated Use phpseclib/phpseclib version 3 Instead.
*/
class AES
{
/**
* The cipher key.
*
* @var string
*/
protected $key = '';
/**
* The AES encryption adapter in use.
*
* @var AesInterface
*/
protected $adapter;
/**
* Initialise the AES encryption object.
*
* Note: If the key is not 16 bytes this class will do a stupid key expansion for legacy reasons (produce the
* SHA-256 of the key string and throw away half of it).
*
* @param string $key The encryption key (password). It can be a raw key (16 bytes) or a passphrase.
* @param int $strength Bit strength (128, 192 or 256) ALWAYS USE 128 BITS. THIS PARAMETER IS DEPRECATED.
* @param string $mode Encryption mode. Can be ebc or cbc. We recommend using cbc.
* @param Phpfunc $phpfunc For testing
* @param string $priority Priority which adapter we should try first
*/
public function __construct($key, $strength = 128, $mode = 'cbc', Phpfunc $phpfunc = null, $priority = 'openssl')
{
if ($priority == 'openssl')
{
$this->adapter = new Openssl();
if (!$this->adapter->isSupported($phpfunc))
{
$this->adapter = new Mcrypt();
}
}
else
{
$this->adapter = new Mcrypt();
if (!$this->adapter->isSupported($phpfunc))
{
$this->adapter = new Openssl();
}
}
$this->adapter->setEncryptionMode($mode, $strength);
$this->setPassword($key, true);
}
/**
* Sets the password for this instance.
*
* WARNING: Do not use the legacy mode, it's insecure
*
* @param string $password The password (either user-provided password or binary encryption key) to use
* @param bool $legacyMode True to use the legacy key expansion. We recommend against using it.
*/
public function setPassword($password, $legacyMode = false)
{
$this->key = $password;
$passLength = strlen($password);
if (function_exists('mb_strlen'))
{
$passLength = mb_strlen($password, 'ASCII');
}
// Legacy mode was doing something stupid, requiring a key of 32 bytes. DO NOT USE LEGACY MODE!
if ($legacyMode && ($passLength != 32))
{
// Legacy mode: use the sha256 of the password
$this->key = hash('sha256', $password, true);
// We have to trim or zero pad the password (we end up throwing half of it away in Rijndael-128 / AES...)
$this->key = $this->adapter->resizeKey($this->key, $this->adapter->getBlockSize());
}
}
/**
* Encrypts a string using AES
*
* @param string $stringToEncrypt The plaintext to encrypt
* @param bool $base64encoded Should I Base64-encode the result?
*
* @return string The cryptotext. Please note that the first 16 bytes of
* the raw string is the IV (initialisation vector) which
* is necessary for decoding the string.
*/
public function encryptString($stringToEncrypt, $base64encoded = true)
{
$blockSize = $this->adapter->getBlockSize();
$randVal = new Randval();
$iv = $randVal->generate($blockSize);
$key = $this->getExpandedKey($blockSize, $iv);
$cipherText = $this->adapter->encrypt($stringToEncrypt, $key, $iv);
// Optionally pass the result through Base64 encoding
if ($base64encoded)
{
$cipherText = base64_encode((string) $cipherText);
}
// Return the result
return $cipherText;
}
/**
* Decrypts a ciphertext into a plaintext string using AES
*
* @param string $stringToDecrypt The ciphertext to decrypt. The first 16 bytes of the raw string must contain
* the IV (initialisation vector).
* @param bool $base64encoded Should I Base64-decode the data before decryption?
*
* @return string The plain text string
*/
public function decryptString($stringToDecrypt, $base64encoded = true)
{
if ($base64encoded)
{
$stringToDecrypt = base64_decode($stringToDecrypt);
}
// Extract IV
$iv_size = $this->adapter->getBlockSize();
$iv = substr($stringToDecrypt, 0, $iv_size);
$key = $this->getExpandedKey($iv_size, $iv);
// Decrypt the data
$plainText = $this->adapter->decrypt($stringToDecrypt, $key);
return $plainText;
}
/**
* Is AES encryption supported by this PHP installation?
*
* @param Phpfunc $phpfunc
*
* @return boolean
*/
public static function isSupported(Phpfunc $phpfunc = null)
{
if (!is_object($phpfunc) || !($phpfunc instanceof $phpfunc))
{
$phpfunc = new Phpfunc();
}
$adapter = new Openssl();
if (!$adapter->isSupported($phpfunc))
{
$adapter = new Mcrypt();
if (!$adapter->isSupported($phpfunc))
{
return false;
}
}
if (!$phpfunc->function_exists('base64_encode'))
{
return false;
}
if (!$phpfunc->function_exists('base64_decode'))
{
return false;
}
if (!$phpfunc->function_exists('hash_algos'))
{
return false;
}
$algorightms = $phpfunc->hash_algos();
if (!in_array('sha256', $algorightms))
{
return false;
}
return true;
}
/**
* @param $blockSize
* @param $iv
*
* @return string
*/
public function getExpandedKey($blockSize, $iv)
{
$key = $this->key;
$passLength = strlen($key);
if (function_exists('mb_strlen'))
{
$passLength = mb_strlen($key, 'ASCII');
}
if ($passLength != $blockSize)
{
$iterations = 1000;
$salt = $this->adapter->resizeKey($iv, 16);
$key = hash_pbkdf2('sha256', $this->key, $salt, $iterations, $blockSize, true);
}
return $key;
}
}
if (!function_exists('hash_pbkdf2'))
{
function hash_pbkdf2($algo, $password, $salt, $count, $length = 0, $raw_output = false)
{
if (!in_array(strtolower((string) $algo), hash_algos()))
{
trigger_error(__FUNCTION__ . '(): Unknown hashing algorithm: ' . $algo, E_USER_WARNING);
}
if (!is_numeric($count))
{
trigger_error(__FUNCTION__ . '(): expects parameter 4 to be long, ' . gettype($count) . ' given', E_USER_WARNING);
}
if (!is_numeric($length))
{
trigger_error(__FUNCTION__ . '(): expects parameter 5 to be long, ' . gettype($length) . ' given', E_USER_WARNING);
}
if ($count <= 0)
{
trigger_error(__FUNCTION__ . '(): Iterations must be a positive integer: ' . $count, E_USER_WARNING);
}
if ($length < 0)
{
trigger_error(__FUNCTION__ . '(): Length must be greater than or equal to 0: ' . $length, E_USER_WARNING);
}
$output = '';
$block_count = $length ? ceil($length / strlen(hash((string) $algo, '', $raw_output))) : 1;
for ($i = 1; $i <= $block_count; $i++)
{
$last = $xorsum = hash_hmac((string) $algo, $salt . pack('N', $i), (string) $password, true);
for ($j = 1; $j < $count; $j++)
{
$xorsum ^= ($last = hash_hmac((string) $algo, $last, (string) $password, true));
}
$output .= $xorsum;
}
if (!$raw_output)
{
$output = bin2hex($output);
}
return $length ? substr($output, 0, $length) : $output;
}
}

View File

@ -0,0 +1,265 @@
/**
* The cipher key.
*
* @var string
*/
protected $key = '';
/**
* The AES encryption adapter in use.
*
* @var AesInterface
*/
protected $adapter;
/**
* Initialise the AES encryption object.
*
* Note: If the key is not 16 bytes this class will do a stupid key expansion for legacy reasons (produce the
* SHA-256 of the key string and throw away half of it).
*
* @param string $key The encryption key (password). It can be a raw key (16 bytes) or a passphrase.
* @param int $strength Bit strength (128, 192 or 256) ALWAYS USE 128 BITS. THIS PARAMETER IS DEPRECATED.
* @param string $mode Encryption mode. Can be ebc or cbc. We recommend using cbc.
* @param Phpfunc $phpfunc For testing
* @param string $priority Priority which adapter we should try first
*/
public function __construct($key, $strength = 128, $mode = 'cbc', Phpfunc $phpfunc = null, $priority = 'openssl')
{
if ($priority == 'openssl')
{
$this->adapter = new Openssl();
if (!$this->adapter->isSupported($phpfunc))
{
$this->adapter = new Mcrypt();
}
}
else
{
$this->adapter = new Mcrypt();
if (!$this->adapter->isSupported($phpfunc))
{
$this->adapter = new Openssl();
}
}
$this->adapter->setEncryptionMode($mode, $strength);
$this->setPassword($key, true);
}
/**
* Sets the password for this instance.
*
* WARNING: Do not use the legacy mode, it's insecure
*
* @param string $password The password (either user-provided password or binary encryption key) to use
* @param bool $legacyMode True to use the legacy key expansion. We recommend against using it.
*/
public function setPassword($password, $legacyMode = false)
{
$this->key = $password;
$passLength = strlen($password);
if (function_exists('mb_strlen'))
{
$passLength = mb_strlen($password, 'ASCII');
}
// Legacy mode was doing something stupid, requiring a key of 32 bytes. DO NOT USE LEGACY MODE!
if ($legacyMode && ($passLength != 32))
{
// Legacy mode: use the sha256 of the password
$this->key = hash('sha256', $password, true);
// We have to trim or zero pad the password (we end up throwing half of it away in Rijndael-128 / AES...)
$this->key = $this->adapter->resizeKey($this->key, $this->adapter->getBlockSize());
}
}
/**
* Encrypts a string using AES
*
* @param string $stringToEncrypt The plaintext to encrypt
* @param bool $base64encoded Should I Base64-encode the result?
*
* @return string The cryptotext. Please note that the first 16 bytes of
* the raw string is the IV (initialisation vector) which
* is necessary for decoding the string.
*/
public function encryptString($stringToEncrypt, $base64encoded = true)
{
$blockSize = $this->adapter->getBlockSize();
$randVal = new Randval();
$iv = $randVal->generate($blockSize);
$key = $this->getExpandedKey($blockSize, $iv);
$cipherText = $this->adapter->encrypt($stringToEncrypt, $key, $iv);
// Optionally pass the result through Base64 encoding
if ($base64encoded)
{
$cipherText = base64_encode((string) $cipherText);
}
// Return the result
return $cipherText;
}
/**
* Decrypts a ciphertext into a plaintext string using AES
*
* @param string $stringToDecrypt The ciphertext to decrypt. The first 16 bytes of the raw string must contain
* the IV (initialisation vector).
* @param bool $base64encoded Should I Base64-decode the data before decryption?
*
* @return string The plain text string
*/
public function decryptString($stringToDecrypt, $base64encoded = true)
{
if ($base64encoded)
{
$stringToDecrypt = base64_decode($stringToDecrypt);
}
// Extract IV
$iv_size = $this->adapter->getBlockSize();
$iv = substr($stringToDecrypt, 0, $iv_size);
$key = $this->getExpandedKey($iv_size, $iv);
// Decrypt the data
$plainText = $this->adapter->decrypt($stringToDecrypt, $key);
return $plainText;
}
/**
* Is AES encryption supported by this PHP installation?
*
* @param Phpfunc $phpfunc
*
* @return boolean
*/
public static function isSupported(Phpfunc $phpfunc = null)
{
if (!is_object($phpfunc) || !($phpfunc instanceof $phpfunc))
{
$phpfunc = new Phpfunc();
}
$adapter = new Openssl();
if (!$adapter->isSupported($phpfunc))
{
$adapter = new Mcrypt();
if (!$adapter->isSupported($phpfunc))
{
return false;
}
}
if (!$phpfunc->function_exists('base64_encode'))
{
return false;
}
if (!$phpfunc->function_exists('base64_decode'))
{
return false;
}
if (!$phpfunc->function_exists('hash_algos'))
{
return false;
}
$algorightms = $phpfunc->hash_algos();
if (!in_array('sha256', $algorightms))
{
return false;
}
return true;
}
/**
* @param $blockSize
* @param $iv
*
* @return string
*/
public function getExpandedKey($blockSize, $iv)
{
$key = $this->key;
$passLength = strlen($key);
if (function_exists('mb_strlen'))
{
$passLength = mb_strlen($key, 'ASCII');
}
if ($passLength != $blockSize)
{
$iterations = 1000;
$salt = $this->adapter->resizeKey($iv, 16);
$key = hash_pbkdf2('sha256', $this->key, $salt, $iterations, $blockSize, true);
}
return $key;
}
}
if (!function_exists('hash_pbkdf2'))
{
function hash_pbkdf2($algo, $password, $salt, $count, $length = 0, $raw_output = false)
{
if (!in_array(strtolower((string) $algo), hash_algos()))
{
trigger_error(__FUNCTION__ . '(): Unknown hashing algorithm: ' . $algo, E_USER_WARNING);
}
if (!is_numeric($count))
{
trigger_error(__FUNCTION__ . '(): expects parameter 4 to be long, ' . gettype($count) . ' given', E_USER_WARNING);
}
if (!is_numeric($length))
{
trigger_error(__FUNCTION__ . '(): expects parameter 5 to be long, ' . gettype($length) . ' given', E_USER_WARNING);
}
if ($count <= 0)
{
trigger_error(__FUNCTION__ . '(): Iterations must be a positive integer: ' . $count, E_USER_WARNING);
}
if ($length < 0)
{
trigger_error(__FUNCTION__ . '(): Length must be greater than or equal to 0: ' . $length, E_USER_WARNING);
}
$output = '';
$block_count = $length ? ceil($length / strlen(hash((string) $algo, '', $raw_output))) : 1;
for ($i = 1; $i <= $block_count; $i++)
{
$last = $xorsum = hash_hmac((string) $algo, $salt . pack('N', $i), (string) $password, true);
for ($j = 1; $j < $count; $j++)
{
$xorsum ^= ($last = hash_hmac((string) $algo, $last, (string) $password, true));
}
$output .= $xorsum;
}
if (!$raw_output)
{
$output = bin2hex($output);
}
return $length ? substr($output, 0, $length) : $output;
}

View File

@ -0,0 +1,39 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "99175f6d-dba8-4086-8a65-5c4ec175e61d",
"implements": null,
"load_selection": {
"load_selection0": {
"load": "eef08a1d-5367-4464-8d07-d47c479fb76f"
}
},
"name": "AES",
"power_version": "1.0.0",
"system_name": "FOF.Encrypt.AES",
"type": "class",
"use_selection": {
"use_selection0": {
"use": "7f753585-6e3b-4b81-bd29-3b7bdf0e3769",
"as": "default"
},
"use_selection1": {
"use": "25da88d3-f7b2-4666-977f-e68ff731d1e8",
"as": "default"
},
"use_selection2": {
"use": "885cc1cf-1904-483c-aecc-6af916c329e7",
"as": "default"
},
"use_selection3": {
"use": "470a08ee-6b31-4a2b-98d9-5b64757a3b34",
"as": "default"
}
},
"namespace": "VDM\\Joomla\\FOF\\Encrypt.AES",
"description": "AES encryption class\r\n\r\n@package FrameworkOnFramework\r\n@since 1.0\r\n@deprecated Use phpseclib\/phpseclib version 3 Instead. ",
"licensing_template": "\/**\r\n * @package FrameworkOnFramework\r\n * @subpackage Encryption\r\n * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos \/ Akeeba Ltd. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n * @note\t This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.\r\n * @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.\r\n * - Do not use this in new projects.\r\n * - Expect no updates.\r\n * - This is outdated.\r\n * - Not best choice for encryption.\r\n * - Use phpseclib\/phpseclib version 3 Instead.\r\n * - Checkout the JCB Crypt Suite. <https:\/\/git.vdm.dev\/joomla\/phpseclib>\r\n *\/",
"head": "",
"composer": ""
}

View File

@ -0,0 +1,36 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# interface Randvalinterface (Details)
> namespace: **VDM\Joomla\FOF\Encrypt**
```uml
@startuml
interface Randvalinterface #Lavender {
+ generate() : string
}
note right of Randvalinterface::generate
Returns a cryptographically secure random value.
return: string
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,37 @@
<?php
/**
* @package FrameworkOnFramework
* @subpackage Encryption
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
* - Do not use this in new projects.
* - Expect no updates.
* - This is outdated.
* - Not best choice for encryption.
* - Use phpseclib/phpseclib version 3 Instead.
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
*/
namespace VDM\Joomla\FOF\Encrypt;
/**
* Randvalinterface
*
* @package FrameworkOnFramework
* @since 1.0
* @deprecated Use phpseclib/phpseclib version 3 Instead.
*/
interface Randvalinterface
{
/**
*
* Returns a cryptographically secure random value.
*
* @return string
*
*/
public function generate();
}

View File

@ -0,0 +1,8 @@
/**
*
* Returns a cryptographically secure random value.
*
* @return string
*
*/
public function generate();

View File

@ -0,0 +1,18 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "ba82e88a-254d-4ba4-99a3-ea69ed814f5c",
"implements": null,
"load_selection": null,
"name": "Randvalinterface",
"power_version": "1.0.0",
"system_name": "FOF.Encrypt.Randvalinterface",
"type": "interface",
"use_selection": null,
"namespace": "VDM\\Joomla\\FOF\\Encrypt.Randvalinterface",
"description": "Randvalinterface\r\n\r\n@package FrameworkOnFramework\r\n@since 1.0\r\n@deprecated Use phpseclib\/phpseclib version 3 Instead. ",
"licensing_template": "\/**\r\n * @package FrameworkOnFramework\r\n * @subpackage Encryption\r\n * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos \/ Akeeba Ltd. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n * @note\t This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.\r\n * @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.\r\n * - Do not use this in new projects.\r\n * - Expect no updates.\r\n * - This is outdated.\r\n * - Not best choice for encryption.\r\n * - Use phpseclib\/phpseclib version 3 Instead.\r\n * - Checkout the JCB Crypt Suite. <https:\/\/git.vdm.dev\/joomla\/phpseclib>\r\n *\/",
"head": "",
"composer": ""
}

View File

@ -0,0 +1,53 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Randval (Details)
> namespace: **VDM\Joomla\FOF\Encrypt**
```uml
@startuml
class Randval #Gold {
+ generate(integer $bytes = 32) : string
+ genRandomBytes(integer $length = 32) : string
}
note right of Randval::generate
Returns a cryptographically secure random value.
Since we only run on PHP 7+ we can use random_bytes(), which internally uses a crypto safe PRNG. If the function
doesn't exist, Joomla already loads a secure polyfill.
The reason this method exists is backwards compatibility with older versions of FOF. It also allows us to quickly
address any future issues if Joomla drops the polyfill or otherwise find problems with PHP's random_bytes() on
some weird host (you can't be too careful when releasing mass-distributed software).
return: string
end note
note right of Randval::genRandomBytes
Generate random bytes. Adapted from Joomla! 3.2.
Since we only run on PHP 7+ we can use random_bytes(), which internally uses a crypto safe PRNG. If the function
doesn't exist, Joomla already loads a secure polyfill.
The reason this method exists is backwards compatibility with older versions of FOF. It also allows us to quickly
address any future issues if Joomla drops the polyfill or otherwise find problems with PHP's random_bytes() on
some weird host (you can't be too careful when releasing mass-distributed software).
return: string
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,69 @@
<?php
/**
* @package FrameworkOnFramework
* @subpackage Encryption
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
* - Do not use this in new projects.
* - Expect no updates.
* - This is outdated.
* - Not best choice for encryption.
* - Use phpseclib/phpseclib version 3 Instead.
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
*/
namespace VDM\Joomla\FOF\Encrypt;
use VDM\Joomla\FOF\Encrypt\Randvalinterface;
/**
* Generates cryptographically-secure random values.
*
* @package FrameworkOnFramework
* @since 1.0
* @deprecated Use phpseclib/phpseclib version 3 Instead.
*/
class Randval implements Randvalinterface
{
/**
* Returns a cryptographically secure random value.
*
* Since we only run on PHP 7+ we can use random_bytes(), which internally uses a crypto safe PRNG. If the function
* doesn't exist, Joomla already loads a secure polyfill.
*
* The reason this method exists is backwards compatibility with older versions of FOF. It also allows us to quickly
* address any future issues if Joomla drops the polyfill or otherwise find problems with PHP's random_bytes() on
* some weird host (you can't be too careful when releasing mass-distributed software).
*
* @param integer $bytes How many bytes to return
*
* @return string
*/
public function generate($bytes = 32)
{
return random_bytes($bytes);
}
/**
* Generate random bytes. Adapted from Joomla! 3.2.
*
* Since we only run on PHP 7+ we can use random_bytes(), which internally uses a crypto safe PRNG. If the function
* doesn't exist, Joomla already loads a secure polyfill.
*
* The reason this method exists is backwards compatibility with older versions of FOF. It also allows us to quickly
* address any future issues if Joomla drops the polyfill or otherwise find problems with PHP's random_bytes() on
* some weird host (you can't be too careful when releasing mass-distributed software).
*
* @param integer $length Length of the random data to generate
*
* @return string Random binary data
*/
public function genRandomBytes($length = 32)
{
return random_bytes($length);
}
}

View File

@ -0,0 +1,37 @@
/**
* Returns a cryptographically secure random value.
*
* Since we only run on PHP 7+ we can use random_bytes(), which internally uses a crypto safe PRNG. If the function
* doesn't exist, Joomla already loads a secure polyfill.
*
* The reason this method exists is backwards compatibility with older versions of FOF. It also allows us to quickly
* address any future issues if Joomla drops the polyfill or otherwise find problems with PHP's random_bytes() on
* some weird host (you can't be too careful when releasing mass-distributed software).
*
* @param integer $bytes How many bytes to return
*
* @return string
*/
public function generate($bytes = 32)
{
return random_bytes($bytes);
}
/**
* Generate random bytes. Adapted from Joomla! 3.2.
*
* Since we only run on PHP 7+ we can use random_bytes(), which internally uses a crypto safe PRNG. If the function
* doesn't exist, Joomla already loads a secure polyfill.
*
* The reason this method exists is backwards compatibility with older versions of FOF. It also allows us to quickly
* address any future issues if Joomla drops the polyfill or otherwise find problems with PHP's random_bytes() on
* some weird host (you can't be too careful when releasing mass-distributed software).
*
* @param integer $length Length of the random data to generate
*
* @return string Random binary data
*/
public function genRandomBytes($length = 32)
{
return random_bytes($length);
}

View File

@ -0,0 +1,20 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "0",
"guid": "eef08a1d-5367-4464-8d07-d47c479fb76f",
"implements": [
"ba82e88a-254d-4ba4-99a3-ea69ed814f5c"
],
"load_selection": null,
"name": "Randval",
"power_version": "1.0.0",
"system_name": "FOF.Encrypt.Randval",
"type": "class",
"use_selection": null,
"namespace": "VDM\\Joomla\\FOF\\Encrypt.Randval",
"description": "Generates cryptographically-secure random values.\r\n\r\n@package FrameworkOnFramework\r\n@since 1.0\r\n@deprecated Use phpseclib\/phpseclib version 3 Instead. ",
"licensing_template": "\/**\r\n * @package FrameworkOnFramework\r\n * @subpackage Encryption\r\n * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos \/ Akeeba Ltd. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n * @note\t This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.\r\n * @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.\r\n * - Do not use this in new projects.\r\n * - Expect no updates.\r\n * - This is outdated.\r\n * - Not best choice for encryption.\r\n * - Use phpseclib\/phpseclib version 3 Instead.\r\n * - Checkout the JCB Crypt Suite. <https:\/\/git.vdm.dev\/joomla\/phpseclib>\r\n *\/",
"head": "",
"composer": ""
}

90
super-powers.json Normal file
View File

@ -0,0 +1,90 @@
{
"25da88d3-f7b2-4666-977f-e68ff731d1e8": {
"name": "Mcrypt",
"type": "class",
"namespace": "VDM\\Joomla\\FOF\\Encrypt\\AES",
"code": "src\/25da88d3-f7b2-4666-977f-e68ff731d1e8\/code.php",
"power": "src\/25da88d3-f7b2-4666-977f-e68ff731d1e8\/code.power",
"settings": "src\/25da88d3-f7b2-4666-977f-e68ff731d1e8\/settings.json",
"path": "src\/25da88d3-f7b2-4666-977f-e68ff731d1e8",
"spk": "Super__25da88d3_f7b2_4666_977f_e68ff731d1e8__Power",
"guid": "25da88d3-f7b2-4666-977f-e68ff731d1e8"
},
"470a08ee-6b31-4a2b-98d9-5b64757a3b34": {
"name": "Phpfunc",
"type": "class",
"namespace": "VDM\\Joomla\\FOF\\Utils",
"code": "src\/470a08ee-6b31-4a2b-98d9-5b64757a3b34\/code.php",
"power": "src\/470a08ee-6b31-4a2b-98d9-5b64757a3b34\/code.power",
"settings": "src\/470a08ee-6b31-4a2b-98d9-5b64757a3b34\/settings.json",
"path": "src\/470a08ee-6b31-4a2b-98d9-5b64757a3b34",
"spk": "Super__470a08ee_6b31_4a2b_98d9_5b64757a3b34__Power",
"guid": "470a08ee-6b31-4a2b-98d9-5b64757a3b34"
},
"4c89df31-8b94-40bb-94fc-7ec378145044": {
"name": "Abstraction",
"type": "abstract class",
"namespace": "VDM\\Joomla\\FOF\\Encrypt\\AES",
"code": "src\/4c89df31-8b94-40bb-94fc-7ec378145044\/code.php",
"power": "src\/4c89df31-8b94-40bb-94fc-7ec378145044\/code.power",
"settings": "src\/4c89df31-8b94-40bb-94fc-7ec378145044\/settings.json",
"path": "src\/4c89df31-8b94-40bb-94fc-7ec378145044",
"spk": "Super__4c89df31_8b94_40bb_94fc_7ec378145044__Power",
"guid": "4c89df31-8b94-40bb-94fc-7ec378145044"
},
"7f753585-6e3b-4b81-bd29-3b7bdf0e3769": {
"name": "AesInterface",
"type": "interface",
"namespace": "VDM\\Joomla\\FOF\\Encrypt\\AES",
"code": "src\/7f753585-6e3b-4b81-bd29-3b7bdf0e3769\/code.php",
"power": "src\/7f753585-6e3b-4b81-bd29-3b7bdf0e3769\/code.power",
"settings": "src\/7f753585-6e3b-4b81-bd29-3b7bdf0e3769\/settings.json",
"path": "src\/7f753585-6e3b-4b81-bd29-3b7bdf0e3769",
"spk": "Super__7f753585_6e3b_4b81_bd29_3b7bdf0e3769__Power",
"guid": "7f753585-6e3b-4b81-bd29-3b7bdf0e3769"
},
"885cc1cf-1904-483c-aecc-6af916c329e7": {
"name": "Openssl",
"type": "class",
"namespace": "VDM\\Joomla\\FOF\\Encrypt\\AES",
"code": "src\/885cc1cf-1904-483c-aecc-6af916c329e7\/code.php",
"power": "src\/885cc1cf-1904-483c-aecc-6af916c329e7\/code.power",
"settings": "src\/885cc1cf-1904-483c-aecc-6af916c329e7\/settings.json",
"path": "src\/885cc1cf-1904-483c-aecc-6af916c329e7",
"spk": "Super__885cc1cf_1904_483c_aecc_6af916c329e7__Power",
"guid": "885cc1cf-1904-483c-aecc-6af916c329e7"
},
"99175f6d-dba8-4086-8a65-5c4ec175e61d": {
"name": "AES",
"type": "class",
"namespace": "VDM\\Joomla\\FOF\\Encrypt",
"code": "src\/99175f6d-dba8-4086-8a65-5c4ec175e61d\/code.php",
"power": "src\/99175f6d-dba8-4086-8a65-5c4ec175e61d\/code.power",
"settings": "src\/99175f6d-dba8-4086-8a65-5c4ec175e61d\/settings.json",
"path": "src\/99175f6d-dba8-4086-8a65-5c4ec175e61d",
"spk": "Super__99175f6d_dba8_4086_8a65_5c4ec175e61d__Power",
"guid": "99175f6d-dba8-4086-8a65-5c4ec175e61d"
},
"ba82e88a-254d-4ba4-99a3-ea69ed814f5c": {
"name": "Randvalinterface",
"type": "interface",
"namespace": "VDM\\Joomla\\FOF\\Encrypt",
"code": "src\/ba82e88a-254d-4ba4-99a3-ea69ed814f5c\/code.php",
"power": "src\/ba82e88a-254d-4ba4-99a3-ea69ed814f5c\/code.power",
"settings": "src\/ba82e88a-254d-4ba4-99a3-ea69ed814f5c\/settings.json",
"path": "src\/ba82e88a-254d-4ba4-99a3-ea69ed814f5c",
"spk": "Super__ba82e88a_254d_4ba4_99a3_ea69ed814f5c__Power",
"guid": "ba82e88a-254d-4ba4-99a3-ea69ed814f5c"
},
"eef08a1d-5367-4464-8d07-d47c479fb76f": {
"name": "Randval",
"type": "class",
"namespace": "VDM\\Joomla\\FOF\\Encrypt",
"code": "src\/eef08a1d-5367-4464-8d07-d47c479fb76f\/code.php",
"power": "src\/eef08a1d-5367-4464-8d07-d47c479fb76f\/code.power",
"settings": "src\/eef08a1d-5367-4464-8d07-d47c479fb76f\/settings.json",
"path": "src\/eef08a1d-5367-4464-8d07-d47c479fb76f",
"spk": "Super__eef08a1d_5367_4464_8d07_d47c479fb76f__Power",
"guid": "eef08a1d-5367-4464-8d07-d47c479fb76f"
}
}