Вход Регистрация
Файл: oc-includes/phpseclib/Crypt/Twofish.php
Строк: 357
<?php

/**
 * Pure-PHP implementation of Twofish.
 *
 * Uses mcrypt, if available, and an internal implementation, otherwise.
 *
 * PHP versions 4 and 5
 *
 * Useful resources are as follows:
 *
 *  - {@link http://en.wikipedia.org/wiki/Twofish Wikipedia description of Twofish}
 *
 * Here's a short example of how to use this library:
 * <code>
 * <?php
 *    include 'Crypt/Twofish.php';
 *
 *    $twofish = new Crypt_Twofish();
 *
 *    $twofish->setKey('12345678901234567890123456789012');
 *
 *    $plaintext = str_repeat('a', 1024);
 *
 *    echo $twofish->decrypt($twofish->encrypt($plaintext));
 * ?>
 * </code>
 *
 * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @category  Crypt
 * @package   Crypt_Twofish
 * @author    Jim Wigginton <terrafrost@php.net>
 * @author    Hans-Juergen Petrich <petrich@tronic-media.com>
 * @copyright 2007 Jim Wigginton
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
 * @link      http://phpseclib.sourceforge.net
 */

/**
 * Include Crypt_Base
 *
 * Base cipher class
 */
if (!class_exists('Crypt_Base')) {
    include_once 
'Base.php';
}

/**#@+
 * @access public
 * @see Crypt_Twofish::encrypt()
 * @see Crypt_Twofish::decrypt()
 */
/**
 * Encrypt / decrypt using the Counter mode.
 *
 * Set to -1 since that's what Crypt/Random.php uses to index the CTR mode.
 *
 * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29
 */
define('CRYPT_TWOFISH_MODE_CTR'CRYPT_MODE_CTR);
/**
 * Encrypt / decrypt using the Electronic Code Book mode.
 *
 * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29
 */
define('CRYPT_TWOFISH_MODE_ECB'CRYPT_MODE_ECB);
/**
 * Encrypt / decrypt using the Code Book Chaining mode.
 *
 * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29
 */
define('CRYPT_TWOFISH_MODE_CBC'CRYPT_MODE_CBC);
/**
 * Encrypt / decrypt using the Cipher Feedback mode.
 *
 * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29
 */
define('CRYPT_TWOFISH_MODE_CFB'CRYPT_MODE_CFB);
/**
 * Encrypt / decrypt using the Cipher Feedback mode.
 *
 * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29
 */
define('CRYPT_TWOFISH_MODE_OFB'CRYPT_MODE_OFB);
/**#@-*/

/**
 * Pure-PHP implementation of Twofish.
 *
 * @package Crypt_Twofish
 * @author  Jim Wigginton <terrafrost@php.net>
 * @author  Hans-Juergen Petrich <petrich@tronic-media.com>
 * @access  public
 */
class Crypt_Twofish extends Crypt_Base
{
    
/**
     * The namespace used by the cipher for its constants.
     *
     * @see Crypt_Base::const_namespace
     * @var String
     * @access private
     */
    
var $const_namespace 'TWOFISH';

    
/**
     * The mcrypt specific name of the cipher
     *
     * @see Crypt_Base::cipher_name_mcrypt
     * @var String
     * @access private
     */
    
var $cipher_name_mcrypt 'twofish';

    
/**
     * Optimizing value while CFB-encrypting
     *
     * @see Crypt_Base::cfb_init_len
     * @var Integer
     * @access private
     */
    
var $cfb_init_len 800;

    
/**
     * Q-Table
     *
     * @var Array
     * @access private
     */
    
var $q0 = array (
        
0xA90x670xB30xE80x040xFD0xA30x76,
        
0x9A0x920x800x780xE40xDD0xD10x38,
        
0x0D0xC60x350x980x180xF70xEC0x6C,
        
0x430x750x370x260xFA0x130x940x48,
        
0xF20xD00x8B0x300x840x540xDF0x23,
        
0x190x5B0x3D0x590xF30xAE0xA20x82,
        
0x630x010x830x2E0xD90x510x9B0x7C,
        
0xA60xEB0xA50xBE0x160x0C0xE30x61,
        
0xC00x8C0x3A0xF50x730x2C0x250x0B,
        
0xBB0x4E0x890x6B0x530x6A0xB40xF1,
        
0xE10xE60xBD0x450xE20xF40xB60x66,
        
0xCC0x950x030x560xD40x1C0x1E0xD7,
        
0xFB0xC30x8E0xB50xE90xCF0xBF0xBA,
        
0xEA0x770x390xAF0x330xC90x620x71,
        
0x810x790x090xAD0x240xCD0xF90xD8,
        
0xE50xC50xB90x4D0x440x080x860xE7,
        
0xA10x1D0xAA0xED0x060x700xB20xD2,
        
0x410x7B0xA00x110x310xC20x270x90,
        
0x200xF60x600xFF0x960x5C0xB10xAB,
        
0x9E0x9C0x520x1B0x5F0x930x0A0xEF,
        
0x910x850x490xEE0x2D0x4F0x8F0x3B,
        
0x470x870x6D0x460xD60x3E0x690x64,
        
0x2A0xCE0xCB0x2F0xFC0x970x050x7A,
        
0xAC0x7F0xD50x1A0x4B0x0E0xA70x5A,
        
0x280x140x3F0x290x880x3C0x4C0x02,
        
0xB80xDA0xB00x170x550x1F0x8A0x7D,
        
0x570xC70x8D0x740xB70xC40x9F0x72,
        
0x7E0x150x220x120x580x070x990x34,
        
0x6E0x500xDE0x680x650xBC0xDB0xF8,
        
0xC80xA80x2B0x400xDC0xFE0x320xA4,
        
0xCA0x100x210xF00xD30x5D0x0F0x00,
        
0x6F0x9D0x360x420x4A0x5E0xC10xE0
    
);

    
/**
     * Q-Table
     *
     * @var Array
     * @access private
     */
    
var $q1 = array (
        
0x750xF30xC60xF40xDB0x7B0xFB0xC8,
        
0x4A0xD30xE60x6B0x450x7D0xE80x4B,
        
0xD60x320xD80xFD0x370x710xF10xE1,
        
0x300x0F0xF80x1B0x870xFA0x060x3F,
        
0x5E0xBA0xAE0x5B0x8A0x000xBC0x9D,
        
0x6D0xC10xB10x0E0x800x5D0xD20xD5,
        
0xA00x840x070x140xB50x900x2C0xA3,
        
0xB20x730x4C0x540x920x740x360x51,
        
0x380xB00xBD0x5A0xFC0x600x620x96,
        
0x6C0x420xF70x100x7C0x280x270x8C,
        
0x130x950x9C0xC70x240x460x3B0x70,
        
0xCA0xE30x850xCB0x110xD00x930xB8,
        
0xA60x830x200xFF0x9F0x770xC30xCC,
        
0x030x6F0x080xBF0x400xE70x2B0xE2,
        
0x790x0C0xAA0x820x410x3A0xEA0xB9,
        
0xE40x9A0xA40x970x7E0xDA0x7A0x17,
        
0x660x940xA10x1D0x3D0xF00xDE0xB3,
        
0x0B0x720xA70x1C0xEF0xD10x530x3E,
        
0x8F0x330x260x5F0xEC0x760x2A0x49,
        
0x810x880xEE0x210xC40x1A0xEB0xD9,
        
0xC50x390x990xCD0xAD0x310x8B0x01,
        
0x180x230xDD0x1F0x4E0x2D0xF90x48,
        
0x4F0xF20x650x8E0x780x5C0x580x19,
        
0x8D0xE50x980x570x670x7F0x050x64,
        
0xAF0x630xB60xFE0xF50xB70x3C0xA5,
        
0xCE0xE90x680x440xE00x4D0x430x69,
        
0x290x2E0xAC0x150x590xA80x0A0x9E,
        
0x6E0x470xDF0x340x350x6A0xCF0xDC,
        
0x220xC90xC00x9B0x890xD40xED0xAB,
        
0x120xA20x0D0x520xBB0x020x2F0xA9,
        
0xD70x610x1E0xB40x500x040xF60xC2,
        
0x160x250x860x560x550x090xBE0x91
    
);

    
/**
     * M-Table
     *
     * @var Array
     * @access private
     */
    
var $m0 = array (
        
0xBCBC32750xECEC21F30x202043C60xB3B3C9F40xDADA03DB0x02028B7B0xE2E22BFB0x9E9EFAC8,
        
0xC9C9EC4A0xD4D409D30x18186BE60x1E1E9F6B0x98980E450xB2B2387D0xA6A6D2E80x2626B74B,
        
0x3C3C57D60x93938A320x8282EED80x525298FD0x7B7BD4370xBBBB37710x5B5B97F10x474783E1,
        
0x24243C300x5151E20F0xBABAC6F80x4A4AF31B0xBFBF48870x0D0D70FA0xB0B0B3060x7575DE3F,
        
0xD2D2FD5E0x7D7D20BA0x666631AE0x3A3AA35B0x59591C8A0x000000000xCDCD93BC0x1A1AE09D,
        
0xAEAE2C6D0x7F7FABC10x2B2BC7B10xBEBEB90E0xE0E0A0800x8A8A105D0x3B3B52D20x6464BAD5,
        
0xD8D888A00xE7E7A5840x5F5FE8070x1B1B11140x2C2CC2B50xFCFCB4900x3131272C0x808065A3,
        
0x73732AB20x0C0C81730x79795F4C0x6B6B41540x4B4B02920x535369740x94948F360x83831F51,
        
0x2A2A36380xC4C49CB00x2222C8BD0xD5D5F85A0xBDBDC3FC0x484878600xFFFFCE620x4C4C0796,
        
0x4141776C0xC7C7E6420xEBEB24F70x1C1C14100x5D5D637C0x363622280x6767C0270xE9E9AF8C,
        
0x4444F9130x1414EA950xF5F5BB9C0xCFCF18C70x3F3F2D240xC0C0E3460x7272DB3B0x54546C70,
        
0x29294CCA0xF0F035E30x0808FE850xC6C617CB0xF3F34F110x8C8CE4D00xA4A459930xCACA96B8,
        
0x68683BA60xB8B84D830x383828200xE5E52EFF0xADAD569F0x0B0B84770xC8C81DC30x9999FFCC,
        
0x5858ED030x19199A6F0x0E0E0A080x95957EBF0x707050400xF7F730E70x6E6ECF2B0x1F1F6EE2,
        
0xB5B53D790x09090F0C0x616134AA0x575716820x9F9F0B410x9D9D803A0x111164EA0x2525CDB9,
        
0xAFAFDDE40x4545089A0xDFDF8DA40xA3A35C970xEAEAD57E0x353558DA0xEDEDD07A0x4343FC17,
        
0xF8F8CB660xFBFBB1940x3737D3A10xFAFA401D0xC2C2683D0xB4B4CCF00x32325DDE0x9C9C71B3,
        
0x5656E70B0xE3E3DA720x878760A70x15151B1C0xF9F93AEF0x6363BFD10x3434A9530x9A9A853E,
        
0xB1B1428F0x7C7CD1330x88889B260x3D3DA65F0xA1A1D7EC0xE4E4DF760x8181942A0x91910149,
        
0x0F0FFB810xEEEEAA880x161661EE0xD7D773210x9797F5C40xA5A5A81A0xFEFE3FEB0x6D6DB5D9,
        
0x7878AEC50xC5C56D390x1D1DE5990x7676A4CD0x3E3EDCAD0xCBCB67310xB6B6478B0xEFEF5B01,
        
0x12121E180x6060C5230x6A6AB0DD0x4D4DF61F0xCECEE94E0xDEDE7C2D0x55559DF90x7E7E5A48,
        
0x2121B24F0x03037AF20xA0A026650x5E5E198E0x5A5A66780x65654B5C0x62624E580xFDFD4519,
        
0x0606F48D0x404086E50xF2F2BE980x3333AC570x171790670x05058E7F0xE8E85E050x4F4F7D64,
        
0x89896AAF0x101095630x74742FB60x0A0A75FE0x5C5C92F50x9B9B74B70x2D2D333C0x3030D6A5,
        
0x2E2E49CE0x494989E90x464672680x777755440xA8A8D8E00x9696044D0x2828BD430xA9A92969,
        
0xD9D979290x8686912E0xD1D187AC0xF4F44A150x8D8D15590xD6D682A80xB9B9BC0A0x42420D9E,
        
0xF6F6C16E0x2F2FB8470xDDDD06DF0x232339340xCCCC62350xF1F1C46A0xC1C112CF0x8585EBDC,
        
0x8F8F9E220x7171A1C90x9090F0C00xAAAA539B0x0101F1890x8B8BE1D40x4E4E8CED0x8E8E6FAB,
        
0xABABA2120x6F6F3EA20xE6E6540D0xDBDBF2520x92927BBB0xB7B7B6020x6969CA2F0x3939D9A9,
        
0xD3D30CD70xA7A723610xA2A2AD1E0xC3C399B40x6C6C44500x070705040x04047FF60x272746C2,
        
0xACACA7160xD0D076250x505013860xDCDCF7560x84841A550xE1E151090x7A7A25BE0x1313EF91
    
);

    
/**
     * M-Table
     *
     * @var Array
     * @access private
     */
    
var $m1 = array (
        
0xA9D939390x679017170xB3719C9C0xE8D2A6A60x040507070xFD9852520xA36580800x76DFE4E4,
        
0x9A0845450x92024B4B0x80A0E0E00x78665A5A0xE4DDAFAF0xDDB06A6A0xD1BF63630x38362A2A,
        
0x0D54E6E60xC64320200x3562CCCC0x98BEF2F20x181E12120xF724EBEB0xECD7A1A10x6C774141,
        
0x43BD28280x7532BCBC0x37D47B7B0x269B88880xFA700D0D0x13F944440x94B1FBFB0x485A7E7E,
        
0xF27A03030xD0E48C8C0x8B47B6B60x303C24240x84A5E7E70x54416B6B0xDF06DDDD0x23C56060,
        
0x1945FDFD0x5BA33A3A0x3D68C2C20x59158D8D0xF321ECEC0xAE3166660xA23E6F6F0x82165757,
        
0x639510100x015BEFEF0x834DB8B80x2E9186860xD9B56D6D0x511F83830x9B53AAAA0x7C635D5D,
        
0xA63B68680xEB3FFEFE0xA5D630300xBE257A7A0x16A7ACAC0x0C0F09090xE335F0F00x6123A7A7,
        
0xC0F090900x8CAFE9E90x3A809D9D0xF5925C5C0x73810C0C0x2C2731310x2576D0D00x0BE75656,
        
0xBB7B92920x4EE9CECE0x89F101010x6B9F1E1E0x53A934340x6AC4F1F10xB499C3C30xF1975B5B,
        
0xE18347470xE66B18180xBDC822220x450E98980xE26E1F1F0xF4C9B3B30xB62F74740x66CBF8F8,
        
0xCCFF99990x95EA14140x03ED58580x56F7DCDC0xD4E18B8B0x1C1B15150x1EADA2A20xD70CD3D3,
        
0xFB2BE2E20xC31DC8C80x8E195E5E0xB5C22C2C0xE98949490xCF12C1C10xBF7E95950xBA207D7D,
        
0xEA6411110x77840B0B0x396DC5C50xAF6A89890x33D17C7C0xC9A171710x62CEFFFF0x7137BBBB,
        
0x81FB0F0F0x793DB5B50x0951E1E10xADDC3E3E0x242D3F3F0xCDA476760xF99D55550xD8EE8282,
        
0xE58640400xC5AE78780xB9CD25250x4D0496960x445577770x080A0E0E0x861350500xE730F7F7,
        
0xA1D337370x1D40FAFA0xAA3461610xED8C4E4E0x06B3B0B00x706C54540xB22A73730xD2523B3B,
        
0x410B9F9F0x7B8B02020xA088D8D80x114FF3F30x3167CBCB0xC24627270x27C067670x90B4FCFC,
        
0x202838380xF67F04040x607848480xFF2EE5E50x96074C4C0x5C4B65650xB1C72B2B0xAB6F8E8E,
        
0x9E0D42420x9CBBF5F50x52F2DBDB0x1BF34A4A0x5FA63D3D0x9359A4A40x0ABCB9B90xEF3AF9F9,
        
0x91EF13130x85FE08080x490191910xEE6116160x2D7CDEDE0x4FB221210x8F42B1B10x3BDB7272,
        
0x47B82F2F0x8748BFBF0x6D2CAEAE0x46E3C0C00xD6573C3C0x3E859A9A0x6929A9A90x647D4F4F,
        
0x2A9481810xCE492E2E0xCB17C6C60x2FCA69690xFCC3BDBD0x975CA3A30x055EE8E80x7AD0EDED,
        
0xAC87D1D10x7F8E05050xD5BA64640x1AA8A5A50x4BB726260x0EB9BEBE0xA76087870x5AF8D5D5,
        
0x282236360x14111B1B0x3FDE75750x2979D9D90x88AAEEEE0x3C332D2D0x4C5F79790x02B6B7B7,
        
0xB896CACA0xDA5835350xB09CC4C40x17FC43430x551A84840x1FF64D4D0x8A1C59590x7D38B2B2,
        
0x57AC33330xC718CFCF0x8DF406060x746953530xB7749B9B0xC4F597970x9F56ADAD0x72DAE3E3,
        
0x7ED5EAEA0x154AF4F40x229E8F8F0x12A2ABAB0x584E62620x07E85F5F0x99E51D1D0x34392323,
        
0x6EC1F6F60x50446C6C0xDE5D32320x687246460x6526A0A00xBC93CDCD0xDB03DADA0xF8C6BABA,
        
0xC8FA9E9E0xA882D6D60x2BCF6E6E0x405070700xDCEB85850xFE750A0A0x328A93930xA48DDFDF,
        
0xCA4C29290x10141C1C0x2173D7D70xF0CCB4B40xD309D4D40x5D108A8A0x0FE251510x00000000,
        
0x6F9A19190x9DE01A1A0x368F94940x42E6C7C70x4AECC9C90x5EFDD2D20xC1AB7F7F0xE0D8A8A8
    
);

    
/**
     * M-Table
     *
     * @var Array
     * @access private
     */
    
var $m2 = array (
        
0xBC75BC320xECF3EC210x20C620430xB3F4B3C90xDADBDA030x027B028B0xE2FBE22B0x9EC89EFA,
        
0xC94AC9EC0xD4D3D4090x18E6186B0x1E6B1E9F0x9845980E0xB27DB2380xA6E8A6D20x264B26B7,
        
0x3CD63C570x9332938A0x82D882EE0x52FD52980x7B377BD40xBB71BB370x5BF15B970x47E14783,
        
0x2430243C0x510F51E20xBAF8BAC60x4A1B4AF30xBF87BF480x0DFA0D700xB006B0B30x753F75DE,
        
0xD25ED2FD0x7DBA7D200x66AE66310x3A5B3AA30x598A591C0x000000000xCDBCCD930x1A9D1AE0,
        
0xAE6DAE2C0x7FC17FAB0x2BB12BC70xBE0EBEB90xE080E0A00x8A5D8A100x3BD23B520x64D564BA,
        
0xD8A0D8880xE784E7A50x5F075FE80x1B141B110x2CB52CC20xFC90FCB40x312C31270x80A38065,
        
0x73B2732A0x0C730C810x794C795F0x6B546B410x4B924B020x537453690x9436948F0x8351831F,
        
0x2A382A360xC4B0C49C0x22BD22C80xD55AD5F80xBDFCBDC30x486048780xFF62FFCE0x4C964C07,
        
0x416C41770xC742C7E60xEBF7EB240x1C101C140x5D7C5D630x362836220x672767C00xE98CE9AF,
        
0x441344F90x149514EA0xF59CF5BB0xCFC7CF180x3F243F2D0xC046C0E30x723B72DB0x5470546C,
        
0x29CA294C0xF0E3F0350x088508FE0xC6CBC6170xF311F34F0x8CD08CE40xA493A4590xCAB8CA96,
        
0x68A6683B0xB883B84D0x382038280xE5FFE52E0xAD9FAD560x0B770B840xC8C3C81D0x99CC99FF,
        
0x580358ED0x196F199A0x0E080E0A0x95BF957E0x704070500xF7E7F7300x6E2B6ECF0x1FE21F6E,
        
0xB579B53D0x090C090F0x61AA61340x578257160x9F419F0B0x9D3A9D800x11EA11640x25B925CD,
        
0xAFE4AFDD0x459A45080xDFA4DF8D0xA397A35C0xEA7EEAD50x35DA35580xED7AEDD00x431743FC,
        
0xF866F8CB0xFB94FBB10x37A137D30xFA1DFA400xC23DC2680xB4F0B4CC0x32DE325D0x9CB39C71,
        
0x560B56E70xE372E3DA0x87A787600x151C151B0xF9EFF93A0x63D163BF0x345334A90x9A3E9A85,
        
0xB18FB1420x7C337CD10x8826889B0x3D5F3DA60xA1ECA1D70xE476E4DF0x812A81940x91499101,
        
0x0F810FFB0xEE88EEAA0x16EE16610xD721D7730x97C497F50xA51AA5A80xFEEBFE3F0x6DD96DB5,
        
0x78C578AE0xC539C56D0x1D991DE50x76CD76A40x3EAD3EDC0xCB31CB670xB68BB6470xEF01EF5B,
        
0x1218121E0x602360C50x6ADD6AB00x4D1F4DF60xCE4ECEE90xDE2DDE7C0x55F9559D0x7E487E5A,
        
0x214F21B20x03F2037A0xA065A0260x5E8E5E190x5A785A660x655C654B0x6258624E0xFD19FD45,
        
0x068D06F40x40E540860xF298F2BE0x335733AC0x176717900x057F058E0xE805E85E0x4F644F7D,
        
0x89AF896A0x106310950x74B6742F0x0AFE0A750x5CF55C920x9BB79B740x2D3C2D330x30A530D6,
        
0x2ECE2E490x49E949890x466846720x774477550xA8E0A8D80x964D96040x284328BD0xA969A929,
        
0xD929D9790x862E86910xD1ACD1870xF415F44A0x8D598D150xD6A8D6820xB90AB9BC0x429E420D,
        
0xF66EF6C10x2F472FB80xDDDFDD060x233423390xCC35CC620xF16AF1C40xC1CFC1120x85DC85EB,
        
0x8F228F9E0x71C971A10x90C090F00xAA9BAA530x018901F10x8BD48BE10x4EED4E8C0x8EAB8E6F,
        
0xAB12ABA20x6FA26F3E0xE60DE6540xDB52DBF20x92BB927B0xB702B7B60x692F69CA0x39A939D9,
        
0xD3D7D30C0xA761A7230xA21EA2AD0xC3B4C3990x6C506C440x070407050x04F6047F0x27C22746,
        
0xAC16ACA70xD025D0760x508650130xDC56DCF70x8455841A0xE109E1510x7ABE7A250x139113EF
    
);

    
/**
     * M-Table
     *
     * @var Array
     * @access private
     */
    
var $m3 = array (
        
0xD939A9D90x901767900x719CB3710xD2A6E8D20x050704050x9852FD980x6580A3650xDFE476DF,
        
0x08459A080x024B92020xA0E080A00x665A78660xDDAFE4DD0xB06ADDB00xBF63D1BF0x362A3836,
        
0x54E60D540x4320C6430x62CC35620xBEF298BE0x1E12181E0x24EBF7240xD7A1ECD70x77416C77,
        
0xBD2843BD0x32BC75320xD47B37D40x9B88269B0x700DFA700xF94413F90xB1FB94B10x5A7E485A,
        
0x7A03F27A0xE48CD0E40x47B68B470x3C24303C0xA5E784A50x416B54410x06DDDF060xC56023C5,
        
0x45FD19450xA33A5BA30x68C23D680x158D59150x21ECF3210x3166AE310x3E6FA23E0x16578216,
        
0x951063950x5BEF015B0x4DB8834D0x91862E910xB56DD9B50x1F83511F0x53AA9B530x635D7C63,
        
0x3B68A63B0x3FFEEB3F0xD630A5D60x257ABE250xA7AC16A70x0F090C0F0x35F0E3350x23A76123,
        
0xF090C0F00xAFE98CAF0x809D3A800x925CF5920x810C73810x27312C270x76D025760xE7560BE7,
        
0x7B92BB7B0xE9CE4EE90xF10189F10x9F1E6B9F0xA93453A90xC4F16AC40x99C3B4990x975BF197,
        
0x8347E1830x6B18E66B0xC822BDC80x0E98450E0x6E1FE26E0xC9B3F4C90x2F74B62F0xCBF866CB,
        
0xFF99CCFF0xEA1495EA0xED5803ED0xF7DC56F70xE18BD4E10x1B151C1B0xADA21EAD0x0CD3D70C,
        
0x2BE2FB2B0x1DC8C31D0x195E8E190xC22CB5C20x8949E9890x12C1CF120x7E95BF7E0x207DBA20,
        
0x6411EA640x840B77840x6DC5396D0x6A89AF6A0xD17C33D10xA171C9A10xCEFF62CE0x37BB7137,
        
0xFB0F81FB0x3DB5793D0x51E109510xDC3EADDC0x2D3F242D0xA476CDA40x9D55F99D0xEE82D8EE,
        
0x8640E5860xAE78C5AE0xCD25B9CD0x04964D040x557744550x0A0E080A0x135086130x30F7E730,
        
0xD337A1D30x40FA1D400x3461AA340x8C4EED8C0xB3B006B30x6C54706C0x2A73B22A0x523BD252,
        
0x0B9F410B0x8B027B8B0x88D8A0880x4FF3114F0x67CB31670x4627C2460xC06727C00xB4FC90B4,
        
0x283820280x7F04F67F0x784860780x2EE5FF2E0x074C96070x4B655C4B0xC72BB1C70x6F8EAB6F,
        
0x0D429E0D0xBBF59CBB0xF2DB52F20xF34A1BF30xA63D5FA60x59A493590xBCB90ABC0x3AF9EF3A,
        
0xEF1391EF0xFE0885FE0x019149010x6116EE610x7CDE2D7C0xB2214FB20x42B18F420xDB723BDB,
        
0xB82F47B80x48BF87480x2CAE6D2C0xE3C046E30x573CD6570x859A3E850x29A969290x7D4F647D,
        
0x94812A940x492ECE490x17C6CB170xCA692FCA0xC3BDFCC30x5CA3975C0x5EE8055E0xD0ED7AD0,
        
0x87D1AC870x8E057F8E0xBA64D5BA0xA8A51AA80xB7264BB70xB9BE0EB90x6087A7600xF8D55AF8,
        
0x223628220x111B14110xDE753FDE0x79D929790xAAEE88AA0x332D3C330x5F794C5F0xB6B702B6,
        
0x96CAB8960x5835DA580x9CC4B09C0xFC4317FC0x1A84551A0xF64D1FF60x1C598A1C0x38B27D38,
        
0xAC3357AC0x18CFC7180xF4068DF40x695374690x749BB7740xF597C4F50x56AD9F560xDAE372DA,
        
0xD5EA7ED50x4AF4154A0x9E8F229E0xA2AB12A20x4E62584E0xE85F07E80xE51D99E50x39233439,
        
0xC1F66EC10x446C50440x5D32DE5D0x724668720x26A065260x93CDBC930x03DADB030xC6BAF8C6,
        
0xFA9EC8FA0x82D6A8820xCF6E2BCF0x507040500xEB85DCEB0x750AFE750x8A93328A0x8DDFA48D,
        
0x4C29CA4C0x141C10140x73D721730xCCB4F0CC0x09D4D3090x108A5D100xE2510FE20x00000000,
        
0x9A196F9A0xE01A9DE00x8F94368F0xE6C742E60xECC94AEC0xFDD25EFD0xAB7FC1AB0xD8A8E0D8
    
);

    
/**
     * The Key Schedule Array
     *
     * @var Array
     * @access private
     */
    
var $K = array();

    
/**
     * The Key depended S-Table 0
     *
     * @var Array
     * @access private
     */
    
var $S0 = array();

    
/**
     * The Key depended S-Table 1
     *
     * @var Array
     * @access private
     */
    
var $S1 = array();

    
/**
     * The Key depended S-Table 2
     *
     * @var Array
     * @access private
     */
    
var $S2 = array();

    
/**
     * The Key depended S-Table 3
     *
     * @var Array
     * @access private
     */
    
var $S3 = array();

    
/**
     * Holds the last used key
     *
     * @var Array
     * @access private
     */
    
var $kl;

    
/**
     * Sets the key.
     *
     * Keys can be of any length. Twofish, itself, requires the use of a key that's 128, 192 or 256-bits long.
     * If the key is less than 256-bits we round the length up to the closest valid key length,
     * padding $key with null bytes. If the key is more than 256-bits, we trim the excess bits.
     *
     * If the key is not explicitly set, it'll be assumed a 128 bits key to be all null bytes.
     *
     * @access public
     * @see Crypt_Base::setKey()
     * @param String $key
     */
    
function setKey($key)
    {
        
$keylength strlen($key);
        switch (
true) {
            case 
$keylength <= 16:
                
$key str_pad($key16"");
                break;
            case 
$keylength <= 24:
                
$key str_pad($key24"");
                break;
            case 
$keylength 32:
                
$key str_pad($key32"");
                break;
            case 
$keylength 32:
                
$key substr($key032);
        }
        
parent::setKey($key);
    }

    
/**
     * Setup the key (expansion)
     *
     * @see Crypt_Base::_setupKey()
     * @access private
     */
    
function _setupKey()
    {
        if (isset(
$this->kl['key']) && $this->key === $this->kl['key']) {
            
// already expanded
            
return;
        }
        
$this->kl = array('key' => $this->key);

        
/* Key expanding and generating the key-depended s-boxes */
        
$le_longs unpack('V*'$this->key);
        
$key unpack('C*'$this->key);
        
$m0 $this->m0;
        
$m1 $this->m1;
        
$m2 $this->m2;
        
$m3 $this->m3;
        
$q0 $this->q0;
        
$q1 $this->q1;

        
$K $S0 $S1 $S2 $S3 = array();

        switch (
strlen($this->key)) {
            case 
16:
                list (
$s7$s6$s5$s4) = $this->_mdsrem($le_longs[1], $le_longs[2]);
                list (
$s3$s2$s1$s0) = $this->_mdsrem($le_longs[3], $le_longs[4]);
                for (
$i 0$j 1$i 40$i+= 2,$j+= 2) {
                    
$A $m0[$q0[$q0[$i] ^ $key9]] ^ $key[1]] ^
                         
$m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^
                         
$m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^
                         
$m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]];
                    
$B $m0[$q0[$q0[$j] ^ $key[13]] ^ $key[5]] ^
                         
$m1[$q0[$q1[$j] ^ $key[14]] ^ $key[6]] ^
                         
$m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] ^
                         
$m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]];
                    
$B = ($B << 8) | ($B >> 24 0xff);
                    
$K[] = $A+= $B;
                    
$K[] = (($A+= $B) << $A >> 23 0x1ff);
                }
                for (
$i 0$i 256; ++$i) {
                    
$S0[$i] = $m0[$q0[$q0[$i] ^ $s4] ^ $s0];
                    
$S1[$i] = $m1[$q0[$q1[$i] ^ $s5] ^ $s1];
                    
$S2[$i] = $m2[$q1[$q0[$i] ^ $s6] ^ $s2];
                    
$S3[$i] = $m3[$q1[$q1[$i] ^ $s7] ^ $s3];
                }
                break;
            case 
24:
                list (
$sb$sa$s9$s8) = $this->_mdsrem($le_longs[1], $le_longs[2]);
                list (
$s7$s6$s5$s4) = $this->_mdsrem($le_longs[3], $le_longs[4]);
                list (
$s3$s2$s1$s0) = $this->_mdsrem($le_longs[5], $le_longs[6]);
                for (
$i 0$j 1$i 40$i+= 2$j+= 2) {
                    
$A $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key9]] ^ $key[1]] ^
                         
$m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^
                         
$m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^
                         
$m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]];
                    
$B $m0[$q0[$q0[$q1[$j] ^ $key[21]] ^ $key[13]] ^ $key[5]] ^
                         
$m1[$q0[$q1[$q1[$j] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^
                         
$m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^
                         
$m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]];
                    
$B = ($B << 8) | ($B >> 24 0xff);
                    
$K[] = $A+= $B;
                    
$K[] = (($A+= $B) << $A >> 23 0x1ff);
                }
                for (
$i 0$i 256; ++$i) {
                    
$S0[$i] = $m0[$q0[$q0[$q1[$i] ^ $s8] ^ $s4] ^ $s0];
                    
$S1[$i] = $m1[$q0[$q1[$q1[$i] ^ $s9] ^ $s5] ^ $s1];
                    
$S2[$i] = $m2[$q1[$q0[$q0[$i] ^ $sa] ^ $s6] ^ $s2];
                    
$S3[$i] = $m3[$q1[$q1[$q0[$i] ^ $sb] ^ $s7] ^ $s3];
                }
                break;
            default: 
// 32
                
list ($sf$se$sd$sc) = $this->_mdsrem($le_longs[1], $le_longs[2]);
                list (
$sb$sa$s9$s8) = $this->_mdsrem($le_longs[3], $le_longs[4]);
                list (
$s7$s6$s5$s4) = $this->_mdsrem($le_longs[5], $le_longs[6]);
                list (
$s3$s2$s1$s0) = $this->_mdsrem($le_longs[7], $le_longs[8]);
                for (
$i 0$j 1$i 40$i+= 2$j+= 2) {
                    
$A $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key9]] ^ $key[1]] ^
                         
$m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^
                         
$m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^
                         
$m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]];
                    
$B $m0[$q0[$q0[$q1[$q1[$j] ^ $key[29]] ^ $key[21]] ^ $key[13]] ^ $key[5]] ^
                         
$m1[$q0[$q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^
                         
$m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^
                         
$m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]];
                    
$B = ($B << 8) | ($B >> 24 0xff);
                    
$K[] = $A+= $B;
                    
$K[] = (($A+= $B) << $A >> 23 0x1ff);
                }
                for (
$i 0$i 256; ++$i) {
                    
$S0[$i] = $m0[$q0[$q0[$q1[$q1[$i] ^ $sc] ^ $s8] ^ $s4] ^ $s0];
                    
$S1[$i] = $m1[$q0[$q1[$q1[$q0[$i] ^ $sd] ^ $s9] ^ $s5] ^ $s1];
                    
$S2[$i] = $m2[$q1[$q0[$q0[$q0[$i] ^ $se] ^ $sa] ^ $s6] ^ $s2];
                    
$S3[$i] = $m3[$q1[$q1[$q0[$q1[$i] ^ $sf] ^ $sb] ^ $s7] ^ $s3];
                }
        }

        
$this->K  $K;
        
$this->S0 $S0;
        
$this->S1 $S1;
        
$this->S2 $S2;
        
$this->S3 $S3;
    }

    
/**
     * _mdsrem function using by the twofish cipher algorithm
     *
     * @access private
     * @param String $A
     * @param String $B
     * @return Array
     */
    
function _mdsrem($A$B)
    {
        
// No gain by unrolling this loop.
        
for ($i 0$i 8; ++$i) {
            
// Get most significant coefficient.
            
$t 0xff & ($B >> 24);

            
// Shift the others up.
            
$B = ($B << 8) | (0xff & ($A >> 24));
            
$A<<= 8;

            
$u $t << 1;

            
// Subtract the modular polynomial on overflow.
            
if ($t 0x80) {
                
$u^= 0x14d;
            }

            
// Remove t * (a * x^2 + 1).
            
$B ^= $t ^ ($u << 16);

            
// Form u = a*t + t/a = t*(a + 1/a).
            
$u^= 0x7fffffff & ($t >> 1);

            
// Add the modular polynomial on underflow.
            
if ($t 0x01) {
                
$u^= 0xa6 ;
            }

            
// Remove t * (a + 1/a) * (x^3 + x).
            
$B^= ($u << 24) | ($u << 8);
        }

        return array(
            
0xff $B >> 24,
            
0xff $B >> 16,
            
0xff $B >>  8,
            
0xff $B);
    }

    
/**
     * Encrypts a block
     *
     * @access private
     * @param String $in
     * @return String
     */
    
function _encryptBlock($in)
    {
        
$S0 $this->S0;
        
$S1 $this->S1;
        
$S2 $this->S2;
        
$S3 $this->S3;
        
$K  $this->K;

        
$in unpack("V4"$in);
        
$R0 $K[0] ^ $in[1];
        
$R1 $K[1] ^ $in[2];
        
$R2 $K[2] ^ $in[3];
        
$R3 $K[3] ^ $in[4];

        
$ki 7;
        while (
$ki 39) {
            
$t0 $S0$R0        0xff] ^
                  
$S1[($R0 >>  8) & 0xff] ^
                  
$S2[($R0 >> 16) & 0xff] ^
                  
$S3[($R0 >> 24) & 0xff];
            
$t1 $S0[($R1 >> 24) & 0xff] ^
                  
$S1$R1        0xff] ^
                  
$S2[($R1 >>  8) & 0xff] ^
                  
$S3[($R1 >> 16) & 0xff];
            
$R2^= $t0 $t1 $K[++$ki];
            
$R2 = ($R2 >> 0x7fffffff) | ($R2 << 31);
            
$R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ ($t0 + ($t1 << 1) + $K[++$ki]);

            
$t0 $S0$R2        0xff] ^
                  
$S1[($R2 >>  8) & 0xff] ^
                  
$S2[($R2 >> 16) & 0xff] ^
                  
$S3[($R2 >> 24) & 0xff];
            
$t1 $S0[($R3 >> 24) & 0xff] ^
                  
$S1$R3        0xff] ^
                  
$S2[($R3 >>  8) & 0xff] ^
                  
$S3[($R3 >> 16) & 0xff];
            
$R0^= ($t0 $t1 $K[++$ki]);
            
$R0 = ($R0 >> 0x7fffffff) | ($R0 << 31);
            
$R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + $K[++$ki]);
        }

        
// @codingStandardsIgnoreStart
        
return pack("V4"$K[4] ^ $R2,
                          
$K[5] ^ $R3,
                          
$K[6] ^ $R0,
                          
$K[7] ^ $R1);
        
// @codingStandardsIgnoreEnd
    
}

    
/**
     * Decrypts a block
     *
     * @access private
     * @param String $in
     * @return String
     */
    
function _decryptBlock($in)
    {
        
$S0 $this->S0;
        
$S1 $this->S1;
        
$S2 $this->S2;
        
$S3 $this->S3;
        
$K  $this->K;

        
$in unpack("V4"$in);
        
$R0 $K[4] ^ $in[1];
        
$R1 $K[5] ^ $in[2];
        
$R2 $K[6] ^ $in[3];
        
$R3 $K[7] ^ $in[4];

        
$ki 40;
        while (
$ki 8) {
            
$t0 $S0[$R0       0xff] ^
                  
$S1[$R0 >>  0xff] ^
                  
$S2[$R0 >> 16 0xff] ^
                  
$S3[$R0 >> 24 0xff];
            
$t1 $S0[$R1 >> 24 0xff] ^
                  
$S1[$R1       0xff] ^
                  
$S2[$R1 >>  0xff] ^
                  
$S3[$R1 >> 16 0xff];
            
$R3^= $t0 + ($t1 << 1) + $K[--$ki];
            
$R3 $R3 >> 0x7fffffff $R3 << 31;
            
$R2 = ($R2 >> 31 0x1 $R2 << 1) ^ ($t0 $t1 $K[--$ki]);

            
$t0 $S0[$R2       0xff] ^
                  
$S1[$R2 >>  0xff] ^
                  
$S2[$R2 >> 16 0xff] ^
                  
$S3[$R2 >> 24 0xff];
            
$t1 $S0[$R3 >> 24 0xff] ^
                  
$S1[$R3       0xff] ^
                  
$S2[$R3 >>  0xff] ^
                  
$S3[$R3 >> 16 0xff];
            
$R1^= $t0 + ($t1 << 1) + $K[--$ki];
            
$R1 $R1 >> 0x7fffffff $R1 << 31;
            
$R0 = ($R0 >> 31 0x1 $R0 << 1) ^ ($t0 $t1 $K[--$ki]);
        }

        
// @codingStandardsIgnoreStart
        
return pack("V4"$K[0] ^ $R2,
                          
$K[1] ^ $R3,
                          
$K[2] ^ $R0,
                          
$K[3] ^ $R1);
        
// @codingStandardsIgnoreEnd
    
}

    
/**
     * Setup the performance-optimized function for de/encrypt()
     *
     * @see Crypt_Base::_setupInlineCrypt()
     * @access private
     */
    
function _setupInlineCrypt()
    {
        
$lambda_functions =& Crypt_Twofish::_getLambdaFunctions();

        
// Max. 10 Ultra-Hi-optimized inline-crypt functions. After that, we'll (still) create very fast code, but not the ultimate fast one.
        // (Currently, for Crypt_Twofish, one generated $lambda_function cost on php5.5@32bit ~140kb unfreeable mem and ~240kb on php5.5@64bit)
        
$gen_hi_opt_code = (bool)( count($lambda_functions) < 10 );

        
// Generation of a uniqe hash for our generated code
        
$code_hash "Crypt_Twofish, {$this->mode}";
        if (
$gen_hi_opt_code) {
            
$code_hash str_pad($code_hash32) . $this->_hashInlineCryptFunction($this->key);
        }

        if (!isset(
$lambda_functions[$code_hash])) {
            switch (
true) {
                case 
$gen_hi_opt_code:
                    
$K $this->K;
                    
$init_crypt '
                        static $S0, $S1, $S2, $S3;
                        if (!$S0) {
                            for ($i = 0; $i < 256; ++$i) {
                                $S0[] = (int)$self->S0[$i];
                                $S1[] = (int)$self->S1[$i];
                                $S2[] = (int)$self->S2[$i];
                                $S3[] = (int)$self->S3[$i];
                            }
                        }
                    '
;
                    break;
                default:
                    
$K   = array();
                    for (
$i 0$i 40; ++$i) {
                        
$K[] = '$K_' $i;
                    }
                    
$init_crypt '
                        $S0 = $self->S0;
                        $S1 = $self->S1;
                        $S2 = $self->S2;
                        $S3 = $self->S3;
                        list(' 
implode(','$K) . ') = $self->K;
                    '
;
            }

            
// Generating encrypt code:
            
$encrypt_block '
                $in = unpack("V4", $in);
                $R0 = '
.$K[0].' ^ $in[1];
                $R1 = '
.$K[1].' ^ $in[2];
                $R2 = '
.$K[2].' ^ $in[3];
                $R3 = '
.$K[3].' ^ $in[4];
            '
;
            for (
$ki 7$i 0$i 8; ++$i) {
                
$encrypt_block.= '
                    $t0 = $S0[ $R0        & 0xff] ^
                          $S1[($R0 >>  8) & 0xff] ^
                          $S2[($R0 >> 16) & 0xff] ^
                          $S3[($R0 >> 24) & 0xff];
                    $t1 = $S0[($R1 >> 24) & 0xff] ^
                          $S1[ $R1        & 0xff] ^
                          $S2[($R1 >>  8) & 0xff] ^
                          $S3[($R1 >> 16) & 0xff];
                    $R2^= ($t0 + $t1 + '
.$K[++$ki].');
                    $R2 = ($R2 >> 1 & 0x7fffffff) | ($R2 << 31);
                    $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ ($t0 + ($t1 << 1) + '
.$K[++$ki].');

                    $t0 = $S0[ $R2        & 0xff] ^
                          $S1[($R2 >>  8) & 0xff] ^
                          $S2[($R2 >> 16) & 0xff] ^
                          $S3[($R2 >> 24) & 0xff];
                    $t1 = $S0[($R3 >> 24) & 0xff] ^
                          $S1[ $R3        & 0xff] ^
                          $S2[($R3 >>  8) & 0xff] ^
                          $S3[($R3 >> 16) & 0xff];
                    $R0^= ($t0 + $t1 + '
.$K[++$ki].');
                    $R0 = ($R0 >> 1 & 0x7fffffff) | ($R0 << 31);
                    $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + '
.$K[++$ki].');
                '
;
            }
            
$encrypt_block.= '
                $in = pack("V4", '
.$K[4].' ^ $R2,
                                 '
.$K[5].' ^ $R3,
                                 '
.$K[6].' ^ $R0,
                                 '
.$K[7].' ^ $R1);
            '
;

            
// Generating decrypt code:
            
$decrypt_block '
                $in = unpack("V4", $in);
                $R0 = '
.$K[4].' ^ $in[1];
                $R1 = '
.$K[5].' ^ $in[2];
                $R2 = '
.$K[6].' ^ $in[3];
                $R3 = '
.$K[7].' ^ $in[4];
            '
;
            for (
$ki 40$i 0$i 8; ++$i) {
                
$decrypt_block.= '
                    $t0 = $S0[$R0       & 0xff] ^
                          $S1[$R0 >>  8 & 0xff] ^
                          $S2[$R0 >> 16 & 0xff] ^
                          $S3[$R0 >> 24 & 0xff];
                    $t1 = $S0[$R1 >> 24 & 0xff] ^
                          $S1[$R1       & 0xff] ^
                          $S2[$R1 >>  8 & 0xff] ^
                          $S3[$R1 >> 16 & 0xff];
                    $R3^= $t0 + ($t1 << 1) + '
.$K[--$ki].';
                    $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31;
                    $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ($t0 + $t1 + '
.$K[--$ki].');

                    $t0 = $S0[$R2       & 0xff] ^
                          $S1[$R2 >>  8 & 0xff] ^
                          $S2[$R2 >> 16 & 0xff] ^
                          $S3[$R2 >> 24 & 0xff];
                    $t1 = $S0[$R3 >> 24 & 0xff] ^
                          $S1[$R3       & 0xff] ^
                          $S2[$R3 >>  8 & 0xff] ^
                          $S3[$R3 >> 16 & 0xff];
                    $R1^= $t0 + ($t1 << 1) + '
.$K[--$ki].';
                    $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31;
                    $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ($t0 + $t1 + '
.$K[--$ki].');
                '
;
            }
            
$decrypt_block.= '
                $in = pack("V4", '
.$K[0].' ^ $R2,
                                 '
.$K[1].' ^ $R3,
                                 '
.$K[2].' ^ $R0,
                                 '
.$K[3].' ^ $R1);
            '
;

            
$lambda_functions[$code_hash] = $this->_createInlineCryptFunction(
                array(
                   
'init_crypt'    => $init_crypt,
                   
'init_encrypt'  => '',
                   
'init_decrypt'  => '',
                   
'encrypt_block' => $encrypt_block,
                   
'decrypt_block' => $decrypt_block
                
)
            );
        }
        
$this->inline_crypt $lambda_functions[$code_hash];
    }
}
Онлайн: 0
Реклама