@@ -287,9 +287,9 @@ |
||
287 | 287 | strlen($n), |
288 | 288 | $n |
289 | 289 | ); |
290 | - $key = "---- BEGIN SSH2 PUBLIC KEY ----\r\n" . |
|
291 | - 'Comment: "' . str_replace(array('\\', '"'), array('\\\\', '\"'), self::$comment) . "\"\r\n"; |
|
292 | - chunk_split(Base64::encode($key), 64) . |
|
290 | + $key = "---- BEGIN SSH2 PUBLIC KEY ----\r\n". |
|
291 | + 'Comment: "'.str_replace(array('\\', '"'), array('\\\\', '\"'), self::$comment)."\"\r\n"; |
|
292 | + chunk_split(Base64::encode($key), 64). |
|
293 | 293 | '---- END SSH2 PUBLIC KEY ----'; |
294 | 294 | |
295 | 295 | return $key; |
@@ -149,12 +149,12 @@ |
||
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 |
@@ -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 | } |
@@ -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 |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | case 16: |
463 | 463 | list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[1], $le_longs[2]); |
464 | 464 | list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[3], $le_longs[4]); |
465 | - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
|
466 | - $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^ |
|
465 | + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { |
|
466 | + $A = $m0[$q0[$q0[$i] ^ $key[9]] ^ $key[1]] ^ |
|
467 | 467 | $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ |
468 | 468 | $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ |
469 | 469 | $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]]; |
@@ -486,8 +486,8 @@ discard block |
||
486 | 486 | list($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[1], $le_longs[2]); |
487 | 487 | list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[3], $le_longs[4]); |
488 | 488 | list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[5], $le_longs[6]); |
489 | - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
|
490 | - $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
|
489 | + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { |
|
490 | + $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[9]] ^ $key[1]] ^ |
|
491 | 491 | $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
492 | 492 | $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
493 | 493 | $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | list($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[3], $le_longs[4]); |
512 | 512 | list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[5], $le_longs[6]); |
513 | 513 | list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[7], $le_longs[8]); |
514 | - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
|
515 | - $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
|
514 | + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { |
|
515 | + $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[9]] ^ $key[1]] ^ |
|
516 | 516 | $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
517 | 517 | $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
518 | 518 | $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
@@ -610,27 +610,27 @@ discard block |
||
610 | 610 | |
611 | 611 | $ki = 7; |
612 | 612 | while ($ki < 39) { |
613 | - $t0 = $S0[ $R0 & 0xff] ^ |
|
614 | - $S1[($R0 >> 8) & 0xff] ^ |
|
613 | + $t0 = $S0[$R0 & 0xff] ^ |
|
614 | + $S1[($R0 >> 8) & 0xff] ^ |
|
615 | 615 | $S2[($R0 >> 16) & 0xff] ^ |
616 | 616 | $S3[($R0 >> 24) & 0xff]; |
617 | 617 | $t1 = $S0[($R1 >> 24) & 0xff] ^ |
618 | - $S1[ $R1 & 0xff] ^ |
|
619 | - $S2[($R1 >> 8) & 0xff] ^ |
|
618 | + $S1[$R1 & 0xff] ^ |
|
619 | + $S2[($R1 >> 8) & 0xff] ^ |
|
620 | 620 | $S3[($R1 >> 16) & 0xff]; |
621 | - $R2^= $t0 + $t1 + $K[++$ki]; |
|
621 | + $R2 ^= $t0 + $t1 + $K[++$ki]; |
|
622 | 622 | $R2 = ($R2 >> 1 & 0x7fffffff) | ($R2 << 31); |
623 | 623 | $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ ($t0 + ($t1 << 1) + $K[++$ki]); |
624 | 624 | |
625 | - $t0 = $S0[ $R2 & 0xff] ^ |
|
626 | - $S1[($R2 >> 8) & 0xff] ^ |
|
625 | + $t0 = $S0[$R2 & 0xff] ^ |
|
626 | + $S1[($R2 >> 8) & 0xff] ^ |
|
627 | 627 | $S2[($R2 >> 16) & 0xff] ^ |
628 | 628 | $S3[($R2 >> 24) & 0xff]; |
629 | 629 | $t1 = $S0[($R3 >> 24) & 0xff] ^ |
630 | - $S1[ $R3 & 0xff] ^ |
|
631 | - $S2[($R3 >> 8) & 0xff] ^ |
|
630 | + $S1[$R3 & 0xff] ^ |
|
631 | + $S2[($R3 >> 8) & 0xff] ^ |
|
632 | 632 | $S3[($R3 >> 16) & 0xff]; |
633 | - $R0^= ($t0 + $t1 + $K[++$ki]); |
|
633 | + $R0 ^= ($t0 + $t1 + $K[++$ki]); |
|
634 | 634 | $R0 = ($R0 >> 1 & 0x7fffffff) | ($R0 << 31); |
635 | 635 | $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + $K[++$ki]); |
636 | 636 | } |
@@ -666,27 +666,27 @@ discard block |
||
666 | 666 | |
667 | 667 | $ki = 40; |
668 | 668 | while ($ki > 8) { |
669 | - $t0 = $S0[$R0 & 0xff] ^ |
|
670 | - $S1[$R0 >> 8 & 0xff] ^ |
|
669 | + $t0 = $S0[$R0 & 0xff] ^ |
|
670 | + $S1[$R0 >> 8 & 0xff] ^ |
|
671 | 671 | $S2[$R0 >> 16 & 0xff] ^ |
672 | 672 | $S3[$R0 >> 24 & 0xff]; |
673 | 673 | $t1 = $S0[$R1 >> 24 & 0xff] ^ |
674 | - $S1[$R1 & 0xff] ^ |
|
675 | - $S2[$R1 >> 8 & 0xff] ^ |
|
674 | + $S1[$R1 & 0xff] ^ |
|
675 | + $S2[$R1 >> 8 & 0xff] ^ |
|
676 | 676 | $S3[$R1 >> 16 & 0xff]; |
677 | - $R3^= $t0 + ($t1 << 1) + $K[--$ki]; |
|
677 | + $R3 ^= $t0 + ($t1 << 1) + $K[--$ki]; |
|
678 | 678 | $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31; |
679 | 679 | $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ($t0 + $t1 + $K[--$ki]); |
680 | 680 | |
681 | - $t0 = $S0[$R2 & 0xff] ^ |
|
682 | - $S1[$R2 >> 8 & 0xff] ^ |
|
681 | + $t0 = $S0[$R2 & 0xff] ^ |
|
682 | + $S1[$R2 >> 8 & 0xff] ^ |
|
683 | 683 | $S2[$R2 >> 16 & 0xff] ^ |
684 | 684 | $S3[$R2 >> 24 & 0xff]; |
685 | 685 | $t1 = $S0[$R3 >> 24 & 0xff] ^ |
686 | - $S1[$R3 & 0xff] ^ |
|
687 | - $S2[$R3 >> 8 & 0xff] ^ |
|
686 | + $S1[$R3 & 0xff] ^ |
|
687 | + $S2[$R3 >> 8 & 0xff] ^ |
|
688 | 688 | $S3[$R3 >> 16 & 0xff]; |
689 | - $R1^= $t0 + ($t1 << 1) + $K[--$ki]; |
|
689 | + $R1 ^= $t0 + ($t1 << 1) + $K[--$ki]; |
|
690 | 690 | $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31; |
691 | 691 | $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ($t0 + $t1 + $K[--$ki]); |
692 | 692 | } |
@@ -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 | } |
@@ -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; |
@@ -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 | } |
@@ -1232,31 +1232,31 @@ discard block |
||
1232 | 1232 | //'arcfour', // OPTIONAL the ARCFOUR stream cipher with a 128-bit key |
1233 | 1233 | |
1234 | 1234 | // CTR modes from <http://tools.ietf.org/html/rfc4344#section-4>: |
1235 | - 'aes128-ctr', // RECOMMENDED AES (Rijndael) in SDCTR mode, with 128-bit key |
|
1236 | - 'aes192-ctr', // RECOMMENDED AES with 192-bit key |
|
1237 | - 'aes256-ctr', // RECOMMENDED AES with 256-bit key |
|
1235 | + 'aes128-ctr', // RECOMMENDED AES (Rijndael) in SDCTR mode, with 128-bit key |
|
1236 | + 'aes192-ctr', // RECOMMENDED AES with 192-bit key |
|
1237 | + 'aes256-ctr', // RECOMMENDED AES with 256-bit key |
|
1238 | 1238 | |
1239 | 1239 | 'twofish128-ctr', // OPTIONAL Twofish in SDCTR mode, with 128-bit key |
1240 | 1240 | 'twofish192-ctr', // OPTIONAL Twofish with 192-bit key |
1241 | 1241 | 'twofish256-ctr', // OPTIONAL Twofish with 256-bit key |
1242 | 1242 | |
1243 | - 'aes128-cbc', // RECOMMENDED AES with a 128-bit key |
|
1244 | - 'aes192-cbc', // OPTIONAL AES with a 192-bit key |
|
1245 | - 'aes256-cbc', // OPTIONAL AES in CBC mode, with a 256-bit key |
|
1243 | + 'aes128-cbc', // RECOMMENDED AES with a 128-bit key |
|
1244 | + 'aes192-cbc', // OPTIONAL AES with a 192-bit key |
|
1245 | + 'aes256-cbc', // OPTIONAL AES in CBC mode, with a 256-bit key |
|
1246 | 1246 | |
1247 | 1247 | 'twofish128-cbc', // OPTIONAL Twofish with a 128-bit key |
1248 | 1248 | 'twofish192-cbc', // OPTIONAL Twofish with a 192-bit key |
1249 | 1249 | 'twofish256-cbc', |
1250 | - 'twofish-cbc', // OPTIONAL alias for "twofish256-cbc" |
|
1250 | + 'twofish-cbc', // OPTIONAL alias for "twofish256-cbc" |
|
1251 | 1251 | // (this is being retained for historical reasons) |
1252 | 1252 | |
1253 | - 'blowfish-ctr', // OPTIONAL Blowfish in SDCTR mode |
|
1253 | + 'blowfish-ctr', // OPTIONAL Blowfish in SDCTR mode |
|
1254 | 1254 | |
1255 | - 'blowfish-cbc', // OPTIONAL Blowfish in CBC mode |
|
1255 | + 'blowfish-cbc', // OPTIONAL Blowfish in CBC mode |
|
1256 | 1256 | |
1257 | - '3des-ctr', // RECOMMENDED Three-key 3DES in SDCTR mode |
|
1257 | + '3des-ctr', // RECOMMENDED Three-key 3DES in SDCTR mode |
|
1258 | 1258 | |
1259 | - '3des-cbc', // REQUIRED three-key 3DES in CBC mode |
|
1259 | + '3des-cbc', // REQUIRED three-key 3DES in CBC mode |
|
1260 | 1260 | //'none' // OPTIONAL no encryption; NOT RECOMMENDED |
1261 | 1261 | ); |
1262 | 1262 | |
@@ -2994,9 +2994,9 @@ discard block |
||
2994 | 2994 | |
2995 | 2995 | if (defined('NET_SSH2_LOGGING')) { |
2996 | 2996 | $current = microtime(true); |
2997 | - $message_number = isset($this->message_numbers[ord($payload[0])]) ? $this->message_numbers[ord($payload[0])] : 'UNKNOWN (' . ord($payload[0]) . ')'; |
|
2998 | - $message_number = '<- ' . $message_number . |
|
2999 | - ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
2997 | + $message_number = isset($this->message_numbers[ord($payload[0])]) ? $this->message_numbers[ord($payload[0])] : 'UNKNOWN ('.ord($payload[0]).')'; |
|
2998 | + $message_number = '<- '.$message_number. |
|
2999 | + ' (since last: '.round($current - $this->last_packet, 4).', network: '.round($stop - $start, 4).'s)'; |
|
3000 | 3000 | $this->_append_log($message_number, $payload); |
3001 | 3001 | $this->last_packet = $current; |
3002 | 3002 | } |
@@ -3470,9 +3470,9 @@ discard block |
||
3470 | 3470 | |
3471 | 3471 | if (defined('NET_SSH2_LOGGING')) { |
3472 | 3472 | $current = microtime(true); |
3473 | - $message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN (' . ord($data[0]) . ')'; |
|
3474 | - $message_number = '-> ' . $message_number . |
|
3475 | - ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
3473 | + $message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN ('.ord($data[0]).')'; |
|
3474 | + $message_number = '-> '.$message_number. |
|
3475 | + ' (since last: '.round($current - $this->last_packet, 4).', network: '.round($stop - $start, 4).'s)'; |
|
3476 | 3476 | $this->_append_log($message_number, isset($logged) ? $logged : $data); |
3477 | 3477 | $this->last_packet = $current; |
3478 | 3478 | } |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | $response = $this->_get_channel_packet(self::CHANNEL); |
438 | 438 | if ($response === false) { |
439 | 439 | // from PuTTY's psftp.exe |
440 | - $command = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n" . |
|
441 | - "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n" . |
|
440 | + $command = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n". |
|
441 | + "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n". |
|
442 | 442 | "exec sftp-server"; |
443 | 443 | // we don't do $this->exec($command, false) because exec() operates on a different channel and plus the SSH_MSG_CHANNEL_OPEN that exec() does |
444 | 444 | // is redundant |
@@ -2785,18 +2785,17 @@ discard block |
||
2785 | 2785 | function _send_sftp_packet($type, $data) |
2786 | 2786 | { |
2787 | 2787 | $packet = $this->request_id !== false ? |
2788 | - pack('NCNa*', strlen($data) + 5, $type, $this->request_id, $data) : |
|
2789 | - pack('NCa*', strlen($data) + 1, $type, $data); |
|
2788 | + pack('NCNa*', strlen($data) + 5, $type, $this->request_id, $data) : pack('NCa*', strlen($data) + 1, $type, $data); |
|
2790 | 2789 | |
2791 | 2790 | $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 |
2792 | 2791 | $result = $this->_send_channel_packet(self::CHANNEL, $packet); |
2793 | 2792 | $stop = strtok(microtime(), ' ') + strtok(''); |
2794 | 2793 | |
2795 | 2794 | if (defined('NET_SFTP_LOGGING')) { |
2796 | - $packet_type = '-> ' . $this->packet_types[$type] . |
|
2797 | - ' (' . round($stop - $start, 4) . 's)'; |
|
2795 | + $packet_type = '-> '.$this->packet_types[$type]. |
|
2796 | + ' ('.round($stop - $start, 4).'s)'; |
|
2798 | 2797 | if (NET_SFTP_LOGGING == self::LOG_REALTIME) { |
2799 | - echo "<pre>\r\n" . $this->_format_log(array($data), array($packet_type)) . "\r\n</pre>\r\n"; |
|
2798 | + echo "<pre>\r\n".$this->_format_log(array($data), array($packet_type))."\r\n</pre>\r\n"; |
|
2800 | 2799 | flush(); |
2801 | 2800 | ob_flush(); |
2802 | 2801 | } else { |
@@ -2861,18 +2860,18 @@ discard block |
||
2861 | 2860 | |
2862 | 2861 | if ($this->request_id !== false) { |
2863 | 2862 | Strings::shift($this->packet_buffer, 4); // remove the request id |
2864 | - $length-= 5; // account for the request id and the packet type |
|
2863 | + $length -= 5; // account for the request id and the packet type |
|
2865 | 2864 | } else { |
2866 | - $length-= 1; // account for the packet type |
|
2865 | + $length -= 1; // account for the packet type |
|
2867 | 2866 | } |
2868 | 2867 | |
2869 | 2868 | $packet = Strings::shift($this->packet_buffer, $length); |
2870 | 2869 | |
2871 | 2870 | if (defined('NET_SFTP_LOGGING')) { |
2872 | - $packet_type = '<- ' . $this->packet_types[$this->packet_type] . |
|
2873 | - ' (' . round($stop - $start, 4) . 's)'; |
|
2871 | + $packet_type = '<- '.$this->packet_types[$this->packet_type]. |
|
2872 | + ' ('.round($stop - $start, 4).'s)'; |
|
2874 | 2873 | if (NET_SFTP_LOGGING == self::LOG_REALTIME) { |
2875 | - echo "<pre>\r\n" . $this->_format_log(array($packet), array($packet_type)) . "\r\n</pre>\r\n"; |
|
2874 | + echo "<pre>\r\n".$this->_format_log(array($packet), array($packet_type))."\r\n</pre>\r\n"; |
|
2876 | 2875 | flush(); |
2877 | 2876 | ob_flush(); |
2878 | 2877 | } else { |
@@ -1610,18 +1610,18 @@ discard block |
||
1610 | 1610 | ); |
1611 | 1611 | |
1612 | 1612 | $rsaOID = "\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00"; // hex version of MA0GCSqGSIb3DQEBAQUA |
1613 | - $RSAPublicKey = chr(0) . $RSAPublicKey; |
|
1614 | - $RSAPublicKey = chr(3) . self::_encodeASN1Length(strlen($RSAPublicKey)) . $RSAPublicKey; |
|
1613 | + $RSAPublicKey = chr(0).$RSAPublicKey; |
|
1614 | + $RSAPublicKey = chr(3).self::_encodeASN1Length(strlen($RSAPublicKey)).$RSAPublicKey; |
|
1615 | 1615 | |
1616 | 1616 | $encapsulated = pack( |
1617 | 1617 | 'Ca*a*', |
1618 | 1618 | 48, |
1619 | - self::_encodeASN1Length(strlen($rsaOID . $RSAPublicKey)), |
|
1620 | - $rsaOID . $RSAPublicKey |
|
1619 | + self::_encodeASN1Length(strlen($rsaOID.$RSAPublicKey)), |
|
1620 | + $rsaOID.$RSAPublicKey |
|
1621 | 1621 | ); |
1622 | 1622 | |
1623 | - $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . |
|
1624 | - chunk_split(Base64::encode($encapsulated)) . |
|
1623 | + $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n". |
|
1624 | + chunk_split(Base64::encode($encapsulated)). |
|
1625 | 1625 | '-----END PUBLIC KEY-----'; |
1626 | 1626 | |
1627 | 1627 | $plaintext = str_pad($this->toBytes(), strlen($n->toBytes(true)) - 1, "\0", STR_PAD_LEFT); |
@@ -3269,18 +3269,18 @@ discard block |
||
3269 | 3269 | if (!$t) { |
3270 | 3270 | // see HAC 4.49 "Note (controlling the error probability)" |
3271 | 3271 | // @codingStandardsIgnoreStart |
3272 | - if ($length >= 163) { $t = 2; } // floor(1300 / 8) |
|
3273 | - else if ($length >= 106) { $t = 3; } // floor( 850 / 8) |
|
3274 | - else if ($length >= 81 ) { $t = 4; } // floor( 650 / 8) |
|
3275 | - else if ($length >= 68 ) { $t = 5; } // floor( 550 / 8) |
|
3276 | - else if ($length >= 56 ) { $t = 6; } // floor( 450 / 8) |
|
3277 | - else if ($length >= 50 ) { $t = 7; } // floor( 400 / 8) |
|
3278 | - else if ($length >= 43 ) { $t = 8; } // floor( 350 / 8) |
|
3279 | - else if ($length >= 37 ) { $t = 9; } // floor( 300 / 8) |
|
3280 | - else if ($length >= 31 ) { $t = 12; } // floor( 250 / 8) |
|
3281 | - else if ($length >= 25 ) { $t = 15; } // floor( 200 / 8) |
|
3282 | - else if ($length >= 18 ) { $t = 18; } // floor( 150 / 8) |
|
3283 | - else { $t = 27; } |
|
3272 | + if ($length >= 163) { $t = 2; } // floor(1300 / 8) |
|
3273 | + else if ($length >= 106) { $t = 3; } // floor( 850 / 8) |
|
3274 | + else if ($length >= 81) { $t = 4; } // floor( 650 / 8) |
|
3275 | + else if ($length >= 68) { $t = 5; } // floor( 550 / 8) |
|
3276 | + else if ($length >= 56) { $t = 6; } // floor( 450 / 8) |
|
3277 | + else if ($length >= 50) { $t = 7; } // floor( 400 / 8) |
|
3278 | + else if ($length >= 43) { $t = 8; } // floor( 350 / 8) |
|
3279 | + else if ($length >= 37) { $t = 9; } // floor( 300 / 8) |
|
3280 | + else if ($length >= 31) { $t = 12; } // floor( 250 / 8) |
|
3281 | + else if ($length >= 25) { $t = 15; } // floor( 200 / 8) |
|
3282 | + else if ($length >= 18) { $t = 18; } // floor( 150 / 8) |
|
3283 | + else { $t = 27; } |
|
3284 | 3284 | // @codingStandardsIgnoreEnd |
3285 | 3285 | } |
3286 | 3286 |