Added replacement for mcrypt removal in PHP 7.2, added stronger encryption options

SVN:trunk[5996]
This commit is contained in:
Stephen Abello
2018-08-03 08:43:36 +00:00
parent 0adadeb280
commit 8fe38b03f6
18 changed files with 279 additions and 23 deletions

View File

@@ -2737,7 +2737,7 @@ class AttributeEncryptedString extends AttributeString
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
static $sKey = null; // Encryption key used for all encrypted fields
static $sLibrary = null; // Encryption library used for all encrypted fields
public function __construct($sCode, $aParams)
{
parent::__construct($sCode, $aParams);
@@ -2745,6 +2745,10 @@ class AttributeEncryptedString extends AttributeString
{
self::$sKey = MetaModel::GetConfig()->GetEncryptionKey();
}
if(self::$sLibrary == null)
{
self::$sLibrary = MetaModel::GetConfig()->GetEncryptionLibrary();
}
}
/**
* When the attribute definitions are stored in APC cache:
@@ -2760,6 +2764,10 @@ class AttributeEncryptedString extends AttributeString
{
self::$sKey = MetaModel::GetConfig()->GetEncryptionKey();
}
if(self::$sLibrary == null)
{
self::$sLibrary = MetaModel::GetConfig()->GetEncryptionLibrary();
}
}
@@ -2788,7 +2796,7 @@ class AttributeEncryptedString extends AttributeString
*/
public function FromSQLToValue($aCols, $sPrefix = '')
{
$oSimpleCrypt = new SimpleCrypt();
$oSimpleCrypt = new SimpleCrypt(self::$sLibrary);
$sValue = $oSimpleCrypt->Decrypt(self::$sKey, $aCols[$sPrefix]);
return $sValue;
}
@@ -2798,7 +2806,7 @@ class AttributeEncryptedString extends AttributeString
*/
public function GetSQLValues($value)
{
$oSimpleCrypt = new SimpleCrypt();
$oSimpleCrypt = new SimpleCrypt(self::$sLibrary);
$encryptedValue = $oSimpleCrypt->Encrypt(self::$sKey, $value);
$aValues = array();