@@ -203,9 +203,8 @@ |
||
| 203 | 203 | /** |
| 204 | 204 | * Set the number of lines that should be logged past the terminal height |
| 205 | 205 | * |
| 206 | - * @param int $x |
|
| 207 | - * @param int $y |
|
| 208 | 206 | * @access public |
| 207 | + * @param integer $history |
|
| 209 | 208 | */ |
| 210 | 209 | function setHistory($history) |
| 211 | 210 | { |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | $this->tokenization = array(''); |
| 236 | 236 | for ($i = 0; $i < strlen($source); $i++) { |
| 237 | 237 | if (strlen($this->ansi)) { |
| 238 | - $this->ansi.= $source[$i]; |
|
| 238 | + $this->ansi .= $source[$i]; |
|
| 239 | 239 | $chr = ord($source[$i]); |
| 240 | 240 | // http://en.wikipedia.org/wiki/ANSI_escape_code#Sequence_elements |
| 241 | 241 | // single character CSI's not currently supported |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | switch (true) { |
| 291 | 291 | case preg_match('#\x1B\[(\d+)B#', $this->ansi, $match): // Move cursor down n lines |
| 292 | 292 | $this->old_y = $this->y; |
| 293 | - $this->y+= $match[1]; |
|
| 293 | + $this->y += $match[1]; |
|
| 294 | 294 | break; |
| 295 | 295 | case preg_match('#\x1B\[(\d+);(\d+)H#', $this->ansi, $match): // Move cursor to screen location v,h |
| 296 | 296 | $this->old_x = $this->x; |
@@ -300,11 +300,11 @@ discard block |
||
| 300 | 300 | break; |
| 301 | 301 | case preg_match('#\x1B\[(\d+)C#', $this->ansi, $match): // Move cursor right n lines |
| 302 | 302 | $this->old_x = $this->x; |
| 303 | - $this->x+= $match[1]; |
|
| 303 | + $this->x += $match[1]; |
|
| 304 | 304 | break; |
| 305 | 305 | case preg_match('#\x1B\[(\d+)D#', $this->ansi, $match): // Move cursor left n lines |
| 306 | 306 | $this->old_x = $this->x; |
| 307 | - $this->x-= $match[1]; |
|
| 307 | + $this->x -= $match[1]; |
|
| 308 | 308 | break; |
| 309 | 309 | case preg_match('#\x1B\[(\d+);(\d+)r#', $this->ansi, $match): // Set top and bottom lines of a window |
| 310 | 310 | break; |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | continue; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - $this->tokenization[count($this->tokenization) - 1].= $source[$i]; |
|
| 376 | + $this->tokenization[count($this->tokenization) - 1] .= $source[$i]; |
|
| 377 | 377 | switch ($source[$i]) { |
| 378 | 378 | case "\r": |
| 379 | 379 | $this->x = 0; |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | //if (!strlen($this->tokenization[count($this->tokenization) - 1])) { |
| 401 | 401 | // array_pop($this->tokenization); |
| 402 | 402 | //} |
| 403 | - $this->ansi.= "\x1B"; |
|
| 403 | + $this->ansi .= "\x1B"; |
|
| 404 | 404 | break; |
| 405 | 405 | default: |
| 406 | 406 | $this->attrs[$this->y][$this->x] = clone $this->attr_cell; |
@@ -468,45 +468,45 @@ discard block |
||
| 468 | 468 | $close = $open = ''; |
| 469 | 469 | if ($last_attr->foreground != $cur_attr->foreground) { |
| 470 | 470 | if ($cur_attr->foreground != 'white') { |
| 471 | - $open.= '<span style="color: ' . $cur_attr->foreground . '">'; |
|
| 471 | + $open .= '<span style="color: '.$cur_attr->foreground.'">'; |
|
| 472 | 472 | } |
| 473 | 473 | if ($last_attr->foreground != 'white') { |
| 474 | - $close = '</span>' . $close; |
|
| 474 | + $close = '</span>'.$close; |
|
| 475 | 475 | } |
| 476 | 476 | } |
| 477 | 477 | if ($last_attr->background != $cur_attr->background) { |
| 478 | 478 | if ($cur_attr->background != 'black') { |
| 479 | - $open.= '<span style="background: ' . $cur_attr->background . '">'; |
|
| 479 | + $open .= '<span style="background: '.$cur_attr->background.'">'; |
|
| 480 | 480 | } |
| 481 | 481 | if ($last_attr->background != 'black') { |
| 482 | - $close = '</span>' . $close; |
|
| 482 | + $close = '</span>'.$close; |
|
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | if ($last_attr->bold != $cur_attr->bold) { |
| 486 | 486 | if ($cur_attr->bold) { |
| 487 | - $open.= '<b>'; |
|
| 487 | + $open .= '<b>'; |
|
| 488 | 488 | } else { |
| 489 | - $close = '</b>' . $close; |
|
| 489 | + $close = '</b>'.$close; |
|
| 490 | 490 | } |
| 491 | 491 | } |
| 492 | 492 | if ($last_attr->underline != $cur_attr->underline) { |
| 493 | 493 | if ($cur_attr->underline) { |
| 494 | - $open.= '<u>'; |
|
| 494 | + $open .= '<u>'; |
|
| 495 | 495 | } else { |
| 496 | - $close = '</u>' . $close; |
|
| 496 | + $close = '</u>'.$close; |
|
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | 499 | if ($last_attr->blink != $cur_attr->blink) { |
| 500 | 500 | if ($cur_attr->blink) { |
| 501 | - $open.= '<blink>'; |
|
| 501 | + $open .= '<blink>'; |
|
| 502 | 502 | } else { |
| 503 | - $close = '</blink>' . $close; |
|
| 503 | + $close = '</blink>'.$close; |
|
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | - $output.= $close . $open; |
|
| 506 | + $output .= $close.$open; |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - $output.= htmlspecialchars($char); |
|
| 509 | + $output .= htmlspecialchars($char); |
|
| 510 | 510 | |
| 511 | 511 | return $output; |
| 512 | 512 | } |
@@ -524,14 +524,14 @@ discard block |
||
| 524 | 524 | for ($i = 0; $i <= $this->max_y; $i++) { |
| 525 | 525 | for ($j = 0; $j <= $this->max_x; $j++) { |
| 526 | 526 | $cur_attr = $this->attrs[$i][$j]; |
| 527 | - $output.= $this->_processCoordinate($last_attr, $cur_attr, isset($this->screen[$i][$j]) ? $this->screen[$i][$j] : ''); |
|
| 527 | + $output .= $this->_processCoordinate($last_attr, $cur_attr, isset($this->screen[$i][$j]) ? $this->screen[$i][$j] : ''); |
|
| 528 | 528 | $last_attr = $this->attrs[$i][$j]; |
| 529 | 529 | } |
| 530 | - $output.= "\r\n"; |
|
| 530 | + $output .= "\r\n"; |
|
| 531 | 531 | } |
| 532 | 532 | $output = substr($output, 0, -2); |
| 533 | 533 | // close any remaining open tags |
| 534 | - $output.= $this->_processCoordinate($last_attr, $this->base_attr_cell, ''); |
|
| 534 | + $output .= $this->_processCoordinate($last_attr, $this->base_attr_cell, ''); |
|
| 535 | 535 | return rtrim($output); |
| 536 | 536 | } |
| 537 | 537 | |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | function getScreen() |
| 545 | 545 | { |
| 546 | - return '<pre width="' . ($this->max_x + 1) . '" style="color: white; background: black">' . $this->_getScreen() . '</pre>'; |
|
| 546 | + return '<pre width="'.($this->max_x + 1).'" style="color: white; background: black">'.$this->_getScreen().'</pre>'; |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -559,16 +559,16 @@ discard block |
||
| 559 | 559 | for ($i = 0; $i < count($this->history); $i++) { |
| 560 | 560 | for ($j = 0; $j <= $this->max_x + 1; $j++) { |
| 561 | 561 | $cur_attr = $this->history_attrs[$i][$j]; |
| 562 | - $scrollback.= $this->_processCoordinate($last_attr, $cur_attr, isset($this->history[$i][$j]) ? $this->history[$i][$j] : ''); |
|
| 562 | + $scrollback .= $this->_processCoordinate($last_attr, $cur_attr, isset($this->history[$i][$j]) ? $this->history[$i][$j] : ''); |
|
| 563 | 563 | $last_attr = $this->history_attrs[$i][$j]; |
| 564 | 564 | } |
| 565 | - $scrollback.= "\r\n"; |
|
| 565 | + $scrollback .= "\r\n"; |
|
| 566 | 566 | } |
| 567 | 567 | $base_attr_cell = $this->base_attr_cell; |
| 568 | 568 | $this->base_attr_cell = $last_attr; |
| 569 | - $scrollback.= $this->_getScreen(); |
|
| 569 | + $scrollback .= $this->_getScreen(); |
|
| 570 | 570 | $this->base_attr_cell = $base_attr_cell; |
| 571 | 571 | |
| 572 | - return '<pre width="' . ($this->max_x + 1) . '" style="color: white; background: black">' . $scrollback . '</span></pre>'; |
|
| 572 | + return '<pre width="'.($this->max_x + 1).'" style="color: white; background: black">'.$scrollback.'</span></pre>'; |
|
| 573 | 573 | } |
| 574 | 574 | } |
@@ -783,7 +783,6 @@ discard block |
||
| 783 | 783 | * |
| 784 | 784 | * @param string $source |
| 785 | 785 | * @param string $mapping |
| 786 | - * @param int $idx |
|
| 787 | 786 | * @return string |
| 788 | 787 | * @access public |
| 789 | 788 | */ |
@@ -1108,7 +1107,7 @@ discard block |
||
| 1108 | 1107 | * @access private |
| 1109 | 1108 | * @param string $content |
| 1110 | 1109 | * @param int $tag |
| 1111 | - * @return string |
|
| 1110 | + * @return double |
|
| 1112 | 1111 | */ |
| 1113 | 1112 | function _decodeTime($content, $tag) |
| 1114 | 1113 | { |
@@ -261,15 +261,15 @@ discard block |
||
| 261 | 261 | } elseif ($length & 0x80) { // definite length, long form |
| 262 | 262 | // technically, the long form of the length can be represented by up to 126 octets (bytes), but we'll only |
| 263 | 263 | // support it up to four. |
| 264 | - $length&= 0x7F; |
|
| 264 | + $length &= 0x7F; |
|
| 265 | 265 | $temp = substr($encoded, $encoded_pos, $length); |
| 266 | 266 | $encoded_pos += $length; |
| 267 | 267 | // tags of indefinte length don't really have a header length; this length includes the tag |
| 268 | - $current+= array('headerlength' => $length + 2); |
|
| 269 | - $start+= $length; |
|
| 268 | + $current += array('headerlength' => $length + 2); |
|
| 269 | + $start += $length; |
|
| 270 | 270 | extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4))); |
| 271 | 271 | } else { |
| 272 | - $current+= array('headerlength' => 2); |
|
| 272 | + $current += array('headerlength' => 2); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | if ($length > (strlen($encoded) - $encoded_pos)) { |
@@ -311,13 +311,13 @@ discard block |
||
| 311 | 311 | $length = $temp['length']; |
| 312 | 312 | // end-of-content octets - see paragraph 8.1.5 |
| 313 | 313 | if (substr($content, $content_pos + $length, 2) == "\0\0") { |
| 314 | - $length+= 2; |
|
| 315 | - $start+= $length; |
|
| 314 | + $length += 2; |
|
| 315 | + $start += $length; |
|
| 316 | 316 | $newcontent[] = $temp; |
| 317 | 317 | break; |
| 318 | 318 | } |
| 319 | - $start+= $length; |
|
| 320 | - $remainingLength-= $length; |
|
| 319 | + $start += $length; |
|
| 320 | + $remainingLength -= $length; |
|
| 321 | 321 | $newcontent[] = $temp; |
| 322 | 322 | $content_pos += $length; |
| 323 | 323 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | ) + $current; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - $current+= array('type' => $tag); |
|
| 337 | + $current += array('type' => $tag); |
|
| 338 | 338 | |
| 339 | 339 | // decode UNIVERSAL tags |
| 340 | 340 | switch ($tag) { |
@@ -359,20 +359,20 @@ discard block |
||
| 359 | 359 | $current['content'] = substr($content, $content_pos); |
| 360 | 360 | } else { |
| 361 | 361 | $temp = $this->_decode_ber($content, $start, $content_pos); |
| 362 | - $length-= (strlen($content) - $content_pos); |
|
| 362 | + $length -= (strlen($content) - $content_pos); |
|
| 363 | 363 | $last = count($temp) - 1; |
| 364 | 364 | for ($i = 0; $i < $last; $i++) { |
| 365 | 365 | // all subtags should be bit strings |
| 366 | 366 | //if ($temp[$i]['type'] != self::TYPE_BIT_STRING) { |
| 367 | 367 | // return false; |
| 368 | 368 | //} |
| 369 | - $current['content'].= substr($temp[$i]['content'], 1); |
|
| 369 | + $current['content'] .= substr($temp[$i]['content'], 1); |
|
| 370 | 370 | } |
| 371 | 371 | // all subtags should be bit strings |
| 372 | 372 | //if ($temp[$last]['type'] != self::TYPE_BIT_STRING) { |
| 373 | 373 | // return false; |
| 374 | 374 | //} |
| 375 | - $current['content'] = $temp[$last]['content'][0] . $current['content'] . substr($temp[$i]['content'], 1); |
|
| 375 | + $current['content'] = $temp[$last]['content'][0].$current['content'].substr($temp[$i]['content'], 1); |
|
| 376 | 376 | } |
| 377 | 377 | break; |
| 378 | 378 | case self::TYPE_OCTET_STRING: |
@@ -388,11 +388,11 @@ discard block |
||
| 388 | 388 | //if ($temp['type'] != self::TYPE_OCTET_STRING) { |
| 389 | 389 | // return false; |
| 390 | 390 | //} |
| 391 | - $current['content'].= $temp['content']; |
|
| 392 | - $length+= $temp['length']; |
|
| 391 | + $current['content'] .= $temp['content']; |
|
| 392 | + $length += $temp['length']; |
|
| 393 | 393 | } |
| 394 | 394 | if (substr($content, $content_pos, 2) == "\0\0") { |
| 395 | - $length+= 2; // +2 for the EOC |
|
| 395 | + $length += 2; // +2 for the EOC |
|
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | break; |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | $temp = $this->_decode_ber($content, $start + $offset, $content_pos); |
| 418 | 418 | $content_pos += $temp['length']; |
| 419 | 419 | $current['content'][] = $temp; |
| 420 | - $offset+= $temp['length']; |
|
| 420 | + $offset += $temp['length']; |
|
| 421 | 421 | } |
| 422 | 422 | break; |
| 423 | 423 | case self::TYPE_OBJECT_IDENTIFIER: |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | $valuen <<= 7; |
| 432 | 432 | $valuen |= $temp & 0x7F; |
| 433 | 433 | if (~$temp & 0x80) { |
| 434 | - $current['content'].= ".$valuen"; |
|
| 434 | + $current['content'] .= ".$valuen"; |
|
| 435 | 435 | $valuen = 0; |
| 436 | 436 | } |
| 437 | 437 | } |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | default: |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - $start+= $length; |
|
| 479 | + $start += $length; |
|
| 480 | 480 | |
| 481 | 481 | // ie. length is the length of the full TLV encoding - it's not just the length of the value |
| 482 | 482 | return $current + array('length' => $start - $current['start']); |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | // Fail mapping if all input items have not been consumed. |
| 626 | - return $i < $n ? null: $map; |
|
| 626 | + return $i < $n ? null : $map; |
|
| 627 | 627 | |
| 628 | 628 | // the main diff between sets and sequences is the encapsulation of the foreach in another for loop |
| 629 | 629 | case self::TYPE_SET: |
@@ -766,8 +766,7 @@ discard block |
||
| 766 | 766 | if (isset($mapping['mapping'])) { |
| 767 | 767 | $temp = (int) $temp->toString(); |
| 768 | 768 | return isset($mapping['mapping'][$temp]) ? |
| 769 | - $mapping['mapping'][$temp] : |
|
| 770 | - false; |
|
| 769 | + $mapping['mapping'][$temp] : false; |
|
| 771 | 770 | } |
| 772 | 771 | return $temp; |
| 773 | 772 | } |
@@ -826,7 +825,7 @@ discard block |
||
| 826 | 825 | switch ($tag) { |
| 827 | 826 | case self::TYPE_SET: // Children order is not important, thus process in sequence. |
| 828 | 827 | case self::TYPE_SEQUENCE: |
| 829 | - $tag|= 0x20; // set the constructed bit |
|
| 828 | + $tag |= 0x20; // set the constructed bit |
|
| 830 | 829 | |
| 831 | 830 | // ignore the min and max |
| 832 | 831 | if (isset($mapping['min']) && isset($mapping['max'])) { |
@@ -838,7 +837,7 @@ discard block |
||
| 838 | 837 | if ($temp === false) { |
| 839 | 838 | return false; |
| 840 | 839 | } |
| 841 | - $value[]= $temp; |
|
| 840 | + $value[] = $temp; |
|
| 842 | 841 | } |
| 843 | 842 | /* "The encodings of the component values of a set-of value shall appear in ascending order, the encodings being compared |
| 844 | 843 | as octet strings with the shorter components being padded at their trailing end with 0-octets. |
@@ -885,13 +884,13 @@ discard block |
||
| 885 | 884 | */ |
| 886 | 885 | if (isset($child['explicit']) || $child['type'] == self::TYPE_CHOICE) { |
| 887 | 886 | $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']); |
| 888 | - $temp = $subtag . Functions::encodeLength(strlen($temp)) . $temp; |
|
| 887 | + $temp = $subtag.Functions::encodeLength(strlen($temp)).$temp; |
|
| 889 | 888 | } else { |
| 890 | 889 | $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']); |
| 891 | - $temp = $subtag . substr($temp, 1); |
|
| 890 | + $temp = $subtag.substr($temp, 1); |
|
| 892 | 891 | } |
| 893 | 892 | } |
| 894 | - $value.= $temp; |
|
| 893 | + $value .= $temp; |
|
| 895 | 894 | } |
| 896 | 895 | break; |
| 897 | 896 | case self::TYPE_CHOICE: |
@@ -919,10 +918,10 @@ discard block |
||
| 919 | 918 | if (isset($child['constant'])) { |
| 920 | 919 | if (isset($child['explicit']) || $child['type'] == self::TYPE_CHOICE) { |
| 921 | 920 | $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']); |
| 922 | - $temp = $subtag . Functions::encodeLength(strlen($temp)) . $temp; |
|
| 921 | + $temp = $subtag.Functions::encodeLength(strlen($temp)).$temp; |
|
| 923 | 922 | } else { |
| 924 | 923 | $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']); |
| 925 | - $temp = $subtag . substr($temp, 1); |
|
| 924 | + $temp = $subtag.substr($temp, 1); |
|
| 926 | 925 | } |
| 927 | 926 | } |
| 928 | 927 | } |
@@ -958,8 +957,8 @@ discard block |
||
| 958 | 957 | case self::TYPE_UTC_TIME: |
| 959 | 958 | case self::TYPE_GENERALIZED_TIME: |
| 960 | 959 | $format = $mapping['type'] == self::TYPE_UTC_TIME ? 'y' : 'Y'; |
| 961 | - $format.= 'mdHis'; |
|
| 962 | - $value = @gmdate($format, strtotime($source)) . 'Z'; |
|
| 960 | + $format .= 'mdHis'; |
|
| 961 | + $value = @gmdate($format, strtotime($source)).'Z'; |
|
| 963 | 962 | break; |
| 964 | 963 | case self::TYPE_BIT_STRING: |
| 965 | 964 | if (isset($mapping['mapping'])) { |
@@ -988,7 +987,7 @@ discard block |
||
| 988 | 987 | $bits = implode('', array_pad($bits, $size + $offset + 1, 0)); |
| 989 | 988 | $bytes = explode(' ', rtrim(chunk_split($bits, 8, ' '))); |
| 990 | 989 | foreach ($bytes as $byte) { |
| 991 | - $value.= chr(bindec($byte)); |
|
| 990 | + $value .= chr(bindec($byte)); |
|
| 992 | 991 | } |
| 993 | 992 | |
| 994 | 993 | break; |
@@ -1015,12 +1014,12 @@ discard block |
||
| 1015 | 1014 | $temp = "\0"; |
| 1016 | 1015 | } else { |
| 1017 | 1016 | while ($parts[$i]) { |
| 1018 | - $temp = chr(0x80 | ($parts[$i] & 0x7F)) . $temp; |
|
| 1017 | + $temp = chr(0x80 | ($parts[$i] & 0x7F)).$temp; |
|
| 1019 | 1018 | $parts[$i] >>= 7; |
| 1020 | 1019 | } |
| 1021 | 1020 | $temp[strlen($temp) - 1] = $temp[strlen($temp) - 1] & chr(0x7F); |
| 1022 | 1021 | } |
| 1023 | - $value.= $temp; |
|
| 1022 | + $value .= $temp; |
|
| 1024 | 1023 | } |
| 1025 | 1024 | break; |
| 1026 | 1025 | case self::TYPE_ANY: |
@@ -1056,7 +1055,7 @@ discard block |
||
| 1056 | 1055 | $filters = $filters[$part]; |
| 1057 | 1056 | } |
| 1058 | 1057 | if ($filters === false) { |
| 1059 | - throw new \RuntimeException('No filters defined for ' . implode('/', $loc)); |
|
| 1058 | + throw new \RuntimeException('No filters defined for '.implode('/', $loc)); |
|
| 1060 | 1059 | return false; |
| 1061 | 1060 | } |
| 1062 | 1061 | return $this->_encode_der($source, $filters + $mapping, null, $special); |
@@ -1080,7 +1079,7 @@ discard block |
||
| 1080 | 1079 | $value = $source ? "\xFF" : "\x00"; |
| 1081 | 1080 | break; |
| 1082 | 1081 | default: |
| 1083 | - throw new \RuntimeException('Mapping provides no type definition for ' . implode('/', $this->location)); |
|
| 1082 | + throw new \RuntimeException('Mapping provides no type definition for '.implode('/', $this->location)); |
|
| 1084 | 1083 | return false; |
| 1085 | 1084 | } |
| 1086 | 1085 | |
@@ -1090,14 +1089,14 @@ discard block |
||
| 1090 | 1089 | |
| 1091 | 1090 | if (isset($mapping['cast'])) { |
| 1092 | 1091 | if (isset($mapping['explicit']) || $mapping['type'] == self::TYPE_CHOICE) { |
| 1093 | - $value = chr($tag) . Functions::encodeLength(strlen($value)) . $value; |
|
| 1092 | + $value = chr($tag).Functions::encodeLength(strlen($value)).$value; |
|
| 1094 | 1093 | $tag = ($mapping['class'] << 6) | 0x20 | $mapping['cast']; |
| 1095 | 1094 | } else { |
| 1096 | 1095 | $tag = ($mapping['class'] << 6) | (ord($temp[0]) & 0x20) | $mapping['cast']; |
| 1097 | 1096 | } |
| 1098 | 1097 | } |
| 1099 | 1098 | |
| 1100 | - return chr($tag) . Functions::encodeLength(strlen($value)) . $value; |
|
| 1099 | + return chr($tag).Functions::encodeLength(strlen($value)).$value; |
|
| 1101 | 1100 | } |
| 1102 | 1101 | |
| 1103 | 1102 | /** |
@@ -1121,8 +1120,7 @@ discard block |
||
| 1121 | 1120 | http://www.obj-sys.com/asn1tutorial/node14.html */ |
| 1122 | 1121 | |
| 1123 | 1122 | $pattern = $tag == self::TYPE_UTC_TIME ? |
| 1124 | - '#(..)(..)(..)(..)(..)(..)(.*)#' : |
|
| 1125 | - '#(....)(..)(..)(..)(..)(..).*([Z+-].*)$#'; |
|
| 1123 | + '#(..)(..)(..)(..)(..)(..)(.*)#' : '#(....)(..)(..)(..)(..)(..).*([Z+-].*)$#'; |
|
| 1126 | 1124 | |
| 1127 | 1125 | preg_match($pattern, $content, $matches); |
| 1128 | 1126 | |
@@ -1704,7 +1704,7 @@ discard block |
||
| 1704 | 1704 | * |
| 1705 | 1705 | * @param array ref $root |
| 1706 | 1706 | * @param string $path |
| 1707 | - * @param object $asn1 |
|
| 1707 | + * @param ASN1 $asn1 |
|
| 1708 | 1708 | * @access private |
| 1709 | 1709 | */ |
| 1710 | 1710 | function _mapInAttributes(&$root, $path, $asn1) |
@@ -1745,7 +1745,7 @@ discard block |
||
| 1745 | 1745 | * |
| 1746 | 1746 | * @param array ref $root |
| 1747 | 1747 | * @param string $path |
| 1748 | - * @param object $asn1 |
|
| 1748 | + * @param ASN1 $asn1 |
|
| 1749 | 1749 | * @access private |
| 1750 | 1750 | */ |
| 1751 | 1751 | function _mapOutAttributes(&$root, $path, $asn1) |
@@ -1788,7 +1788,7 @@ discard block |
||
| 1788 | 1788 | * |
| 1789 | 1789 | * @param array ref $root |
| 1790 | 1790 | * @param string $path |
| 1791 | - * @param object $asn1 |
|
| 1791 | + * @param ASN1 $asn1 |
|
| 1792 | 1792 | * @access private |
| 1793 | 1793 | */ |
| 1794 | 1794 | function _mapInDNs(&$root, $path, $asn1) |
@@ -1818,7 +1818,7 @@ discard block |
||
| 1818 | 1818 | * |
| 1819 | 1819 | * @param array ref $root |
| 1820 | 1820 | * @param string $path |
| 1821 | - * @param object $asn1 |
|
| 1821 | + * @param ASN1 $asn1 |
|
| 1822 | 1822 | * @access private |
| 1823 | 1823 | */ |
| 1824 | 1824 | function _mapOutDNs(&$root, $path, $asn1) |
@@ -2113,7 +2113,7 @@ discard block |
||
| 2113 | 2113 | * |
| 2114 | 2114 | * @param bool $caonly optional |
| 2115 | 2115 | * @access public |
| 2116 | - * @return mixed |
|
| 2116 | + * @return null|boolean |
|
| 2117 | 2117 | */ |
| 2118 | 2118 | function validateSignature($caonly = true) |
| 2119 | 2119 | { |
@@ -2327,7 +2327,7 @@ discard block |
||
| 2327 | 2327 | * |
| 2328 | 2328 | * @param string $propName |
| 2329 | 2329 | * @access private |
| 2330 | - * @return mixed |
|
| 2330 | + * @return string|false |
|
| 2331 | 2331 | */ |
| 2332 | 2332 | function _translateDNProp($propName) |
| 2333 | 2333 | { |
@@ -2585,7 +2585,7 @@ discard block |
||
| 2585 | 2585 | /** |
| 2586 | 2586 | * Get the Distinguished Name for a certificates subject |
| 2587 | 2587 | * |
| 2588 | - * @param mixed $format optional |
|
| 2588 | + * @param integer $format optional |
|
| 2589 | 2589 | * @param array $dn optional |
| 2590 | 2590 | * @access public |
| 2591 | 2591 | * @return bool |
@@ -2734,7 +2734,7 @@ discard block |
||
| 2734 | 2734 | * |
| 2735 | 2735 | * @param int $format optional |
| 2736 | 2736 | * @access public |
| 2737 | - * @return mixed |
|
| 2737 | + * @return boolean |
|
| 2738 | 2738 | */ |
| 2739 | 2739 | function getIssuerDN($format = self::DN_ARRAY) |
| 2740 | 2740 | { |
@@ -2756,7 +2756,7 @@ discard block |
||
| 2756 | 2756 | * |
| 2757 | 2757 | * @param int $format optional |
| 2758 | 2758 | * @access public |
| 2759 | - * @return mixed |
|
| 2759 | + * @return boolean |
|
| 2760 | 2760 | */ |
| 2761 | 2761 | function getSubjectDN($format = self::DN_ARRAY) |
| 2762 | 2762 | { |
@@ -2872,7 +2872,7 @@ discard block |
||
| 2872 | 2872 | * |
| 2873 | 2873 | * @param object $key |
| 2874 | 2874 | * @access public |
| 2875 | - * @return bool |
|
| 2875 | + * @return boolean|null |
|
| 2876 | 2876 | */ |
| 2877 | 2877 | function setPublicKey($key) |
| 2878 | 2878 | { |
@@ -3087,8 +3087,8 @@ discard block |
||
| 3087 | 3087 | * |
| 3088 | 3088 | * https://developer.mozilla.org/en-US/docs/HTML/Element/keygen |
| 3089 | 3089 | * |
| 3090 | - * @param string $csr |
|
| 3091 | 3090 | * @access public |
| 3091 | + * @param false|string $spkac |
|
| 3092 | 3092 | * @return mixed |
| 3093 | 3093 | */ |
| 3094 | 3094 | function loadSPKAC($spkac) |
@@ -3158,7 +3158,6 @@ discard block |
||
| 3158 | 3158 | /** |
| 3159 | 3159 | * Save a SPKAC CSR request |
| 3160 | 3160 | * |
| 3161 | - * @param array $csr |
|
| 3162 | 3161 | * @param int $format optional |
| 3163 | 3162 | * @access public |
| 3164 | 3163 | * @return string |
@@ -3789,7 +3788,6 @@ discard block |
||
| 3789 | 3788 | * X.509 certificate signing helper function. |
| 3790 | 3789 | * |
| 3791 | 3790 | * @param object $key |
| 3792 | - * @param \phpseclib\File\X509 $subject |
|
| 3793 | 3791 | * @param string $signatureAlgorithm |
| 3794 | 3792 | * @access public |
| 3795 | 3793 | * @throws \phpseclib\Exception\UnsupportedAlgorithmException if the algorithm is unsupported |
@@ -4325,7 +4323,7 @@ discard block |
||
| 4325 | 4323 | * |
| 4326 | 4324 | * @param string $id |
| 4327 | 4325 | * @param mixed $value |
| 4328 | - * @param bool $disposition optional |
|
| 4326 | + * @param integer $disposition optional |
|
| 4329 | 4327 | * @access public |
| 4330 | 4328 | * @return bool |
| 4331 | 4329 | */ |
@@ -4483,7 +4481,7 @@ discard block |
||
| 4483 | 4481 | * Format a public key as appropriate |
| 4484 | 4482 | * |
| 4485 | 4483 | * @access private |
| 4486 | - * @return array |
|
| 4484 | + * @return string |
|
| 4487 | 4485 | */ |
| 4488 | 4486 | function _formatSubjectPublicKey() |
| 4489 | 4487 | { |
@@ -4517,7 +4515,6 @@ discard block |
||
| 4517 | 4515 | * Set the IP Addresses's which the cert is to be valid for |
| 4518 | 4516 | * |
| 4519 | 4517 | * @access public |
| 4520 | - * @param string $ipAddress optional |
|
| 4521 | 4518 | */ |
| 4522 | 4519 | function setIPAddress() |
| 4523 | 4520 | { |
@@ -402,10 +402,10 @@ discard block |
||
| 402 | 402 | 'children' => array( |
| 403 | 403 | 'extnId' => array('type' => ASN1::TYPE_OBJECT_IDENTIFIER), |
| 404 | 404 | 'critical' => array( |
| 405 | - 'type' => ASN1::TYPE_BOOLEAN, |
|
| 406 | - 'optional' => true, |
|
| 407 | - 'default' => false |
|
| 408 | - ), |
|
| 405 | + 'type' => ASN1::TYPE_BOOLEAN, |
|
| 406 | + 'optional' => true, |
|
| 407 | + 'default' => false |
|
| 408 | + ), |
|
| 409 | 409 | 'extnValue' => array('type' => ASN1::TYPE_OCTET_STRING) |
| 410 | 410 | ) |
| 411 | 411 | ); |
@@ -460,11 +460,11 @@ discard block |
||
| 460 | 460 | // technically, default implies optional, but we'll define it as being optional, none-the-less, just to |
| 461 | 461 | // reenforce that fact |
| 462 | 462 | 'version' => array( |
| 463 | - 'constant' => 0, |
|
| 464 | - 'optional' => true, |
|
| 465 | - 'explicit' => true, |
|
| 466 | - 'default' => 'v1' |
|
| 467 | - ) + $Version, |
|
| 463 | + 'constant' => 0, |
|
| 464 | + 'optional' => true, |
|
| 465 | + 'explicit' => true, |
|
| 466 | + 'default' => 'v1' |
|
| 467 | + ) + $Version, |
|
| 468 | 468 | 'serialNumber' => $CertificateSerialNumber, |
| 469 | 469 | 'signature' => $AlgorithmIdentifier, |
| 470 | 470 | 'issuer' => $this->Name, |
@@ -473,31 +473,31 @@ discard block |
||
| 473 | 473 | 'subjectPublicKeyInfo' => $SubjectPublicKeyInfo, |
| 474 | 474 | // implicit means that the T in the TLV structure is to be rewritten, regardless of the type |
| 475 | 475 | 'issuerUniqueID' => array( |
| 476 | - 'constant' => 1, |
|
| 477 | - 'optional' => true, |
|
| 478 | - 'implicit' => true |
|
| 479 | - ) + $UniqueIdentifier, |
|
| 476 | + 'constant' => 1, |
|
| 477 | + 'optional' => true, |
|
| 478 | + 'implicit' => true |
|
| 479 | + ) + $UniqueIdentifier, |
|
| 480 | 480 | 'subjectUniqueID' => array( |
| 481 | - 'constant' => 2, |
|
| 482 | - 'optional' => true, |
|
| 483 | - 'implicit' => true |
|
| 484 | - ) + $UniqueIdentifier, |
|
| 481 | + 'constant' => 2, |
|
| 482 | + 'optional' => true, |
|
| 483 | + 'implicit' => true |
|
| 484 | + ) + $UniqueIdentifier, |
|
| 485 | 485 | // <http://tools.ietf.org/html/rfc2459#page-74> doesn't use the EXPLICIT keyword but if |
| 486 | 486 | // it's not IMPLICIT, it's EXPLICIT |
| 487 | 487 | 'extensions' => array( |
| 488 | - 'constant' => 3, |
|
| 489 | - 'optional' => true, |
|
| 490 | - 'explicit' => true |
|
| 491 | - ) + $this->Extensions |
|
| 488 | + 'constant' => 3, |
|
| 489 | + 'optional' => true, |
|
| 490 | + 'explicit' => true |
|
| 491 | + ) + $this->Extensions |
|
| 492 | 492 | ) |
| 493 | 493 | ); |
| 494 | 494 | |
| 495 | 495 | $this->Certificate = array( |
| 496 | 496 | 'type' => ASN1::TYPE_SEQUENCE, |
| 497 | 497 | 'children' => array( |
| 498 | - 'tbsCertificate' => $TBSCertificate, |
|
| 499 | - 'signatureAlgorithm' => $AlgorithmIdentifier, |
|
| 500 | - 'signature' => array('type' => ASN1::TYPE_BIT_STRING) |
|
| 498 | + 'tbsCertificate' => $TBSCertificate, |
|
| 499 | + 'signatureAlgorithm' => $AlgorithmIdentifier, |
|
| 500 | + 'signature' => array('type' => ASN1::TYPE_BIT_STRING) |
|
| 501 | 501 | ) |
| 502 | 502 | ); |
| 503 | 503 | |
@@ -520,14 +520,14 @@ discard block |
||
| 520 | 520 | 'type' => ASN1::TYPE_SEQUENCE, |
| 521 | 521 | 'children' => array( |
| 522 | 522 | 'cA' => array( |
| 523 | - 'type' => ASN1::TYPE_BOOLEAN, |
|
| 524 | - 'optional' => true, |
|
| 525 | - 'default' => false |
|
| 526 | - ), |
|
| 523 | + 'type' => ASN1::TYPE_BOOLEAN, |
|
| 524 | + 'optional' => true, |
|
| 525 | + 'default' => false |
|
| 526 | + ), |
|
| 527 | 527 | 'pathLenConstraint' => array( |
| 528 | - 'type' => ASN1::TYPE_INTEGER, |
|
| 529 | - 'optional' => true |
|
| 530 | - ) |
|
| 528 | + 'type' => ASN1::TYPE_INTEGER, |
|
| 529 | + 'optional' => true |
|
| 530 | + ) |
|
| 531 | 531 | ) |
| 532 | 532 | ); |
| 533 | 533 | |
@@ -544,29 +544,29 @@ discard block |
||
| 544 | 544 | 'type' => ASN1::TYPE_SET, |
| 545 | 545 | 'children' => array( |
| 546 | 546 | 'surname' => array( |
| 547 | - 'type' => ASN1::TYPE_PRINTABLE_STRING, |
|
| 548 | - 'constant' => 0, |
|
| 549 | - 'optional' => true, |
|
| 550 | - 'implicit' => true |
|
| 551 | - ), |
|
| 547 | + 'type' => ASN1::TYPE_PRINTABLE_STRING, |
|
| 548 | + 'constant' => 0, |
|
| 549 | + 'optional' => true, |
|
| 550 | + 'implicit' => true |
|
| 551 | + ), |
|
| 552 | 552 | 'given-name' => array( |
| 553 | - 'type' => ASN1::TYPE_PRINTABLE_STRING, |
|
| 554 | - 'constant' => 1, |
|
| 555 | - 'optional' => true, |
|
| 556 | - 'implicit' => true |
|
| 557 | - ), |
|
| 553 | + 'type' => ASN1::TYPE_PRINTABLE_STRING, |
|
| 554 | + 'constant' => 1, |
|
| 555 | + 'optional' => true, |
|
| 556 | + 'implicit' => true |
|
| 557 | + ), |
|
| 558 | 558 | 'initials' => array( |
| 559 | - 'type' => ASN1::TYPE_PRINTABLE_STRING, |
|
| 560 | - 'constant' => 2, |
|
| 561 | - 'optional' => true, |
|
| 562 | - 'implicit' => true |
|
| 563 | - ), |
|
| 559 | + 'type' => ASN1::TYPE_PRINTABLE_STRING, |
|
| 560 | + 'constant' => 2, |
|
| 561 | + 'optional' => true, |
|
| 562 | + 'implicit' => true |
|
| 563 | + ), |
|
| 564 | 564 | 'generation-qualifier' => array( |
| 565 | - 'type' => ASN1::TYPE_PRINTABLE_STRING, |
|
| 566 | - 'constant' => 3, |
|
| 567 | - 'optional' => true, |
|
| 568 | - 'implicit' => true |
|
| 569 | - ) |
|
| 565 | + 'type' => ASN1::TYPE_PRINTABLE_STRING, |
|
| 566 | + 'constant' => 3, |
|
| 567 | + 'optional' => true, |
|
| 568 | + 'implicit' => true |
|
| 569 | + ) |
|
| 570 | 570 | ) |
| 571 | 571 | ); |
| 572 | 572 | |
@@ -613,26 +613,26 @@ discard block |
||
| 613 | 613 | $AnotherName = array( |
| 614 | 614 | 'type' => ASN1::TYPE_SEQUENCE, |
| 615 | 615 | 'children' => array( |
| 616 | - 'type-id' => array('type' => ASN1::TYPE_OBJECT_IDENTIFIER), |
|
| 617 | - 'value' => array( |
|
| 618 | - 'type' => ASN1::TYPE_ANY, |
|
| 619 | - 'constant' => 0, |
|
| 620 | - 'optional' => true, |
|
| 621 | - 'explicit' => true |
|
| 622 | - ) |
|
| 616 | + 'type-id' => array('type' => ASN1::TYPE_OBJECT_IDENTIFIER), |
|
| 617 | + 'value' => array( |
|
| 618 | + 'type' => ASN1::TYPE_ANY, |
|
| 619 | + 'constant' => 0, |
|
| 620 | + 'optional' => true, |
|
| 621 | + 'explicit' => true |
|
| 622 | + ) |
|
| 623 | 623 | ) |
| 624 | 624 | ); |
| 625 | 625 | |
| 626 | 626 | $ExtensionAttribute = array( |
| 627 | 627 | 'type' => ASN1::TYPE_SEQUENCE, |
| 628 | 628 | 'children' => array( |
| 629 | - 'extension-attribute-type' => array( |
|
| 629 | + 'extension-attribute-type' => array( |
|
| 630 | 630 | 'type' => ASN1::TYPE_PRINTABLE_STRING, |
| 631 | 631 | 'constant' => 0, |
| 632 | 632 | 'optional' => true, |
| 633 | 633 | 'implicit' => true |
| 634 | 634 | ), |
| 635 | - 'extension-attribute-value' => array( |
|
| 635 | + 'extension-attribute-value' => array( |
|
| 636 | 636 | 'type' => ASN1::TYPE_ANY, |
| 637 | 637 | 'constant' => 1, |
| 638 | 638 | 'optional' => true, |
@@ -651,8 +651,8 @@ discard block |
||
| 651 | 651 | $BuiltInDomainDefinedAttribute = array( |
| 652 | 652 | 'type' => ASN1::TYPE_SEQUENCE, |
| 653 | 653 | 'children' => array( |
| 654 | - 'type' => array('type' => ASN1::TYPE_PRINTABLE_STRING), |
|
| 655 | - 'value' => array('type' => ASN1::TYPE_PRINTABLE_STRING) |
|
| 654 | + 'type' => array('type' => ASN1::TYPE_PRINTABLE_STRING), |
|
| 655 | + 'value' => array('type' => ASN1::TYPE_PRINTABLE_STRING) |
|
| 656 | 656 | ) |
| 657 | 657 | ); |
| 658 | 658 | |
@@ -669,63 +669,63 @@ discard block |
||
| 669 | 669 | 'country-name' => array('optional' => true) + $CountryName, |
| 670 | 670 | 'administration-domain-name' => array('optional' => true) + $AdministrationDomainName, |
| 671 | 671 | 'network-address' => array( |
| 672 | - 'constant' => 0, |
|
| 673 | - 'optional' => true, |
|
| 674 | - 'implicit' => true |
|
| 675 | - ) + $NetworkAddress, |
|
| 672 | + 'constant' => 0, |
|
| 673 | + 'optional' => true, |
|
| 674 | + 'implicit' => true |
|
| 675 | + ) + $NetworkAddress, |
|
| 676 | 676 | 'terminal-identifier' => array( |
| 677 | - 'constant' => 1, |
|
| 678 | - 'optional' => true, |
|
| 679 | - 'implicit' => true |
|
| 680 | - ) + $TerminalIdentifier, |
|
| 677 | + 'constant' => 1, |
|
| 678 | + 'optional' => true, |
|
| 679 | + 'implicit' => true |
|
| 680 | + ) + $TerminalIdentifier, |
|
| 681 | 681 | 'private-domain-name' => array( |
| 682 | - 'constant' => 2, |
|
| 683 | - 'optional' => true, |
|
| 684 | - 'explicit' => true |
|
| 685 | - ) + $PrivateDomainName, |
|
| 682 | + 'constant' => 2, |
|
| 683 | + 'optional' => true, |
|
| 684 | + 'explicit' => true |
|
| 685 | + ) + $PrivateDomainName, |
|
| 686 | 686 | 'organization-name' => array( |
| 687 | - 'constant' => 3, |
|
| 688 | - 'optional' => true, |
|
| 689 | - 'implicit' => true |
|
| 690 | - ) + $OrganizationName, |
|
| 687 | + 'constant' => 3, |
|
| 688 | + 'optional' => true, |
|
| 689 | + 'implicit' => true |
|
| 690 | + ) + $OrganizationName, |
|
| 691 | 691 | 'numeric-user-identifier' => array( |
| 692 | - 'constant' => 4, |
|
| 693 | - 'optional' => true, |
|
| 694 | - 'implicit' => true |
|
| 695 | - ) + $NumericUserIdentifier, |
|
| 692 | + 'constant' => 4, |
|
| 693 | + 'optional' => true, |
|
| 694 | + 'implicit' => true |
|
| 695 | + ) + $NumericUserIdentifier, |
|
| 696 | 696 | 'personal-name' => array( |
| 697 | - 'constant' => 5, |
|
| 698 | - 'optional' => true, |
|
| 699 | - 'implicit' => true |
|
| 700 | - ) + $PersonalName, |
|
| 697 | + 'constant' => 5, |
|
| 698 | + 'optional' => true, |
|
| 699 | + 'implicit' => true |
|
| 700 | + ) + $PersonalName, |
|
| 701 | 701 | 'organizational-unit-names' => array( |
| 702 | - 'constant' => 6, |
|
| 703 | - 'optional' => true, |
|
| 704 | - 'implicit' => true |
|
| 705 | - ) + $OrganizationalUnitNames |
|
| 702 | + 'constant' => 6, |
|
| 703 | + 'optional' => true, |
|
| 704 | + 'implicit' => true |
|
| 705 | + ) + $OrganizationalUnitNames |
|
| 706 | 706 | ) |
| 707 | 707 | ); |
| 708 | 708 | |
| 709 | 709 | $ORAddress = array( |
| 710 | 710 | 'type' => ASN1::TYPE_SEQUENCE, |
| 711 | 711 | 'children' => array( |
| 712 | - 'built-in-standard-attributes' => $BuiltInStandardAttributes, |
|
| 713 | - 'built-in-domain-defined-attributes' => array('optional' => true) + $BuiltInDomainDefinedAttributes, |
|
| 714 | - 'extension-attributes' => array('optional' => true) + $ExtensionAttributes |
|
| 712 | + 'built-in-standard-attributes' => $BuiltInStandardAttributes, |
|
| 713 | + 'built-in-domain-defined-attributes' => array('optional' => true) + $BuiltInDomainDefinedAttributes, |
|
| 714 | + 'extension-attributes' => array('optional' => true) + $ExtensionAttributes |
|
| 715 | 715 | ) |
| 716 | 716 | ); |
| 717 | 717 | |
| 718 | 718 | $EDIPartyName = array( |
| 719 | 719 | 'type' => ASN1::TYPE_SEQUENCE, |
| 720 | 720 | 'children' => array( |
| 721 | - 'nameAssigner' => array( |
|
| 721 | + 'nameAssigner' => array( |
|
| 722 | 722 | 'constant' => 0, |
| 723 | 723 | 'optional' => true, |
| 724 | 724 | 'implicit' => true |
| 725 | 725 | ) + $this->DirectoryString, |
| 726 | - // partyName is technically required but \phpseclib\File\ASN1 doesn't currently support non-optional constants and |
|
| 727 | - // setting it to optional gets the job done in any event. |
|
| 728 | - 'partyName' => array( |
|
| 726 | + // partyName is technically required but \phpseclib\File\ASN1 doesn't currently support non-optional constants and |
|
| 727 | + // setting it to optional gets the job done in any event. |
|
| 728 | + 'partyName' => array( |
|
| 729 | 729 | 'constant' => 1, |
| 730 | 730 | 'optional' => true, |
| 731 | 731 | 'implicit' => true |
@@ -737,55 +737,55 @@ discard block |
||
| 737 | 737 | 'type' => ASN1::TYPE_CHOICE, |
| 738 | 738 | 'children' => array( |
| 739 | 739 | 'otherName' => array( |
| 740 | - 'constant' => 0, |
|
| 741 | - 'optional' => true, |
|
| 742 | - 'implicit' => true |
|
| 743 | - ) + $AnotherName, |
|
| 740 | + 'constant' => 0, |
|
| 741 | + 'optional' => true, |
|
| 742 | + 'implicit' => true |
|
| 743 | + ) + $AnotherName, |
|
| 744 | 744 | 'rfc822Name' => array( |
| 745 | - 'type' => ASN1::TYPE_IA5_STRING, |
|
| 746 | - 'constant' => 1, |
|
| 747 | - 'optional' => true, |
|
| 748 | - 'implicit' => true |
|
| 749 | - ), |
|
| 745 | + 'type' => ASN1::TYPE_IA5_STRING, |
|
| 746 | + 'constant' => 1, |
|
| 747 | + 'optional' => true, |
|
| 748 | + 'implicit' => true |
|
| 749 | + ), |
|
| 750 | 750 | 'dNSName' => array( |
| 751 | - 'type' => ASN1::TYPE_IA5_STRING, |
|
| 752 | - 'constant' => 2, |
|
| 753 | - 'optional' => true, |
|
| 754 | - 'implicit' => true |
|
| 755 | - ), |
|
| 751 | + 'type' => ASN1::TYPE_IA5_STRING, |
|
| 752 | + 'constant' => 2, |
|
| 753 | + 'optional' => true, |
|
| 754 | + 'implicit' => true |
|
| 755 | + ), |
|
| 756 | 756 | 'x400Address' => array( |
| 757 | - 'constant' => 3, |
|
| 758 | - 'optional' => true, |
|
| 759 | - 'implicit' => true |
|
| 760 | - ) + $ORAddress, |
|
| 757 | + 'constant' => 3, |
|
| 758 | + 'optional' => true, |
|
| 759 | + 'implicit' => true |
|
| 760 | + ) + $ORAddress, |
|
| 761 | 761 | 'directoryName' => array( |
| 762 | - 'constant' => 4, |
|
| 763 | - 'optional' => true, |
|
| 764 | - 'explicit' => true |
|
| 765 | - ) + $this->Name, |
|
| 762 | + 'constant' => 4, |
|
| 763 | + 'optional' => true, |
|
| 764 | + 'explicit' => true |
|
| 765 | + ) + $this->Name, |
|
| 766 | 766 | 'ediPartyName' => array( |
| 767 | - 'constant' => 5, |
|
| 768 | - 'optional' => true, |
|
| 769 | - 'implicit' => true |
|
| 770 | - ) + $EDIPartyName, |
|
| 767 | + 'constant' => 5, |
|
| 768 | + 'optional' => true, |
|
| 769 | + 'implicit' => true |
|
| 770 | + ) + $EDIPartyName, |
|
| 771 | 771 | 'uniformResourceIdentifier' => array( |
| 772 | - 'type' => ASN1::TYPE_IA5_STRING, |
|
| 773 | - 'constant' => 6, |
|
| 774 | - 'optional' => true, |
|
| 775 | - 'implicit' => true |
|
| 776 | - ), |
|
| 772 | + 'type' => ASN1::TYPE_IA5_STRING, |
|
| 773 | + 'constant' => 6, |
|
| 774 | + 'optional' => true, |
|
| 775 | + 'implicit' => true |
|
| 776 | + ), |
|
| 777 | 777 | 'iPAddress' => array( |
| 778 | - 'type' => ASN1::TYPE_OCTET_STRING, |
|
| 779 | - 'constant' => 7, |
|
| 780 | - 'optional' => true, |
|
| 781 | - 'implicit' => true |
|
| 782 | - ), |
|
| 778 | + 'type' => ASN1::TYPE_OCTET_STRING, |
|
| 779 | + 'constant' => 7, |
|
| 780 | + 'optional' => true, |
|
| 781 | + 'implicit' => true |
|
| 782 | + ), |
|
| 783 | 783 | 'registeredID' => array( |
| 784 | - 'type' => ASN1::TYPE_OBJECT_IDENTIFIER, |
|
| 785 | - 'constant' => 8, |
|
| 786 | - 'optional' => true, |
|
| 787 | - 'implicit' => true |
|
| 788 | - ) |
|
| 784 | + 'type' => ASN1::TYPE_OBJECT_IDENTIFIER, |
|
| 785 | + 'constant' => 8, |
|
| 786 | + 'optional' => true, |
|
| 787 | + 'implicit' => true |
|
| 788 | + ) |
|
| 789 | 789 | ) |
| 790 | 790 | ); |
| 791 | 791 | |
@@ -817,15 +817,15 @@ discard block |
||
| 817 | 817 | 'type' => ASN1::TYPE_CHOICE, |
| 818 | 818 | 'children' => array( |
| 819 | 819 | 'fullName' => array( |
| 820 | - 'constant' => 0, |
|
| 821 | - 'optional' => true, |
|
| 822 | - 'implicit' => true |
|
| 823 | - ) + $GeneralNames, |
|
| 820 | + 'constant' => 0, |
|
| 821 | + 'optional' => true, |
|
| 822 | + 'implicit' => true |
|
| 823 | + ) + $GeneralNames, |
|
| 824 | 824 | 'nameRelativeToCRLIssuer' => array( |
| 825 | - 'constant' => 1, |
|
| 826 | - 'optional' => true, |
|
| 827 | - 'implicit' => true |
|
| 828 | - ) + $this->RelativeDistinguishedName |
|
| 825 | + 'constant' => 1, |
|
| 826 | + 'optional' => true, |
|
| 827 | + 'implicit' => true |
|
| 828 | + ) + $this->RelativeDistinguishedName |
|
| 829 | 829 | ) |
| 830 | 830 | ); |
| 831 | 831 | |
@@ -833,20 +833,20 @@ discard block |
||
| 833 | 833 | 'type' => ASN1::TYPE_SEQUENCE, |
| 834 | 834 | 'children' => array( |
| 835 | 835 | 'distributionPoint' => array( |
| 836 | - 'constant' => 0, |
|
| 837 | - 'optional' => true, |
|
| 838 | - 'explicit' => true |
|
| 839 | - ) + $DistributionPointName, |
|
| 836 | + 'constant' => 0, |
|
| 837 | + 'optional' => true, |
|
| 838 | + 'explicit' => true |
|
| 839 | + ) + $DistributionPointName, |
|
| 840 | 840 | 'reasons' => array( |
| 841 | - 'constant' => 1, |
|
| 842 | - 'optional' => true, |
|
| 843 | - 'implicit' => true |
|
| 844 | - ) + $ReasonFlags, |
|
| 841 | + 'constant' => 1, |
|
| 842 | + 'optional' => true, |
|
| 843 | + 'implicit' => true |
|
| 844 | + ) + $ReasonFlags, |
|
| 845 | 845 | 'cRLIssuer' => array( |
| 846 | - 'constant' => 2, |
|
| 847 | - 'optional' => true, |
|
| 848 | - 'implicit' => true |
|
| 849 | - ) + $GeneralNames |
|
| 846 | + 'constant' => 2, |
|
| 847 | + 'optional' => true, |
|
| 848 | + 'implicit' => true |
|
| 849 | + ) + $GeneralNames |
|
| 850 | 850 | ) |
| 851 | 851 | ); |
| 852 | 852 | |
@@ -861,20 +861,20 @@ discard block |
||
| 861 | 861 | 'type' => ASN1::TYPE_SEQUENCE, |
| 862 | 862 | 'children' => array( |
| 863 | 863 | 'keyIdentifier' => array( |
| 864 | - 'constant' => 0, |
|
| 865 | - 'optional' => true, |
|
| 866 | - 'implicit' => true |
|
| 867 | - ) + $this->KeyIdentifier, |
|
| 864 | + 'constant' => 0, |
|
| 865 | + 'optional' => true, |
|
| 866 | + 'implicit' => true |
|
| 867 | + ) + $this->KeyIdentifier, |
|
| 868 | 868 | 'authorityCertIssuer' => array( |
| 869 | - 'constant' => 1, |
|
| 870 | - 'optional' => true, |
|
| 871 | - 'implicit' => true |
|
| 872 | - ) + $GeneralNames, |
|
| 869 | + 'constant' => 1, |
|
| 870 | + 'optional' => true, |
|
| 871 | + 'implicit' => true |
|
| 872 | + ) + $GeneralNames, |
|
| 873 | 873 | 'authorityCertSerialNumber' => array( |
| 874 | - 'constant' => 2, |
|
| 875 | - 'optional' => true, |
|
| 876 | - 'implicit' => true |
|
| 877 | - ) + $CertificateSerialNumber |
|
| 874 | + 'constant' => 2, |
|
| 875 | + 'optional' => true, |
|
| 876 | + 'implicit' => true |
|
| 877 | + ) + $CertificateSerialNumber |
|
| 878 | 878 | ) |
| 879 | 879 | ); |
| 880 | 880 | |
@@ -895,12 +895,12 @@ discard block |
||
| 895 | 895 | 'children' => array( |
| 896 | 896 | 'policyIdentifier' => $CertPolicyId, |
| 897 | 897 | 'policyQualifiers' => array( |
| 898 | - 'type' => ASN1::TYPE_SEQUENCE, |
|
| 899 | - 'min' => 0, |
|
| 900 | - 'max' => -1, |
|
| 901 | - 'optional' => true, |
|
| 902 | - 'children' => $PolicyQualifierInfo |
|
| 903 | - ) |
|
| 898 | + 'type' => ASN1::TYPE_SEQUENCE, |
|
| 899 | + 'min' => 0, |
|
| 900 | + 'max' => -1, |
|
| 901 | + 'optional' => true, |
|
| 902 | + 'children' => $PolicyQualifierInfo |
|
| 903 | + ) |
|
| 904 | 904 | ) |
| 905 | 905 | ); |
| 906 | 906 | |
@@ -916,12 +916,12 @@ discard block |
||
| 916 | 916 | 'min' => 1, |
| 917 | 917 | 'max' => -1, |
| 918 | 918 | 'children' => array( |
| 919 | - 'type' => ASN1::TYPE_SEQUENCE, |
|
| 920 | - 'children' => array( |
|
| 921 | - 'issuerDomainPolicy' => $CertPolicyId, |
|
| 922 | - 'subjectDomainPolicy' => $CertPolicyId |
|
| 923 | - ) |
|
| 924 | - ) |
|
| 919 | + 'type' => ASN1::TYPE_SEQUENCE, |
|
| 920 | + 'children' => array( |
|
| 921 | + 'issuerDomainPolicy' => $CertPolicyId, |
|
| 922 | + 'subjectDomainPolicy' => $CertPolicyId |
|
| 923 | + ) |
|
| 924 | + ) |
|
| 925 | 925 | ); |
| 926 | 926 | |
| 927 | 927 | $KeyPurposeId = array('type' => ASN1::TYPE_OBJECT_IDENTIFIER); |
@@ -954,15 +954,15 @@ discard block |
||
| 954 | 954 | 'type' => ASN1::TYPE_SEQUENCE, |
| 955 | 955 | 'children' => array( |
| 956 | 956 | 'notBefore' => array( |
| 957 | - 'constant' => 0, |
|
| 958 | - 'optional' => true, |
|
| 959 | - 'implicit' => true, |
|
| 960 | - 'type' => ASN1::TYPE_GENERALIZED_TIME), |
|
| 957 | + 'constant' => 0, |
|
| 958 | + 'optional' => true, |
|
| 959 | + 'implicit' => true, |
|
| 960 | + 'type' => ASN1::TYPE_GENERALIZED_TIME), |
|
| 961 | 961 | 'notAfter' => array( |
| 962 | - 'constant' => 1, |
|
| 963 | - 'optional' => true, |
|
| 964 | - 'implicit' => true, |
|
| 965 | - 'type' => ASN1::TYPE_GENERALIZED_TIME) |
|
| 962 | + 'constant' => 1, |
|
| 963 | + 'optional' => true, |
|
| 964 | + 'implicit' => true, |
|
| 965 | + 'type' => ASN1::TYPE_GENERALIZED_TIME) |
|
| 966 | 966 | ) |
| 967 | 967 | ); |
| 968 | 968 | |
@@ -973,16 +973,16 @@ discard block |
||
| 973 | 973 | 'children' => array( |
| 974 | 974 | 'base' => $GeneralName, |
| 975 | 975 | 'minimum' => array( |
| 976 | - 'constant' => 0, |
|
| 977 | - 'optional' => true, |
|
| 978 | - 'implicit' => true, |
|
| 979 | - 'default' => new BigInteger(0) |
|
| 980 | - ) + $BaseDistance, |
|
| 976 | + 'constant' => 0, |
|
| 977 | + 'optional' => true, |
|
| 978 | + 'implicit' => true, |
|
| 979 | + 'default' => new BigInteger(0) |
|
| 980 | + ) + $BaseDistance, |
|
| 981 | 981 | 'maximum' => array( |
| 982 | - 'constant' => 1, |
|
| 983 | - 'optional' => true, |
|
| 984 | - 'implicit' => true, |
|
| 985 | - ) + $BaseDistance |
|
| 982 | + 'constant' => 1, |
|
| 983 | + 'optional' => true, |
|
| 984 | + 'implicit' => true, |
|
| 985 | + ) + $BaseDistance |
|
| 986 | 986 | ) |
| 987 | 987 | ); |
| 988 | 988 | |
@@ -997,15 +997,15 @@ discard block |
||
| 997 | 997 | 'type' => ASN1::TYPE_SEQUENCE, |
| 998 | 998 | 'children' => array( |
| 999 | 999 | 'permittedSubtrees' => array( |
| 1000 | - 'constant' => 0, |
|
| 1001 | - 'optional' => true, |
|
| 1002 | - 'implicit' => true |
|
| 1003 | - ) + $GeneralSubtrees, |
|
| 1000 | + 'constant' => 0, |
|
| 1001 | + 'optional' => true, |
|
| 1002 | + 'implicit' => true |
|
| 1003 | + ) + $GeneralSubtrees, |
|
| 1004 | 1004 | 'excludedSubtrees' => array( |
| 1005 | - 'constant' => 1, |
|
| 1006 | - 'optional' => true, |
|
| 1007 | - 'implicit' => true |
|
| 1008 | - ) + $GeneralSubtrees |
|
| 1005 | + 'constant' => 1, |
|
| 1006 | + 'optional' => true, |
|
| 1007 | + 'implicit' => true |
|
| 1008 | + ) + $GeneralSubtrees |
|
| 1009 | 1009 | ) |
| 1010 | 1010 | ); |
| 1011 | 1011 | |
@@ -1026,11 +1026,11 @@ discard block |
||
| 1026 | 1026 | 'children' => array( |
| 1027 | 1027 | 'organization' => $DisplayText, |
| 1028 | 1028 | 'noticeNumbers' => array( |
| 1029 | - 'type' => ASN1::TYPE_SEQUENCE, |
|
| 1030 | - 'min' => 1, |
|
| 1031 | - 'max' => 200, |
|
| 1032 | - 'children' => array('type' => ASN1::TYPE_INTEGER) |
|
| 1033 | - ) |
|
| 1029 | + 'type' => ASN1::TYPE_SEQUENCE, |
|
| 1030 | + 'min' => 1, |
|
| 1031 | + 'max' => 200, |
|
| 1032 | + 'children' => array('type' => ASN1::TYPE_INTEGER) |
|
| 1033 | + ) |
|
| 1034 | 1034 | ) |
| 1035 | 1035 | ); |
| 1036 | 1036 | |
@@ -1038,13 +1038,13 @@ discard block |
||
| 1038 | 1038 | 'type' => ASN1::TYPE_SEQUENCE, |
| 1039 | 1039 | 'children' => array( |
| 1040 | 1040 | 'noticeRef' => array( |
| 1041 | - 'optional' => true, |
|
| 1042 | - 'implicit' => true |
|
| 1043 | - ) + $NoticeReference, |
|
| 1041 | + 'optional' => true, |
|
| 1042 | + 'implicit' => true |
|
| 1043 | + ) + $NoticeReference, |
|
| 1044 | 1044 | 'explicitText' => array( |
| 1045 | - 'optional' => true, |
|
| 1046 | - 'implicit' => true |
|
| 1047 | - ) + $DisplayText |
|
| 1045 | + 'optional' => true, |
|
| 1046 | + 'implicit' => true |
|
| 1047 | + ) + $DisplayText |
|
| 1048 | 1048 | ) |
| 1049 | 1049 | ); |
| 1050 | 1050 | |
@@ -1073,11 +1073,11 @@ discard block |
||
| 1073 | 1073 | 'children' => array( |
| 1074 | 1074 | 'type' => $AttributeType, |
| 1075 | 1075 | 'value'=> array( |
| 1076 | - 'type' => ASN1::TYPE_SET, |
|
| 1077 | - 'min' => 1, |
|
| 1078 | - 'max' => -1, |
|
| 1079 | - 'children' => $this->AttributeValue |
|
| 1080 | - ) |
|
| 1076 | + 'type' => ASN1::TYPE_SET, |
|
| 1077 | + 'min' => 1, |
|
| 1078 | + 'max' => -1, |
|
| 1079 | + 'children' => $this->AttributeValue |
|
| 1080 | + ) |
|
| 1081 | 1081 | ) |
| 1082 | 1082 | ); |
| 1083 | 1083 | |
@@ -1101,16 +1101,16 @@ discard block |
||
| 1101 | 1101 | 'type' => ASN1::TYPE_SEQUENCE, |
| 1102 | 1102 | 'children' => array( |
| 1103 | 1103 | 'version' => array( |
| 1104 | - 'type' => ASN1::TYPE_INTEGER, |
|
| 1105 | - 'mapping' => array('v1') |
|
| 1106 | - ), |
|
| 1104 | + 'type' => ASN1::TYPE_INTEGER, |
|
| 1105 | + 'mapping' => array('v1') |
|
| 1106 | + ), |
|
| 1107 | 1107 | 'subject' => $this->Name, |
| 1108 | 1108 | 'subjectPKInfo' => $SubjectPublicKeyInfo, |
| 1109 | 1109 | 'attributes' => array( |
| 1110 | - 'constant' => 0, |
|
| 1111 | - 'optional' => true, |
|
| 1112 | - 'implicit' => true |
|
| 1113 | - ) + $Attributes, |
|
| 1110 | + 'constant' => 0, |
|
| 1111 | + 'optional' => true, |
|
| 1112 | + 'implicit' => true |
|
| 1113 | + ) + $Attributes, |
|
| 1114 | 1114 | ) |
| 1115 | 1115 | ); |
| 1116 | 1116 | |
@@ -1126,39 +1126,39 @@ discard block |
||
| 1126 | 1126 | $RevokedCertificate = array( |
| 1127 | 1127 | 'type' => ASN1::TYPE_SEQUENCE, |
| 1128 | 1128 | 'children' => array( |
| 1129 | - 'userCertificate' => $CertificateSerialNumber, |
|
| 1130 | - 'revocationDate' => $Time, |
|
| 1131 | - 'crlEntryExtensions' => array( |
|
| 1132 | - 'optional' => true |
|
| 1133 | - ) + $this->Extensions |
|
| 1134 | - ) |
|
| 1129 | + 'userCertificate' => $CertificateSerialNumber, |
|
| 1130 | + 'revocationDate' => $Time, |
|
| 1131 | + 'crlEntryExtensions' => array( |
|
| 1132 | + 'optional' => true |
|
| 1133 | + ) + $this->Extensions |
|
| 1134 | + ) |
|
| 1135 | 1135 | ); |
| 1136 | 1136 | |
| 1137 | 1137 | $TBSCertList = array( |
| 1138 | 1138 | 'type' => ASN1::TYPE_SEQUENCE, |
| 1139 | 1139 | 'children' => array( |
| 1140 | 1140 | 'version' => array( |
| 1141 | - 'optional' => true, |
|
| 1142 | - 'default' => 'v1' |
|
| 1143 | - ) + $Version, |
|
| 1141 | + 'optional' => true, |
|
| 1142 | + 'default' => 'v1' |
|
| 1143 | + ) + $Version, |
|
| 1144 | 1144 | 'signature' => $AlgorithmIdentifier, |
| 1145 | 1145 | 'issuer' => $this->Name, |
| 1146 | 1146 | 'thisUpdate' => $Time, |
| 1147 | 1147 | 'nextUpdate' => array( |
| 1148 | - 'optional' => true |
|
| 1149 | - ) + $Time, |
|
| 1148 | + 'optional' => true |
|
| 1149 | + ) + $Time, |
|
| 1150 | 1150 | 'revokedCertificates' => array( |
| 1151 | - 'type' => ASN1::TYPE_SEQUENCE, |
|
| 1152 | - 'optional' => true, |
|
| 1153 | - 'min' => 0, |
|
| 1154 | - 'max' => -1, |
|
| 1155 | - 'children' => $RevokedCertificate |
|
| 1156 | - ), |
|
| 1151 | + 'type' => ASN1::TYPE_SEQUENCE, |
|
| 1152 | + 'optional' => true, |
|
| 1153 | + 'min' => 0, |
|
| 1154 | + 'max' => -1, |
|
| 1155 | + 'children' => $RevokedCertificate |
|
| 1156 | + ), |
|
| 1157 | 1157 | 'crlExtensions' => array( |
| 1158 | - 'constant' => 0, |
|
| 1159 | - 'optional' => true, |
|
| 1160 | - 'explicit' => true |
|
| 1161 | - ) + $this->Extensions |
|
| 1158 | + 'constant' => 0, |
|
| 1159 | + 'optional' => true, |
|
| 1160 | + 'explicit' => true |
|
| 1161 | + ) + $this->Extensions |
|
| 1162 | 1162 | ) |
| 1163 | 1163 | ); |
| 1164 | 1164 | |
@@ -1174,7 +1174,7 @@ discard block |
||
| 1174 | 1174 | $this->CRLNumber = array('type' => ASN1::TYPE_INTEGER); |
| 1175 | 1175 | |
| 1176 | 1176 | $this->CRLReason = array('type' => ASN1::TYPE_ENUMERATED, |
| 1177 | - 'mapping' => array( |
|
| 1177 | + 'mapping' => array( |
|
| 1178 | 1178 | 'unspecified', |
| 1179 | 1179 | 'keyCompromise', |
| 1180 | 1180 | 'cACompromise', |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | 'default' => false, |
| 1230 | 1230 | 'implicit' => true |
| 1231 | 1231 | ) |
| 1232 | - ) |
|
| 1232 | + ) |
|
| 1233 | 1233 | ); |
| 1234 | 1234 | |
| 1235 | 1235 | $this->InvalidityDate = array('type' => ASN1::TYPE_GENERALIZED_TIME); |
@@ -4581,7 +4581,7 @@ discard block |
||
| 4581 | 4581 | |
| 4582 | 4582 | $i = count($rclist); |
| 4583 | 4583 | $rclist[] = array('userCertificate' => $serial, |
| 4584 | - 'revocationDate' => $this->_timeField(@date('D, d M Y H:i:s O'))); |
|
| 4584 | + 'revocationDate' => $this->_timeField(@date('D, d M Y H:i:s O'))); |
|
| 4585 | 4585 | return $i; |
| 4586 | 4586 | } |
| 4587 | 4587 | |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | 'children' => $BuiltInDomainDefinedAttribute |
| 664 | 664 | ); |
| 665 | 665 | |
| 666 | - $BuiltInStandardAttributes = array( |
|
| 666 | + $BuiltInStandardAttributes = array( |
|
| 667 | 667 | 'type' => ASN1::TYPE_SEQUENCE, |
| 668 | 668 | 'children' => array( |
| 669 | 669 | 'country-name' => array('optional' => true) + $CountryName, |
@@ -1528,7 +1528,7 @@ discard block |
||
| 1528 | 1528 | switch ($algorithm) { |
| 1529 | 1529 | case 'rsaEncryption': |
| 1530 | 1530 | $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'] |
| 1531 | - = Base64::encode("\0" . Base64::decode(preg_replace('#-.+-|[\r\n]#', '', $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']))); |
|
| 1531 | + = Base64::encode("\0".Base64::decode(preg_replace('#-.+-|[\r\n]#', '', $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']))); |
|
| 1532 | 1532 | /* "[For RSA keys] the parameters field MUST have ASN.1 type NULL for this algorithm identifier." |
| 1533 | 1533 | -- https://tools.ietf.org/html/rfc3279#section-2.3.1 |
| 1534 | 1534 | |
@@ -1578,7 +1578,7 @@ discard block |
||
| 1578 | 1578 | return $cert; |
| 1579 | 1579 | // case self::FORMAT_PEM: |
| 1580 | 1580 | default: |
| 1581 | - return "-----BEGIN CERTIFICATE-----\r\n" . chunk_split(Base64::encode($cert), 64) . '-----END CERTIFICATE-----'; |
|
| 1581 | + return "-----BEGIN CERTIFICATE-----\r\n".chunk_split(Base64::encode($cert), 64).'-----END CERTIFICATE-----'; |
|
| 1582 | 1582 | } |
| 1583 | 1583 | } |
| 1584 | 1584 | |
@@ -1676,7 +1676,7 @@ discard block |
||
| 1676 | 1676 | case 'id-ce-authorityKeyIdentifier': // use 00 as the serial number instead of an empty string |
| 1677 | 1677 | if (isset($value['authorityCertSerialNumber'])) { |
| 1678 | 1678 | if ($value['authorityCertSerialNumber']->toBytes() == '') { |
| 1679 | - $temp = chr((ASN1::CLASS_CONTEXT_SPECIFIC << 6) | 2) . "\1\0"; |
|
| 1679 | + $temp = chr((ASN1::CLASS_CONTEXT_SPECIFIC << 6) | 2)."\1\0"; |
|
| 1680 | 1680 | $value['authorityCertSerialNumber'] = new Element($temp); |
| 1681 | 1681 | } |
| 1682 | 1682 | } |
@@ -2041,7 +2041,7 @@ discard block |
||
| 2041 | 2041 | field in the Subject field of the certificate MUST be used. Although |
| 2042 | 2042 | the use of the Common Name is existing practice, it is deprecated and |
| 2043 | 2043 | Certification Authorities are encouraged to use the dNSName instead. */ |
| 2044 | - if (preg_match('#^' . $value . '$#', $components['host'])) { |
|
| 2044 | + if (preg_match('#^'.$value.'$#', $components['host'])) { |
|
| 2045 | 2045 | return true; |
| 2046 | 2046 | } |
| 2047 | 2047 | break; |
@@ -2051,7 +2051,7 @@ discard block |
||
| 2051 | 2051 | In some cases, the URI is specified as an IP address rather than a |
| 2052 | 2052 | hostname. In this case, the iPAddress subjectAltName must be present |
| 2053 | 2053 | in the certificate and must exactly match the IP in the URI. */ |
| 2054 | - if (preg_match('#(?:\d{1-3}\.){4}#', $components['host'] . '.') && preg_match('#^' . $value . '$#', $components['host'])) { |
|
| 2054 | + if (preg_match('#(?:\d{1-3}\.){4}#', $components['host'].'.') && preg_match('#^'.$value.'$#', $components['host'])) { |
|
| 2055 | 2055 | return true; |
| 2056 | 2056 | } |
| 2057 | 2057 | } |
@@ -2061,7 +2061,7 @@ discard block |
||
| 2061 | 2061 | |
| 2062 | 2062 | if ($value = $this->getDNProp('id-at-commonName')) { |
| 2063 | 2063 | $value = str_replace(array('.', '*'), array('\.', '[^.]*'), $value[0]); |
| 2064 | - return preg_match('#^' . $value . '$#', $components['host']); |
|
| 2064 | + return preg_match('#^'.$value.'$#', $components['host']); |
|
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | 2067 | return false; |
@@ -2283,11 +2283,11 @@ discard block |
||
| 2283 | 2283 | switch ($algorithm) { |
| 2284 | 2284 | case 'rsaEncryption': |
| 2285 | 2285 | return |
| 2286 | - "-----BEGIN RSA PUBLIC KEY-----\r\n" . |
|
| 2286 | + "-----BEGIN RSA PUBLIC KEY-----\r\n". |
|
| 2287 | 2287 | // subjectPublicKey is stored as a bit string in X.509 certs. the first byte of a bit string represents how many bits |
| 2288 | 2288 | // in the last byte should be ignored. the following only supports non-zero stuff but as none of the X.509 certs Firefox |
| 2289 | 2289 | // uses as a cert authority actually use a non-zero bit I think it's safe to assume that none do. |
| 2290 | - chunk_split(Base64::encode(substr(Base64::decode($key), 1)), 64) . |
|
| 2290 | + chunk_split(Base64::encode(substr(Base64::decode($key), 1)), 64). |
|
| 2291 | 2291 | '-----END RSA PUBLIC KEY-----'; |
| 2292 | 2292 | default: |
| 2293 | 2293 | return $key; |
@@ -2571,7 +2571,7 @@ discard block |
||
| 2571 | 2571 | |
| 2572 | 2572 | // handles everything else |
| 2573 | 2573 | $results = preg_split('#((?:^|, *|/)(?:C=|O=|OU=|CN=|L=|ST=|SN=|postalCode=|streetAddress=|emailAddress=|serialNumber=|organizationalUnitName=|title=|description=|role=|x500UniqueIdentifier=|postalAddress=))#', $dn, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 2574 | - for ($i = 1; $i < count($results); $i+=2) { |
|
| 2574 | + for ($i = 1; $i < count($results); $i += 2) { |
|
| 2575 | 2575 | $prop = trim($results[$i], ', =/'); |
| 2576 | 2576 | $value = $results[$i + 1]; |
| 2577 | 2577 | if (!$this->setDNProp($prop, $value, $type)) { |
@@ -2699,7 +2699,7 @@ discard block |
||
| 2699 | 2699 | } |
| 2700 | 2700 | |
| 2701 | 2701 | if (!$start) { |
| 2702 | - $output.= $delim; |
|
| 2702 | + $output .= $delim; |
|
| 2703 | 2703 | } |
| 2704 | 2704 | if (is_array($value)) { |
| 2705 | 2705 | foreach ($value as $type => $v) { |
@@ -2719,10 +2719,9 @@ discard block |
||
| 2719 | 2719 | $callback = create_function('$x', 'return "\x" . bin2hex($x[0]);'); |
| 2720 | 2720 | $value = strtoupper(preg_replace_callback('#[^\x20-\x7E]#', $callback, $value->element)); |
| 2721 | 2721 | } |
| 2722 | - $output.= $desc . '=' . $value; |
|
| 2722 | + $output .= $desc.'='.$value; |
|
| 2723 | 2723 | $result[$desc] = isset($result[$desc]) ? |
| 2724 | - array_merge((array) $dn[$prop], array($value)) : |
|
| 2725 | - $value; |
|
| 2724 | + array_merge((array) $dn[$prop], array($value)) : $value; |
|
| 2726 | 2725 | $start = false; |
| 2727 | 2726 | } |
| 2728 | 2727 | |
@@ -3050,7 +3049,7 @@ discard block |
||
| 3050 | 3049 | switch ($algorithm) { |
| 3051 | 3050 | case 'rsaEncryption': |
| 3052 | 3051 | $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'] |
| 3053 | - = Base64::encode("\0" . Base64::decode(preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']))); |
|
| 3052 | + = Base64::encode("\0".Base64::decode(preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']))); |
|
| 3054 | 3053 | $csr['certificationRequestInfo']['subjectPKInfo']['algorithm']['parameters'] = null; |
| 3055 | 3054 | $csr['signatureAlgorithm']['parameters'] = null; |
| 3056 | 3055 | $csr['certificationRequestInfo']['signature']['parameters'] = null; |
@@ -3076,7 +3075,7 @@ discard block |
||
| 3076 | 3075 | return $csr; |
| 3077 | 3076 | // case self::FORMAT_PEM: |
| 3078 | 3077 | default: |
| 3079 | - return "-----BEGIN CERTIFICATE REQUEST-----\r\n" . chunk_split(Base64::encode($csr), 64) . '-----END CERTIFICATE REQUEST-----'; |
|
| 3078 | + return "-----BEGIN CERTIFICATE REQUEST-----\r\n".chunk_split(Base64::encode($csr), 64).'-----END CERTIFICATE REQUEST-----'; |
|
| 3080 | 3079 | } |
| 3081 | 3080 | } |
| 3082 | 3081 | |
@@ -3178,7 +3177,7 @@ discard block |
||
| 3178 | 3177 | switch ($algorithm) { |
| 3179 | 3178 | case 'rsaEncryption': |
| 3180 | 3179 | $spkac['publicKeyAndChallenge']['spki']['subjectPublicKey'] |
| 3181 | - = Base64::encode("\0" . Base64::decode(preg_replace('#-.+-|[\r\n]#', '', $spkac['publicKeyAndChallenge']['spki']['subjectPublicKey']))); |
|
| 3180 | + = Base64::encode("\0".Base64::decode(preg_replace('#-.+-|[\r\n]#', '', $spkac['publicKeyAndChallenge']['spki']['subjectPublicKey']))); |
|
| 3182 | 3181 | } |
| 3183 | 3182 | } |
| 3184 | 3183 | |
@@ -3194,7 +3193,7 @@ discard block |
||
| 3194 | 3193 | default: |
| 3195 | 3194 | // OpenSSL's implementation of SPKAC requires the SPKAC be preceded by SPKAC= and since there are pretty much |
| 3196 | 3195 | // no other SPKAC decoders phpseclib will use that same format |
| 3197 | - return 'SPKAC=' . Base64::encode($spkac); |
|
| 3196 | + return 'SPKAC='.Base64::encode($spkac); |
|
| 3198 | 3197 | } |
| 3199 | 3198 | } |
| 3200 | 3199 | |
@@ -3321,7 +3320,7 @@ discard block |
||
| 3321 | 3320 | return $crl; |
| 3322 | 3321 | // case self::FORMAT_PEM: |
| 3323 | 3322 | default: |
| 3324 | - return "-----BEGIN X509 CRL-----\r\n" . chunk_split(Base64::encode($crl), 64) . '-----END X509 CRL-----'; |
|
| 3323 | + return "-----BEGIN X509 CRL-----\r\n".chunk_split(Base64::encode($crl), 64).'-----END X509 CRL-----'; |
|
| 3325 | 3324 | } |
| 3326 | 3325 | } |
| 3327 | 3326 | |
@@ -3371,7 +3370,7 @@ discard block |
||
| 3371 | 3370 | } |
| 3372 | 3371 | |
| 3373 | 3372 | $currentCert = isset($this->currentCert) ? $this->currentCert : null; |
| 3374 | - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null; |
|
| 3373 | + $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null; |
|
| 3375 | 3374 | |
| 3376 | 3375 | if (isset($subject->currentCert) && is_array($subject->currentCert) && isset($subject->currentCert['tbsCertificate'])) { |
| 3377 | 3376 | $this->currentCert = $subject->currentCert; |
@@ -3414,8 +3413,7 @@ discard block |
||
| 3414 | 3413 | application of a bitmap |
| 3415 | 3414 | */ |
| 3416 | 3415 | $serialNumber = !empty($this->serialNumber) ? |
| 3417 | - $this->serialNumber : |
|
| 3418 | - new BigInteger(Random::string(20) & ("\x7F" . str_repeat("\xFF", 19)), 256); |
|
| 3416 | + $this->serialNumber : new BigInteger(Random::string(20) & ("\x7F".str_repeat("\xFF", 19)), 256); |
|
| 3419 | 3417 | |
| 3420 | 3418 | $this->currentCert = array( |
| 3421 | 3419 | 'tbsCertificate' => |
@@ -3554,7 +3552,7 @@ discard block |
||
| 3554 | 3552 | $this->publicKey = $origPublicKey; |
| 3555 | 3553 | |
| 3556 | 3554 | $currentCert = isset($this->currentCert) ? $this->currentCert : null; |
| 3557 | - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null; |
|
| 3555 | + $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null; |
|
| 3558 | 3556 | |
| 3559 | 3557 | if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['certificationRequestInfo'])) { |
| 3560 | 3558 | $this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm; |
@@ -3613,7 +3611,7 @@ discard block |
||
| 3613 | 3611 | $this->publicKey = $origPublicKey; |
| 3614 | 3612 | |
| 3615 | 3613 | $currentCert = isset($this->currentCert) ? $this->currentCert : null; |
| 3616 | - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null; |
|
| 3614 | + $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null; |
|
| 3617 | 3615 | |
| 3618 | 3616 | // re-signing a SPKAC seems silly but since everything else supports re-signing why not? |
| 3619 | 3617 | if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['publicKeyAndChallenge'])) { |
@@ -3808,7 +3806,7 @@ discard block |
||
| 3808 | 3806 | case 'sha512WithRSAEncryption': |
| 3809 | 3807 | $key->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm)); |
| 3810 | 3808 | |
| 3811 | - $this->currentCert['signature'] = Base64::encode("\0" . $key->sign($this->signatureSubject, RSA::PADDING_PKCS1)); |
|
| 3809 | + $this->currentCert['signature'] = Base64::encode("\0".$key->sign($this->signatureSubject, RSA::PADDING_PKCS1)); |
|
| 3812 | 3810 | return $this->currentCert; |
| 3813 | 3811 | default: |
| 3814 | 3812 | throw new UnsupportedAlgorithmException('Signature algorithm unsupported'); |
@@ -3847,7 +3845,7 @@ discard block |
||
| 3847 | 3845 | if (strtolower($date) == 'lifetime') { |
| 3848 | 3846 | $temp = '99991231235959Z'; |
| 3849 | 3847 | $asn1 = new ASN1(); |
| 3850 | - $temp = chr(ASN1::TYPE_GENERALIZED_TIME) . $asn1->_encodeLength(strlen($temp)) . $temp; |
|
| 3848 | + $temp = chr(ASN1::TYPE_GENERALIZED_TIME).$asn1->_encodeLength(strlen($temp)).$temp; |
|
| 3851 | 3849 | $this->endDate = new Element($temp); |
| 3852 | 3850 | } else { |
| 3853 | 3851 | $this->endDate = @date('D, d M Y H:i:s O', @strtotime($date)); |
@@ -4369,7 +4367,7 @@ discard block |
||
| 4369 | 4367 | $attributes[$last]['value'][] = $value; |
| 4370 | 4368 | break; |
| 4371 | 4369 | default: |
| 4372 | - $attributes[] = array('type' => $id, 'value' => $disposition == self::ATTR_ALL ? $value: array($value)); |
|
| 4370 | + $attributes[] = array('type' => $id, 'value' => $disposition == self::ATTR_ALL ? $value : array($value)); |
|
| 4373 | 4371 | break; |
| 4374 | 4372 | } |
| 4375 | 4373 | |
@@ -4441,12 +4439,12 @@ discard block |
||
| 4441 | 4439 | // If the key is private, compute identifier from its corresponding public key. |
| 4442 | 4440 | $key = new RSA(); |
| 4443 | 4441 | if (!$key->load($raw)) { |
| 4444 | - return false; // Not an unencrypted RSA key. |
|
| 4442 | + return false; // Not an unencrypted RSA key. |
|
| 4445 | 4443 | } |
| 4446 | 4444 | if ($key->getPrivateKey() !== false) { // If private. |
| 4447 | 4445 | return $this->computeKeyIdentifier($key, $method); |
| 4448 | 4446 | } |
| 4449 | - $key = $raw; // Is a public key. |
|
| 4447 | + $key = $raw; // Is a public key. |
|
| 4450 | 4448 | break; |
| 4451 | 4449 | case $key instanceof X509: |
| 4452 | 4450 | if (isset($key->publicKey)) { |
@@ -4716,7 +4714,7 @@ discard block |
||
| 4716 | 4714 | |
| 4717 | 4715 | if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) { |
| 4718 | 4716 | if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) { |
| 4719 | - return $this->_getExtension($id, $crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); |
|
| 4717 | + return $this->_getExtension($id, $crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); |
|
| 4720 | 4718 | } |
| 4721 | 4719 | } |
| 4722 | 4720 | |
@@ -1329,7 +1329,7 @@ discard block |
||
| 1329 | 1329 | * </code> |
| 1330 | 1330 | * |
| 1331 | 1331 | * @param \phpseclib\Math\BigInteger $y |
| 1332 | - * @return array |
|
| 1332 | + * @return BigInteger[] |
|
| 1333 | 1333 | * @access public |
| 1334 | 1334 | * @internal This function is based off of {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=9 HAC 14.20}. |
| 1335 | 1335 | */ |
@@ -2360,7 +2360,7 @@ discard block |
||
| 2360 | 2360 | * </code> |
| 2361 | 2361 | * |
| 2362 | 2362 | * @param \phpseclib\Math\BigInteger $n |
| 2363 | - * @return \phpseclib\Math\BigInteger|false |
|
| 2363 | + * @return BigInteger |
|
| 2364 | 2364 | * @access public |
| 2365 | 2365 | * @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=21 HAC 14.64} for more information. |
| 2366 | 2366 | */ |
@@ -3048,8 +3048,6 @@ discard block |
||
| 3048 | 3048 | * BigInteger::randomRange($min, $max) |
| 3049 | 3049 | * BigInteger::randomRange($max, $min) |
| 3050 | 3050 | * |
| 3051 | - * @param \phpseclib\Math\BigInteger $arg1 |
|
| 3052 | - * @param \phpseclib\Math\BigInteger $arg2 |
|
| 3053 | 3051 | * @return \phpseclib\Math\BigInteger |
| 3054 | 3052 | * @access public |
| 3055 | 3053 | */ |
@@ -3553,8 +3551,8 @@ discard block |
||
| 3553 | 3551 | /** |
| 3554 | 3552 | * Array Repeat |
| 3555 | 3553 | * |
| 3556 | - * @param $input Array |
|
| 3557 | - * @param $multiplier mixed |
|
| 3554 | + * @param integer $input Array |
|
| 3555 | + * @param integer $multiplier mixed |
|
| 3558 | 3556 | * @return array |
| 3559 | 3557 | * @access private |
| 3560 | 3558 | */ |
@@ -3569,7 +3567,7 @@ discard block |
||
| 3569 | 3567 | * Shifts binary strings $shift bits, essentially multiplying by 2**$shift. |
| 3570 | 3568 | * |
| 3571 | 3569 | * @param $x String |
| 3572 | - * @param $shift Integer |
|
| 3570 | + * @param integer $shift Integer |
|
| 3573 | 3571 | * @return string |
| 3574 | 3572 | * @access private |
| 3575 | 3573 | */ |
@@ -1626,8 +1626,8 @@ discard block |
||
| 1626 | 1626 | ); |
| 1627 | 1627 | |
| 1628 | 1628 | $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . |
| 1629 | - chunk_split(Base64::encode($encapsulated)) . |
|
| 1630 | - '-----END PUBLIC KEY-----'; |
|
| 1629 | + chunk_split(Base64::encode($encapsulated)) . |
|
| 1630 | + '-----END PUBLIC KEY-----'; |
|
| 1631 | 1631 | |
| 1632 | 1632 | $plaintext = str_pad($this->toBytes(), strlen($n->toBytes(true)) - 1, "\0", STR_PAD_LEFT); |
| 1633 | 1633 | |
@@ -3276,7 +3276,7 @@ discard block |
||
| 3276 | 3276 | if (!$t) { |
| 3277 | 3277 | // see HAC 4.49 "Note (controlling the error probability)" |
| 3278 | 3278 | // @codingStandardsIgnoreStart |
| 3279 | - if ($length >= 163) { $t = 2; } // floor(1300 / 8) |
|
| 3279 | + if ($length >= 163) { $t = 2; } // floor(1300 / 8) |
|
| 3280 | 3280 | else if ($length >= 106) { $t = 3; } // floor( 850 / 8) |
| 3281 | 3281 | else if ($length >= 81 ) { $t = 4; } // floor( 650 / 8) |
| 3282 | 3282 | else if ($length >= 68 ) { $t = 5; } // floor( 550 / 8) |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | switch (MATH_BIGINTEGER_MODE) { |
| 332 | 332 | case self::MODE_GMP: |
| 333 | 333 | $sign = $this->is_negative ? '-' : ''; |
| 334 | - $this->value = gmp_init($sign . '0x' . Hex::encode($x)); |
|
| 334 | + $this->value = gmp_init($sign.'0x'.Hex::encode($x)); |
|
| 335 | 335 | break; |
| 336 | 336 | case self::MODE_BCMATH: |
| 337 | 337 | // round $len to the nearest 4 (thanks, DavidMJ!) |
@@ -339,13 +339,13 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | $x = str_pad($x, $len, chr(0), STR_PAD_LEFT); |
| 341 | 341 | |
| 342 | - for ($i = 0; $i < $len; $i+= 4) { |
|
| 342 | + for ($i = 0; $i < $len; $i += 4) { |
|
| 343 | 343 | $this->value = bcmul($this->value, '4294967296', 0); // 4294967296 == 2**32 |
| 344 | 344 | $this->value = bcadd($this->value, 0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord($x[$i + 2]) << 8) | ord($x[$i + 3])), 0); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | if ($this->is_negative) { |
| 348 | - $this->value = '-' . $this->value; |
|
| 348 | + $this->value = '-'.$this->value; |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | break; |
@@ -381,18 +381,18 @@ discard block |
||
| 381 | 381 | |
| 382 | 382 | switch (MATH_BIGINTEGER_MODE) { |
| 383 | 383 | case self::MODE_GMP: |
| 384 | - $temp = $this->is_negative ? '-0x' . $x : '0x' . $x; |
|
| 384 | + $temp = $this->is_negative ? '-0x'.$x : '0x'.$x; |
|
| 385 | 385 | $this->value = gmp_init($temp); |
| 386 | 386 | $this->is_negative = false; |
| 387 | 387 | break; |
| 388 | 388 | case self::MODE_BCMATH: |
| 389 | - $x = (strlen($x) & 1) ? '0' . $x : $x; |
|
| 389 | + $x = (strlen($x) & 1) ? '0'.$x : $x; |
|
| 390 | 390 | $temp = new static(Hex::decode($x), 256); |
| 391 | - $this->value = $this->is_negative ? '-' . $temp->value : $temp->value; |
|
| 391 | + $this->value = $this->is_negative ? '-'.$temp->value : $temp->value; |
|
| 392 | 392 | $this->is_negative = false; |
| 393 | 393 | break; |
| 394 | 394 | default: |
| 395 | - $x = (strlen($x) & 1) ? '0' . $x : $x; |
|
| 395 | + $x = (strlen($x) & 1) ? '0'.$x : $x; |
|
| 396 | 396 | $temp = new static(Hex::decode($x), 256); |
| 397 | 397 | $this->value = $temp->value; |
| 398 | 398 | } |
@@ -452,12 +452,12 @@ discard block |
||
| 452 | 452 | $str = '0x'; |
| 453 | 453 | while (strlen($x)) { |
| 454 | 454 | $part = substr($x, 0, 4); |
| 455 | - $str.= dechex(bindec($part)); |
|
| 455 | + $str .= dechex(bindec($part)); |
|
| 456 | 456 | $x = substr($x, 4); |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | if ($this->is_negative) { |
| 460 | - $str = '-' . $str; |
|
| 460 | + $str = '-'.$str; |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | $temp = new static($str, 8 * $base); // ie. either -16 or +16 |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | if (ord($bytes[0]) & 0x80) { |
| 509 | - $bytes = chr(0) . $bytes; |
|
| 509 | + $bytes = chr(0).$bytes; |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | return $comparison < 0 ? ~$bytes : $bytes; |
@@ -519,12 +519,11 @@ discard block |
||
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | $temp = gmp_strval(gmp_abs($this->value), 16); |
| 522 | - $temp = (strlen($temp) & 1) ? '0' . $temp : $temp; |
|
| 522 | + $temp = (strlen($temp) & 1) ? '0'.$temp : $temp; |
|
| 523 | 523 | $temp = Hex::decode($temp); |
| 524 | 524 | |
| 525 | 525 | return $this->precision > 0 ? |
| 526 | - substr(str_pad($temp, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) : |
|
| 527 | - ltrim($temp, chr(0)); |
|
| 526 | + substr(str_pad($temp, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) : ltrim($temp, chr(0)); |
|
| 528 | 527 | case self::MODE_BCMATH: |
| 529 | 528 | if ($this->value === '0') { |
| 530 | 529 | return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : ''; |
@@ -539,13 +538,12 @@ discard block |
||
| 539 | 538 | |
| 540 | 539 | while (bccomp($current, '0', 0) > 0) { |
| 541 | 540 | $temp = bcmod($current, '16777216'); |
| 542 | - $value = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $value; |
|
| 541 | + $value = chr($temp >> 16).chr($temp >> 8).chr($temp).$value; |
|
| 543 | 542 | $current = bcdiv($current, '16777216', 0); |
| 544 | 543 | } |
| 545 | 544 | |
| 546 | 545 | return $this->precision > 0 ? |
| 547 | - substr(str_pad($value, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) : |
|
| 548 | - ltrim($value, chr(0)); |
|
| 546 | + substr(str_pad($value, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) : ltrim($value, chr(0)); |
|
| 549 | 547 | } |
| 550 | 548 | |
| 551 | 549 | if (!count($this->value)) { |
@@ -559,8 +557,7 @@ discard block |
||
| 559 | 557 | } |
| 560 | 558 | |
| 561 | 559 | return $this->precision > 0 ? |
| 562 | - str_pad(substr($result, -(($this->precision + 7) >> 3)), ($this->precision + 7) >> 3, chr(0), STR_PAD_LEFT) : |
|
| 563 | - $result; |
|
| 560 | + str_pad(substr($result, -(($this->precision + 7) >> 3)), ($this->precision + 7) >> 3, chr(0), STR_PAD_LEFT) : $result; |
|
| 564 | 561 | } |
| 565 | 562 | |
| 566 | 563 | /** |
@@ -612,16 +609,16 @@ discard block |
||
| 612 | 609 | { |
| 613 | 610 | $hex = $this->toHex($twos_compliment); |
| 614 | 611 | $bits = ''; |
| 615 | - for ($i = strlen($hex) - 8, $start = strlen($hex) & 7; $i >= $start; $i-=8) { |
|
| 616 | - $bits = str_pad(decbin(hexdec(substr($hex, $i, 8))), 32, '0', STR_PAD_LEFT) . $bits; |
|
| 612 | + for ($i = strlen($hex) - 8, $start = strlen($hex) & 7; $i >= $start; $i -= 8) { |
|
| 613 | + $bits = str_pad(decbin(hexdec(substr($hex, $i, 8))), 32, '0', STR_PAD_LEFT).$bits; |
|
| 617 | 614 | } |
| 618 | 615 | if ($start) { // hexdec('') == 0 |
| 619 | - $bits = str_pad(decbin(hexdec(substr($hex, 0, $start))), 8, '0', STR_PAD_LEFT) . $bits; |
|
| 616 | + $bits = str_pad(decbin(hexdec(substr($hex, 0, $start))), 8, '0', STR_PAD_LEFT).$bits; |
|
| 620 | 617 | } |
| 621 | 618 | $result = $this->precision > 0 ? substr($bits, -$this->precision) : ltrim($bits, '0'); |
| 622 | 619 | |
| 623 | 620 | if ($twos_compliment && $this->compare(new static()) > 0 && $this->precision <= 0) { |
| 624 | - return '0' . $result; |
|
| 621 | + return '0'.$result; |
|
| 625 | 622 | } |
| 626 | 623 | |
| 627 | 624 | return $result; |
@@ -668,7 +665,7 @@ discard block |
||
| 668 | 665 | $result = ''; |
| 669 | 666 | while (count($temp->value)) { |
| 670 | 667 | list($temp, $mod) = $temp->divide($divisor); |
| 671 | - $result = str_pad(isset($mod->value[0]) ? $mod->value[0] : '', self::$max10Len, '0', STR_PAD_LEFT) . $result; |
|
| 668 | + $result = str_pad(isset($mod->value[0]) ? $mod->value[0] : '', self::$max10Len, '0', STR_PAD_LEFT).$result; |
|
| 672 | 669 | } |
| 673 | 670 | $result = ltrim($result, '0'); |
| 674 | 671 | if (empty($result)) { |
@@ -676,7 +673,7 @@ discard block |
||
| 676 | 673 | } |
| 677 | 674 | |
| 678 | 675 | if ($this->is_negative) { |
| 679 | - $result = '-' . $result; |
|
| 676 | + $result = '-'.$result; |
|
| 680 | 677 | } |
| 681 | 678 | |
| 682 | 679 | return $result; |
@@ -758,10 +755,10 @@ discard block |
||
| 758 | 755 | $opts[] = 'OpenSSL'; |
| 759 | 756 | } |
| 760 | 757 | if (!empty($opts)) { |
| 761 | - $engine.= ' (' . implode($opts, ', ') . ')'; |
|
| 758 | + $engine .= ' ('.implode($opts, ', ').')'; |
|
| 762 | 759 | } |
| 763 | 760 | return array( |
| 764 | - 'value' => '0x' . $this->toHex(true), |
|
| 761 | + 'value' => '0x'.$this->toHex(true), |
|
| 765 | 762 | 'engine' => $engine |
| 766 | 763 | ); |
| 767 | 764 | } |
@@ -864,7 +861,7 @@ discard block |
||
| 864 | 861 | $value[count($value)] = 0; // just in case the carry adds an extra digit |
| 865 | 862 | |
| 866 | 863 | $carry = 0; |
| 867 | - for ($i = 0, $j = 1; $j < $size; $i+=2, $j+=2) { |
|
| 864 | + for ($i = 0, $j = 1; $j < $size; $i += 2, $j += 2) { |
|
| 868 | 865 | $sum = $x_value[$j] * self::$baseFull + $x_value[$i] + $y_value[$j] * self::$baseFull + $y_value[$i] + $carry; |
| 869 | 866 | $carry = $sum >= self::$maxDigit2; // eg. floor($sum / 2**52); only possible values (in any base) are 0 and 1 |
| 870 | 867 | $sum = $carry ? $sum - self::$maxDigit2 : $sum; |
@@ -998,7 +995,7 @@ discard block |
||
| 998 | 995 | // at this point, $x_value should be at least as big as - if not bigger than - $y_value |
| 999 | 996 | |
| 1000 | 997 | $carry = 0; |
| 1001 | - for ($i = 0, $j = 1; $j < $y_size; $i+=2, $j+=2) { |
|
| 998 | + for ($i = 0, $j = 1; $j < $y_size; $i += 2, $j += 2) { |
|
| 1002 | 999 | $sum = $x_value[$j] * self::$baseFull + $x_value[$i] - $y_value[$j] * self::$baseFull - $y_value[$i] - $carry; |
| 1003 | 1000 | $carry = $sum < 0; // eg. floor($sum / 2**52); only possible values (in any base) are 0 and 1 |
| 1004 | 1001 | $sum = $carry ? $sum + self::$maxDigit2 : $sum; |
@@ -1103,8 +1100,7 @@ discard block |
||
| 1103 | 1100 | |
| 1104 | 1101 | return array( |
| 1105 | 1102 | self::VALUE => min($x_length, $y_length) < 2 * self::KARATSUBA_CUTOFF ? |
| 1106 | - self::_trim(self::_regularMultiply($x_value, $y_value)) : |
|
| 1107 | - self::_trim(self::_karatsuba($x_value, $y_value)), |
|
| 1103 | + self::_trim(self::_regularMultiply($x_value, $y_value)) : self::_trim(self::_karatsuba($x_value, $y_value)), |
|
| 1108 | 1104 | self::SIGN => $x_negative != $y_negative |
| 1109 | 1105 | ); |
| 1110 | 1106 | } |
@@ -1224,8 +1220,7 @@ discard block |
||
| 1224 | 1220 | static function _square($x = false) |
| 1225 | 1221 | { |
| 1226 | 1222 | return count($x) < 2 * self::KARATSUBA_CUTOFF ? |
| 1227 | - self::_trim(self::_baseSquare($x)) : |
|
| 1228 | - self::_trim(self::_karatsubaSquare($x)); |
|
| 1223 | + self::_trim(self::_baseSquare($x)) : self::_trim(self::_karatsubaSquare($x)); |
|
| 1229 | 1224 | } |
| 1230 | 1225 | |
| 1231 | 1226 | /** |
@@ -1420,11 +1415,11 @@ discard block |
||
| 1420 | 1415 | static $temp, $lhs, $rhs; |
| 1421 | 1416 | if (!isset($temp)) { |
| 1422 | 1417 | $temp = new static(); |
| 1423 | - $lhs = new static(); |
|
| 1424 | - $rhs = new static(); |
|
| 1418 | + $lhs = new static(); |
|
| 1419 | + $rhs = new static(); |
|
| 1425 | 1420 | } |
| 1426 | 1421 | $temp_value = &$temp->value; |
| 1427 | - $rhs_value = &$rhs->value; |
|
| 1422 | + $rhs_value = &$rhs->value; |
|
| 1428 | 1423 | |
| 1429 | 1424 | // $temp = $y << ($x_max - $y_max-1) in base 2**26 |
| 1430 | 1425 | $temp_value = array_merge($this->_array_repeat(0, $x_max - $y_max), $y_value); |
@@ -1615,18 +1610,18 @@ discard block |
||
| 1615 | 1610 | ); |
| 1616 | 1611 | |
| 1617 | 1612 | $rsaOID = "\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00"; // hex version of MA0GCSqGSIb3DQEBAQUA |
| 1618 | - $RSAPublicKey = chr(0) . $RSAPublicKey; |
|
| 1619 | - $RSAPublicKey = chr(3) . self::_encodeASN1Length(strlen($RSAPublicKey)) . $RSAPublicKey; |
|
| 1613 | + $RSAPublicKey = chr(0).$RSAPublicKey; |
|
| 1614 | + $RSAPublicKey = chr(3).self::_encodeASN1Length(strlen($RSAPublicKey)).$RSAPublicKey; |
|
| 1620 | 1615 | |
| 1621 | 1616 | $encapsulated = pack( |
| 1622 | 1617 | 'Ca*a*', |
| 1623 | 1618 | 48, |
| 1624 | - self::_encodeASN1Length(strlen($rsaOID . $RSAPublicKey)), |
|
| 1625 | - $rsaOID . $RSAPublicKey |
|
| 1619 | + self::_encodeASN1Length(strlen($rsaOID.$RSAPublicKey)), |
|
| 1620 | + $rsaOID.$RSAPublicKey |
|
| 1626 | 1621 | ); |
| 1627 | 1622 | |
| 1628 | - $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . |
|
| 1629 | - chunk_split(Base64::encode($encapsulated)) . |
|
| 1623 | + $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n". |
|
| 1624 | + chunk_split(Base64::encode($encapsulated)). |
|
| 1630 | 1625 | '-----END PUBLIC KEY-----'; |
| 1631 | 1626 | |
| 1632 | 1627 | $plaintext = str_pad($this->toBytes(), strlen($n->toBytes(true)) - 1, "\0", STR_PAD_LEFT); |
@@ -1679,7 +1674,7 @@ discard block |
||
| 1679 | 1674 | if ($n->value[$i]) { |
| 1680 | 1675 | $temp = decbin($n->value[$i]); |
| 1681 | 1676 | $j = strlen($temp) - strrpos($temp, '1') - 1; |
| 1682 | - $j+= 26 * $i; |
|
| 1677 | + $j += 26 * $i; |
|
| 1683 | 1678 | break; |
| 1684 | 1679 | } |
| 1685 | 1680 | } |
@@ -1747,7 +1742,7 @@ discard block |
||
| 1747 | 1742 | $e_length = count($e_value) - 1; |
| 1748 | 1743 | $e_bits = decbin($e_value[$e_length]); |
| 1749 | 1744 | for ($i = $e_length - 1; $i >= 0; --$i) { |
| 1750 | - $e_bits.= str_pad(decbin($e_value[$i]), self::$base, '0', STR_PAD_LEFT); |
|
| 1745 | + $e_bits .= str_pad(decbin($e_value[$i]), self::$base, '0', STR_PAD_LEFT); |
|
| 1751 | 1746 | } |
| 1752 | 1747 | |
| 1753 | 1748 | $e_length = strlen($e_bits); |
@@ -1991,7 +1986,7 @@ discard block |
||
| 1991 | 1986 | |
| 1992 | 1987 | $cutoff = $m_length + ($m_length >> 1); |
| 1993 | 1988 | $lsd = array_slice($n, 0, $cutoff); // m.length + (m.length >> 1) |
| 1994 | - $msd = array_slice($n, $cutoff); // m.length >> 1 |
|
| 1989 | + $msd = array_slice($n, $cutoff); // m.length >> 1 |
|
| 1995 | 1990 | $lsd = self::_trim($lsd); |
| 1996 | 1991 | $temp = self::_multiply($msd, false, $m1, false); |
| 1997 | 1992 | $n = self::_add($lsd, false, $temp[self::VALUE], false); // m.length + (m.length >> 1) + 1 |
@@ -2064,7 +2059,7 @@ discard block |
||
| 2064 | 2059 | $lhs_value[] = 1; |
| 2065 | 2060 | $rhs = new static(); |
| 2066 | 2061 | $rhs->value = $n; |
| 2067 | - list($temp, ) = $lhs->divide($rhs); // m.length |
|
| 2062 | + list($temp,) = $lhs->divide($rhs); // m.length |
|
| 2068 | 2063 | $cache[self::DATA][] = $temp->value; |
| 2069 | 2064 | } |
| 2070 | 2065 | |
@@ -2331,7 +2326,7 @@ discard block |
||
| 2331 | 2326 | $x = -$x[0]; |
| 2332 | 2327 | $result = $x & 0x3; // x**-1 mod 2**2 |
| 2333 | 2328 | $result = ($result * (2 - $x * $result)) & 0xF; // x**-1 mod 2**4 |
| 2334 | - $result = ($result * (2 - ($x & 0xFF) * $result)) & 0xFF; // x**-1 mod 2**8 |
|
| 2329 | + $result = ($result * (2 - ($x & 0xFF) * $result)) & 0xFF; // x**-1 mod 2**8 |
|
| 2335 | 2330 | $result = ($result * ((2 - ($x & 0xFFFF) * $result) & 0xFFFF)) & 0xFFFF; // x**-1 mod 2**16 |
| 2336 | 2331 | $result = fmod($result * (2 - fmod($x * $result, self::$baseFull)), self::$baseFull); // x**-1 mod 2**26 |
| 2337 | 2332 | return $result & self::$maxDigit; |
@@ -2480,7 +2475,7 @@ discard block |
||
| 2480 | 2475 | $g = new static(); |
| 2481 | 2476 | $g->value = array(1); |
| 2482 | 2477 | |
| 2483 | - while (!(($x->value[0] & 1)|| ($y->value[0] & 1))) { |
|
| 2478 | + while (!(($x->value[0] & 1) || ($y->value[0] & 1))) { |
|
| 2484 | 2479 | $x->_rshift(1); |
| 2485 | 2480 | $y->_rshift(1); |
| 2486 | 2481 | $g->_lshift(1); |
@@ -2692,7 +2687,7 @@ discard block |
||
| 2692 | 2687 | } |
| 2693 | 2688 | $this->precision = $bits; |
| 2694 | 2689 | if (MATH_BIGINTEGER_MODE != self::MODE_BCMATH) { |
| 2695 | - $this->bitmask = new static(chr((1 << ($bits & 0x7)) - 1) . str_repeat(chr(0xFF), $bits >> 3), 256); |
|
| 2690 | + $this->bitmask = new static(chr((1 << ($bits & 0x7)) - 1).str_repeat(chr(0xFF), $bits >> 3), 256); |
|
| 2696 | 2691 | } else { |
| 2697 | 2692 | $this->bitmask = new static(bcpow('2', $bits, 0)); |
| 2698 | 2693 | } |
@@ -2748,7 +2743,7 @@ discard block |
||
| 2748 | 2743 | $result->value = array_slice($result->value, 0, $length); |
| 2749 | 2744 | |
| 2750 | 2745 | for ($i = 0; $i < $length; ++$i) { |
| 2751 | - $result->value[$i]&= $x->value[$i]; |
|
| 2746 | + $result->value[$i] &= $x->value[$i]; |
|
| 2752 | 2747 | } |
| 2753 | 2748 | |
| 2754 | 2749 | return $this->_normalize($result); |
@@ -2788,7 +2783,7 @@ discard block |
||
| 2788 | 2783 | $x->value = array_pad($x->value, $length, 0); |
| 2789 | 2784 | |
| 2790 | 2785 | for ($i = 0; $i < $length; ++$i) { |
| 2791 | - $result->value[$i]|= $x->value[$i]; |
|
| 2786 | + $result->value[$i] |= $x->value[$i]; |
|
| 2792 | 2787 | } |
| 2793 | 2788 | |
| 2794 | 2789 | return $this->_normalize($result); |
@@ -2828,7 +2823,7 @@ discard block |
||
| 2828 | 2823 | $x->value = array_pad($x->value, $length, 0); |
| 2829 | 2824 | |
| 2830 | 2825 | for ($i = 0; $i < $length; ++$i) { |
| 2831 | - $result->value[$i]^= $x->value[$i]; |
|
| 2826 | + $result->value[$i] ^= $x->value[$i]; |
|
| 2832 | 2827 | } |
| 2833 | 2828 | |
| 2834 | 2829 | return $this->_normalize($result); |
@@ -2865,7 +2860,7 @@ discard block |
||
| 2865 | 2860 | } |
| 2866 | 2861 | |
| 2867 | 2862 | // generate as many leading 1's as we need to. |
| 2868 | - $leading_ones = chr((1 << ($new_bits & 0x7)) - 1) . str_repeat(chr(0xFF), $new_bits >> 3); |
|
| 2863 | + $leading_ones = chr((1 << ($new_bits & 0x7)) - 1).str_repeat(chr(0xFF), $new_bits >> 3); |
|
| 2869 | 2864 | |
| 2870 | 2865 | self::_base256_lshift($leading_ones, $current_bits); |
| 2871 | 2866 | |
@@ -2976,13 +2971,13 @@ discard block |
||
| 2976 | 2971 | for ($i = 0; $temp >> $i; ++$i) { |
| 2977 | 2972 | } |
| 2978 | 2973 | $precision = 8 * strlen($bits) - 8 + $i; |
| 2979 | - $mask = chr((1 << ($precision & 0x7)) - 1) . str_repeat(chr(0xFF), $precision >> 3); |
|
| 2974 | + $mask = chr((1 << ($precision & 0x7)) - 1).str_repeat(chr(0xFF), $precision >> 3); |
|
| 2980 | 2975 | } |
| 2981 | 2976 | |
| 2982 | 2977 | if ($shift < 0) { |
| 2983 | - $shift+= $precision; |
|
| 2978 | + $shift += $precision; |
|
| 2984 | 2979 | } |
| 2985 | - $shift%= $precision; |
|
| 2980 | + $shift %= $precision; |
|
| 2986 | 2981 | |
| 2987 | 2982 | if (!$shift) { |
| 2988 | 2983 | return clone $this; |
@@ -3026,13 +3021,13 @@ discard block |
||
| 3026 | 3021 | $random = ''; |
| 3027 | 3022 | |
| 3028 | 3023 | if ($size & 1) { |
| 3029 | - $random.= chr(mt_rand(0, 255)); |
|
| 3024 | + $random .= chr(mt_rand(0, 255)); |
|
| 3030 | 3025 | } |
| 3031 | 3026 | |
| 3032 | 3027 | $blocks = $size >> 1; |
| 3033 | 3028 | for ($i = 0; $i < $blocks; ++$i) { |
| 3034 | 3029 | // mt_rand(-2147483648, 0x7FFFFFFF) always produces -2147483648 on some systems |
| 3035 | - $random.= pack('n', mt_rand(0, 0xFFFF)); |
|
| 3030 | + $random .= pack('n', mt_rand(0, 0xFFFF)); |
|
| 3036 | 3031 | } |
| 3037 | 3032 | } |
| 3038 | 3033 | |
@@ -3089,7 +3084,7 @@ discard block |
||
| 3089 | 3084 | |
| 3090 | 3085 | http://crypto.stackexchange.com/questions/5708/creating-a-small-number-from-a-cryptographically-secure-random-string |
| 3091 | 3086 | */ |
| 3092 | - $random_max = new static(chr(1) . str_repeat("\0", $size), 256); |
|
| 3087 | + $random_max = new static(chr(1).str_repeat("\0", $size), 256); |
|
| 3093 | 3088 | $random = static::random($size); |
| 3094 | 3089 | |
| 3095 | 3090 | list($max_multiple) = $random_max->divide($max); |
@@ -3125,8 +3120,8 @@ discard block |
||
| 3125 | 3120 | $max = str_repeat(chr(0xFF), $bytes); |
| 3126 | 3121 | $msb = $bits & 7; |
| 3127 | 3122 | if ($msb) { |
| 3128 | - $min = chr(1 << ($msb - 1)) . $min; |
|
| 3129 | - $max = chr((1 << $msb) - 1) . $max; |
|
| 3123 | + $min = chr(1 << ($msb - 1)).$min; |
|
| 3124 | + $max = chr((1 << $msb) - 1).$max; |
|
| 3130 | 3125 | } else { |
| 3131 | 3126 | $min[0] = chr(0x80); |
| 3132 | 3127 | } |
@@ -3276,18 +3271,18 @@ discard block |
||
| 3276 | 3271 | if (!$t) { |
| 3277 | 3272 | // see HAC 4.49 "Note (controlling the error probability)" |
| 3278 | 3273 | // @codingStandardsIgnoreStart |
| 3279 | - if ($length >= 163) { $t = 2; } // floor(1300 / 8) |
|
| 3280 | - else if ($length >= 106) { $t = 3; } // floor( 850 / 8) |
|
| 3281 | - else if ($length >= 81 ) { $t = 4; } // floor( 650 / 8) |
|
| 3282 | - else if ($length >= 68 ) { $t = 5; } // floor( 550 / 8) |
|
| 3283 | - else if ($length >= 56 ) { $t = 6; } // floor( 450 / 8) |
|
| 3284 | - else if ($length >= 50 ) { $t = 7; } // floor( 400 / 8) |
|
| 3285 | - else if ($length >= 43 ) { $t = 8; } // floor( 350 / 8) |
|
| 3286 | - else if ($length >= 37 ) { $t = 9; } // floor( 300 / 8) |
|
| 3287 | - else if ($length >= 31 ) { $t = 12; } // floor( 250 / 8) |
|
| 3288 | - else if ($length >= 25 ) { $t = 15; } // floor( 200 / 8) |
|
| 3289 | - else if ($length >= 18 ) { $t = 18; } // floor( 150 / 8) |
|
| 3290 | - else { $t = 27; } |
|
| 3274 | + if ($length >= 163) { $t = 2; } // floor(1300 / 8) |
|
| 3275 | + else if ($length >= 106) { $t = 3; } // floor( 850 / 8) |
|
| 3276 | + else if ($length >= 81) { $t = 4; } // floor( 650 / 8) |
|
| 3277 | + else if ($length >= 68) { $t = 5; } // floor( 550 / 8) |
|
| 3278 | + else if ($length >= 56) { $t = 6; } // floor( 450 / 8) |
|
| 3279 | + else if ($length >= 50) { $t = 7; } // floor( 400 / 8) |
|
| 3280 | + else if ($length >= 43) { $t = 8; } // floor( 350 / 8) |
|
| 3281 | + else if ($length >= 37) { $t = 9; } // floor( 300 / 8) |
|
| 3282 | + else if ($length >= 31) { $t = 12; } // floor( 250 / 8) |
|
| 3283 | + else if ($length >= 25) { $t = 15; } // floor( 200 / 8) |
|
| 3284 | + else if ($length >= 18) { $t = 18; } // floor( 150 / 8) |
|
| 3285 | + else { $t = 27; } |
|
| 3291 | 3286 | // @codingStandardsIgnoreEnd |
| 3292 | 3287 | } |
| 3293 | 3288 | |
@@ -3317,17 +3312,17 @@ discard block |
||
| 3317 | 3312 | |
| 3318 | 3313 | if (!isset($primes)) { |
| 3319 | 3314 | $primes = array( |
| 3320 | - 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, |
|
| 3321 | - 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, |
|
| 3322 | - 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, |
|
| 3323 | - 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, |
|
| 3324 | - 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, |
|
| 3325 | - 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, |
|
| 3326 | - 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, |
|
| 3327 | - 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, |
|
| 3328 | - 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, |
|
| 3329 | - 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, |
|
| 3330 | - 953, 967, 971, 977, 983, 991, 997 |
|
| 3315 | + 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, |
|
| 3316 | + 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, |
|
| 3317 | + 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, |
|
| 3318 | + 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, |
|
| 3319 | + 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, |
|
| 3320 | + 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, |
|
| 3321 | + 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, |
|
| 3322 | + 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, |
|
| 3323 | + 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, |
|
| 3324 | + 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, |
|
| 3325 | + 953, 967, 971, 977, 983, 991, 997 |
|
| 3331 | 3326 | ); |
| 3332 | 3327 | |
| 3333 | 3328 | if (MATH_BIGINTEGER_MODE != self::MODE_INTERNAL) { |
@@ -3589,7 +3584,7 @@ discard block |
||
| 3589 | 3584 | $carry = $temp >> 8; |
| 3590 | 3585 | } |
| 3591 | 3586 | $carry = ($carry != 0) ? chr($carry) : ''; |
| 3592 | - $x = $carry . $x . str_repeat(chr(0), $num_bytes); |
|
| 3587 | + $x = $carry.$x.str_repeat(chr(0), $num_bytes); |
|
| 3593 | 3588 | } |
| 3594 | 3589 | |
| 3595 | 3590 | /** |
@@ -3628,7 +3623,7 @@ discard block |
||
| 3628 | 3623 | } |
| 3629 | 3624 | $x = ltrim($x, chr(0)); |
| 3630 | 3625 | |
| 3631 | - $remainder = chr($carry >> $carry_shift) . $remainder; |
|
| 3626 | + $remainder = chr($carry >> $carry_shift).$remainder; |
|
| 3632 | 3627 | |
| 3633 | 3628 | return ltrim($remainder, chr(0)); |
| 3634 | 3629 | } |
@@ -212,7 +212,7 @@ |
||
| 212 | 212 | * |
| 213 | 213 | * @param string $remote_file |
| 214 | 214 | * @param string $local_file |
| 215 | - * @return mixed |
|
| 215 | + * @return boolean|string |
|
| 216 | 216 | * @access public |
| 217 | 217 | */ |
| 218 | 218 | function get($remote_file, $local_file = false) |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | /** |
| 71 | 71 | * SSH2 is being used. |
| 72 | 72 | */ |
| 73 | - const MODE_SSH2 = 2; |
|
| 73 | + const MODE_SSH2 = 2; |
|
| 74 | 74 | /**#@-*/ |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | return false; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - if (!$this->ssh->exec('scp -t ' . escapeshellarg($remote_file), false)) { // -t = to |
|
| 151 | + if (!$this->ssh->exec('scp -t '.escapeshellarg($remote_file), false)) { // -t = to |
|
| 152 | 152 | return false; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $size = filesize($data); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - $this->_send('C0644 ' . $size . ' ' . $remote_file . "\n"); |
|
| 180 | + $this->_send('C0644 '.$size.' '.$remote_file."\n"); |
|
| 181 | 181 | |
| 182 | 182 | $temp = $this->_receive(); |
| 183 | 183 | if ($temp !== chr(0)) { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | while ($sent < $size) { |
| 189 | 189 | $temp = $mode & self::SOURCE_STRING ? substr($data, $sent, $this->packet_size) : fread($fp, $this->packet_size); |
| 190 | 190 | $this->_send($temp); |
| 191 | - $sent+= strlen($temp); |
|
| 191 | + $sent += strlen($temp); |
|
| 192 | 192 | |
| 193 | 193 | if (is_callable($callback)) { |
| 194 | 194 | call_user_func($callback, $sent); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | return false; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if (!$this->ssh->exec('scp -f ' . escapeshellarg($remote_file), false)) { // -f = from |
|
| 224 | + if (!$this->ssh->exec('scp -f '.escapeshellarg($remote_file), false)) { // -f = from |
|
| 225 | 225 | return false; |
| 226 | 226 | } |
| 227 | 227 | |
@@ -246,10 +246,10 @@ discard block |
||
| 246 | 246 | while ($size < $info['size']) { |
| 247 | 247 | $data = $this->_receive(); |
| 248 | 248 | // SCP usually seems to split stuff out into 16k chunks |
| 249 | - $size+= strlen($data); |
|
| 249 | + $size += strlen($data); |
|
| 250 | 250 | |
| 251 | 251 | if ($local_file === false) { |
| 252 | - $content.= $data; |
|
| 252 | + $content .= $data; |
|
| 253 | 253 | } else { |
| 254 | 254 | fputs($fp, $data); |
| 255 | 255 | } |
@@ -384,7 +384,6 @@ discard block |
||
| 384 | 384 | * Login |
| 385 | 385 | * |
| 386 | 386 | * @param string $username |
| 387 | - * @param string $password |
|
| 388 | 387 | * @throws \UnexpectedValueException on receipt of unexpected packets |
| 389 | 388 | * @return bool |
| 390 | 389 | * @access public |
@@ -573,7 +572,7 @@ discard block |
||
| 573 | 572 | /** |
| 574 | 573 | * Returns the current directory name |
| 575 | 574 | * |
| 576 | - * @return mixed |
|
| 575 | + * @return string |
|
| 577 | 576 | * @access public |
| 578 | 577 | */ |
| 579 | 578 | function pwd() |
@@ -611,7 +610,7 @@ discard block |
||
| 611 | 610 | * path and returns the canonicalized absolute pathname. |
| 612 | 611 | * |
| 613 | 612 | * @param string $path |
| 614 | - * @return mixed |
|
| 613 | + * @return false|string |
|
| 615 | 614 | * @access public |
| 616 | 615 | */ |
| 617 | 616 | function realpath($path) |
@@ -628,7 +627,7 @@ discard block |
||
| 628 | 627 | * @see self::chdir() |
| 629 | 628 | * @param string $path |
| 630 | 629 | * @throws \UnexpectedValueException on receipt of unexpected packets |
| 631 | - * @return mixed |
|
| 630 | + * @return false|string |
|
| 632 | 631 | * @access private |
| 633 | 632 | */ |
| 634 | 633 | function _realpath($path) |
@@ -1101,7 +1100,7 @@ discard block |
||
| 1101 | 1100 | * Remove files / directories from cache |
| 1102 | 1101 | * |
| 1103 | 1102 | * @param string $path |
| 1104 | - * @return bool |
|
| 1103 | + * @return boolean|null |
|
| 1105 | 1104 | * @access private |
| 1106 | 1105 | */ |
| 1107 | 1106 | function _remove_from_stat_cache($path) |
@@ -1127,7 +1126,7 @@ discard block |
||
| 1127 | 1126 | * |
| 1128 | 1127 | * Mainly used by file_exists |
| 1129 | 1128 | * |
| 1130 | - * @param string $dir |
|
| 1129 | + * @param false|string $path |
|
| 1131 | 1130 | * @return mixed |
| 1132 | 1131 | * @access private |
| 1133 | 1132 | */ |
@@ -1588,7 +1587,7 @@ discard block |
||
| 1588 | 1587 | * |
| 1589 | 1588 | * @param string $link |
| 1590 | 1589 | * @throws \UnexpectedValueException on receipt of unexpected packets |
| 1591 | - * @return mixed |
|
| 1590 | + * @return false|string |
|
| 1592 | 1591 | * @access public |
| 1593 | 1592 | */ |
| 1594 | 1593 | function readlink($link) |
@@ -1702,6 +1701,7 @@ discard block |
||
| 1702 | 1701 | * Helper function for directory creation |
| 1703 | 1702 | * |
| 1704 | 1703 | * @param string $dir |
| 1704 | + * @param string $attr |
|
| 1705 | 1705 | * @return bool |
| 1706 | 1706 | * @throws \UnexpectedValueException on receipt of unexpected packets |
| 1707 | 1707 | * @access private |
@@ -2034,7 +2034,7 @@ discard block |
||
| 2034 | 2034 | * @param int $offset |
| 2035 | 2035 | * @param int $length |
| 2036 | 2036 | * @throws \UnexpectedValueException on receipt of unexpected packets |
| 2037 | - * @return mixed |
|
| 2037 | + * @return string|boolean |
|
| 2038 | 2038 | * @access public |
| 2039 | 2039 | */ |
| 2040 | 2040 | function get($remote_file, $local_file = false, $offset = 0, $length = -1) |
@@ -2504,7 +2504,7 @@ discard block |
||
| 2504 | 2504 | * Gets file type |
| 2505 | 2505 | * |
| 2506 | 2506 | * @param string $path |
| 2507 | - * @return mixed |
|
| 2507 | + * @return false|string |
|
| 2508 | 2508 | * @access public |
| 2509 | 2509 | */ |
| 2510 | 2510 | function filetype($path) |
@@ -2569,6 +2569,7 @@ discard block |
||
| 2569 | 2569 | * |
| 2570 | 2570 | * @param string $path |
| 2571 | 2571 | * @param string $prop |
| 2572 | + * @param string $type |
|
| 2572 | 2573 | * @return mixed |
| 2573 | 2574 | * @access private |
| 2574 | 2575 | */ |
@@ -2647,7 +2648,7 @@ discard block |
||
| 2647 | 2648 | * See '7. File Attributes' of draft-ietf-secsh-filexfer-13 for more info. |
| 2648 | 2649 | * |
| 2649 | 2650 | * @param string $response |
| 2650 | - * @return array |
|
| 2651 | + * @return string |
|
| 2651 | 2652 | * @access private |
| 2652 | 2653 | */ |
| 2653 | 2654 | function _parseAttributes(&$response) |
@@ -2952,7 +2953,7 @@ discard block |
||
| 2952 | 2953 | * Disconnect |
| 2953 | 2954 | * |
| 2954 | 2955 | * @param int $reason |
| 2955 | - * @return bool |
|
| 2956 | + * @return boolean|null |
|
| 2956 | 2957 | * @access private |
| 2957 | 2958 | */ |
| 2958 | 2959 | function _disconnect($reason) |
@@ -439,8 +439,8 @@ discard block |
||
| 439 | 439 | if ($response === false) { |
| 440 | 440 | // from PuTTY's psftp.exe |
| 441 | 441 | $command = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n" . |
| 442 | - "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n" . |
|
| 443 | - "exec sftp-server"; |
|
| 442 | + "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n" . |
|
| 443 | + "exec sftp-server"; |
|
| 444 | 444 | // 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 |
| 445 | 445 | // is redundant |
| 446 | 446 | $packet = pack( |
@@ -2795,7 +2795,7 @@ discard block |
||
| 2795 | 2795 | |
| 2796 | 2796 | if (defined('NET_SFTP_LOGGING')) { |
| 2797 | 2797 | $packet_type = '-> ' . $this->packet_types[$type] . |
| 2798 | - ' (' . round($stop - $start, 4) . 's)'; |
|
| 2798 | + ' (' . round($stop - $start, 4) . 's)'; |
|
| 2799 | 2799 | if (NET_SFTP_LOGGING == self::LOG_REALTIME) { |
| 2800 | 2800 | echo "<pre>\r\n" . $this->_format_log(array($data), array($packet_type)) . "\r\n</pre>\r\n"; |
| 2801 | 2801 | flush(); |
@@ -2871,7 +2871,7 @@ discard block |
||
| 2871 | 2871 | |
| 2872 | 2872 | if (defined('NET_SFTP_LOGGING')) { |
| 2873 | 2873 | $packet_type = '<- ' . $this->packet_types[$this->packet_type] . |
| 2874 | - ' (' . round($stop - $start, 4) . 's)'; |
|
| 2874 | + ' (' . round($stop - $start, 4) . 's)'; |
|
| 2875 | 2875 | if (NET_SFTP_LOGGING == self::LOG_REALTIME) { |
| 2876 | 2876 | echo "<pre>\r\n" . $this->_format_log(array($packet), array($packet_type)) . "\r\n</pre>\r\n"; |
| 2877 | 2877 | flush(); |
@@ -438,8 +438,8 @@ discard block |
||
| 438 | 438 | $response = $this->_get_channel_packet(self::CHANNEL); |
| 439 | 439 | if ($response === false) { |
| 440 | 440 | // from PuTTY's psftp.exe |
| 441 | - $command = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n" . |
|
| 442 | - "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n" . |
|
| 441 | + $command = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n". |
|
| 442 | + "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n". |
|
| 443 | 443 | "exec sftp-server"; |
| 444 | 444 | // 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 |
| 445 | 445 | // is redundant |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | if ($this->version > 2) { |
| 600 | 600 | extract(unpack('Nlength', Strings::shift($response, 4))); |
| 601 | - $this->sftp_errors[] = $error . ': ' . Strings::shift($response, $length); |
|
| 601 | + $this->sftp_errors[] = $error.': '.Strings::shift($response, $length); |
|
| 602 | 602 | } else { |
| 603 | 603 | $this->sftp_errors[] = $error; |
| 604 | 604 | } |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | if ($path[0] != '/') { |
| 660 | - $path = $this->pwd . '/' . $path; |
|
| 660 | + $path = $this->pwd.'/'.$path; |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | $path = explode('/', $path); |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | } |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - return '/' . implode('/', $new); |
|
| 679 | + return '/'.implode('/', $new); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | /** |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | $dir = './'; |
| 699 | 699 | // suffix a slash if needed |
| 700 | 700 | } elseif ($dir[strlen($dir) - 1] != '/') { |
| 701 | - $dir.= '/'; |
|
| 701 | + $dir .= '/'; |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | $dir = $this->_realpath($dir); |
@@ -779,11 +779,11 @@ discard block |
||
| 779 | 779 | } |
| 780 | 780 | continue; |
| 781 | 781 | } |
| 782 | - if (is_array($this->_query_stat_cache($this->_realpath($dir . '/' . $value)))) { |
|
| 783 | - $temp = $this->_nlist_helper($dir . '/' . $value, true, $relativeDir . $value . '/'); |
|
| 782 | + if (is_array($this->_query_stat_cache($this->_realpath($dir.'/'.$value)))) { |
|
| 783 | + $temp = $this->_nlist_helper($dir.'/'.$value, true, $relativeDir.$value.'/'); |
|
| 784 | 784 | $result = array_merge($result, $temp); |
| 785 | 785 | } else { |
| 786 | - $result[] = $relativeDir . $value; |
|
| 786 | + $result[] = $relativeDir.$value; |
|
| 787 | 787 | } |
| 788 | 788 | } |
| 789 | 789 | |
@@ -812,9 +812,9 @@ discard block |
||
| 812 | 812 | unset($files[$key]); |
| 813 | 813 | continue; |
| 814 | 814 | } |
| 815 | - if ($key != '.' && $key != '..' && is_array($this->_query_stat_cache($this->_realpath($dir . '/' . $key)))) { |
|
| 815 | + if ($key != '.' && $key != '..' && is_array($this->_query_stat_cache($this->_realpath($dir.'/'.$key)))) { |
|
| 816 | 816 | $depth++; |
| 817 | - $files[$key] = $this->rawlist($dir . '/' . $key, true); |
|
| 817 | + $files[$key] = $this->rawlist($dir.'/'.$key, true); |
|
| 818 | 818 | $depth--; |
| 819 | 819 | } else { |
| 820 | 820 | $files[$key] = (object) $value; |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | return false; |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | - $dir = $this->_realpath($dir . '/'); |
|
| 842 | + $dir = $this->_realpath($dir.'/'); |
|
| 843 | 843 | if ($dir === false) { |
| 844 | 844 | return false; |
| 845 | 845 | } |
@@ -895,12 +895,12 @@ discard block |
||
| 895 | 895 | $contents[$shortname] = $attributes + array('filename' => $shortname); |
| 896 | 896 | |
| 897 | 897 | if (isset($attributes['type']) && $attributes['type'] == NET_SFTP_TYPE_DIRECTORY && ($shortname != '.' && $shortname != '..')) { |
| 898 | - $this->_update_stat_cache($dir . '/' . $shortname, array()); |
|
| 898 | + $this->_update_stat_cache($dir.'/'.$shortname, array()); |
|
| 899 | 899 | } else { |
| 900 | 900 | if ($shortname == '..') { |
| 901 | - $temp = $this->_realpath($dir . '/..') . '/.'; |
|
| 901 | + $temp = $this->_realpath($dir.'/..').'/.'; |
|
| 902 | 902 | } else { |
| 903 | - $temp = $dir . '/' . $shortname; |
|
| 903 | + $temp = $dir.'/'.$shortname; |
|
| 904 | 904 | } |
| 905 | 905 | $this->_update_stat_cache($temp, (object) array('lstat' => $attributes)); |
| 906 | 906 | } |
@@ -984,8 +984,8 @@ discard block |
||
| 984 | 984 | break; |
| 985 | 985 | case 'permissions': |
| 986 | 986 | case 'mode': |
| 987 | - $a[$sort]&= 07777; |
|
| 988 | - $b[$sort]&= 07777; |
|
| 987 | + $a[$sort] &= 07777; |
|
| 988 | + $b[$sort] &= 07777; |
|
| 989 | 989 | default: |
| 990 | 990 | if ($a[$sort] === $b[$sort]) { |
| 991 | 991 | break; |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | return; |
| 1024 | 1024 | } |
| 1025 | 1025 | $len = count($args) & 0x7FFFFFFE; |
| 1026 | - for ($i = 0; $i < $len; $i+=2) { |
|
| 1026 | + for ($i = 0; $i < $len; $i += 2) { |
|
| 1027 | 1027 | $this->sortOptions[$args[$i]] = $args[$i + 1]; |
| 1028 | 1028 | } |
| 1029 | 1029 | if (!count($this->sortOptions)) { |
@@ -1182,7 +1182,7 @@ discard block |
||
| 1182 | 1182 | } |
| 1183 | 1183 | if (isset($stat['type'])) { |
| 1184 | 1184 | if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) { |
| 1185 | - $filename.= '/.'; |
|
| 1185 | + $filename .= '/.'; |
|
| 1186 | 1186 | } |
| 1187 | 1187 | $this->_update_stat_cache($filename, (object) array('stat' => $stat)); |
| 1188 | 1188 | return $stat; |
@@ -1190,12 +1190,11 @@ discard block |
||
| 1190 | 1190 | |
| 1191 | 1191 | $pwd = $this->pwd; |
| 1192 | 1192 | $stat['type'] = $this->chdir($filename) ? |
| 1193 | - NET_SFTP_TYPE_DIRECTORY : |
|
| 1194 | - NET_SFTP_TYPE_REGULAR; |
|
| 1193 | + NET_SFTP_TYPE_DIRECTORY : NET_SFTP_TYPE_REGULAR; |
|
| 1195 | 1194 | $this->pwd = $pwd; |
| 1196 | 1195 | |
| 1197 | 1196 | if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) { |
| 1198 | - $filename.= '/.'; |
|
| 1197 | + $filename .= '/.'; |
|
| 1199 | 1198 | } |
| 1200 | 1199 | $this->_update_stat_cache($filename, (object) array('stat' => $stat)); |
| 1201 | 1200 | |
@@ -1239,7 +1238,7 @@ discard block |
||
| 1239 | 1238 | } |
| 1240 | 1239 | if (isset($lstat['type'])) { |
| 1241 | 1240 | if ($lstat['type'] == NET_SFTP_TYPE_DIRECTORY) { |
| 1242 | - $filename.= '/.'; |
|
| 1241 | + $filename .= '/.'; |
|
| 1243 | 1242 | } |
| 1244 | 1243 | $this->_update_stat_cache($filename, (object) array('lstat' => $lstat)); |
| 1245 | 1244 | return $lstat; |
@@ -1255,12 +1254,11 @@ discard block |
||
| 1255 | 1254 | |
| 1256 | 1255 | $pwd = $this->pwd; |
| 1257 | 1256 | $lstat['type'] = $this->chdir($filename) ? |
| 1258 | - NET_SFTP_TYPE_DIRECTORY : |
|
| 1259 | - NET_SFTP_TYPE_REGULAR; |
|
| 1257 | + NET_SFTP_TYPE_DIRECTORY : NET_SFTP_TYPE_REGULAR; |
|
| 1260 | 1258 | $this->pwd = $pwd; |
| 1261 | 1259 | |
| 1262 | 1260 | if ($lstat['type'] == NET_SFTP_TYPE_DIRECTORY) { |
| 1263 | - $filename.= '/.'; |
|
| 1261 | + $filename .= '/.'; |
|
| 1264 | 1262 | } |
| 1265 | 1263 | $this->_update_stat_cache($filename, (object) array('lstat' => $lstat)); |
| 1266 | 1264 | |
@@ -1546,7 +1544,7 @@ discard block |
||
| 1546 | 1544 | return false; |
| 1547 | 1545 | } |
| 1548 | 1546 | |
| 1549 | - $temp = $path . '/' . $filename; |
|
| 1547 | + $temp = $path.'/'.$filename; |
|
| 1550 | 1548 | if ($props['type'] == NET_SFTP_TYPE_DIRECTORY) { |
| 1551 | 1549 | if (!$this->_setstat_recursive($temp, $attr, $i)) { |
| 1552 | 1550 | return false; |
@@ -1685,7 +1683,7 @@ discard block |
||
| 1685 | 1683 | $dirs = explode('/', preg_replace('#/(?=/)|/$#', '', $dir)); |
| 1686 | 1684 | if (empty($dirs[0])) { |
| 1687 | 1685 | array_shift($dirs); |
| 1688 | - $dirs[0] = '/' . $dirs[0]; |
|
| 1686 | + $dirs[0] = '/'.$dirs[0]; |
|
| 1689 | 1687 | } |
| 1690 | 1688 | for ($i = 0; $i < count($dirs); $i++) { |
| 1691 | 1689 | $temp = array_slice($dirs, 0, $i + 1); |
@@ -1844,7 +1842,7 @@ discard block |
||
| 1844 | 1842 | $offset = $size !== false ? $size : 0; |
| 1845 | 1843 | } else { |
| 1846 | 1844 | $offset = 0; |
| 1847 | - $flags|= NET_SFTP_OPEN_TRUNCATE; |
|
| 1845 | + $flags |= NET_SFTP_OPEN_TRUNCATE; |
|
| 1848 | 1846 | } |
| 1849 | 1847 | |
| 1850 | 1848 | $packet = pack('Na*N2', strlen($remote_file), $remote_file, $flags, 0); |
@@ -1894,7 +1892,7 @@ discard block |
||
| 1894 | 1892 | |
| 1895 | 1893 | if ($local_start >= 0) { |
| 1896 | 1894 | fseek($fp, $local_start); |
| 1897 | - $size-= $local_start; |
|
| 1895 | + $size -= $local_start; |
|
| 1898 | 1896 | } |
| 1899 | 1897 | } elseif ($dataCallback) { |
| 1900 | 1898 | $size = 0; |
@@ -1907,7 +1905,7 @@ discard block |
||
| 1907 | 1905 | |
| 1908 | 1906 | $sftp_packet_size = 4096; // PuTTY uses 4096 |
| 1909 | 1907 | // make the SFTP packet be exactly 4096 bytes by including the bytes in the NET_SFTP_WRITE packets "header" |
| 1910 | - $sftp_packet_size-= strlen($handle) + 25; |
|
| 1908 | + $sftp_packet_size -= strlen($handle) + 25; |
|
| 1911 | 1909 | $i = 0; |
| 1912 | 1910 | while ($dataCallback || ($size === 0 || $sent < $size)) { |
| 1913 | 1911 | if ($dataCallback) { |
@@ -1930,7 +1928,7 @@ discard block |
||
| 1930 | 1928 | } |
| 1931 | 1929 | return false; |
| 1932 | 1930 | } |
| 1933 | - $sent+= strlen($temp); |
|
| 1931 | + $sent += strlen($temp); |
|
| 1934 | 1932 | if (is_callable($progressCallback)) { |
| 1935 | 1933 | call_user_func($progressCallback, $sent); |
| 1936 | 1934 | } |
@@ -2101,7 +2099,7 @@ discard block |
||
| 2101 | 2099 | return false; |
| 2102 | 2100 | } |
| 2103 | 2101 | $packet = null; |
| 2104 | - $read+= $packet_size; |
|
| 2102 | + $read += $packet_size; |
|
| 2105 | 2103 | $i++; |
| 2106 | 2104 | } |
| 2107 | 2105 | |
@@ -2123,9 +2121,9 @@ discard block |
||
| 2123 | 2121 | switch ($this->packet_type) { |
| 2124 | 2122 | case NET_SFTP_DATA: |
| 2125 | 2123 | $temp = substr($response, 4); |
| 2126 | - $offset+= strlen($temp); |
|
| 2124 | + $offset += strlen($temp); |
|
| 2127 | 2125 | if ($local_file === false) { |
| 2128 | - $content.= $temp; |
|
| 2126 | + $content .= $temp; |
|
| 2129 | 2127 | } else { |
| 2130 | 2128 | fputs($fp, $temp); |
| 2131 | 2129 | } |
@@ -2248,7 +2246,7 @@ discard block |
||
| 2248 | 2246 | return false; |
| 2249 | 2247 | } |
| 2250 | 2248 | |
| 2251 | - $temp = $path . '/' . $filename; |
|
| 2249 | + $temp = $path.'/'.$filename; |
|
| 2252 | 2250 | if ($props['type'] == NET_SFTP_TYPE_DIRECTORY) { |
| 2253 | 2251 | if (!$this->_delete_recursive($temp, $i)) { |
| 2254 | 2252 | return false; |
@@ -2667,20 +2665,20 @@ discard block |
||
| 2667 | 2665 | $attr['size'] = hexdec(Hex::encode(Strings::shift($response, 8))); |
| 2668 | 2666 | break; |
| 2669 | 2667 | case NET_SFTP_ATTR_UIDGID: // 0x00000002 (SFTPv3 only) |
| 2670 | - $attr+= unpack('Nuid/Ngid', Strings::shift($response, 8)); |
|
| 2668 | + $attr += unpack('Nuid/Ngid', Strings::shift($response, 8)); |
|
| 2671 | 2669 | break; |
| 2672 | 2670 | case NET_SFTP_ATTR_PERMISSIONS: // 0x00000004 |
| 2673 | - $attr+= unpack('Npermissions', Strings::shift($response, 4)); |
|
| 2671 | + $attr += unpack('Npermissions', Strings::shift($response, 4)); |
|
| 2674 | 2672 | // mode == permissions; permissions was the original array key and is retained for bc purposes. |
| 2675 | 2673 | // mode was added because that's the more industry standard terminology |
| 2676 | - $attr+= array('mode' => $attr['permissions']); |
|
| 2674 | + $attr += array('mode' => $attr['permissions']); |
|
| 2677 | 2675 | $fileType = $this->_parseMode($attr['permissions']); |
| 2678 | 2676 | if ($fileType !== false) { |
| 2679 | - $attr+= array('type' => $fileType); |
|
| 2677 | + $attr += array('type' => $fileType); |
|
| 2680 | 2678 | } |
| 2681 | 2679 | break; |
| 2682 | 2680 | case NET_SFTP_ATTR_ACCESSTIME: // 0x00000008 |
| 2683 | - $attr+= unpack('Natime/Nmtime', Strings::shift($response, 8)); |
|
| 2681 | + $attr += unpack('Natime/Nmtime', Strings::shift($response, 8)); |
|
| 2684 | 2682 | break; |
| 2685 | 2683 | case NET_SFTP_ATTR_EXTENDED: // 0x80000000 |
| 2686 | 2684 | extract(unpack('Ncount', Strings::shift($response, 4))); |
@@ -2786,18 +2784,17 @@ discard block |
||
| 2786 | 2784 | function _send_sftp_packet($type, $data) |
| 2787 | 2785 | { |
| 2788 | 2786 | $packet = $this->request_id !== false ? |
| 2789 | - pack('NCNa*', strlen($data) + 5, $type, $this->request_id, $data) : |
|
| 2790 | - pack('NCa*', strlen($data) + 1, $type, $data); |
|
| 2787 | + pack('NCNa*', strlen($data) + 5, $type, $this->request_id, $data) : pack('NCa*', strlen($data) + 1, $type, $data); |
|
| 2791 | 2788 | |
| 2792 | 2789 | $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 |
| 2793 | 2790 | $result = $this->_send_channel_packet(self::CHANNEL, $packet); |
| 2794 | 2791 | $stop = strtok(microtime(), ' ') + strtok(''); |
| 2795 | 2792 | |
| 2796 | 2793 | if (defined('NET_SFTP_LOGGING')) { |
| 2797 | - $packet_type = '-> ' . $this->packet_types[$type] . |
|
| 2798 | - ' (' . round($stop - $start, 4) . 's)'; |
|
| 2794 | + $packet_type = '-> '.$this->packet_types[$type]. |
|
| 2795 | + ' ('.round($stop - $start, 4).'s)'; |
|
| 2799 | 2796 | if (NET_SFTP_LOGGING == self::LOG_REALTIME) { |
| 2800 | - echo "<pre>\r\n" . $this->_format_log(array($data), array($packet_type)) . "\r\n</pre>\r\n"; |
|
| 2797 | + echo "<pre>\r\n".$this->_format_log(array($data), array($packet_type))."\r\n</pre>\r\n"; |
|
| 2801 | 2798 | flush(); |
| 2802 | 2799 | ob_flush(); |
| 2803 | 2800 | } else { |
@@ -2838,11 +2835,11 @@ discard block |
||
| 2838 | 2835 | $this->packet_buffer = ''; |
| 2839 | 2836 | return false; |
| 2840 | 2837 | } |
| 2841 | - $this->packet_buffer.= $temp; |
|
| 2838 | + $this->packet_buffer .= $temp; |
|
| 2842 | 2839 | } |
| 2843 | 2840 | extract(unpack('Nlength', Strings::shift($this->packet_buffer, 4))); |
| 2844 | 2841 | $tempLength = $length; |
| 2845 | - $tempLength-= strlen($this->packet_buffer); |
|
| 2842 | + $tempLength -= strlen($this->packet_buffer); |
|
| 2846 | 2843 | |
| 2847 | 2844 | // SFTP packet type and data payload |
| 2848 | 2845 | while ($tempLength > 0) { |
@@ -2852,8 +2849,8 @@ discard block |
||
| 2852 | 2849 | $this->packet_buffer = ''; |
| 2853 | 2850 | return false; |
| 2854 | 2851 | } |
| 2855 | - $this->packet_buffer.= $temp; |
|
| 2856 | - $tempLength-= strlen($temp); |
|
| 2852 | + $this->packet_buffer .= $temp; |
|
| 2853 | + $tempLength -= strlen($temp); |
|
| 2857 | 2854 | } |
| 2858 | 2855 | |
| 2859 | 2856 | $stop = strtok(microtime(), ' ') + strtok(''); |
@@ -2862,18 +2859,18 @@ discard block |
||
| 2862 | 2859 | |
| 2863 | 2860 | if ($this->request_id !== false) { |
| 2864 | 2861 | Strings::shift($this->packet_buffer, 4); // remove the request id |
| 2865 | - $length-= 5; // account for the request id and the packet type |
|
| 2862 | + $length -= 5; // account for the request id and the packet type |
|
| 2866 | 2863 | } else { |
| 2867 | - $length-= 1; // account for the packet type |
|
| 2864 | + $length -= 1; // account for the packet type |
|
| 2868 | 2865 | } |
| 2869 | 2866 | |
| 2870 | 2867 | $packet = Strings::shift($this->packet_buffer, $length); |
| 2871 | 2868 | |
| 2872 | 2869 | if (defined('NET_SFTP_LOGGING')) { |
| 2873 | - $packet_type = '<- ' . $this->packet_types[$this->packet_type] . |
|
| 2874 | - ' (' . round($stop - $start, 4) . 's)'; |
|
| 2870 | + $packet_type = '<- '.$this->packet_types[$this->packet_type]. |
|
| 2871 | + ' ('.round($stop - $start, 4).'s)'; |
|
| 2875 | 2872 | if (NET_SFTP_LOGGING == self::LOG_REALTIME) { |
| 2876 | - echo "<pre>\r\n" . $this->_format_log(array($packet), array($packet_type)) . "\r\n</pre>\r\n"; |
|
| 2873 | + echo "<pre>\r\n".$this->_format_log(array($packet), array($packet_type))."\r\n</pre>\r\n"; |
|
| 2877 | 2874 | flush(); |
| 2878 | 2875 | ob_flush(); |
| 2879 | 2876 | } else { |
@@ -626,7 +626,6 @@ |
||
| 626 | 626 | * $options. What does 8 correspond to? |
| 627 | 627 | * |
| 628 | 628 | * @param string $path |
| 629 | - * @param int $mode |
|
| 630 | 629 | * @param int $options |
| 631 | 630 | * @return bool |
| 632 | 631 | * @access public |
@@ -157,14 +157,14 @@ discard block |
||
| 157 | 157 | $orig = $path; |
| 158 | 158 | extract(parse_url($path) + array('port' => 22)); |
| 159 | 159 | if (isset($query)) { |
| 160 | - $path.= '?' . $query; |
|
| 160 | + $path .= '?'.$query; |
|
| 161 | 161 | } elseif (preg_match('/(\?|\?#)$/', $orig)) { |
| 162 | - $path.= '?'; |
|
| 162 | + $path .= '?'; |
|
| 163 | 163 | } |
| 164 | 164 | if (isset($fragment)) { |
| 165 | - $path.= '#' . $fragment; |
|
| 165 | + $path .= '#'.$fragment; |
|
| 166 | 166 | } elseif ($orig[strlen($orig) - 1] == '#') { |
| 167 | - $path.= '#'; |
|
| 167 | + $path .= '#'; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | if (!isset($host)) { |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $this->eof = true; |
| 330 | 330 | return false; |
| 331 | 331 | } |
| 332 | - $this->pos+= strlen($result); |
|
| 332 | + $this->pos += strlen($result); |
|
| 333 | 333 | |
| 334 | 334 | return $result; |
| 335 | 335 | } |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | if ($result === false) { |
| 362 | 362 | return false; |
| 363 | 363 | } |
| 364 | - $this->pos+= strlen($data); |
|
| 364 | + $this->pos += strlen($data); |
|
| 365 | 365 | if ($this->pos > $this->size) { |
| 366 | 366 | $this->size = $this->pos; |
| 367 | 367 | } |
@@ -415,10 +415,10 @@ discard block |
||
| 415 | 415 | } |
| 416 | 416 | break; |
| 417 | 417 | case SEEK_CUR: |
| 418 | - $offset+= $this->pos; |
|
| 418 | + $offset += $this->pos; |
|
| 419 | 419 | break; |
| 420 | 420 | case SEEK_END: |
| 421 | - $offset+= $this->size; |
|
| 421 | + $offset += $this->size; |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | $this->pos = $offset; |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | function __call($name, $arguments) |
| 777 | 777 | { |
| 778 | 778 | if (defined('NET_SFTP_STREAM_LOGGING')) { |
| 779 | - echo $name . '('; |
|
| 779 | + echo $name.'('; |
|
| 780 | 780 | $last = count($arguments) - 1; |
| 781 | 781 | foreach ($arguments as $i => $argument) { |
| 782 | 782 | var_export($argument); |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | } |
| 787 | 787 | echo ")\r\n"; |
| 788 | 788 | } |
| 789 | - $name = '_' . $name; |
|
| 789 | + $name = '_'.$name; |
|
| 790 | 790 | if (!method_exists($this, $name)) { |
| 791 | 791 | return false; |
| 792 | 792 | } |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | * @see self::interactiveRead() |
| 792 | 792 | * @see self::interactiveWrite() |
| 793 | 793 | * @param string $cmd |
| 794 | - * @return mixed |
|
| 794 | + * @return boolean|string |
|
| 795 | 795 | * @throws \RuntimeException on error sending command |
| 796 | 796 | * @access public |
| 797 | 797 | */ |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | * @see self::write() |
| 900 | 900 | * @param string $expect |
| 901 | 901 | * @param int $mode |
| 902 | - * @return bool |
|
| 902 | + * @return string|null |
|
| 903 | 903 | * @throws \RuntimeException on connection error |
| 904 | 904 | * @access public |
| 905 | 905 | */ |
@@ -1282,8 +1282,8 @@ discard block |
||
| 1282 | 1282 | * |
| 1283 | 1283 | * @see self::__construct() |
| 1284 | 1284 | * @param BigInteger $m |
| 1285 | - * @param array $key |
|
| 1286 | - * @return BigInteger |
|
| 1285 | + * @param BigInteger[] $key |
|
| 1286 | + * @return string |
|
| 1287 | 1287 | * @access private |
| 1288 | 1288 | */ |
| 1289 | 1289 | function _rsa_crypt($m, $key) |
@@ -1331,7 +1331,6 @@ discard block |
||
| 1331 | 1331 | * named constants from it, using the value as the name of the constant and the index as the value of the constant. |
| 1332 | 1332 | * If any of the constants that would be defined already exists, none of the constants will be defined. |
| 1333 | 1333 | * |
| 1334 | - * @param array $array |
|
| 1335 | 1334 | * @access private |
| 1336 | 1335 | */ |
| 1337 | 1336 | function _define_array() |
@@ -1530,8 +1529,9 @@ discard block |
||
| 1530 | 1529 | * |
| 1531 | 1530 | * Makes sure that only the last 1MB worth of packets will be logged |
| 1532 | 1531 | * |
| 1533 | - * @param string $data |
|
| 1534 | 1532 | * @access private |
| 1533 | + * @param string $protocol_flags |
|
| 1534 | + * @param string $message |
|
| 1535 | 1535 | */ |
| 1536 | 1536 | function _append_log($protocol_flags, $message) |
| 1537 | 1537 | { |
@@ -48,7 +48,6 @@ |
||
| 48 | 48 | |
| 49 | 49 | namespace phpseclib\Net; |
| 50 | 50 | |
| 51 | -use ParagonIE\ConstantTime\Hex; |
|
| 52 | 51 | use phpseclib\Crypt\DES; |
| 53 | 52 | use phpseclib\Crypt\Random; |
| 54 | 53 | use phpseclib\Crypt\TripleDES; |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | |
| 555 | 555 | if (defined('NET_SSH1_LOGGING')) { |
| 556 | 556 | $this->_append_log('<-', $this->server_identification); |
| 557 | - $this->_append_log('->', $this->identifier . "\r\n"); |
|
| 557 | + $this->_append_log('->', $this->identifier."\r\n"); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | if (!preg_match('#SSH-([0-9\.]+)-(.+)#', $init_line, $parts)) { |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | } |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | - $session_id = md5($host_key_public_modulus->toBytes() . $server_key_public_modulus->toBytes() . $anti_spoofing_cookie, true); |
|
| 614 | + $session_id = md5($host_key_public_modulus->toBytes().$server_key_public_modulus->toBytes().$anti_spoofing_cookie, true); |
|
| 615 | 615 | |
| 616 | 616 | $session_key = Random::string(32); |
| 617 | 617 | $double_encrypted_session_key = $session_key ^ str_pad($session_id, 32, chr(0)); |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | $this->crypto = new DES(DES::MODE_CBC); |
| 664 | 664 | $this->crypto->disablePadding(); |
| 665 | 665 | $this->crypto->enableContinuousBuffer(); |
| 666 | - $this->crypto->setKey(substr($session_key, 0, 8)); |
|
| 666 | + $this->crypto->setKey(substr($session_key, 0, 8)); |
|
| 667 | 667 | // "The iv (initialization vector) is initialized to all zeroes." |
| 668 | 668 | $this->crypto->setIV(str_repeat("\0", 8)); |
| 669 | 669 | break; |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | |
| 817 | 817 | if ($response !== false) { |
| 818 | 818 | do { |
| 819 | - $output.= substr($response[self::RESPONSE_DATA], 4); |
|
| 819 | + $output .= substr($response[self::RESPONSE_DATA], 4); |
|
| 820 | 820 | $response = $this->_get_binary_packet(); |
| 821 | 821 | } while (is_array($response) && $response[self::RESPONSE_TYPE] != NET_SSH1_SMSG_EXITSTATUS); |
| 822 | 822 | } |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | if ($response === true) { |
| 929 | 929 | return Strings::shift($this->interactiveBuffer, strlen($this->interactiveBuffer)); |
| 930 | 930 | } |
| 931 | - $this->interactiveBuffer.= substr($response[self::RESPONSE_DATA], 4); |
|
| 931 | + $this->interactiveBuffer .= substr($response[self::RESPONSE_DATA], 4); |
|
| 932 | 932 | } |
| 933 | 933 | } |
| 934 | 934 | |
@@ -1081,7 +1081,7 @@ discard block |
||
| 1081 | 1081 | return true; |
| 1082 | 1082 | } |
| 1083 | 1083 | $elapsed = strtok(microtime(), ' ') + strtok('') - $start; |
| 1084 | - $this->curTimeout-= $elapsed; |
|
| 1084 | + $this->curTimeout -= $elapsed; |
|
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 |
@@ -1093,8 +1093,8 @@ discard block |
||
| 1093 | 1093 | |
| 1094 | 1094 | while ($length > 0) { |
| 1095 | 1095 | $temp = fread($this->fsock, $length); |
| 1096 | - $raw.= $temp; |
|
| 1097 | - $length-= strlen($temp); |
|
| 1096 | + $raw .= $temp; |
|
| 1097 | + $length -= strlen($temp); |
|
| 1098 | 1098 | } |
| 1099 | 1099 | $stop = strtok(microtime(), ' ') + strtok(''); |
| 1100 | 1100 | |
@@ -1117,8 +1117,8 @@ discard block |
||
| 1117 | 1117 | |
| 1118 | 1118 | if (defined('NET_SSH1_LOGGING')) { |
| 1119 | 1119 | $temp = isset($this->protocol_flags[$type]) ? $this->protocol_flags[$type] : 'UNKNOWN'; |
| 1120 | - $temp = '<- ' . $temp . |
|
| 1121 | - ' (' . round($stop - $start, 4) . 's)'; |
|
| 1120 | + $temp = '<- '.$temp. |
|
| 1121 | + ' ('.round($stop - $start, 4).'s)'; |
|
| 1122 | 1122 | $this->_append_log($temp, $data); |
| 1123 | 1123 | } |
| 1124 | 1124 | |
@@ -1150,8 +1150,8 @@ discard block |
||
| 1150 | 1150 | $padding = Random::string(8 - ($length & 7)); |
| 1151 | 1151 | |
| 1152 | 1152 | $orig = $data; |
| 1153 | - $data = $padding . $data; |
|
| 1154 | - $data.= pack('N', $this->_crc($data)); |
|
| 1153 | + $data = $padding.$data; |
|
| 1154 | + $data .= pack('N', $this->_crc($data)); |
|
| 1155 | 1155 | |
| 1156 | 1156 | if ($this->crypto !== false) { |
| 1157 | 1157 | $data = $this->crypto->encrypt($data); |
@@ -1165,8 +1165,8 @@ discard block |
||
| 1165 | 1165 | |
| 1166 | 1166 | if (defined('NET_SSH1_LOGGING')) { |
| 1167 | 1167 | $temp = isset($this->protocol_flags[ord($orig[0])]) ? $this->protocol_flags[ord($orig[0])] : 'UNKNOWN'; |
| 1168 | - $temp = '-> ' . $temp . |
|
| 1169 | - ' (' . round($stop - $start, 4) . 's)'; |
|
| 1168 | + $temp = '-> '.$temp. |
|
| 1169 | + ' ('.round($stop - $start, 4).'s)'; |
|
| 1170 | 1170 | $this->_append_log($temp, $orig); |
| 1171 | 1171 | } |
| 1172 | 1172 | |
@@ -1260,7 +1260,7 @@ discard block |
||
| 1260 | 1260 | $crc = 0x00000000; |
| 1261 | 1261 | $length = strlen($data); |
| 1262 | 1262 | |
| 1263 | - for ($i=0; $i<$length; $i++) { |
|
| 1263 | + for ($i = 0; $i < $length; $i++) { |
|
| 1264 | 1264 | // We AND $crc >> 8 with 0x00FFFFFF because we want the eight newly added bits to all |
| 1265 | 1265 | // be zero. PHP, unfortunately, doesn't always do this. 0x80000000 >> 8, as an example, |
| 1266 | 1266 | // yields 0xFF800000 - not 0x00800000. The following link elaborates: |
@@ -1314,9 +1314,9 @@ discard block |
||
| 1314 | 1314 | while (strlen($random) != $length) { |
| 1315 | 1315 | $block = Random::string($length - strlen($random)); |
| 1316 | 1316 | $block = str_replace("\x00", '', $block); |
| 1317 | - $random.= $block; |
|
| 1317 | + $random .= $block; |
|
| 1318 | 1318 | } |
| 1319 | - $temp = chr(0) . chr(2) . $random . chr(0) . $m; |
|
| 1319 | + $temp = chr(0).chr(2).$random.chr(0).$m; |
|
| 1320 | 1320 | |
| 1321 | 1321 | $m = new BigInteger($temp, 256); |
| 1322 | 1322 | $m = $m->modPow($key[0], $key[1]); |
@@ -1386,12 +1386,12 @@ discard block |
||
| 1386 | 1386 | { |
| 1387 | 1387 | $output = ''; |
| 1388 | 1388 | for ($i = 0; $i < count($message_log); $i++) { |
| 1389 | - $output.= $message_number_log[$i] . "\r\n"; |
|
| 1389 | + $output .= $message_number_log[$i]."\r\n"; |
|
| 1390 | 1390 | $current_log = $message_log[$i]; |
| 1391 | 1391 | $j = 0; |
| 1392 | 1392 | do { |
| 1393 | 1393 | if (strlen($current_log)) { |
| 1394 | - $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; |
|
| 1394 | + $output .= str_pad(dechex($j), 7, '0', STR_PAD_LEFT).'0 '; |
|
| 1395 | 1395 | } |
| 1396 | 1396 | $fragment = Strings::shift($current_log, $this->log_short_width); |
| 1397 | 1397 | $hex = substr(preg_replace_callback('#.#s', array($this, '_format_log_helper'), $fragment), strlen($this->log_boundary)); |
@@ -1399,10 +1399,10 @@ discard block |
||
| 1399 | 1399 | // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters |
| 1400 | 1400 | // also replace < with a . since < messes up the output on web browsers |
| 1401 | 1401 | $raw = preg_replace('#[^\x20-\x7E]|<#', '.', $fragment); |
| 1402 | - $output.= str_pad($hex, $this->log_long_width - $this->log_short_width, ' ') . $raw . "\r\n"; |
|
| 1402 | + $output .= str_pad($hex, $this->log_long_width - $this->log_short_width, ' ').$raw."\r\n"; |
|
| 1403 | 1403 | $j++; |
| 1404 | 1404 | } while (strlen($current_log)); |
| 1405 | - $output.= "\r\n"; |
|
| 1405 | + $output .= "\r\n"; |
|
| 1406 | 1406 | } |
| 1407 | 1407 | |
| 1408 | 1408 | return $output; |
@@ -1419,7 +1419,7 @@ discard block |
||
| 1419 | 1419 | */ |
| 1420 | 1420 | function _format_log_helper($matches) |
| 1421 | 1421 | { |
| 1422 | - return $this->log_boundary . str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT); |
|
| 1422 | + return $this->log_boundary.str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT); |
|
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | 1425 | /** |
@@ -1544,10 +1544,10 @@ discard block |
||
| 1544 | 1544 | case self::LOG_COMPLEX: |
| 1545 | 1545 | $this->protocol_flags_log[] = $protocol_flags; |
| 1546 | 1546 | Strings::shift($message); |
| 1547 | - $this->log_size+= strlen($message); |
|
| 1547 | + $this->log_size += strlen($message); |
|
| 1548 | 1548 | $this->message_log[] = $message; |
| 1549 | 1549 | while ($this->log_size > self::LOG_MAX_SIZE) { |
| 1550 | - $this->log_size-= strlen(array_shift($this->message_log)); |
|
| 1550 | + $this->log_size -= strlen(array_shift($this->message_log)); |
|
| 1551 | 1551 | array_shift($this->protocol_flags_log); |
| 1552 | 1552 | } |
| 1553 | 1553 | break; |
@@ -1555,7 +1555,7 @@ discard block |
||
| 1555 | 1555 | // passwords won't be filtered out and select other packets may not be correctly |
| 1556 | 1556 | // identified |
| 1557 | 1557 | case self::LOG_REALTIME: |
| 1558 | - echo "<pre>\r\n" . $this->_format_log(array($message), array($protocol_flags)) . "\r\n</pre>\r\n"; |
|
| 1558 | + echo "<pre>\r\n".$this->_format_log(array($message), array($protocol_flags))."\r\n</pre>\r\n"; |
|
| 1559 | 1559 | @flush(); |
| 1560 | 1560 | @ob_flush(); |
| 1561 | 1561 | break; |
@@ -1576,10 +1576,10 @@ discard block |
||
| 1576 | 1576 | $entry = $this->_format_log(array($message), array($protocol_flags)); |
| 1577 | 1577 | if ($this->realtime_log_wrap) { |
| 1578 | 1578 | $temp = "<<< START >>>\r\n"; |
| 1579 | - $entry.= $temp; |
|
| 1579 | + $entry .= $temp; |
|
| 1580 | 1580 | fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp)); |
| 1581 | 1581 | } |
| 1582 | - $this->realtime_log_size+= strlen($entry); |
|
| 1582 | + $this->realtime_log_size += strlen($entry); |
|
| 1583 | 1583 | if ($this->realtime_log_size > self::LOG_MAX_SIZE) { |
| 1584 | 1584 | fseek($this->realtime_log_file, 0); |
| 1585 | 1585 | $this->realtime_log_size = strlen($entry); |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | * |
| 904 | 904 | * $host can either be a string, representing the host, or a stream resource. |
| 905 | 905 | * |
| 906 | - * @param mixed $host |
|
| 906 | + * @param string $host |
|
| 907 | 907 | * @param int $port |
| 908 | 908 | * @param int $timeout |
| 909 | 909 | * @see self::login() |
@@ -1894,8 +1894,6 @@ discard block |
||
| 1894 | 1894 | * The $password parameter can be a plaintext password, a \phpseclib\Crypt\RSA object or an array |
| 1895 | 1895 | * |
| 1896 | 1896 | * @param string $username |
| 1897 | - * @param mixed $password |
|
| 1898 | - * @param mixed $... |
|
| 1899 | 1897 | * @return bool |
| 1900 | 1898 | * @see self::_login() |
| 1901 | 1899 | * @access public |
@@ -1910,9 +1908,7 @@ discard block |
||
| 1910 | 1908 | * Login Helper |
| 1911 | 1909 | * |
| 1912 | 1910 | * @param string $username |
| 1913 | - * @param mixed $password |
|
| 1914 | - * @param mixed $... |
|
| 1915 | - * @return bool |
|
| 1911 | + * @return boolean|null |
|
| 1916 | 1912 | * @see self::_login_helper() |
| 1917 | 1913 | * @access private |
| 1918 | 1914 | */ |
@@ -1942,7 +1938,7 @@ discard block |
||
| 1942 | 1938 | * |
| 1943 | 1939 | * @param string $username |
| 1944 | 1940 | * @param string $password |
| 1945 | - * @return bool |
|
| 1941 | + * @return boolean|null |
|
| 1946 | 1942 | * @throws \UnexpectedValueException on receipt of unexpected packets |
| 1947 | 1943 | * @throws \RuntimeException on other errors |
| 1948 | 1944 | * @access private |
@@ -2144,7 +2140,6 @@ discard block |
||
| 2144 | 2140 | /** |
| 2145 | 2141 | * Handle the keyboard-interactive requests / responses. |
| 2146 | 2142 | * |
| 2147 | - * @param string $responses... |
|
| 2148 | 2143 | * @return bool |
| 2149 | 2144 | * @throws \RuntimeException on connection error |
| 2150 | 2145 | * @access private |
@@ -2280,7 +2275,6 @@ discard block |
||
| 2280 | 2275 | * Login with an RSA private key |
| 2281 | 2276 | * |
| 2282 | 2277 | * @param string $username |
| 2283 | - * @param \phpseclib\Crypt\RSA $password |
|
| 2284 | 2278 | * @return bool |
| 2285 | 2279 | * @throws \RuntimeException on connection error |
| 2286 | 2280 | * @access private |
@@ -3016,6 +3010,7 @@ discard block |
||
| 3016 | 3010 | * Because some binary packets need to be ignored... |
| 3017 | 3011 | * |
| 3018 | 3012 | * @see self::_get_binary_packet() |
| 3013 | + * @param string $payload |
|
| 3019 | 3014 | * @return string |
| 3020 | 3015 | * @access private |
| 3021 | 3016 | */ |
@@ -3212,7 +3207,7 @@ discard block |
||
| 3212 | 3207 | * |
| 3213 | 3208 | * Returns the data as a string if it's available and false if not. |
| 3214 | 3209 | * |
| 3215 | - * @param $client_channel |
|
| 3210 | + * @param integer $client_channel |
|
| 3216 | 3211 | * @return mixed |
| 3217 | 3212 | * @throws \RuntimeException on connection error |
| 3218 | 3213 | * @access private |
@@ -3490,8 +3485,8 @@ discard block |
||
| 3490 | 3485 | * |
| 3491 | 3486 | * Makes sure that only the last 1MB worth of packets will be logged |
| 3492 | 3487 | * |
| 3493 | - * @param string $data |
|
| 3494 | 3488 | * @access private |
| 3489 | + * @param string $message_number |
|
| 3495 | 3490 | */ |
| 3496 | 3491 | function _append_log($message_number, $message) |
| 3497 | 3492 | { |
@@ -3616,7 +3611,7 @@ discard block |
||
| 3616 | 3611 | * |
| 3617 | 3612 | * @param int $client_channel |
| 3618 | 3613 | * @param bool $want_reply |
| 3619 | - * @return bool |
|
| 3614 | + * @return boolean|null |
|
| 3620 | 3615 | * @access private |
| 3621 | 3616 | */ |
| 3622 | 3617 | function _close_channel($client_channel, $want_reply = false) |
@@ -3649,7 +3644,7 @@ discard block |
||
| 3649 | 3644 | * Disconnect |
| 3650 | 3645 | * |
| 3651 | 3646 | * @param int $reason |
| 3652 | - * @return bool |
|
| 3647 | + * @return false|null |
|
| 3653 | 3648 | * @access private |
| 3654 | 3649 | */ |
| 3655 | 3650 | function _disconnect($reason) |
@@ -3670,7 +3665,6 @@ discard block |
||
| 3670 | 3665 | * named constants from it, using the value as the name of the constant and the index as the value of the constant. |
| 3671 | 3666 | * If any of the constants that would be defined already exists, none of the constants will be defined. |
| 3672 | 3667 | * |
| 3673 | - * @param array $array |
|
| 3674 | 3668 | * @access private |
| 3675 | 3669 | */ |
| 3676 | 3670 | function _define_array() |
@@ -3781,9 +3775,9 @@ discard block |
||
| 3781 | 3775 | * Returns the first value of the intersection of two arrays or false if |
| 3782 | 3776 | * the intersection is empty. The order is defined by the first parameter. |
| 3783 | 3777 | * |
| 3784 | - * @param array $array1 |
|
| 3778 | + * @param string[] $array1 |
|
| 3785 | 3779 | * @param array $array2 |
| 3786 | - * @return mixed False if intersection is empty, else intersected value. |
|
| 3780 | + * @return string False if intersection is empty, else intersected value. |
|
| 3787 | 3781 | * @access private |
| 3788 | 3782 | */ |
| 3789 | 3783 | function _array_intersect_first($array1, $array2) |
@@ -3799,7 +3793,7 @@ discard block |
||
| 3799 | 3793 | /** |
| 3800 | 3794 | * Returns all errors |
| 3801 | 3795 | * |
| 3802 | - * @return string[] |
|
| 3796 | + * @return string |
|
| 3803 | 3797 | * @access public |
| 3804 | 3798 | */ |
| 3805 | 3799 | function getErrors() |
@@ -979,16 +979,16 @@ discard block |
||
| 979 | 979 | array(60 => 'NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ'), |
| 980 | 980 | array(60 => 'NET_SSH2_MSG_USERAUTH_PK_OK'), |
| 981 | 981 | array(60 => 'NET_SSH2_MSG_USERAUTH_INFO_REQUEST', |
| 982 | - 61 => 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE'), |
|
| 982 | + 61 => 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE'), |
|
| 983 | 983 | // RFC 4419 - diffie-hellman-group-exchange-sha{1,256} |
| 984 | 984 | array(30 => 'NET_SSH2_MSG_KEXDH_GEX_REQUEST_OLD', |
| 985 | - 31 => 'NET_SSH2_MSG_KEXDH_GEX_GROUP', |
|
| 986 | - 32 => 'NET_SSH2_MSG_KEXDH_GEX_INIT', |
|
| 987 | - 33 => 'NET_SSH2_MSG_KEXDH_GEX_REPLY', |
|
| 988 | - 34 => 'NET_SSH2_MSG_KEXDH_GEX_REQUEST'), |
|
| 985 | + 31 => 'NET_SSH2_MSG_KEXDH_GEX_GROUP', |
|
| 986 | + 32 => 'NET_SSH2_MSG_KEXDH_GEX_INIT', |
|
| 987 | + 33 => 'NET_SSH2_MSG_KEXDH_GEX_REPLY', |
|
| 988 | + 34 => 'NET_SSH2_MSG_KEXDH_GEX_REQUEST'), |
|
| 989 | 989 | // RFC 5656 - Elliptic Curves (for [email protected]) |
| 990 | 990 | array(30 => 'NET_SSH2_MSG_KEX_ECDH_INIT', |
| 991 | - 31 => 'NET_SSH2_MSG_KEX_ECDH_REPLY') |
|
| 991 | + 31 => 'NET_SSH2_MSG_KEX_ECDH_REPLY') |
|
| 992 | 992 | ); |
| 993 | 993 | |
| 994 | 994 | self::$connections[$this->getResourceId()] = $this; |
@@ -1248,7 +1248,7 @@ discard block |
||
| 1248 | 1248 | 'twofish192-cbc', // OPTIONAL Twofish with a 192-bit key |
| 1249 | 1249 | 'twofish256-cbc', |
| 1250 | 1250 | 'twofish-cbc', // OPTIONAL alias for "twofish256-cbc" |
| 1251 | - // (this is being retained for historical reasons) |
|
| 1251 | + // (this is being retained for historical reasons) |
|
| 1252 | 1252 | |
| 1253 | 1253 | 'blowfish-ctr', // OPTIONAL Blowfish in SDCTR mode |
| 1254 | 1254 | |
@@ -3002,7 +3002,7 @@ discard block |
||
| 3002 | 3002 | $current = microtime(true); |
| 3003 | 3003 | $message_number = isset($this->message_numbers[ord($payload[0])]) ? $this->message_numbers[ord($payload[0])] : 'UNKNOWN (' . ord($payload[0]) . ')'; |
| 3004 | 3004 | $message_number = '<- ' . $message_number . |
| 3005 | - ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
| 3005 | + ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
| 3006 | 3006 | $this->_append_log($message_number, $payload); |
| 3007 | 3007 | $this->last_packet = $current; |
| 3008 | 3008 | } |
@@ -3477,7 +3477,7 @@ discard block |
||
| 3477 | 3477 | $current = microtime(true); |
| 3478 | 3478 | $message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN (' . ord($data[0]) . ')'; |
| 3479 | 3479 | $message_number = '-> ' . $message_number . |
| 3480 | - ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
| 3480 | + ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
| 3481 | 3481 | $this->_append_log($message_number, isset($logged) ? $logged : $data); |
| 3482 | 3482 | $this->last_packet = $current; |
| 3483 | 3483 | } |
@@ -1043,12 +1043,12 @@ discard block |
||
| 1043 | 1043 | $start = microtime(true); |
| 1044 | 1044 | $this->fsock = @fsockopen($this->host, $this->port, $errno, $errstr, $this->curTimeout); |
| 1045 | 1045 | if (!$this->fsock) { |
| 1046 | - $host = $this->host . ':' . $this->port; |
|
| 1046 | + $host = $this->host.':'.$this->port; |
|
| 1047 | 1047 | throw new \RuntimeException(rtrim("Cannot connect to $host. Error $errno. $errstr")); |
| 1048 | 1048 | } |
| 1049 | 1049 | $elapsed = microtime(true) - $start; |
| 1050 | 1050 | |
| 1051 | - $this->curTimeout-= $elapsed; |
|
| 1051 | + $this->curTimeout -= $elapsed; |
|
| 1052 | 1052 | |
| 1053 | 1053 | if ($this->curTimeout <= 0) { |
| 1054 | 1054 | $this->is_timeout = true; |
@@ -1058,7 +1058,7 @@ discard block |
||
| 1058 | 1058 | |
| 1059 | 1059 | $this->identifier = $this->_generate_identifier(); |
| 1060 | 1060 | |
| 1061 | - fputs($this->fsock, $this->identifier . "\r\n"); |
|
| 1061 | + fputs($this->fsock, $this->identifier."\r\n"); |
|
| 1062 | 1062 | |
| 1063 | 1063 | /* According to the SSH2 specs, |
| 1064 | 1064 | |
@@ -1088,7 +1088,7 @@ discard block |
||
| 1088 | 1088 | return false; |
| 1089 | 1089 | } |
| 1090 | 1090 | $elapsed = microtime(true) - $start; |
| 1091 | - $this->curTimeout-= $elapsed; |
|
| 1091 | + $this->curTimeout -= $elapsed; |
|
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | $temp = stream_get_line($this->fsock, 255, "\n"); |
@@ -1096,7 +1096,7 @@ discard block |
||
| 1096 | 1096 | continue; |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - $line.= "$temp\n"; |
|
| 1099 | + $line .= "$temp\n"; |
|
| 1100 | 1100 | |
| 1101 | 1101 | // quoting RFC4253, "Implementers who wish to maintain |
| 1102 | 1102 | // compatibility with older, undocumented versions of this protocol may |
@@ -1111,7 +1111,7 @@ discard block |
||
| 1111 | 1111 | break; |
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | - $data.= $line; |
|
| 1114 | + $data .= $line; |
|
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | 1117 | if (feof($this->fsock)) { |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | |
| 1123 | 1123 | if (defined('NET_SSH2_LOGGING')) { |
| 1124 | 1124 | $this->_append_log('<-', $matches[0]); |
| 1125 | - $this->_append_log('->', $this->identifier . "\r\n"); |
|
| 1125 | + $this->_append_log('->', $this->identifier."\r\n"); |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | $this->server_identifier = trim($temp, "\r\n"); |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | return false; |
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | - $this->bitmap|= self::MASK_CONNECTED; |
|
| 1150 | + $this->bitmap |= self::MASK_CONNECTED; |
|
| 1151 | 1151 | |
| 1152 | 1152 | return true; |
| 1153 | 1153 | } |
@@ -1182,7 +1182,7 @@ discard block |
||
| 1182 | 1182 | } |
| 1183 | 1183 | |
| 1184 | 1184 | if (!empty($ext)) { |
| 1185 | - $identifier .= ' (' . implode(', ', $ext) . ')'; |
|
| 1185 | + $identifier .= ' ('.implode(', ', $ext).')'; |
|
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | 1188 | return $identifier; |
@@ -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 | |
@@ -1303,12 +1303,12 @@ discard block |
||
| 1303 | 1303 | |
| 1304 | 1304 | $mac_algorithms = array( |
| 1305 | 1305 | // from <http://www.ietf.org/rfc/rfc6668.txt>: |
| 1306 | - 'hmac-sha2-256',// RECOMMENDED HMAC-SHA256 (digest length = key length = 32) |
|
| 1306 | + 'hmac-sha2-256', // RECOMMENDED HMAC-SHA256 (digest length = key length = 32) |
|
| 1307 | 1307 | |
| 1308 | 1308 | 'hmac-sha1-96', // RECOMMENDED first 96 bits of HMAC-SHA1 (digest length = 12, key length = 20) |
| 1309 | - 'hmac-sha1', // REQUIRED HMAC-SHA1 (digest length = key length = 20) |
|
| 1310 | - 'hmac-md5-96', // OPTIONAL first 96 bits of HMAC-MD5 (digest length = 12, key length = 16) |
|
| 1311 | - 'hmac-md5', // OPTIONAL HMAC-MD5 (digest length = key length = 16) |
|
| 1309 | + 'hmac-sha1', // REQUIRED HMAC-SHA1 (digest length = key length = 20) |
|
| 1310 | + 'hmac-md5-96', // OPTIONAL first 96 bits of HMAC-MD5 (digest length = 12, key length = 16) |
|
| 1311 | + 'hmac-md5', // OPTIONAL HMAC-MD5 (digest length = key length = 16) |
|
| 1312 | 1312 | //'none' // OPTIONAL no MAC; NOT RECOMMENDED |
| 1313 | 1313 | ); |
| 1314 | 1314 | |
@@ -1491,20 +1491,20 @@ discard block |
||
| 1491 | 1491 | // see http://tools.ietf.org/html/rfc2409#section-6.2 and |
| 1492 | 1492 | // http://tools.ietf.org/html/rfc2412, appendex E |
| 1493 | 1493 | case 'diffie-hellman-group1-sha1': |
| 1494 | - $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' . |
|
| 1495 | - '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . |
|
| 1496 | - '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' . |
|
| 1494 | + $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74'. |
|
| 1495 | + '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437'. |
|
| 1496 | + '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED'. |
|
| 1497 | 1497 | 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'; |
| 1498 | 1498 | break; |
| 1499 | 1499 | // see http://tools.ietf.org/html/rfc3526#section-3 |
| 1500 | 1500 | case 'diffie-hellman-group14-sha1': |
| 1501 | - $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' . |
|
| 1502 | - '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . |
|
| 1503 | - '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' . |
|
| 1504 | - 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05' . |
|
| 1505 | - '98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB' . |
|
| 1506 | - '9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' . |
|
| 1507 | - 'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718' . |
|
| 1501 | + $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74'. |
|
| 1502 | + '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437'. |
|
| 1503 | + '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED'. |
|
| 1504 | + 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05'. |
|
| 1505 | + '98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB'. |
|
| 1506 | + '9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B'. |
|
| 1507 | + 'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718'. |
|
| 1508 | 1508 | '3995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF'; |
| 1509 | 1509 | break; |
| 1510 | 1510 | } |
@@ -1658,16 +1658,16 @@ discard block |
||
| 1658 | 1658 | $this->encrypt->disablePadding(); |
| 1659 | 1659 | |
| 1660 | 1660 | if ($this->encrypt->usesIV()) { |
| 1661 | - $iv = $kexHash->hash($keyBytes . $this->exchange_hash . 'A' . $this->session_id); |
|
| 1661 | + $iv = $kexHash->hash($keyBytes.$this->exchange_hash.'A'.$this->session_id); |
|
| 1662 | 1662 | while ($this->encrypt_block_size > strlen($iv)) { |
| 1663 | - $iv.= $kexHash->hash($keyBytes . $this->exchange_hash . $iv); |
|
| 1663 | + $iv .= $kexHash->hash($keyBytes.$this->exchange_hash.$iv); |
|
| 1664 | 1664 | } |
| 1665 | 1665 | $this->encrypt->setIV(substr($iv, 0, $this->encrypt_block_size)); |
| 1666 | 1666 | } |
| 1667 | 1667 | |
| 1668 | - $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'C' . $this->session_id); |
|
| 1668 | + $key = $kexHash->hash($keyBytes.$this->exchange_hash.'C'.$this->session_id); |
|
| 1669 | 1669 | while ($encryptKeyLength > strlen($key)) { |
| 1670 | - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); |
|
| 1670 | + $key .= $kexHash->hash($keyBytes.$this->exchange_hash.$key); |
|
| 1671 | 1671 | } |
| 1672 | 1672 | $this->encrypt->setKey(substr($key, 0, $encryptKeyLength)); |
| 1673 | 1673 | } |
@@ -1684,16 +1684,16 @@ discard block |
||
| 1684 | 1684 | $this->decrypt->disablePadding(); |
| 1685 | 1685 | |
| 1686 | 1686 | if ($this->decrypt->usesIV()) { |
| 1687 | - $iv = $kexHash->hash($keyBytes . $this->exchange_hash . 'B' . $this->session_id); |
|
| 1687 | + $iv = $kexHash->hash($keyBytes.$this->exchange_hash.'B'.$this->session_id); |
|
| 1688 | 1688 | while ($this->decrypt_block_size > strlen($iv)) { |
| 1689 | - $iv.= $kexHash->hash($keyBytes . $this->exchange_hash . $iv); |
|
| 1689 | + $iv .= $kexHash->hash($keyBytes.$this->exchange_hash.$iv); |
|
| 1690 | 1690 | } |
| 1691 | 1691 | $this->decrypt->setIV(substr($iv, 0, $this->decrypt_block_size)); |
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | - $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'D' . $this->session_id); |
|
| 1694 | + $key = $kexHash->hash($keyBytes.$this->exchange_hash.'D'.$this->session_id); |
|
| 1695 | 1695 | while ($decryptKeyLength > strlen($key)) { |
| 1696 | - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); |
|
| 1696 | + $key .= $kexHash->hash($keyBytes.$this->exchange_hash.$key); |
|
| 1697 | 1697 | } |
| 1698 | 1698 | $this->decrypt->setKey(substr($key, 0, $decryptKeyLength)); |
| 1699 | 1699 | } |
@@ -1776,15 +1776,15 @@ discard block |
||
| 1776 | 1776 | $this->hmac_size = 12; |
| 1777 | 1777 | } |
| 1778 | 1778 | |
| 1779 | - $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'E' . $this->session_id); |
|
| 1779 | + $key = $kexHash->hash($keyBytes.$this->exchange_hash.'E'.$this->session_id); |
|
| 1780 | 1780 | while ($createKeyLength > strlen($key)) { |
| 1781 | - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); |
|
| 1781 | + $key .= $kexHash->hash($keyBytes.$this->exchange_hash.$key); |
|
| 1782 | 1782 | } |
| 1783 | 1783 | $this->hmac_create->setKey(substr($key, 0, $createKeyLength)); |
| 1784 | 1784 | |
| 1785 | - $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'F' . $this->session_id); |
|
| 1785 | + $key = $kexHash->hash($keyBytes.$this->exchange_hash.'F'.$this->session_id); |
|
| 1786 | 1786 | while ($checkKeyLength > strlen($key)) { |
| 1787 | - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); |
|
| 1787 | + $key .= $kexHash->hash($keyBytes.$this->exchange_hash.$key); |
|
| 1788 | 1788 | } |
| 1789 | 1789 | $this->hmac_check->setKey(substr($key, 0, $checkKeyLength)); |
| 1790 | 1790 | |
@@ -2081,7 +2081,7 @@ discard block |
||
| 2081 | 2081 | $this->message_number_log[count($this->message_number_log) - 1] = 'NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ'; |
| 2082 | 2082 | } |
| 2083 | 2083 | extract(unpack('Nlength', Strings::shift($response, 4))); |
| 2084 | - $this->errors[] = 'SSH_MSG_USERAUTH_PASSWD_CHANGEREQ: ' . utf8_decode(Strings::shift($response, $length)); |
|
| 2084 | + $this->errors[] = 'SSH_MSG_USERAUTH_PASSWD_CHANGEREQ: '.utf8_decode(Strings::shift($response, $length)); |
|
| 2085 | 2085 | return $this->_disconnect(NET_SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER); |
| 2086 | 2086 | case NET_SSH2_MSG_USERAUTH_FAILURE: |
| 2087 | 2087 | // can we use keyboard-interactive authentication? if not then either the login is bad or the server employees |
@@ -2222,8 +2222,8 @@ discard block |
||
| 2222 | 2222 | // see http://tools.ietf.org/html/rfc4256#section-3.4 |
| 2223 | 2223 | $packet = $logged = pack('CN', NET_SSH2_MSG_USERAUTH_INFO_RESPONSE, count($responses)); |
| 2224 | 2224 | for ($i = 0; $i < count($responses); $i++) { |
| 2225 | - $packet.= pack('Na*', strlen($responses[$i]), $responses[$i]); |
|
| 2226 | - $logged.= pack('Na*', strlen('dummy-answer'), 'dummy-answer'); |
|
| 2225 | + $packet .= pack('Na*', strlen($responses[$i]), $responses[$i]); |
|
| 2226 | + $logged .= pack('Na*', strlen('dummy-answer'), 'dummy-answer'); |
|
| 2227 | 2227 | } |
| 2228 | 2228 | |
| 2229 | 2229 | if (!$this->_send_binary_packet($packet, $logged)) { |
@@ -2321,7 +2321,7 @@ discard block |
||
| 2321 | 2321 | ); |
| 2322 | 2322 | $part2 = pack('Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publickey), $publickey); |
| 2323 | 2323 | |
| 2324 | - $packet = $part1 . chr(0) . $part2; |
|
| 2324 | + $packet = $part1.chr(0).$part2; |
|
| 2325 | 2325 | if (!$this->_send_binary_packet($packet)) { |
| 2326 | 2326 | return false; |
| 2327 | 2327 | } |
@@ -2336,7 +2336,7 @@ discard block |
||
| 2336 | 2336 | switch ($type) { |
| 2337 | 2337 | case NET_SSH2_MSG_USERAUTH_FAILURE: |
| 2338 | 2338 | extract(unpack('Nlength', Strings::shift($response, 4))); |
| 2339 | - $this->errors[] = 'SSH_MSG_USERAUTH_FAILURE: ' . Strings::shift($response, $length); |
|
| 2339 | + $this->errors[] = 'SSH_MSG_USERAUTH_FAILURE: '.Strings::shift($response, $length); |
|
| 2340 | 2340 | return false; |
| 2341 | 2341 | case NET_SSH2_MSG_USERAUTH_PK_OK: |
| 2342 | 2342 | // we'll just take it on faith that the public key blob and the public key algorithm name are as |
@@ -2350,11 +2350,11 @@ discard block |
||
| 2350 | 2350 | } |
| 2351 | 2351 | } |
| 2352 | 2352 | |
| 2353 | - $packet = $part1 . chr(1) . $part2; |
|
| 2353 | + $packet = $part1.chr(1).$part2; |
|
| 2354 | 2354 | $privatekey->setHash('sha1'); |
| 2355 | 2355 | $signature = $privatekey->sign(pack('Na*a*', strlen($this->session_id), $this->session_id, $packet), RSA::PADDING_PKCS1); |
| 2356 | 2356 | $signature = pack('Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($signature), $signature); |
| 2357 | - $packet.= pack('Na*', strlen($signature), $signature); |
|
| 2357 | + $packet .= pack('Na*', strlen($signature), $signature); |
|
| 2358 | 2358 | |
| 2359 | 2359 | if (!$this->_send_binary_packet($packet)) { |
| 2360 | 2360 | return false; |
@@ -2547,7 +2547,7 @@ discard block |
||
| 2547 | 2547 | return true; |
| 2548 | 2548 | } |
| 2549 | 2549 | } else { |
| 2550 | - $output.= $temp; |
|
| 2550 | + $output .= $temp; |
|
| 2551 | 2551 | } |
| 2552 | 2552 | } |
| 2553 | 2553 | } |
@@ -2740,7 +2740,7 @@ discard block |
||
| 2740 | 2740 | return $response ? Strings::shift($this->interactiveBuffer, strlen($this->interactiveBuffer)) : false; |
| 2741 | 2741 | } |
| 2742 | 2742 | |
| 2743 | - $this->interactiveBuffer.= $response; |
|
| 2743 | + $this->interactiveBuffer .= $response; |
|
| 2744 | 2744 | } |
| 2745 | 2745 | } |
| 2746 | 2746 | |
@@ -2971,12 +2971,12 @@ discard block |
||
| 2971 | 2971 | $this->bitmap = 0; |
| 2972 | 2972 | throw new \RuntimeException('Error reading from socket'); |
| 2973 | 2973 | } |
| 2974 | - $buffer.= $temp; |
|
| 2975 | - $remaining_length-= strlen($temp); |
|
| 2974 | + $buffer .= $temp; |
|
| 2975 | + $remaining_length -= strlen($temp); |
|
| 2976 | 2976 | } |
| 2977 | 2977 | $stop = microtime(true); |
| 2978 | 2978 | if (strlen($buffer)) { |
| 2979 | - $raw.= $this->decrypt !== false ? $this->decrypt->decrypt($buffer) : $buffer; |
|
| 2979 | + $raw .= $this->decrypt !== false ? $this->decrypt->decrypt($buffer) : $buffer; |
|
| 2980 | 2980 | } |
| 2981 | 2981 | |
| 2982 | 2982 | $payload = Strings::shift($raw, $packet_length - $padding_length - 1); |
@@ -2987,7 +2987,7 @@ discard block |
||
| 2987 | 2987 | if ($hmac === false || strlen($hmac) != $this->hmac_size) { |
| 2988 | 2988 | $this->bitmap = 0; |
| 2989 | 2989 | throw new \RuntimeException('Error reading socket'); |
| 2990 | - } elseif ($hmac != $this->hmac_check->hash(pack('NNCa*', $this->get_seq_no, $packet_length, $padding_length, $payload . $padding))) { |
|
| 2990 | + } elseif ($hmac != $this->hmac_check->hash(pack('NNCa*', $this->get_seq_no, $packet_length, $padding_length, $payload.$padding))) { |
|
| 2991 | 2991 | throw new \RuntimeException('Invalid HMAC'); |
| 2992 | 2992 | } |
| 2993 | 2993 | } |
@@ -3000,9 +3000,9 @@ discard block |
||
| 3000 | 3000 | |
| 3001 | 3001 | if (defined('NET_SSH2_LOGGING')) { |
| 3002 | 3002 | $current = microtime(true); |
| 3003 | - $message_number = isset($this->message_numbers[ord($payload[0])]) ? $this->message_numbers[ord($payload[0])] : 'UNKNOWN (' . ord($payload[0]) . ')'; |
|
| 3004 | - $message_number = '<- ' . $message_number . |
|
| 3005 | - ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
| 3003 | + $message_number = isset($this->message_numbers[ord($payload[0])]) ? $this->message_numbers[ord($payload[0])] : 'UNKNOWN ('.ord($payload[0]).')'; |
|
| 3004 | + $message_number = '<- '.$message_number. |
|
| 3005 | + ' (since last: '.round($current - $this->last_packet, 4).', network: '.round($stop - $start, 4).'s)'; |
|
| 3006 | 3006 | $this->_append_log($message_number, $payload); |
| 3007 | 3007 | $this->last_packet = $current; |
| 3008 | 3008 | } |
@@ -3025,7 +3025,7 @@ discard block |
||
| 3025 | 3025 | case NET_SSH2_MSG_DISCONNECT: |
| 3026 | 3026 | Strings::shift($payload, 1); |
| 3027 | 3027 | extract(unpack('Nreason_code/Nlength', Strings::shift($payload, 8))); |
| 3028 | - $this->errors[] = 'SSH_MSG_DISCONNECT: ' . $this->disconnect_reasons[$reason_code] . "\r\n" . utf8_decode(Strings::shift($payload, $length)); |
|
| 3028 | + $this->errors[] = 'SSH_MSG_DISCONNECT: '.$this->disconnect_reasons[$reason_code]."\r\n".utf8_decode(Strings::shift($payload, $length)); |
|
| 3029 | 3029 | $this->bitmap = 0; |
| 3030 | 3030 | return false; |
| 3031 | 3031 | case NET_SSH2_MSG_IGNORE: |
@@ -3034,7 +3034,7 @@ discard block |
||
| 3034 | 3034 | case NET_SSH2_MSG_DEBUG: |
| 3035 | 3035 | Strings::shift($payload, 2); |
| 3036 | 3036 | extract(unpack('Nlength', Strings::shift($payload, 4))); |
| 3037 | - $this->errors[] = 'SSH_MSG_DEBUG: ' . utf8_decode(Strings::shift($payload, $length)); |
|
| 3037 | + $this->errors[] = 'SSH_MSG_DEBUG: '.utf8_decode(Strings::shift($payload, $length)); |
|
| 3038 | 3038 | $payload = $this->_get_binary_packet(); |
| 3039 | 3039 | break; |
| 3040 | 3040 | case NET_SSH2_MSG_UNIMPLEMENTED: |
@@ -3062,7 +3062,7 @@ discard block |
||
| 3062 | 3062 | switch (ord($payload[0])) { |
| 3063 | 3063 | case NET_SSH2_MSG_GLOBAL_REQUEST: // see http://tools.ietf.org/html/rfc4254#section-4 |
| 3064 | 3064 | extract(unpack('Nlength', Strings::shift($payload, 4))); |
| 3065 | - $this->errors[] = 'SSH_MSG_GLOBAL_REQUEST: ' . Strings::shift($payload, $length); |
|
| 3065 | + $this->errors[] = 'SSH_MSG_GLOBAL_REQUEST: '.Strings::shift($payload, $length); |
|
| 3066 | 3066 | |
| 3067 | 3067 | if (!$this->_send_binary_packet(pack('C', NET_SSH2_MSG_REQUEST_FAILURE))) { |
| 3068 | 3068 | return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); |
@@ -3128,7 +3128,7 @@ discard block |
||
| 3128 | 3128 | Strings::shift($payload, 1); |
| 3129 | 3129 | extract(unpack('Nchannel', Strings::shift($payload, 4))); |
| 3130 | 3130 | extract(unpack('Nwindow_size', Strings::shift($payload, 4))); |
| 3131 | - $this->window_size_client_to_server[$channel]+= $window_size; |
|
| 3131 | + $this->window_size_client_to_server[$channel] += $window_size; |
|
| 3132 | 3132 | |
| 3133 | 3133 | $payload = ($this->bitmap & self::MASK_WINDOW_ADJUST) ? true : $this->_get_binary_packet(); |
| 3134 | 3134 | } |
@@ -3242,7 +3242,7 @@ discard block |
||
| 3242 | 3242 | return true; |
| 3243 | 3243 | } |
| 3244 | 3244 | $elapsed = microtime(true) - $start; |
| 3245 | - $this->curTimeout-= $elapsed; |
|
| 3245 | + $this->curTimeout -= $elapsed; |
|
| 3246 | 3246 | } |
| 3247 | 3247 | |
| 3248 | 3248 | $response = $this->_get_binary_packet(); |
@@ -3266,7 +3266,7 @@ discard block |
||
| 3266 | 3266 | |
| 3267 | 3267 | // will not be setup yet on incoming channel open request |
| 3268 | 3268 | if (isset($channel) && isset($this->channel_status[$channel]) && isset($this->window_size_server_to_client[$channel])) { |
| 3269 | - $this->window_size_server_to_client[$channel]-= strlen($response); |
|
| 3269 | + $this->window_size_server_to_client[$channel] -= strlen($response); |
|
| 3270 | 3270 | |
| 3271 | 3271 | // resize the window, if appropriate |
| 3272 | 3272 | if ($this->window_size_server_to_client[$channel] < 0) { |
@@ -3274,7 +3274,7 @@ discard block |
||
| 3274 | 3274 | if (!$this->_send_binary_packet($packet)) { |
| 3275 | 3275 | return false; |
| 3276 | 3276 | } |
| 3277 | - $this->window_size_server_to_client[$channel]+= $this->window_size; |
|
| 3277 | + $this->window_size_server_to_client[$channel] += $this->window_size; |
|
| 3278 | 3278 | } |
| 3279 | 3279 | |
| 3280 | 3280 | switch ($this->channel_status[$channel]) { |
@@ -3285,8 +3285,8 @@ discard block |
||
| 3285 | 3285 | $this->server_channels[$channel] = $server_channel; |
| 3286 | 3286 | extract(unpack('Nwindow_size', Strings::shift($response, 4))); |
| 3287 | 3287 | if ($window_size < 0) { |
| 3288 | - $window_size&= 0x7FFFFFFF; |
|
| 3289 | - $window_size+= 0x80000000; |
|
| 3288 | + $window_size &= 0x7FFFFFFF; |
|
| 3289 | + $window_size += 0x80000000; |
|
| 3290 | 3290 | } |
| 3291 | 3291 | $this->window_size_client_to_server[$channel] = $window_size; |
| 3292 | 3292 | $temp = unpack('Npacket_size_client_to_server', Strings::shift($response, 4)); |
@@ -3356,7 +3356,7 @@ discard block |
||
| 3356 | 3356 | // currently, there's only one possible value for $data_type_code: NET_SSH2_EXTENDED_DATA_STDERR |
| 3357 | 3357 | extract(unpack('Ndata_type_code/Nlength', Strings::shift($response, 8))); |
| 3358 | 3358 | $data = Strings::shift($response, $length); |
| 3359 | - $this->stdErrorLog.= $data; |
|
| 3359 | + $this->stdErrorLog .= $data; |
|
| 3360 | 3360 | if ($skip_extended || $this->quiet_mode) { |
| 3361 | 3361 | break; |
| 3362 | 3362 | } |
@@ -3375,11 +3375,11 @@ discard block |
||
| 3375 | 3375 | case 'exit-signal': |
| 3376 | 3376 | Strings::shift($response, 1); |
| 3377 | 3377 | extract(unpack('Nlength', Strings::shift($response, 4))); |
| 3378 | - $this->errors[] = 'SSH_MSG_CHANNEL_REQUEST (exit-signal): ' . Strings::shift($response, $length); |
|
| 3378 | + $this->errors[] = 'SSH_MSG_CHANNEL_REQUEST (exit-signal): '.Strings::shift($response, $length); |
|
| 3379 | 3379 | Strings::shift($response, 1); |
| 3380 | 3380 | extract(unpack('Nlength', Strings::shift($response, 4))); |
| 3381 | 3381 | if ($length) { |
| 3382 | - $this->errors[count($this->errors)].= "\r\n" . Strings::shift($response, $length); |
|
| 3382 | + $this->errors[count($this->errors)] .= "\r\n".Strings::shift($response, $length); |
|
| 3383 | 3383 | } |
| 3384 | 3384 | |
| 3385 | 3385 | $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel])); |
@@ -3406,7 +3406,7 @@ discard block |
||
| 3406 | 3406 | $this->curTimeout = 0; |
| 3407 | 3407 | |
| 3408 | 3408 | if ($this->bitmap & self::MASK_SHELL) { |
| 3409 | - $this->bitmap&= ~self::MASK_SHELL; |
|
| 3409 | + $this->bitmap &= ~self::MASK_SHELL; |
|
| 3410 | 3410 | } |
| 3411 | 3411 | if ($this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_EOF) { |
| 3412 | 3412 | $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel])); |
@@ -3452,13 +3452,13 @@ discard block |
||
| 3452 | 3452 | // 4 (packet length) + 1 (padding length) + 4 (minimal padding amount) == 9 |
| 3453 | 3453 | $packet_length = strlen($data) + 9; |
| 3454 | 3454 | // round up to the nearest $this->encrypt_block_size |
| 3455 | - $packet_length+= (($this->encrypt_block_size - 1) * $packet_length) % $this->encrypt_block_size; |
|
| 3455 | + $packet_length += (($this->encrypt_block_size - 1) * $packet_length) % $this->encrypt_block_size; |
|
| 3456 | 3456 | // subtracting strlen($data) is obvious - subtracting 5 is necessary because of packet_length and padding_length |
| 3457 | 3457 | $padding_length = $packet_length - strlen($data) - 5; |
| 3458 | 3458 | $padding = Random::string($padding_length); |
| 3459 | 3459 | |
| 3460 | 3460 | // we subtract 4 from packet_length because the packet_length field isn't supposed to include itself |
| 3461 | - $packet = pack('NCa*', $packet_length - 4, $padding_length, $data . $padding); |
|
| 3461 | + $packet = pack('NCa*', $packet_length - 4, $padding_length, $data.$padding); |
|
| 3462 | 3462 | |
| 3463 | 3463 | $hmac = $this->hmac_create !== false ? $this->hmac_create->hash(pack('Na*', $this->send_seq_no, $packet)) : ''; |
| 3464 | 3464 | $this->send_seq_no++; |
@@ -3467,7 +3467,7 @@ discard block |
||
| 3467 | 3467 | $packet = $this->encrypt->encrypt($packet); |
| 3468 | 3468 | } |
| 3469 | 3469 | |
| 3470 | - $packet.= $hmac; |
|
| 3470 | + $packet .= $hmac; |
|
| 3471 | 3471 | |
| 3472 | 3472 | $start = microtime(true); |
| 3473 | 3473 | $result = strlen($packet) == fputs($this->fsock, $packet); |
@@ -3475,9 +3475,9 @@ discard block |
||
| 3475 | 3475 | |
| 3476 | 3476 | if (defined('NET_SSH2_LOGGING')) { |
| 3477 | 3477 | $current = microtime(true); |
| 3478 | - $message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN (' . ord($data[0]) . ')'; |
|
| 3479 | - $message_number = '-> ' . $message_number . |
|
| 3480 | - ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
| 3478 | + $message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN ('.ord($data[0]).')'; |
|
| 3479 | + $message_number = '-> '.$message_number. |
|
| 3480 | + ' (since last: '.round($current - $this->last_packet, 4).', network: '.round($stop - $start, 4).'s)'; |
|
| 3481 | 3481 | $this->_append_log($message_number, isset($logged) ? $logged : $data); |
| 3482 | 3482 | $this->last_packet = $current; |
| 3483 | 3483 | } |
@@ -3508,10 +3508,10 @@ discard block |
||
| 3508 | 3508 | // the most useful log for SSH2 |
| 3509 | 3509 | case self::LOG_COMPLEX: |
| 3510 | 3510 | $this->message_number_log[] = $message_number; |
| 3511 | - $this->log_size+= strlen($message); |
|
| 3511 | + $this->log_size += strlen($message); |
|
| 3512 | 3512 | $this->message_log[] = $message; |
| 3513 | 3513 | while ($this->log_size > self::LOG_MAX_SIZE) { |
| 3514 | - $this->log_size-= strlen(array_shift($this->message_log)); |
|
| 3514 | + $this->log_size -= strlen(array_shift($this->message_log)); |
|
| 3515 | 3515 | array_shift($this->message_number_log); |
| 3516 | 3516 | } |
| 3517 | 3517 | break; |
@@ -3527,7 +3527,7 @@ discard block |
||
| 3527 | 3527 | $start = '<pre>'; |
| 3528 | 3528 | $stop = '</pre>'; |
| 3529 | 3529 | } |
| 3530 | - echo $start . $this->_format_log(array($message), array($message_number)) . $stop; |
|
| 3530 | + echo $start.$this->_format_log(array($message), array($message_number)).$stop; |
|
| 3531 | 3531 | @flush(); |
| 3532 | 3532 | @ob_flush(); |
| 3533 | 3533 | break; |
@@ -3548,10 +3548,10 @@ discard block |
||
| 3548 | 3548 | $entry = $this->_format_log(array($message), array($message_number)); |
| 3549 | 3549 | if ($this->realtime_log_wrap) { |
| 3550 | 3550 | $temp = "<<< START >>>\r\n"; |
| 3551 | - $entry.= $temp; |
|
| 3551 | + $entry .= $temp; |
|
| 3552 | 3552 | fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp)); |
| 3553 | 3553 | } |
| 3554 | - $this->realtime_log_size+= strlen($entry); |
|
| 3554 | + $this->realtime_log_size += strlen($entry); |
|
| 3555 | 3555 | if ($this->realtime_log_size > self::LOG_MAX_SIZE) { |
| 3556 | 3556 | fseek($this->realtime_log_file, 0); |
| 3557 | 3557 | $this->realtime_log_size = strlen($entry); |
@@ -3575,10 +3575,10 @@ discard block |
||
| 3575 | 3575 | { |
| 3576 | 3576 | while (strlen($data)) { |
| 3577 | 3577 | if (!$this->window_size_client_to_server[$client_channel]) { |
| 3578 | - $this->bitmap^= self::MASK_WINDOW_ADJUST; |
|
| 3578 | + $this->bitmap ^= self::MASK_WINDOW_ADJUST; |
|
| 3579 | 3579 | // using an invalid channel will let the buffers be built up for the valid channels |
| 3580 | 3580 | $this->_get_channel_packet(-1); |
| 3581 | - $this->bitmap^= self::MASK_WINDOW_ADJUST; |
|
| 3581 | + $this->bitmap ^= self::MASK_WINDOW_ADJUST; |
|
| 3582 | 3582 | } |
| 3583 | 3583 | |
| 3584 | 3584 | /* The maximum amount of data allowed is determined by the maximum |
@@ -3598,7 +3598,7 @@ discard block |
||
| 3598 | 3598 | strlen($temp), |
| 3599 | 3599 | $temp |
| 3600 | 3600 | ); |
| 3601 | - $this->window_size_client_to_server[$client_channel]-= strlen($temp); |
|
| 3601 | + $this->window_size_client_to_server[$client_channel] -= strlen($temp); |
|
| 3602 | 3602 | if (!$this->_send_binary_packet($packet)) { |
| 3603 | 3603 | return false; |
| 3604 | 3604 | } |
@@ -3641,7 +3641,7 @@ discard block |
||
| 3641 | 3641 | } |
| 3642 | 3642 | |
| 3643 | 3643 | if ($this->bitmap & self::MASK_SHELL) { |
| 3644 | - $this->bitmap&= ~self::MASK_SHELL; |
|
| 3644 | + $this->bitmap &= ~self::MASK_SHELL; |
|
| 3645 | 3645 | } |
| 3646 | 3646 | } |
| 3647 | 3647 | |
@@ -3725,12 +3725,12 @@ discard block |
||
| 3725 | 3725 | { |
| 3726 | 3726 | $output = ''; |
| 3727 | 3727 | for ($i = 0; $i < count($message_log); $i++) { |
| 3728 | - $output.= $message_number_log[$i] . "\r\n"; |
|
| 3728 | + $output .= $message_number_log[$i]."\r\n"; |
|
| 3729 | 3729 | $current_log = $message_log[$i]; |
| 3730 | 3730 | $j = 0; |
| 3731 | 3731 | do { |
| 3732 | 3732 | if (strlen($current_log)) { |
| 3733 | - $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; |
|
| 3733 | + $output .= str_pad(dechex($j), 7, '0', STR_PAD_LEFT).'0 '; |
|
| 3734 | 3734 | } |
| 3735 | 3735 | $fragment = Strings::shift($current_log, $this->log_short_width); |
| 3736 | 3736 | $hex = substr(preg_replace_callback('#.#s', array($this, '_format_log_helper'), $fragment), strlen($this->log_boundary)); |
@@ -3738,10 +3738,10 @@ discard block |
||
| 3738 | 3738 | // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters |
| 3739 | 3739 | // also replace < with a . since < messes up the output on web browsers |
| 3740 | 3740 | $raw = preg_replace('#[^\x20-\x7E]|<#', '.', $fragment); |
| 3741 | - $output.= str_pad($hex, $this->log_long_width - $this->log_short_width, ' ') . $raw . "\r\n"; |
|
| 3741 | + $output .= str_pad($hex, $this->log_long_width - $this->log_short_width, ' ').$raw."\r\n"; |
|
| 3742 | 3742 | $j++; |
| 3743 | 3743 | } while (strlen($current_log)); |
| 3744 | - $output.= "\r\n"; |
|
| 3744 | + $output .= "\r\n"; |
|
| 3745 | 3745 | } |
| 3746 | 3746 | |
| 3747 | 3747 | return $output; |
@@ -3758,7 +3758,7 @@ discard block |
||
| 3758 | 3758 | */ |
| 3759 | 3759 | function _format_log_helper($matches) |
| 3760 | 3760 | { |
| 3761 | - return $this->log_boundary . str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT); |
|
| 3761 | + return $this->log_boundary.str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT); |
|
| 3762 | 3762 | } |
| 3763 | 3763 | |
| 3764 | 3764 | /** |
@@ -4006,8 +4006,7 @@ discard block |
||
| 4006 | 4006 | |
| 4007 | 4007 | if ($this->signature_validated) { |
| 4008 | 4008 | return $this->bitmap ? |
| 4009 | - $this->signature_format . ' ' . Base64::encode($this->server_public_host_key) : |
|
| 4010 | - false; |
|
| 4009 | + $this->signature_format.' '.Base64::encode($this->server_public_host_key) : false; |
|
| 4011 | 4010 | } |
| 4012 | 4011 | |
| 4013 | 4012 | $this->signature_validated = true; |
@@ -4110,7 +4109,7 @@ discard block |
||
| 4110 | 4109 | $s = $s->toBytes(); |
| 4111 | 4110 | |
| 4112 | 4111 | $h = pack('N4H*', 0x00302130, 0x0906052B, 0x0E03021A, 0x05000414, sha1($this->exchange_hash)); |
| 4113 | - $h = chr(0x01) . str_repeat(chr(0xFF), $nLength - 2 - strlen($h)) . $h; |
|
| 4112 | + $h = chr(0x01).str_repeat(chr(0xFF), $nLength - 2 - strlen($h)).$h; |
|
| 4114 | 4113 | |
| 4115 | 4114 | if ($s != $h) { |
| 4116 | 4115 | //user_error('Bad server signature'); |
@@ -4122,7 +4121,7 @@ discard block |
||
| 4122 | 4121 | throw new NoSupportedAlgorithmsException('Unsupported signature format'); |
| 4123 | 4122 | } |
| 4124 | 4123 | |
| 4125 | - return $this->signature_format . ' ' . Base64::encode($this->server_public_host_key); |
|
| 4124 | + return $this->signature_format.' '.Base64::encode($this->server_public_host_key); |
|
| 4126 | 4125 | } |
| 4127 | 4126 | |
| 4128 | 4127 | /** |
@@ -4214,7 +4213,7 @@ discard block |
||
| 4214 | 4213 | */ |
| 4215 | 4214 | function getResourceId() |
| 4216 | 4215 | { |
| 4217 | - return '{' . spl_object_hash($this) . '}'; |
|
| 4216 | + return '{'.spl_object_hash($this).'}'; |
|
| 4218 | 4217 | } |
| 4219 | 4218 | |
| 4220 | 4219 | /** |