Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/worker/src/PHPSecLi.../Crypt
File: Base.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Base Class for all Crypt_* cipher classes
[3] Fix | Delete
*
[4] Fix | Delete
* PHP versions 4 and 5
[5] Fix | Delete
*
[6] Fix | Delete
* Internally for phpseclib developers:
[7] Fix | Delete
* If you plan to add a new cipher class, please note following rules:
[8] Fix | Delete
*
[9] Fix | Delete
* - The new Crypt_* cipher class should extend Crypt_Base
[10] Fix | Delete
*
[11] Fix | Delete
* - Following methods are then required to be overridden/overloaded:
[12] Fix | Delete
*
[13] Fix | Delete
* - _encryptBlock()
[14] Fix | Delete
*
[15] Fix | Delete
* - _decryptBlock()
[16] Fix | Delete
*
[17] Fix | Delete
* - _setupKey()
[18] Fix | Delete
*
[19] Fix | Delete
* - All other methods are optional to be overridden/overloaded
[20] Fix | Delete
*
[21] Fix | Delete
* - Look at the source code of the current ciphers how they extend Crypt_Base
[22] Fix | Delete
* and take one of them as a start up for the new cipher class.
[23] Fix | Delete
*
[24] Fix | Delete
* - Please read all the other comments/notes/hints here also for each class var/method
[25] Fix | Delete
*
[26] Fix | Delete
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
[27] Fix | Delete
* of this software and associated documentation files (the "Software"), to deal
[28] Fix | Delete
* in the Software without restriction, including without limitation the rights
[29] Fix | Delete
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
[30] Fix | Delete
* copies of the Software, and to permit persons to whom the Software is
[31] Fix | Delete
* furnished to do so, subject to the following conditions:
[32] Fix | Delete
*
[33] Fix | Delete
* The above copyright notice and this permission notice shall be included in
[34] Fix | Delete
* all copies or substantial portions of the Software.
[35] Fix | Delete
*
[36] Fix | Delete
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
[37] Fix | Delete
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
[38] Fix | Delete
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
[39] Fix | Delete
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
[40] Fix | Delete
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
[41] Fix | Delete
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
[42] Fix | Delete
* THE SOFTWARE.
[43] Fix | Delete
*
[44] Fix | Delete
* @category Crypt
[45] Fix | Delete
* @package Crypt_Base
[46] Fix | Delete
* @author Jim Wigginton <terrafrost@php.net>
[47] Fix | Delete
* @author Hans-Juergen Petrich <petrich@tronic-media.com>
[48] Fix | Delete
* @copyright MMVII Jim Wigginton
[49] Fix | Delete
* @license http://www.opensource.org/licenses/mit-license.html MIT License
[50] Fix | Delete
* @link http://phpseclib.sourceforge.net
[51] Fix | Delete
*/
[52] Fix | Delete
[53] Fix | Delete
/**#@+
[54] Fix | Delete
* @access public
[55] Fix | Delete
* @see Crypt_Base::encrypt()
[56] Fix | Delete
* @see Crypt_Base::decrypt()
[57] Fix | Delete
*/
[58] Fix | Delete
/**
[59] Fix | Delete
* Encrypt / decrypt using the Counter mode.
[60] Fix | Delete
*
[61] Fix | Delete
* Set to -1 since that's what Crypt/Random.php uses to index the CTR mode.
[62] Fix | Delete
*
[63] Fix | Delete
* @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29
[64] Fix | Delete
*/
[65] Fix | Delete
define('CRYPT_MODE_CTR', -1);
[66] Fix | Delete
/**
[67] Fix | Delete
* Encrypt / decrypt using the Electronic Code Book mode.
[68] Fix | Delete
*
[69] Fix | Delete
* @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29
[70] Fix | Delete
*/
[71] Fix | Delete
define('CRYPT_MODE_ECB', 1);
[72] Fix | Delete
/**
[73] Fix | Delete
* Encrypt / decrypt using the Code Book Chaining mode.
[74] Fix | Delete
*
[75] Fix | Delete
* @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29
[76] Fix | Delete
*/
[77] Fix | Delete
define('CRYPT_MODE_CBC', 2);
[78] Fix | Delete
/**
[79] Fix | Delete
* Encrypt / decrypt using the Cipher Feedback mode.
[80] Fix | Delete
*
[81] Fix | Delete
* @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29
[82] Fix | Delete
*/
[83] Fix | Delete
define('CRYPT_MODE_CFB', 3);
[84] Fix | Delete
/**
[85] Fix | Delete
* Encrypt / decrypt using the Output Feedback mode.
[86] Fix | Delete
*
[87] Fix | Delete
* @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29
[88] Fix | Delete
*/
[89] Fix | Delete
define('CRYPT_MODE_OFB', 4);
[90] Fix | Delete
/**
[91] Fix | Delete
* Encrypt / decrypt using streaming mode.
[92] Fix | Delete
*
[93] Fix | Delete
*/
[94] Fix | Delete
define('CRYPT_MODE_STREAM', 5);
[95] Fix | Delete
/**#@-*/
[96] Fix | Delete
[97] Fix | Delete
/**#@+
[98] Fix | Delete
* @access private
[99] Fix | Delete
* @see Crypt_Base::Crypt_Base()
[100] Fix | Delete
*/
[101] Fix | Delete
/**
[102] Fix | Delete
* Base value for the internal implementation $engine switch
[103] Fix | Delete
*/
[104] Fix | Delete
define('CRYPT_MODE_INTERNAL', 1);
[105] Fix | Delete
/**
[106] Fix | Delete
* Base value for the mcrypt implementation $engine switch
[107] Fix | Delete
*/
[108] Fix | Delete
define('CRYPT_MODE_MCRYPT', 2);
[109] Fix | Delete
/**#@-*/
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* Base Class for all Crypt_* cipher classes
[113] Fix | Delete
*
[114] Fix | Delete
* @package Crypt_Base
[115] Fix | Delete
* @author Jim Wigginton <terrafrost@php.net>
[116] Fix | Delete
* @author Hans-Juergen Petrich <petrich@tronic-media.com>
[117] Fix | Delete
* @access public
[118] Fix | Delete
*/
[119] Fix | Delete
class Crypt_Base
[120] Fix | Delete
{
[121] Fix | Delete
/**
[122] Fix | Delete
* The Encryption Mode
[123] Fix | Delete
*
[124] Fix | Delete
* @see Crypt_Base::Crypt_Base()
[125] Fix | Delete
* @var Integer
[126] Fix | Delete
* @access private
[127] Fix | Delete
*/
[128] Fix | Delete
public $mode;
[129] Fix | Delete
[130] Fix | Delete
/**
[131] Fix | Delete
* The Block Length of the block cipher
[132] Fix | Delete
*
[133] Fix | Delete
* @var Integer
[134] Fix | Delete
* @access private
[135] Fix | Delete
*/
[136] Fix | Delete
public $block_size = 16;
[137] Fix | Delete
[138] Fix | Delete
/**
[139] Fix | Delete
* The Key
[140] Fix | Delete
*
[141] Fix | Delete
* @see Crypt_Base::setKey()
[142] Fix | Delete
* @var String
[143] Fix | Delete
* @access private
[144] Fix | Delete
*/
[145] Fix | Delete
public $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
[146] Fix | Delete
[147] Fix | Delete
/**
[148] Fix | Delete
* The Initialization Vector
[149] Fix | Delete
*
[150] Fix | Delete
* @see Crypt_Base::setIV()
[151] Fix | Delete
* @var String
[152] Fix | Delete
* @access private
[153] Fix | Delete
*/
[154] Fix | Delete
public $iv;
[155] Fix | Delete
[156] Fix | Delete
/**
[157] Fix | Delete
* A "sliding" Initialization Vector
[158] Fix | Delete
*
[159] Fix | Delete
* @see Crypt_Base::enableContinuousBuffer()
[160] Fix | Delete
* @see Crypt_Base::_clearBuffers()
[161] Fix | Delete
* @var String
[162] Fix | Delete
* @access private
[163] Fix | Delete
*/
[164] Fix | Delete
public $encryptIV;
[165] Fix | Delete
[166] Fix | Delete
/**
[167] Fix | Delete
* A "sliding" Initialization Vector
[168] Fix | Delete
*
[169] Fix | Delete
* @see Crypt_Base::enableContinuousBuffer()
[170] Fix | Delete
* @see Crypt_Base::_clearBuffers()
[171] Fix | Delete
* @var String
[172] Fix | Delete
* @access private
[173] Fix | Delete
*/
[174] Fix | Delete
public $decryptIV;
[175] Fix | Delete
[176] Fix | Delete
/**
[177] Fix | Delete
* Continuous Buffer status
[178] Fix | Delete
*
[179] Fix | Delete
* @see Crypt_Base::enableContinuousBuffer()
[180] Fix | Delete
* @var Boolean
[181] Fix | Delete
* @access private
[182] Fix | Delete
*/
[183] Fix | Delete
public $continuousBuffer = false;
[184] Fix | Delete
[185] Fix | Delete
/**
[186] Fix | Delete
* Encryption buffer for CTR, OFB and CFB modes
[187] Fix | Delete
*
[188] Fix | Delete
* @see Crypt_Base::encrypt()
[189] Fix | Delete
* @see Crypt_Base::_clearBuffers()
[190] Fix | Delete
* @var Array
[191] Fix | Delete
* @access private
[192] Fix | Delete
*/
[193] Fix | Delete
public $enbuffer;
[194] Fix | Delete
[195] Fix | Delete
/**
[196] Fix | Delete
* Decryption buffer for CTR, OFB and CFB modes
[197] Fix | Delete
*
[198] Fix | Delete
* @see Crypt_Base::decrypt()
[199] Fix | Delete
* @see Crypt_Base::_clearBuffers()
[200] Fix | Delete
* @var Array
[201] Fix | Delete
* @access private
[202] Fix | Delete
*/
[203] Fix | Delete
public $debuffer;
[204] Fix | Delete
[205] Fix | Delete
/**
[206] Fix | Delete
* mcrypt resource for encryption
[207] Fix | Delete
*
[208] Fix | Delete
* The mcrypt resource can be recreated every time something needs to be created or it can be created just once.
[209] Fix | Delete
* Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.
[210] Fix | Delete
*
[211] Fix | Delete
* @see Crypt_Base::encrypt()
[212] Fix | Delete
* @var Resource
[213] Fix | Delete
* @access private
[214] Fix | Delete
*/
[215] Fix | Delete
public $enmcrypt;
[216] Fix | Delete
[217] Fix | Delete
/**
[218] Fix | Delete
* mcrypt resource for decryption
[219] Fix | Delete
*
[220] Fix | Delete
* The mcrypt resource can be recreated every time something needs to be created or it can be created just once.
[221] Fix | Delete
* Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.
[222] Fix | Delete
*
[223] Fix | Delete
* @see Crypt_Base::decrypt()
[224] Fix | Delete
* @var Resource
[225] Fix | Delete
* @access private
[226] Fix | Delete
*/
[227] Fix | Delete
public $demcrypt;
[228] Fix | Delete
[229] Fix | Delete
/**
[230] Fix | Delete
* Does the enmcrypt resource need to be (re)initialized?
[231] Fix | Delete
*
[232] Fix | Delete
* @see Crypt_Twofish::setKey()
[233] Fix | Delete
* @see Crypt_Twofish::setIV()
[234] Fix | Delete
* @var Boolean
[235] Fix | Delete
* @access private
[236] Fix | Delete
*/
[237] Fix | Delete
public $enchanged = true;
[238] Fix | Delete
[239] Fix | Delete
/**
[240] Fix | Delete
* Does the demcrypt resource need to be (re)initialized?
[241] Fix | Delete
*
[242] Fix | Delete
* @see Crypt_Twofish::setKey()
[243] Fix | Delete
* @see Crypt_Twofish::setIV()
[244] Fix | Delete
* @var Boolean
[245] Fix | Delete
* @access private
[246] Fix | Delete
*/
[247] Fix | Delete
public $dechanged = true;
[248] Fix | Delete
[249] Fix | Delete
/**
[250] Fix | Delete
* mcrypt resource for CFB mode
[251] Fix | Delete
*
[252] Fix | Delete
* mcrypt's CFB mode, in (and only in) buffered context,
[253] Fix | Delete
* is broken, so phpseclib implements the CFB mode by it self,
[254] Fix | Delete
* even when the mcrypt php extension is available.
[255] Fix | Delete
*
[256] Fix | Delete
* In order to do the CFB-mode work (fast) phpseclib
[257] Fix | Delete
* use a separate ECB-mode mcrypt resource.
[258] Fix | Delete
*
[259] Fix | Delete
* @link http://phpseclib.sourceforge.net/cfb-demo.phps
[260] Fix | Delete
* @see Crypt_Base::encrypt()
[261] Fix | Delete
* @see Crypt_Base::decrypt()
[262] Fix | Delete
* @see Crypt_Base::_setupMcrypt()
[263] Fix | Delete
* @var Resource
[264] Fix | Delete
* @access private
[265] Fix | Delete
*/
[266] Fix | Delete
public $ecb;
[267] Fix | Delete
[268] Fix | Delete
/**
[269] Fix | Delete
* Optimizing value while CFB-encrypting
[270] Fix | Delete
*
[271] Fix | Delete
* Only relevant if $continuousBuffer enabled
[272] Fix | Delete
* and $engine == CRYPT_MODE_MCRYPT
[273] Fix | Delete
*
[274] Fix | Delete
* It's faster to re-init $enmcrypt if
[275] Fix | Delete
* $buffer bytes > $cfb_init_len than
[276] Fix | Delete
* using the $ecb resource furthermore.
[277] Fix | Delete
*
[278] Fix | Delete
* This value depends of the chosen cipher
[279] Fix | Delete
* and the time it would be needed for it's
[280] Fix | Delete
* initialization [by mcrypt_generic_init()]
[281] Fix | Delete
* which, typically, depends on the complexity
[282] Fix | Delete
* on its internaly Key-expanding algorithm.
[283] Fix | Delete
*
[284] Fix | Delete
* @see Crypt_Base::encrypt()
[285] Fix | Delete
* @var Integer
[286] Fix | Delete
* @access private
[287] Fix | Delete
*/
[288] Fix | Delete
public $cfb_init_len = 600;
[289] Fix | Delete
[290] Fix | Delete
/**
[291] Fix | Delete
* Does internal cipher state need to be (re)initialized?
[292] Fix | Delete
*
[293] Fix | Delete
* @see setKey()
[294] Fix | Delete
* @see setIV()
[295] Fix | Delete
* @see disableContinuousBuffer()
[296] Fix | Delete
* @var Boolean
[297] Fix | Delete
* @access private
[298] Fix | Delete
*/
[299] Fix | Delete
public $changed = true;
[300] Fix | Delete
[301] Fix | Delete
/**
[302] Fix | Delete
* Padding status
[303] Fix | Delete
*
[304] Fix | Delete
* @see Crypt_Base::enablePadding()
[305] Fix | Delete
* @var Boolean
[306] Fix | Delete
* @access private
[307] Fix | Delete
*/
[308] Fix | Delete
public $padding = true;
[309] Fix | Delete
[310] Fix | Delete
/**
[311] Fix | Delete
* Is the mode one that is paddable?
[312] Fix | Delete
*
[313] Fix | Delete
* @see Crypt_Base::Crypt_Base()
[314] Fix | Delete
* @var Boolean
[315] Fix | Delete
* @access private
[316] Fix | Delete
*/
[317] Fix | Delete
public $paddable = false;
[318] Fix | Delete
[319] Fix | Delete
/**
[320] Fix | Delete
* Holds which crypt engine internaly should be use,
[321] Fix | Delete
* which will be determined automatically on __construct()
[322] Fix | Delete
*
[323] Fix | Delete
* Currently available $engines are:
[324] Fix | Delete
* - CRYPT_MODE_MCRYPT (fast, php-extension: mcrypt, extension_loaded('mcrypt') required)
[325] Fix | Delete
* - CRYPT_MODE_INTERNAL (slower, pure php-engine, no php-extension required)
[326] Fix | Delete
*
[327] Fix | Delete
* In the pipeline... maybe. But currently not available:
[328] Fix | Delete
* - CRYPT_MODE_OPENSSL (very fast, php-extension: openssl, extension_loaded('openssl') required)
[329] Fix | Delete
*
[330] Fix | Delete
* If possible, CRYPT_MODE_MCRYPT will be used for each cipher.
[331] Fix | Delete
* Otherwise CRYPT_MODE_INTERNAL
[332] Fix | Delete
*
[333] Fix | Delete
* @see Crypt_Base::encrypt()
[334] Fix | Delete
* @see Crypt_Base::decrypt()
[335] Fix | Delete
* @var Integer
[336] Fix | Delete
* @access private
[337] Fix | Delete
*/
[338] Fix | Delete
public $engine;
[339] Fix | Delete
[340] Fix | Delete
/**
[341] Fix | Delete
* The mcrypt specific name of the cipher
[342] Fix | Delete
*
[343] Fix | Delete
* Only used if $engine == CRYPT_MODE_MCRYPT
[344] Fix | Delete
*
[345] Fix | Delete
* @link http://www.php.net/mcrypt_module_open
[346] Fix | Delete
* @link http://www.php.net/mcrypt_list_algorithms
[347] Fix | Delete
* @see Crypt_Base::_setupMcrypt()
[348] Fix | Delete
* @var String
[349] Fix | Delete
* @access private
[350] Fix | Delete
*/
[351] Fix | Delete
public $cipher_name_mcrypt;
[352] Fix | Delete
[353] Fix | Delete
/**
[354] Fix | Delete
* The default password key_size used by setPassword()
[355] Fix | Delete
*
[356] Fix | Delete
* @see Crypt_Base::setPassword()
[357] Fix | Delete
* @var Integer
[358] Fix | Delete
* @access private
[359] Fix | Delete
*/
[360] Fix | Delete
public $password_key_size = 32;
[361] Fix | Delete
[362] Fix | Delete
/**
[363] Fix | Delete
* The default salt used by setPassword()
[364] Fix | Delete
*
[365] Fix | Delete
* @see Crypt_Base::setPassword()
[366] Fix | Delete
* @var String
[367] Fix | Delete
* @access private
[368] Fix | Delete
*/
[369] Fix | Delete
public $password_default_salt = 'phpseclib/salt';
[370] Fix | Delete
[371] Fix | Delete
/**
[372] Fix | Delete
* The namespace used by the cipher for its constants.
[373] Fix | Delete
*
[374] Fix | Delete
* ie: AES.php is using CRYPT_AES_MODE_* for its constants
[375] Fix | Delete
* so $const_namespace is AES
[376] Fix | Delete
*
[377] Fix | Delete
* DES.php is using CRYPT_DES_MODE_* for its constants
[378] Fix | Delete
* so $const_namespace is DES... and so on
[379] Fix | Delete
*
[380] Fix | Delete
* All CRYPT_<$const_namespace>_MODE_* are aliases of
[381] Fix | Delete
* the generic CRYPT_MODE_* constants, so both could be used
[382] Fix | Delete
* for each cipher.
[383] Fix | Delete
*
[384] Fix | Delete
* Example:
[385] Fix | Delete
* $aes = new Crypt_AES(CRYPT_AES_MODE_CFB); // $aes will operate in cfb mode
[386] Fix | Delete
* $aes = new Crypt_AES(CRYPT_MODE_CFB); // identical
[387] Fix | Delete
*
[388] Fix | Delete
* @see Crypt_Base::Crypt_Base()
[389] Fix | Delete
* @var String
[390] Fix | Delete
* @access private
[391] Fix | Delete
*/
[392] Fix | Delete
public $const_namespace;
[393] Fix | Delete
[394] Fix | Delete
/**
[395] Fix | Delete
* The name of the performance-optimized callback function
[396] Fix | Delete
*
[397] Fix | Delete
* Used by encrypt() / decrypt()
[398] Fix | Delete
* only if $engine == CRYPT_MODE_INTERNAL
[399] Fix | Delete
*
[400] Fix | Delete
* @see Crypt_Base::encrypt()
[401] Fix | Delete
* @see Crypt_Base::decrypt()
[402] Fix | Delete
* @see Crypt_Base::_setupInlineCrypt()
[403] Fix | Delete
* @see Crypt_Base::$use_inline_crypt
[404] Fix | Delete
* @var Callback
[405] Fix | Delete
* @access private
[406] Fix | Delete
*/
[407] Fix | Delete
public $inline_crypt;
[408] Fix | Delete
[409] Fix | Delete
/**
[410] Fix | Delete
* Holds whether performance-optimized $inline_crypt() can/should be used.
[411] Fix | Delete
*
[412] Fix | Delete
* @see Crypt_Base::encrypt()
[413] Fix | Delete
* @see Crypt_Base::decrypt()
[414] Fix | Delete
* @see Crypt_Base::inline_crypt
[415] Fix | Delete
* @var mixed
[416] Fix | Delete
* @access private
[417] Fix | Delete
*/
[418] Fix | Delete
public $use_inline_crypt;
[419] Fix | Delete
[420] Fix | Delete
/**
[421] Fix | Delete
* Default Constructor.
[422] Fix | Delete
*
[423] Fix | Delete
* Determines whether or not the mcrypt extension should be used.
[424] Fix | Delete
*
[425] Fix | Delete
* $mode could be:
[426] Fix | Delete
*
[427] Fix | Delete
* - CRYPT_MODE_ECB
[428] Fix | Delete
*
[429] Fix | Delete
* - CRYPT_MODE_CBC
[430] Fix | Delete
*
[431] Fix | Delete
* - CRYPT_MODE_CTR
[432] Fix | Delete
*
[433] Fix | Delete
* - CRYPT_MODE_CFB
[434] Fix | Delete
*
[435] Fix | Delete
* - CRYPT_MODE_OFB
[436] Fix | Delete
*
[437] Fix | Delete
* (or the alias constants of the chosen cipher, for example for AES: CRYPT_AES_MODE_ECB or CRYPT_AES_MODE_CBC ...)
[438] Fix | Delete
*
[439] Fix | Delete
* If not explicitly set, CRYPT_MODE_CBC will be used.
[440] Fix | Delete
*
[441] Fix | Delete
* @param optional Integer $mode
[442] Fix | Delete
*
[443] Fix | Delete
* @access public
[444] Fix | Delete
*/
[445] Fix | Delete
public function __construct($mode = CRYPT_MODE_CBC)
[446] Fix | Delete
{
[447] Fix | Delete
$const_crypt_mode = 'CRYPT_'.$this->const_namespace.'_MODE';
[448] Fix | Delete
[449] Fix | Delete
// Determining the availibility of mcrypt support for the cipher
[450] Fix | Delete
if (!defined($const_crypt_mode)) {
[451] Fix | Delete
switch (true) {
[452] Fix | Delete
case extension_loaded('mcrypt') && in_array($this->cipher_name_mcrypt, mcrypt_list_algorithms()):
[453] Fix | Delete
define($const_crypt_mode, CRYPT_MODE_MCRYPT);
[454] Fix | Delete
break;
[455] Fix | Delete
default:
[456] Fix | Delete
define($const_crypt_mode, CRYPT_MODE_INTERNAL);
[457] Fix | Delete
}
[458] Fix | Delete
}
[459] Fix | Delete
[460] Fix | Delete
// Determining which internal $engine should be used.
[461] Fix | Delete
// The fastes possible first.
[462] Fix | Delete
switch (true) {
[463] Fix | Delete
case empty($this->cipher_name_mcrypt): // The cipher module has no mcrypt-engine support at all so we force CRYPT_MODE_INTERNAL
[464] Fix | Delete
$this->engine = CRYPT_MODE_INTERNAL;
[465] Fix | Delete
break;
[466] Fix | Delete
case constant($const_crypt_mode) == CRYPT_MODE_MCRYPT:
[467] Fix | Delete
$this->engine = CRYPT_MODE_MCRYPT;
[468] Fix | Delete
break;
[469] Fix | Delete
default:
[470] Fix | Delete
$this->engine = CRYPT_MODE_INTERNAL;
[471] Fix | Delete
}
[472] Fix | Delete
[473] Fix | Delete
// $mode dependent settings
[474] Fix | Delete
switch ($mode) {
[475] Fix | Delete
case CRYPT_MODE_ECB:
[476] Fix | Delete
$this->paddable = true;
[477] Fix | Delete
$this->mode = $mode;
[478] Fix | Delete
break;
[479] Fix | Delete
case CRYPT_MODE_CTR:
[480] Fix | Delete
case CRYPT_MODE_CFB:
[481] Fix | Delete
case CRYPT_MODE_OFB:
[482] Fix | Delete
case CRYPT_MODE_STREAM:
[483] Fix | Delete
$this->mode = $mode;
[484] Fix | Delete
break;
[485] Fix | Delete
case CRYPT_MODE_CBC:
[486] Fix | Delete
default:
[487] Fix | Delete
$this->paddable = true;
[488] Fix | Delete
$this->mode = CRYPT_MODE_CBC;
[489] Fix | Delete
}
[490] Fix | Delete
[491] Fix | Delete
// Determining whether inline crypting can be used by the cipher
[492] Fix | Delete
if ($this->use_inline_crypt !== false && function_exists('create_function')) {
[493] Fix | Delete
$this->use_inline_crypt = true;
[494] Fix | Delete
}
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
/**
[498] Fix | Delete
* Sets the initialization vector. (optional)
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function