@@ -279,7 +279,7 @@ |
||
| 279 | 279 | function _forward_data($data) |
| 280 | 280 | { |
| 281 | 281 | if ($this->expected_bytes > 0) { |
| 282 | - $this->socket_buffer.= $data; |
|
| 282 | + $this->socket_buffer .= $data; |
|
| 283 | 283 | $this->expected_bytes -= strlen($data); |
| 284 | 284 | } else { |
| 285 | 285 | $agent_data_bytes = current(unpack('N', $data)); |
@@ -734,15 +734,15 @@ discard block |
||
| 734 | 734 | return false; |
| 735 | 735 | } |
| 736 | 736 | return "<RSAKeyValue>\r\n" . |
| 737 | - ' <Modulus>' . base64_encode($raw['modulus']) . "</Modulus>\r\n" . |
|
| 738 | - ' <Exponent>' . base64_encode($raw['publicExponent']) . "</Exponent>\r\n" . |
|
| 739 | - ' <P>' . base64_encode($raw['prime1']) . "</P>\r\n" . |
|
| 740 | - ' <Q>' . base64_encode($raw['prime2']) . "</Q>\r\n" . |
|
| 741 | - ' <DP>' . base64_encode($raw['exponent1']) . "</DP>\r\n" . |
|
| 742 | - ' <DQ>' . base64_encode($raw['exponent2']) . "</DQ>\r\n" . |
|
| 743 | - ' <InverseQ>' . base64_encode($raw['coefficient']) . "</InverseQ>\r\n" . |
|
| 744 | - ' <D>' . base64_encode($raw['privateExponent']) . "</D>\r\n" . |
|
| 745 | - '</RSAKeyValue>'; |
|
| 737 | + ' <Modulus>' . base64_encode($raw['modulus']) . "</Modulus>\r\n" . |
|
| 738 | + ' <Exponent>' . base64_encode($raw['publicExponent']) . "</Exponent>\r\n" . |
|
| 739 | + ' <P>' . base64_encode($raw['prime1']) . "</P>\r\n" . |
|
| 740 | + ' <Q>' . base64_encode($raw['prime2']) . "</Q>\r\n" . |
|
| 741 | + ' <DP>' . base64_encode($raw['exponent1']) . "</DP>\r\n" . |
|
| 742 | + ' <DQ>' . base64_encode($raw['exponent2']) . "</DQ>\r\n" . |
|
| 743 | + ' <InverseQ>' . base64_encode($raw['coefficient']) . "</InverseQ>\r\n" . |
|
| 744 | + ' <D>' . base64_encode($raw['privateExponent']) . "</D>\r\n" . |
|
| 745 | + '</RSAKeyValue>'; |
|
| 746 | 746 | break; |
| 747 | 747 | case self::PRIVATE_FORMAT_PUTTY: |
| 748 | 748 | if ($num_primes != 2) { |
@@ -897,12 +897,12 @@ discard block |
||
| 897 | 897 | $RSAPrivateKey = pack('Ca*a*', self::ASN1_SEQUENCE, $this->_encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey); |
| 898 | 898 | |
| 899 | 899 | $RSAPrivateKey = "-----BEGIN ENCRYPTED PRIVATE KEY-----\r\n" . |
| 900 | - chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
| 901 | - '-----END ENCRYPTED PRIVATE KEY-----'; |
|
| 900 | + chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
| 901 | + '-----END ENCRYPTED PRIVATE KEY-----'; |
|
| 902 | 902 | } else { |
| 903 | 903 | $RSAPrivateKey = "-----BEGIN PRIVATE KEY-----\r\n" . |
| 904 | - chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
| 905 | - '-----END PRIVATE KEY-----'; |
|
| 904 | + chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
| 905 | + '-----END PRIVATE KEY-----'; |
|
| 906 | 906 | } |
| 907 | 907 | return $RSAPrivateKey; |
| 908 | 908 | } |
@@ -916,15 +916,15 @@ discard block |
||
| 916 | 916 | $des->setIV($iv); |
| 917 | 917 | $iv = strtoupper(bin2hex($iv)); |
| 918 | 918 | $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . |
| 919 | - "Proc-Type: 4,ENCRYPTED\r\n" . |
|
| 920 | - "DEK-Info: DES-EDE3-CBC,$iv\r\n" . |
|
| 921 | - "\r\n" . |
|
| 922 | - chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64) . |
|
| 923 | - '-----END RSA PRIVATE KEY-----'; |
|
| 919 | + "Proc-Type: 4,ENCRYPTED\r\n" . |
|
| 920 | + "DEK-Info: DES-EDE3-CBC,$iv\r\n" . |
|
| 921 | + "\r\n" . |
|
| 922 | + chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64) . |
|
| 923 | + '-----END RSA PRIVATE KEY-----'; |
|
| 924 | 924 | } else { |
| 925 | 925 | $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . |
| 926 | - chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
| 927 | - '-----END RSA PRIVATE KEY-----'; |
|
| 926 | + chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
| 927 | + '-----END RSA PRIVATE KEY-----'; |
|
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | return $RSAPrivateKey; |
@@ -951,9 +951,9 @@ discard block |
||
| 951 | 951 | return array('e' => $e->copy(), 'n' => $n->copy()); |
| 952 | 952 | case self::PUBLIC_FORMAT_XML: |
| 953 | 953 | return "<RSAKeyValue>\r\n" . |
| 954 | - ' <Modulus>' . base64_encode($modulus) . "</Modulus>\r\n" . |
|
| 955 | - ' <Exponent>' . base64_encode($publicExponent) . "</Exponent>\r\n" . |
|
| 956 | - '</RSAKeyValue>'; |
|
| 954 | + ' <Modulus>' . base64_encode($modulus) . "</Modulus>\r\n" . |
|
| 955 | + ' <Exponent>' . base64_encode($publicExponent) . "</Exponent>\r\n" . |
|
| 956 | + '</RSAKeyValue>'; |
|
| 957 | 957 | break; |
| 958 | 958 | case self::PUBLIC_FORMAT_OPENSSH: |
| 959 | 959 | // from <http://tools.ietf.org/html/rfc4253#page-15>: |
@@ -1001,8 +1001,8 @@ discard block |
||
| 1001 | 1001 | ); |
| 1002 | 1002 | |
| 1003 | 1003 | $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . |
| 1004 | - chunk_split(base64_encode($RSAPublicKey), 64) . |
|
| 1005 | - '-----END PUBLIC KEY-----'; |
|
| 1004 | + chunk_split(base64_encode($RSAPublicKey), 64) . |
|
| 1005 | + '-----END PUBLIC KEY-----'; |
|
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | return $RSAPublicKey; |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | do { |
| 609 | 609 | for ($i = $i0; $i <= $num_primes; $i++) { |
| 610 | 610 | if ($timeout !== false) { |
| 611 | - $timeout-= time() - $start; |
|
| 611 | + $timeout -= time() - $start; |
|
| 612 | 612 | $start = time(); |
| 613 | 613 | if ($timeout <= 0) { |
| 614 | 614 | return array( |
@@ -750,8 +750,8 @@ discard block |
||
| 750 | 750 | } |
| 751 | 751 | $key = "PuTTY-User-Key-File-2: ssh-rsa\r\nEncryption: "; |
| 752 | 752 | $encryption = (!empty($this->password) || is_string($this->password)) ? 'aes256-cbc' : 'none'; |
| 753 | - $key.= $encryption; |
|
| 754 | - $key.= "\r\nComment: " . $this->comment . "\r\n"; |
|
| 753 | + $key .= $encryption; |
|
| 754 | + $key .= "\r\nComment: " . $this->comment . "\r\n"; |
|
| 755 | 755 | $public = pack( |
| 756 | 756 | 'Na*Na*Na*', |
| 757 | 757 | strlen('ssh-rsa'), |
@@ -773,8 +773,8 @@ discard block |
||
| 773 | 773 | $public |
| 774 | 774 | ); |
| 775 | 775 | $public = base64_encode($public); |
| 776 | - $key.= "Public-Lines: " . ((strlen($public) + 63) >> 6) . "\r\n"; |
|
| 777 | - $key.= chunk_split($public, 64); |
|
| 776 | + $key .= "Public-Lines: " . ((strlen($public) + 63) >> 6) . "\r\n"; |
|
| 777 | + $key .= chunk_split($public, 64); |
|
| 778 | 778 | $private = pack( |
| 779 | 779 | 'Na*Na*Na*Na*', |
| 780 | 780 | strlen($raw['privateExponent']), |
@@ -787,16 +787,16 @@ discard block |
||
| 787 | 787 | $raw['coefficient'] |
| 788 | 788 | ); |
| 789 | 789 | if (empty($this->password) && !is_string($this->password)) { |
| 790 | - $source.= pack('Na*', strlen($private), $private); |
|
| 790 | + $source .= pack('Na*', strlen($private), $private); |
|
| 791 | 791 | $hashkey = 'putty-private-key-file-mac-key'; |
| 792 | 792 | } else { |
| 793 | - $private.= Random::string(16 - (strlen($private) & 15)); |
|
| 794 | - $source.= pack('Na*', strlen($private), $private); |
|
| 793 | + $private .= Random::string(16 - (strlen($private) & 15)); |
|
| 794 | + $source .= pack('Na*', strlen($private), $private); |
|
| 795 | 795 | $sequence = 0; |
| 796 | 796 | $symkey = ''; |
| 797 | 797 | while (strlen($symkey) < 32) { |
| 798 | 798 | $temp = pack('Na*', $sequence++, $this->password); |
| 799 | - $symkey.= pack('H*', sha1($temp)); |
|
| 799 | + $symkey .= pack('H*', sha1($temp)); |
|
| 800 | 800 | } |
| 801 | 801 | $symkey = substr($symkey, 0, 32); |
| 802 | 802 | $crypto = new AES(); |
@@ -808,11 +808,11 @@ discard block |
||
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | $private = base64_encode($private); |
| 811 | - $key.= 'Private-Lines: ' . ((strlen($private) + 63) >> 6) . "\r\n"; |
|
| 812 | - $key.= chunk_split($private, 64); |
|
| 811 | + $key .= 'Private-Lines: ' . ((strlen($private) + 63) >> 6) . "\r\n"; |
|
| 812 | + $key .= chunk_split($private, 64); |
|
| 813 | 813 | $hash = new Hash('sha1'); |
| 814 | 814 | $hash->setKey(pack('H*', sha1($hashkey))); |
| 815 | - $key.= 'Private-MAC: ' . bin2hex($hash->hash($source)) . "\r\n"; |
|
| 815 | + $key .= 'Private-MAC: ' . bin2hex($hash->hash($source)) . "\r\n"; |
|
| 816 | 816 | |
| 817 | 817 | return $key; |
| 818 | 818 | default: // eg. self::PRIVATE_FORMAT_PKCS1 |
@@ -834,11 +834,11 @@ discard block |
||
| 834 | 834 | // coefficient INTEGER -- ti |
| 835 | 835 | // } |
| 836 | 836 | $OtherPrimeInfo = pack('Ca*a*', self::ASN1_INTEGER, $this->_encodeLength(strlen($primes[$i]->toBytes(true))), $primes[$i]->toBytes(true)); |
| 837 | - $OtherPrimeInfo.= pack('Ca*a*', self::ASN1_INTEGER, $this->_encodeLength(strlen($exponents[$i]->toBytes(true))), $exponents[$i]->toBytes(true)); |
|
| 838 | - $OtherPrimeInfo.= pack('Ca*a*', self::ASN1_INTEGER, $this->_encodeLength(strlen($coefficients[$i]->toBytes(true))), $coefficients[$i]->toBytes(true)); |
|
| 839 | - $OtherPrimeInfos.= pack('Ca*a*', self::ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfo)), $OtherPrimeInfo); |
|
| 837 | + $OtherPrimeInfo .= pack('Ca*a*', self::ASN1_INTEGER, $this->_encodeLength(strlen($exponents[$i]->toBytes(true))), $exponents[$i]->toBytes(true)); |
|
| 838 | + $OtherPrimeInfo .= pack('Ca*a*', self::ASN1_INTEGER, $this->_encodeLength(strlen($coefficients[$i]->toBytes(true))), $coefficients[$i]->toBytes(true)); |
|
| 839 | + $OtherPrimeInfos .= pack('Ca*a*', self::ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfo)), $OtherPrimeInfo); |
|
| 840 | 840 | } |
| 841 | - $RSAPrivateKey.= pack('Ca*a*', self::ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfos)), $OtherPrimeInfos); |
|
| 841 | + $RSAPrivateKey .= pack('Ca*a*', self::ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfos)), $OtherPrimeInfos); |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | $RSAPrivateKey = pack('Ca*a*', self::ASN1_SEQUENCE, $this->_encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey); |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | if (!empty($this->password) || is_string($this->password)) { |
| 911 | 911 | $iv = Random::string(8); |
| 912 | 912 | $symkey = pack('H*', md5($this->password . $iv)); // symkey is short for symmetric key |
| 913 | - $symkey.= substr(pack('H*', md5($symkey . $this->password . $iv)), 0, 8); |
|
| 913 | + $symkey .= substr(pack('H*', md5($symkey . $this->password . $iv)), 0, 8); |
|
| 914 | 914 | $des = new TripleDES(); |
| 915 | 915 | $des->setKey($symkey); |
| 916 | 916 | $des->setIV($iv); |
@@ -1079,7 +1079,7 @@ discard block |
||
| 1079 | 1079 | if (preg_match('#DEK-Info: (.+),(.+)#', $key, $matches)) { |
| 1080 | 1080 | $iv = pack('H*', trim($matches[2])); |
| 1081 | 1081 | $symkey = pack('H*', md5($this->password . substr($iv, 0, 8))); // symkey is short for symmetric key |
| 1082 | - $symkey.= pack('H*', md5($symkey . $this->password . substr($iv, 0, 8))); |
|
| 1082 | + $symkey .= pack('H*', md5($symkey . $this->password . substr($iv, 0, 8))); |
|
| 1083 | 1083 | // remove the Proc-Type / DEK-Info sections as they're no longer needed |
| 1084 | 1084 | $key = preg_replace('#^(?:Proc-Type|DEK-Info): .*#m', '', $key); |
| 1085 | 1085 | $ciphertext = $this->_extractBER($key); |
@@ -1360,7 +1360,7 @@ discard block |
||
| 1360 | 1360 | $sequence = 0; |
| 1361 | 1361 | while (strlen($symkey) < 32) { |
| 1362 | 1362 | $temp = pack('Na*', $sequence++, $this->password); |
| 1363 | - $symkey.= pack('H*', sha1($temp)); |
|
| 1363 | + $symkey .= pack('H*', sha1($temp)); |
|
| 1364 | 1364 | } |
| 1365 | 1365 | $symkey = substr($symkey, 0, 32); |
| 1366 | 1366 | $crypto = new AES(); |
@@ -1491,7 +1491,7 @@ discard block |
||
| 1491 | 1491 | if (!isset($this->current) || is_object($this->current)) { |
| 1492 | 1492 | return; |
| 1493 | 1493 | } |
| 1494 | - $this->current.= trim($data); |
|
| 1494 | + $this->current .= trim($data); |
|
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | 1497 | /** |
@@ -1896,7 +1896,7 @@ discard block |
||
| 1896 | 1896 | { |
| 1897 | 1897 | $length = ord($this->_string_shift($string)); |
| 1898 | 1898 | if ($length & 0x80) { // definite length, long form |
| 1899 | - $length&= 0x7F; |
|
| 1899 | + $length &= 0x7F; |
|
| 1900 | 1900 | $temp = $this->_string_shift($string, $length); |
| 1901 | 1901 | list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)); |
| 1902 | 1902 | } |
@@ -2289,7 +2289,7 @@ discard block |
||
| 2289 | 2289 | $count = ceil($maskLen / $this->mgfHLen); |
| 2290 | 2290 | for ($i = 0; $i < $count; $i++) { |
| 2291 | 2291 | $c = pack('N', $i); |
| 2292 | - $t.= $this->mgfHash->hash($mgfSeed . $c); |
|
| 2292 | + $t .= $this->mgfHash->hash($mgfSeed . $c); |
|
| 2293 | 2293 | } |
| 2294 | 2294 | |
| 2295 | 2295 | return substr($t, 0, $maskLen); |
@@ -2458,7 +2458,7 @@ discard block |
||
| 2458 | 2458 | while (strlen($ps) != $psLen) { |
| 2459 | 2459 | $temp = Random::string($psLen - strlen($ps)); |
| 2460 | 2460 | $temp = str_replace("\x00", '', $temp); |
| 2461 | - $ps.= $temp; |
|
| 2461 | + $ps .= $temp; |
|
| 2462 | 2462 | } |
| 2463 | 2463 | $type = 2; |
| 2464 | 2464 | // see the comments of _rsaes_pkcs1_v1_5_decrypt() to understand why this is being done |
@@ -2721,7 +2721,7 @@ discard block |
||
| 2721 | 2721 | case 'sha512': |
| 2722 | 2722 | $t = pack('H*', '3051300d060960864801650304020305000440'); |
| 2723 | 2723 | } |
| 2724 | - $t.= $h; |
|
| 2724 | + $t .= $h; |
|
| 2725 | 2725 | $tLen = strlen($t); |
| 2726 | 2726 | |
| 2727 | 2727 | if ($emLen < $tLen + 11) { |
@@ -2874,7 +2874,7 @@ discard block |
||
| 2874 | 2874 | $plaintext = str_split($plaintext, $this->k); |
| 2875 | 2875 | $ciphertext = ''; |
| 2876 | 2876 | foreach ($plaintext as $m) { |
| 2877 | - $ciphertext.= $this->_raw_encrypt($m); |
|
| 2877 | + $ciphertext .= $this->_raw_encrypt($m); |
|
| 2878 | 2878 | } |
| 2879 | 2879 | return $ciphertext; |
| 2880 | 2880 | case self::ENCRYPTION_PKCS1: |
@@ -2886,7 +2886,7 @@ discard block |
||
| 2886 | 2886 | $plaintext = str_split($plaintext, $length); |
| 2887 | 2887 | $ciphertext = ''; |
| 2888 | 2888 | foreach ($plaintext as $m) { |
| 2889 | - $ciphertext.= $this->_rsaes_pkcs1_v1_5_encrypt($m); |
|
| 2889 | + $ciphertext .= $this->_rsaes_pkcs1_v1_5_encrypt($m); |
|
| 2890 | 2890 | } |
| 2891 | 2891 | return $ciphertext; |
| 2892 | 2892 | //case self::ENCRYPTION_OAEP: |
@@ -2899,7 +2899,7 @@ discard block |
||
| 2899 | 2899 | $plaintext = str_split($plaintext, $length); |
| 2900 | 2900 | $ciphertext = ''; |
| 2901 | 2901 | foreach ($plaintext as $m) { |
| 2902 | - $ciphertext.= $this->_rsaes_oaep_encrypt($m); |
|
| 2902 | + $ciphertext .= $this->_rsaes_oaep_encrypt($m); |
|
| 2903 | 2903 | } |
| 2904 | 2904 | return $ciphertext; |
| 2905 | 2905 | } |
@@ -2942,7 +2942,7 @@ discard block |
||
| 2942 | 2942 | if ($temp === false) { |
| 2943 | 2943 | return false; |
| 2944 | 2944 | } |
| 2945 | - $plaintext.= $temp; |
|
| 2945 | + $plaintext .= $temp; |
|
| 2946 | 2946 | } |
| 2947 | 2947 | |
| 2948 | 2948 | return $plaintext; |
@@ -423,13 +423,13 @@ discard block |
||
| 423 | 423 | list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[3], $le_longs[4]); |
| 424 | 424 | for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
| 425 | 425 | $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^ |
| 426 | - $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ |
|
| 427 | - $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ |
|
| 428 | - $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]]; |
|
| 426 | + $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ |
|
| 427 | + $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ |
|
| 428 | + $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]]; |
|
| 429 | 429 | $B = $m0[$q0[$q0[$j] ^ $key[13]] ^ $key[5]] ^ |
| 430 | - $m1[$q0[$q1[$j] ^ $key[14]] ^ $key[6]] ^ |
|
| 431 | - $m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] ^ |
|
| 432 | - $m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]]; |
|
| 430 | + $m1[$q0[$q1[$j] ^ $key[14]] ^ $key[6]] ^ |
|
| 431 | + $m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] ^ |
|
| 432 | + $m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]]; |
|
| 433 | 433 | $B = ($B << 8) | ($B >> 24 & 0xff); |
| 434 | 434 | $K[] = $A+= $B; |
| 435 | 435 | $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
@@ -447,13 +447,13 @@ discard block |
||
| 447 | 447 | list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[5], $le_longs[6]); |
| 448 | 448 | for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
| 449 | 449 | $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
| 450 | - $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
|
| 451 | - $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
|
| 452 | - $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
|
| 450 | + $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
|
| 451 | + $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
|
| 452 | + $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
|
| 453 | 453 | $B = $m0[$q0[$q0[$q1[$j] ^ $key[21]] ^ $key[13]] ^ $key[5]] ^ |
| 454 | - $m1[$q0[$q1[$q1[$j] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ |
|
| 455 | - $m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
|
| 456 | - $m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
|
| 454 | + $m1[$q0[$q1[$q1[$j] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ |
|
| 455 | + $m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
|
| 456 | + $m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
|
| 457 | 457 | $B = ($B << 8) | ($B >> 24 & 0xff); |
| 458 | 458 | $K[] = $A+= $B; |
| 459 | 459 | $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
@@ -472,13 +472,13 @@ discard block |
||
| 472 | 472 | list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[7], $le_longs[8]); |
| 473 | 473 | for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
| 474 | 474 | $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
| 475 | - $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
|
| 476 | - $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
|
| 477 | - $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
|
| 475 | + $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
|
| 476 | + $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
|
| 477 | + $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
|
| 478 | 478 | $B = $m0[$q0[$q0[$q1[$q1[$j] ^ $key[29]] ^ $key[21]] ^ $key[13]] ^ $key[5]] ^ |
| 479 | - $m1[$q0[$q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ |
|
| 480 | - $m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
|
| 481 | - $m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
|
| 479 | + $m1[$q0[$q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ |
|
| 480 | + $m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
|
| 481 | + $m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
|
| 482 | 482 | $B = ($B << 8) | ($B >> 24 & 0xff); |
| 483 | 483 | $K[] = $A+= $B; |
| 484 | 484 | $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
@@ -570,25 +570,25 @@ discard block |
||
| 570 | 570 | $ki = 7; |
| 571 | 571 | while ($ki < 39) { |
| 572 | 572 | $t0 = $S0[ $R0 & 0xff] ^ |
| 573 | - $S1[($R0 >> 8) & 0xff] ^ |
|
| 574 | - $S2[($R0 >> 16) & 0xff] ^ |
|
| 575 | - $S3[($R0 >> 24) & 0xff]; |
|
| 573 | + $S1[($R0 >> 8) & 0xff] ^ |
|
| 574 | + $S2[($R0 >> 16) & 0xff] ^ |
|
| 575 | + $S3[($R0 >> 24) & 0xff]; |
|
| 576 | 576 | $t1 = $S0[($R1 >> 24) & 0xff] ^ |
| 577 | - $S1[ $R1 & 0xff] ^ |
|
| 578 | - $S2[($R1 >> 8) & 0xff] ^ |
|
| 579 | - $S3[($R1 >> 16) & 0xff]; |
|
| 577 | + $S1[ $R1 & 0xff] ^ |
|
| 578 | + $S2[($R1 >> 8) & 0xff] ^ |
|
| 579 | + $S3[($R1 >> 16) & 0xff]; |
|
| 580 | 580 | $R2^= $t0 + $t1 + $K[++$ki]; |
| 581 | 581 | $R2 = ($R2 >> 1 & 0x7fffffff) | ($R2 << 31); |
| 582 | 582 | $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ ($t0 + ($t1 << 1) + $K[++$ki]); |
| 583 | 583 | |
| 584 | 584 | $t0 = $S0[ $R2 & 0xff] ^ |
| 585 | - $S1[($R2 >> 8) & 0xff] ^ |
|
| 586 | - $S2[($R2 >> 16) & 0xff] ^ |
|
| 587 | - $S3[($R2 >> 24) & 0xff]; |
|
| 585 | + $S1[($R2 >> 8) & 0xff] ^ |
|
| 586 | + $S2[($R2 >> 16) & 0xff] ^ |
|
| 587 | + $S3[($R2 >> 24) & 0xff]; |
|
| 588 | 588 | $t1 = $S0[($R3 >> 24) & 0xff] ^ |
| 589 | - $S1[ $R3 & 0xff] ^ |
|
| 590 | - $S2[($R3 >> 8) & 0xff] ^ |
|
| 591 | - $S3[($R3 >> 16) & 0xff]; |
|
| 589 | + $S1[ $R3 & 0xff] ^ |
|
| 590 | + $S2[($R3 >> 8) & 0xff] ^ |
|
| 591 | + $S3[($R3 >> 16) & 0xff]; |
|
| 592 | 592 | $R0^= ($t0 + $t1 + $K[++$ki]); |
| 593 | 593 | $R0 = ($R0 >> 1 & 0x7fffffff) | ($R0 << 31); |
| 594 | 594 | $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + $K[++$ki]); |
@@ -596,9 +596,9 @@ discard block |
||
| 596 | 596 | |
| 597 | 597 | // @codingStandardsIgnoreStart |
| 598 | 598 | return pack("V4", $K[4] ^ $R2, |
| 599 | - $K[5] ^ $R3, |
|
| 600 | - $K[6] ^ $R0, |
|
| 601 | - $K[7] ^ $R1); |
|
| 599 | + $K[5] ^ $R3, |
|
| 600 | + $K[6] ^ $R0, |
|
| 601 | + $K[7] ^ $R1); |
|
| 602 | 602 | // @codingStandardsIgnoreEnd |
| 603 | 603 | } |
| 604 | 604 | |
@@ -626,25 +626,25 @@ discard block |
||
| 626 | 626 | $ki = 40; |
| 627 | 627 | while ($ki > 8) { |
| 628 | 628 | $t0 = $S0[$R0 & 0xff] ^ |
| 629 | - $S1[$R0 >> 8 & 0xff] ^ |
|
| 630 | - $S2[$R0 >> 16 & 0xff] ^ |
|
| 631 | - $S3[$R0 >> 24 & 0xff]; |
|
| 629 | + $S1[$R0 >> 8 & 0xff] ^ |
|
| 630 | + $S2[$R0 >> 16 & 0xff] ^ |
|
| 631 | + $S3[$R0 >> 24 & 0xff]; |
|
| 632 | 632 | $t1 = $S0[$R1 >> 24 & 0xff] ^ |
| 633 | - $S1[$R1 & 0xff] ^ |
|
| 634 | - $S2[$R1 >> 8 & 0xff] ^ |
|
| 635 | - $S3[$R1 >> 16 & 0xff]; |
|
| 633 | + $S1[$R1 & 0xff] ^ |
|
| 634 | + $S2[$R1 >> 8 & 0xff] ^ |
|
| 635 | + $S3[$R1 >> 16 & 0xff]; |
|
| 636 | 636 | $R3^= $t0 + ($t1 << 1) + $K[--$ki]; |
| 637 | 637 | $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31; |
| 638 | 638 | $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ($t0 + $t1 + $K[--$ki]); |
| 639 | 639 | |
| 640 | 640 | $t0 = $S0[$R2 & 0xff] ^ |
| 641 | - $S1[$R2 >> 8 & 0xff] ^ |
|
| 642 | - $S2[$R2 >> 16 & 0xff] ^ |
|
| 643 | - $S3[$R2 >> 24 & 0xff]; |
|
| 641 | + $S1[$R2 >> 8 & 0xff] ^ |
|
| 642 | + $S2[$R2 >> 16 & 0xff] ^ |
|
| 643 | + $S3[$R2 >> 24 & 0xff]; |
|
| 644 | 644 | $t1 = $S0[$R3 >> 24 & 0xff] ^ |
| 645 | - $S1[$R3 & 0xff] ^ |
|
| 646 | - $S2[$R3 >> 8 & 0xff] ^ |
|
| 647 | - $S3[$R3 >> 16 & 0xff]; |
|
| 645 | + $S1[$R3 & 0xff] ^ |
|
| 646 | + $S2[$R3 >> 8 & 0xff] ^ |
|
| 647 | + $S3[$R3 >> 16 & 0xff]; |
|
| 648 | 648 | $R1^= $t0 + ($t1 << 1) + $K[--$ki]; |
| 649 | 649 | $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31; |
| 650 | 650 | $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ($t0 + $t1 + $K[--$ki]); |
@@ -652,9 +652,9 @@ discard block |
||
| 652 | 652 | |
| 653 | 653 | // @codingStandardsIgnoreStart |
| 654 | 654 | return pack("V4", $K[0] ^ $R2, |
| 655 | - $K[1] ^ $R3, |
|
| 656 | - $K[2] ^ $R0, |
|
| 657 | - $K[3] ^ $R1); |
|
| 655 | + $K[1] ^ $R3, |
|
| 656 | + $K[2] ^ $R0, |
|
| 657 | + $K[3] ^ $R1); |
|
| 658 | 658 | // @codingStandardsIgnoreEnd |
| 659 | 659 | } |
| 660 | 660 | |
@@ -794,11 +794,11 @@ discard block |
||
| 794 | 794 | |
| 795 | 795 | $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( |
| 796 | 796 | array( |
| 797 | - 'init_crypt' => $init_crypt, |
|
| 798 | - 'init_encrypt' => '', |
|
| 799 | - 'init_decrypt' => '', |
|
| 800 | - 'encrypt_block' => $encrypt_block, |
|
| 801 | - 'decrypt_block' => $decrypt_block |
|
| 797 | + 'init_crypt' => $init_crypt, |
|
| 798 | + 'init_encrypt' => '', |
|
| 799 | + 'init_decrypt' => '', |
|
| 800 | + 'encrypt_block' => $encrypt_block, |
|
| 801 | + 'decrypt_block' => $decrypt_block |
|
| 802 | 802 | ) |
| 803 | 803 | ); |
| 804 | 804 | } |
@@ -421,8 +421,8 @@ discard block |
||
| 421 | 421 | case 16: |
| 422 | 422 | list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[1], $le_longs[2]); |
| 423 | 423 | list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[3], $le_longs[4]); |
| 424 | - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
|
| 425 | - $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^ |
|
| 424 | + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { |
|
| 425 | + $A = $m0[$q0[$q0[$i] ^ $key[9]] ^ $key[1]] ^ |
|
| 426 | 426 | $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ |
| 427 | 427 | $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ |
| 428 | 428 | $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]]; |
@@ -431,8 +431,8 @@ discard block |
||
| 431 | 431 | $m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] ^ |
| 432 | 432 | $m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]]; |
| 433 | 433 | $B = ($B << 8) | ($B >> 24 & 0xff); |
| 434 | - $K[] = $A+= $B; |
|
| 435 | - $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
|
| 434 | + $K[] = $A += $B; |
|
| 435 | + $K[] = (($A += $B) << 9 | $A >> 23 & 0x1ff); |
|
| 436 | 436 | } |
| 437 | 437 | for ($i = 0; $i < 256; ++$i) { |
| 438 | 438 | $S0[$i] = $m0[$q0[$q0[$i] ^ $s4] ^ $s0]; |
@@ -445,8 +445,8 @@ discard block |
||
| 445 | 445 | list($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[1], $le_longs[2]); |
| 446 | 446 | list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[3], $le_longs[4]); |
| 447 | 447 | list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[5], $le_longs[6]); |
| 448 | - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
|
| 449 | - $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
|
| 448 | + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { |
|
| 449 | + $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[9]] ^ $key[1]] ^ |
|
| 450 | 450 | $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
| 451 | 451 | $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
| 452 | 452 | $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
@@ -455,8 +455,8 @@ discard block |
||
| 455 | 455 | $m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
| 456 | 456 | $m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
| 457 | 457 | $B = ($B << 8) | ($B >> 24 & 0xff); |
| 458 | - $K[] = $A+= $B; |
|
| 459 | - $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
|
| 458 | + $K[] = $A += $B; |
|
| 459 | + $K[] = (($A += $B) << 9 | $A >> 23 & 0x1ff); |
|
| 460 | 460 | } |
| 461 | 461 | for ($i = 0; $i < 256; ++$i) { |
| 462 | 462 | $S0[$i] = $m0[$q0[$q0[$q1[$i] ^ $s8] ^ $s4] ^ $s0]; |
@@ -470,8 +470,8 @@ discard block |
||
| 470 | 470 | list($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[3], $le_longs[4]); |
| 471 | 471 | list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[5], $le_longs[6]); |
| 472 | 472 | list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[7], $le_longs[8]); |
| 473 | - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
|
| 474 | - $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
|
| 473 | + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { |
|
| 474 | + $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[9]] ^ $key[1]] ^ |
|
| 475 | 475 | $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
| 476 | 476 | $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
| 477 | 477 | $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
@@ -480,8 +480,8 @@ discard block |
||
| 480 | 480 | $m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
| 481 | 481 | $m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
| 482 | 482 | $B = ($B << 8) | ($B >> 24 & 0xff); |
| 483 | - $K[] = $A+= $B; |
|
| 484 | - $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
|
| 483 | + $K[] = $A += $B; |
|
| 484 | + $K[] = (($A += $B) << 9 | $A >> 23 & 0x1ff); |
|
| 485 | 485 | } |
| 486 | 486 | for ($i = 0; $i < 256; ++$i) { |
| 487 | 487 | $S0[$i] = $m0[$q0[$q0[$q1[$q1[$i] ^ $sc] ^ $s8] ^ $s4] ^ $s0]; |
@@ -515,34 +515,34 @@ discard block |
||
| 515 | 515 | |
| 516 | 516 | // Shift the others up. |
| 517 | 517 | $B = ($B << 8) | (0xff & ($A >> 24)); |
| 518 | - $A<<= 8; |
|
| 518 | + $A <<= 8; |
|
| 519 | 519 | |
| 520 | 520 | $u = $t << 1; |
| 521 | 521 | |
| 522 | 522 | // Subtract the modular polynomial on overflow. |
| 523 | 523 | if ($t & 0x80) { |
| 524 | - $u^= 0x14d; |
|
| 524 | + $u ^= 0x14d; |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | // Remove t * (a * x^2 + 1). |
| 528 | 528 | $B ^= $t ^ ($u << 16); |
| 529 | 529 | |
| 530 | 530 | // Form u = a*t + t/a = t*(a + 1/a). |
| 531 | - $u^= 0x7fffffff & ($t >> 1); |
|
| 531 | + $u ^= 0x7fffffff & ($t >> 1); |
|
| 532 | 532 | |
| 533 | 533 | // Add the modular polynomial on underflow. |
| 534 | 534 | if ($t & 0x01) { |
| 535 | - $u^= 0xa6 ; |
|
| 535 | + $u ^= 0xa6; |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | // Remove t * (a + 1/a) * (x^3 + x). |
| 539 | - $B^= ($u << 24) | ($u << 8); |
|
| 539 | + $B ^= ($u << 24) | ($u << 8); |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | return array( |
| 543 | 543 | 0xff & $B >> 24, |
| 544 | 544 | 0xff & $B >> 16, |
| 545 | - 0xff & $B >> 8, |
|
| 545 | + 0xff & $B >> 8, |
|
| 546 | 546 | 0xff & $B); |
| 547 | 547 | } |
| 548 | 548 | |
@@ -569,27 +569,27 @@ discard block |
||
| 569 | 569 | |
| 570 | 570 | $ki = 7; |
| 571 | 571 | while ($ki < 39) { |
| 572 | - $t0 = $S0[ $R0 & 0xff] ^ |
|
| 573 | - $S1[($R0 >> 8) & 0xff] ^ |
|
| 572 | + $t0 = $S0[$R0 & 0xff] ^ |
|
| 573 | + $S1[($R0 >> 8) & 0xff] ^ |
|
| 574 | 574 | $S2[($R0 >> 16) & 0xff] ^ |
| 575 | 575 | $S3[($R0 >> 24) & 0xff]; |
| 576 | 576 | $t1 = $S0[($R1 >> 24) & 0xff] ^ |
| 577 | - $S1[ $R1 & 0xff] ^ |
|
| 578 | - $S2[($R1 >> 8) & 0xff] ^ |
|
| 577 | + $S1[$R1 & 0xff] ^ |
|
| 578 | + $S2[($R1 >> 8) & 0xff] ^ |
|
| 579 | 579 | $S3[($R1 >> 16) & 0xff]; |
| 580 | - $R2^= $t0 + $t1 + $K[++$ki]; |
|
| 580 | + $R2 ^= $t0 + $t1 + $K[++$ki]; |
|
| 581 | 581 | $R2 = ($R2 >> 1 & 0x7fffffff) | ($R2 << 31); |
| 582 | 582 | $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ ($t0 + ($t1 << 1) + $K[++$ki]); |
| 583 | 583 | |
| 584 | - $t0 = $S0[ $R2 & 0xff] ^ |
|
| 585 | - $S1[($R2 >> 8) & 0xff] ^ |
|
| 584 | + $t0 = $S0[$R2 & 0xff] ^ |
|
| 585 | + $S1[($R2 >> 8) & 0xff] ^ |
|
| 586 | 586 | $S2[($R2 >> 16) & 0xff] ^ |
| 587 | 587 | $S3[($R2 >> 24) & 0xff]; |
| 588 | 588 | $t1 = $S0[($R3 >> 24) & 0xff] ^ |
| 589 | - $S1[ $R3 & 0xff] ^ |
|
| 590 | - $S2[($R3 >> 8) & 0xff] ^ |
|
| 589 | + $S1[$R3 & 0xff] ^ |
|
| 590 | + $S2[($R3 >> 8) & 0xff] ^ |
|
| 591 | 591 | $S3[($R3 >> 16) & 0xff]; |
| 592 | - $R0^= ($t0 + $t1 + $K[++$ki]); |
|
| 592 | + $R0 ^= ($t0 + $t1 + $K[++$ki]); |
|
| 593 | 593 | $R0 = ($R0 >> 1 & 0x7fffffff) | ($R0 << 31); |
| 594 | 594 | $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + $K[++$ki]); |
| 595 | 595 | } |
@@ -625,27 +625,27 @@ discard block |
||
| 625 | 625 | |
| 626 | 626 | $ki = 40; |
| 627 | 627 | while ($ki > 8) { |
| 628 | - $t0 = $S0[$R0 & 0xff] ^ |
|
| 629 | - $S1[$R0 >> 8 & 0xff] ^ |
|
| 628 | + $t0 = $S0[$R0 & 0xff] ^ |
|
| 629 | + $S1[$R0 >> 8 & 0xff] ^ |
|
| 630 | 630 | $S2[$R0 >> 16 & 0xff] ^ |
| 631 | 631 | $S3[$R0 >> 24 & 0xff]; |
| 632 | 632 | $t1 = $S0[$R1 >> 24 & 0xff] ^ |
| 633 | - $S1[$R1 & 0xff] ^ |
|
| 634 | - $S2[$R1 >> 8 & 0xff] ^ |
|
| 633 | + $S1[$R1 & 0xff] ^ |
|
| 634 | + $S2[$R1 >> 8 & 0xff] ^ |
|
| 635 | 635 | $S3[$R1 >> 16 & 0xff]; |
| 636 | - $R3^= $t0 + ($t1 << 1) + $K[--$ki]; |
|
| 636 | + $R3 ^= $t0 + ($t1 << 1) + $K[--$ki]; |
|
| 637 | 637 | $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31; |
| 638 | 638 | $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ($t0 + $t1 + $K[--$ki]); |
| 639 | 639 | |
| 640 | - $t0 = $S0[$R2 & 0xff] ^ |
|
| 641 | - $S1[$R2 >> 8 & 0xff] ^ |
|
| 640 | + $t0 = $S0[$R2 & 0xff] ^ |
|
| 641 | + $S1[$R2 >> 8 & 0xff] ^ |
|
| 642 | 642 | $S2[$R2 >> 16 & 0xff] ^ |
| 643 | 643 | $S3[$R2 >> 24 & 0xff]; |
| 644 | 644 | $t1 = $S0[$R3 >> 24 & 0xff] ^ |
| 645 | - $S1[$R3 & 0xff] ^ |
|
| 646 | - $S2[$R3 >> 8 & 0xff] ^ |
|
| 645 | + $S1[$R3 & 0xff] ^ |
|
| 646 | + $S2[$R3 >> 8 & 0xff] ^ |
|
| 647 | 647 | $S3[$R3 >> 16 & 0xff]; |
| 648 | - $R1^= $t0 + ($t1 << 1) + $K[--$ki]; |
|
| 648 | + $R1 ^= $t0 + ($t1 << 1) + $K[--$ki]; |
|
| 649 | 649 | $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31; |
| 650 | 650 | $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ($t0 + $t1 + $K[--$ki]); |
| 651 | 651 | } |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | */ |
| 667 | 667 | function _setupInlineCrypt() |
| 668 | 668 | { |
| 669 | - $lambda_functions =& self::_getLambdaFunctions(); |
|
| 669 | + $lambda_functions = & self::_getLambdaFunctions(); |
|
| 670 | 670 | |
| 671 | 671 | // Max. 10 Ultra-Hi-optimized inline-crypt functions. After that, we'll (still) create very fast code, but not the ultimate fast one. |
| 672 | 672 | // (Currently, for Crypt_Twofish, one generated $lambda_function cost on php5.5@32bit ~140kb unfreeable mem and ~240kb on php5.5@64bit) |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | '; |
| 696 | 696 | break; |
| 697 | 697 | default: |
| 698 | - $K = array(); |
|
| 698 | + $K = array(); |
|
| 699 | 699 | for ($i = 0; $i < 40; ++$i) { |
| 700 | 700 | $K[] = '$K_' . $i; |
| 701 | 701 | } |
@@ -711,13 +711,13 @@ discard block |
||
| 711 | 711 | // Generating encrypt code: |
| 712 | 712 | $encrypt_block = ' |
| 713 | 713 | $in = unpack("V4", $in); |
| 714 | - $R0 = '.$K[0].' ^ $in[1]; |
|
| 715 | - $R1 = '.$K[1].' ^ $in[2]; |
|
| 716 | - $R2 = '.$K[2].' ^ $in[3]; |
|
| 717 | - $R3 = '.$K[3].' ^ $in[4]; |
|
| 714 | + $R0 = '.$K[0] . ' ^ $in[1]; |
|
| 715 | + $R1 = '.$K[1] . ' ^ $in[2]; |
|
| 716 | + $R2 = '.$K[2] . ' ^ $in[3]; |
|
| 717 | + $R3 = '.$K[3] . ' ^ $in[4]; |
|
| 718 | 718 | '; |
| 719 | 719 | for ($ki = 7, $i = 0; $i < 8; ++$i) { |
| 720 | - $encrypt_block.= ' |
|
| 720 | + $encrypt_block .= ' |
|
| 721 | 721 | $t0 = $S0[ $R0 & 0xff] ^ |
| 722 | 722 | $S1[($R0 >> 8) & 0xff] ^ |
| 723 | 723 | $S2[($R0 >> 16) & 0xff] ^ |
@@ -726,9 +726,9 @@ discard block |
||
| 726 | 726 | $S1[ $R1 & 0xff] ^ |
| 727 | 727 | $S2[($R1 >> 8) & 0xff] ^ |
| 728 | 728 | $S3[($R1 >> 16) & 0xff]; |
| 729 | - $R2^= ($t0 + $t1 + '.$K[++$ki].'); |
|
| 729 | + $R2^= ($t0 + $t1 + '.$K[++$ki] . '); |
|
| 730 | 730 | $R2 = ($R2 >> 1 & 0x7fffffff) | ($R2 << 31); |
| 731 | - $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ ($t0 + ($t1 << 1) + '.$K[++$ki].'); |
|
| 731 | + $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ ($t0 + ($t1 << 1) + '.$K[++$ki] . '); |
|
| 732 | 732 | |
| 733 | 733 | $t0 = $S0[ $R2 & 0xff] ^ |
| 734 | 734 | $S1[($R2 >> 8) & 0xff] ^ |
@@ -738,28 +738,28 @@ discard block |
||
| 738 | 738 | $S1[ $R3 & 0xff] ^ |
| 739 | 739 | $S2[($R3 >> 8) & 0xff] ^ |
| 740 | 740 | $S3[($R3 >> 16) & 0xff]; |
| 741 | - $R0^= ($t0 + $t1 + '.$K[++$ki].'); |
|
| 741 | + $R0^= ($t0 + $t1 + '.$K[++$ki] . '); |
|
| 742 | 742 | $R0 = ($R0 >> 1 & 0x7fffffff) | ($R0 << 31); |
| 743 | - $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + '.$K[++$ki].'); |
|
| 743 | + $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + '.$K[++$ki] . '); |
|
| 744 | 744 | '; |
| 745 | 745 | } |
| 746 | - $encrypt_block.= ' |
|
| 747 | - $in = pack("V4", '.$K[4].' ^ $R2, |
|
| 748 | - '.$K[5].' ^ $R3, |
|
| 749 | - '.$K[6].' ^ $R0, |
|
| 750 | - '.$K[7].' ^ $R1); |
|
| 746 | + $encrypt_block .= ' |
|
| 747 | + $in = pack("V4", '.$K[4] . ' ^ $R2, |
|
| 748 | + '.$K[5] . ' ^ $R3, |
|
| 749 | + '.$K[6] . ' ^ $R0, |
|
| 750 | + '.$K[7] . ' ^ $R1); |
|
| 751 | 751 | '; |
| 752 | 752 | |
| 753 | 753 | // Generating decrypt code: |
| 754 | 754 | $decrypt_block = ' |
| 755 | 755 | $in = unpack("V4", $in); |
| 756 | - $R0 = '.$K[4].' ^ $in[1]; |
|
| 757 | - $R1 = '.$K[5].' ^ $in[2]; |
|
| 758 | - $R2 = '.$K[6].' ^ $in[3]; |
|
| 759 | - $R3 = '.$K[7].' ^ $in[4]; |
|
| 756 | + $R0 = '.$K[4] . ' ^ $in[1]; |
|
| 757 | + $R1 = '.$K[5] . ' ^ $in[2]; |
|
| 758 | + $R2 = '.$K[6] . ' ^ $in[3]; |
|
| 759 | + $R3 = '.$K[7] . ' ^ $in[4]; |
|
| 760 | 760 | '; |
| 761 | 761 | for ($ki = 40, $i = 0; $i < 8; ++$i) { |
| 762 | - $decrypt_block.= ' |
|
| 762 | + $decrypt_block .= ' |
|
| 763 | 763 | $t0 = $S0[$R0 & 0xff] ^ |
| 764 | 764 | $S1[$R0 >> 8 & 0xff] ^ |
| 765 | 765 | $S2[$R0 >> 16 & 0xff] ^ |
@@ -768,9 +768,9 @@ discard block |
||
| 768 | 768 | $S1[$R1 & 0xff] ^ |
| 769 | 769 | $S2[$R1 >> 8 & 0xff] ^ |
| 770 | 770 | $S3[$R1 >> 16 & 0xff]; |
| 771 | - $R3^= $t0 + ($t1 << 1) + '.$K[--$ki].'; |
|
| 771 | + $R3^= $t0 + ($t1 << 1) + '.$K[--$ki] . '; |
|
| 772 | 772 | $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31; |
| 773 | - $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ($t0 + $t1 + '.$K[--$ki].'); |
|
| 773 | + $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ($t0 + $t1 + '.$K[--$ki] . '); |
|
| 774 | 774 | |
| 775 | 775 | $t0 = $S0[$R2 & 0xff] ^ |
| 776 | 776 | $S1[$R2 >> 8 & 0xff] ^ |
@@ -780,16 +780,16 @@ discard block |
||
| 780 | 780 | $S1[$R3 & 0xff] ^ |
| 781 | 781 | $S2[$R3 >> 8 & 0xff] ^ |
| 782 | 782 | $S3[$R3 >> 16 & 0xff]; |
| 783 | - $R1^= $t0 + ($t1 << 1) + '.$K[--$ki].'; |
|
| 783 | + $R1^= $t0 + ($t1 << 1) + '.$K[--$ki] . '; |
|
| 784 | 784 | $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31; |
| 785 | - $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ($t0 + $t1 + '.$K[--$ki].'); |
|
| 785 | + $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ($t0 + $t1 + '.$K[--$ki] . '); |
|
| 786 | 786 | '; |
| 787 | 787 | } |
| 788 | - $decrypt_block.= ' |
|
| 789 | - $in = pack("V4", '.$K[0].' ^ $R2, |
|
| 790 | - '.$K[1].' ^ $R3, |
|
| 791 | - '.$K[2].' ^ $R0, |
|
| 792 | - '.$K[3].' ^ $R1); |
|
| 788 | + $decrypt_block .= ' |
|
| 789 | + $in = pack("V4", '.$K[0] . ' ^ $R2, |
|
| 790 | + '.$K[1] . ' ^ $R3, |
|
| 791 | + '.$K[2] . ' ^ $R0, |
|
| 792 | + '.$K[3] . ' ^ $R1); |
|
| 793 | 793 | '; |
| 794 | 794 | |
| 795 | 795 | $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( |
@@ -708,13 +708,13 @@ discard block |
||
| 708 | 708 | $t = unpack('Nl/Nr', $block); |
| 709 | 709 | list($l, $r) = array($t['l'], $t['r']); |
| 710 | 710 | $block = ($shuffleip[ $r & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
| 711 | - ($shuffleip[($r >> 8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
| 712 | - ($shuffleip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
| 713 | - ($shuffleip[($r >> 24) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
| 714 | - ($shuffleip[ $l & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
| 715 | - ($shuffleip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
| 716 | - ($shuffleip[($l >> 16) & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
| 717 | - ($shuffleip[($l >> 24) & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
| 711 | + ($shuffleip[($r >> 8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
| 712 | + ($shuffleip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
| 713 | + ($shuffleip[($r >> 24) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
| 714 | + ($shuffleip[ $l & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
| 715 | + ($shuffleip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
| 716 | + ($shuffleip[($l >> 16) & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
| 717 | + ($shuffleip[($l >> 24) & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
| 718 | 718 | |
| 719 | 719 | // Extract L0 and R0. |
| 720 | 720 | $t = unpack('Nl/Nr', $block); |
@@ -731,9 +731,9 @@ discard block |
||
| 731 | 731 | |
| 732 | 732 | // S-box indexing. |
| 733 | 733 | $t = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ |
| 734 | - $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
|
| 735 | - $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
|
| 736 | - $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ $l; |
|
| 734 | + $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
|
| 735 | + $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
|
| 736 | + $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ $l; |
|
| 737 | 737 | // end of "the Feistel (F) function" |
| 738 | 738 | |
| 739 | 739 | $l = $r; |
@@ -748,13 +748,13 @@ discard block |
||
| 748 | 748 | |
| 749 | 749 | // Perform the inverse IP permutation. |
| 750 | 750 | return ($shuffleinvip[($r >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
| 751 | - ($shuffleinvip[($l >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
| 752 | - ($shuffleinvip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
| 753 | - ($shuffleinvip[($l >> 16) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
| 754 | - ($shuffleinvip[($r >> 8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
| 755 | - ($shuffleinvip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
| 756 | - ($shuffleinvip[ $r & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
| 757 | - ($shuffleinvip[ $l & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
| 751 | + ($shuffleinvip[($l >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
| 752 | + ($shuffleinvip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
| 753 | + ($shuffleinvip[($l >> 16) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
| 754 | + ($shuffleinvip[($r >> 8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
| 755 | + ($shuffleinvip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
| 756 | + ($shuffleinvip[ $r & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
| 757 | + ($shuffleinvip[ $l & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | /** |
@@ -1229,13 +1229,13 @@ discard block |
||
| 1229 | 1229 | $t = unpack('Nl/Nr', $key); |
| 1230 | 1230 | list($l, $r) = array($t['l'], $t['r']); |
| 1231 | 1231 | $key = ($this->shuffle[$pc1map[ $r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") | |
| 1232 | - ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | |
|
| 1233 | - ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | |
|
| 1234 | - ($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") | |
|
| 1235 | - ($this->shuffle[$pc1map[ $l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | |
|
| 1236 | - ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | |
|
| 1237 | - ($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") | |
|
| 1238 | - ($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00"); |
|
| 1232 | + ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | |
|
| 1233 | + ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | |
|
| 1234 | + ($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") | |
|
| 1235 | + ($this->shuffle[$pc1map[ $l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | |
|
| 1236 | + ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | |
|
| 1237 | + ($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") | |
|
| 1238 | + ($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00"); |
|
| 1239 | 1239 | $key = unpack('Nc/Nd', $key); |
| 1240 | 1240 | $c = ( $key['c'] >> 4) & 0x0FFFFFFF; |
| 1241 | 1241 | $d = (($key['d'] >> 4) & 0x0FFFFFF0) | ($key['c'] & 0x0F); |
@@ -1252,9 +1252,9 @@ discard block |
||
| 1252 | 1252 | |
| 1253 | 1253 | // Perform the PC-2 transformation. |
| 1254 | 1254 | $cp = $pc2mapc1[ $c >> 24 ] | $pc2mapc2[($c >> 16) & 0xFF] | |
| 1255 | - $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[ $c & 0xFF]; |
|
| 1255 | + $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[ $c & 0xFF]; |
|
| 1256 | 1256 | $dp = $pc2mapd1[ $d >> 24 ] | $pc2mapd2[($d >> 16) & 0xFF] | |
| 1257 | - $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[ $d & 0xFF]; |
|
| 1257 | + $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[ $d & 0xFF]; |
|
| 1258 | 1258 | |
| 1259 | 1259 | // Reorder: odd bytes/even bytes. Push the result in key schedule. |
| 1260 | 1260 | $val1 = ( $cp & 0xFF000000) | (($cp << 8) & 0x00FF0000) | |
@@ -1439,11 +1439,11 @@ discard block |
||
| 1439 | 1439 | // Creates the inline-crypt function |
| 1440 | 1440 | $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( |
| 1441 | 1441 | array( |
| 1442 | - 'init_crypt' => $init_crypt, |
|
| 1443 | - 'init_encrypt' => $init_encrypt, |
|
| 1444 | - 'init_decrypt' => $init_decrypt, |
|
| 1445 | - 'encrypt_block' => $crypt_block[self::ENCRYPT], |
|
| 1446 | - 'decrypt_block' => $crypt_block[self::DECRYPT] |
|
| 1442 | + 'init_crypt' => $init_crypt, |
|
| 1443 | + 'init_encrypt' => $init_encrypt, |
|
| 1444 | + 'init_decrypt' => $init_decrypt, |
|
| 1445 | + 'encrypt_block' => $crypt_block[self::ENCRYPT], |
|
| 1446 | + 'decrypt_block' => $crypt_block[self::DECRYPT] |
|
| 1447 | 1447 | ) |
| 1448 | 1448 | ); |
| 1449 | 1449 | } |
@@ -696,8 +696,8 @@ discard block |
||
| 696 | 696 | $sbox8 = array_map("intval", $this->sbox8); |
| 697 | 697 | /* Merge $shuffle with $[inv]ipmap */ |
| 698 | 698 | for ($i = 0; $i < 256; ++$i) { |
| 699 | - $shuffleip[] = $this->shuffle[$this->ipmap[$i]]; |
|
| 700 | - $shuffleinvip[] = $this->shuffle[$this->invipmap[$i]]; |
|
| 699 | + $shuffleip[] = $this->shuffle[$this->ipmap[$i]]; |
|
| 700 | + $shuffleinvip[] = $this->shuffle[$this->invipmap[$i]]; |
|
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | 703 | |
@@ -707,12 +707,12 @@ discard block |
||
| 707 | 707 | // Do the initial IP permutation. |
| 708 | 708 | $t = unpack('Nl/Nr', $block); |
| 709 | 709 | list($l, $r) = array($t['l'], $t['r']); |
| 710 | - $block = ($shuffleip[ $r & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
|
| 711 | - ($shuffleip[($r >> 8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
| 710 | + $block = ($shuffleip[$r & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
|
| 711 | + ($shuffleip[($r >> 8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
| 712 | 712 | ($shuffleip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
| 713 | 713 | ($shuffleip[($r >> 24) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
| 714 | - ($shuffleip[ $l & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
| 715 | - ($shuffleip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
| 714 | + ($shuffleip[$l & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
| 715 | + ($shuffleip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
| 716 | 716 | ($shuffleip[($l >> 16) & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
| 717 | 717 | ($shuffleip[($l >> 24) & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
| 718 | 718 | |
@@ -726,14 +726,14 @@ discard block |
||
| 726 | 726 | // start of "the Feistel (F) function" - see the following URL: |
| 727 | 727 | // http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png |
| 728 | 728 | // Merge key schedule. |
| 729 | - $b1 = (($r >> 3) & 0x1FFFFFFF) ^ ($r << 29) ^ $keys[++$ki]; |
|
| 730 | - $b2 = (($r >> 31) & 0x00000001) ^ ($r << 1) ^ $keys[++$ki]; |
|
| 729 | + $b1 = (($r >> 3) & 0x1FFFFFFF) ^ ($r << 29) ^ $keys[++$ki]; |
|
| 730 | + $b2 = (($r >> 31) & 0x00000001) ^ ($r << 1) ^ $keys[++$ki]; |
|
| 731 | 731 | |
| 732 | 732 | // S-box indexing. |
| 733 | 733 | $t = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ |
| 734 | 734 | $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
| 735 | - $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
|
| 736 | - $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ $l; |
|
| 735 | + $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
|
| 736 | + $sbox7[$b1 & 0x3F] ^ $sbox8[$b2 & 0x3F] ^ $l; |
|
| 737 | 737 | // end of "the Feistel (F) function" |
| 738 | 738 | |
| 739 | 739 | $l = $r; |
@@ -751,10 +751,10 @@ discard block |
||
| 751 | 751 | ($shuffleinvip[($l >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
| 752 | 752 | ($shuffleinvip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
| 753 | 753 | ($shuffleinvip[($l >> 16) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
| 754 | - ($shuffleinvip[($r >> 8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
| 755 | - ($shuffleinvip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
| 756 | - ($shuffleinvip[ $r & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
| 757 | - ($shuffleinvip[ $l & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
| 754 | + ($shuffleinvip[($r >> 8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
| 755 | + ($shuffleinvip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
| 756 | + ($shuffleinvip[$r & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
| 757 | + ($shuffleinvip[$l & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | /** |
@@ -1228,43 +1228,43 @@ discard block |
||
| 1228 | 1228 | // Perform the PC/1 transformation and compute C and D. |
| 1229 | 1229 | $t = unpack('Nl/Nr', $key); |
| 1230 | 1230 | list($l, $r) = array($t['l'], $t['r']); |
| 1231 | - $key = ($this->shuffle[$pc1map[ $r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") | |
|
| 1232 | - ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | |
|
| 1231 | + $key = ($this->shuffle[$pc1map[$r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") | |
|
| 1232 | + ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | |
|
| 1233 | 1233 | ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | |
| 1234 | 1234 | ($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") | |
| 1235 | - ($this->shuffle[$pc1map[ $l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | |
|
| 1236 | - ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | |
|
| 1235 | + ($this->shuffle[$pc1map[$l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | |
|
| 1236 | + ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | |
|
| 1237 | 1237 | ($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") | |
| 1238 | 1238 | ($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00"); |
| 1239 | 1239 | $key = unpack('Nc/Nd', $key); |
| 1240 | - $c = ( $key['c'] >> 4) & 0x0FFFFFFF; |
|
| 1240 | + $c = ($key['c'] >> 4) & 0x0FFFFFFF; |
|
| 1241 | 1241 | $d = (($key['d'] >> 4) & 0x0FFFFFF0) | ($key['c'] & 0x0F); |
| 1242 | 1242 | |
| 1243 | 1243 | $keys[$des_round] = array( |
| 1244 | 1244 | self::ENCRYPT => array(), |
| 1245 | 1245 | self::DECRYPT => array_fill(0, 32, 0) |
| 1246 | 1246 | ); |
| 1247 | - for ($i = 0, $ki = 31; $i < 16; ++$i, $ki-= 2) { |
|
| 1247 | + for ($i = 0, $ki = 31; $i < 16; ++$i, $ki -= 2) { |
|
| 1248 | 1248 | $c <<= $shifts[$i]; |
| 1249 | 1249 | $c = ($c | ($c >> 28)) & 0x0FFFFFFF; |
| 1250 | 1250 | $d <<= $shifts[$i]; |
| 1251 | 1251 | $d = ($d | ($d >> 28)) & 0x0FFFFFFF; |
| 1252 | 1252 | |
| 1253 | 1253 | // Perform the PC-2 transformation. |
| 1254 | - $cp = $pc2mapc1[ $c >> 24 ] | $pc2mapc2[($c >> 16) & 0xFF] | |
|
| 1255 | - $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[ $c & 0xFF]; |
|
| 1256 | - $dp = $pc2mapd1[ $d >> 24 ] | $pc2mapd2[($d >> 16) & 0xFF] | |
|
| 1257 | - $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[ $d & 0xFF]; |
|
| 1254 | + $cp = $pc2mapc1[$c >> 24] | $pc2mapc2[($c >> 16) & 0xFF] | |
|
| 1255 | + $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[$c & 0xFF]; |
|
| 1256 | + $dp = $pc2mapd1[$d >> 24] | $pc2mapd2[($d >> 16) & 0xFF] | |
|
| 1257 | + $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[$d & 0xFF]; |
|
| 1258 | 1258 | |
| 1259 | 1259 | // Reorder: odd bytes/even bytes. Push the result in key schedule. |
| 1260 | - $val1 = ( $cp & 0xFF000000) | (($cp << 8) & 0x00FF0000) | |
|
| 1261 | - (($dp >> 16) & 0x0000FF00) | (($dp >> 8) & 0x000000FF); |
|
| 1262 | - $val2 = (($cp << 8) & 0xFF000000) | (($cp << 16) & 0x00FF0000) | |
|
| 1263 | - (($dp >> 8) & 0x0000FF00) | ( $dp & 0x000000FF); |
|
| 1264 | - $keys[$des_round][self::ENCRYPT][ ] = $val1; |
|
| 1260 | + $val1 = ($cp & 0xFF000000) | (($cp << 8) & 0x00FF0000) | |
|
| 1261 | + (($dp >> 16) & 0x0000FF00) | (($dp >> 8) & 0x000000FF); |
|
| 1262 | + $val2 = (($cp << 8) & 0xFF000000) | (($cp << 16) & 0x00FF0000) | |
|
| 1263 | + (($dp >> 8) & 0x0000FF00) | ($dp & 0x000000FF); |
|
| 1264 | + $keys[$des_round][self::ENCRYPT][] = $val1; |
|
| 1265 | 1265 | $keys[$des_round][self::DECRYPT][$ki - 1] = $val1; |
| 1266 | - $keys[$des_round][self::ENCRYPT][ ] = $val2; |
|
| 1267 | - $keys[$des_round][self::DECRYPT][$ki ] = $val2; |
|
| 1266 | + $keys[$des_round][self::ENCRYPT][] = $val2; |
|
| 1267 | + $keys[$des_round][self::DECRYPT][$ki] = $val2; |
|
| 1268 | 1268 | } |
| 1269 | 1269 | } |
| 1270 | 1270 | |
@@ -1300,7 +1300,7 @@ discard block |
||
| 1300 | 1300 | */ |
| 1301 | 1301 | function _setupInlineCrypt() |
| 1302 | 1302 | { |
| 1303 | - $lambda_functions =& self::_getLambdaFunctions(); |
|
| 1303 | + $lambda_functions = & self::_getLambdaFunctions(); |
|
| 1304 | 1304 | |
| 1305 | 1305 | // Engine configuration for: |
| 1306 | 1306 | // - DES ($des_rounds == 1) or |
@@ -1311,7 +1311,7 @@ discard block |
||
| 1311 | 1311 | // (Currently, for Crypt_DES, one generated $lambda_function cost on php5.5@32bit ~135kb unfreeable mem and ~230kb on php5.5@64bit) |
| 1312 | 1312 | // (Currently, for Crypt_TripleDES, one generated $lambda_function cost on php5.5@32bit ~240kb unfreeable mem and ~340kb on php5.5@64bit) |
| 1313 | 1313 | // After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one |
| 1314 | - $gen_hi_opt_code = (bool)( count($lambda_functions) < 10 ); |
|
| 1314 | + $gen_hi_opt_code = (bool)(count($lambda_functions) < 10); |
|
| 1315 | 1315 | |
| 1316 | 1316 | // Generation of a uniqe hash for our generated code |
| 1317 | 1317 | $code_hash = "Crypt_DES, $des_rounds, {$this->mode}"; |
@@ -1406,7 +1406,7 @@ discard block |
||
| 1406 | 1406 | // start of "the Feistel (F) function" - see the following URL: |
| 1407 | 1407 | // http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png |
| 1408 | 1408 | // Merge key schedule. |
| 1409 | - $crypt_block[$c].= ' |
|
| 1409 | + $crypt_block[$c] .= ' |
|
| 1410 | 1410 | $b1 = ((' . $r . ' >> 3) & 0x1FFFFFFF) ^ (' . $r . ' << 29) ^ ' . $k[$c][++$ki] . '; |
| 1411 | 1411 | $b2 = ((' . $r . ' >> 31) & 0x00000001) ^ (' . $r . ' << 1) ^ ' . $k[$c][++$ki] . ';' . |
| 1412 | 1412 | /* S-box indexing. */ |
@@ -1424,7 +1424,7 @@ discard block |
||
| 1424 | 1424 | } |
| 1425 | 1425 | |
| 1426 | 1426 | // Perform the inverse IP permutation. |
| 1427 | - $crypt_block[$c].= '$in = |
|
| 1427 | + $crypt_block[$c] .= '$in = |
|
| 1428 | 1428 | ($shuffleinvip[($l >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
| 1429 | 1429 | ($shuffleinvip[($r >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
| 1430 | 1430 | ($shuffleinvip[($l >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
@@ -185,8 +185,7 @@ |
||
| 185 | 185 | function hash($text) |
| 186 | 186 | { |
| 187 | 187 | $output = !empty($this->key) || is_string($this->key) ? |
| 188 | - hash_hmac($this->hash, $text, $this->key, true) : |
|
| 189 | - hash($this->hash, $text, true); |
|
| 188 | + hash_hmac($this->hash, $text, $this->key, true) : hash($this->hash, $text, true); |
|
| 190 | 189 | |
| 191 | 190 | return strlen($output) > $this->length |
| 192 | 191 | ? substr($output, 0, $this->length) |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | // subWord |
| 404 | 404 | for ($i = 0; $i < $Nb; ++$i) { |
| 405 | 405 | $state[$i] = $sbox[$state[$i] & 0x000000FF] | |
| 406 | - ($sbox[$state[$i] >> 8 & 0x000000FF] << 8) | |
|
| 407 | - ($sbox[$state[$i] >> 16 & 0x000000FF] << 16) | |
|
| 408 | - ($sbox[$state[$i] >> 24 & 0x000000FF] << 24); |
|
| 406 | + ($sbox[$state[$i] >> 8 & 0x000000FF] << 8) | |
|
| 407 | + ($sbox[$state[$i] >> 16 & 0x000000FF] << 16) | |
|
| 408 | + ($sbox[$state[$i] >> 24 & 0x000000FF] << 24); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // shiftRows + addRoundKey |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | ($state[$j] & 0x00FF0000) ^ |
| 419 | 419 | ($state[$k] & 0x0000FF00) ^ |
| 420 | 420 | ($state[$l] & 0x000000FF) ^ |
| 421 | - $w[$i]; |
|
| 421 | + $w[$i]; |
|
| 422 | 422 | ++$i; |
| 423 | 423 | $j = ($j + 1) % $Nb; |
| 424 | 424 | $k = ($k + 1) % $Nb; |
@@ -506,9 +506,9 @@ discard block |
||
| 506 | 506 | ($state[$l] & 0x000000FF); |
| 507 | 507 | |
| 508 | 508 | $temp[$i] = $dw[$i] ^ ($isbox[$word & 0x000000FF] | |
| 509 | - ($isbox[$word >> 8 & 0x000000FF] << 8) | |
|
| 510 | - ($isbox[$word >> 16 & 0x000000FF] << 16) | |
|
| 511 | - ($isbox[$word >> 24 & 0x000000FF] << 24)); |
|
| 509 | + ($isbox[$word >> 8 & 0x000000FF] << 8) | |
|
| 510 | + ($isbox[$word >> 16 & 0x000000FF] << 16) | |
|
| 511 | + ($isbox[$word >> 24 & 0x000000FF] << 24)); |
|
| 512 | 512 | ++$i; |
| 513 | 513 | $j = ($j + 1) % $Nb; |
| 514 | 514 | $k = ($k + 1) % $Nb; |
@@ -658,9 +658,9 @@ discard block |
||
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | return $sbox[$word & 0x000000FF] | |
| 661 | - ($sbox[$word >> 8 & 0x000000FF] << 8) | |
|
| 662 | - ($sbox[$word >> 16 & 0x000000FF] << 16) | |
|
| 663 | - ($sbox[$word >> 24 & 0x000000FF] << 24); |
|
| 661 | + ($sbox[$word >> 8 & 0x000000FF] << 8) | |
|
| 662 | + ($sbox[$word >> 16 & 0x000000FF] << 16) | |
|
| 663 | + ($sbox[$word >> 24 & 0x000000FF] << 24); |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | /** |
@@ -999,11 +999,11 @@ discard block |
||
| 999 | 999 | |
| 1000 | 1000 | $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( |
| 1001 | 1001 | array( |
| 1002 | - 'init_crypt' => '', |
|
| 1003 | - 'init_encrypt' => $init_encrypt, |
|
| 1004 | - 'init_decrypt' => $init_decrypt, |
|
| 1005 | - 'encrypt_block' => $encrypt_block, |
|
| 1006 | - 'decrypt_block' => $decrypt_block |
|
| 1002 | + 'init_crypt' => '', |
|
| 1003 | + 'init_encrypt' => $init_encrypt, |
|
| 1004 | + 'init_decrypt' => $init_decrypt, |
|
| 1005 | + 'encrypt_block' => $encrypt_block, |
|
| 1006 | + 'decrypt_block' => $decrypt_block |
|
| 1007 | 1007 | ) |
| 1008 | 1008 | ); |
| 1009 | 1009 | } |
@@ -389,8 +389,8 @@ discard block |
||
| 389 | 389 | while ($i < $Nb) { |
| 390 | 390 | $temp[$i] = $t0[$state[$i] >> 24 & 0x000000FF] ^ |
| 391 | 391 | $t1[$state[$j] >> 16 & 0x000000FF] ^ |
| 392 | - $t2[$state[$k] >> 8 & 0x000000FF] ^ |
|
| 393 | - $t3[$state[$l] & 0x000000FF] ^ |
|
| 392 | + $t2[$state[$k] >> 8 & 0x000000FF] ^ |
|
| 393 | + $t3[$state[$l] & 0x000000FF] ^ |
|
| 394 | 394 | $w[++$wc]; |
| 395 | 395 | ++$i; |
| 396 | 396 | $j = ($j + 1) % $Nb; |
@@ -402,8 +402,8 @@ discard block |
||
| 402 | 402 | |
| 403 | 403 | // subWord |
| 404 | 404 | for ($i = 0; $i < $Nb; ++$i) { |
| 405 | - $state[$i] = $sbox[$state[$i] & 0x000000FF] | |
|
| 406 | - ($sbox[$state[$i] >> 8 & 0x000000FF] << 8) | |
|
| 405 | + $state[$i] = $sbox[$state[$i] & 0x000000FF] | |
|
| 406 | + ($sbox[$state[$i] >> 8 & 0x000000FF] << 8) | |
|
| 407 | 407 | ($sbox[$state[$i] >> 16 & 0x000000FF] << 16) | |
| 408 | 408 | ($sbox[$state[$i] >> 24 & 0x000000FF] << 24); |
| 409 | 409 | } |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | while ($i < $Nb) { |
| 483 | 483 | $temp[$i] = $dt0[$state[$i] >> 24 & 0x000000FF] ^ |
| 484 | 484 | $dt1[$state[$j] >> 16 & 0x000000FF] ^ |
| 485 | - $dt2[$state[$k] >> 8 & 0x000000FF] ^ |
|
| 486 | - $dt3[$state[$l] & 0x000000FF] ^ |
|
| 485 | + $dt2[$state[$k] >> 8 & 0x000000FF] ^ |
|
| 486 | + $dt3[$state[$l] & 0x000000FF] ^ |
|
| 487 | 487 | $dw[++$wc]; |
| 488 | 488 | ++$i; |
| 489 | 489 | $j = ($j + 1) % $Nb; |
@@ -505,8 +505,8 @@ discard block |
||
| 505 | 505 | ($state[$k] & 0x0000FF00) | |
| 506 | 506 | ($state[$l] & 0x000000FF); |
| 507 | 507 | |
| 508 | - $temp[$i] = $dw[$i] ^ ($isbox[$word & 0x000000FF] | |
|
| 509 | - ($isbox[$word >> 8 & 0x000000FF] << 8) | |
|
| 508 | + $temp[$i] = $dw[$i] ^ ($isbox[$word & 0x000000FF] | |
|
| 509 | + ($isbox[$word >> 8 & 0x000000FF] << 8) | |
|
| 510 | 510 | ($isbox[$word >> 16 & 0x000000FF] << 16) | |
| 511 | 511 | ($isbox[$word >> 24 & 0x000000FF] << 24)); |
| 512 | 512 | ++$i; |
@@ -615,8 +615,8 @@ discard block |
||
| 615 | 615 | $dw = $this->_subWord($this->w[$row][$j]); |
| 616 | 616 | $temp[$j] = $dt0[$dw >> 24 & 0x000000FF] ^ |
| 617 | 617 | $dt1[$dw >> 16 & 0x000000FF] ^ |
| 618 | - $dt2[$dw >> 8 & 0x000000FF] ^ |
|
| 619 | - $dt3[$dw & 0x000000FF]; |
|
| 618 | + $dt2[$dw >> 8 & 0x000000FF] ^ |
|
| 619 | + $dt3[$dw & 0x000000FF]; |
|
| 620 | 620 | $j++; |
| 621 | 621 | } |
| 622 | 622 | $this->dw[$row] = $temp; |
@@ -654,11 +654,11 @@ discard block |
||
| 654 | 654 | { |
| 655 | 655 | static $sbox; |
| 656 | 656 | if (empty($sbox)) { |
| 657 | - list(, , , , $sbox) = $this->_getTables(); |
|
| 657 | + list(,,,, $sbox) = $this->_getTables(); |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | - return $sbox[$word & 0x000000FF] | |
|
| 661 | - ($sbox[$word >> 8 & 0x000000FF] << 8) | |
|
| 660 | + return $sbox[$word & 0x000000FF] | |
|
| 661 | + ($sbox[$word >> 8 & 0x000000FF] << 8) | |
|
| 662 | 662 | ($sbox[$word >> 16 & 0x000000FF] << 16) | |
| 663 | 663 | ($sbox[$word >> 24 & 0x000000FF] << 24); |
| 664 | 664 | } |
@@ -717,9 +717,9 @@ discard block |
||
| 717 | 717 | )); |
| 718 | 718 | |
| 719 | 719 | foreach ($t3 as $t3i) { |
| 720 | - $t0[] = (($t3i << 24) & 0xFF000000) | (($t3i >> 8) & 0x00FFFFFF); |
|
| 720 | + $t0[] = (($t3i << 24) & 0xFF000000) | (($t3i >> 8) & 0x00FFFFFF); |
|
| 721 | 721 | $t1[] = (($t3i << 16) & 0xFFFF0000) | (($t3i >> 16) & 0x0000FFFF); |
| 722 | - $t2[] = (($t3i << 8) & 0xFFFFFF00) | (($t3i >> 24) & 0x000000FF); |
|
| 722 | + $t2[] = (($t3i << 8) & 0xFFFFFF00) | (($t3i >> 24) & 0x000000FF); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | $tables = array( |
@@ -801,9 +801,9 @@ discard block |
||
| 801 | 801 | )); |
| 802 | 802 | |
| 803 | 803 | foreach ($dt3 as $dt3i) { |
| 804 | - $dt0[] = (($dt3i << 24) & 0xFF000000) | (($dt3i >> 8) & 0x00FFFFFF); |
|
| 804 | + $dt0[] = (($dt3i << 24) & 0xFF000000) | (($dt3i >> 8) & 0x00FFFFFF); |
|
| 805 | 805 | $dt1[] = (($dt3i << 16) & 0xFFFF0000) | (($dt3i >> 16) & 0x0000FFFF); |
| 806 | - $dt2[] = (($dt3i << 8) & 0xFFFFFF00) | (($dt3i >> 24) & 0x000000FF); |
|
| 806 | + $dt2[] = (($dt3i << 8) & 0xFFFFFF00) | (($dt3i >> 24) & 0x000000FF); |
|
| 807 | 807 | }; |
| 808 | 808 | |
| 809 | 809 | $tables = array( |
@@ -848,7 +848,7 @@ discard block |
||
| 848 | 848 | // So here we are'nt under the same heavy timing-stress as we are in _de/encryptBlock() or de/encrypt(). |
| 849 | 849 | // However...the here generated function- $code, stored as php callback in $this->inline_crypt, must work as fast as even possible. |
| 850 | 850 | |
| 851 | - $lambda_functions =& self::_getLambdaFunctions(); |
|
| 851 | + $lambda_functions = & self::_getLambdaFunctions(); |
|
| 852 | 852 | |
| 853 | 853 | // We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function. |
| 854 | 854 | // (Currently, for Crypt_Rijndael/AES, one generated $lambda_function cost on php5.5@32bit ~80kb unfreeable mem and ~130kb on php5.5@64bit) |
@@ -872,7 +872,7 @@ discard block |
||
| 872 | 872 | break; |
| 873 | 873 | default: |
| 874 | 874 | for ($i = 0, $cw = count($this->w); $i < $cw; ++$i) { |
| 875 | - $w[] = '$w[' . $i . ']'; |
|
| 875 | + $w[] = '$w[' . $i . ']'; |
|
| 876 | 876 | $dw[] = '$dw[' . $i . ']'; |
| 877 | 877 | } |
| 878 | 878 | $init_encrypt = '$w = $self->w;'; |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | $c = $this->c; |
| 885 | 885 | |
| 886 | 886 | // Generating encrypt code: |
| 887 | - $init_encrypt.= ' |
|
| 887 | + $init_encrypt .= ' |
|
| 888 | 888 | static $tables; |
| 889 | 889 | if (empty($tables)) { |
| 890 | 890 | $tables = &$self->_getTables(); |
@@ -901,47 +901,47 @@ discard block |
||
| 901 | 901 | $wc = $Nb - 1; |
| 902 | 902 | |
| 903 | 903 | // Preround: addRoundKey |
| 904 | - $encrypt_block = '$in = unpack("N*", $in);'."\n"; |
|
| 904 | + $encrypt_block = '$in = unpack("N*", $in);' . "\n"; |
|
| 905 | 905 | for ($i = 0; $i < $Nb; ++$i) { |
| 906 | - $encrypt_block .= '$s'.$i.' = $in['.($i + 1).'] ^ '.$w[++$wc].";\n"; |
|
| 906 | + $encrypt_block .= '$s' . $i . ' = $in[' . ($i + 1) . '] ^ ' . $w[++$wc] . ";\n"; |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey |
| 910 | 910 | for ($round = 1; $round < $Nr; ++$round) { |
| 911 | 911 | list($s, $e) = array($e, $s); |
| 912 | 912 | for ($i = 0; $i < $Nb; ++$i) { |
| 913 | - $encrypt_block.= |
|
| 914 | - '$'.$e.$i.' = |
|
| 915 | - $t0[($'.$s.$i .' >> 24) & 0xff] ^ |
|
| 916 | - $t1[($'.$s.(($i + $c[1]) % $Nb).' >> 16) & 0xff] ^ |
|
| 917 | - $t2[($'.$s.(($i + $c[2]) % $Nb).' >> 8) & 0xff] ^ |
|
| 918 | - $t3[ $'.$s.(($i + $c[3]) % $Nb).' & 0xff] ^ |
|
| 919 | - '.$w[++$wc].";\n"; |
|
| 913 | + $encrypt_block .= |
|
| 914 | + '$' . $e . $i . ' = |
|
| 915 | + $t0[($'.$s . $i . ' >> 24) & 0xff] ^ |
|
| 916 | + $t1[($'.$s . (($i + $c[1]) % $Nb) . ' >> 16) & 0xff] ^ |
|
| 917 | + $t2[($'.$s . (($i + $c[2]) % $Nb) . ' >> 8) & 0xff] ^ |
|
| 918 | + $t3[ $'.$s . (($i + $c[3]) % $Nb) . ' & 0xff] ^ |
|
| 919 | + '.$w[++$wc] . ";\n"; |
|
| 920 | 920 | } |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | // Finalround: subWord + shiftRows + addRoundKey |
| 924 | 924 | for ($i = 0; $i < $Nb; ++$i) { |
| 925 | - $encrypt_block.= |
|
| 926 | - '$'.$e.$i.' = |
|
| 927 | - $sbox[ $'.$e.$i.' & 0xff] | |
|
| 928 | - ($sbox[($'.$e.$i.' >> 8) & 0xff] << 8) | |
|
| 929 | - ($sbox[($'.$e.$i.' >> 16) & 0xff] << 16) | |
|
| 930 | - ($sbox[($'.$e.$i.' >> 24) & 0xff] << 24);'."\n"; |
|
| 925 | + $encrypt_block .= |
|
| 926 | + '$' . $e . $i . ' = |
|
| 927 | + $sbox[ $'.$e . $i . ' & 0xff] | |
|
| 928 | + ($sbox[($'.$e . $i . ' >> 8) & 0xff] << 8) | |
|
| 929 | + ($sbox[($'.$e . $i . ' >> 16) & 0xff] << 16) | |
|
| 930 | + ($sbox[($'.$e . $i . ' >> 24) & 0xff] << 24);' . "\n"; |
|
| 931 | 931 | } |
| 932 | - $encrypt_block .= '$in = pack("N*"'."\n"; |
|
| 932 | + $encrypt_block .= '$in = pack("N*"' . "\n"; |
|
| 933 | 933 | for ($i = 0; $i < $Nb; ++$i) { |
| 934 | - $encrypt_block.= ', |
|
| 935 | - ($'.$e.$i .' & '.((int)0xFF000000).') ^ |
|
| 936 | - ($'.$e.(($i + $c[1]) % $Nb).' & 0x00FF0000 ) ^ |
|
| 937 | - ($'.$e.(($i + $c[2]) % $Nb).' & 0x0000FF00 ) ^ |
|
| 938 | - ($'.$e.(($i + $c[3]) % $Nb).' & 0x000000FF ) ^ |
|
| 939 | - '.$w[$i]."\n"; |
|
| 934 | + $encrypt_block .= ', |
|
| 935 | + ($'.$e . $i . ' & ' . ((int)0xFF000000) . ') ^ |
|
| 936 | + ($'.$e . (($i + $c[1]) % $Nb) . ' & 0x00FF0000 ) ^ |
|
| 937 | + ($'.$e . (($i + $c[2]) % $Nb) . ' & 0x0000FF00 ) ^ |
|
| 938 | + ($'.$e . (($i + $c[3]) % $Nb) . ' & 0x000000FF ) ^ |
|
| 939 | + '.$w[$i] . "\n"; |
|
| 940 | 940 | } |
| 941 | 941 | $encrypt_block .= ');'; |
| 942 | 942 | |
| 943 | 943 | // Generating decrypt code: |
| 944 | - $init_decrypt.= ' |
|
| 944 | + $init_decrypt .= ' |
|
| 945 | 945 | static $invtables; |
| 946 | 946 | if (empty($invtables)) { |
| 947 | 947 | $invtables = &$self->_getInvTables(); |
@@ -958,42 +958,42 @@ discard block |
||
| 958 | 958 | $wc = $Nb - 1; |
| 959 | 959 | |
| 960 | 960 | // Preround: addRoundKey |
| 961 | - $decrypt_block = '$in = unpack("N*", $in);'."\n"; |
|
| 961 | + $decrypt_block = '$in = unpack("N*", $in);' . "\n"; |
|
| 962 | 962 | for ($i = 0; $i < $Nb; ++$i) { |
| 963 | - $decrypt_block .= '$s'.$i.' = $in['.($i + 1).'] ^ '.$dw[++$wc].';'."\n"; |
|
| 963 | + $decrypt_block .= '$s' . $i . ' = $in[' . ($i + 1) . '] ^ ' . $dw[++$wc] . ';' . "\n"; |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey |
| 967 | 967 | for ($round = 1; $round < $Nr; ++$round) { |
| 968 | 968 | list($s, $e) = array($e, $s); |
| 969 | 969 | for ($i = 0; $i < $Nb; ++$i) { |
| 970 | - $decrypt_block.= |
|
| 971 | - '$'.$e.$i.' = |
|
| 972 | - $dt0[($'.$s.$i .' >> 24) & 0xff] ^ |
|
| 973 | - $dt1[($'.$s.(($Nb + $i - $c[1]) % $Nb).' >> 16) & 0xff] ^ |
|
| 974 | - $dt2[($'.$s.(($Nb + $i - $c[2]) % $Nb).' >> 8) & 0xff] ^ |
|
| 975 | - $dt3[ $'.$s.(($Nb + $i - $c[3]) % $Nb).' & 0xff] ^ |
|
| 976 | - '.$dw[++$wc].";\n"; |
|
| 970 | + $decrypt_block .= |
|
| 971 | + '$' . $e . $i . ' = |
|
| 972 | + $dt0[($'.$s . $i . ' >> 24) & 0xff] ^ |
|
| 973 | + $dt1[($'.$s . (($Nb + $i - $c[1]) % $Nb) . ' >> 16) & 0xff] ^ |
|
| 974 | + $dt2[($'.$s . (($Nb + $i - $c[2]) % $Nb) . ' >> 8) & 0xff] ^ |
|
| 975 | + $dt3[ $'.$s . (($Nb + $i - $c[3]) % $Nb) . ' & 0xff] ^ |
|
| 976 | + '.$dw[++$wc] . ";\n"; |
|
| 977 | 977 | } |
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | // Finalround: subWord + shiftRows + addRoundKey |
| 981 | 981 | for ($i = 0; $i < $Nb; ++$i) { |
| 982 | - $decrypt_block.= |
|
| 983 | - '$'.$e.$i.' = |
|
| 984 | - $isbox[ $'.$e.$i.' & 0xff] | |
|
| 985 | - ($isbox[($'.$e.$i.' >> 8) & 0xff] << 8) | |
|
| 986 | - ($isbox[($'.$e.$i.' >> 16) & 0xff] << 16) | |
|
| 987 | - ($isbox[($'.$e.$i.' >> 24) & 0xff] << 24);'."\n"; |
|
| 982 | + $decrypt_block .= |
|
| 983 | + '$' . $e . $i . ' = |
|
| 984 | + $isbox[ $'.$e . $i . ' & 0xff] | |
|
| 985 | + ($isbox[($'.$e . $i . ' >> 8) & 0xff] << 8) | |
|
| 986 | + ($isbox[($'.$e . $i . ' >> 16) & 0xff] << 16) | |
|
| 987 | + ($isbox[($'.$e . $i . ' >> 24) & 0xff] << 24);' . "\n"; |
|
| 988 | 988 | } |
| 989 | - $decrypt_block .= '$in = pack("N*"'."\n"; |
|
| 989 | + $decrypt_block .= '$in = pack("N*"' . "\n"; |
|
| 990 | 990 | for ($i = 0; $i < $Nb; ++$i) { |
| 991 | - $decrypt_block.= ', |
|
| 992 | - ($'.$e.$i. ' & '.((int)0xFF000000).') ^ |
|
| 993 | - ($'.$e.(($Nb + $i - $c[1]) % $Nb).' & 0x00FF0000 ) ^ |
|
| 994 | - ($'.$e.(($Nb + $i - $c[2]) % $Nb).' & 0x0000FF00 ) ^ |
|
| 995 | - ($'.$e.(($Nb + $i - $c[3]) % $Nb).' & 0x000000FF ) ^ |
|
| 996 | - '.$dw[$i]."\n"; |
|
| 991 | + $decrypt_block .= ', |
|
| 992 | + ($'.$e . $i . ' & ' . ((int)0xFF000000) . ') ^ |
|
| 993 | + ($'.$e . (($Nb + $i - $c[1]) % $Nb) . ' & 0x00FF0000 ) ^ |
|
| 994 | + ($'.$e . (($Nb + $i - $c[2]) % $Nb) . ' & 0x0000FF00 ) ^ |
|
| 995 | + ($'.$e . (($Nb + $i - $c[3]) % $Nb) . ' & 0x000000FF ) ^ |
|
| 996 | + '.$dw[$i] . "\n"; |
|
| 997 | 997 | } |
| 998 | 998 | $decrypt_block .= ');'; |
| 999 | 999 | |
@@ -648,9 +648,9 @@ |
||
| 648 | 648 | // Creates the inline-crypt function |
| 649 | 649 | $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( |
| 650 | 650 | array( |
| 651 | - 'init_crypt' => $init_crypt, |
|
| 652 | - 'encrypt_block' => $encrypt_block, |
|
| 653 | - 'decrypt_block' => $decrypt_block |
|
| 651 | + 'init_crypt' => $init_crypt, |
|
| 652 | + 'encrypt_block' => $encrypt_block, |
|
| 653 | + 'decrypt_block' => $decrypt_block |
|
| 654 | 654 | ) |
| 655 | 655 | ); |
| 656 | 656 | } |
@@ -530,7 +530,7 @@ |
||
| 530 | 530 | */ |
| 531 | 531 | function _setupInlineCrypt() |
| 532 | 532 | { |
| 533 | - $lambda_functions =& self::_getLambdaFunctions(); |
|
| 533 | + $lambda_functions = & self::_getLambdaFunctions(); |
|
| 534 | 534 | |
| 535 | 535 | // The first 10 generated $lambda_functions will use the $keys hardcoded as integers |
| 536 | 536 | // for the mixing rounds, for better inline crypt performance [~20% faster]. |
@@ -411,13 +411,13 @@ discard block |
||
| 411 | 411 | $l^= $p[$i]; |
| 412 | 412 | $r^= ($sb_0[$l >> 24 & 0xff] + |
| 413 | 413 | $sb_1[$l >> 16 & 0xff] ^ |
| 414 | - $sb_2[$l >> 8 & 0xff]) + |
|
| 414 | + $sb_2[$l >> 8 & 0xff]) + |
|
| 415 | 415 | $sb_3[$l & 0xff]; |
| 416 | 416 | |
| 417 | 417 | $r^= $p[$i + 1]; |
| 418 | 418 | $l^= ($sb_0[$r >> 24 & 0xff] + |
| 419 | 419 | $sb_1[$r >> 16 & 0xff] ^ |
| 420 | - $sb_2[$r >> 8 & 0xff]) + |
|
| 420 | + $sb_2[$r >> 8 & 0xff]) + |
|
| 421 | 421 | $sb_3[$r & 0xff]; |
| 422 | 422 | } |
| 423 | 423 | return pack("N*", $r ^ $p[17], $l ^ $p[16]); |
@@ -446,13 +446,13 @@ discard block |
||
| 446 | 446 | $l^= $p[$i]; |
| 447 | 447 | $r^= ($sb_0[$l >> 24 & 0xff] + |
| 448 | 448 | $sb_1[$l >> 16 & 0xff] ^ |
| 449 | - $sb_2[$l >> 8 & 0xff]) + |
|
| 449 | + $sb_2[$l >> 8 & 0xff]) + |
|
| 450 | 450 | $sb_3[$l & 0xff]; |
| 451 | 451 | |
| 452 | 452 | $r^= $p[$i - 1]; |
| 453 | 453 | $l^= ($sb_0[$r >> 24 & 0xff] + |
| 454 | 454 | $sb_1[$r >> 16 & 0xff] ^ |
| 455 | - $sb_2[$r >> 8 & 0xff]) + |
|
| 455 | + $sb_2[$r >> 8 & 0xff]) + |
|
| 456 | 456 | $sb_3[$r & 0xff]; |
| 457 | 457 | } |
| 458 | 458 | return pack("N*", $r ^ $p[0], $l ^ $p[1]); |
@@ -565,11 +565,11 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( |
| 567 | 567 | array( |
| 568 | - 'init_crypt' => $init_crypt, |
|
| 569 | - 'init_encrypt' => '', |
|
| 570 | - 'init_decrypt' => '', |
|
| 571 | - 'encrypt_block' => $encrypt_block, |
|
| 572 | - 'decrypt_block' => $decrypt_block |
|
| 568 | + 'init_crypt' => $init_crypt, |
|
| 569 | + 'init_encrypt' => '', |
|
| 570 | + 'init_decrypt' => '', |
|
| 571 | + 'encrypt_block' => $encrypt_block, |
|
| 572 | + 'decrypt_block' => $decrypt_block |
|
| 573 | 573 | ) |
| 574 | 574 | ); |
| 575 | 575 | } |
@@ -375,13 +375,13 @@ discard block |
||
| 375 | 375 | $data = "\0\0\0\0\0\0\0\0"; |
| 376 | 376 | for ($i = 0; $i < 18; $i += 2) { |
| 377 | 377 | list($l, $r) = array_values(unpack('N*', $data = $this->_encryptBlock($data))); |
| 378 | - $this->bctx['p'][$i ] = $l; |
|
| 378 | + $this->bctx['p'][$i] = $l; |
|
| 379 | 379 | $this->bctx['p'][$i + 1] = $r; |
| 380 | 380 | } |
| 381 | 381 | for ($i = 0; $i < 4; ++$i) { |
| 382 | 382 | for ($j = 0; $j < 256; $j += 2) { |
| 383 | 383 | list($l, $r) = array_values(unpack('N*', $data = $this->_encryptBlock($data))); |
| 384 | - $this->bctx['sb'][$i][$j ] = $l; |
|
| 384 | + $this->bctx['sb'][$i][$j] = $l; |
|
| 385 | 385 | $this->bctx['sb'][$i][$j + 1] = $r; |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -407,18 +407,18 @@ discard block |
||
| 407 | 407 | $l = $in[1]; |
| 408 | 408 | $r = $in[2]; |
| 409 | 409 | |
| 410 | - for ($i = 0; $i < 16; $i+= 2) { |
|
| 411 | - $l^= $p[$i]; |
|
| 412 | - $r^= ($sb_0[$l >> 24 & 0xff] + |
|
| 413 | - $sb_1[$l >> 16 & 0xff] ^ |
|
| 414 | - $sb_2[$l >> 8 & 0xff]) + |
|
| 415 | - $sb_3[$l & 0xff]; |
|
| 416 | - |
|
| 417 | - $r^= $p[$i + 1]; |
|
| 418 | - $l^= ($sb_0[$r >> 24 & 0xff] + |
|
| 419 | - $sb_1[$r >> 16 & 0xff] ^ |
|
| 420 | - $sb_2[$r >> 8 & 0xff]) + |
|
| 421 | - $sb_3[$r & 0xff]; |
|
| 410 | + for ($i = 0; $i < 16; $i += 2) { |
|
| 411 | + $l ^= $p[$i]; |
|
| 412 | + $r ^= ($sb_0[$l >> 24 & 0xff] + |
|
| 413 | + $sb_1[$l >> 16 & 0xff] ^ |
|
| 414 | + $sb_2[$l >> 8 & 0xff]) + |
|
| 415 | + $sb_3[$l & 0xff]; |
|
| 416 | + |
|
| 417 | + $r ^= $p[$i + 1]; |
|
| 418 | + $l ^= ($sb_0[$r >> 24 & 0xff] + |
|
| 419 | + $sb_1[$r >> 16 & 0xff] ^ |
|
| 420 | + $sb_2[$r >> 8 & 0xff]) + |
|
| 421 | + $sb_3[$r & 0xff]; |
|
| 422 | 422 | } |
| 423 | 423 | return pack("N*", $r ^ $p[17], $l ^ $p[16]); |
| 424 | 424 | } |
@@ -442,18 +442,18 @@ discard block |
||
| 442 | 442 | $l = $in[1]; |
| 443 | 443 | $r = $in[2]; |
| 444 | 444 | |
| 445 | - for ($i = 17; $i > 2; $i-= 2) { |
|
| 446 | - $l^= $p[$i]; |
|
| 447 | - $r^= ($sb_0[$l >> 24 & 0xff] + |
|
| 448 | - $sb_1[$l >> 16 & 0xff] ^ |
|
| 449 | - $sb_2[$l >> 8 & 0xff]) + |
|
| 450 | - $sb_3[$l & 0xff]; |
|
| 451 | - |
|
| 452 | - $r^= $p[$i - 1]; |
|
| 453 | - $l^= ($sb_0[$r >> 24 & 0xff] + |
|
| 454 | - $sb_1[$r >> 16 & 0xff] ^ |
|
| 455 | - $sb_2[$r >> 8 & 0xff]) + |
|
| 456 | - $sb_3[$r & 0xff]; |
|
| 445 | + for ($i = 17; $i > 2; $i -= 2) { |
|
| 446 | + $l ^= $p[$i]; |
|
| 447 | + $r ^= ($sb_0[$l >> 24 & 0xff] + |
|
| 448 | + $sb_1[$l >> 16 & 0xff] ^ |
|
| 449 | + $sb_2[$l >> 8 & 0xff]) + |
|
| 450 | + $sb_3[$l & 0xff]; |
|
| 451 | + |
|
| 452 | + $r ^= $p[$i - 1]; |
|
| 453 | + $l ^= ($sb_0[$r >> 24 & 0xff] + |
|
| 454 | + $sb_1[$r >> 16 & 0xff] ^ |
|
| 455 | + $sb_2[$r >> 8 & 0xff]) + |
|
| 456 | + $sb_3[$r & 0xff]; |
|
| 457 | 457 | } |
| 458 | 458 | return pack("N*", $r ^ $p[0], $l ^ $p[1]); |
| 459 | 459 | } |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | */ |
| 467 | 467 | function _setupInlineCrypt() |
| 468 | 468 | { |
| 469 | - $lambda_functions =& self::_getLambdaFunctions(); |
|
| 469 | + $lambda_functions = & self::_getLambdaFunctions(); |
|
| 470 | 470 | |
| 471 | 471 | // We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function. |
| 472 | 472 | // (Currently, for Crypt_Blowfish, one generated $lambda_function cost on php5.5@32bit ~100kb unfreeable mem and ~180kb on php5.5@64bit) |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | '; |
| 495 | 495 | break; |
| 496 | 496 | default: |
| 497 | - $p = array(); |
|
| 497 | + $p = array(); |
|
| 498 | 498 | for ($i = 0; $i < 18; ++$i) { |
| 499 | 499 | $p[] = '$p_' . $i; |
| 500 | 500 | } |
@@ -511,8 +511,8 @@ discard block |
||
| 511 | 511 | $l = $in[1]; |
| 512 | 512 | $r = $in[2]; |
| 513 | 513 | '; |
| 514 | - for ($i = 0; $i < 16; $i+= 2) { |
|
| 515 | - $encrypt_block.= ' |
|
| 514 | + for ($i = 0; $i < 16; $i += 2) { |
|
| 515 | + $encrypt_block .= ' |
|
| 516 | 516 | $l^= ' . $p[$i] . '; |
| 517 | 517 | $r^= ($sb_0[$l >> 24 & 0xff] + |
| 518 | 518 | $sb_1[$l >> 16 & 0xff] ^ |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | $sb_3[$r & 0xff]; |
| 527 | 527 | '; |
| 528 | 528 | } |
| 529 | - $encrypt_block.= ' |
|
| 529 | + $encrypt_block .= ' |
|
| 530 | 530 | $in = pack("N*", |
| 531 | 531 | $r ^ ' . $p[17] . ', |
| 532 | 532 | $l ^ ' . $p[16] . ' |
@@ -540,8 +540,8 @@ discard block |
||
| 540 | 540 | $r = $in[2]; |
| 541 | 541 | '; |
| 542 | 542 | |
| 543 | - for ($i = 17; $i > 2; $i-= 2) { |
|
| 544 | - $decrypt_block.= ' |
|
| 543 | + for ($i = 17; $i > 2; $i -= 2) { |
|
| 544 | + $decrypt_block .= ' |
|
| 545 | 545 | $l^= ' . $p[$i] . '; |
| 546 | 546 | $r^= ($sb_0[$l >> 24 & 0xff] + |
| 547 | 547 | $sb_1[$l >> 16 & 0xff] ^ |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | '; |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - $decrypt_block.= ' |
|
| 559 | + $decrypt_block .= ' |
|
| 560 | 560 | $in = pack("N*", |
| 561 | 561 | $r ^ ' . $p[0] . ', |
| 562 | 562 | $l ^ ' . $p[1] . ' |
@@ -602,9 +602,9 @@ discard block |
||
| 602 | 602 | $f = $u = $hmac->hash($salt . pack('N', $i++)); |
| 603 | 603 | for ($j = 2; $j <= $count; ++$j) { |
| 604 | 604 | $u = $hmac->hash($u); |
| 605 | - $f^= $u; |
|
| 605 | + $f ^= $u; |
|
| 606 | 606 | } |
| 607 | - $key.= $f; |
|
| 607 | + $key .= $f; |
|
| 608 | 608 | } |
| 609 | 609 | $key = substr($key, 0, $dkLen); |
| 610 | 610 | break; |
@@ -681,11 +681,11 @@ discard block |
||
| 681 | 681 | $max = $this->block_size - $pos; |
| 682 | 682 | if ($len >= $max) { |
| 683 | 683 | $i = $max; |
| 684 | - $len-= $max; |
|
| 684 | + $len -= $max; |
|
| 685 | 685 | $pos = 0; |
| 686 | 686 | } else { |
| 687 | 687 | $i = $len; |
| 688 | - $pos+= $len; |
|
| 688 | + $pos += $len; |
|
| 689 | 689 | $len = 0; |
| 690 | 690 | } |
| 691 | 691 | // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize |
@@ -697,13 +697,13 @@ discard block |
||
| 697 | 697 | $overflow = $len % $this->block_size; |
| 698 | 698 | |
| 699 | 699 | if ($overflow) { |
| 700 | - $ciphertext.= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); |
|
| 700 | + $ciphertext .= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); |
|
| 701 | 701 | $iv = $this->_string_pop($ciphertext, $this->block_size); |
| 702 | 702 | |
| 703 | 703 | $size = $len - $overflow; |
| 704 | 704 | $block = $iv ^ substr($plaintext, -$overflow); |
| 705 | 705 | $iv = substr_replace($iv, $block, 0, $overflow); |
| 706 | - $ciphertext.= $block; |
|
| 706 | + $ciphertext .= $block; |
|
| 707 | 707 | $pos = $overflow; |
| 708 | 708 | } elseif ($len) { |
| 709 | 709 | $ciphertext = openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); |
@@ -741,11 +741,11 @@ discard block |
||
| 741 | 741 | $max = $block_size - $pos; |
| 742 | 742 | if ($len >= $max) { |
| 743 | 743 | $i = $max; |
| 744 | - $len-= $max; |
|
| 744 | + $len -= $max; |
|
| 745 | 745 | $pos = 0; |
| 746 | 746 | } else { |
| 747 | 747 | $i = $len; |
| 748 | - $pos+= $len; |
|
| 748 | + $pos += $len; |
|
| 749 | 749 | $len = 0; |
| 750 | 750 | } |
| 751 | 751 | $ciphertext = substr($iv, $orig_pos) ^ $plaintext; |
@@ -758,15 +758,15 @@ discard block |
||
| 758 | 758 | mcrypt_generic_init($this->enmcrypt, $this->key, $iv); |
| 759 | 759 | $this->enbuffer['enmcrypt_init'] = false; |
| 760 | 760 | } |
| 761 | - $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % $block_size)); |
|
| 761 | + $ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % $block_size)); |
|
| 762 | 762 | $iv = substr($ciphertext, -$block_size); |
| 763 | - $len%= $block_size; |
|
| 763 | + $len %= $block_size; |
|
| 764 | 764 | } else { |
| 765 | 765 | while ($len >= $block_size) { |
| 766 | 766 | $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size); |
| 767 | - $ciphertext.= $iv; |
|
| 768 | - $len-= $block_size; |
|
| 769 | - $i+= $block_size; |
|
| 767 | + $ciphertext .= $iv; |
|
| 768 | + $len -= $block_size; |
|
| 769 | + $i += $block_size; |
|
| 770 | 770 | } |
| 771 | 771 | } |
| 772 | 772 | } |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | $iv = mcrypt_generic($this->ecb, $iv); |
| 776 | 776 | $block = $iv ^ substr($plaintext, -$len); |
| 777 | 777 | $iv = substr_replace($iv, $block, 0, $len); |
| 778 | - $ciphertext.= $block; |
|
| 778 | + $ciphertext .= $block; |
|
| 779 | 779 | $pos = $len; |
| 780 | 780 | } |
| 781 | 781 | |
@@ -805,17 +805,17 @@ discard block |
||
| 805 | 805 | $ciphertext = ''; |
| 806 | 806 | switch ($this->mode) { |
| 807 | 807 | case self::MODE_ECB: |
| 808 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
| 809 | - $ciphertext.= $this->_encryptBlock(substr($plaintext, $i, $block_size)); |
|
| 808 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
| 809 | + $ciphertext .= $this->_encryptBlock(substr($plaintext, $i, $block_size)); |
|
| 810 | 810 | } |
| 811 | 811 | break; |
| 812 | 812 | case self::MODE_CBC: |
| 813 | 813 | $xor = $this->encryptIV; |
| 814 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
| 814 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
| 815 | 815 | $block = substr($plaintext, $i, $block_size); |
| 816 | 816 | $block = $this->_encryptBlock($block ^ $xor); |
| 817 | 817 | $xor = $block; |
| 818 | - $ciphertext.= $block; |
|
| 818 | + $ciphertext .= $block; |
|
| 819 | 819 | } |
| 820 | 820 | if ($this->continuousBuffer) { |
| 821 | 821 | $this->encryptIV = $xor; |
@@ -824,21 +824,21 @@ discard block |
||
| 824 | 824 | case self::MODE_CTR: |
| 825 | 825 | $xor = $this->encryptIV; |
| 826 | 826 | if (strlen($buffer['ciphertext'])) { |
| 827 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
| 827 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
| 828 | 828 | $block = substr($plaintext, $i, $block_size); |
| 829 | 829 | if (strlen($block) > strlen($buffer['ciphertext'])) { |
| 830 | - $buffer['ciphertext'].= $this->_encryptBlock($xor); |
|
| 830 | + $buffer['ciphertext'] .= $this->_encryptBlock($xor); |
|
| 831 | 831 | } |
| 832 | 832 | $this->_increment_str($xor); |
| 833 | 833 | $key = $this->_string_shift($buffer['ciphertext'], $block_size); |
| 834 | - $ciphertext.= $block ^ $key; |
|
| 834 | + $ciphertext .= $block ^ $key; |
|
| 835 | 835 | } |
| 836 | 836 | } else { |
| 837 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
| 837 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
| 838 | 838 | $block = substr($plaintext, $i, $block_size); |
| 839 | 839 | $key = $this->_encryptBlock($xor); |
| 840 | 840 | $this->_increment_str($xor); |
| 841 | - $ciphertext.= $block ^ $key; |
|
| 841 | + $ciphertext .= $block ^ $key; |
|
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | if ($this->continuousBuffer) { |
@@ -865,11 +865,11 @@ discard block |
||
| 865 | 865 | $max = $block_size - $pos; |
| 866 | 866 | if ($len >= $max) { |
| 867 | 867 | $i = $max; |
| 868 | - $len-= $max; |
|
| 868 | + $len -= $max; |
|
| 869 | 869 | $pos = 0; |
| 870 | 870 | } else { |
| 871 | 871 | $i = $len; |
| 872 | - $pos+= $len; |
|
| 872 | + $pos += $len; |
|
| 873 | 873 | $len = 0; |
| 874 | 874 | } |
| 875 | 875 | // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize |
@@ -878,34 +878,34 @@ discard block |
||
| 878 | 878 | } |
| 879 | 879 | while ($len >= $block_size) { |
| 880 | 880 | $iv = $this->_encryptBlock($iv) ^ substr($plaintext, $i, $block_size); |
| 881 | - $ciphertext.= $iv; |
|
| 882 | - $len-= $block_size; |
|
| 883 | - $i+= $block_size; |
|
| 881 | + $ciphertext .= $iv; |
|
| 882 | + $len -= $block_size; |
|
| 883 | + $i += $block_size; |
|
| 884 | 884 | } |
| 885 | 885 | if ($len) { |
| 886 | 886 | $iv = $this->_encryptBlock($iv); |
| 887 | 887 | $block = $iv ^ substr($plaintext, $i); |
| 888 | 888 | $iv = substr_replace($iv, $block, 0, $len); |
| 889 | - $ciphertext.= $block; |
|
| 889 | + $ciphertext .= $block; |
|
| 890 | 890 | $pos = $len; |
| 891 | 891 | } |
| 892 | 892 | break; |
| 893 | 893 | case self::MODE_OFB: |
| 894 | 894 | $xor = $this->encryptIV; |
| 895 | 895 | if (strlen($buffer['xor'])) { |
| 896 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
| 896 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
| 897 | 897 | $block = substr($plaintext, $i, $block_size); |
| 898 | 898 | if (strlen($block) > strlen($buffer['xor'])) { |
| 899 | 899 | $xor = $this->_encryptBlock($xor); |
| 900 | - $buffer['xor'].= $xor; |
|
| 900 | + $buffer['xor'] .= $xor; |
|
| 901 | 901 | } |
| 902 | 902 | $key = $this->_string_shift($buffer['xor'], $block_size); |
| 903 | - $ciphertext.= $block ^ $key; |
|
| 903 | + $ciphertext .= $block ^ $key; |
|
| 904 | 904 | } |
| 905 | 905 | } else { |
| 906 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
| 906 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
| 907 | 907 | $xor = $this->_encryptBlock($xor); |
| 908 | - $ciphertext.= substr($plaintext, $i, $block_size) ^ $xor; |
|
| 908 | + $ciphertext .= substr($plaintext, $i, $block_size) ^ $xor; |
|
| 909 | 909 | } |
| 910 | 910 | $key = $xor; |
| 911 | 911 | } |
@@ -955,14 +955,14 @@ discard block |
||
| 955 | 955 | break; |
| 956 | 956 | case self::MODE_ECB: |
| 957 | 957 | if (!defined('OPENSSL_RAW_DATA')) { |
| 958 | - $ciphertext.= openssl_encrypt('', $this->cipher_name_openssl_ecb, $this->key, true); |
|
| 958 | + $ciphertext .= openssl_encrypt('', $this->cipher_name_openssl_ecb, $this->key, true); |
|
| 959 | 959 | } |
| 960 | 960 | $plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options); |
| 961 | 961 | break; |
| 962 | 962 | case self::MODE_CBC: |
| 963 | 963 | if (!defined('OPENSSL_RAW_DATA')) { |
| 964 | 964 | $padding = str_repeat(chr($this->block_size), $this->block_size) ^ substr($ciphertext, -$this->block_size); |
| 965 | - $ciphertext.= substr(openssl_encrypt($padding, $this->cipher_name_openssl_ecb, $this->key, true), 0, $this->block_size); |
|
| 965 | + $ciphertext .= substr(openssl_encrypt($padding, $this->cipher_name_openssl_ecb, $this->key, true), 0, $this->block_size); |
|
| 966 | 966 | } |
| 967 | 967 | $plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $this->decryptIV); |
| 968 | 968 | if ($this->continuousBuffer) { |
@@ -990,11 +990,11 @@ discard block |
||
| 990 | 990 | $max = $this->block_size - $pos; |
| 991 | 991 | if ($len >= $max) { |
| 992 | 992 | $i = $max; |
| 993 | - $len-= $max; |
|
| 993 | + $len -= $max; |
|
| 994 | 994 | $pos = 0; |
| 995 | 995 | } else { |
| 996 | 996 | $i = $len; |
| 997 | - $pos+= $len; |
|
| 997 | + $pos += $len; |
|
| 998 | 998 | $len = 0; |
| 999 | 999 | } |
| 1000 | 1000 | // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $this->blocksize |
@@ -1004,16 +1004,16 @@ discard block |
||
| 1004 | 1004 | } |
| 1005 | 1005 | $overflow = $len % $this->block_size; |
| 1006 | 1006 | if ($overflow) { |
| 1007 | - $plaintext.= openssl_decrypt(substr($ciphertext, 0, -$overflow), $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); |
|
| 1007 | + $plaintext .= openssl_decrypt(substr($ciphertext, 0, -$overflow), $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); |
|
| 1008 | 1008 | if ($len - $overflow) { |
| 1009 | 1009 | $iv = substr($ciphertext, -$overflow - $this->block_size, -$overflow); |
| 1010 | 1010 | } |
| 1011 | 1011 | $iv = openssl_encrypt(str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); |
| 1012 | - $plaintext.= $iv ^ substr($ciphertext, -$overflow); |
|
| 1012 | + $plaintext .= $iv ^ substr($ciphertext, -$overflow); |
|
| 1013 | 1013 | $iv = substr_replace($iv, substr($ciphertext, -$overflow), 0, $overflow); |
| 1014 | 1014 | $pos = $overflow; |
| 1015 | 1015 | } elseif ($len) { |
| 1016 | - $plaintext.= openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); |
|
| 1016 | + $plaintext .= openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); |
|
| 1017 | 1017 | $iv = substr($ciphertext, -$this->block_size); |
| 1018 | 1018 | } |
| 1019 | 1019 | break; |
@@ -1046,11 +1046,11 @@ discard block |
||
| 1046 | 1046 | $max = $block_size - $pos; |
| 1047 | 1047 | if ($len >= $max) { |
| 1048 | 1048 | $i = $max; |
| 1049 | - $len-= $max; |
|
| 1049 | + $len -= $max; |
|
| 1050 | 1050 | $pos = 0; |
| 1051 | 1051 | } else { |
| 1052 | 1052 | $i = $len; |
| 1053 | - $pos+= $len; |
|
| 1053 | + $pos += $len; |
|
| 1054 | 1054 | $len = 0; |
| 1055 | 1055 | } |
| 1056 | 1056 | // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize |
@@ -1059,13 +1059,13 @@ discard block |
||
| 1059 | 1059 | } |
| 1060 | 1060 | if ($len >= $block_size) { |
| 1061 | 1061 | $cb = substr($ciphertext, $i, $len - $len % $block_size); |
| 1062 | - $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; |
|
| 1062 | + $plaintext .= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; |
|
| 1063 | 1063 | $iv = substr($cb, -$block_size); |
| 1064 | - $len%= $block_size; |
|
| 1064 | + $len %= $block_size; |
|
| 1065 | 1065 | } |
| 1066 | 1066 | if ($len) { |
| 1067 | 1067 | $iv = mcrypt_generic($this->ecb, $iv); |
| 1068 | - $plaintext.= $iv ^ substr($ciphertext, -$len); |
|
| 1068 | + $plaintext .= $iv ^ substr($ciphertext, -$len); |
|
| 1069 | 1069 | $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); |
| 1070 | 1070 | $pos = $len; |
| 1071 | 1071 | } |
@@ -1097,15 +1097,15 @@ discard block |
||
| 1097 | 1097 | $plaintext = ''; |
| 1098 | 1098 | switch ($this->mode) { |
| 1099 | 1099 | case self::MODE_ECB: |
| 1100 | - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { |
|
| 1101 | - $plaintext.= $this->_decryptBlock(substr($ciphertext, $i, $block_size)); |
|
| 1100 | + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { |
|
| 1101 | + $plaintext .= $this->_decryptBlock(substr($ciphertext, $i, $block_size)); |
|
| 1102 | 1102 | } |
| 1103 | 1103 | break; |
| 1104 | 1104 | case self::MODE_CBC: |
| 1105 | 1105 | $xor = $this->decryptIV; |
| 1106 | - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { |
|
| 1106 | + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { |
|
| 1107 | 1107 | $block = substr($ciphertext, $i, $block_size); |
| 1108 | - $plaintext.= $this->_decryptBlock($block) ^ $xor; |
|
| 1108 | + $plaintext .= $this->_decryptBlock($block) ^ $xor; |
|
| 1109 | 1109 | $xor = $block; |
| 1110 | 1110 | } |
| 1111 | 1111 | if ($this->continuousBuffer) { |
@@ -1115,21 +1115,21 @@ discard block |
||
| 1115 | 1115 | case self::MODE_CTR: |
| 1116 | 1116 | $xor = $this->decryptIV; |
| 1117 | 1117 | if (strlen($buffer['ciphertext'])) { |
| 1118 | - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { |
|
| 1118 | + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { |
|
| 1119 | 1119 | $block = substr($ciphertext, $i, $block_size); |
| 1120 | 1120 | if (strlen($block) > strlen($buffer['ciphertext'])) { |
| 1121 | - $buffer['ciphertext'].= $this->_encryptBlock($xor); |
|
| 1121 | + $buffer['ciphertext'] .= $this->_encryptBlock($xor); |
|
| 1122 | 1122 | $this->_increment_str($xor); |
| 1123 | 1123 | } |
| 1124 | 1124 | $key = $this->_string_shift($buffer['ciphertext'], $block_size); |
| 1125 | - $plaintext.= $block ^ $key; |
|
| 1125 | + $plaintext .= $block ^ $key; |
|
| 1126 | 1126 | } |
| 1127 | 1127 | } else { |
| 1128 | - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { |
|
| 1128 | + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { |
|
| 1129 | 1129 | $block = substr($ciphertext, $i, $block_size); |
| 1130 | 1130 | $key = $this->_encryptBlock($xor); |
| 1131 | 1131 | $this->_increment_str($xor); |
| 1132 | - $plaintext.= $block ^ $key; |
|
| 1132 | + $plaintext .= $block ^ $key; |
|
| 1133 | 1133 | } |
| 1134 | 1134 | } |
| 1135 | 1135 | if ($this->continuousBuffer) { |
@@ -1154,11 +1154,11 @@ discard block |
||
| 1154 | 1154 | $max = $block_size - $pos; |
| 1155 | 1155 | if ($len >= $max) { |
| 1156 | 1156 | $i = $max; |
| 1157 | - $len-= $max; |
|
| 1157 | + $len -= $max; |
|
| 1158 | 1158 | $pos = 0; |
| 1159 | 1159 | } else { |
| 1160 | 1160 | $i = $len; |
| 1161 | - $pos+= $len; |
|
| 1161 | + $pos += $len; |
|
| 1162 | 1162 | $len = 0; |
| 1163 | 1163 | } |
| 1164 | 1164 | // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize |
@@ -1168,14 +1168,14 @@ discard block |
||
| 1168 | 1168 | while ($len >= $block_size) { |
| 1169 | 1169 | $iv = $this->_encryptBlock($iv); |
| 1170 | 1170 | $cb = substr($ciphertext, $i, $block_size); |
| 1171 | - $plaintext.= $iv ^ $cb; |
|
| 1171 | + $plaintext .= $iv ^ $cb; |
|
| 1172 | 1172 | $iv = $cb; |
| 1173 | - $len-= $block_size; |
|
| 1174 | - $i+= $block_size; |
|
| 1173 | + $len -= $block_size; |
|
| 1174 | + $i += $block_size; |
|
| 1175 | 1175 | } |
| 1176 | 1176 | if ($len) { |
| 1177 | 1177 | $iv = $this->_encryptBlock($iv); |
| 1178 | - $plaintext.= $iv ^ substr($ciphertext, $i); |
|
| 1178 | + $plaintext .= $iv ^ substr($ciphertext, $i); |
|
| 1179 | 1179 | $iv = substr_replace($iv, substr($ciphertext, $i), 0, $len); |
| 1180 | 1180 | $pos = $len; |
| 1181 | 1181 | } |
@@ -1183,19 +1183,19 @@ discard block |
||
| 1183 | 1183 | case self::MODE_OFB: |
| 1184 | 1184 | $xor = $this->decryptIV; |
| 1185 | 1185 | if (strlen($buffer['xor'])) { |
| 1186 | - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { |
|
| 1186 | + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { |
|
| 1187 | 1187 | $block = substr($ciphertext, $i, $block_size); |
| 1188 | 1188 | if (strlen($block) > strlen($buffer['xor'])) { |
| 1189 | 1189 | $xor = $this->_encryptBlock($xor); |
| 1190 | - $buffer['xor'].= $xor; |
|
| 1190 | + $buffer['xor'] .= $xor; |
|
| 1191 | 1191 | } |
| 1192 | 1192 | $key = $this->_string_shift($buffer['xor'], $block_size); |
| 1193 | - $plaintext.= $block ^ $key; |
|
| 1193 | + $plaintext .= $block ^ $key; |
|
| 1194 | 1194 | } |
| 1195 | 1195 | } else { |
| 1196 | - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { |
|
| 1196 | + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { |
|
| 1197 | 1197 | $xor = $this->_encryptBlock($xor); |
| 1198 | - $plaintext.= substr($ciphertext, $i, $block_size) ^ $xor; |
|
| 1198 | + $plaintext .= substr($ciphertext, $i, $block_size) ^ $xor; |
|
| 1199 | 1199 | } |
| 1200 | 1200 | $key = $xor; |
| 1201 | 1201 | } |
@@ -1239,24 +1239,24 @@ discard block |
||
| 1239 | 1239 | if ($this->openssl_emulate_ctr) { |
| 1240 | 1240 | $xor = $encryptIV; |
| 1241 | 1241 | if (strlen($buffer['ciphertext'])) { |
| 1242 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
| 1242 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
| 1243 | 1243 | $block = substr($plaintext, $i, $block_size); |
| 1244 | 1244 | if (strlen($block) > strlen($buffer['ciphertext'])) { |
| 1245 | 1245 | $result = openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, $this->openssl_options); |
| 1246 | 1246 | $result = !defined('OPENSSL_RAW_DATA') ? substr($result, 0, -$this->block_size) : $result; |
| 1247 | - $buffer['ciphertext'].= $result; |
|
| 1247 | + $buffer['ciphertext'] .= $result; |
|
| 1248 | 1248 | } |
| 1249 | 1249 | $this->_increment_str($xor); |
| 1250 | 1250 | $otp = $this->_string_shift($buffer['ciphertext'], $block_size); |
| 1251 | - $ciphertext.= $block ^ $otp; |
|
| 1251 | + $ciphertext .= $block ^ $otp; |
|
| 1252 | 1252 | } |
| 1253 | 1253 | } else { |
| 1254 | - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { |
|
| 1254 | + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { |
|
| 1255 | 1255 | $block = substr($plaintext, $i, $block_size); |
| 1256 | 1256 | $otp = openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, $this->openssl_options); |
| 1257 | 1257 | $otp = !defined('OPENSSL_RAW_DATA') ? substr($otp, 0, -$this->block_size) : $otp; |
| 1258 | 1258 | $this->_increment_str($xor); |
| 1259 | - $ciphertext.= $block ^ $otp; |
|
| 1259 | + $ciphertext .= $block ^ $otp; |
|
| 1260 | 1260 | } |
| 1261 | 1261 | } |
| 1262 | 1262 | if ($this->continuousBuffer) { |
@@ -1283,13 +1283,13 @@ discard block |
||
| 1283 | 1283 | $plaintext2 = $this->_string_pop($plaintext, $overflow); // ie. trim $plaintext to a multiple of $block_size and put rest of $plaintext in $plaintext2 |
| 1284 | 1284 | $encrypted = openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV); |
| 1285 | 1285 | $temp = $this->_string_pop($encrypted, $block_size); |
| 1286 | - $ciphertext.= $encrypted . ($plaintext2 ^ $temp); |
|
| 1286 | + $ciphertext .= $encrypted . ($plaintext2 ^ $temp); |
|
| 1287 | 1287 | if ($this->continuousBuffer) { |
| 1288 | 1288 | $buffer['ciphertext'] = substr($temp, $overflow); |
| 1289 | 1289 | $encryptIV = $temp; |
| 1290 | 1290 | } |
| 1291 | 1291 | } elseif (!strlen($buffer['ciphertext'])) { |
| 1292 | - $ciphertext.= openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV); |
|
| 1292 | + $ciphertext .= openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV); |
|
| 1293 | 1293 | $temp = $this->_string_pop($ciphertext, $block_size); |
| 1294 | 1294 | if ($this->continuousBuffer) { |
| 1295 | 1295 | $encryptIV = $temp; |
@@ -1297,7 +1297,7 @@ discard block |
||
| 1297 | 1297 | } |
| 1298 | 1298 | if ($this->continuousBuffer) { |
| 1299 | 1299 | if (!defined('OPENSSL_RAW_DATA')) { |
| 1300 | - $encryptIV.= openssl_encrypt('', $this->cipher_name_openssl_ecb, $key, $this->openssl_options); |
|
| 1300 | + $encryptIV .= openssl_encrypt('', $this->cipher_name_openssl_ecb, $key, $this->openssl_options); |
|
| 1301 | 1301 | } |
| 1302 | 1302 | $encryptIV = openssl_decrypt($encryptIV, $this->cipher_name_openssl_ecb, $key, $this->openssl_options); |
| 1303 | 1303 | if ($overflow) { |
@@ -1341,12 +1341,12 @@ discard block |
||
| 1341 | 1341 | |
| 1342 | 1342 | if (strlen($plaintext)) { |
| 1343 | 1343 | if ($overflow) { |
| 1344 | - $ciphertext.= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV); |
|
| 1344 | + $ciphertext .= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV); |
|
| 1345 | 1345 | $xor = $this->_string_pop($ciphertext, $block_size); |
| 1346 | 1346 | if ($this->continuousBuffer) { |
| 1347 | 1347 | $encryptIV = $xor; |
| 1348 | 1348 | } |
| 1349 | - $ciphertext.= $this->_string_shift($xor, $overflow) ^ substr($plaintext, -$overflow); |
|
| 1349 | + $ciphertext .= $this->_string_shift($xor, $overflow) ^ substr($plaintext, -$overflow); |
|
| 1350 | 1350 | if ($this->continuousBuffer) { |
| 1351 | 1351 | $buffer['xor'] = $xor; |
| 1352 | 1352 | } |
@@ -1876,7 +1876,7 @@ discard block |
||
| 1876 | 1876 | */ |
| 1877 | 1877 | function _increment_str(&$var) |
| 1878 | 1878 | { |
| 1879 | - for ($i = 4; $i <= strlen($var); $i+= 4) { |
|
| 1879 | + for ($i = 4; $i <= strlen($var); $i += 4) { |
|
| 1880 | 1880 | $temp = substr($var, -$i, 4); |
| 1881 | 1881 | switch ($temp) { |
| 1882 | 1882 | case "\xFF\xFF\xFF\xFF": |
@@ -2090,9 +2090,9 @@ discard block |
||
| 2090 | 2090 | $block_size = $this->block_size; |
| 2091 | 2091 | |
| 2092 | 2092 | // optional |
| 2093 | - $init_crypt = isset($cipher_code['init_crypt']) ? $cipher_code['init_crypt'] : ''; |
|
| 2094 | - $init_encrypt = isset($cipher_code['init_encrypt']) ? $cipher_code['init_encrypt'] : ''; |
|
| 2095 | - $init_decrypt = isset($cipher_code['init_decrypt']) ? $cipher_code['init_decrypt'] : ''; |
|
| 2093 | + $init_crypt = isset($cipher_code['init_crypt']) ? $cipher_code['init_crypt'] : ''; |
|
| 2094 | + $init_encrypt = isset($cipher_code['init_encrypt']) ? $cipher_code['init_encrypt'] : ''; |
|
| 2095 | + $init_decrypt = isset($cipher_code['init_decrypt']) ? $cipher_code['init_decrypt'] : ''; |
|
| 2096 | 2096 | // required |
| 2097 | 2097 | $encrypt_block = $cipher_code['encrypt_block']; |
| 2098 | 2098 | $decrypt_block = $cipher_code['decrypt_block']; |
@@ -2106,9 +2106,9 @@ discard block |
||
| 2106 | 2106 | $_ciphertext = ""; |
| 2107 | 2107 | $_plaintext_len = strlen($_text); |
| 2108 | 2108 | |
| 2109 | - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { |
|
| 2110 | - $in = substr($_text, $_i, '.$block_size.'); |
|
| 2111 | - '.$encrypt_block.' |
|
| 2109 | + for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size . ') { |
|
| 2110 | + $in = substr($_text, $_i, '.$block_size . '); |
|
| 2111 | + '.$encrypt_block . ' |
|
| 2112 | 2112 | $_ciphertext.= $in; |
| 2113 | 2113 | } |
| 2114 | 2114 | |
@@ -2117,12 +2117,12 @@ discard block |
||
| 2117 | 2117 | |
| 2118 | 2118 | $decrypt = $init_decrypt . ' |
| 2119 | 2119 | $_plaintext = ""; |
| 2120 | - $_text = str_pad($_text, strlen($_text) + ('.$block_size.' - strlen($_text) % '.$block_size.') % '.$block_size.', chr(0)); |
|
| 2120 | + $_text = str_pad($_text, strlen($_text) + ('.$block_size . ' - strlen($_text) % ' . $block_size . ') % ' . $block_size . ', chr(0)); |
|
| 2121 | 2121 | $_ciphertext_len = strlen($_text); |
| 2122 | 2122 | |
| 2123 | - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { |
|
| 2124 | - $in = substr($_text, $_i, '.$block_size.'); |
|
| 2125 | - '.$decrypt_block.' |
|
| 2123 | + for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size . ') { |
|
| 2124 | + $in = substr($_text, $_i, '.$block_size . '); |
|
| 2125 | + '.$decrypt_block . ' |
|
| 2126 | 2126 | $_plaintext.= $in; |
| 2127 | 2127 | } |
| 2128 | 2128 | |
@@ -2136,22 +2136,22 @@ discard block |
||
| 2136 | 2136 | $_xor = $self->encryptIV; |
| 2137 | 2137 | $_buffer = &$self->enbuffer; |
| 2138 | 2138 | if (strlen($_buffer["ciphertext"])) { |
| 2139 | - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { |
|
| 2140 | - $_block = substr($_text, $_i, '.$block_size.'); |
|
| 2139 | + for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size . ') { |
|
| 2140 | + $_block = substr($_text, $_i, '.$block_size . '); |
|
| 2141 | 2141 | if (strlen($_block) > strlen($_buffer["ciphertext"])) { |
| 2142 | 2142 | $in = $_xor; |
| 2143 | - '.$encrypt_block.' |
|
| 2143 | + '.$encrypt_block . ' |
|
| 2144 | 2144 | $self->_increment_str($_xor); |
| 2145 | 2145 | $_buffer["ciphertext"].= $in; |
| 2146 | 2146 | } |
| 2147 | - $_key = $self->_string_shift($_buffer["ciphertext"], '.$block_size.'); |
|
| 2147 | + $_key = $self->_string_shift($_buffer["ciphertext"], '.$block_size . '); |
|
| 2148 | 2148 | $_ciphertext.= $_block ^ $_key; |
| 2149 | 2149 | } |
| 2150 | 2150 | } else { |
| 2151 | - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { |
|
| 2152 | - $_block = substr($_text, $_i, '.$block_size.'); |
|
| 2151 | + for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size . ') { |
|
| 2152 | + $_block = substr($_text, $_i, '.$block_size . '); |
|
| 2153 | 2153 | $in = $_xor; |
| 2154 | - '.$encrypt_block.' |
|
| 2154 | + '.$encrypt_block . ' |
|
| 2155 | 2155 | $self->_increment_str($_xor); |
| 2156 | 2156 | $_key = $in; |
| 2157 | 2157 | $_ciphertext.= $_block ^ $_key; |
@@ -2159,7 +2159,7 @@ discard block |
||
| 2159 | 2159 | } |
| 2160 | 2160 | if ($self->continuousBuffer) { |
| 2161 | 2161 | $self->encryptIV = $_xor; |
| 2162 | - if ($_start = $_plaintext_len % '.$block_size.') { |
|
| 2162 | + if ($_start = $_plaintext_len % '.$block_size . ') { |
|
| 2163 | 2163 | $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"]; |
| 2164 | 2164 | } |
| 2165 | 2165 | } |
@@ -2174,22 +2174,22 @@ discard block |
||
| 2174 | 2174 | $_buffer = &$self->debuffer; |
| 2175 | 2175 | |
| 2176 | 2176 | if (strlen($_buffer["ciphertext"])) { |
| 2177 | - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { |
|
| 2178 | - $_block = substr($_text, $_i, '.$block_size.'); |
|
| 2177 | + for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size . ') { |
|
| 2178 | + $_block = substr($_text, $_i, '.$block_size . '); |
|
| 2179 | 2179 | if (strlen($_block) > strlen($_buffer["ciphertext"])) { |
| 2180 | 2180 | $in = $_xor; |
| 2181 | - '.$encrypt_block.' |
|
| 2181 | + '.$encrypt_block . ' |
|
| 2182 | 2182 | $self->_increment_str($_xor); |
| 2183 | 2183 | $_buffer["ciphertext"].= $in; |
| 2184 | 2184 | } |
| 2185 | - $_key = $self->_string_shift($_buffer["ciphertext"], '.$block_size.'); |
|
| 2185 | + $_key = $self->_string_shift($_buffer["ciphertext"], '.$block_size . '); |
|
| 2186 | 2186 | $_plaintext.= $_block ^ $_key; |
| 2187 | 2187 | } |
| 2188 | 2188 | } else { |
| 2189 | - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { |
|
| 2190 | - $_block = substr($_text, $_i, '.$block_size.'); |
|
| 2189 | + for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size . ') { |
|
| 2190 | + $_block = substr($_text, $_i, '.$block_size . '); |
|
| 2191 | 2191 | $in = $_xor; |
| 2192 | - '.$encrypt_block.' |
|
| 2192 | + '.$encrypt_block . ' |
|
| 2193 | 2193 | $self->_increment_str($_xor); |
| 2194 | 2194 | $_key = $in; |
| 2195 | 2195 | $_plaintext.= $_block ^ $_key; |
@@ -2197,7 +2197,7 @@ discard block |
||
| 2197 | 2197 | } |
| 2198 | 2198 | if ($self->continuousBuffer) { |
| 2199 | 2199 | $self->decryptIV = $_xor; |
| 2200 | - if ($_start = $_ciphertext_len % '.$block_size.') { |
|
| 2200 | + if ($_start = $_ciphertext_len % '.$block_size . ') { |
|
| 2201 | 2201 | $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"]; |
| 2202 | 2202 | } |
| 2203 | 2203 | } |
@@ -2221,7 +2221,7 @@ discard block |
||
| 2221 | 2221 | $_i = 0; |
| 2222 | 2222 | if ($_pos) { |
| 2223 | 2223 | $_orig_pos = $_pos; |
| 2224 | - $_max = '.$block_size.' - $_pos; |
|
| 2224 | + $_max = '.$block_size . ' - $_pos; |
|
| 2225 | 2225 | if ($_len >= $_max) { |
| 2226 | 2226 | $_i = $_max; |
| 2227 | 2227 | $_len-= $_max; |
@@ -2234,17 +2234,17 @@ discard block |
||
| 2234 | 2234 | $_ciphertext = substr($_iv, $_orig_pos) ^ $_text; |
| 2235 | 2235 | $_iv = substr_replace($_iv, $_ciphertext, $_orig_pos, $_i); |
| 2236 | 2236 | } |
| 2237 | - while ($_len >= '.$block_size.') { |
|
| 2237 | + while ($_len >= '.$block_size . ') { |
|
| 2238 | 2238 | $in = $_iv; |
| 2239 | - '.$encrypt_block.'; |
|
| 2240 | - $_iv = $in ^ substr($_text, $_i, '.$block_size.'); |
|
| 2239 | + '.$encrypt_block . '; |
|
| 2240 | + $_iv = $in ^ substr($_text, $_i, '.$block_size . '); |
|
| 2241 | 2241 | $_ciphertext.= $_iv; |
| 2242 | - $_len-= '.$block_size.'; |
|
| 2243 | - $_i+= '.$block_size.'; |
|
| 2242 | + $_len-= '.$block_size . '; |
|
| 2243 | + $_i+= '.$block_size . '; |
|
| 2244 | 2244 | } |
| 2245 | 2245 | if ($_len) { |
| 2246 | 2246 | $in = $_iv; |
| 2247 | - '.$encrypt_block.' |
|
| 2247 | + '.$encrypt_block . ' |
|
| 2248 | 2248 | $_iv = $in; |
| 2249 | 2249 | $_block = $_iv ^ substr($_text, $_i); |
| 2250 | 2250 | $_iv = substr_replace($_iv, $_block, 0, $_len); |
@@ -2269,7 +2269,7 @@ discard block |
||
| 2269 | 2269 | $_i = 0; |
| 2270 | 2270 | if ($_pos) { |
| 2271 | 2271 | $_orig_pos = $_pos; |
| 2272 | - $_max = '.$block_size.' - $_pos; |
|
| 2272 | + $_max = '.$block_size . ' - $_pos; |
|
| 2273 | 2273 | if ($_len >= $_max) { |
| 2274 | 2274 | $_i = $_max; |
| 2275 | 2275 | $_len-= $_max; |
@@ -2282,19 +2282,19 @@ discard block |
||
| 2282 | 2282 | $_plaintext = substr($_iv, $_orig_pos) ^ $_text; |
| 2283 | 2283 | $_iv = substr_replace($_iv, substr($_text, 0, $_i), $_orig_pos, $_i); |
| 2284 | 2284 | } |
| 2285 | - while ($_len >= '.$block_size.') { |
|
| 2285 | + while ($_len >= '.$block_size . ') { |
|
| 2286 | 2286 | $in = $_iv; |
| 2287 | - '.$encrypt_block.' |
|
| 2287 | + '.$encrypt_block . ' |
|
| 2288 | 2288 | $_iv = $in; |
| 2289 | - $cb = substr($_text, $_i, '.$block_size.'); |
|
| 2289 | + $cb = substr($_text, $_i, '.$block_size . '); |
|
| 2290 | 2290 | $_plaintext.= $_iv ^ $cb; |
| 2291 | 2291 | $_iv = $cb; |
| 2292 | - $_len-= '.$block_size.'; |
|
| 2293 | - $_i+= '.$block_size.'; |
|
| 2292 | + $_len-= '.$block_size . '; |
|
| 2293 | + $_i+= '.$block_size . '; |
|
| 2294 | 2294 | } |
| 2295 | 2295 | if ($_len) { |
| 2296 | 2296 | $in = $_iv; |
| 2297 | - '.$encrypt_block.' |
|
| 2297 | + '.$encrypt_block . ' |
|
| 2298 | 2298 | $_iv = $in; |
| 2299 | 2299 | $_plaintext.= $_iv ^ substr($_text, $_i); |
| 2300 | 2300 | $_iv = substr_replace($_iv, substr($_text, $_i), 0, $_len); |
@@ -2312,29 +2312,29 @@ discard block |
||
| 2312 | 2312 | $_buffer = &$self->enbuffer; |
| 2313 | 2313 | |
| 2314 | 2314 | if (strlen($_buffer["xor"])) { |
| 2315 | - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { |
|
| 2316 | - $_block = substr($_text, $_i, '.$block_size.'); |
|
| 2315 | + for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size . ') { |
|
| 2316 | + $_block = substr($_text, $_i, '.$block_size . '); |
|
| 2317 | 2317 | if (strlen($_block) > strlen($_buffer["xor"])) { |
| 2318 | 2318 | $in = $_xor; |
| 2319 | - '.$encrypt_block.' |
|
| 2319 | + '.$encrypt_block . ' |
|
| 2320 | 2320 | $_xor = $in; |
| 2321 | 2321 | $_buffer["xor"].= $_xor; |
| 2322 | 2322 | } |
| 2323 | - $_key = $self->_string_shift($_buffer["xor"], '.$block_size.'); |
|
| 2323 | + $_key = $self->_string_shift($_buffer["xor"], '.$block_size . '); |
|
| 2324 | 2324 | $_ciphertext.= $_block ^ $_key; |
| 2325 | 2325 | } |
| 2326 | 2326 | } else { |
| 2327 | - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { |
|
| 2327 | + for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size . ') { |
|
| 2328 | 2328 | $in = $_xor; |
| 2329 | - '.$encrypt_block.' |
|
| 2329 | + '.$encrypt_block . ' |
|
| 2330 | 2330 | $_xor = $in; |
| 2331 | - $_ciphertext.= substr($_text, $_i, '.$block_size.') ^ $_xor; |
|
| 2331 | + $_ciphertext.= substr($_text, $_i, '.$block_size . ') ^ $_xor; |
|
| 2332 | 2332 | } |
| 2333 | 2333 | $_key = $_xor; |
| 2334 | 2334 | } |
| 2335 | 2335 | if ($self->continuousBuffer) { |
| 2336 | 2336 | $self->encryptIV = $_xor; |
| 2337 | - if ($_start = $_plaintext_len % '.$block_size.') { |
|
| 2337 | + if ($_start = $_plaintext_len % '.$block_size . ') { |
|
| 2338 | 2338 | $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"]; |
| 2339 | 2339 | } |
| 2340 | 2340 | } |
@@ -2348,29 +2348,29 @@ discard block |
||
| 2348 | 2348 | $_buffer = &$self->debuffer; |
| 2349 | 2349 | |
| 2350 | 2350 | if (strlen($_buffer["xor"])) { |
| 2351 | - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { |
|
| 2352 | - $_block = substr($_text, $_i, '.$block_size.'); |
|
| 2351 | + for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size . ') { |
|
| 2352 | + $_block = substr($_text, $_i, '.$block_size . '); |
|
| 2353 | 2353 | if (strlen($_block) > strlen($_buffer["xor"])) { |
| 2354 | 2354 | $in = $_xor; |
| 2355 | - '.$encrypt_block.' |
|
| 2355 | + '.$encrypt_block . ' |
|
| 2356 | 2356 | $_xor = $in; |
| 2357 | 2357 | $_buffer["xor"].= $_xor; |
| 2358 | 2358 | } |
| 2359 | - $_key = $self->_string_shift($_buffer["xor"], '.$block_size.'); |
|
| 2359 | + $_key = $self->_string_shift($_buffer["xor"], '.$block_size . '); |
|
| 2360 | 2360 | $_plaintext.= $_block ^ $_key; |
| 2361 | 2361 | } |
| 2362 | 2362 | } else { |
| 2363 | - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { |
|
| 2363 | + for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size . ') { |
|
| 2364 | 2364 | $in = $_xor; |
| 2365 | - '.$encrypt_block.' |
|
| 2365 | + '.$encrypt_block . ' |
|
| 2366 | 2366 | $_xor = $in; |
| 2367 | - $_plaintext.= substr($_text, $_i, '.$block_size.') ^ $_xor; |
|
| 2367 | + $_plaintext.= substr($_text, $_i, '.$block_size . ') ^ $_xor; |
|
| 2368 | 2368 | } |
| 2369 | 2369 | $_key = $_xor; |
| 2370 | 2370 | } |
| 2371 | 2371 | if ($self->continuousBuffer) { |
| 2372 | 2372 | $self->decryptIV = $_xor; |
| 2373 | - if ($_start = $_ciphertext_len % '.$block_size.') { |
|
| 2373 | + if ($_start = $_ciphertext_len % '.$block_size . ') { |
|
| 2374 | 2374 | $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"]; |
| 2375 | 2375 | } |
| 2376 | 2376 | } |
@@ -2380,12 +2380,12 @@ discard block |
||
| 2380 | 2380 | case self::MODE_STREAM: |
| 2381 | 2381 | $encrypt = $init_encrypt . ' |
| 2382 | 2382 | $_ciphertext = ""; |
| 2383 | - '.$encrypt_block.' |
|
| 2383 | + '.$encrypt_block . ' |
|
| 2384 | 2384 | return $_ciphertext; |
| 2385 | 2385 | '; |
| 2386 | 2386 | $decrypt = $init_decrypt . ' |
| 2387 | 2387 | $_plaintext = ""; |
| 2388 | - '.$decrypt_block.' |
|
| 2388 | + '.$decrypt_block . ' |
|
| 2389 | 2389 | return $_plaintext; |
| 2390 | 2390 | '; |
| 2391 | 2391 | break; |
@@ -2397,9 +2397,9 @@ discard block |
||
| 2397 | 2397 | |
| 2398 | 2398 | $in = $self->encryptIV; |
| 2399 | 2399 | |
| 2400 | - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { |
|
| 2401 | - $in = substr($_text, $_i, '.$block_size.') ^ $in; |
|
| 2402 | - '.$encrypt_block.' |
|
| 2400 | + for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size . ') { |
|
| 2401 | + $in = substr($_text, $_i, '.$block_size . ') ^ $in; |
|
| 2402 | + '.$encrypt_block . ' |
|
| 2403 | 2403 | $_ciphertext.= $in; |
| 2404 | 2404 | } |
| 2405 | 2405 | |
@@ -2412,14 +2412,14 @@ discard block |
||
| 2412 | 2412 | |
| 2413 | 2413 | $decrypt = $init_decrypt . ' |
| 2414 | 2414 | $_plaintext = ""; |
| 2415 | - $_text = str_pad($_text, strlen($_text) + ('.$block_size.' - strlen($_text) % '.$block_size.') % '.$block_size.', chr(0)); |
|
| 2415 | + $_text = str_pad($_text, strlen($_text) + ('.$block_size . ' - strlen($_text) % ' . $block_size . ') % ' . $block_size . ', chr(0)); |
|
| 2416 | 2416 | $_ciphertext_len = strlen($_text); |
| 2417 | 2417 | |
| 2418 | 2418 | $_iv = $self->decryptIV; |
| 2419 | 2419 | |
| 2420 | - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { |
|
| 2421 | - $in = $_block = substr($_text, $_i, '.$block_size.'); |
|
| 2422 | - '.$decrypt_block.' |
|
| 2420 | + for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size . ') { |
|
| 2421 | + $in = $_block = substr($_text, $_i, '.$block_size . '); |
|
| 2422 | + '.$decrypt_block . ' |
|
| 2423 | 2423 | $_plaintext.= $in ^ $_iv; |
| 2424 | 2424 | $_iv = $_block; |
| 2425 | 2425 | } |
@@ -2484,7 +2484,7 @@ discard block |
||
| 2484 | 2484 | return $result . hash('whirlpool', $hash, true); |
| 2485 | 2485 | default: |
| 2486 | 2486 | $len = strlen($bytes); |
| 2487 | - for ($i = 0; $i < $len; $i+=20) { |
|
| 2487 | + for ($i = 0; $i < $len; $i += 20) { |
|
| 2488 | 2488 | $t = substr($bytes, $i, 20); |
| 2489 | 2489 | $hash = pack('H*', sha1($hash)); |
| 2490 | 2490 | $result .= $t ^ $hash; |