@@ -709,13 +709,13 @@ discard block |
||
709 | 709 | $t = unpack('Nl/Nr', $block); |
710 | 710 | list($l, $r) = array($t['l'], $t['r']); |
711 | 711 | $block = ($shuffleip[ $r & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
712 | - ($shuffleip[($r >> 8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
713 | - ($shuffleip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
714 | - ($shuffleip[($r >> 24) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
715 | - ($shuffleip[ $l & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
716 | - ($shuffleip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
717 | - ($shuffleip[($l >> 16) & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
718 | - ($shuffleip[($l >> 24) & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
712 | + ($shuffleip[($r >> 8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
713 | + ($shuffleip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
714 | + ($shuffleip[($r >> 24) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
715 | + ($shuffleip[ $l & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
716 | + ($shuffleip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
717 | + ($shuffleip[($l >> 16) & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
718 | + ($shuffleip[($l >> 24) & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
719 | 719 | |
720 | 720 | // Extract L0 and R0. |
721 | 721 | $t = unpack('Nl/Nr', $block); |
@@ -732,9 +732,9 @@ discard block |
||
732 | 732 | |
733 | 733 | // S-box indexing. |
734 | 734 | $t = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ |
735 | - $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
|
736 | - $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
|
737 | - $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ $l; |
|
735 | + $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
|
736 | + $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
|
737 | + $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ $l; |
|
738 | 738 | // end of "the Feistel (F) function" |
739 | 739 | |
740 | 740 | $l = $r; |
@@ -749,13 +749,13 @@ discard block |
||
749 | 749 | |
750 | 750 | // Perform the inverse IP permutation. |
751 | 751 | return ($shuffleinvip[($r >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
752 | - ($shuffleinvip[($l >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
753 | - ($shuffleinvip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
754 | - ($shuffleinvip[($l >> 16) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
755 | - ($shuffleinvip[($r >> 8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
756 | - ($shuffleinvip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
757 | - ($shuffleinvip[ $r & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
758 | - ($shuffleinvip[ $l & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
752 | + ($shuffleinvip[($l >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
753 | + ($shuffleinvip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
|
754 | + ($shuffleinvip[($l >> 16) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
|
755 | + ($shuffleinvip[($r >> 8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
756 | + ($shuffleinvip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
757 | + ($shuffleinvip[ $r & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
758 | + ($shuffleinvip[ $l & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | /** |
@@ -1230,13 +1230,13 @@ discard block |
||
1230 | 1230 | $t = unpack('Nl/Nr', $key); |
1231 | 1231 | list($l, $r) = array($t['l'], $t['r']); |
1232 | 1232 | $key = ($this->shuffle[$pc1map[ $r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") | |
1233 | - ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | |
|
1234 | - ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | |
|
1235 | - ($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") | |
|
1236 | - ($this->shuffle[$pc1map[ $l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | |
|
1237 | - ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | |
|
1238 | - ($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") | |
|
1239 | - ($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00"); |
|
1233 | + ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | |
|
1234 | + ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | |
|
1235 | + ($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") | |
|
1236 | + ($this->shuffle[$pc1map[ $l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | |
|
1237 | + ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | |
|
1238 | + ($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") | |
|
1239 | + ($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00"); |
|
1240 | 1240 | $key = unpack('Nc/Nd', $key); |
1241 | 1241 | $c = ( $key['c'] >> 4) & 0x0FFFFFFF; |
1242 | 1242 | $d = (($key['d'] >> 4) & 0x0FFFFFF0) | ($key['c'] & 0x0F); |
@@ -1253,9 +1253,9 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | // Perform the PC-2 transformation. |
1255 | 1255 | $cp = $pc2mapc1[ $c >> 24 ] | $pc2mapc2[($c >> 16) & 0xFF] | |
1256 | - $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[ $c & 0xFF]; |
|
1256 | + $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[ $c & 0xFF]; |
|
1257 | 1257 | $dp = $pc2mapd1[ $d >> 24 ] | $pc2mapd2[($d >> 16) & 0xFF] | |
1258 | - $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[ $d & 0xFF]; |
|
1258 | + $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[ $d & 0xFF]; |
|
1259 | 1259 | |
1260 | 1260 | // Reorder: odd bytes/even bytes. Push the result in key schedule. |
1261 | 1261 | $val1 = ( $cp & 0xFF000000) | (($cp << 8) & 0x00FF0000) | |
@@ -1440,11 +1440,11 @@ discard block |
||
1440 | 1440 | // Creates the inline-crypt function |
1441 | 1441 | $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( |
1442 | 1442 | array( |
1443 | - 'init_crypt' => $init_crypt, |
|
1444 | - 'init_encrypt' => $init_encrypt, |
|
1445 | - 'init_decrypt' => $init_decrypt, |
|
1446 | - 'encrypt_block' => $crypt_block[self::ENCRYPT], |
|
1447 | - 'decrypt_block' => $crypt_block[self::DECRYPT] |
|
1443 | + 'init_crypt' => $init_crypt, |
|
1444 | + 'init_encrypt' => $init_encrypt, |
|
1445 | + 'init_decrypt' => $init_decrypt, |
|
1446 | + 'encrypt_block' => $crypt_block[self::ENCRYPT], |
|
1447 | + 'decrypt_block' => $crypt_block[self::DECRYPT] |
|
1448 | 1448 | ) |
1449 | 1449 | ); |
1450 | 1450 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | if ($this->key_length_max == 8) { |
612 | 612 | if ($engine == self::ENGINE_OPENSSL) { |
613 | 613 | $this->cipher_name_openssl_ecb = 'des-ecb'; |
614 | - $this->cipher_name_openssl = 'des-' . $this->_openssl_translate_mode(); |
|
614 | + $this->cipher_name_openssl = 'des-'.$this->_openssl_translate_mode(); |
|
615 | 615 | } |
616 | 616 | } |
617 | 617 | |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | function setKey($key) |
633 | 633 | { |
634 | 634 | if (!($this instanceof TripleDES) && strlen($key) != 8) { |
635 | - throw new \LengthException('Key of size ' . strlen($key) . ' not supported by this algorithm. Only keys of size 8 are supported'); |
|
635 | + throw new \LengthException('Key of size '.strlen($key).' not supported by this algorithm. Only keys of size 8 are supported'); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | // Sets the key |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | $sbox8 = array_map("intval", $this->sbox8); |
698 | 698 | /* Merge $shuffle with $[inv]ipmap */ |
699 | 699 | for ($i = 0; $i < 256; ++$i) { |
700 | - $shuffleip[] = $this->shuffle[$this->ipmap[$i]]; |
|
701 | - $shuffleinvip[] = $this->shuffle[$this->invipmap[$i]]; |
|
700 | + $shuffleip[] = $this->shuffle[$this->ipmap[$i]]; |
|
701 | + $shuffleinvip[] = $this->shuffle[$this->invipmap[$i]]; |
|
702 | 702 | } |
703 | 703 | } |
704 | 704 | |
@@ -708,12 +708,12 @@ discard block |
||
708 | 708 | // Do the initial IP permutation. |
709 | 709 | $t = unpack('Nl/Nr', $block); |
710 | 710 | list($l, $r) = array($t['l'], $t['r']); |
711 | - $block = ($shuffleip[ $r & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
|
712 | - ($shuffleip[($r >> 8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
711 | + $block = ($shuffleip[$r & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
|
712 | + ($shuffleip[($r >> 8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
|
713 | 713 | ($shuffleip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
714 | 714 | ($shuffleip[($r >> 24) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
715 | - ($shuffleip[ $l & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
716 | - ($shuffleip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
715 | + ($shuffleip[$l & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
716 | + ($shuffleip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
717 | 717 | ($shuffleip[($l >> 16) & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
718 | 718 | ($shuffleip[($l >> 24) & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
719 | 719 | |
@@ -727,14 +727,14 @@ discard block |
||
727 | 727 | // start of "the Feistel (F) function" - see the following URL: |
728 | 728 | // http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png |
729 | 729 | // Merge key schedule. |
730 | - $b1 = (($r >> 3) & 0x1FFFFFFF) ^ ($r << 29) ^ $keys[++$ki]; |
|
731 | - $b2 = (($r >> 31) & 0x00000001) ^ ($r << 1) ^ $keys[++$ki]; |
|
730 | + $b1 = (($r >> 3) & 0x1FFFFFFF) ^ ($r << 29) ^ $keys[++$ki]; |
|
731 | + $b2 = (($r >> 31) & 0x00000001) ^ ($r << 1) ^ $keys[++$ki]; |
|
732 | 732 | |
733 | 733 | // S-box indexing. |
734 | 734 | $t = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ |
735 | 735 | $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
736 | - $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
|
737 | - $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ $l; |
|
736 | + $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
|
737 | + $sbox7[$b1 & 0x3F] ^ $sbox8[$b2 & 0x3F] ^ $l; |
|
738 | 738 | // end of "the Feistel (F) function" |
739 | 739 | |
740 | 740 | $l = $r; |
@@ -752,10 +752,10 @@ discard block |
||
752 | 752 | ($shuffleinvip[($l >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
753 | 753 | ($shuffleinvip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
754 | 754 | ($shuffleinvip[($l >> 16) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | |
755 | - ($shuffleinvip[($r >> 8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
756 | - ($shuffleinvip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
757 | - ($shuffleinvip[ $r & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
758 | - ($shuffleinvip[ $l & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
755 | + ($shuffleinvip[($r >> 8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | |
|
756 | + ($shuffleinvip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | |
|
757 | + ($shuffleinvip[$r & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | |
|
758 | + ($shuffleinvip[$l & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | /** |
@@ -1229,43 +1229,43 @@ discard block |
||
1229 | 1229 | // Perform the PC/1 transformation and compute C and D. |
1230 | 1230 | $t = unpack('Nl/Nr', $key); |
1231 | 1231 | list($l, $r) = array($t['l'], $t['r']); |
1232 | - $key = ($this->shuffle[$pc1map[ $r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") | |
|
1233 | - ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | |
|
1232 | + $key = ($this->shuffle[$pc1map[$r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") | |
|
1233 | + ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | |
|
1234 | 1234 | ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | |
1235 | 1235 | ($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") | |
1236 | - ($this->shuffle[$pc1map[ $l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | |
|
1237 | - ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | |
|
1236 | + ($this->shuffle[$pc1map[$l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | |
|
1237 | + ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | |
|
1238 | 1238 | ($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") | |
1239 | 1239 | ($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00"); |
1240 | 1240 | $key = unpack('Nc/Nd', $key); |
1241 | - $c = ( $key['c'] >> 4) & 0x0FFFFFFF; |
|
1241 | + $c = ($key['c'] >> 4) & 0x0FFFFFFF; |
|
1242 | 1242 | $d = (($key['d'] >> 4) & 0x0FFFFFF0) | ($key['c'] & 0x0F); |
1243 | 1243 | |
1244 | 1244 | $keys[$des_round] = array( |
1245 | 1245 | self::ENCRYPT => array(), |
1246 | 1246 | self::DECRYPT => array_fill(0, 32, 0) |
1247 | 1247 | ); |
1248 | - for ($i = 0, $ki = 31; $i < 16; ++$i, $ki-= 2) { |
|
1248 | + for ($i = 0, $ki = 31; $i < 16; ++$i, $ki -= 2) { |
|
1249 | 1249 | $c <<= $shifts[$i]; |
1250 | 1250 | $c = ($c | ($c >> 28)) & 0x0FFFFFFF; |
1251 | 1251 | $d <<= $shifts[$i]; |
1252 | 1252 | $d = ($d | ($d >> 28)) & 0x0FFFFFFF; |
1253 | 1253 | |
1254 | 1254 | // Perform the PC-2 transformation. |
1255 | - $cp = $pc2mapc1[ $c >> 24 ] | $pc2mapc2[($c >> 16) & 0xFF] | |
|
1256 | - $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[ $c & 0xFF]; |
|
1257 | - $dp = $pc2mapd1[ $d >> 24 ] | $pc2mapd2[($d >> 16) & 0xFF] | |
|
1258 | - $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[ $d & 0xFF]; |
|
1255 | + $cp = $pc2mapc1[$c >> 24] | $pc2mapc2[($c >> 16) & 0xFF] | |
|
1256 | + $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[$c & 0xFF]; |
|
1257 | + $dp = $pc2mapd1[$d >> 24] | $pc2mapd2[($d >> 16) & 0xFF] | |
|
1258 | + $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[$d & 0xFF]; |
|
1259 | 1259 | |
1260 | 1260 | // Reorder: odd bytes/even bytes. Push the result in key schedule. |
1261 | - $val1 = ( $cp & 0xFF000000) | (($cp << 8) & 0x00FF0000) | |
|
1262 | - (($dp >> 16) & 0x0000FF00) | (($dp >> 8) & 0x000000FF); |
|
1263 | - $val2 = (($cp << 8) & 0xFF000000) | (($cp << 16) & 0x00FF0000) | |
|
1264 | - (($dp >> 8) & 0x0000FF00) | ( $dp & 0x000000FF); |
|
1265 | - $keys[$des_round][self::ENCRYPT][ ] = $val1; |
|
1261 | + $val1 = ($cp & 0xFF000000) | (($cp << 8) & 0x00FF0000) | |
|
1262 | + (($dp >> 16) & 0x0000FF00) | (($dp >> 8) & 0x000000FF); |
|
1263 | + $val2 = (($cp << 8) & 0xFF000000) | (($cp << 16) & 0x00FF0000) | |
|
1264 | + (($dp >> 8) & 0x0000FF00) | ($dp & 0x000000FF); |
|
1265 | + $keys[$des_round][self::ENCRYPT][] = $val1; |
|
1266 | 1266 | $keys[$des_round][self::DECRYPT][$ki - 1] = $val1; |
1267 | - $keys[$des_round][self::ENCRYPT][ ] = $val2; |
|
1268 | - $keys[$des_round][self::DECRYPT][$ki ] = $val2; |
|
1267 | + $keys[$des_round][self::ENCRYPT][] = $val2; |
|
1268 | + $keys[$des_round][self::DECRYPT][$ki] = $val2; |
|
1269 | 1269 | } |
1270 | 1270 | } |
1271 | 1271 | |
@@ -1301,7 +1301,7 @@ discard block |
||
1301 | 1301 | */ |
1302 | 1302 | function _setupInlineCrypt() |
1303 | 1303 | { |
1304 | - $lambda_functions =& self::_getLambdaFunctions(); |
|
1304 | + $lambda_functions = & self::_getLambdaFunctions(); |
|
1305 | 1305 | |
1306 | 1306 | // Engine configuration for: |
1307 | 1307 | // - DES ($des_rounds == 1) or |
@@ -1312,7 +1312,7 @@ discard block |
||
1312 | 1312 | // (Currently, for DES, one generated $lambda_function cost on php5.5@32bit ~135kb unfreeable mem and ~230kb on php5.5@64bit) |
1313 | 1313 | // (Currently, for TripleDES, one generated $lambda_function cost on php5.5@32bit ~240kb unfreeable mem and ~340kb on php5.5@64bit) |
1314 | 1314 | // After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one |
1315 | - $gen_hi_opt_code = (bool)( count($lambda_functions) < 10 ); |
|
1315 | + $gen_hi_opt_code = (bool) (count($lambda_functions) < 10); |
|
1316 | 1316 | |
1317 | 1317 | // Generation of a unique hash for our generated code |
1318 | 1318 | $code_hash = "Crypt_DES, $des_rounds, {$this->mode}"; |
@@ -1322,7 +1322,7 @@ discard block |
||
1322 | 1322 | // After max 10 hi-optimized functions, we create generic |
1323 | 1323 | // (still very fast.. but not ultra) functions for each $mode/$des_rounds |
1324 | 1324 | // Currently 2 * 5 generic functions will be then max. possible. |
1325 | - $code_hash = str_pad($code_hash, 32) . $this->_hashInlineCryptFunction($this->key); |
|
1325 | + $code_hash = str_pad($code_hash, 32).$this->_hashInlineCryptFunction($this->key); |
|
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | // Is there a re-usable $lambda_functions in there? If not, we have to create it. |
@@ -1338,7 +1338,7 @@ discard block |
||
1338 | 1338 | $sbox6 = array_map("intval", $self->sbox6); |
1339 | 1339 | $sbox7 = array_map("intval", $self->sbox7); |
1340 | 1340 | $sbox8 = array_map("intval", $self->sbox8);' |
1341 | - /* Merge $shuffle with $[inv]ipmap */ . ' |
|
1341 | + /* Merge $shuffle with $[inv]ipmap */.' |
|
1342 | 1342 | for ($i = 0; $i < 256; ++$i) { |
1343 | 1343 | $shuffleip[] = $self->shuffle[$self->ipmap[$i]]; |
1344 | 1344 | $shuffleinvip[] = $self->shuffle[$self->invipmap[$i]]; |
@@ -1366,8 +1366,8 @@ discard block |
||
1366 | 1366 | self::DECRYPT => array() |
1367 | 1367 | ); |
1368 | 1368 | for ($i = 0, $c = count($this->keys[self::ENCRYPT]); $i < $c; ++$i) { |
1369 | - $k[self::ENCRYPT][$i] = '$ke[' . $i . ']'; |
|
1370 | - $k[self::DECRYPT][$i] = '$kd[' . $i . ']'; |
|
1369 | + $k[self::ENCRYPT][$i] = '$ke['.$i.']'; |
|
1370 | + $k[self::DECRYPT][$i] = '$kd['.$i.']'; |
|
1371 | 1371 | } |
1372 | 1372 | $init_encrypt = '$ke = $self->keys[self::ENCRYPT];'; |
1373 | 1373 | $init_decrypt = '$kd = $self->keys[self::DECRYPT];'; |
@@ -1407,14 +1407,14 @@ discard block |
||
1407 | 1407 | // start of "the Feistel (F) function" - see the following URL: |
1408 | 1408 | // http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png |
1409 | 1409 | // Merge key schedule. |
1410 | - $crypt_block[$c].= ' |
|
1411 | - $b1 = ((' . $r . ' >> 3) & 0x1FFFFFFF) ^ (' . $r . ' << 29) ^ ' . $k[$c][++$ki] . '; |
|
1412 | - $b2 = ((' . $r . ' >> 31) & 0x00000001) ^ (' . $r . ' << 1) ^ ' . $k[$c][++$ki] . ';' . |
|
1410 | + $crypt_block[$c] .= ' |
|
1411 | + $b1 = ((' . $r.' >> 3) & 0x1FFFFFFF) ^ ('.$r.' << 29) ^ '.$k[$c][++$ki].'; |
|
1412 | + $b2 = ((' . $r.' >> 31) & 0x00000001) ^ ('.$r.' << 1) ^ '.$k[$c][++$ki].';'. |
|
1413 | 1413 | /* S-box indexing. */ |
1414 | - $l . ' = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ |
|
1414 | + $l.' = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ |
|
1415 | 1415 | $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ |
1416 | 1416 | $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ |
1417 | - $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ ' . $l . '; |
|
1417 | + $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ ' . $l.'; |
|
1418 | 1418 | '; |
1419 | 1419 | // end of "the Feistel (F) function" |
1420 | 1420 | |
@@ -1425,7 +1425,7 @@ discard block |
||
1425 | 1425 | } |
1426 | 1426 | |
1427 | 1427 | // Perform the inverse IP permutation. |
1428 | - $crypt_block[$c].= '$in = |
|
1428 | + $crypt_block[$c] .= '$in = |
|
1429 | 1429 | ($shuffleinvip[($l >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | |
1430 | 1430 | ($shuffleinvip[($r >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | |
1431 | 1431 | ($shuffleinvip[($l >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | $n = strrev($n->toBytes()); |
177 | 177 | $e = str_pad(strrev($e->toBytes()), 4, "\0"); |
178 | 178 | $key = pack('aavV', chr(self::PRIVATEKEYBLOB), chr(2), 0, self::CALG_RSA_KEYX); |
179 | - $key.= pack('VVa*', self::RSA2, 8 * strlen($n), $e); |
|
180 | - $key.= $n; |
|
181 | - $key.= strrev($primes[1]->toBytes()); |
|
182 | - $key.= strrev($primes[2]->toBytes()); |
|
183 | - $key.= strrev($exponents[1]->toBytes()); |
|
184 | - $key.= strrev($exponents[2]->toBytes()); |
|
185 | - $key.= strrev($coefficients[1]->toBytes()); |
|
186 | - $key.= strrev($d->toBytes()); |
|
179 | + $key .= pack('VVa*', self::RSA2, 8 * strlen($n), $e); |
|
180 | + $key .= $n; |
|
181 | + $key .= strrev($primes[1]->toBytes()); |
|
182 | + $key .= strrev($primes[2]->toBytes()); |
|
183 | + $key .= strrev($exponents[1]->toBytes()); |
|
184 | + $key .= strrev($exponents[2]->toBytes()); |
|
185 | + $key .= strrev($coefficients[1]->toBytes()); |
|
186 | + $key .= strrev($d->toBytes()); |
|
187 | 187 | |
188 | 188 | return Base64::encode($key); |
189 | 189 | } |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | $n = strrev($n->toBytes()); |
202 | 202 | $e = str_pad(strrev($e->toBytes()), 4, "\0"); |
203 | 203 | $key = pack('aavV', chr(self::PUBLICKEYBLOB), chr(2), 0, self::CALG_RSA_KEYX); |
204 | - $key.= pack('VVa*', self::RSA1, 8 * strlen($n), $e); |
|
205 | - $key.= $n; |
|
204 | + $key .= pack('VVa*', self::RSA1, 8 * strlen($n), $e); |
|
205 | + $key .= $n; |
|
206 | 206 | |
207 | 207 | return Base64::encode($key); |
208 | 208 | } |
@@ -119,15 +119,15 @@ discard block |
||
119 | 119 | return false; |
120 | 120 | } |
121 | 121 | return "<RSAKeyValue>\r\n" . |
122 | - ' <Modulus>' . Base64::encode($n->toBytes()) . "</Modulus>\r\n" . |
|
123 | - ' <Exponent>' . Base64::encode($e->toBytes()) . "</Exponent>\r\n" . |
|
124 | - ' <P>' . Base64::encode($primes[1]->toBytes()) . "</P>\r\n" . |
|
125 | - ' <Q>' . Base64::encode($primes[2]->toBytes()) . "</Q>\r\n" . |
|
126 | - ' <DP>' . Base64::encode($exponents[1]->toBytes()) . "</DP>\r\n" . |
|
127 | - ' <DQ>' . Base64::encode($exponents[2]->toBytes()) . "</DQ>\r\n" . |
|
128 | - ' <InverseQ>' . Base64::encode($coefficients[2]->toBytes()) . "</InverseQ>\r\n" . |
|
129 | - ' <D>' . Base64::encode($d->toBytes()) . "</D>\r\n" . |
|
130 | - '</RSAKeyValue>'; |
|
122 | + ' <Modulus>' . Base64::encode($n->toBytes()) . "</Modulus>\r\n" . |
|
123 | + ' <Exponent>' . Base64::encode($e->toBytes()) . "</Exponent>\r\n" . |
|
124 | + ' <P>' . Base64::encode($primes[1]->toBytes()) . "</P>\r\n" . |
|
125 | + ' <Q>' . Base64::encode($primes[2]->toBytes()) . "</Q>\r\n" . |
|
126 | + ' <DP>' . Base64::encode($exponents[1]->toBytes()) . "</DP>\r\n" . |
|
127 | + ' <DQ>' . Base64::encode($exponents[2]->toBytes()) . "</DQ>\r\n" . |
|
128 | + ' <InverseQ>' . Base64::encode($coefficients[2]->toBytes()) . "</InverseQ>\r\n" . |
|
129 | + ' <D>' . Base64::encode($d->toBytes()) . "</D>\r\n" . |
|
130 | + '</RSAKeyValue>'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | static function savePublicKey(BigInteger $n, BigInteger $e) |
142 | 142 | { |
143 | 143 | return "<RSAKeyValue>\r\n" . |
144 | - ' <Modulus>' . Base64::encode($n->toBytes()) . "</Modulus>\r\n" . |
|
145 | - ' <Exponent>' . Base64::encode($e->toBytes()) . "</Exponent>\r\n" . |
|
146 | - '</RSAKeyValue>'; |
|
144 | + ' <Modulus>' . Base64::encode($n->toBytes()) . "</Modulus>\r\n" . |
|
145 | + ' <Exponent>' . Base64::encode($e->toBytes()) . "</Exponent>\r\n" . |
|
146 | + '</RSAKeyValue>'; |
|
147 | 147 | } |
148 | 148 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $use_errors = libxml_use_internal_errors(true); |
57 | 57 | |
58 | 58 | $dom = new \DOMDocument(); |
59 | - if (!$dom->loadXML('<xml>' . $key . '</xml>')) { |
|
59 | + if (!$dom->loadXML('<xml>'.$key.'</xml>')) { |
|
60 | 60 | return false; |
61 | 61 | } |
62 | 62 | $xpath = new \DOMXPath($dom); |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | if (count($primes) != 2) { |
119 | 119 | return false; |
120 | 120 | } |
121 | - return "<RSAKeyValue>\r\n" . |
|
122 | - ' <Modulus>' . Base64::encode($n->toBytes()) . "</Modulus>\r\n" . |
|
123 | - ' <Exponent>' . Base64::encode($e->toBytes()) . "</Exponent>\r\n" . |
|
124 | - ' <P>' . Base64::encode($primes[1]->toBytes()) . "</P>\r\n" . |
|
125 | - ' <Q>' . Base64::encode($primes[2]->toBytes()) . "</Q>\r\n" . |
|
126 | - ' <DP>' . Base64::encode($exponents[1]->toBytes()) . "</DP>\r\n" . |
|
127 | - ' <DQ>' . Base64::encode($exponents[2]->toBytes()) . "</DQ>\r\n" . |
|
128 | - ' <InverseQ>' . Base64::encode($coefficients[2]->toBytes()) . "</InverseQ>\r\n" . |
|
129 | - ' <D>' . Base64::encode($d->toBytes()) . "</D>\r\n" . |
|
121 | + return "<RSAKeyValue>\r\n". |
|
122 | + ' <Modulus>'.Base64::encode($n->toBytes())."</Modulus>\r\n". |
|
123 | + ' <Exponent>'.Base64::encode($e->toBytes())."</Exponent>\r\n". |
|
124 | + ' <P>'.Base64::encode($primes[1]->toBytes())."</P>\r\n". |
|
125 | + ' <Q>'.Base64::encode($primes[2]->toBytes())."</Q>\r\n". |
|
126 | + ' <DP>'.Base64::encode($exponents[1]->toBytes())."</DP>\r\n". |
|
127 | + ' <DQ>'.Base64::encode($exponents[2]->toBytes())."</DQ>\r\n". |
|
128 | + ' <InverseQ>'.Base64::encode($coefficients[2]->toBytes())."</InverseQ>\r\n". |
|
129 | + ' <D>'.Base64::encode($d->toBytes())."</D>\r\n". |
|
130 | 130 | '</RSAKeyValue>'; |
131 | 131 | } |
132 | 132 | |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | */ |
141 | 141 | static function savePublicKey(BigInteger $n, BigInteger $e) |
142 | 142 | { |
143 | - return "<RSAKeyValue>\r\n" . |
|
144 | - ' <Modulus>' . Base64::encode($n->toBytes()) . "</Modulus>\r\n" . |
|
145 | - ' <Exponent>' . Base64::encode($e->toBytes()) . "</Exponent>\r\n" . |
|
143 | + return "<RSAKeyValue>\r\n". |
|
144 | + ' <Modulus>'.Base64::encode($n->toBytes())."</Modulus>\r\n". |
|
145 | + ' <Exponent>'.Base64::encode($e->toBytes())."</Exponent>\r\n". |
|
146 | 146 | '</RSAKeyValue>'; |
147 | 147 | } |
148 | 148 | } |
@@ -150,12 +150,12 @@ |
||
150 | 150 | $RSAPrivateKey = pack('Ca*a*', self::ASN1_SEQUENCE, ASN1::encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey); |
151 | 151 | |
152 | 152 | $RSAPrivateKey = "-----BEGIN ENCRYPTED PRIVATE KEY-----\r\n" . |
153 | - chunk_split(Base64::encode($RSAPrivateKey), 64) . |
|
154 | - '-----END ENCRYPTED PRIVATE KEY-----'; |
|
153 | + chunk_split(Base64::encode($RSAPrivateKey), 64) . |
|
154 | + '-----END ENCRYPTED PRIVATE KEY-----'; |
|
155 | 155 | } else { |
156 | 156 | $RSAPrivateKey = "-----BEGIN PRIVATE KEY-----\r\n" . |
157 | - chunk_split(Base64::encode($RSAPrivateKey), 64) . |
|
158 | - '-----END PRIVATE KEY-----'; |
|
157 | + chunk_split(Base64::encode($RSAPrivateKey), 64) . |
|
158 | + '-----END PRIVATE KEY-----'; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return $RSAPrivateKey; |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | // coefficient INTEGER -- ti |
89 | 89 | // } |
90 | 90 | $OtherPrimeInfo = pack('Ca*a*', self::ASN1_INTEGER, ASN1::encodeLength(strlen($primes[$i]->toBytes(true))), $primes[$i]->toBytes(true)); |
91 | - $OtherPrimeInfo.= pack('Ca*a*', self::ASN1_INTEGER, ASN1::encodeLength(strlen($exponents[$i]->toBytes(true))), $exponents[$i]->toBytes(true)); |
|
92 | - $OtherPrimeInfo.= pack('Ca*a*', self::ASN1_INTEGER, ASN1::encodeLength(strlen($coefficients[$i]->toBytes(true))), $coefficients[$i]->toBytes(true)); |
|
93 | - $OtherPrimeInfos.= pack('Ca*a*', self::ASN1_SEQUENCE, ASN1::encodeLength(strlen($OtherPrimeInfo)), $OtherPrimeInfo); |
|
91 | + $OtherPrimeInfo .= pack('Ca*a*', self::ASN1_INTEGER, ASN1::encodeLength(strlen($exponents[$i]->toBytes(true))), $exponents[$i]->toBytes(true)); |
|
92 | + $OtherPrimeInfo .= pack('Ca*a*', self::ASN1_INTEGER, ASN1::encodeLength(strlen($coefficients[$i]->toBytes(true))), $coefficients[$i]->toBytes(true)); |
|
93 | + $OtherPrimeInfos .= pack('Ca*a*', self::ASN1_SEQUENCE, ASN1::encodeLength(strlen($OtherPrimeInfo)), $OtherPrimeInfo); |
|
94 | 94 | } |
95 | - $RSAPrivateKey.= pack('Ca*a*', self::ASN1_SEQUENCE, ASN1::encodeLength(strlen($OtherPrimeInfos)), $OtherPrimeInfos); |
|
95 | + $RSAPrivateKey .= pack('Ca*a*', self::ASN1_SEQUENCE, ASN1::encodeLength(strlen($OtherPrimeInfos)), $OtherPrimeInfos); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $RSAPrivateKey = pack('Ca*a*', self::ASN1_SEQUENCE, ASN1::encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey); |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | |
150 | 150 | $RSAPrivateKey = pack('Ca*a*', self::ASN1_SEQUENCE, ASN1::encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey); |
151 | 151 | |
152 | - $RSAPrivateKey = "-----BEGIN ENCRYPTED PRIVATE KEY-----\r\n" . |
|
153 | - chunk_split(Base64::encode($RSAPrivateKey), 64) . |
|
152 | + $RSAPrivateKey = "-----BEGIN ENCRYPTED PRIVATE KEY-----\r\n". |
|
153 | + chunk_split(Base64::encode($RSAPrivateKey), 64). |
|
154 | 154 | '-----END ENCRYPTED PRIVATE KEY-----'; |
155 | 155 | } else { |
156 | - $RSAPrivateKey = "-----BEGIN PRIVATE KEY-----\r\n" . |
|
157 | - chunk_split(Base64::encode($RSAPrivateKey), 64) . |
|
156 | + $RSAPrivateKey = "-----BEGIN PRIVATE KEY-----\r\n". |
|
157 | + chunk_split(Base64::encode($RSAPrivateKey), 64). |
|
158 | 158 | '-----END PRIVATE KEY-----'; |
159 | 159 | } |
160 | 160 | |
@@ -194,18 +194,18 @@ discard block |
||
194 | 194 | |
195 | 195 | // sequence(oid(1.2.840.113549.1.1.1), null)) = rsaEncryption. |
196 | 196 | $rsaOID = "\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00"; // hex version of MA0GCSqGSIb3DQEBAQUA |
197 | - $RSAPublicKey = chr(0) . $RSAPublicKey; |
|
198 | - $RSAPublicKey = chr(3) . ASN1::encodeLength(strlen($RSAPublicKey)) . $RSAPublicKey; |
|
197 | + $RSAPublicKey = chr(0).$RSAPublicKey; |
|
198 | + $RSAPublicKey = chr(3).ASN1::encodeLength(strlen($RSAPublicKey)).$RSAPublicKey; |
|
199 | 199 | |
200 | 200 | $RSAPublicKey = pack( |
201 | 201 | 'Ca*a*', |
202 | 202 | self::ASN1_SEQUENCE, |
203 | - ASN1::encodeLength(strlen($rsaOID . $RSAPublicKey)), |
|
204 | - $rsaOID . $RSAPublicKey |
|
203 | + ASN1::encodeLength(strlen($rsaOID.$RSAPublicKey)), |
|
204 | + $rsaOID.$RSAPublicKey |
|
205 | 205 | ); |
206 | 206 | |
207 | - $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . |
|
208 | - chunk_split(Base64::encode($RSAPublicKey), 64) . |
|
207 | + $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n". |
|
208 | + chunk_split(Base64::encode($RSAPublicKey), 64). |
|
209 | 209 | '-----END PUBLIC KEY-----'; |
210 | 210 | |
211 | 211 | return $RSAPublicKey; |
@@ -119,7 +119,7 @@ |
||
119 | 119 | // mpint e |
120 | 120 | // mpint n |
121 | 121 | $RSAPublicKey = pack('Na*Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publicExponent), $publicExponent, strlen($modulus), $modulus); |
122 | - $RSAPublicKey = 'ssh-rsa ' . Base64::encode($RSAPublicKey) . ' ' . self::$comment; |
|
122 | + $RSAPublicKey = 'ssh-rsa '.Base64::encode($RSAPublicKey).' '.self::$comment; |
|
123 | 123 | |
124 | 124 | return $RSAPublicKey; |
125 | 125 | } |
@@ -693,9 +693,9 @@ |
||
693 | 693 | // Creates the inline-crypt function |
694 | 694 | $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( |
695 | 695 | array( |
696 | - 'init_crypt' => $init_crypt, |
|
697 | - 'encrypt_block' => $encrypt_block, |
|
698 | - 'decrypt_block' => $decrypt_block |
|
696 | + 'init_crypt' => $init_crypt, |
|
697 | + 'encrypt_block' => $encrypt_block, |
|
698 | + 'decrypt_block' => $decrypt_block |
|
699 | 699 | ) |
700 | 700 | ); |
701 | 701 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | return false; |
296 | 296 | } |
297 | 297 | $this->cipher_name_openssl_ecb = 'rc2-ecb'; |
298 | - $this->cipher_name_openssl = 'rc2-' . $this->_openssl_translate_mode(); |
|
298 | + $this->cipher_name_openssl = 'rc2-'.$this->_openssl_translate_mode(); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | return parent::isValidEngine($engine); |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | function setKeyLength($length) |
316 | 316 | { |
317 | 317 | if ($length < 8 || $length > 1024) { |
318 | - throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys between 1 and 1024 bits, inclusive, are supported'); |
|
318 | + throw new \LengthException('Key size of '.$length.' bits is not supported by this algorithm. Only keys between 1 and 1024 bits, inclusive, are supported'); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | $this->default_key_length = $this->current_key_length = $length; |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | } |
359 | 359 | |
360 | 360 | if ($t1 < 1 || $t1 > 1024) { |
361 | - throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys between 1 and 1024 bits, inclusive, are supported'); |
|
361 | + throw new \LengthException('Key size of '.$length.' bits is not supported by this algorithm. Only keys between 1 and 1024 bits, inclusive, are supported'); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | $this->current_key_length = $t1; |
@@ -575,18 +575,18 @@ discard block |
||
575 | 575 | */ |
576 | 576 | function _setupInlineCrypt() |
577 | 577 | { |
578 | - $lambda_functions =& self::_getLambdaFunctions(); |
|
578 | + $lambda_functions = & self::_getLambdaFunctions(); |
|
579 | 579 | |
580 | 580 | // The first 10 generated $lambda_functions will use the $keys hardcoded as integers |
581 | 581 | // for the mixing rounds, for better inline crypt performance [~20% faster]. |
582 | 582 | // But for memory reason we have to limit those ultra-optimized $lambda_functions to an amount of 10. |
583 | 583 | // (Currently, for Crypt_RC2, one generated $lambda_function cost on php5.5@32bit ~60kb unfreeable mem and ~100kb on php5.5@64bit) |
584 | - $gen_hi_opt_code = (bool)(count($lambda_functions) < 10); |
|
584 | + $gen_hi_opt_code = (bool) (count($lambda_functions) < 10); |
|
585 | 585 | |
586 | 586 | // Generation of a unique hash for our generated code |
587 | 587 | $code_hash = "Crypt_RC2, {$this->mode}"; |
588 | 588 | if ($gen_hi_opt_code) { |
589 | - $code_hash = str_pad($code_hash, 32) . $this->_hashInlineCryptFunction($this->key); |
|
589 | + $code_hash = str_pad($code_hash, 32).$this->_hashInlineCryptFunction($this->key); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | // Is there a re-usable $lambda_functions in there? |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | default: |
602 | 602 | $keys = array(); |
603 | 603 | foreach ($this->keys as $k => $v) { |
604 | - $keys[$k] = '$keys[' . $k . ']'; |
|
604 | + $keys[$k] = '$keys['.$k.']'; |
|
605 | 605 | } |
606 | 606 | } |
607 | 607 | |
@@ -622,16 +622,16 @@ discard block |
||
622 | 622 | for (;;) { |
623 | 623 | // Mixing round. |
624 | 624 | $encrypt_block .= ' |
625 | - $r0 = (($r0 + ' . $keys[$j++] . ' + |
|
625 | + $r0 = (($r0 + ' . $keys[$j++].' + |
|
626 | 626 | ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF) << 1; |
627 | 627 | $r0 |= $r0 >> 16; |
628 | - $r1 = (($r1 + ' . $keys[$j++] . ' + |
|
628 | + $r1 = (($r1 + ' . $keys[$j++].' + |
|
629 | 629 | ((($r2 ^ $r3) & $r0) ^ $r2)) & 0xFFFF) << 2; |
630 | 630 | $r1 |= $r1 >> 16; |
631 | - $r2 = (($r2 + ' . $keys[$j++] . ' + |
|
631 | + $r2 = (($r2 + ' . $keys[$j++].' + |
|
632 | 632 | ((($r3 ^ $r0) & $r1) ^ $r3)) & 0xFFFF) << 3; |
633 | 633 | $r2 |= $r2 >> 16; |
634 | - $r3 = (($r3 + ' . $keys[$j++] . ' + |
|
634 | + $r3 = (($r3 + ' . $keys[$j++].' + |
|
635 | 635 | ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF) << 5; |
636 | 636 | $r3 |= $r3 >> 16;'; |
637 | 637 | |
@@ -661,16 +661,16 @@ discard block |
||
661 | 661 | // R-mixing round. |
662 | 662 | $decrypt_block .= ' |
663 | 663 | $r3 = ($r3 | ($r3 << 16)) >> 5; |
664 | - $r3 = ($r3 - ' . $keys[--$j] . ' - |
|
664 | + $r3 = ($r3 - ' . $keys[--$j].' - |
|
665 | 665 | ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF; |
666 | 666 | $r2 = ($r2 | ($r2 << 16)) >> 3; |
667 | - $r2 = ($r2 - ' . $keys[--$j] . ' - |
|
667 | + $r2 = ($r2 - ' . $keys[--$j].' - |
|
668 | 668 | ((($r3 ^ $r0) & $r1) ^ $r3)) & 0xFFFF; |
669 | 669 | $r1 = ($r1 | ($r1 << 16)) >> 2; |
670 | - $r1 = ($r1 - ' . $keys[--$j] . ' - |
|
670 | + $r1 = ($r1 - ' . $keys[--$j].' - |
|
671 | 671 | ((($r2 ^ $r3) & $r0) ^ $r2)) & 0xFFFF; |
672 | 672 | $r0 = ($r0 | ($r0 << 16)) >> 1; |
673 | - $r0 = ($r0 - ' . $keys[--$j] . ' - |
|
673 | + $r0 = ($r0 - ' . $keys[--$j].' - |
|
674 | 674 | ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF;'; |
675 | 675 | |
676 | 676 | if ($j === $limit) { |
@@ -96,12 +96,12 @@ |
||
96 | 96 | session_start(); |
97 | 97 | |
98 | 98 | $v = (isset($_SERVER) ? self::safe_serialize($_SERVER) : '') . |
99 | - (isset($_POST) ? self::safe_serialize($_POST) : '') . |
|
100 | - (isset($_GET) ? self::safe_serialize($_GET) : '') . |
|
101 | - (isset($_COOKIE) ? self::safe_serialize($_COOKIE) : '') . |
|
102 | - self::safe_serialize($GLOBALS) . |
|
103 | - self::safe_serialize($_SESSION) . |
|
104 | - self::safe_serialize($_OLD_SESSION); |
|
99 | + (isset($_POST) ? self::safe_serialize($_POST) : '') . |
|
100 | + (isset($_GET) ? self::safe_serialize($_GET) : '') . |
|
101 | + (isset($_COOKIE) ? self::safe_serialize($_COOKIE) : '') . |
|
102 | + self::safe_serialize($GLOBALS) . |
|
103 | + self::safe_serialize($_SESSION) . |
|
104 | + self::safe_serialize($_OLD_SESSION); |
|
105 | 105 | $v = $seed = $_SESSION['seed'] = sha1($v, true); |
106 | 106 | if (!isset($_SESSION['count'])) { |
107 | 107 | $_SESSION['count'] = 0; |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | session_cache_limiter(''); |
96 | 96 | session_start(); |
97 | 97 | |
98 | - $v = (isset($_SERVER) ? self::safe_serialize($_SERVER) : '') . |
|
99 | - (isset($_POST) ? self::safe_serialize($_POST) : '') . |
|
100 | - (isset($_GET) ? self::safe_serialize($_GET) : '') . |
|
101 | - (isset($_COOKIE) ? self::safe_serialize($_COOKIE) : '') . |
|
102 | - self::safe_serialize($GLOBALS) . |
|
103 | - self::safe_serialize($_SESSION) . |
|
98 | + $v = (isset($_SERVER) ? self::safe_serialize($_SERVER) : ''). |
|
99 | + (isset($_POST) ? self::safe_serialize($_POST) : ''). |
|
100 | + (isset($_GET) ? self::safe_serialize($_GET) : ''). |
|
101 | + (isset($_COOKIE) ? self::safe_serialize($_COOKIE) : ''). |
|
102 | + self::safe_serialize($GLOBALS). |
|
103 | + self::safe_serialize($_SESSION). |
|
104 | 104 | self::safe_serialize($_OLD_SESSION); |
105 | 105 | $v = $seed = $_SESSION['seed'] = sha1($v, true); |
106 | 106 | if (!isset($_SESSION['count'])) { |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | // http://tools.ietf.org/html/rfc4253#section-7.2 |
134 | 134 | // |
135 | 135 | // see the is_string($crypto) part for an example of how to expand the keys |
136 | - $key = sha1($seed . 'A', true); |
|
137 | - $iv = sha1($seed . 'C', true); |
|
136 | + $key = sha1($seed.'A', true); |
|
137 | + $iv = sha1($seed.'C', true); |
|
138 | 138 | |
139 | 139 | // ciphers are used as per the nist.gov link below. also, see this link: |
140 | 140 | // |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $crypto = new RC4(); |
160 | 160 | break; |
161 | 161 | default: |
162 | - throw new \RuntimeException(__CLASS__ . ' requires at least one symmetric cipher be loaded'); |
|
162 | + throw new \RuntimeException(__CLASS__.' requires at least one symmetric cipher be loaded'); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | $crypto->setKey(substr($key, 0, $crypto->getKeyLength() >> 3)); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $i = $crypto->encrypt(microtime()); // strlen(microtime()) == 21 |
183 | 183 | $r = $crypto->encrypt($i ^ $v); // strlen($v) == 20 |
184 | 184 | $v = $crypto->encrypt($r ^ $i); // strlen($r) == 20 |
185 | - $result.= $r; |
|
185 | + $result .= $r; |
|
186 | 186 | } |
187 | 187 | return substr($result, 0, $length); |
188 | 188 | } |
@@ -372,9 +372,9 @@ discard block |
||
372 | 372 | // subWord |
373 | 373 | for ($i = 0; $i < $Nb; ++$i) { |
374 | 374 | $state[$i] = $sbox[$state[$i] & 0x000000FF] | |
375 | - ($sbox[$state[$i] >> 8 & 0x000000FF] << 8) | |
|
376 | - ($sbox[$state[$i] >> 16 & 0x000000FF] << 16) | |
|
377 | - ($sbox[$state[$i] >> 24 & 0x000000FF] << 24); |
|
375 | + ($sbox[$state[$i] >> 8 & 0x000000FF] << 8) | |
|
376 | + ($sbox[$state[$i] >> 16 & 0x000000FF] << 16) | |
|
377 | + ($sbox[$state[$i] >> 24 & 0x000000FF] << 24); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | // shiftRows + addRoundKey |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | ($state[$j] & 0x00FF0000) ^ |
388 | 388 | ($state[$k] & 0x0000FF00) ^ |
389 | 389 | ($state[$l] & 0x000000FF) ^ |
390 | - $w[$i]; |
|
390 | + $w[$i]; |
|
391 | 391 | ++$i; |
392 | 392 | $j = ($j + 1) % $Nb; |
393 | 393 | $k = ($k + 1) % $Nb; |
@@ -475,9 +475,9 @@ discard block |
||
475 | 475 | ($state[$l] & 0x000000FF); |
476 | 476 | |
477 | 477 | $temp[$i] = $dw[$i] ^ ($isbox[$word & 0x000000FF] | |
478 | - ($isbox[$word >> 8 & 0x000000FF] << 8) | |
|
479 | - ($isbox[$word >> 16 & 0x000000FF] << 16) | |
|
480 | - ($isbox[$word >> 24 & 0x000000FF] << 24)); |
|
478 | + ($isbox[$word >> 8 & 0x000000FF] << 8) | |
|
479 | + ($isbox[$word >> 16 & 0x000000FF] << 16) | |
|
480 | + ($isbox[$word >> 24 & 0x000000FF] << 24)); |
|
481 | 481 | ++$i; |
482 | 482 | $j = ($j + 1) % $Nb; |
483 | 483 | $k = ($k + 1) % $Nb; |
@@ -625,9 +625,9 @@ discard block |
||
625 | 625 | } |
626 | 626 | |
627 | 627 | return $sbox[$word & 0x000000FF] | |
628 | - ($sbox[$word >> 8 & 0x000000FF] << 8) | |
|
629 | - ($sbox[$word >> 16 & 0x000000FF] << 16) | |
|
630 | - ($sbox[$word >> 24 & 0x000000FF] << 24); |
|
628 | + ($sbox[$word >> 8 & 0x000000FF] << 8) | |
|
629 | + ($sbox[$word >> 16 & 0x000000FF] << 16) | |
|
630 | + ($sbox[$word >> 24 & 0x000000FF] << 24); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | /** |
@@ -966,11 +966,11 @@ discard block |
||
966 | 966 | |
967 | 967 | $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( |
968 | 968 | array( |
969 | - 'init_crypt' => '', |
|
970 | - 'init_encrypt' => $init_encrypt, |
|
971 | - 'init_decrypt' => $init_decrypt, |
|
972 | - 'encrypt_block' => $encrypt_block, |
|
973 | - 'decrypt_block' => $decrypt_block |
|
969 | + 'init_crypt' => '', |
|
970 | + 'init_encrypt' => $init_encrypt, |
|
971 | + 'init_decrypt' => $init_decrypt, |
|
972 | + 'encrypt_block' => $encrypt_block, |
|
973 | + 'decrypt_block' => $decrypt_block |
|
974 | 974 | ) |
975 | 975 | ); |
976 | 976 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $this->key_length = $length >> 3; |
218 | 218 | break; |
219 | 219 | default: |
220 | - throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys of sizes 128, 160, 192, 224 or 256 bits are supported'); |
|
220 | + throw new \LengthException('Key size of '.$length.' bits is not supported by this algorithm. Only keys of sizes 128, 160, 192, 224 or 256 bits are supported'); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | parent::setKeyLength($length); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | case 32: |
244 | 244 | break; |
245 | 245 | default: |
246 | - throw new \LengthException('Key of size ' . strlen($key) . ' not supported by this algorithm. Only keys of sizes 16, 20, 24, 28 or 32 are supported'); |
|
246 | + throw new \LengthException('Key of size '.strlen($key).' not supported by this algorithm. Only keys of sizes 16, 20, 24, 28 or 32 are supported'); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | parent::setKey($key); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | case 256: |
268 | 268 | break; |
269 | 269 | default: |
270 | - throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys of sizes 128, 160, 192, 224 or 256 bits are supported'); |
|
270 | + throw new \LengthException('Key size of '.$length.' bits is not supported by this algorithm. Only keys of sizes 128, 160, 192, 224 or 256 bits are supported'); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | $this->Nb = $length >> 5; |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | if ($this->block_size != 16) { |
294 | 294 | return false; |
295 | 295 | } |
296 | - $this->cipher_name_openssl_ecb = 'aes-' . ($this->key_length << 3) . '-ecb'; |
|
297 | - $this->cipher_name_openssl = 'aes-' . ($this->key_length << 3) . '-' . $this->_openssl_translate_mode(); |
|
296 | + $this->cipher_name_openssl_ecb = 'aes-'.($this->key_length << 3).'-ecb'; |
|
297 | + $this->cipher_name_openssl = 'aes-'.($this->key_length << 3).'-'.$this->_openssl_translate_mode(); |
|
298 | 298 | break; |
299 | 299 | case self::ENGINE_MCRYPT: |
300 | - $this->cipher_name_mcrypt = 'rijndael-' . ($this->block_size << 3); |
|
300 | + $this->cipher_name_mcrypt = 'rijndael-'.($this->block_size << 3); |
|
301 | 301 | if ($this->key_length % 8) { // is it a 160/224-bit key? |
302 | 302 | // mcrypt is not usable for them, only for 128/192/256-bit keys |
303 | 303 | return false; |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | while ($i < $Nb) { |
359 | 359 | $temp[$i] = $t0[$state[$i] >> 24 & 0x000000FF] ^ |
360 | 360 | $t1[$state[$j] >> 16 & 0x000000FF] ^ |
361 | - $t2[$state[$k] >> 8 & 0x000000FF] ^ |
|
362 | - $t3[$state[$l] & 0x000000FF] ^ |
|
361 | + $t2[$state[$k] >> 8 & 0x000000FF] ^ |
|
362 | + $t3[$state[$l] & 0x000000FF] ^ |
|
363 | 363 | $w[++$wc]; |
364 | 364 | ++$i; |
365 | 365 | $j = ($j + 1) % $Nb; |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | |
372 | 372 | // subWord |
373 | 373 | for ($i = 0; $i < $Nb; ++$i) { |
374 | - $state[$i] = $sbox[$state[$i] & 0x000000FF] | |
|
375 | - ($sbox[$state[$i] >> 8 & 0x000000FF] << 8) | |
|
374 | + $state[$i] = $sbox[$state[$i] & 0x000000FF] | |
|
375 | + ($sbox[$state[$i] >> 8 & 0x000000FF] << 8) | |
|
376 | 376 | ($sbox[$state[$i] >> 16 & 0x000000FF] << 16) | |
377 | 377 | ($sbox[$state[$i] >> 24 & 0x000000FF] << 24); |
378 | 378 | } |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | while ($i < $Nb) { |
452 | 452 | $temp[$i] = $dt0[$state[$i] >> 24 & 0x000000FF] ^ |
453 | 453 | $dt1[$state[$j] >> 16 & 0x000000FF] ^ |
454 | - $dt2[$state[$k] >> 8 & 0x000000FF] ^ |
|
455 | - $dt3[$state[$l] & 0x000000FF] ^ |
|
454 | + $dt2[$state[$k] >> 8 & 0x000000FF] ^ |
|
455 | + $dt3[$state[$l] & 0x000000FF] ^ |
|
456 | 456 | $dw[++$wc]; |
457 | 457 | ++$i; |
458 | 458 | $j = ($j + 1) % $Nb; |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | ($state[$k] & 0x0000FF00) | |
475 | 475 | ($state[$l] & 0x000000FF); |
476 | 476 | |
477 | - $temp[$i] = $dw[$i] ^ ($isbox[$word & 0x000000FF] | |
|
478 | - ($isbox[$word >> 8 & 0x000000FF] << 8) | |
|
477 | + $temp[$i] = $dw[$i] ^ ($isbox[$word & 0x000000FF] | |
|
478 | + ($isbox[$word >> 8 & 0x000000FF] << 8) | |
|
479 | 479 | ($isbox[$word >> 16 & 0x000000FF] << 16) | |
480 | 480 | ($isbox[$word >> 24 & 0x000000FF] << 24)); |
481 | 481 | ++$i; |
@@ -582,8 +582,8 @@ discard block |
||
582 | 582 | $dw = $this->_subWord($this->w[$row][$j]); |
583 | 583 | $temp[$j] = $dt0[$dw >> 24 & 0x000000FF] ^ |
584 | 584 | $dt1[$dw >> 16 & 0x000000FF] ^ |
585 | - $dt2[$dw >> 8 & 0x000000FF] ^ |
|
586 | - $dt3[$dw & 0x000000FF]; |
|
585 | + $dt2[$dw >> 8 & 0x000000FF] ^ |
|
586 | + $dt3[$dw & 0x000000FF]; |
|
587 | 587 | $j++; |
588 | 588 | } |
589 | 589 | $this->dw[$row] = $temp; |
@@ -621,11 +621,11 @@ discard block |
||
621 | 621 | { |
622 | 622 | static $sbox; |
623 | 623 | if (empty($sbox)) { |
624 | - list(, , , , $sbox) = $this->_getTables(); |
|
624 | + list(,,,, $sbox) = $this->_getTables(); |
|
625 | 625 | } |
626 | 626 | |
627 | - return $sbox[$word & 0x000000FF] | |
|
628 | - ($sbox[$word >> 8 & 0x000000FF] << 8) | |
|
627 | + return $sbox[$word & 0x000000FF] | |
|
628 | + ($sbox[$word >> 8 & 0x000000FF] << 8) | |
|
629 | 629 | ($sbox[$word >> 16 & 0x000000FF] << 16) | |
630 | 630 | ($sbox[$word >> 24 & 0x000000FF] << 24); |
631 | 631 | } |
@@ -684,9 +684,9 @@ discard block |
||
684 | 684 | )); |
685 | 685 | |
686 | 686 | foreach ($t3 as $t3i) { |
687 | - $t0[] = (($t3i << 24) & 0xFF000000) | (($t3i >> 8) & 0x00FFFFFF); |
|
687 | + $t0[] = (($t3i << 24) & 0xFF000000) | (($t3i >> 8) & 0x00FFFFFF); |
|
688 | 688 | $t1[] = (($t3i << 16) & 0xFFFF0000) | (($t3i >> 16) & 0x0000FFFF); |
689 | - $t2[] = (($t3i << 8) & 0xFFFFFF00) | (($t3i >> 24) & 0x000000FF); |
|
689 | + $t2[] = (($t3i << 8) & 0xFFFFFF00) | (($t3i >> 24) & 0x000000FF); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | $tables = array( |
@@ -768,9 +768,9 @@ discard block |
||
768 | 768 | )); |
769 | 769 | |
770 | 770 | foreach ($dt3 as $dt3i) { |
771 | - $dt0[] = (($dt3i << 24) & 0xFF000000) | (($dt3i >> 8) & 0x00FFFFFF); |
|
771 | + $dt0[] = (($dt3i << 24) & 0xFF000000) | (($dt3i >> 8) & 0x00FFFFFF); |
|
772 | 772 | $dt1[] = (($dt3i << 16) & 0xFFFF0000) | (($dt3i >> 16) & 0x0000FFFF); |
773 | - $dt2[] = (($dt3i << 8) & 0xFFFFFF00) | (($dt3i >> 24) & 0x000000FF); |
|
773 | + $dt2[] = (($dt3i << 8) & 0xFFFFFF00) | (($dt3i >> 24) & 0x000000FF); |
|
774 | 774 | }; |
775 | 775 | |
776 | 776 | $tables = array( |
@@ -815,17 +815,17 @@ discard block |
||
815 | 815 | // So here we are'nt under the same heavy timing-stress as we are in _de/encryptBlock() or de/encrypt(). |
816 | 816 | // However...the here generated function- $code, stored as php callback in $this->inline_crypt, must work as fast as even possible. |
817 | 817 | |
818 | - $lambda_functions =& self::_getLambdaFunctions(); |
|
818 | + $lambda_functions = & self::_getLambdaFunctions(); |
|
819 | 819 | |
820 | 820 | // We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function. |
821 | 821 | // (Currently, for Crypt_Rijndael/AES, one generated $lambda_function cost on php5.5@32bit ~80kb unfreeable mem and ~130kb on php5.5@64bit) |
822 | 822 | // After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one. |
823 | - $gen_hi_opt_code = (bool)(count($lambda_functions) < 10); |
|
823 | + $gen_hi_opt_code = (bool) (count($lambda_functions) < 10); |
|
824 | 824 | |
825 | 825 | // Generation of a uniqe hash for our generated code |
826 | 826 | $code_hash = "Crypt_Rijndael, {$this->mode}, {$this->Nr}, {$this->Nb}"; |
827 | 827 | if ($gen_hi_opt_code) { |
828 | - $code_hash = str_pad($code_hash, 32) . $this->_hashInlineCryptFunction($this->key); |
|
828 | + $code_hash = str_pad($code_hash, 32).$this->_hashInlineCryptFunction($this->key); |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | if (!isset($lambda_functions[$code_hash])) { |
@@ -839,8 +839,8 @@ discard block |
||
839 | 839 | break; |
840 | 840 | default: |
841 | 841 | for ($i = 0, $cw = count($this->w); $i < $cw; ++$i) { |
842 | - $w[] = '$w[' . $i . ']'; |
|
843 | - $dw[] = '$dw[' . $i . ']'; |
|
842 | + $w[] = '$w['.$i.']'; |
|
843 | + $dw[] = '$dw['.$i.']'; |
|
844 | 844 | } |
845 | 845 | $init_encrypt = '$w = $self->w;'; |
846 | 846 | $init_decrypt = '$dw = $self->dw;'; |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | $c = $this->c; |
852 | 852 | |
853 | 853 | // Generating encrypt code: |
854 | - $init_encrypt.= ' |
|
854 | + $init_encrypt .= ' |
|
855 | 855 | static $tables; |
856 | 856 | if (empty($tables)) { |
857 | 857 | $tables = &$self->_getTables(); |
@@ -877,9 +877,9 @@ discard block |
||
877 | 877 | for ($round = 1; $round < $Nr; ++$round) { |
878 | 878 | list($s, $e) = array($e, $s); |
879 | 879 | for ($i = 0; $i < $Nb; ++$i) { |
880 | - $encrypt_block.= |
|
880 | + $encrypt_block .= |
|
881 | 881 | '$'.$e.$i.' = |
882 | - $t0[($'.$s.$i .' >> 24) & 0xff] ^ |
|
882 | + $t0[($'.$s.$i.' >> 24) & 0xff] ^ |
|
883 | 883 | $t1[($'.$s.(($i + $c[1]) % $Nb).' >> 16) & 0xff] ^ |
884 | 884 | $t2[($'.$s.(($i + $c[2]) % $Nb).' >> 8) & 0xff] ^ |
885 | 885 | $t3[ $'.$s.(($i + $c[3]) % $Nb).' & 0xff] ^ |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | |
890 | 890 | // Finalround: subWord + shiftRows + addRoundKey |
891 | 891 | for ($i = 0; $i < $Nb; ++$i) { |
892 | - $encrypt_block.= |
|
892 | + $encrypt_block .= |
|
893 | 893 | '$'.$e.$i.' = |
894 | 894 | $sbox[ $'.$e.$i.' & 0xff] | |
895 | 895 | ($sbox[($'.$e.$i.' >> 8) & 0xff] << 8) | |
@@ -898,8 +898,8 @@ discard block |
||
898 | 898 | } |
899 | 899 | $encrypt_block .= '$in = pack("N*"'."\n"; |
900 | 900 | for ($i = 0; $i < $Nb; ++$i) { |
901 | - $encrypt_block.= ', |
|
902 | - ($'.$e.$i .' & '.((int)0xFF000000).') ^ |
|
901 | + $encrypt_block .= ', |
|
902 | + ($'.$e.$i.' & '.((int) 0xFF000000).') ^ |
|
903 | 903 | ($'.$e.(($i + $c[1]) % $Nb).' & 0x00FF0000 ) ^ |
904 | 904 | ($'.$e.(($i + $c[2]) % $Nb).' & 0x0000FF00 ) ^ |
905 | 905 | ($'.$e.(($i + $c[3]) % $Nb).' & 0x000000FF ) ^ |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | $encrypt_block .= ');'; |
909 | 909 | |
910 | 910 | // Generating decrypt code: |
911 | - $init_decrypt.= ' |
|
911 | + $init_decrypt .= ' |
|
912 | 912 | static $invtables; |
913 | 913 | if (empty($invtables)) { |
914 | 914 | $invtables = &$self->_getInvTables(); |
@@ -934,9 +934,9 @@ discard block |
||
934 | 934 | for ($round = 1; $round < $Nr; ++$round) { |
935 | 935 | list($s, $e) = array($e, $s); |
936 | 936 | for ($i = 0; $i < $Nb; ++$i) { |
937 | - $decrypt_block.= |
|
937 | + $decrypt_block .= |
|
938 | 938 | '$'.$e.$i.' = |
939 | - $dt0[($'.$s.$i .' >> 24) & 0xff] ^ |
|
939 | + $dt0[($'.$s.$i.' >> 24) & 0xff] ^ |
|
940 | 940 | $dt1[($'.$s.(($Nb + $i - $c[1]) % $Nb).' >> 16) & 0xff] ^ |
941 | 941 | $dt2[($'.$s.(($Nb + $i - $c[2]) % $Nb).' >> 8) & 0xff] ^ |
942 | 942 | $dt3[ $'.$s.(($Nb + $i - $c[3]) % $Nb).' & 0xff] ^ |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | |
947 | 947 | // Finalround: subWord + shiftRows + addRoundKey |
948 | 948 | for ($i = 0; $i < $Nb; ++$i) { |
949 | - $decrypt_block.= |
|
949 | + $decrypt_block .= |
|
950 | 950 | '$'.$e.$i.' = |
951 | 951 | $isbox[ $'.$e.$i.' & 0xff] | |
952 | 952 | ($isbox[($'.$e.$i.' >> 8) & 0xff] << 8) | |
@@ -955,8 +955,8 @@ discard block |
||
955 | 955 | } |
956 | 956 | $decrypt_block .= '$in = pack("N*"'."\n"; |
957 | 957 | for ($i = 0; $i < $Nb; ++$i) { |
958 | - $decrypt_block.= ', |
|
959 | - ($'.$e.$i. ' & '.((int)0xFF000000).') ^ |
|
958 | + $decrypt_block .= ', |
|
959 | + ($'.$e.$i.' & '.((int) 0xFF000000).') ^ |
|
960 | 960 | ($'.$e.(($Nb + $i - $c[1]) % $Nb).' & 0x00FF0000 ) ^ |
961 | 961 | ($'.$e.(($Nb + $i - $c[2]) % $Nb).' & 0x0000FF00 ) ^ |
962 | 962 | ($'.$e.(($Nb + $i - $c[3]) % $Nb).' & 0x000000FF ) ^ |
@@ -37,7 +37,7 @@ |
||
37 | 37 | { |
38 | 38 | $length = ord(Strings::shift($string)); |
39 | 39 | if ($length & 0x80) { // definite length, long form |
40 | - $length&= 0x7F; |
|
40 | + $length &= 0x7F; |
|
41 | 41 | $temp = Strings::shift($string, $length); |
42 | 42 | list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)); |
43 | 43 | } |