[BUGFIX] Follow-up to PHP 5.5 warning when decrypting word 45/46645/2
authorStanislas Rolland <typo3@sjbr.ca>
Sat, 13 Feb 2016 16:51:59 +0000 (11:51 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Sat, 13 Feb 2016 16:54:32 +0000 (17:54 +0100)
Resolves: #73220
Change-Id: Ie97700202c8a1ed845f154ebb78a4f93bd6957fa
Reviewed-on: https://review.typo3.org/46645
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
ChangeLog
Classes/Utility/EncryptionUtility.php

index 2df1790..c88fcfd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,8 @@
 2016-02-13  Stanislas Rolland  <typo(arobas)sjbr.ca>
 
        * Resolves #73422: Cleanup in German word list
-       * Resolves #73423: Incorrect audio rendering when using word lists with non-ASCII characters    
+       * Resolves #73423: Incorrect audio rendering when using word lists with non-ASCII characters
+       * Resolves #73220: Follow-up to PHP 5.5 warning when decrypting word with blowfish algorithm
 
 2016-02-11  Stanislas Rolland  <typo(arobas)sjbr.ca>
 
index f4712ef..609d068 100644 (file)
@@ -41,13 +41,12 @@ class EncryptionUtility
        {
                if (in_array('mcrypt', get_loaded_extensions())) {
                        $encryptionAlgorithm = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sr_freecap']['encryptionAlgorithm'];
-                       $module = mcrypt_module_open($encryptionAlgorithm, '', MCRYPT_MODE_CBC, '');
-                       if ($module !== false) {
-                               $key = md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
-                               $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND);
+                       $availableAlgorithms = mcrypt_list_algorithms();
+                       if (in_array($encryptionAlgorithm, $availableAlgorithms)) {
+                               $key = md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], true);
+                               $iv = mcrypt_create_iv(mcrypt_get_iv_size($encryptionAlgorithm, MCRYPT_MODE_CBC), MCRYPT_RAND);
                                $string = mcrypt_encrypt($encryptionAlgorithm, $key, $string, MCRYPT_MODE_CBC, $iv);
-                               $cypher = array(base64_encode($string), $iv);
-                               mcrypt_module_close($module);
+                               $cypher = array(base64_encode($string), base64_encode($iv));
                        } else {
                                $cypher = array(base64_encode($string));
                        }
@@ -66,8 +65,8 @@ class EncryptionUtility
        public static function decrypt($cypher)
        {
                if (in_array('mcrypt', get_loaded_extensions())) {
-                       $key = md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
-                       $string = trim(mcrypt_decrypt($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sr_freecap']['encryptionAlgorithm'], $key, base64_decode($cypher[0]), MCRYPT_MODE_CBC, $cypher[1]));
+                       $key = md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], true);
+                       $string = trim(mcrypt_decrypt($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sr_freecap']['encryptionAlgorithm'], $key, base64_decode($cypher[0]), MCRYPT_MODE_CBC, base64_decode($cypher[1])));
                } else {
                        $string = base64_decode($cypher[0]);
                }