@@ -677,7 +677,6 @@ discard block |
||
677 | 677 | * |
678 | 678 | * @access private |
679 | 679 | * @see setPrivateKeyFormat() |
680 | - * @param String $RSAPrivateKey |
|
681 | 680 | * @return String |
682 | 681 | */ |
683 | 682 | function _convertPrivateKey($n, $e, $d, $primes, $exponents, $coefficients) |
@@ -830,7 +829,6 @@ discard block |
||
830 | 829 | * |
831 | 830 | * @access private |
832 | 831 | * @see setPublicKeyFormat() |
833 | - * @param String $RSAPrivateKey |
|
834 | 832 | * @return String |
835 | 833 | */ |
836 | 834 | function _convertPublicKey($n, $e) |
@@ -1491,7 +1489,6 @@ discard block |
||
1491 | 1489 | * |
1492 | 1490 | * @see getPublicKey() |
1493 | 1491 | * @access public |
1494 | - * @param String $key |
|
1495 | 1492 | * @param Integer $type optional |
1496 | 1493 | */ |
1497 | 1494 | function getPublicKey($type = CRYPT_RSA_PUBLIC_FORMAT_PKCS1) |
@@ -1514,7 +1511,6 @@ discard block |
||
1514 | 1511 | * |
1515 | 1512 | * @see getPublicKey() |
1516 | 1513 | * @access public |
1517 | - * @param String $key |
|
1518 | 1514 | * @param Integer $type optional |
1519 | 1515 | */ |
1520 | 1516 | function getPrivateKey($type = CRYPT_RSA_PUBLIC_FORMAT_PKCS1) |
@@ -1538,8 +1534,7 @@ discard block |
||
1538 | 1534 | * |
1539 | 1535 | * @see getPrivateKey() |
1540 | 1536 | * @access private |
1541 | - * @param String $key |
|
1542 | - * @param Integer $type optional |
|
1537 | + * @param integer $mode |
|
1543 | 1538 | */ |
1544 | 1539 | function _getPrivatePublicKey($mode = CRYPT_RSA_PUBLIC_FORMAT_PKCS1) |
1545 | 1540 | { |
@@ -1742,7 +1737,6 @@ discard block |
||
1742 | 1737 | * of the hash function Hash) and 0. |
1743 | 1738 | * |
1744 | 1739 | * @access public |
1745 | - * @param Integer $format |
|
1746 | 1740 | */ |
1747 | 1741 | function setSaltLength($sLen) |
1748 | 1742 | { |
@@ -1991,7 +1985,6 @@ discard block |
||
1991 | 1985 | * |
1992 | 1986 | * @access private |
1993 | 1987 | * @param String $mgfSeed |
1994 | - * @param Integer $mgfLen |
|
1995 | 1988 | * @return String |
1996 | 1989 | */ |
1997 | 1990 | function _mgf1($mgfSeed, $maskLen) |
@@ -2284,7 +2277,7 @@ discard block |
||
2284 | 2277 | * @param String $m |
2285 | 2278 | * @param String $em |
2286 | 2279 | * @param Integer $emBits |
2287 | - * @return String |
|
2280 | + * @return boolean |
|
2288 | 2281 | */ |
2289 | 2282 | function _emsa_pss_verify($m, $em, $emBits) |
2290 | 2283 | { |
@@ -2356,7 +2349,7 @@ discard block |
||
2356 | 2349 | * @access private |
2357 | 2350 | * @param String $m |
2358 | 2351 | * @param String $s |
2359 | - * @return String |
|
2352 | + * @return boolean |
|
2360 | 2353 | */ |
2361 | 2354 | function _rsassa_pss_verify($m, $s) |
2362 | 2355 | { |
@@ -2477,7 +2470,8 @@ discard block |
||
2477 | 2470 | * |
2478 | 2471 | * @access private |
2479 | 2472 | * @param String $m |
2480 | - * @return String |
|
2473 | + * @param string $s |
|
2474 | + * @return boolean |
|
2481 | 2475 | */ |
2482 | 2476 | function _rsassa_pkcs1_v1_5_verify($m, $s) |
2483 | 2477 | { |
@@ -2610,7 +2604,6 @@ discard block |
||
2610 | 2604 | * |
2611 | 2605 | * @see encrypt() |
2612 | 2606 | * @access public |
2613 | - * @param String $plaintext |
|
2614 | 2607 | * @return String |
2615 | 2608 | */ |
2616 | 2609 | function decrypt($ciphertext) |
@@ -703,15 +703,15 @@ discard block |
||
703 | 703 | return false; |
704 | 704 | } |
705 | 705 | return "<RSAKeyValue>\r\n" . |
706 | - ' <Modulus>' . base64_encode($raw['modulus']) . "</Modulus>\r\n" . |
|
707 | - ' <Exponent>' . base64_encode($raw['publicExponent']) . "</Exponent>\r\n" . |
|
708 | - ' <P>' . base64_encode($raw['prime1']) . "</P>\r\n" . |
|
709 | - ' <Q>' . base64_encode($raw['prime2']) . "</Q>\r\n" . |
|
710 | - ' <DP>' . base64_encode($raw['exponent1']) . "</DP>\r\n" . |
|
711 | - ' <DQ>' . base64_encode($raw['exponent2']) . "</DQ>\r\n" . |
|
712 | - ' <InverseQ>' . base64_encode($raw['coefficient']) . "</InverseQ>\r\n" . |
|
713 | - ' <D>' . base64_encode($raw['privateExponent']) . "</D>\r\n" . |
|
714 | - '</RSAKeyValue>'; |
|
706 | + ' <Modulus>' . base64_encode($raw['modulus']) . "</Modulus>\r\n" . |
|
707 | + ' <Exponent>' . base64_encode($raw['publicExponent']) . "</Exponent>\r\n" . |
|
708 | + ' <P>' . base64_encode($raw['prime1']) . "</P>\r\n" . |
|
709 | + ' <Q>' . base64_encode($raw['prime2']) . "</Q>\r\n" . |
|
710 | + ' <DP>' . base64_encode($raw['exponent1']) . "</DP>\r\n" . |
|
711 | + ' <DQ>' . base64_encode($raw['exponent2']) . "</DQ>\r\n" . |
|
712 | + ' <InverseQ>' . base64_encode($raw['coefficient']) . "</InverseQ>\r\n" . |
|
713 | + ' <D>' . base64_encode($raw['privateExponent']) . "</D>\r\n" . |
|
714 | + '</RSAKeyValue>'; |
|
715 | 715 | break; |
716 | 716 | case CRYPT_RSA_PRIVATE_FORMAT_PUTTY: |
717 | 717 | if ($num_primes != 2) { |
@@ -725,8 +725,8 @@ discard block |
||
725 | 725 | strlen('ssh-rsa'), 'ssh-rsa', strlen($raw['publicExponent']), $raw['publicExponent'], strlen($raw['modulus']), $raw['modulus'] |
726 | 726 | ); |
727 | 727 | $source = pack('Na*Na*Na*Na*', |
728 | - strlen('ssh-rsa'), 'ssh-rsa', strlen($encryption), $encryption, |
|
729 | - strlen($this->comment), $this->comment, strlen($public), $public |
|
728 | + strlen('ssh-rsa'), 'ssh-rsa', strlen($encryption), $encryption, |
|
729 | + strlen($this->comment), $this->comment, strlen($public), $public |
|
730 | 730 | ); |
731 | 731 | $public = base64_encode($public); |
732 | 732 | $key.= "Public-Lines: " . ((strlen($public) + 32) >> 6) . "\r\n"; |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | $des->setIV($iv); |
811 | 811 | $iv = strtoupper(bin2hex($iv)); |
812 | 812 | $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . |
813 | - "Proc-Type: 4,ENCRYPTED\r\n" . |
|
814 | - "DEK-Info: DES-EDE3-CBC,$iv\r\n" . |
|
815 | - "\r\n" . |
|
816 | - chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64) . |
|
817 | - '-----END RSA PRIVATE KEY-----'; |
|
813 | + "Proc-Type: 4,ENCRYPTED\r\n" . |
|
814 | + "DEK-Info: DES-EDE3-CBC,$iv\r\n" . |
|
815 | + "\r\n" . |
|
816 | + chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64) . |
|
817 | + '-----END RSA PRIVATE KEY-----'; |
|
818 | 818 | } else { |
819 | 819 | $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . |
820 | - chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
821 | - '-----END RSA PRIVATE KEY-----'; |
|
820 | + chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
821 | + '-----END RSA PRIVATE KEY-----'; |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | return $RSAPrivateKey; |
@@ -843,9 +843,9 @@ discard block |
||
843 | 843 | return array('e' => $e->copy(), 'n' => $n->copy()); |
844 | 844 | case CRYPT_RSA_PUBLIC_FORMAT_XML: |
845 | 845 | return "<RSAKeyValue>\r\n" . |
846 | - ' <Modulus>' . base64_encode($modulus) . "</Modulus>\r\n" . |
|
847 | - ' <Exponent>' . base64_encode($publicExponent) . "</Exponent>\r\n" . |
|
848 | - '</RSAKeyValue>'; |
|
846 | + ' <Modulus>' . base64_encode($modulus) . "</Modulus>\r\n" . |
|
847 | + ' <Exponent>' . base64_encode($publicExponent) . "</Exponent>\r\n" . |
|
848 | + '</RSAKeyValue>'; |
|
849 | 849 | break; |
850 | 850 | case CRYPT_RSA_PUBLIC_FORMAT_OPENSSH: |
851 | 851 | // from <http://tools.ietf.org/html/rfc4253#page-15>: |
@@ -884,8 +884,8 @@ discard block |
||
884 | 884 | } |
885 | 885 | |
886 | 886 | $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . |
887 | - chunk_split(base64_encode($RSAPublicKey), 64) . |
|
888 | - '-----END PUBLIC KEY-----'; |
|
887 | + chunk_split(base64_encode($RSAPublicKey), 64) . |
|
888 | + '-----END PUBLIC KEY-----'; |
|
889 | 889 | |
890 | 890 | return $RSAPublicKey; |
891 | 891 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @see Crypt_RSA::setHash() |
101 | 101 | * @see Crypt_RSA::setMGFHash() |
102 | 102 | */ |
103 | -define('CRYPT_RSA_ENCRYPTION_OAEP', 1); |
|
103 | +define('CRYPT_RSA_ENCRYPTION_OAEP', 1); |
|
104 | 104 | /** |
105 | 105 | * Use PKCS#1 padding. |
106 | 106 | * |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @see Crypt_RSA::setSaltLength() |
125 | 125 | * @see Crypt_RSA::setMGFHash() |
126 | 126 | */ |
127 | -define('CRYPT_RSA_SIGNATURE_PSS', 1); |
|
127 | +define('CRYPT_RSA_SIGNATURE_PSS', 1); |
|
128 | 128 | /** |
129 | 129 | * Use the PKCS#1 scheme by default. |
130 | 130 | * |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | /** |
142 | 142 | * ASN1 Integer |
143 | 143 | */ |
144 | -define('CRYPT_RSA_ASN1_INTEGER', 2); |
|
144 | +define('CRYPT_RSA_ASN1_INTEGER', 2); |
|
145 | 145 | /** |
146 | 146 | * ASN1 Bit String |
147 | 147 | */ |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | /** |
172 | 172 | * Default openSSL configuration file. |
173 | 173 | */ |
174 | -define('CRYPT_RSA_OPENSSL_CONFIG', dirname(__FILE__) . '/../openssl.cnf'); |
|
174 | +define('CRYPT_RSA_OPENSSL_CONFIG', dirname(__FILE__).'/../openssl.cnf'); |
|
175 | 175 | |
176 | 176 | |
177 | 177 | /**#@+ |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | |
468 | 468 | $this->configFile = CRYPT_RSA_OPENSSL_CONFIG; |
469 | 469 | |
470 | - if ( !defined('CRYPT_RSA_MODE') ) { |
|
470 | + if (!defined('CRYPT_RSA_MODE')) { |
|
471 | 471 | switch (true) { |
472 | 472 | case extension_loaded('openssl') && version_compare(PHP_VERSION, '4.2.0', '>=') && file_exists($this->configFile): |
473 | 473 | define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_OPENSSL); |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | } |
519 | 519 | |
520 | 520 | // OpenSSL uses 65537 as the exponent and requires RSA keys be 384 bits minimum |
521 | - if ( CRYPT_RSA_MODE == CRYPT_RSA_MODE_OPENSSL && $bits >= 384 && CRYPT_RSA_EXPONENT == 65537) { |
|
521 | + if (CRYPT_RSA_MODE == CRYPT_RSA_MODE_OPENSSL && $bits >= 384 && CRYPT_RSA_EXPONENT == 65537) { |
|
522 | 522 | $config = array(); |
523 | 523 | if (isset($this->configFile)) { |
524 | 524 | $config['config'] = $this->configFile; |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | do { |
579 | 579 | for ($i = $i0; $i <= $num_primes; $i++) { |
580 | 580 | if ($timeout !== false) { |
581 | - $timeout-= time() - $start; |
|
581 | + $timeout -= time() - $start; |
|
582 | 582 | $start = time(); |
583 | 583 | if ($timeout <= 0) { |
584 | 584 | return array( |
@@ -702,15 +702,15 @@ discard block |
||
702 | 702 | if ($num_primes != 2) { |
703 | 703 | return false; |
704 | 704 | } |
705 | - return "<RSAKeyValue>\r\n" . |
|
706 | - ' <Modulus>' . base64_encode($raw['modulus']) . "</Modulus>\r\n" . |
|
707 | - ' <Exponent>' . base64_encode($raw['publicExponent']) . "</Exponent>\r\n" . |
|
708 | - ' <P>' . base64_encode($raw['prime1']) . "</P>\r\n" . |
|
709 | - ' <Q>' . base64_encode($raw['prime2']) . "</Q>\r\n" . |
|
710 | - ' <DP>' . base64_encode($raw['exponent1']) . "</DP>\r\n" . |
|
711 | - ' <DQ>' . base64_encode($raw['exponent2']) . "</DQ>\r\n" . |
|
712 | - ' <InverseQ>' . base64_encode($raw['coefficient']) . "</InverseQ>\r\n" . |
|
713 | - ' <D>' . base64_encode($raw['privateExponent']) . "</D>\r\n" . |
|
705 | + return "<RSAKeyValue>\r\n". |
|
706 | + ' <Modulus>'.base64_encode($raw['modulus'])."</Modulus>\r\n". |
|
707 | + ' <Exponent>'.base64_encode($raw['publicExponent'])."</Exponent>\r\n". |
|
708 | + ' <P>'.base64_encode($raw['prime1'])."</P>\r\n". |
|
709 | + ' <Q>'.base64_encode($raw['prime2'])."</Q>\r\n". |
|
710 | + ' <DP>'.base64_encode($raw['exponent1'])."</DP>\r\n". |
|
711 | + ' <DQ>'.base64_encode($raw['exponent2'])."</DQ>\r\n". |
|
712 | + ' <InverseQ>'.base64_encode($raw['coefficient'])."</InverseQ>\r\n". |
|
713 | + ' <D>'.base64_encode($raw['privateExponent'])."</D>\r\n". |
|
714 | 714 | '</RSAKeyValue>'; |
715 | 715 | break; |
716 | 716 | case CRYPT_RSA_PRIVATE_FORMAT_PUTTY: |
@@ -719,8 +719,8 @@ discard block |
||
719 | 719 | } |
720 | 720 | $key = "PuTTY-User-Key-File-2: ssh-rsa\r\nEncryption: "; |
721 | 721 | $encryption = (!empty($this->password) || is_string($this->password)) ? 'aes256-cbc' : 'none'; |
722 | - $key.= $encryption; |
|
723 | - $key.= "\r\nComment: " . $this->comment . "\r\n"; |
|
722 | + $key .= $encryption; |
|
723 | + $key .= "\r\nComment: ".$this->comment."\r\n"; |
|
724 | 724 | $public = pack('Na*Na*Na*', |
725 | 725 | strlen('ssh-rsa'), 'ssh-rsa', strlen($raw['publicExponent']), $raw['publicExponent'], strlen($raw['modulus']), $raw['modulus'] |
726 | 726 | ); |
@@ -729,18 +729,18 @@ discard block |
||
729 | 729 | strlen($this->comment), $this->comment, strlen($public), $public |
730 | 730 | ); |
731 | 731 | $public = base64_encode($public); |
732 | - $key.= "Public-Lines: " . ((strlen($public) + 32) >> 6) . "\r\n"; |
|
733 | - $key.= chunk_split($public, 64); |
|
732 | + $key .= "Public-Lines: ".((strlen($public) + 32) >> 6)."\r\n"; |
|
733 | + $key .= chunk_split($public, 64); |
|
734 | 734 | $private = pack('Na*Na*Na*Na*', |
735 | 735 | strlen($raw['privateExponent']), $raw['privateExponent'], strlen($raw['prime1']), $raw['prime1'], |
736 | 736 | strlen($raw['prime2']), $raw['prime2'], strlen($raw['coefficient']), $raw['coefficient'] |
737 | 737 | ); |
738 | 738 | if (empty($this->password) && !is_string($this->password)) { |
739 | - $source.= pack('Na*', strlen($private), $private); |
|
739 | + $source .= pack('Na*', strlen($private), $private); |
|
740 | 740 | $hashkey = 'putty-private-key-file-mac-key'; |
741 | 741 | } else { |
742 | - $private.= crypt_random_string(16 - (strlen($private) & 15)); |
|
743 | - $source.= pack('Na*', strlen($private), $private); |
|
742 | + $private .= crypt_random_string(16 - (strlen($private) & 15)); |
|
743 | + $source .= pack('Na*', strlen($private), $private); |
|
744 | 744 | if (!class_exists('Crypt_AES')) { |
745 | 745 | require_once('Crypt/AES.php'); |
746 | 746 | } |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | $symkey = ''; |
749 | 749 | while (strlen($symkey) < 32) { |
750 | 750 | $temp = pack('Na*', $sequence++, $this->password); |
751 | - $symkey.= pack('H*', sha1($temp)); |
|
751 | + $symkey .= pack('H*', sha1($temp)); |
|
752 | 752 | } |
753 | 753 | $symkey = substr($symkey, 0, 32); |
754 | 754 | $crypto = new Crypt_AES(); |
@@ -756,18 +756,18 @@ discard block |
||
756 | 756 | $crypto->setKey($symkey); |
757 | 757 | $crypto->disablePadding(); |
758 | 758 | $private = $crypto->encrypt($private); |
759 | - $hashkey = 'putty-private-key-file-mac-key' . $this->password; |
|
759 | + $hashkey = 'putty-private-key-file-mac-key'.$this->password; |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | $private = base64_encode($private); |
763 | - $key.= 'Private-Lines: ' . ((strlen($private) + 32) >> 6) . "\r\n"; |
|
764 | - $key.= chunk_split($private, 64); |
|
763 | + $key .= 'Private-Lines: '.((strlen($private) + 32) >> 6)."\r\n"; |
|
764 | + $key .= chunk_split($private, 64); |
|
765 | 765 | if (!class_exists('Crypt_Hash')) { |
766 | 766 | require_once('Crypt/Hash.php'); |
767 | 767 | } |
768 | 768 | $hash = new Crypt_Hash('sha1'); |
769 | 769 | $hash->setKey(pack('H*', sha1($hashkey))); |
770 | - $key.= 'Private-MAC: ' . bin2hex($hash->hash($source)) . "\r\n"; |
|
770 | + $key .= 'Private-MAC: '.bin2hex($hash->hash($source))."\r\n"; |
|
771 | 771 | |
772 | 772 | return $key; |
773 | 773 | default: // eg. CRYPT_RSA_PRIVATE_FORMAT_PKCS1 |
@@ -789,19 +789,19 @@ discard block |
||
789 | 789 | // coefficient INTEGER -- ti |
790 | 790 | // } |
791 | 791 | $OtherPrimeInfo = pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($primes[$i]->toBytes(true))), $primes[$i]->toBytes(true)); |
792 | - $OtherPrimeInfo.= pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($exponents[$i]->toBytes(true))), $exponents[$i]->toBytes(true)); |
|
793 | - $OtherPrimeInfo.= pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($coefficients[$i]->toBytes(true))), $coefficients[$i]->toBytes(true)); |
|
794 | - $OtherPrimeInfos.= pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfo)), $OtherPrimeInfo); |
|
792 | + $OtherPrimeInfo .= pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($exponents[$i]->toBytes(true))), $exponents[$i]->toBytes(true)); |
|
793 | + $OtherPrimeInfo .= pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($coefficients[$i]->toBytes(true))), $coefficients[$i]->toBytes(true)); |
|
794 | + $OtherPrimeInfos .= pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfo)), $OtherPrimeInfo); |
|
795 | 795 | } |
796 | - $RSAPrivateKey.= pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfos)), $OtherPrimeInfos); |
|
796 | + $RSAPrivateKey .= pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfos)), $OtherPrimeInfos); |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | $RSAPrivateKey = pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey); |
800 | 800 | |
801 | 801 | if (!empty($this->password) || is_string($this->password)) { |
802 | 802 | $iv = crypt_random_string(8); |
803 | - $symkey = pack('H*', md5($this->password . $iv)); // symkey is short for symmetric key |
|
804 | - $symkey.= substr(pack('H*', md5($symkey . $this->password . $iv)), 0, 8); |
|
803 | + $symkey = pack('H*', md5($this->password.$iv)); // symkey is short for symmetric key |
|
804 | + $symkey .= substr(pack('H*', md5($symkey.$this->password.$iv)), 0, 8); |
|
805 | 805 | if (!class_exists('Crypt_TripleDES')) { |
806 | 806 | require_once('Crypt/TripleDES.php'); |
807 | 807 | } |
@@ -809,15 +809,15 @@ discard block |
||
809 | 809 | $des->setKey($symkey); |
810 | 810 | $des->setIV($iv); |
811 | 811 | $iv = strtoupper(bin2hex($iv)); |
812 | - $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . |
|
813 | - "Proc-Type: 4,ENCRYPTED\r\n" . |
|
814 | - "DEK-Info: DES-EDE3-CBC,$iv\r\n" . |
|
815 | - "\r\n" . |
|
816 | - chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64) . |
|
812 | + $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n". |
|
813 | + "Proc-Type: 4,ENCRYPTED\r\n". |
|
814 | + "DEK-Info: DES-EDE3-CBC,$iv\r\n". |
|
815 | + "\r\n". |
|
816 | + chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64). |
|
817 | 817 | '-----END RSA PRIVATE KEY-----'; |
818 | 818 | } else { |
819 | - $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . |
|
820 | - chunk_split(base64_encode($RSAPrivateKey), 64) . |
|
819 | + $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n". |
|
820 | + chunk_split(base64_encode($RSAPrivateKey), 64). |
|
821 | 821 | '-----END RSA PRIVATE KEY-----'; |
822 | 822 | } |
823 | 823 | |
@@ -842,9 +842,9 @@ discard block |
||
842 | 842 | case CRYPT_RSA_PUBLIC_FORMAT_RAW: |
843 | 843 | return array('e' => $e->copy(), 'n' => $n->copy()); |
844 | 844 | case CRYPT_RSA_PUBLIC_FORMAT_XML: |
845 | - return "<RSAKeyValue>\r\n" . |
|
846 | - ' <Modulus>' . base64_encode($modulus) . "</Modulus>\r\n" . |
|
847 | - ' <Exponent>' . base64_encode($publicExponent) . "</Exponent>\r\n" . |
|
845 | + return "<RSAKeyValue>\r\n". |
|
846 | + ' <Modulus>'.base64_encode($modulus)."</Modulus>\r\n". |
|
847 | + ' <Exponent>'.base64_encode($publicExponent)."</Exponent>\r\n". |
|
848 | 848 | '</RSAKeyValue>'; |
849 | 849 | break; |
850 | 850 | case CRYPT_RSA_PUBLIC_FORMAT_OPENSSH: |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | // mpint e |
854 | 854 | // mpint n |
855 | 855 | $RSAPublicKey = pack('Na*Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publicExponent), $publicExponent, strlen($modulus), $modulus); |
856 | - $RSAPublicKey = 'ssh-rsa ' . base64_encode($RSAPublicKey) . ' ' . $this->comment; |
|
856 | + $RSAPublicKey = 'ssh-rsa '.base64_encode($RSAPublicKey).' '.$this->comment; |
|
857 | 857 | |
858 | 858 | return $RSAPublicKey; |
859 | 859 | default: // eg. CRYPT_RSA_PUBLIC_FORMAT_PKCS1_RAW or CRYPT_RSA_PUBLIC_FORMAT_PKCS1 |
@@ -875,16 +875,16 @@ discard block |
||
875 | 875 | if ($this->publicKeyFormat == CRYPT_RSA_PUBLIC_FORMAT_PKCS1) { |
876 | 876 | // sequence(oid(1.2.840.113549.1.1.1), null)) = rsaEncryption. |
877 | 877 | $rsaOID = pack('H*', '300d06092a864886f70d0101010500'); // hex version of MA0GCSqGSIb3DQEBAQUA |
878 | - $RSAPublicKey = chr(0) . $RSAPublicKey; |
|
879 | - $RSAPublicKey = chr(3) . $this->_encodeLength(strlen($RSAPublicKey)) . $RSAPublicKey; |
|
878 | + $RSAPublicKey = chr(0).$RSAPublicKey; |
|
879 | + $RSAPublicKey = chr(3).$this->_encodeLength(strlen($RSAPublicKey)).$RSAPublicKey; |
|
880 | 880 | |
881 | 881 | $RSAPublicKey = pack('Ca*a*', |
882 | - CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($rsaOID . $RSAPublicKey)), $rsaOID . $RSAPublicKey |
|
882 | + CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($rsaOID.$RSAPublicKey)), $rsaOID.$RSAPublicKey |
|
883 | 883 | ); |
884 | 884 | } |
885 | 885 | |
886 | - $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . |
|
887 | - chunk_split(base64_encode($RSAPublicKey), 64) . |
|
886 | + $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n". |
|
887 | + chunk_split(base64_encode($RSAPublicKey), 64). |
|
888 | 888 | '-----END PUBLIC KEY-----'; |
889 | 889 | |
890 | 890 | return $RSAPublicKey; |
@@ -959,8 +959,8 @@ discard block |
||
959 | 959 | * OpenSSL is the de facto standard. It's utilized by OpenSSH and other projects */ |
960 | 960 | if (preg_match('#DEK-Info: (.+),(.+)#', $key, $matches)) { |
961 | 961 | $iv = pack('H*', trim($matches[2])); |
962 | - $symkey = pack('H*', md5($this->password . substr($iv, 0, 8))); // symkey is short for symmetric key |
|
963 | - $symkey.= pack('H*', md5($symkey . $this->password . substr($iv, 0, 8))); |
|
962 | + $symkey = pack('H*', md5($this->password.substr($iv, 0, 8))); // symkey is short for symmetric key |
|
963 | + $symkey .= pack('H*', md5($symkey.$this->password.substr($iv, 0, 8))); |
|
964 | 964 | $ciphertext = preg_replace('#.+(\r|\n|\r\n)\1|[\r\n]|-.+-| #s', '', $key); |
965 | 965 | $ciphertext = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $ciphertext) ? base64_decode($ciphertext) : false; |
966 | 966 | if ($ciphertext === false) { |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | xml_set_element_handler($xml, '_start_element_handler', '_stop_element_handler'); |
1180 | 1180 | xml_set_character_data_handler($xml, '_data_handler'); |
1181 | 1181 | // add <xml></xml> to account for "dangling" tags like <BitStrength>...</BitStrength> that are sometimes added |
1182 | - if (!xml_parse($xml, '<xml>' . $key . '</xml>')) { |
|
1182 | + if (!xml_parse($xml, '<xml>'.$key.'</xml>')) { |
|
1183 | 1183 | return false; |
1184 | 1184 | } |
1185 | 1185 | |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | $sequence = 0; |
1216 | 1216 | while (strlen($symkey) < 32) { |
1217 | 1217 | $temp = pack('Na*', $sequence++, $this->password); |
1218 | - $symkey.= pack('H*', sha1($temp)); |
|
1218 | + $symkey .= pack('H*', sha1($temp)); |
|
1219 | 1219 | } |
1220 | 1220 | $symkey = substr($symkey, 0, 32); |
1221 | 1221 | $crypto = new Crypt_AES(); |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | if (!isset($this->current) || is_object($this->current)) { |
1351 | 1351 | return; |
1352 | 1352 | } |
1353 | - $this->current.= trim($data); |
|
1353 | + $this->current .= trim($data); |
|
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | /** |
@@ -1583,8 +1583,8 @@ discard block |
||
1583 | 1583 | $max = str_repeat(chr(0xFF), $bytes); |
1584 | 1584 | $msb = $bits & 7; |
1585 | 1585 | if ($msb) { |
1586 | - $min = chr(1 << ($msb - 1)) . $min; |
|
1587 | - $max = chr((1 << $msb) - 1) . $max; |
|
1586 | + $min = chr(1 << ($msb - 1)).$min; |
|
1587 | + $max = chr((1 << $msb) - 1).$max; |
|
1588 | 1588 | } else { |
1589 | 1589 | $min[0] = chr(0x80); |
1590 | 1590 | } |
@@ -1608,8 +1608,8 @@ discard block |
||
1608 | 1608 | function _decodeLength(&$string) |
1609 | 1609 | { |
1610 | 1610 | $length = ord($this->_string_shift($string)); |
1611 | - if ( $length & 0x80 ) { // definite length, long form |
|
1612 | - $length&= 0x7F; |
|
1611 | + if ($length & 0x80) { // definite length, long form |
|
1612 | + $length &= 0x7F; |
|
1613 | 1613 | $temp = $this->_string_shift($string, $length); |
1614 | 1614 | list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)); |
1615 | 1615 | } |
@@ -2002,7 +2002,7 @@ discard block |
||
2002 | 2002 | $count = ceil($maskLen / $this->mgfHLen); |
2003 | 2003 | for ($i = 0; $i < $count; $i++) { |
2004 | 2004 | $c = pack('N', $i); |
2005 | - $t.= $this->mgfHash->hash($mgfSeed . $c); |
|
2005 | + $t .= $this->mgfHash->hash($mgfSeed.$c); |
|
2006 | 2006 | } |
2007 | 2007 | |
2008 | 2008 | return substr($t, 0, $maskLen); |
@@ -2037,13 +2037,13 @@ discard block |
||
2037 | 2037 | |
2038 | 2038 | $lHash = $this->hash->hash($l); |
2039 | 2039 | $ps = str_repeat(chr(0), $this->k - $mLen - 2 * $this->hLen - 2); |
2040 | - $db = $lHash . $ps . chr(1) . $m; |
|
2040 | + $db = $lHash.$ps.chr(1).$m; |
|
2041 | 2041 | $seed = crypt_random_string($this->hLen); |
2042 | 2042 | $dbMask = $this->_mgf1($seed, $this->k - $this->hLen - 1); |
2043 | 2043 | $maskedDB = $db ^ $dbMask; |
2044 | 2044 | $seedMask = $this->_mgf1($maskedDB, $this->hLen); |
2045 | 2045 | $maskedSeed = $seed ^ $seedMask; |
2046 | - $em = chr(0) . $maskedSeed . $maskedDB; |
|
2046 | + $em = chr(0).$maskedSeed.$maskedDB; |
|
2047 | 2047 | |
2048 | 2048 | // RSA encryption |
2049 | 2049 | |
@@ -2158,7 +2158,7 @@ discard block |
||
2158 | 2158 | while (strlen($ps) != $psLen) { |
2159 | 2159 | $temp = crypt_random_string($psLen - strlen($ps)); |
2160 | 2160 | $temp = str_replace("\x00", '', $temp); |
2161 | - $ps.= $temp; |
|
2161 | + $ps .= $temp; |
|
2162 | 2162 | } |
2163 | 2163 | $type = 2; |
2164 | 2164 | // see the comments of _rsaes_pkcs1_v1_5_decrypt() to understand why this is being done |
@@ -2167,7 +2167,7 @@ discard block |
||
2167 | 2167 | // "The padding string PS shall consist of k-3-||D|| octets. ... for block type 01, they shall have value FF" |
2168 | 2168 | $ps = str_repeat("\xFF", $psLen); |
2169 | 2169 | } |
2170 | - $em = chr(0) . chr($type) . $ps . chr(0) . $m; |
|
2170 | + $em = chr(0).chr($type).$ps.chr(0).$m; |
|
2171 | 2171 | |
2172 | 2172 | // RSA encryption |
2173 | 2173 | $m = $this->_os2ip($em); |
@@ -2263,14 +2263,14 @@ discard block |
||
2263 | 2263 | } |
2264 | 2264 | |
2265 | 2265 | $salt = crypt_random_string($sLen); |
2266 | - $m2 = "\0\0\0\0\0\0\0\0" . $mHash . $salt; |
|
2266 | + $m2 = "\0\0\0\0\0\0\0\0".$mHash.$salt; |
|
2267 | 2267 | $h = $this->hash->hash($m2); |
2268 | 2268 | $ps = str_repeat(chr(0), $emLen - $sLen - $this->hLen - 2); |
2269 | - $db = $ps . chr(1) . $salt; |
|
2269 | + $db = $ps.chr(1).$salt; |
|
2270 | 2270 | $dbMask = $this->_mgf1($h, $emLen - $this->hLen - 1); |
2271 | 2271 | $maskedDB = $db ^ $dbMask; |
2272 | 2272 | $maskedDB[0] = ~chr(0xFF << ($emBits & 7)) & $maskedDB[0]; |
2273 | - $em = $maskedDB . $h . chr(0xBC); |
|
2273 | + $em = $maskedDB.$h.chr(0xBC); |
|
2274 | 2274 | |
2275 | 2275 | return $em; |
2276 | 2276 | } |
@@ -2317,7 +2317,7 @@ discard block |
||
2317 | 2317 | return false; |
2318 | 2318 | } |
2319 | 2319 | $salt = substr($db, $temp + 1); // should be $sLen long |
2320 | - $m2 = "\0\0\0\0\0\0\0\0" . $mHash . $salt; |
|
2320 | + $m2 = "\0\0\0\0\0\0\0\0".$mHash.$salt; |
|
2321 | 2321 | $h2 = $this->hash->hash($m2); |
2322 | 2322 | return $this->_equals($h, $h2); |
2323 | 2323 | } |
@@ -2425,7 +2425,7 @@ discard block |
||
2425 | 2425 | case 'sha512': |
2426 | 2426 | $t = pack('H*', '3051300d060960864801650304020305000440'); |
2427 | 2427 | } |
2428 | - $t.= $h; |
|
2428 | + $t .= $h; |
|
2429 | 2429 | $tLen = strlen($t); |
2430 | 2430 | |
2431 | 2431 | if ($emLen < $tLen + 11) { |
@@ -2586,7 +2586,7 @@ discard block |
||
2586 | 2586 | $plaintext = str_split($plaintext, $length); |
2587 | 2587 | $ciphertext = ''; |
2588 | 2588 | foreach ($plaintext as $m) { |
2589 | - $ciphertext.= $this->_rsaes_pkcs1_v1_5_encrypt($m); |
|
2589 | + $ciphertext .= $this->_rsaes_pkcs1_v1_5_encrypt($m); |
|
2590 | 2590 | } |
2591 | 2591 | return $ciphertext; |
2592 | 2592 | //case CRYPT_RSA_ENCRYPTION_OAEP: |
@@ -2599,7 +2599,7 @@ discard block |
||
2599 | 2599 | $plaintext = str_split($plaintext, $length); |
2600 | 2600 | $ciphertext = ''; |
2601 | 2601 | foreach ($plaintext as $m) { |
2602 | - $ciphertext.= $this->_rsaes_oaep_encrypt($m); |
|
2602 | + $ciphertext .= $this->_rsaes_oaep_encrypt($m); |
|
2603 | 2603 | } |
2604 | 2604 | return $ciphertext; |
2605 | 2605 | } |
@@ -2638,7 +2638,7 @@ discard block |
||
2638 | 2638 | if ($temp === false) { |
2639 | 2639 | return false; |
2640 | 2640 | } |
2641 | - $plaintext.= $temp; |
|
2641 | + $plaintext .= $temp; |
|
2642 | 2642 | } |
2643 | 2643 | |
2644 | 2644 | return $plaintext; |
@@ -98,6 +98,7 @@ discard block |
||
98 | 98 | * CRYPT_DES_MODE_ECB or CRYPT_DES_MODE_CBC. If not explictly set, CRYPT_DES_MODE_CBC will be used. |
99 | 99 | * |
100 | 100 | * @param optional Integer $mode |
101 | + * @param integer $mode |
|
101 | 102 | * @return Crypt_TripleDES |
102 | 103 | * @access public |
103 | 104 | */ |
@@ -318,6 +319,7 @@ discard block |
||
318 | 319 | * |
319 | 320 | * @access public |
320 | 321 | * @param String $plaintext |
322 | + * @return string |
|
321 | 323 | */ |
322 | 324 | function encrypt($plaintext) |
323 | 325 | { |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | if ($this->continuousBuffer) { |
539 | 539 | $this->encryptIV = $xor; |
540 | 540 | if ($start = strlen($plaintext) & 7) { |
541 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
541 | + $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
542 | 542 | } |
543 | 543 | } |
544 | 544 | } |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | if ($this->continuousBuffer) { |
758 | 758 | $this->decryptIV = $xor; |
759 | 759 | if ($start = strlen($ciphertext) & 7) { |
760 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
760 | + $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | function Crypt_TripleDES($mode = CRYPT_DES_MODE_CBC) |
105 | 105 | { |
106 | - if ( !defined('CRYPT_DES_MODE') ) { |
|
106 | + if (!defined('CRYPT_DES_MODE')) { |
|
107 | 107 | switch (true) { |
108 | 108 | case extension_loaded('mcrypt') && in_array('tripledes', mcrypt_list_algorithms()): |
109 | 109 | define('CRYPT_DES_MODE', CRYPT_DES_MODE_MCRYPT); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | - if ( $mode == CRYPT_DES_MODE_3CBC ) { |
|
116 | + if ($mode == CRYPT_DES_MODE_3CBC) { |
|
117 | 117 | $this->mode = CRYPT_DES_MODE_3CBC; |
118 | 118 | $this->des = array( |
119 | 119 | new Crypt_DES(CRYPT_DES_MODE_CBC), |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | - switch ( CRYPT_DES_MODE ) { |
|
133 | + switch (CRYPT_DES_MODE) { |
|
134 | 134 | case CRYPT_DES_MODE_MCRYPT: |
135 | 135 | switch ($mode) { |
136 | 136 | case CRYPT_DES_MODE_ECB: |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | switch (true) { |
219 | 219 | case CRYPT_DES_MODE == CRYPT_DES_MODE_INTERNAL: |
220 | 220 | case $this->mode == CRYPT_DES_MODE_3CBC: |
221 | - $this->des[0]->setKey(substr($key, 0, 8)); |
|
222 | - $this->des[1]->setKey(substr($key, 8, 8)); |
|
221 | + $this->des[0]->setKey(substr($key, 0, 8)); |
|
222 | + $this->des[1]->setKey(substr($key, 8, 8)); |
|
223 | 223 | $this->des[2]->setKey(substr($key, 16, 8)); |
224 | 224 | |
225 | 225 | // Merge the three DES-1-dim-key-arrays for 3DES-inline-en/decrypting |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | switch ($method) { |
260 | 260 | default: // 'pbkdf2' |
261 | - list(, , $hash, $salt, $count) = func_get_args(); |
|
261 | + list(,, $hash, $salt, $count) = func_get_args(); |
|
262 | 262 | if (!isset($hash)) { |
263 | 263 | $hash = 'sha1'; |
264 | 264 | } |
@@ -281,12 +281,12 @@ discard block |
||
281 | 281 | $hmac = new Crypt_Hash(); |
282 | 282 | $hmac->setHash($hash); |
283 | 283 | $hmac->setKey($password); |
284 | - $f = $u = $hmac->hash($salt . pack('N', $i++)); |
|
284 | + $f = $u = $hmac->hash($salt.pack('N', $i++)); |
|
285 | 285 | for ($j = 2; $j <= $count; $j++) { |
286 | 286 | $u = $hmac->hash($u); |
287 | - $f^= $u; |
|
287 | + $f ^= $u; |
|
288 | 288 | } |
289 | - $key.= $f; |
|
289 | + $key .= $f; |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | return $ciphertext; |
333 | 333 | } |
334 | 334 | |
335 | - if ( CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT ) { |
|
335 | + if (CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT) { |
|
336 | 336 | if ($this->enchanged) { |
337 | 337 | mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV); |
338 | 338 | if ($this->mode == 'ncfb') { |
@@ -354,11 +354,11 @@ discard block |
||
354 | 354 | $max = 8 - $pos; |
355 | 355 | if ($len >= $max) { |
356 | 356 | $i = $max; |
357 | - $len-= $max; |
|
357 | + $len -= $max; |
|
358 | 358 | $pos = 0; |
359 | 359 | } else { |
360 | 360 | $i = $len; |
361 | - $pos+= $len; |
|
361 | + $pos += $len; |
|
362 | 362 | $len = 0; |
363 | 363 | } |
364 | 364 | $ciphertext = substr($iv, $orig_pos) ^ $plaintext; |
@@ -371,16 +371,16 @@ discard block |
||
371 | 371 | mcrypt_generic_init($this->enmcrypt, $this->key, $iv); |
372 | 372 | $this->enbuffer['enmcrypt_init'] = false; |
373 | 373 | } |
374 | - $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 8)); |
|
374 | + $ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 8)); |
|
375 | 375 | $iv = substr($ciphertext, -8); |
376 | 376 | $i = strlen($ciphertext); |
377 | - $len%= 8; |
|
377 | + $len %= 8; |
|
378 | 378 | } else { |
379 | 379 | while ($len >= 8) { |
380 | 380 | $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, 8); |
381 | - $ciphertext.= $iv; |
|
382 | - $len-= 8; |
|
383 | - $i+= 8; |
|
381 | + $ciphertext .= $iv; |
|
382 | + $len -= 8; |
|
383 | + $i += 8; |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $iv = mcrypt_generic($this->ecb, $iv); |
389 | 389 | $block = $iv ^ substr($plaintext, $i); |
390 | 390 | $iv = substr_replace($iv, $block, 0, $len); |
391 | - $ciphertext.= $block; |
|
391 | + $ciphertext .= $block; |
|
392 | 392 | $pos = $len; |
393 | 393 | } |
394 | 394 | return $ciphertext; |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | $ciphertext = ''; |
420 | 420 | switch ($this->mode) { |
421 | 421 | case CRYPT_DES_MODE_ECB: |
422 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
422 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
423 | 423 | $block = substr($plaintext, $i, 8); |
424 | 424 | // all of these _processBlock calls could, in theory, be put in a function - say Crypt_TripleDES::_ede_encrypt() or something. |
425 | 425 | // only problem with that: it would slow encryption and decryption down. $this->des would have to be called every time that |
@@ -430,18 +430,18 @@ discard block |
||
430 | 430 | $block = $des[0]->_processBlock($block, CRYPT_DES_ENCRYPT); |
431 | 431 | $block = $des[1]->_processBlock($block, CRYPT_DES_DECRYPT); |
432 | 432 | $block = $des[2]->_processBlock($block, CRYPT_DES_ENCRYPT); |
433 | - $ciphertext.= $block; |
|
433 | + $ciphertext .= $block; |
|
434 | 434 | } |
435 | 435 | break; |
436 | 436 | case CRYPT_DES_MODE_CBC: |
437 | 437 | $xor = $this->encryptIV; |
438 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
438 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
439 | 439 | $block = substr($plaintext, $i, 8) ^ $xor; |
440 | 440 | $block = $des[0]->_processBlock($block, CRYPT_DES_ENCRYPT); |
441 | 441 | $block = $des[1]->_processBlock($block, CRYPT_DES_DECRYPT); |
442 | 442 | $block = $des[2]->_processBlock($block, CRYPT_DES_ENCRYPT); |
443 | 443 | $xor = $block; |
444 | - $ciphertext.= $block; |
|
444 | + $ciphertext .= $block; |
|
445 | 445 | } |
446 | 446 | if ($this->continuousBuffer) { |
447 | 447 | $this->encryptIV = $xor; |
@@ -450,41 +450,41 @@ discard block |
||
450 | 450 | case CRYPT_DES_MODE_CTR: |
451 | 451 | $xor = $this->encryptIV; |
452 | 452 | if (strlen($buffer['encrypted'])) { |
453 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
453 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
454 | 454 | $block = substr($plaintext, $i, 8); |
455 | 455 | if (strlen($block) > strlen($buffer['encrypted'])) { |
456 | 456 | $key = $this->_generate_xor($xor); |
457 | 457 | $key = $des[0]->_processBlock($key, CRYPT_DES_ENCRYPT); |
458 | 458 | $key = $des[1]->_processBlock($key, CRYPT_DES_DECRYPT); |
459 | 459 | $key = $des[2]->_processBlock($key, CRYPT_DES_ENCRYPT); |
460 | - $buffer['encrypted'].= $key; |
|
460 | + $buffer['encrypted'] .= $key; |
|
461 | 461 | } |
462 | 462 | $key = $this->_string_shift($buffer['encrypted']); |
463 | - $ciphertext.= $block ^ $key; |
|
463 | + $ciphertext .= $block ^ $key; |
|
464 | 464 | } |
465 | 465 | } else { |
466 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
466 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
467 | 467 | $block = substr($plaintext, $i, 8); |
468 | 468 | $key = $this->_generate_xor($xor); |
469 | 469 | $key = $des[0]->_processBlock($key, CRYPT_DES_ENCRYPT); |
470 | 470 | $key = $des[1]->_processBlock($key, CRYPT_DES_DECRYPT); |
471 | 471 | $key = $des[2]->_processBlock($key, CRYPT_DES_ENCRYPT); |
472 | - $ciphertext.= $block ^ $key; |
|
472 | + $ciphertext .= $block ^ $key; |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | if ($this->continuousBuffer) { |
476 | 476 | $this->encryptIV = $xor; |
477 | 477 | if ($start = strlen($plaintext) & 7) { |
478 | - $buffer['encrypted'] = substr($key, $start) . $buffer['encrypted']; |
|
478 | + $buffer['encrypted'] = substr($key, $start).$buffer['encrypted']; |
|
479 | 479 | } |
480 | 480 | } |
481 | 481 | break; |
482 | 482 | case CRYPT_DES_MODE_CFB: |
483 | 483 | if (strlen($buffer['xor'])) { |
484 | 484 | $ciphertext = $plaintext ^ $buffer['xor']; |
485 | - $iv = $buffer['encrypted'] . $ciphertext; |
|
485 | + $iv = $buffer['encrypted'].$ciphertext; |
|
486 | 486 | $start = strlen($ciphertext); |
487 | - $buffer['encrypted'].= $ciphertext; |
|
487 | + $buffer['encrypted'] .= $ciphertext; |
|
488 | 488 | $buffer['xor'] = substr($buffer['xor'], strlen($ciphertext)); |
489 | 489 | } else { |
490 | 490 | $ciphertext = ''; |
@@ -492,11 +492,11 @@ discard block |
||
492 | 492 | $start = 0; |
493 | 493 | } |
494 | 494 | |
495 | - for ($i = $start; $i < strlen($plaintext); $i+=8) { |
|
495 | + for ($i = $start; $i < strlen($plaintext); $i += 8) { |
|
496 | 496 | $block = substr($plaintext, $i, 8); |
497 | 497 | $iv = $des[0]->_processBlock($iv, CRYPT_DES_ENCRYPT); |
498 | 498 | $iv = $des[1]->_processBlock($iv, CRYPT_DES_DECRYPT); |
499 | - $xor= $des[2]->_processBlock($iv, CRYPT_DES_ENCRYPT); |
|
499 | + $xor = $des[2]->_processBlock($iv, CRYPT_DES_ENCRYPT); |
|
500 | 500 | |
501 | 501 | $iv = $block ^ $xor; |
502 | 502 | if ($continuousBuffer && strlen($iv) != 8) { |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | 'xor' => substr($xor, strlen($iv)) |
506 | 506 | ); |
507 | 507 | } |
508 | - $ciphertext.= $iv; |
|
508 | + $ciphertext .= $iv; |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | if ($this->continuousBuffer) { |
@@ -515,30 +515,30 @@ discard block |
||
515 | 515 | case CRYPT_DES_MODE_OFB: |
516 | 516 | $xor = $this->encryptIV; |
517 | 517 | if (strlen($buffer['xor'])) { |
518 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
518 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
519 | 519 | $block = substr($plaintext, $i, 8); |
520 | 520 | if (strlen($block) > strlen($buffer['xor'])) { |
521 | 521 | $xor = $des[0]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
522 | 522 | $xor = $des[1]->_processBlock($xor, CRYPT_DES_DECRYPT); |
523 | 523 | $xor = $des[2]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
524 | - $buffer['xor'].= $xor; |
|
524 | + $buffer['xor'] .= $xor; |
|
525 | 525 | } |
526 | 526 | $key = $this->_string_shift($buffer['xor']); |
527 | - $ciphertext.= $block ^ $key; |
|
527 | + $ciphertext .= $block ^ $key; |
|
528 | 528 | } |
529 | 529 | } else { |
530 | - for ($i = 0; $i < strlen($plaintext); $i+=8) { |
|
530 | + for ($i = 0; $i < strlen($plaintext); $i += 8) { |
|
531 | 531 | $xor = $des[0]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
532 | 532 | $xor = $des[1]->_processBlock($xor, CRYPT_DES_DECRYPT); |
533 | 533 | $xor = $des[2]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
534 | - $ciphertext.= substr($plaintext, $i, 8) ^ $xor; |
|
534 | + $ciphertext .= substr($plaintext, $i, 8) ^ $xor; |
|
535 | 535 | } |
536 | 536 | $key = $xor; |
537 | 537 | } |
538 | 538 | if ($this->continuousBuffer) { |
539 | 539 | $this->encryptIV = $xor; |
540 | 540 | if ($start = strlen($plaintext) & 7) { |
541 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
541 | + $buffer['xor'] = substr($key, $start).$buffer['xor']; |
|
542 | 542 | } |
543 | 543 | } |
544 | 544 | } |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | $ciphertext = str_pad($ciphertext, (strlen($ciphertext) + 7) & 0xFFFFFFF8, chr(0)); |
567 | 567 | } |
568 | 568 | |
569 | - if ( CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT ) { |
|
569 | + if (CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT) { |
|
570 | 570 | if ($this->dechanged) { |
571 | 571 | mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV); |
572 | 572 | if ($this->mode == 'ncfb') { |
@@ -588,11 +588,11 @@ discard block |
||
588 | 588 | $max = 8 - $pos; |
589 | 589 | if ($len >= $max) { |
590 | 590 | $i = $max; |
591 | - $len-= $max; |
|
591 | + $len -= $max; |
|
592 | 592 | $pos = 0; |
593 | 593 | } else { |
594 | 594 | $i = $len; |
595 | - $pos+= $len; |
|
595 | + $pos += $len; |
|
596 | 596 | $len = 0; |
597 | 597 | } |
598 | 598 | $plaintext = substr($iv, $orig_pos) ^ $ciphertext; |
@@ -600,14 +600,14 @@ discard block |
||
600 | 600 | } |
601 | 601 | if ($len >= 8) { |
602 | 602 | $cb = substr($ciphertext, $i, $len - $len % 8); |
603 | - $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; |
|
603 | + $plaintext .= mcrypt_generic($this->ecb, $iv.$cb) ^ $cb; |
|
604 | 604 | $iv = substr($cb, -8); |
605 | - $len%= 8; |
|
605 | + $len %= 8; |
|
606 | 606 | } |
607 | 607 | if ($len) { |
608 | 608 | $iv = mcrypt_generic($this->ecb, $iv); |
609 | 609 | $cb = substr($ciphertext, -$len); |
610 | - $plaintext.= $iv ^ $cb; |
|
610 | + $plaintext .= $iv ^ $cb; |
|
611 | 611 | $iv = substr_replace($iv, $cb, 0, $len); |
612 | 612 | $pos = $len; |
613 | 613 | } |
@@ -639,22 +639,22 @@ discard block |
||
639 | 639 | $plaintext = ''; |
640 | 640 | switch ($this->mode) { |
641 | 641 | case CRYPT_DES_MODE_ECB: |
642 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
642 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
643 | 643 | $block = substr($ciphertext, $i, 8); |
644 | 644 | $block = $des[2]->_processBlock($block, CRYPT_DES_DECRYPT); |
645 | 645 | $block = $des[1]->_processBlock($block, CRYPT_DES_ENCRYPT); |
646 | 646 | $block = $des[0]->_processBlock($block, CRYPT_DES_DECRYPT); |
647 | - $plaintext.= $block; |
|
647 | + $plaintext .= $block; |
|
648 | 648 | } |
649 | 649 | break; |
650 | 650 | case CRYPT_DES_MODE_CBC: |
651 | 651 | $xor = $this->decryptIV; |
652 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
652 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
653 | 653 | $orig = $block = substr($ciphertext, $i, 8); |
654 | 654 | $block = $des[2]->_processBlock($block, CRYPT_DES_DECRYPT); |
655 | 655 | $block = $des[1]->_processBlock($block, CRYPT_DES_ENCRYPT); |
656 | 656 | $block = $des[0]->_processBlock($block, CRYPT_DES_DECRYPT); |
657 | - $plaintext.= $block ^ $xor; |
|
657 | + $plaintext .= $block ^ $xor; |
|
658 | 658 | $xor = $orig; |
659 | 659 | } |
660 | 660 | if ($this->continuousBuffer) { |
@@ -664,39 +664,39 @@ discard block |
||
664 | 664 | case CRYPT_DES_MODE_CTR: |
665 | 665 | $xor = $this->decryptIV; |
666 | 666 | if (strlen($buffer['ciphertext'])) { |
667 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
667 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
668 | 668 | $block = substr($ciphertext, $i, 8); |
669 | 669 | if (strlen($block) > strlen($buffer['ciphertext'])) { |
670 | 670 | $key = $this->_generate_xor($xor); |
671 | 671 | $key = $des[0]->_processBlock($key, CRYPT_DES_ENCRYPT); |
672 | 672 | $key = $des[1]->_processBlock($key, CRYPT_DES_DECRYPT); |
673 | 673 | $key = $des[2]->_processBlock($key, CRYPT_DES_ENCRYPT); |
674 | - $buffer['ciphertext'].= $key; |
|
674 | + $buffer['ciphertext'] .= $key; |
|
675 | 675 | } |
676 | 676 | $key = $this->_string_shift($buffer['ciphertext']); |
677 | - $plaintext.= $block ^ $key; |
|
677 | + $plaintext .= $block ^ $key; |
|
678 | 678 | } |
679 | 679 | } else { |
680 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
680 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
681 | 681 | $block = substr($ciphertext, $i, 8); |
682 | 682 | $key = $this->_generate_xor($xor); |
683 | 683 | $key = $des[0]->_processBlock($key, CRYPT_DES_ENCRYPT); |
684 | 684 | $key = $des[1]->_processBlock($key, CRYPT_DES_DECRYPT); |
685 | 685 | $key = $des[2]->_processBlock($key, CRYPT_DES_ENCRYPT); |
686 | - $plaintext.= $block ^ $key; |
|
686 | + $plaintext .= $block ^ $key; |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | if ($this->continuousBuffer) { |
690 | 690 | $this->decryptIV = $xor; |
691 | 691 | if ($start = strlen($plaintext) & 7) { |
692 | - $buffer['ciphertext'] = substr($key, $start) . $buffer['ciphertext']; |
|
692 | + $buffer['ciphertext'] = substr($key, $start).$buffer['ciphertext']; |
|
693 | 693 | } |
694 | 694 | } |
695 | 695 | break; |
696 | 696 | case CRYPT_DES_MODE_CFB: |
697 | 697 | if (strlen($buffer['ciphertext'])) { |
698 | 698 | $plaintext = $ciphertext ^ substr($this->decryptIV, strlen($buffer['ciphertext'])); |
699 | - $buffer['ciphertext'].= substr($ciphertext, 0, strlen($plaintext)); |
|
699 | + $buffer['ciphertext'] .= substr($ciphertext, 0, strlen($plaintext)); |
|
700 | 700 | if (strlen($buffer['ciphertext']) != 8) { |
701 | 701 | $block = $this->decryptIV; |
702 | 702 | } else { |
@@ -715,11 +715,11 @@ discard block |
||
715 | 715 | $start = 0; |
716 | 716 | } |
717 | 717 | |
718 | - for ($i = $start; $i < strlen($ciphertext); $i+=8) { |
|
718 | + for ($i = $start; $i < strlen($ciphertext); $i += 8) { |
|
719 | 719 | $block = substr($ciphertext, $i, 8); |
720 | - $plaintext.= $block ^ $xor; |
|
720 | + $plaintext .= $block ^ $xor; |
|
721 | 721 | if ($continuousBuffer && strlen($block) != 8) { |
722 | - $buffer['ciphertext'].= $block; |
|
722 | + $buffer['ciphertext'] .= $block; |
|
723 | 723 | $block = $xor; |
724 | 724 | } else if (strlen($block) == 8) { |
725 | 725 | $xor = $des[0]->_processBlock($block, CRYPT_DES_ENCRYPT); |
@@ -734,30 +734,30 @@ discard block |
||
734 | 734 | case CRYPT_DES_MODE_OFB: |
735 | 735 | $xor = $this->decryptIV; |
736 | 736 | if (strlen($buffer['xor'])) { |
737 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
737 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
738 | 738 | $block = substr($ciphertext, $i, 8); |
739 | 739 | if (strlen($block) > strlen($buffer['xor'])) { |
740 | 740 | $xor = $des[0]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
741 | 741 | $xor = $des[1]->_processBlock($xor, CRYPT_DES_DECRYPT); |
742 | 742 | $xor = $des[2]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
743 | - $buffer['xor'].= $xor; |
|
743 | + $buffer['xor'] .= $xor; |
|
744 | 744 | } |
745 | 745 | $key = $this->_string_shift($buffer['xor']); |
746 | - $plaintext.= $block ^ $key; |
|
746 | + $plaintext .= $block ^ $key; |
|
747 | 747 | } |
748 | 748 | } else { |
749 | - for ($i = 0; $i < strlen($ciphertext); $i+=8) { |
|
749 | + for ($i = 0; $i < strlen($ciphertext); $i += 8) { |
|
750 | 750 | $xor = $des[0]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
751 | 751 | $xor = $des[1]->_processBlock($xor, CRYPT_DES_DECRYPT); |
752 | 752 | $xor = $des[2]->_processBlock($xor, CRYPT_DES_ENCRYPT); |
753 | - $plaintext.= substr($ciphertext, $i, 8) ^ $xor; |
|
753 | + $plaintext .= substr($ciphertext, $i, 8) ^ $xor; |
|
754 | 754 | } |
755 | 755 | $key = $xor; |
756 | 756 | } |
757 | 757 | if ($this->continuousBuffer) { |
758 | 758 | $this->decryptIV = $xor; |
759 | 759 | if ($start = strlen($ciphertext) & 7) { |
760 | - $buffer['xor'] = substr($key, $start) . $buffer['xor']; |
|
760 | + $buffer['xor'] = substr($key, $start).$buffer['xor']; |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | } |
@@ -563,6 +563,7 @@ discard block |
||
563 | 563 | * If not explictly set, CRYPT_TWOFISH_MODE_CBC will be used. |
564 | 564 | * |
565 | 565 | * @param optional Integer $mode |
566 | + * @param integer $mode |
|
566 | 567 | * @access public |
567 | 568 | */ |
568 | 569 | function Crypt_Twofish($mode = CRYPT_TWOFISH_MODE_CBC) |
@@ -1072,6 +1073,7 @@ discard block |
||
1072 | 1073 | * |
1073 | 1074 | * @see Crypt_Twofish::_unpad() |
1074 | 1075 | * @access private |
1076 | + * @param string $text |
|
1075 | 1077 | */ |
1076 | 1078 | function _pad($text) |
1077 | 1079 | { |
@@ -1099,6 +1101,7 @@ discard block |
||
1099 | 1101 | * |
1100 | 1102 | * @see Crypt_Twofish::_pad() |
1101 | 1103 | * @access private |
1104 | + * @param string $text |
|
1102 | 1105 | */ |
1103 | 1106 | function _unpad($text) |
1104 | 1107 | { |
@@ -678,13 +678,13 @@ discard block |
||
678 | 678 | list ($s3, $s2, $s1, $s0) = $this->mds_rem($le_longs[3], $le_longs[4]); |
679 | 679 | for ($i = 0, $j = 1; $i < 40; $i+= 2,$j+= 2) { |
680 | 680 | $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^ |
681 | - $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ |
|
682 | - $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ |
|
683 | - $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]]; |
|
681 | + $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ |
|
682 | + $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ |
|
683 | + $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]]; |
|
684 | 684 | $B = $m0[$q0[$q0[$j] ^ $key[13]] ^ $key[5]] ^ |
685 | - $m1[$q0[$q1[$j] ^ $key[14]] ^ $key[6]] ^ |
|
686 | - $m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] ^ |
|
687 | - $m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]]; |
|
685 | + $m1[$q0[$q1[$j] ^ $key[14]] ^ $key[6]] ^ |
|
686 | + $m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] ^ |
|
687 | + $m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]]; |
|
688 | 688 | $B = ($B << 8) | ($B >> 24 & 0xff); |
689 | 689 | $K[] = $A+= $B; |
690 | 690 | $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
@@ -702,13 +702,13 @@ discard block |
||
702 | 702 | list ($s3, $s2, $s1, $s0) = $this->mds_rem($le_longs[5], $le_longs[6]); |
703 | 703 | for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
704 | 704 | $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
705 | - $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
|
706 | - $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
|
707 | - $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
|
705 | + $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
|
706 | + $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
|
707 | + $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
|
708 | 708 | $B = $m0[$q0[$q0[$q1[$j] ^ $key[21]] ^ $key[13]] ^ $key[5]] ^ |
709 | - $m1[$q0[$q1[$q1[$j] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ |
|
710 | - $m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
|
711 | - $m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
|
709 | + $m1[$q0[$q1[$q1[$j] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ |
|
710 | + $m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
|
711 | + $m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
|
712 | 712 | $B = ($B << 8) | ($B >> 24 & 0xff); |
713 | 713 | $K[] = $A+= $B; |
714 | 714 | $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
@@ -727,13 +727,13 @@ discard block |
||
727 | 727 | list ($s3, $s2, $s1, $s0) = $this->mds_rem($le_longs[7], $le_longs[8]); |
728 | 728 | for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
729 | 729 | $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
730 | - $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
|
731 | - $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
|
732 | - $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
|
730 | + $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
|
731 | + $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
|
732 | + $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
|
733 | 733 | $B = $m0[$q0[$q0[$q1[$q1[$j] ^ $key[29]] ^ $key[21]] ^ $key[13]] ^ $key[5]] ^ |
734 | - $m1[$q0[$q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ |
|
735 | - $m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
|
736 | - $m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
|
734 | + $m1[$q0[$q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ |
|
735 | + $m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
|
736 | + $m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
|
737 | 737 | $B = ($B << 8) | ($B >> 24 & 0xff); |
738 | 738 | $K[] = $A+= $B; |
739 | 739 | $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @var Array |
277 | 277 | * @access private |
278 | 278 | */ |
279 | - var $q0 = array ( |
|
279 | + var $q0 = array( |
|
280 | 280 | 0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, |
281 | 281 | 0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38, |
282 | 282 | 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C, |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @var Array |
318 | 318 | * @access private |
319 | 319 | */ |
320 | - var $q1 = array ( |
|
320 | + var $q1 = array( |
|
321 | 321 | 0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, |
322 | 322 | 0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, 0x4B, |
323 | 323 | 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1, |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @var Array |
359 | 359 | * @access private |
360 | 360 | */ |
361 | - var $m0 = array ( |
|
361 | + var $m0 = array( |
|
362 | 362 | 0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B, 0xE2E22BFB, 0x9E9EFAC8, |
363 | 363 | 0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B, 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B, |
364 | 364 | 0x3C3C57D6, 0x93938A32, 0x8282EED8, 0x525298FD, 0x7B7BD437, 0xBBBB3771, 0x5B5B97F1, 0x474783E1, |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @var Array |
400 | 400 | * @access private |
401 | 401 | */ |
402 | - var $m1 = array ( |
|
402 | + var $m1 = array( |
|
403 | 403 | 0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252, 0xA3658080, 0x76DFE4E4, |
404 | 404 | 0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A, 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A, |
405 | 405 | 0x0D54E6E6, 0xC6432020, 0x3562CCCC, 0x98BEF2F2, 0x181E1212, 0xF724EBEB, 0xECD7A1A1, 0x6C774141, |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @var Array |
441 | 441 | * @access private |
442 | 442 | */ |
443 | - var $m2 = array ( |
|
443 | + var $m2 = array( |
|
444 | 444 | 0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B, 0xE2FBE22B, 0x9EC89EFA, |
445 | 445 | 0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F, 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7, |
446 | 446 | 0x3CD63C57, 0x9332938A, 0x82D882EE, 0x52FD5298, 0x7B377BD4, 0xBB71BB37, 0x5BF15B97, 0x47E14783, |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | * @var Array |
482 | 482 | * @access private |
483 | 483 | */ |
484 | - var $m3 = array ( |
|
484 | + var $m3 = array( |
|
485 | 485 | 0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98, 0x6580A365, 0xDFE476DF, |
486 | 486 | 0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866, 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836, |
487 | 487 | 0x54E60D54, 0x4320C643, 0x62CC3562, 0xBEF298BE, 0x1E12181E, 0x24EBF724, 0xD7A1ECD7, 0x77416C77, |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | */ |
568 | 568 | function Crypt_Twofish($mode = CRYPT_TWOFISH_MODE_CBC) |
569 | 569 | { |
570 | - if ( !defined('CRYPT_TWOFISH_MODE') ) { |
|
570 | + if (!defined('CRYPT_TWOFISH_MODE')) { |
|
571 | 571 | switch (true) { |
572 | 572 | case extension_loaded('mcrypt') && in_array('twofish', mcrypt_list_algorithms()): |
573 | 573 | define('CRYPT_TWOFISH_MODE', CRYPT_TWOFISH_MODE_MCRYPT); |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | } |
578 | 578 | } |
579 | 579 | |
580 | - switch ( CRYPT_TWOFISH_MODE ) { |
|
580 | + switch (CRYPT_TWOFISH_MODE) { |
|
581 | 581 | case CRYPT_TWOFISH_MODE_MCRYPT: |
582 | 582 | switch ($mode) { |
583 | 583 | case CRYPT_TWOFISH_MODE_ECB: |
@@ -640,13 +640,13 @@ discard block |
||
640 | 640 | $keylength = strlen($key); |
641 | 641 | switch (true) { |
642 | 642 | case $keylength <= 16: |
643 | - $key.= str_repeat("\0", 16 - $keylength); |
|
643 | + $key .= str_repeat("\0", 16 - $keylength); |
|
644 | 644 | break; |
645 | 645 | case $keylength <= 24: |
646 | - $key.= str_repeat("\0", 24 - $keylength); |
|
646 | + $key .= str_repeat("\0", 24 - $keylength); |
|
647 | 647 | break; |
648 | 648 | case $keylength <= 32: |
649 | - $key.= str_repeat("\0", 32 - $keylength); |
|
649 | + $key .= str_repeat("\0", 32 - $keylength); |
|
650 | 650 | break; |
651 | 651 | default: |
652 | 652 | $key = substr($key, 0, 32); |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | case 16: |
677 | 677 | list ($s7, $s6, $s5, $s4) = $this->mds_rem($le_longs[1], $le_longs[2]); |
678 | 678 | list ($s3, $s2, $s1, $s0) = $this->mds_rem($le_longs[3], $le_longs[4]); |
679 | - for ($i = 0, $j = 1; $i < 40; $i+= 2,$j+= 2) { |
|
680 | - $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^ |
|
679 | + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { |
|
680 | + $A = $m0[$q0[$q0[$i] ^ $key[9]] ^ $key[1]] ^ |
|
681 | 681 | $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ |
682 | 682 | $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ |
683 | 683 | $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]]; |
@@ -686,8 +686,8 @@ discard block |
||
686 | 686 | $m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] ^ |
687 | 687 | $m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]]; |
688 | 688 | $B = ($B << 8) | ($B >> 24 & 0xff); |
689 | - $K[] = $A+= $B; |
|
690 | - $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
|
689 | + $K[] = $A += $B; |
|
690 | + $K[] = (($A += $B) << 9 | $A >> 23 & 0x1ff); |
|
691 | 691 | } |
692 | 692 | for ($i = 0; $i < 256; ++$i) { |
693 | 693 | $S0[$i] = $m0[$q0[$q0[$i] ^ $s4] ^ $s0]; |
@@ -700,8 +700,8 @@ discard block |
||
700 | 700 | list ($sb, $sa, $s9, $s8) = $this->mds_rem($le_longs[1], $le_longs[2]); |
701 | 701 | list ($s7, $s6, $s5, $s4) = $this->mds_rem($le_longs[3], $le_longs[4]); |
702 | 702 | list ($s3, $s2, $s1, $s0) = $this->mds_rem($le_longs[5], $le_longs[6]); |
703 | - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
|
704 | - $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
|
703 | + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { |
|
704 | + $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[9]] ^ $key[1]] ^ |
|
705 | 705 | $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
706 | 706 | $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
707 | 707 | $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
@@ -710,8 +710,8 @@ discard block |
||
710 | 710 | $m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
711 | 711 | $m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
712 | 712 | $B = ($B << 8) | ($B >> 24 & 0xff); |
713 | - $K[] = $A+= $B; |
|
714 | - $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
|
713 | + $K[] = $A += $B; |
|
714 | + $K[] = (($A += $B) << 9 | $A >> 23 & 0x1ff); |
|
715 | 715 | } |
716 | 716 | for ($i = 0; $i < 256; ++$i) { |
717 | 717 | $S0[$i] = $m0[$q0[$q0[$q1[$i] ^ $s8] ^ $s4] ^ $s0]; |
@@ -725,8 +725,8 @@ discard block |
||
725 | 725 | list ($sb, $sa, $s9, $s8) = $this->mds_rem($le_longs[3], $le_longs[4]); |
726 | 726 | list ($s7, $s6, $s5, $s4) = $this->mds_rem($le_longs[5], $le_longs[6]); |
727 | 727 | list ($s3, $s2, $s1, $s0) = $this->mds_rem($le_longs[7], $le_longs[8]); |
728 | - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { |
|
729 | - $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ |
|
728 | + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { |
|
729 | + $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[9]] ^ $key[1]] ^ |
|
730 | 730 | $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ |
731 | 731 | $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ |
732 | 732 | $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]]; |
@@ -735,8 +735,8 @@ discard block |
||
735 | 735 | $m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ |
736 | 736 | $m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]]; |
737 | 737 | $B = ($B << 8) | ($B >> 24 & 0xff); |
738 | - $K[] = $A+= $B; |
|
739 | - $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); |
|
738 | + $K[] = $A += $B; |
|
739 | + $K[] = (($A += $B) << 9 | $A >> 23 & 0x1ff); |
|
740 | 740 | } |
741 | 741 | for ($i = 0; $i < 256; ++$i) { |
742 | 742 | $S0[$i] = $m0[$q0[$q0[$q1[$q1[$i] ^ $sc] ^ $s8] ^ $s4] ^ $s0]; |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | |
771 | 771 | switch ($method) { |
772 | 772 | default: // 'pbkdf2' |
773 | - list(, , $hash, $salt, $count) = func_get_args(); |
|
773 | + list(,, $hash, $salt, $count) = func_get_args(); |
|
774 | 774 | if (!isset($hash)) { |
775 | 775 | $hash = 'sha1'; |
776 | 776 | } |
@@ -793,12 +793,12 @@ discard block |
||
793 | 793 | $hmac = new Crypt_Hash(); |
794 | 794 | $hmac->setHash($hash); |
795 | 795 | $hmac->setKey($password); |
796 | - $f = $u = $hmac->hash($salt . pack('N', $i++)); |
|
796 | + $f = $u = $hmac->hash($salt.pack('N', $i++)); |
|
797 | 797 | for ($j = 2; $j <= $count; ++$j) { |
798 | 798 | $u = $hmac->hash($u); |
799 | - $f^= $u; |
|
799 | + $f ^= $u; |
|
800 | 800 | } |
801 | - $key.= $f; |
|
801 | + $key .= $f; |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | */ |
841 | 841 | function encrypt($plaintext) |
842 | 842 | { |
843 | - if ( CRYPT_TWOFISH_MODE == CRYPT_TWOFISH_MODE_MCRYPT ) { |
|
843 | + if (CRYPT_TWOFISH_MODE == CRYPT_TWOFISH_MODE_MCRYPT) { |
|
844 | 844 | if ($this->paddable) { |
845 | 845 | $plaintext = $this->_pad($plaintext); |
846 | 846 | } |
@@ -866,11 +866,11 @@ discard block |
||
866 | 866 | $max = 16 - $pos; |
867 | 867 | if ($len >= $max) { |
868 | 868 | $i = $max; |
869 | - $len-= $max; |
|
869 | + $len -= $max; |
|
870 | 870 | $pos = 0; |
871 | 871 | } else { |
872 | 872 | $i = $len; |
873 | - $pos+= $len; |
|
873 | + $pos += $len; |
|
874 | 874 | $len = 0; |
875 | 875 | } |
876 | 876 | $ciphertext = substr($iv, $orig_pos) ^ $plaintext; |
@@ -883,15 +883,15 @@ discard block |
||
883 | 883 | mcrypt_generic_init($this->enmcrypt, $this->key, $iv); |
884 | 884 | $this->enbuffer['enmcrypt_init'] = false; |
885 | 885 | } |
886 | - $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 16)); |
|
886 | + $ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 16)); |
|
887 | 887 | $iv = substr($ciphertext, -16); |
888 | - $len%= 16; |
|
888 | + $len %= 16; |
|
889 | 889 | } else { |
890 | 890 | while ($len >= 16) { |
891 | 891 | $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, 16); |
892 | - $ciphertext.= $iv; |
|
893 | - $len-= 16; |
|
894 | - $i+= 16; |
|
892 | + $ciphertext .= $iv; |
|
893 | + $len -= 16; |
|
894 | + $i += 16; |
|
895 | 895 | } |
896 | 896 | } |
897 | 897 | } |
@@ -899,7 +899,7 @@ discard block |
||
899 | 899 | $iv = mcrypt_generic($this->ecb, $iv); |
900 | 900 | $block = $iv ^ substr($plaintext, -$len); |
901 | 901 | $iv = substr_replace($iv, $block, 0, $len); |
902 | - $ciphertext.= $block; |
|
902 | + $ciphertext .= $block; |
|
903 | 903 | $pos = $len; |
904 | 904 | } |
905 | 905 | return $ciphertext; |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | */ |
932 | 932 | function decrypt($ciphertext) |
933 | 933 | { |
934 | - if ( CRYPT_TWOFISH_MODE == CRYPT_TWOFISH_MODE_MCRYPT ) { |
|
934 | + if (CRYPT_TWOFISH_MODE == CRYPT_TWOFISH_MODE_MCRYPT) { |
|
935 | 935 | if ($this->paddable) { |
936 | 936 | // we pad with chr(0) since that's what mcrypt_generic does. to quote from http://php.net/function.mcrypt-generic : |
937 | 937 | // "The data is padded with "\0" to make sure the length of the data is n * blocksize." |
@@ -959,11 +959,11 @@ discard block |
||
959 | 959 | $max = 16 - $pos; |
960 | 960 | if ($len >= $max) { |
961 | 961 | $i = $max; |
962 | - $len-= $max; |
|
962 | + $len -= $max; |
|
963 | 963 | $pos = 0; |
964 | 964 | } else { |
965 | 965 | $i = $len; |
966 | - $pos+= $len; |
|
966 | + $pos += $len; |
|
967 | 967 | $len = 0; |
968 | 968 | } |
969 | 969 | $plaintext = substr($iv, $orig_pos) ^ $ciphertext; |
@@ -971,13 +971,13 @@ discard block |
||
971 | 971 | } |
972 | 972 | if ($len >= 16) { |
973 | 973 | $cb = substr($ciphertext, $i, $len - $len % 16); |
974 | - $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; |
|
974 | + $plaintext .= mcrypt_generic($this->ecb, $iv.$cb) ^ $cb; |
|
975 | 975 | $iv = substr($cb, -16); |
976 | - $len%= 16; |
|
976 | + $len %= 16; |
|
977 | 977 | } |
978 | 978 | if ($len) { |
979 | 979 | $iv = mcrypt_generic($this->ecb, $iv); |
980 | - $plaintext.= $iv ^ substr($ciphertext, -$len); |
|
980 | + $plaintext .= $iv ^ substr($ciphertext, -$len); |
|
981 | 981 | $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); |
982 | 982 | $pos = $len; |
983 | 983 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | function _generate_xor(&$iv) |
1146 | 1146 | { |
1147 | 1147 | $xor = $iv; |
1148 | - for ($j = 4; $j <= 16; $j+=4) { |
|
1148 | + for ($j = 4; $j <= 16; $j += 4) { |
|
1149 | 1149 | $temp = substr($iv, -$j, 4); |
1150 | 1150 | switch ($temp) { |
1151 | 1151 | case "\xFF\xFF\xFF\xFF": |
@@ -1181,32 +1181,32 @@ discard block |
||
1181 | 1181 | |
1182 | 1182 | // Shift the others up. |
1183 | 1183 | $B = ($B << 8) | (0xff & ($A >> 24)); |
1184 | - $A<<= 8; |
|
1184 | + $A <<= 8; |
|
1185 | 1185 | |
1186 | 1186 | $u = $t << 1; |
1187 | 1187 | |
1188 | 1188 | // Subtract the modular polynomial on overflow. |
1189 | 1189 | if ($t & 0x80) { |
1190 | - $u^= 0x14d; |
|
1190 | + $u ^= 0x14d; |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | // Remove t * (a * x^2 + 1). |
1194 | 1194 | $B ^= $t ^ ($u << 16); |
1195 | 1195 | |
1196 | 1196 | // Form u = a*t + t/a = t*(a + 1/a). |
1197 | - $u^= 0x7fffffff & ($t >> 1); |
|
1197 | + $u ^= 0x7fffffff & ($t >> 1); |
|
1198 | 1198 | |
1199 | 1199 | // Add the modular polynomial on underflow. |
1200 | - if ($t & 0x01) $u^= 0xa6 ; |
|
1200 | + if ($t & 0x01) $u ^= 0xa6; |
|
1201 | 1201 | |
1202 | 1202 | // Remove t * (a + 1/a) * (x^3 + x). |
1203 | - $B^= ($u << 24) | ($u << 8); |
|
1203 | + $B ^= ($u << 24) | ($u << 8); |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | return array( |
1207 | 1207 | 0xff & $B >> 24, |
1208 | 1208 | 0xff & $B >> 16, |
1209 | - 0xff & $B >> 8, |
|
1209 | + 0xff & $B >> 8, |
|
1210 | 1210 | 0xff & $B); |
1211 | 1211 | } |
1212 | 1212 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | */ |
1218 | 1218 | function inline_crypt_setup() |
1219 | 1219 | { |
1220 | - $lambda_functions =& Crypt_Twofish::get_lambda_functions(); |
|
1220 | + $lambda_functions = & Crypt_Twofish::get_lambda_functions(); |
|
1221 | 1221 | $block_size = 16; |
1222 | 1222 | $mode = $this->mode; |
1223 | 1223 | $code_hash = "$mode"; |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | $R3 = $K_3 ^ $in[4]; |
1241 | 1241 | '; |
1242 | 1242 | for ($ki = 7, $i = 0; $i < 8; ++$i) { |
1243 | - $_encryptBlock.= ' |
|
1243 | + $_encryptBlock .= ' |
|
1244 | 1244 | $t0 = $S0[ $R0 & 0xff] ^ |
1245 | 1245 | $S1[($R0 >> 8) & 0xff] ^ |
1246 | 1246 | $S2[($R0 >> 16) & 0xff] ^ |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + $K_'.(++$ki).'); |
1267 | 1267 | '; |
1268 | 1268 | } |
1269 | - $_encryptBlock.= ' |
|
1269 | + $_encryptBlock .= ' |
|
1270 | 1270 | $in = pack("V4", $K_4 ^ $R2, |
1271 | 1271 | $K_5 ^ $R3, |
1272 | 1272 | $K_6 ^ $R0, |
@@ -1282,7 +1282,7 @@ discard block |
||
1282 | 1282 | $R3 = $K_7 ^ $in[4]; |
1283 | 1283 | '; |
1284 | 1284 | for ($ki = 40, $i = 0; $i < 8; ++$i) { |
1285 | - $_decryptBlock.= ' |
|
1285 | + $_decryptBlock .= ' |
|
1286 | 1286 | $t0 = $S0[$R0 & 0xff] ^ |
1287 | 1287 | $S1[$R0 >> 8 & 0xff] ^ |
1288 | 1288 | $S2[$R0 >> 16 & 0xff] ^ |
@@ -1308,7 +1308,7 @@ discard block |
||
1308 | 1308 | $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ($t0 + $t1 + $K_'.(--$ki).'); |
1309 | 1309 | '; |
1310 | 1310 | } |
1311 | - $_decryptBlock.= ' |
|
1311 | + $_decryptBlock .= ' |
|
1312 | 1312 | $in = pack("V4", $K_0 ^ $R2, |
1313 | 1313 | $K_1 ^ $R3, |
1314 | 1314 | $K_2 ^ $R0, |
@@ -1635,12 +1635,12 @@ discard block |
||
1635 | 1635 | break; |
1636 | 1636 | } |
1637 | 1637 | $fnc_head = '$action, &$self, $text'; |
1638 | - $fnc_body = $init_cryptBlock . 'if ($action == "encrypt") { ' . $encrypt . ' } else { ' . $decrypt . ' }'; |
|
1638 | + $fnc_body = $init_cryptBlock.'if ($action == "encrypt") { '.$encrypt.' } else { '.$decrypt.' }'; |
|
1639 | 1639 | |
1640 | 1640 | if (function_exists('create_function') && is_callable('create_function')) { |
1641 | 1641 | $lambda_functions[$code_hash] = create_function($fnc_head, $fnc_body); |
1642 | 1642 | } else { |
1643 | - eval('function ' . ($lambda_functions[$code_hash] = 'f' . md5(microtime())) . '(' . $fnc_head . ') { ' . $fnc_body . ' }'); |
|
1643 | + eval('function '.($lambda_functions[$code_hash] = 'f'.md5(microtime())).'('.$fnc_head.') { '.$fnc_body.' }'); |
|
1644 | 1644 | } |
1645 | 1645 | } |
1646 | 1646 | $this->inline_crypt = $lambda_functions[$code_hash]; |
@@ -1197,7 +1197,9 @@ |
||
1197 | 1197 | $u^= 0x7fffffff & ($t >> 1); |
1198 | 1198 | |
1199 | 1199 | // Add the modular polynomial on underflow. |
1200 | - if ($t & 0x01) $u^= 0xa6 ; |
|
1200 | + if ($t & 0x01) { |
|
1201 | + $u^= 0xa6 ; |
|
1202 | + } |
|
1201 | 1203 | |
1202 | 1204 | // Remove t * (a + 1/a) * (x^3 + x). |
1203 | 1205 | $B^= ($u << 24) | ($u << 8); |
@@ -250,9 +250,8 @@ |
||
250 | 250 | /** |
251 | 251 | * Set the number of lines that should be logged past the terminal height |
252 | 252 | * |
253 | - * @param Integer $x |
|
254 | - * @param Integer $y |
|
255 | 253 | * @access public |
254 | + * @param integer $history |
|
256 | 255 | */ |
257 | 256 | function setHistory($history) |
258 | 257 | { |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | { |
282 | 282 | for ($i = 0; $i < strlen($source); $i++) { |
283 | 283 | if (strlen($this->ansi)) { |
284 | - $this->ansi.= $source[$i]; |
|
284 | + $this->ansi .= $source[$i]; |
|
285 | 285 | $chr = ord($source[$i]); |
286 | 286 | // http://en.wikipedia.org/wiki/ANSI_escape_code#Sequence_elements |
287 | 287 | // single character CSI's not currently supported |
@@ -350,10 +350,10 @@ discard block |
||
350 | 350 | case 0: // Turn off character attributes |
351 | 351 | $this->attrs[$this->y][$this->x] = ''; |
352 | 352 | |
353 | - if ($this->bold) $this->attrs[$this->y][$this->x].= '</b>'; |
|
354 | - if ($this->underline) $this->attrs[$this->y][$this->x].= '</underline>'; |
|
355 | - if ($this->blink) $this->attrs[$this->y][$this->x].= '</blink>'; |
|
356 | - if ($this->color) $this->attrs[$this->y][$this->x].= '</span>'; |
|
353 | + if ($this->bold) $this->attrs[$this->y][$this->x] .= '</b>'; |
|
354 | + if ($this->underline) $this->attrs[$this->y][$this->x] .= '</underline>'; |
|
355 | + if ($this->blink) $this->attrs[$this->y][$this->x] .= '</blink>'; |
|
356 | + if ($this->color) $this->attrs[$this->y][$this->x] .= '</span>'; |
|
357 | 357 | |
358 | 358 | if ($this->reverse) { |
359 | 359 | $temp = $this->background; |
@@ -386,9 +386,9 @@ discard block |
||
386 | 386 | $temp = $this->background; |
387 | 387 | $this->background = $this->foreground; |
388 | 388 | $this->foreground = $temp; |
389 | - $this->attrs[$this->y][$this->x] = '<span style="color: ' . $this->foreground . '; background: ' . $this->background . '">'; |
|
389 | + $this->attrs[$this->y][$this->x] = '<span style="color: '.$this->foreground.'; background: '.$this->background.'">'; |
|
390 | 390 | if ($this->color) { |
391 | - $this->attrs[$this->y][$this->x] = '</span>' . $this->attrs[$this->y][$this->x]; |
|
391 | + $this->attrs[$this->y][$this->x] = '</span>'.$this->attrs[$this->y][$this->x]; |
|
392 | 392 | } |
393 | 393 | $this->color = true; |
394 | 394 | break; |
@@ -417,15 +417,15 @@ discard block |
||
417 | 417 | case 47: $back = 'white'; break; |
418 | 418 | |
419 | 419 | default: |
420 | - user_error('Unsupported attribute: ' . $mod); |
|
420 | + user_error('Unsupported attribute: '.$mod); |
|
421 | 421 | $this->ansi = ''; |
422 | 422 | break 2; |
423 | 423 | } |
424 | 424 | |
425 | 425 | unset($temp); |
426 | - $this->attrs[$this->y][$this->x] = '<span style="color: ' . $this->foreground . '; background: ' . $this->background . '">'; |
|
426 | + $this->attrs[$this->y][$this->x] = '<span style="color: '.$this->foreground.'; background: '.$this->background.'">'; |
|
427 | 427 | if ($this->color) { |
428 | - $this->attrs[$this->y][$this->x] = '</span>' . $this->attrs[$this->y][$this->x]; |
|
428 | + $this->attrs[$this->y][$this->x] = '</span>'.$this->attrs[$this->y][$this->x]; |
|
429 | 429 | } |
430 | 430 | $this->color = true; |
431 | 431 | } |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | case "\x0F": // shift |
450 | 450 | break; |
451 | 451 | case "\x1B": // start ANSI escape code |
452 | - $this->ansi.= "\x1B"; |
|
452 | + $this->ansi .= "\x1B"; |
|
453 | 453 | break; |
454 | 454 | default: |
455 | 455 | $this->screen[$this->y] = substr_replace( |
@@ -511,13 +511,13 @@ discard block |
||
511 | 511 | for ($i = 0; $i <= $this->max_y; $i++) { |
512 | 512 | for ($j = 0; $j <= $this->max_x + 1; $j++) { |
513 | 513 | if (isset($this->attrs[$i][$j])) { |
514 | - $output.= $this->attrs[$i][$j]; |
|
514 | + $output .= $this->attrs[$i][$j]; |
|
515 | 515 | } |
516 | 516 | if (isset($this->screen[$i][$j])) { |
517 | - $output.= htmlspecialchars($this->screen[$i][$j]); |
|
517 | + $output .= htmlspecialchars($this->screen[$i][$j]); |
|
518 | 518 | } |
519 | 519 | } |
520 | - $output.= "\r\n"; |
|
520 | + $output .= "\r\n"; |
|
521 | 521 | } |
522 | 522 | return rtrim($output); |
523 | 523 | } |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | */ |
531 | 531 | function getScreen() |
532 | 532 | { |
533 | - return '<pre style="color: white; background: black" width="' . ($this->max_x + 1) . '">' . $this->_getScreen() . '</pre>'; |
|
533 | + return '<pre style="color: white; background: black" width="'.($this->max_x + 1).'">'.$this->_getScreen().'</pre>'; |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -545,16 +545,16 @@ discard block |
||
545 | 545 | for ($i = 0; $i < count($this->history); $i++) { |
546 | 546 | for ($j = 0; $j <= $this->max_x + 1; $j++) { |
547 | 547 | if (isset($this->history_attrs[$i][$j])) { |
548 | - $scrollback.= $this->history_attrs[$i][$j]; |
|
548 | + $scrollback .= $this->history_attrs[$i][$j]; |
|
549 | 549 | } |
550 | 550 | if (isset($this->history[$i][$j])) { |
551 | - $scrollback.= htmlspecialchars($this->history[$i][$j]); |
|
551 | + $scrollback .= htmlspecialchars($this->history[$i][$j]); |
|
552 | 552 | } |
553 | 553 | } |
554 | - $scrollback.= "\r\n"; |
|
554 | + $scrollback .= "\r\n"; |
|
555 | 555 | } |
556 | - $scrollback.= $this->_getScreen(); |
|
556 | + $scrollback .= $this->_getScreen(); |
|
557 | 557 | |
558 | - return '<pre style="color: white; background: black" width="' . ($this->max_x + 1) . '">' . $scrollback . '</pre>'; |
|
558 | + return '<pre style="color: white; background: black" width="'.($this->max_x + 1).'">'.$scrollback.'</pre>'; |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | \ No newline at end of file |
@@ -350,10 +350,18 @@ |
||
350 | 350 | case 0: // Turn off character attributes |
351 | 351 | $this->attrs[$this->y][$this->x] = ''; |
352 | 352 | |
353 | - if ($this->bold) $this->attrs[$this->y][$this->x].= '</b>'; |
|
354 | - if ($this->underline) $this->attrs[$this->y][$this->x].= '</underline>'; |
|
355 | - if ($this->blink) $this->attrs[$this->y][$this->x].= '</blink>'; |
|
356 | - if ($this->color) $this->attrs[$this->y][$this->x].= '</span>'; |
|
353 | + if ($this->bold) { |
|
354 | + $this->attrs[$this->y][$this->x].= '</b>'; |
|
355 | + } |
|
356 | + if ($this->underline) { |
|
357 | + $this->attrs[$this->y][$this->x].= '</underline>'; |
|
358 | + } |
|
359 | + if ($this->blink) { |
|
360 | + $this->attrs[$this->y][$this->x].= '</blink>'; |
|
361 | + } |
|
362 | + if ($this->color) { |
|
363 | + $this->attrs[$this->y][$this->x].= '</span>'; |
|
364 | + } |
|
357 | 365 | |
358 | 366 | if ($this->reverse) { |
359 | 367 | $temp = $this->background; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * Serves a similar purpose to openssl's asn1parse |
264 | 264 | * |
265 | 265 | * @param String $encoded |
266 | - * @return Array |
|
266 | + * @return string |
|
267 | 267 | * @access public |
268 | 268 | */ |
269 | 269 | function decodeBER($encoded) |
@@ -776,7 +776,6 @@ discard block |
||
776 | 776 | * |
777 | 777 | * @param String $source |
778 | 778 | * @param String $mapping |
779 | - * @param Integer $idx |
|
780 | 779 | * @return String |
781 | 780 | * @access public |
782 | 781 | */ |
@@ -1095,7 +1094,7 @@ discard block |
||
1095 | 1094 | * @access private |
1096 | 1095 | * @param String $content |
1097 | 1096 | * @param Integer $tag |
1098 | - * @return String |
|
1097 | + * @return double |
|
1099 | 1098 | */ |
1100 | 1099 | function _decodeTime($content, $tag) |
1101 | 1100 | { |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | * @access private |
47 | 47 | * @link http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#page=12 |
48 | 48 | */ |
49 | -define('FILE_ASN1_CLASS_UNIVERSAL', 0); |
|
50 | -define('FILE_ASN1_CLASS_APPLICATION', 1); |
|
49 | +define('FILE_ASN1_CLASS_UNIVERSAL', 0); |
|
50 | +define('FILE_ASN1_CLASS_APPLICATION', 1); |
|
51 | 51 | define('FILE_ASN1_CLASS_CONTEXT_SPECIFIC', 2); |
52 | -define('FILE_ASN1_CLASS_PRIVATE', 3); |
|
52 | +define('FILE_ASN1_CLASS_PRIVATE', 3); |
|
53 | 53 | /**#@-*/ |
54 | 54 | |
55 | 55 | /**#@+ |
@@ -58,21 +58,21 @@ discard block |
||
58 | 58 | * @access private |
59 | 59 | * @link http://www.obj-sys.com/asn1tutorial/node124.html |
60 | 60 | */ |
61 | -define('FILE_ASN1_TYPE_BOOLEAN', 1); |
|
62 | -define('FILE_ASN1_TYPE_INTEGER', 2); |
|
63 | -define('FILE_ASN1_TYPE_BIT_STRING', 3); |
|
64 | -define('FILE_ASN1_TYPE_OCTET_STRING', 4); |
|
65 | -define('FILE_ASN1_TYPE_NULL', 5); |
|
66 | -define('FILE_ASN1_TYPE_OBJECT_IDENTIFIER',6); |
|
61 | +define('FILE_ASN1_TYPE_BOOLEAN', 1); |
|
62 | +define('FILE_ASN1_TYPE_INTEGER', 2); |
|
63 | +define('FILE_ASN1_TYPE_BIT_STRING', 3); |
|
64 | +define('FILE_ASN1_TYPE_OCTET_STRING', 4); |
|
65 | +define('FILE_ASN1_TYPE_NULL', 5); |
|
66 | +define('FILE_ASN1_TYPE_OBJECT_IDENTIFIER', 6); |
|
67 | 67 | //define('FILE_ASN1_TYPE_OBJECT_DESCRIPTOR',7); |
68 | 68 | //define('FILE_ASN1_TYPE_INSTANCE_OF', 8); // EXTERNAL |
69 | -define('FILE_ASN1_TYPE_REAL', 9); |
|
70 | -define('FILE_ASN1_TYPE_ENUMERATED', 10); |
|
69 | +define('FILE_ASN1_TYPE_REAL', 9); |
|
70 | +define('FILE_ASN1_TYPE_ENUMERATED', 10); |
|
71 | 71 | //define('FILE_ASN1_TYPE_EMBEDDED', 11); |
72 | -define('FILE_ASN1_TYPE_UTF8_STRING', 12); |
|
72 | +define('FILE_ASN1_TYPE_UTF8_STRING', 12); |
|
73 | 73 | //define('FILE_ASN1_TYPE_RELATIVE_OID', 13); |
74 | -define('FILE_ASN1_TYPE_SEQUENCE', 16); // SEQUENCE OF |
|
75 | -define('FILE_ASN1_TYPE_SET', 17); // SET OF |
|
74 | +define('FILE_ASN1_TYPE_SEQUENCE', 16); // SEQUENCE OF |
|
75 | +define('FILE_ASN1_TYPE_SET', 17); // SET OF |
|
76 | 76 | /**#@-*/ |
77 | 77 | /**#@+ |
78 | 78 | * More Tag Classes |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | * @access private |
81 | 81 | * @link http://www.obj-sys.com/asn1tutorial/node10.html |
82 | 82 | */ |
83 | -define('FILE_ASN1_TYPE_NUMERIC_STRING', 18); |
|
84 | -define('FILE_ASN1_TYPE_PRINTABLE_STRING',19); |
|
85 | -define('FILE_ASN1_TYPE_TELETEX_STRING', 20); // T61String |
|
83 | +define('FILE_ASN1_TYPE_NUMERIC_STRING', 18); |
|
84 | +define('FILE_ASN1_TYPE_PRINTABLE_STRING', 19); |
|
85 | +define('FILE_ASN1_TYPE_TELETEX_STRING', 20); // T61String |
|
86 | 86 | define('FILE_ASN1_TYPE_VIDEOTEX_STRING', 21); |
87 | -define('FILE_ASN1_TYPE_IA5_STRING', 22); |
|
88 | -define('FILE_ASN1_TYPE_UTC_TIME', 23); |
|
89 | -define('FILE_ASN1_TYPE_GENERALIZED_TIME',24); |
|
90 | -define('FILE_ASN1_TYPE_GRAPHIC_STRING', 25); |
|
91 | -define('FILE_ASN1_TYPE_VISIBLE_STRING', 26); // ISO646String |
|
92 | -define('FILE_ASN1_TYPE_GENERAL_STRING', 27); |
|
93 | -define('FILE_ASN1_TYPE_UNIVERSAL_STRING',28); |
|
87 | +define('FILE_ASN1_TYPE_IA5_STRING', 22); |
|
88 | +define('FILE_ASN1_TYPE_UTC_TIME', 23); |
|
89 | +define('FILE_ASN1_TYPE_GENERALIZED_TIME', 24); |
|
90 | +define('FILE_ASN1_TYPE_GRAPHIC_STRING', 25); |
|
91 | +define('FILE_ASN1_TYPE_VISIBLE_STRING', 26); // ISO646String |
|
92 | +define('FILE_ASN1_TYPE_GENERAL_STRING', 27); |
|
93 | +define('FILE_ASN1_TYPE_UNIVERSAL_STRING', 28); |
|
94 | 94 | //define('FILE_ASN1_TYPE_CHARACTER_STRING',29); |
95 | -define('FILE_ASN1_TYPE_BMP_STRING', 30); |
|
95 | +define('FILE_ASN1_TYPE_BMP_STRING', 30); |
|
96 | 96 | /**#@-*/ |
97 | 97 | |
98 | 98 | /**#@+ |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @access private |
104 | 104 | */ |
105 | -define('FILE_ASN1_TYPE_CHOICE', -1); |
|
106 | -define('FILE_ASN1_TYPE_ANY', -2); |
|
105 | +define('FILE_ASN1_TYPE_CHOICE', -1); |
|
106 | +define('FILE_ASN1_TYPE_ANY', -2); |
|
107 | 107 | /**#@-*/ |
108 | 108 | |
109 | 109 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | { |
293 | 293 | $decoded = array(); |
294 | 294 | |
295 | - while ( strlen($encoded) ) { |
|
295 | + while (strlen($encoded)) { |
|
296 | 296 | $current = array('start' => $start); |
297 | 297 | |
298 | 298 | $type = ord($this->_string_shift($encoded)); |
@@ -309,30 +309,30 @@ discard block |
||
309 | 309 | $tag <<= 7; |
310 | 310 | $tag |= ord($this->_string_shift($encoded)) & 0x7F; |
311 | 311 | $start++; |
312 | - } while ( $loop ); |
|
312 | + } while ($loop); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13 |
316 | 316 | $length = ord($this->_string_shift($encoded)); |
317 | 317 | $start++; |
318 | - if ( $length == 0x80 ) { // indefinite length |
|
318 | + if ($length == 0x80) { // indefinite length |
|
319 | 319 | // "[A sender shall] use the indefinite form (see 8.1.3.6) if the encoding is constructed and is not all |
320 | 320 | // immediately available." -- paragraph 8.1.3.2.c |
321 | 321 | //if ( !$constructed ) { |
322 | 322 | // return false; |
323 | 323 | //} |
324 | 324 | $length = strlen($encoded); |
325 | - } elseif ( $length & 0x80 ) { // definite length, long form |
|
325 | + } elseif ($length & 0x80) { // definite length, long form |
|
326 | 326 | // technically, the long form of the length can be represented by up to 126 octets (bytes), but we'll only |
327 | 327 | // support it up to four. |
328 | - $length&= 0x7F; |
|
328 | + $length &= 0x7F; |
|
329 | 329 | $temp = $this->_string_shift($encoded, $length); |
330 | 330 | // tags of indefinite length don't really have a header length; this length includes the tag |
331 | - $current+= array('headerlength' => $length + 2); |
|
332 | - $start+= $length; |
|
331 | + $current += array('headerlength' => $length + 2); |
|
332 | + $start += $length; |
|
333 | 333 | extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4))); |
334 | 334 | } else { |
335 | - $current+= array('headerlength' => 2); |
|
335 | + $current += array('headerlength' => 2); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | // End-of-content, see paragraphs 8.1.1.3, 8.1.3.2, 8.1.3.6, 8.1.5, and (for an example) 8.6.4.2 |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | 'content' => $constructed ? $this->_decode_ber($content, $start) : $content, |
362 | 362 | 'length' => $length + $start - $current['start'] |
363 | 363 | ) + $current; |
364 | - $start+= $length; |
|
364 | + $start += $length; |
|
365 | 365 | continue 2; |
366 | 366 | } |
367 | 367 | |
368 | - $current+= array('type' => $tag); |
|
368 | + $current += array('type' => $tag); |
|
369 | 369 | |
370 | 370 | // decode UNIVERSAL tags |
371 | 371 | switch ($tag) { |
@@ -390,20 +390,20 @@ discard block |
||
390 | 390 | $current['content'] = $content; |
391 | 391 | } else { |
392 | 392 | $temp = $this->_decode_ber($content, $start); |
393 | - $length-= strlen($content); |
|
393 | + $length -= strlen($content); |
|
394 | 394 | $last = count($temp) - 1; |
395 | 395 | for ($i = 0; $i < $last; $i++) { |
396 | 396 | // all subtags should be bit strings |
397 | 397 | //if ($temp[$i]['type'] != FILE_ASN1_TYPE_BIT_STRING) { |
398 | 398 | // return false; |
399 | 399 | //} |
400 | - $current['content'].= substr($temp[$i]['content'], 1); |
|
400 | + $current['content'] .= substr($temp[$i]['content'], 1); |
|
401 | 401 | } |
402 | 402 | // all subtags should be bit strings |
403 | 403 | //if ($temp[$last]['type'] != FILE_ASN1_TYPE_BIT_STRING) { |
404 | 404 | // return false; |
405 | 405 | //} |
406 | - $current['content'] = $temp[$last]['content'][0] . $current['content'] . substr($temp[$i]['content'], 1); |
|
406 | + $current['content'] = $temp[$last]['content'][0].$current['content'].substr($temp[$i]['content'], 1); |
|
407 | 407 | } |
408 | 408 | break; |
409 | 409 | case FILE_ASN1_TYPE_OCTET_STRING: |
@@ -411,13 +411,13 @@ discard block |
||
411 | 411 | $current['content'] = $content; |
412 | 412 | } else { |
413 | 413 | $temp = $this->_decode_ber($content, $start); |
414 | - $length-= strlen($content); |
|
414 | + $length -= strlen($content); |
|
415 | 415 | for ($i = 0, $size = count($temp); $i < $size; $i++) { |
416 | 416 | // all subtags should be octet strings |
417 | 417 | //if ($temp[$i]['type'] != FILE_ASN1_TYPE_OCTET_STRING) { |
418 | 418 | // return false; |
419 | 419 | //} |
420 | - $current['content'].= $temp[$i]['content']; |
|
420 | + $current['content'] .= $temp[$i]['content']; |
|
421 | 421 | } |
422 | 422 | // $length = |
423 | 423 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | $valuen <<= 7; |
443 | 443 | $valuen |= $temp & 0x7F; |
444 | 444 | if (~$temp & 0x80) { |
445 | - $current['content'].= ".$valuen"; |
|
445 | + $current['content'] .= ".$valuen"; |
|
446 | 446 | $valuen = 0; |
447 | 447 | } |
448 | 448 | } |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | |
489 | 489 | } |
490 | 490 | |
491 | - $start+= $length; |
|
491 | + $start += $length; |
|
492 | 492 | $decoded[] = $current + array('length' => $start - $current['start']); |
493 | 493 | } |
494 | 494 | |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | } |
621 | 621 | |
622 | 622 | // Fail mapping if all input items have not been consumed. |
623 | - return $i < $n? NULL: $map; |
|
623 | + return $i < $n ? NULL : $map; |
|
624 | 624 | |
625 | 625 | // the main diff between sets and sequences is the encapsulation of the foreach in another for loop |
626 | 626 | case FILE_ASN1_TYPE_SET: |
@@ -761,8 +761,7 @@ discard block |
||
761 | 761 | if (isset($mapping['mapping'])) { |
762 | 762 | $temp = (int) $temp->toString(); |
763 | 763 | return isset($mapping['mapping'][$temp]) ? |
764 | - $mapping['mapping'][$temp] : |
|
765 | - false; |
|
764 | + $mapping['mapping'][$temp] : false; |
|
766 | 765 | } |
767 | 766 | return $temp; |
768 | 767 | } |
@@ -815,7 +814,7 @@ discard block |
||
815 | 814 | switch ($tag) { |
816 | 815 | case FILE_ASN1_TYPE_SET: // Children order is not important, thus process in sequence. |
817 | 816 | case FILE_ASN1_TYPE_SEQUENCE: |
818 | - $tag|= 0x20; // set the constructed bit |
|
817 | + $tag |= 0x20; // set the constructed bit |
|
819 | 818 | $value = ''; |
820 | 819 | |
821 | 820 | // ignore the min and max |
@@ -827,7 +826,7 @@ discard block |
||
827 | 826 | if ($temp === false) { |
828 | 827 | return false; |
829 | 828 | } |
830 | - $value.= $temp; |
|
829 | + $value .= $temp; |
|
831 | 830 | } |
832 | 831 | break; |
833 | 832 | } |
@@ -864,13 +863,13 @@ discard block |
||
864 | 863 | */ |
865 | 864 | if (isset($child['explicit']) || $child['type'] == FILE_ASN1_TYPE_CHOICE) { |
866 | 865 | $subtag = chr((FILE_ASN1_CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']); |
867 | - $temp = $subtag . $this->_encodeLength(strlen($temp)) . $temp; |
|
866 | + $temp = $subtag.$this->_encodeLength(strlen($temp)).$temp; |
|
868 | 867 | } else { |
869 | 868 | $subtag = chr((FILE_ASN1_CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']); |
870 | - $temp = $subtag . substr($temp, 1); |
|
869 | + $temp = $subtag.substr($temp, 1); |
|
871 | 870 | } |
872 | 871 | } |
873 | - $value.= $temp; |
|
872 | + $value .= $temp; |
|
874 | 873 | } |
875 | 874 | break; |
876 | 875 | case FILE_ASN1_TYPE_CHOICE: |
@@ -898,10 +897,10 @@ discard block |
||
898 | 897 | if (isset($child['constant'])) { |
899 | 898 | if (isset($child['explicit']) || $child['type'] == FILE_ASN1_TYPE_CHOICE) { |
900 | 899 | $subtag = chr((FILE_ASN1_CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']); |
901 | - $temp = $subtag . $this->_encodeLength(strlen($temp)) . $temp; |
|
900 | + $temp = $subtag.$this->_encodeLength(strlen($temp)).$temp; |
|
902 | 901 | } else { |
903 | 902 | $subtag = chr((FILE_ASN1_CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']); |
904 | - $temp = $subtag . substr($temp, 1); |
|
903 | + $temp = $subtag.substr($temp, 1); |
|
905 | 904 | } |
906 | 905 | } |
907 | 906 | } |
@@ -934,8 +933,8 @@ discard block |
||
934 | 933 | case FILE_ASN1_TYPE_UTC_TIME: |
935 | 934 | case FILE_ASN1_TYPE_GENERALIZED_TIME: |
936 | 935 | $format = $mapping['type'] == FILE_ASN1_TYPE_UTC_TIME ? 'y' : 'Y'; |
937 | - $format.= 'mdHis'; |
|
938 | - $value = @gmdate($format, strtotime($source)) . 'Z'; |
|
936 | + $format .= 'mdHis'; |
|
937 | + $value = @gmdate($format, strtotime($source)).'Z'; |
|
939 | 938 | break; |
940 | 939 | case FILE_ASN1_TYPE_BIT_STRING: |
941 | 940 | if (isset($mapping['mapping'])) { |
@@ -960,7 +959,7 @@ discard block |
||
960 | 959 | $bits = implode('', array_pad($bits, $size + $offset + 1, 0)); |
961 | 960 | $bytes = explode(' ', rtrim(chunk_split($bits, 8, ' '))); |
962 | 961 | foreach ($bytes as $byte) { |
963 | - $value.= chr(bindec($byte)); |
|
962 | + $value .= chr(bindec($byte)); |
|
964 | 963 | } |
965 | 964 | |
966 | 965 | break; |
@@ -987,12 +986,12 @@ discard block |
||
987 | 986 | $temp = "\0"; |
988 | 987 | } else { |
989 | 988 | while ($parts[$i]) { |
990 | - $temp = chr(0x80 | ($parts[$i] & 0x7F)) . $temp; |
|
989 | + $temp = chr(0x80 | ($parts[$i] & 0x7F)).$temp; |
|
991 | 990 | $parts[$i] >>= 7; |
992 | 991 | } |
993 | 992 | $temp[strlen($temp) - 1] = $temp[strlen($temp) - 1] & chr(0x7F); |
994 | 993 | } |
995 | - $value.= $temp; |
|
994 | + $value .= $temp; |
|
996 | 995 | } |
997 | 996 | break; |
998 | 997 | case FILE_ASN1_TYPE_ANY: |
@@ -1028,7 +1027,7 @@ discard block |
||
1028 | 1027 | $filters = $filters[$part]; |
1029 | 1028 | } |
1030 | 1029 | if ($filters === false) { |
1031 | - user_error('No filters defined for ' . implode('/', $loc)); |
|
1030 | + user_error('No filters defined for '.implode('/', $loc)); |
|
1032 | 1031 | return false; |
1033 | 1032 | } |
1034 | 1033 | return $this->_encode_der($source, $filters + $mapping); |
@@ -1052,7 +1051,7 @@ discard block |
||
1052 | 1051 | $value = $source ? "\xFF" : "\x00"; |
1053 | 1052 | break; |
1054 | 1053 | default: |
1055 | - user_error('Mapping provides no type definition for ' . implode('/', $this->location)); |
|
1054 | + user_error('Mapping provides no type definition for '.implode('/', $this->location)); |
|
1056 | 1055 | return false; |
1057 | 1056 | } |
1058 | 1057 | |
@@ -1064,7 +1063,7 @@ discard block |
||
1064 | 1063 | $tag = ($mapping['class'] << 6) | ($tag & 0x20) | $mapping['cast']; |
1065 | 1064 | } |
1066 | 1065 | |
1067 | - return chr($tag) . $this->_encodeLength(strlen($value)) . $value; |
|
1066 | + return chr($tag).$this->_encodeLength(strlen($value)).$value; |
|
1068 | 1067 | } |
1069 | 1068 | |
1070 | 1069 | /** |
@@ -1108,8 +1107,7 @@ discard block |
||
1108 | 1107 | http://www.obj-sys.com/asn1tutorial/node14.html */ |
1109 | 1108 | |
1110 | 1109 | $pattern = $tag == FILE_ASN1_TYPE_UTC_TIME ? |
1111 | - '#(..)(..)(..)(..)(..)(..)(.*)#' : |
|
1112 | - '#(....)(..)(..)(..)(..)(..).*([Z+-].*)$#'; |
|
1110 | + '#(..)(..)(..)(..)(..)(..)(.*)#' : '#(....)(..)(..)(..)(..)(..).*([Z+-].*)$#'; |
|
1113 | 1111 | |
1114 | 1112 | preg_match($pattern, $content, $matches); |
1115 | 1113 |
@@ -586,8 +586,7 @@ discard block |
||
586 | 586 | if (isset($child['class'])) { |
587 | 587 | $childClass = $child['class']; |
588 | 588 | $constant = $child['cast']; |
589 | - } |
|
590 | - elseif (isset($child['constant'])) { |
|
589 | + } elseif (isset($child['constant'])) { |
|
591 | 590 | $childClass = FILE_ASN1_CLASS_CONTEXT_SPECIFIC; |
592 | 591 | $constant = $child['constant']; |
593 | 592 | } |
@@ -656,8 +655,7 @@ discard block |
||
656 | 655 | if (isset($child['class'])) { |
657 | 656 | $childClass = $child['class']; |
658 | 657 | $constant = $child['cast']; |
659 | - } |
|
660 | - elseif (isset($child['constant'])) { |
|
658 | + } elseif (isset($child['constant'])) { |
|
661 | 659 | $childClass = FILE_ASN1_CLASS_CONTEXT_SPECIFIC; |
662 | 660 | $constant = $child['constant']; |
663 | 661 | } |
@@ -1653,7 +1653,7 @@ discard block |
||
1653 | 1653 | * |
1654 | 1654 | * @param Array ref $root |
1655 | 1655 | * @param String $path |
1656 | - * @param Object $asn1 |
|
1656 | + * @param File_ASN1 $asn1 |
|
1657 | 1657 | * @access private |
1658 | 1658 | */ |
1659 | 1659 | function _mapInAttributes(&$root, $path, $asn1) |
@@ -1694,7 +1694,7 @@ discard block |
||
1694 | 1694 | * |
1695 | 1695 | * @param Array ref $root |
1696 | 1696 | * @param String $path |
1697 | - * @param Object $asn1 |
|
1697 | + * @param File_ASN1 $asn1 |
|
1698 | 1698 | * @access private |
1699 | 1699 | */ |
1700 | 1700 | function _mapOutAttributes(&$root, $path, $asn1) |
@@ -2111,7 +2111,7 @@ discard block |
||
2111 | 2111 | * @param String $signature |
2112 | 2112 | * @param String $signatureSubject |
2113 | 2113 | * @access private |
2114 | - * @return Integer |
|
2114 | + * @return null|boolean |
|
2115 | 2115 | */ |
2116 | 2116 | function _validateSignature($publicKeyAlgorithm, $publicKey, $signatureAlgorithm, $signature, $signatureSubject) |
2117 | 2117 | { |
@@ -2179,7 +2179,7 @@ discard block |
||
2179 | 2179 | * |
2180 | 2180 | * @param String $propName |
2181 | 2181 | * @access private |
2182 | - * @return Mixed |
|
2182 | + * @return string|false |
|
2183 | 2183 | */ |
2184 | 2184 | function _translateDNProp($propName) |
2185 | 2185 | { |
@@ -2421,7 +2421,7 @@ discard block |
||
2421 | 2421 | /** |
2422 | 2422 | * Get the Distinguished Name for a certificates subject |
2423 | 2423 | * |
2424 | - * @param Mixed $format optional |
|
2424 | + * @param integer $format optional |
|
2425 | 2425 | * @param Array $dn optional |
2426 | 2426 | * @access public |
2427 | 2427 | * @return Boolean |
@@ -2568,7 +2568,7 @@ discard block |
||
2568 | 2568 | * |
2569 | 2569 | * @param Integer $format optional |
2570 | 2570 | * @access public |
2571 | - * @return Mixed |
|
2571 | + * @return boolean |
|
2572 | 2572 | */ |
2573 | 2573 | function getIssuerDN($format = FILE_X509_DN_ARRAY) |
2574 | 2574 | { |
@@ -2590,7 +2590,7 @@ discard block |
||
2590 | 2590 | * |
2591 | 2591 | * @param Integer $format optional |
2592 | 2592 | * @access public |
2593 | - * @return Mixed |
|
2593 | + * @return boolean |
|
2594 | 2594 | */ |
2595 | 2595 | function getSubjectDN($format = FILE_X509_DN_ARRAY) |
2596 | 2596 | { |
@@ -2706,7 +2706,7 @@ discard block |
||
2706 | 2706 | * |
2707 | 2707 | * @param Object $key |
2708 | 2708 | * @access public |
2709 | - * @return Boolean |
|
2709 | + * @return boolean|null |
|
2710 | 2710 | */ |
2711 | 2711 | function setPublicKey($key) |
2712 | 2712 | { |
@@ -3427,7 +3427,6 @@ discard block |
||
3427 | 3427 | * X.509 certificate signing helper function. |
3428 | 3428 | * |
3429 | 3429 | * @param Object $key |
3430 | - * @param File_X509 $subject |
|
3431 | 3430 | * @param String $signatureAlgorithm |
3432 | 3431 | * @access public |
3433 | 3432 | * @return Mixed |
@@ -394,10 +394,10 @@ discard block |
||
394 | 394 | 'children' => array( |
395 | 395 | 'extnId' => array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER), |
396 | 396 | 'critical' => array( |
397 | - 'type' => FILE_ASN1_TYPE_BOOLEAN, |
|
398 | - 'optional' => true, |
|
399 | - 'default' => false |
|
400 | - ), |
|
397 | + 'type' => FILE_ASN1_TYPE_BOOLEAN, |
|
398 | + 'optional' => true, |
|
399 | + 'default' => false |
|
400 | + ), |
|
401 | 401 | 'extnValue' => array('type' => FILE_ASN1_TYPE_OCTET_STRING) |
402 | 402 | ) |
403 | 403 | ); |
@@ -452,11 +452,11 @@ discard block |
||
452 | 452 | // technically, default implies optional, but we'll define it as being optional, none-the-less, just to |
453 | 453 | // reenforce that fact |
454 | 454 | 'version' => array( |
455 | - 'constant' => 0, |
|
456 | - 'optional' => true, |
|
457 | - 'explicit' => true, |
|
458 | - 'default' => 'v1' |
|
459 | - ) + $Version, |
|
455 | + 'constant' => 0, |
|
456 | + 'optional' => true, |
|
457 | + 'explicit' => true, |
|
458 | + 'default' => 'v1' |
|
459 | + ) + $Version, |
|
460 | 460 | 'serialNumber' => $CertificateSerialNumber, |
461 | 461 | 'signature' => $AlgorithmIdentifier, |
462 | 462 | 'issuer' => $this->Name, |
@@ -465,31 +465,31 @@ discard block |
||
465 | 465 | 'subjectPublicKeyInfo' => $SubjectPublicKeyInfo, |
466 | 466 | // implicit means that the T in the TLV structure is to be rewritten, regardless of the type |
467 | 467 | 'issuerUniqueID' => array( |
468 | - 'constant' => 1, |
|
469 | - 'optional' => true, |
|
470 | - 'implicit' => true |
|
471 | - ) + $UniqueIdentifier, |
|
468 | + 'constant' => 1, |
|
469 | + 'optional' => true, |
|
470 | + 'implicit' => true |
|
471 | + ) + $UniqueIdentifier, |
|
472 | 472 | 'subjectUniqueID' => array( |
473 | - 'constant' => 2, |
|
474 | - 'optional' => true, |
|
475 | - 'implicit' => true |
|
476 | - ) + $UniqueIdentifier, |
|
473 | + 'constant' => 2, |
|
474 | + 'optional' => true, |
|
475 | + 'implicit' => true |
|
476 | + ) + $UniqueIdentifier, |
|
477 | 477 | // <http://tools.ietf.org/html/rfc2459#page-74> doesn't use the EXPLICIT keyword but if |
478 | 478 | // it's not IMPLICIT, it's EXPLICIT |
479 | 479 | 'extensions' => array( |
480 | - 'constant' => 3, |
|
481 | - 'optional' => true, |
|
482 | - 'explicit' => true |
|
483 | - ) + $this->Extensions |
|
480 | + 'constant' => 3, |
|
481 | + 'optional' => true, |
|
482 | + 'explicit' => true |
|
483 | + ) + $this->Extensions |
|
484 | 484 | ) |
485 | 485 | ); |
486 | 486 | |
487 | 487 | $this->Certificate = array( |
488 | 488 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
489 | 489 | 'children' => array( |
490 | - 'tbsCertificate' => $TBSCertificate, |
|
491 | - 'signatureAlgorithm' => $AlgorithmIdentifier, |
|
492 | - 'signature' => array('type' => FILE_ASN1_TYPE_BIT_STRING) |
|
490 | + 'tbsCertificate' => $TBSCertificate, |
|
491 | + 'signatureAlgorithm' => $AlgorithmIdentifier, |
|
492 | + 'signature' => array('type' => FILE_ASN1_TYPE_BIT_STRING) |
|
493 | 493 | ) |
494 | 494 | ); |
495 | 495 | |
@@ -512,14 +512,14 @@ discard block |
||
512 | 512 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
513 | 513 | 'children' => array( |
514 | 514 | 'cA' => array( |
515 | - 'type' => FILE_ASN1_TYPE_BOOLEAN, |
|
516 | - 'optional' => true, |
|
517 | - 'default' => false |
|
518 | - ), |
|
515 | + 'type' => FILE_ASN1_TYPE_BOOLEAN, |
|
516 | + 'optional' => true, |
|
517 | + 'default' => false |
|
518 | + ), |
|
519 | 519 | 'pathLenConstraint' => array( |
520 | - 'type' => FILE_ASN1_TYPE_INTEGER, |
|
521 | - 'optional' => true |
|
522 | - ) |
|
520 | + 'type' => FILE_ASN1_TYPE_INTEGER, |
|
521 | + 'optional' => true |
|
522 | + ) |
|
523 | 523 | ) |
524 | 524 | ); |
525 | 525 | |
@@ -536,29 +536,29 @@ discard block |
||
536 | 536 | 'type' => FILE_ASN1_TYPE_SET, |
537 | 537 | 'children' => array( |
538 | 538 | 'surname' => array( |
539 | - 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, |
|
540 | - 'constant' => 0, |
|
541 | - 'optional' => true, |
|
542 | - 'implicit' => true |
|
543 | - ), |
|
539 | + 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, |
|
540 | + 'constant' => 0, |
|
541 | + 'optional' => true, |
|
542 | + 'implicit' => true |
|
543 | + ), |
|
544 | 544 | 'given-name' => array( |
545 | - 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, |
|
546 | - 'constant' => 1, |
|
547 | - 'optional' => true, |
|
548 | - 'implicit' => true |
|
549 | - ), |
|
545 | + 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, |
|
546 | + 'constant' => 1, |
|
547 | + 'optional' => true, |
|
548 | + 'implicit' => true |
|
549 | + ), |
|
550 | 550 | 'initials' => array( |
551 | - 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, |
|
552 | - 'constant' => 2, |
|
553 | - 'optional' => true, |
|
554 | - 'implicit' => true |
|
555 | - ), |
|
551 | + 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, |
|
552 | + 'constant' => 2, |
|
553 | + 'optional' => true, |
|
554 | + 'implicit' => true |
|
555 | + ), |
|
556 | 556 | 'generation-qualifier' => array( |
557 | - 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, |
|
558 | - 'constant' => 3, |
|
559 | - 'optional' => true, |
|
560 | - 'implicit' => true |
|
561 | - ) |
|
557 | + 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, |
|
558 | + 'constant' => 3, |
|
559 | + 'optional' => true, |
|
560 | + 'implicit' => true |
|
561 | + ) |
|
562 | 562 | ) |
563 | 563 | ); |
564 | 564 | |
@@ -605,26 +605,26 @@ discard block |
||
605 | 605 | $AnotherName = array( |
606 | 606 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
607 | 607 | 'children' => array( |
608 | - 'type-id' => array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER), |
|
609 | - 'value' => array( |
|
610 | - 'type' => FILE_ASN1_TYPE_ANY, |
|
611 | - 'constant' => 0, |
|
612 | - 'optional' => true, |
|
613 | - 'explicit' => true |
|
614 | - ) |
|
608 | + 'type-id' => array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER), |
|
609 | + 'value' => array( |
|
610 | + 'type' => FILE_ASN1_TYPE_ANY, |
|
611 | + 'constant' => 0, |
|
612 | + 'optional' => true, |
|
613 | + 'explicit' => true |
|
614 | + ) |
|
615 | 615 | ) |
616 | 616 | ); |
617 | 617 | |
618 | 618 | $ExtensionAttribute = array( |
619 | 619 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
620 | 620 | 'children' => array( |
621 | - 'extension-attribute-type' => array( |
|
621 | + 'extension-attribute-type' => array( |
|
622 | 622 | 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, |
623 | 623 | 'constant' => 0, |
624 | 624 | 'optional' => true, |
625 | 625 | 'implicit' => true |
626 | 626 | ), |
627 | - 'extension-attribute-value' => array( |
|
627 | + 'extension-attribute-value' => array( |
|
628 | 628 | 'type' => FILE_ASN1_TYPE_ANY, |
629 | 629 | 'constant' => 1, |
630 | 630 | 'optional' => true, |
@@ -643,8 +643,8 @@ discard block |
||
643 | 643 | $BuiltInDomainDefinedAttribute = array( |
644 | 644 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
645 | 645 | 'children' => array( |
646 | - 'type' => array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING), |
|
647 | - 'value' => array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING) |
|
646 | + 'type' => array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING), |
|
647 | + 'value' => array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING) |
|
648 | 648 | ) |
649 | 649 | ); |
650 | 650 | |
@@ -661,63 +661,63 @@ discard block |
||
661 | 661 | 'country-name' => array('optional' => true) + $CountryName, |
662 | 662 | 'administration-domain-name' => array('optional' => true) + $AdministrationDomainName, |
663 | 663 | 'network-address' => array( |
664 | - 'constant' => 0, |
|
665 | - 'optional' => true, |
|
666 | - 'implicit' => true |
|
667 | - ) + $NetworkAddress, |
|
664 | + 'constant' => 0, |
|
665 | + 'optional' => true, |
|
666 | + 'implicit' => true |
|
667 | + ) + $NetworkAddress, |
|
668 | 668 | 'terminal-identifier' => array( |
669 | - 'constant' => 1, |
|
670 | - 'optional' => true, |
|
671 | - 'implicit' => true |
|
672 | - ) + $TerminalIdentifier, |
|
669 | + 'constant' => 1, |
|
670 | + 'optional' => true, |
|
671 | + 'implicit' => true |
|
672 | + ) + $TerminalIdentifier, |
|
673 | 673 | 'private-domain-name' => array( |
674 | - 'constant' => 2, |
|
675 | - 'optional' => true, |
|
676 | - 'explicit' => true |
|
677 | - ) + $PrivateDomainName, |
|
674 | + 'constant' => 2, |
|
675 | + 'optional' => true, |
|
676 | + 'explicit' => true |
|
677 | + ) + $PrivateDomainName, |
|
678 | 678 | 'organization-name' => array( |
679 | - 'constant' => 3, |
|
680 | - 'optional' => true, |
|
681 | - 'implicit' => true |
|
682 | - ) + $OrganizationName, |
|
679 | + 'constant' => 3, |
|
680 | + 'optional' => true, |
|
681 | + 'implicit' => true |
|
682 | + ) + $OrganizationName, |
|
683 | 683 | 'numeric-user-identifier' => array( |
684 | - 'constant' => 4, |
|
685 | - 'optional' => true, |
|
686 | - 'implicit' => true |
|
687 | - ) + $NumericUserIdentifier, |
|
684 | + 'constant' => 4, |
|
685 | + 'optional' => true, |
|
686 | + 'implicit' => true |
|
687 | + ) + $NumericUserIdentifier, |
|
688 | 688 | 'personal-name' => array( |
689 | - 'constant' => 5, |
|
690 | - 'optional' => true, |
|
691 | - 'implicit' => true |
|
692 | - ) + $PersonalName, |
|
689 | + 'constant' => 5, |
|
690 | + 'optional' => true, |
|
691 | + 'implicit' => true |
|
692 | + ) + $PersonalName, |
|
693 | 693 | 'organizational-unit-names' => array( |
694 | - 'constant' => 6, |
|
695 | - 'optional' => true, |
|
696 | - 'implicit' => true |
|
697 | - ) + $OrganizationalUnitNames |
|
694 | + 'constant' => 6, |
|
695 | + 'optional' => true, |
|
696 | + 'implicit' => true |
|
697 | + ) + $OrganizationalUnitNames |
|
698 | 698 | ) |
699 | 699 | ); |
700 | 700 | |
701 | 701 | $ORAddress = array( |
702 | 702 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
703 | 703 | 'children' => array( |
704 | - 'built-in-standard-attributes' => $BuiltInStandardAttributes, |
|
705 | - 'built-in-domain-defined-attributes' => array('optional' => true) + $BuiltInDomainDefinedAttributes, |
|
706 | - 'extension-attributes' => array('optional' => true) + $ExtensionAttributes |
|
704 | + 'built-in-standard-attributes' => $BuiltInStandardAttributes, |
|
705 | + 'built-in-domain-defined-attributes' => array('optional' => true) + $BuiltInDomainDefinedAttributes, |
|
706 | + 'extension-attributes' => array('optional' => true) + $ExtensionAttributes |
|
707 | 707 | ) |
708 | 708 | ); |
709 | 709 | |
710 | 710 | $EDIPartyName = array( |
711 | 711 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
712 | 712 | 'children' => array( |
713 | - 'nameAssigner' => array( |
|
713 | + 'nameAssigner' => array( |
|
714 | 714 | 'constant' => 0, |
715 | 715 | 'optional' => true, |
716 | 716 | 'implicit' => true |
717 | 717 | ) + $this->DirectoryString, |
718 | - // partyName is technically required but File_ASN1 doesn't currently support non-optional constants and |
|
719 | - // setting it to optional gets the job done in any event. |
|
720 | - 'partyName' => array( |
|
718 | + // partyName is technically required but File_ASN1 doesn't currently support non-optional constants and |
|
719 | + // setting it to optional gets the job done in any event. |
|
720 | + 'partyName' => array( |
|
721 | 721 | 'constant' => 1, |
722 | 722 | 'optional' => true, |
723 | 723 | 'implicit' => true |
@@ -729,55 +729,55 @@ discard block |
||
729 | 729 | 'type' => FILE_ASN1_TYPE_CHOICE, |
730 | 730 | 'children' => array( |
731 | 731 | 'otherName' => array( |
732 | - 'constant' => 0, |
|
733 | - 'optional' => true, |
|
734 | - 'implicit' => true |
|
735 | - ) + $AnotherName, |
|
732 | + 'constant' => 0, |
|
733 | + 'optional' => true, |
|
734 | + 'implicit' => true |
|
735 | + ) + $AnotherName, |
|
736 | 736 | 'rfc822Name' => array( |
737 | - 'type' => FILE_ASN1_TYPE_IA5_STRING, |
|
738 | - 'constant' => 1, |
|
739 | - 'optional' => true, |
|
740 | - 'implicit' => true |
|
741 | - ), |
|
737 | + 'type' => FILE_ASN1_TYPE_IA5_STRING, |
|
738 | + 'constant' => 1, |
|
739 | + 'optional' => true, |
|
740 | + 'implicit' => true |
|
741 | + ), |
|
742 | 742 | 'dNSName' => array( |
743 | - 'type' => FILE_ASN1_TYPE_IA5_STRING, |
|
744 | - 'constant' => 2, |
|
745 | - 'optional' => true, |
|
746 | - 'implicit' => true |
|
747 | - ), |
|
743 | + 'type' => FILE_ASN1_TYPE_IA5_STRING, |
|
744 | + 'constant' => 2, |
|
745 | + 'optional' => true, |
|
746 | + 'implicit' => true |
|
747 | + ), |
|
748 | 748 | 'x400Address' => array( |
749 | - 'constant' => 3, |
|
750 | - 'optional' => true, |
|
751 | - 'implicit' => true |
|
752 | - ) + $ORAddress, |
|
749 | + 'constant' => 3, |
|
750 | + 'optional' => true, |
|
751 | + 'implicit' => true |
|
752 | + ) + $ORAddress, |
|
753 | 753 | 'directoryName' => array( |
754 | - 'constant' => 4, |
|
755 | - 'optional' => true, |
|
756 | - 'explicit' => true |
|
757 | - ) + $this->Name, |
|
754 | + 'constant' => 4, |
|
755 | + 'optional' => true, |
|
756 | + 'explicit' => true |
|
757 | + ) + $this->Name, |
|
758 | 758 | 'ediPartyName' => array( |
759 | - 'constant' => 5, |
|
760 | - 'optional' => true, |
|
761 | - 'implicit' => true |
|
762 | - ) + $EDIPartyName, |
|
759 | + 'constant' => 5, |
|
760 | + 'optional' => true, |
|
761 | + 'implicit' => true |
|
762 | + ) + $EDIPartyName, |
|
763 | 763 | 'uniformResourceIdentifier' => array( |
764 | - 'type' => FILE_ASN1_TYPE_IA5_STRING, |
|
765 | - 'constant' => 6, |
|
766 | - 'optional' => true, |
|
767 | - 'implicit' => true |
|
768 | - ), |
|
764 | + 'type' => FILE_ASN1_TYPE_IA5_STRING, |
|
765 | + 'constant' => 6, |
|
766 | + 'optional' => true, |
|
767 | + 'implicit' => true |
|
768 | + ), |
|
769 | 769 | 'iPAddress' => array( |
770 | - 'type' => FILE_ASN1_TYPE_OCTET_STRING, |
|
771 | - 'constant' => 7, |
|
772 | - 'optional' => true, |
|
773 | - 'implicit' => true |
|
774 | - ), |
|
770 | + 'type' => FILE_ASN1_TYPE_OCTET_STRING, |
|
771 | + 'constant' => 7, |
|
772 | + 'optional' => true, |
|
773 | + 'implicit' => true |
|
774 | + ), |
|
775 | 775 | 'registeredID' => array( |
776 | - 'type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER, |
|
777 | - 'constant' => 8, |
|
778 | - 'optional' => true, |
|
779 | - 'implicit' => true |
|
780 | - ) |
|
776 | + 'type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER, |
|
777 | + 'constant' => 8, |
|
778 | + 'optional' => true, |
|
779 | + 'implicit' => true |
|
780 | + ) |
|
781 | 781 | ) |
782 | 782 | ); |
783 | 783 | |
@@ -809,15 +809,15 @@ discard block |
||
809 | 809 | 'type' => FILE_ASN1_TYPE_CHOICE, |
810 | 810 | 'children' => array( |
811 | 811 | 'fullName' => array( |
812 | - 'constant' => 0, |
|
813 | - 'optional' => true, |
|
814 | - 'implicit' => true |
|
815 | - ) + $GeneralNames, |
|
812 | + 'constant' => 0, |
|
813 | + 'optional' => true, |
|
814 | + 'implicit' => true |
|
815 | + ) + $GeneralNames, |
|
816 | 816 | 'nameRelativeToCRLIssuer' => array( |
817 | - 'constant' => 1, |
|
818 | - 'optional' => true, |
|
819 | - 'implicit' => true |
|
820 | - ) + $this->RelativeDistinguishedName |
|
817 | + 'constant' => 1, |
|
818 | + 'optional' => true, |
|
819 | + 'implicit' => true |
|
820 | + ) + $this->RelativeDistinguishedName |
|
821 | 821 | ) |
822 | 822 | ); |
823 | 823 | |
@@ -825,20 +825,20 @@ discard block |
||
825 | 825 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
826 | 826 | 'children' => array( |
827 | 827 | 'distributionPoint' => array( |
828 | - 'constant' => 0, |
|
829 | - 'optional' => true, |
|
830 | - 'explicit' => true |
|
831 | - ) + $DistributionPointName, |
|
828 | + 'constant' => 0, |
|
829 | + 'optional' => true, |
|
830 | + 'explicit' => true |
|
831 | + ) + $DistributionPointName, |
|
832 | 832 | 'reasons' => array( |
833 | - 'constant' => 1, |
|
834 | - 'optional' => true, |
|
835 | - 'implicit' => true |
|
836 | - ) + $ReasonFlags, |
|
833 | + 'constant' => 1, |
|
834 | + 'optional' => true, |
|
835 | + 'implicit' => true |
|
836 | + ) + $ReasonFlags, |
|
837 | 837 | 'cRLIssuer' => array( |
838 | - 'constant' => 2, |
|
839 | - 'optional' => true, |
|
840 | - 'implicit' => true |
|
841 | - ) + $GeneralNames |
|
838 | + 'constant' => 2, |
|
839 | + 'optional' => true, |
|
840 | + 'implicit' => true |
|
841 | + ) + $GeneralNames |
|
842 | 842 | ) |
843 | 843 | ); |
844 | 844 | |
@@ -853,20 +853,20 @@ discard block |
||
853 | 853 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
854 | 854 | 'children' => array( |
855 | 855 | 'keyIdentifier' => array( |
856 | - 'constant' => 0, |
|
857 | - 'optional' => true, |
|
858 | - 'implicit' => true |
|
859 | - ) + $this->KeyIdentifier, |
|
856 | + 'constant' => 0, |
|
857 | + 'optional' => true, |
|
858 | + 'implicit' => true |
|
859 | + ) + $this->KeyIdentifier, |
|
860 | 860 | 'authorityCertIssuer' => array( |
861 | - 'constant' => 1, |
|
862 | - 'optional' => true, |
|
863 | - 'implicit' => true |
|
864 | - ) + $GeneralNames, |
|
861 | + 'constant' => 1, |
|
862 | + 'optional' => true, |
|
863 | + 'implicit' => true |
|
864 | + ) + $GeneralNames, |
|
865 | 865 | 'authorityCertSerialNumber' => array( |
866 | - 'constant' => 2, |
|
867 | - 'optional' => true, |
|
868 | - 'implicit' => true |
|
869 | - ) + $CertificateSerialNumber |
|
866 | + 'constant' => 2, |
|
867 | + 'optional' => true, |
|
868 | + 'implicit' => true |
|
869 | + ) + $CertificateSerialNumber |
|
870 | 870 | ) |
871 | 871 | ); |
872 | 872 | |
@@ -887,12 +887,12 @@ discard block |
||
887 | 887 | 'children' => array( |
888 | 888 | 'policyIdentifier' => $CertPolicyId, |
889 | 889 | 'policyQualifiers' => array( |
890 | - 'type' => FILE_ASN1_TYPE_SEQUENCE, |
|
891 | - 'min' => 0, |
|
892 | - 'max' => -1, |
|
893 | - 'optional' => true, |
|
894 | - 'children' => $PolicyQualifierInfo |
|
895 | - ) |
|
890 | + 'type' => FILE_ASN1_TYPE_SEQUENCE, |
|
891 | + 'min' => 0, |
|
892 | + 'max' => -1, |
|
893 | + 'optional' => true, |
|
894 | + 'children' => $PolicyQualifierInfo |
|
895 | + ) |
|
896 | 896 | ) |
897 | 897 | ); |
898 | 898 | |
@@ -908,12 +908,12 @@ discard block |
||
908 | 908 | 'min' => 1, |
909 | 909 | 'max' => -1, |
910 | 910 | 'children' => array( |
911 | - 'type' => FILE_ASN1_TYPE_SEQUENCE, |
|
912 | - 'children' => array( |
|
913 | - 'issuerDomainPolicy' => $CertPolicyId, |
|
914 | - 'subjectDomainPolicy' => $CertPolicyId |
|
915 | - ) |
|
916 | - ) |
|
911 | + 'type' => FILE_ASN1_TYPE_SEQUENCE, |
|
912 | + 'children' => array( |
|
913 | + 'issuerDomainPolicy' => $CertPolicyId, |
|
914 | + 'subjectDomainPolicy' => $CertPolicyId |
|
915 | + ) |
|
916 | + ) |
|
917 | 917 | ); |
918 | 918 | |
919 | 919 | $KeyPurposeId = array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER); |
@@ -946,15 +946,15 @@ discard block |
||
946 | 946 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
947 | 947 | 'children' => array( |
948 | 948 | 'notBefore' => array( |
949 | - 'constant' => 0, |
|
950 | - 'optional' => true, |
|
951 | - 'implicit' => true, |
|
952 | - 'type' => FILE_ASN1_TYPE_GENERALIZED_TIME), |
|
949 | + 'constant' => 0, |
|
950 | + 'optional' => true, |
|
951 | + 'implicit' => true, |
|
952 | + 'type' => FILE_ASN1_TYPE_GENERALIZED_TIME), |
|
953 | 953 | 'notAfter' => array( |
954 | - 'constant' => 1, |
|
955 | - 'optional' => true, |
|
956 | - 'implicit' => true, |
|
957 | - 'type' => FILE_ASN1_TYPE_GENERALIZED_TIME) |
|
954 | + 'constant' => 1, |
|
955 | + 'optional' => true, |
|
956 | + 'implicit' => true, |
|
957 | + 'type' => FILE_ASN1_TYPE_GENERALIZED_TIME) |
|
958 | 958 | ) |
959 | 959 | ); |
960 | 960 | |
@@ -965,16 +965,16 @@ discard block |
||
965 | 965 | 'children' => array( |
966 | 966 | 'base' => $GeneralName, |
967 | 967 | 'minimum' => array( |
968 | - 'constant' => 0, |
|
969 | - 'optional' => true, |
|
970 | - 'implicit' => true, |
|
971 | - 'default' => new Math_BigInteger(0) |
|
972 | - ) + $BaseDistance, |
|
968 | + 'constant' => 0, |
|
969 | + 'optional' => true, |
|
970 | + 'implicit' => true, |
|
971 | + 'default' => new Math_BigInteger(0) |
|
972 | + ) + $BaseDistance, |
|
973 | 973 | 'maximum' => array( |
974 | - 'constant' => 1, |
|
975 | - 'optional' => true, |
|
976 | - 'implicit' => true, |
|
977 | - ) + $BaseDistance |
|
974 | + 'constant' => 1, |
|
975 | + 'optional' => true, |
|
976 | + 'implicit' => true, |
|
977 | + ) + $BaseDistance |
|
978 | 978 | ) |
979 | 979 | ); |
980 | 980 | |
@@ -989,15 +989,15 @@ discard block |
||
989 | 989 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
990 | 990 | 'children' => array( |
991 | 991 | 'permittedSubtrees' => array( |
992 | - 'constant' => 0, |
|
993 | - 'optional' => true, |
|
994 | - 'implicit' => true |
|
995 | - ) + $GeneralSubtrees, |
|
992 | + 'constant' => 0, |
|
993 | + 'optional' => true, |
|
994 | + 'implicit' => true |
|
995 | + ) + $GeneralSubtrees, |
|
996 | 996 | 'excludedSubtrees' => array( |
997 | - 'constant' => 1, |
|
998 | - 'optional' => true, |
|
999 | - 'implicit' => true |
|
1000 | - ) + $GeneralSubtrees |
|
997 | + 'constant' => 1, |
|
998 | + 'optional' => true, |
|
999 | + 'implicit' => true |
|
1000 | + ) + $GeneralSubtrees |
|
1001 | 1001 | ) |
1002 | 1002 | ); |
1003 | 1003 | |
@@ -1018,11 +1018,11 @@ discard block |
||
1018 | 1018 | 'children' => array( |
1019 | 1019 | 'organization' => $DisplayText, |
1020 | 1020 | 'noticeNumbers' => array( |
1021 | - 'type' => FILE_ASN1_TYPE_SEQUENCE, |
|
1022 | - 'min' => 1, |
|
1023 | - 'max' => 200, |
|
1024 | - 'children' => array('type' => FILE_ASN1_TYPE_INTEGER) |
|
1025 | - ) |
|
1021 | + 'type' => FILE_ASN1_TYPE_SEQUENCE, |
|
1022 | + 'min' => 1, |
|
1023 | + 'max' => 200, |
|
1024 | + 'children' => array('type' => FILE_ASN1_TYPE_INTEGER) |
|
1025 | + ) |
|
1026 | 1026 | ) |
1027 | 1027 | ); |
1028 | 1028 | |
@@ -1030,13 +1030,13 @@ discard block |
||
1030 | 1030 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
1031 | 1031 | 'children' => array( |
1032 | 1032 | 'noticeRef' => array( |
1033 | - 'optional' => true, |
|
1034 | - 'implicit' => true |
|
1035 | - ) + $NoticeReference, |
|
1033 | + 'optional' => true, |
|
1034 | + 'implicit' => true |
|
1035 | + ) + $NoticeReference, |
|
1036 | 1036 | 'explicitText' => array( |
1037 | - 'optional' => true, |
|
1038 | - 'implicit' => true |
|
1039 | - ) + $DisplayText |
|
1037 | + 'optional' => true, |
|
1038 | + 'implicit' => true |
|
1039 | + ) + $DisplayText |
|
1040 | 1040 | ) |
1041 | 1041 | ); |
1042 | 1042 | |
@@ -1065,11 +1065,11 @@ discard block |
||
1065 | 1065 | 'children' => array( |
1066 | 1066 | 'type' => $AttributeType, |
1067 | 1067 | 'value'=> array( |
1068 | - 'type' => FILE_ASN1_TYPE_SET, |
|
1069 | - 'min' => 1, |
|
1070 | - 'max' => -1, |
|
1071 | - 'children' => $this->AttributeValue |
|
1072 | - ) |
|
1068 | + 'type' => FILE_ASN1_TYPE_SET, |
|
1069 | + 'min' => 1, |
|
1070 | + 'max' => -1, |
|
1071 | + 'children' => $this->AttributeValue |
|
1072 | + ) |
|
1073 | 1073 | ) |
1074 | 1074 | ); |
1075 | 1075 | |
@@ -1086,16 +1086,16 @@ discard block |
||
1086 | 1086 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
1087 | 1087 | 'children' => array( |
1088 | 1088 | 'version' => array( |
1089 | - 'type' => FILE_ASN1_TYPE_INTEGER, |
|
1090 | - 'mapping' => array('v1') |
|
1091 | - ), |
|
1089 | + 'type' => FILE_ASN1_TYPE_INTEGER, |
|
1090 | + 'mapping' => array('v1') |
|
1091 | + ), |
|
1092 | 1092 | 'subject' => $this->Name, |
1093 | 1093 | 'subjectPKInfo' => $SubjectPublicKeyInfo, |
1094 | 1094 | 'attributes' => array( |
1095 | - 'constant' => 0, |
|
1096 | - 'optional' => true, |
|
1097 | - 'implicit' => true |
|
1098 | - ) + $Attributes, |
|
1095 | + 'constant' => 0, |
|
1096 | + 'optional' => true, |
|
1097 | + 'implicit' => true |
|
1098 | + ) + $Attributes, |
|
1099 | 1099 | ) |
1100 | 1100 | ); |
1101 | 1101 | |
@@ -1111,39 +1111,39 @@ discard block |
||
1111 | 1111 | $RevokedCertificate = array( |
1112 | 1112 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
1113 | 1113 | 'children' => array( |
1114 | - 'userCertificate' => $CertificateSerialNumber, |
|
1115 | - 'revocationDate' => $Time, |
|
1116 | - 'crlEntryExtensions' => array( |
|
1117 | - 'optional' => true |
|
1118 | - ) + $this->Extensions |
|
1119 | - ) |
|
1114 | + 'userCertificate' => $CertificateSerialNumber, |
|
1115 | + 'revocationDate' => $Time, |
|
1116 | + 'crlEntryExtensions' => array( |
|
1117 | + 'optional' => true |
|
1118 | + ) + $this->Extensions |
|
1119 | + ) |
|
1120 | 1120 | ); |
1121 | 1121 | |
1122 | 1122 | $TBSCertList = array( |
1123 | 1123 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
1124 | 1124 | 'children' => array( |
1125 | 1125 | 'version' => array( |
1126 | - 'optional' => true, |
|
1127 | - 'default' => 'v1' |
|
1128 | - ) + $Version, |
|
1126 | + 'optional' => true, |
|
1127 | + 'default' => 'v1' |
|
1128 | + ) + $Version, |
|
1129 | 1129 | 'signature' => $AlgorithmIdentifier, |
1130 | 1130 | 'issuer' => $this->Name, |
1131 | 1131 | 'thisUpdate' => $Time, |
1132 | 1132 | 'nextUpdate' => array( |
1133 | - 'optional' => true |
|
1134 | - ) + $Time, |
|
1133 | + 'optional' => true |
|
1134 | + ) + $Time, |
|
1135 | 1135 | 'revokedCertificates' => array( |
1136 | - 'type' => FILE_ASN1_TYPE_SEQUENCE, |
|
1137 | - 'optional' => true, |
|
1138 | - 'min' => 0, |
|
1139 | - 'max' => -1, |
|
1140 | - 'children' => $RevokedCertificate |
|
1141 | - ), |
|
1136 | + 'type' => FILE_ASN1_TYPE_SEQUENCE, |
|
1137 | + 'optional' => true, |
|
1138 | + 'min' => 0, |
|
1139 | + 'max' => -1, |
|
1140 | + 'children' => $RevokedCertificate |
|
1141 | + ), |
|
1142 | 1142 | 'crlExtensions' => array( |
1143 | - 'constant' => 0, |
|
1144 | - 'optional' => true, |
|
1145 | - 'explicit' => true |
|
1146 | - ) + $this->Extensions |
|
1143 | + 'constant' => 0, |
|
1144 | + 'optional' => true, |
|
1145 | + 'explicit' => true |
|
1146 | + ) + $this->Extensions |
|
1147 | 1147 | ) |
1148 | 1148 | ); |
1149 | 1149 | |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | $this->CRLNumber = array('type' => FILE_ASN1_TYPE_INTEGER); |
1160 | 1160 | |
1161 | 1161 | $this->CRLReason = array('type' => FILE_ASN1_TYPE_ENUMERATED, |
1162 | - 'mapping' => array( |
|
1162 | + 'mapping' => array( |
|
1163 | 1163 | 'unspecified', |
1164 | 1164 | 'keyCompromise', |
1165 | 1165 | 'cACompromise', |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | 'default' => false, |
1215 | 1215 | 'implicit' => true |
1216 | 1216 | ) |
1217 | - ) |
|
1217 | + ) |
|
1218 | 1218 | ); |
1219 | 1219 | |
1220 | 1220 | $this->InvalidityDate = array('type' => FILE_ASN1_TYPE_GENERALIZED_TIME); |
@@ -4132,7 +4132,7 @@ discard block |
||
4132 | 4132 | |
4133 | 4133 | $i = count($rclist); |
4134 | 4134 | $rclist[] = array('userCertificate' => $serial, |
4135 | - 'revocationDate' => array('generalTime' => @date('D, d M y H:i:s O'))); |
|
4135 | + 'revocationDate' => array('generalTime' => @date('D, d M y H:i:s O'))); |
|
4136 | 4136 | return $i; |
4137 | 4137 | } |
4138 | 4138 |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | 'children' => $BuiltInDomainDefinedAttribute |
656 | 656 | ); |
657 | 657 | |
658 | - $BuiltInStandardAttributes = array( |
|
658 | + $BuiltInStandardAttributes = array( |
|
659 | 659 | 'type' => FILE_ASN1_TYPE_SEQUENCE, |
660 | 660 | 'children' => array( |
661 | 661 | 'country-name' => array('optional' => true) + $CountryName, |
@@ -1493,7 +1493,7 @@ discard block |
||
1493 | 1493 | switch ($algorithm) { |
1494 | 1494 | case 'rsaEncryption': |
1495 | 1495 | $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'] = |
1496 | - base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']))); |
|
1496 | + base64_encode("\0".base64_decode(preg_replace('#-.+-|[\r\n]#', '', $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']))); |
|
1497 | 1497 | } |
1498 | 1498 | } |
1499 | 1499 | |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | return $cert; |
1532 | 1532 | // case FILE_X509_FORMAT_PEM: |
1533 | 1533 | default: |
1534 | - return "-----BEGIN CERTIFICATE-----\r\n" . chunk_split(base64_encode($cert), 64) . '-----END CERTIFICATE-----'; |
|
1534 | + return "-----BEGIN CERTIFICATE-----\r\n".chunk_split(base64_encode($cert), 64).'-----END CERTIFICATE-----'; |
|
1535 | 1535 | } |
1536 | 1536 | } |
1537 | 1537 | |
@@ -1625,7 +1625,7 @@ discard block |
||
1625 | 1625 | case 'id-ce-authorityKeyIdentifier': // use 00 as the serial number instead of an empty string |
1626 | 1626 | if (isset($value['authorityCertSerialNumber'])) { |
1627 | 1627 | if ($value['authorityCertSerialNumber']->toBytes() == '') { |
1628 | - $temp = chr((FILE_ASN1_CLASS_CONTEXT_SPECIFIC << 6) | 2) . "\1\0"; |
|
1628 | + $temp = chr((FILE_ASN1_CLASS_CONTEXT_SPECIFIC << 6) | 2)."\1\0"; |
|
1629 | 1629 | $value['authorityCertSerialNumber'] = new File_ASN1_Element($temp); |
1630 | 1630 | } |
1631 | 1631 | } |
@@ -1636,7 +1636,7 @@ discard block |
||
1636 | 1636 | $map = $this->_getMapping($id); |
1637 | 1637 | if (is_bool($map)) { |
1638 | 1638 | if (!$map) { |
1639 | - user_error($id . ' is not a currently supported extension'); |
|
1639 | + user_error($id.' is not a currently supported extension'); |
|
1640 | 1640 | unset($extensions[$i]); |
1641 | 1641 | } |
1642 | 1642 | } else { |
@@ -1709,7 +1709,7 @@ discard block |
||
1709 | 1709 | $id = $attributes[$i]['type']; |
1710 | 1710 | $map = $this->_getMapping($id); |
1711 | 1711 | if ($map === false) { |
1712 | - user_error($id . ' is not a currently supported attribute', E_USER_NOTICE); |
|
1712 | + user_error($id.' is not a currently supported attribute', E_USER_NOTICE); |
|
1713 | 1713 | unset($attributes[$i]); |
1714 | 1714 | } |
1715 | 1715 | elseif (is_array($attributes[$i]['value'])) { |
@@ -1925,7 +1925,7 @@ discard block |
||
1925 | 1925 | field in the Subject field of the certificate MUST be used. Although |
1926 | 1926 | the use of the Common Name is existing practice, it is deprecated and |
1927 | 1927 | Certification Authorities are encouraged to use the dNSName instead. */ |
1928 | - if (preg_match('#^' . $value . '$#', $components['host'])) { |
|
1928 | + if (preg_match('#^'.$value.'$#', $components['host'])) { |
|
1929 | 1929 | return true; |
1930 | 1930 | } |
1931 | 1931 | break; |
@@ -1935,7 +1935,7 @@ discard block |
||
1935 | 1935 | In some cases, the URI is specified as an IP address rather than a |
1936 | 1936 | hostname. In this case, the iPAddress subjectAltName must be present |
1937 | 1937 | in the certificate and must exactly match the IP in the URI. */ |
1938 | - if (preg_match('#(?:\d{1-3}\.){4}#', $components['host'] . '.') && preg_match('#^' . $value . '$#', $components['host'])) { |
|
1938 | + if (preg_match('#(?:\d{1-3}\.){4}#', $components['host'].'.') && preg_match('#^'.$value.'$#', $components['host'])) { |
|
1939 | 1939 | return true; |
1940 | 1940 | } |
1941 | 1941 | } |
@@ -1945,7 +1945,7 @@ discard block |
||
1945 | 1945 | |
1946 | 1946 | if ($value = $this->getDNProp('id-at-commonName')) { |
1947 | 1947 | $value = str_replace(array('.', '*'), array('\.', '[^.]*'), $value[0]); |
1948 | - return preg_match('#^' . $value . '$#', $components['host']); |
|
1948 | + return preg_match('#^'.$value.'$#', $components['host']); |
|
1949 | 1949 | } |
1950 | 1950 | |
1951 | 1951 | return false; |
@@ -2163,11 +2163,11 @@ discard block |
||
2163 | 2163 | switch ($algorithm) { |
2164 | 2164 | case 'rsaEncryption': |
2165 | 2165 | return |
2166 | - "-----BEGIN PUBLIC KEY-----\r\n" . |
|
2166 | + "-----BEGIN PUBLIC KEY-----\r\n". |
|
2167 | 2167 | // subjectPublicKey is stored as a bit string in X.509 certs. the first byte of a bit string represents how many bits |
2168 | 2168 | // in the last byte should be ignored. the following only supports non-zero stuff but as none of the X.509 certs Firefox |
2169 | 2169 | // uses as a cert authority actually use a non-zero bit I think it's safe to assume that none do. |
2170 | - chunk_split(base64_encode(substr(base64_decode($key), 1)), 64) . |
|
2170 | + chunk_split(base64_encode(substr(base64_decode($key), 1)), 64). |
|
2171 | 2171 | '-----END PUBLIC KEY-----'; |
2172 | 2172 | default: |
2173 | 2173 | return $key; |
@@ -2407,7 +2407,7 @@ discard block |
||
2407 | 2407 | |
2408 | 2408 | // handles everything else |
2409 | 2409 | $results = preg_split('#((?:^|, *|/)(?:C=|O=|OU=|CN=|L=|ST=|SN=|postalCode=|streetAddress=|emailAddress=|serialNumber=|organizationalUnitName=|title=|description=|role=|x500UniqueIdentifier=))#', $dn, -1, PREG_SPLIT_DELIM_CAPTURE); |
2410 | - for ($i = 1; $i < count($results); $i+=2) { |
|
2410 | + for ($i = 1; $i < count($results); $i += 2) { |
|
2411 | 2411 | $prop = trim($results[$i], ', =/'); |
2412 | 2412 | $value = $results[$i + 1]; |
2413 | 2413 | if (!$this->setDNProp($prop, $value, $type)) { |
@@ -2535,11 +2535,11 @@ discard block |
||
2535 | 2535 | break; |
2536 | 2536 | default: |
2537 | 2537 | $delim = '/'; |
2538 | - $desc = preg_replace('#.+-([^-]+)$#', '$1', $prop) . '='; |
|
2538 | + $desc = preg_replace('#.+-([^-]+)$#', '$1', $prop).'='; |
|
2539 | 2539 | } |
2540 | 2540 | |
2541 | 2541 | if (!$start) { |
2542 | - $output.= $delim; |
|
2542 | + $output .= $delim; |
|
2543 | 2543 | } |
2544 | 2544 | if (is_array($value)) { |
2545 | 2545 | foreach ($value as $type => $v) { |
@@ -2556,7 +2556,7 @@ discard block |
||
2556 | 2556 | $value = array_pop($value); // Always strip data type. |
2557 | 2557 | } |
2558 | 2558 | } |
2559 | - $output.= $desc . $value; |
|
2559 | + $output .= $desc.$value; |
|
2560 | 2560 | $start = false; |
2561 | 2561 | } |
2562 | 2562 | |
@@ -2868,7 +2868,7 @@ discard block |
||
2868 | 2868 | switch ($algorithm) { |
2869 | 2869 | case 'rsaEncryption': |
2870 | 2870 | $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'] = |
2871 | - base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']))); |
|
2871 | + base64_encode("\0".base64_decode(preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']))); |
|
2872 | 2872 | } |
2873 | 2873 | } |
2874 | 2874 | |
@@ -2890,7 +2890,7 @@ discard block |
||
2890 | 2890 | return $csr; |
2891 | 2891 | // case FILE_X509_FORMAT_PEM: |
2892 | 2892 | default: |
2893 | - return "-----BEGIN CERTIFICATE REQUEST-----\r\n" . chunk_split(base64_encode($csr), 64) . '-----END CERTIFICATE REQUEST-----'; |
|
2893 | + return "-----BEGIN CERTIFICATE REQUEST-----\r\n".chunk_split(base64_encode($csr), 64).'-----END CERTIFICATE REQUEST-----'; |
|
2894 | 2894 | } |
2895 | 2895 | } |
2896 | 2896 | |
@@ -3013,7 +3013,7 @@ discard block |
||
3013 | 3013 | $this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']); |
3014 | 3014 | |
3015 | 3015 | $this->_mapInExtensions($crl, 'tbsCertList/crlExtensions', $asn1); |
3016 | - $rclist = &$this->_subArray($crl,'tbsCertList/revokedCertificates'); |
|
3016 | + $rclist = &$this->_subArray($crl, 'tbsCertList/revokedCertificates'); |
|
3017 | 3017 | if (is_array($rclist)) { |
3018 | 3018 | foreach ($rclist as $i => $extension) { |
3019 | 3019 | $this->_mapInExtensions($rclist, "$i/crlEntryExtensions", $asn1); |
@@ -3063,7 +3063,7 @@ discard block |
||
3063 | 3063 | $asn1->loadFilters($filters); |
3064 | 3064 | |
3065 | 3065 | $this->_mapOutExtensions($crl, 'tbsCertList/crlExtensions', $asn1); |
3066 | - $rclist = &$this->_subArray($crl,'tbsCertList/revokedCertificates'); |
|
3066 | + $rclist = &$this->_subArray($crl, 'tbsCertList/revokedCertificates'); |
|
3067 | 3067 | if (is_array($rclist)) { |
3068 | 3068 | foreach ($rclist as $i => $extension) { |
3069 | 3069 | $this->_mapOutExtensions($rclist, "$i/crlEntryExtensions", $asn1); |
@@ -3077,7 +3077,7 @@ discard block |
||
3077 | 3077 | return $crl; |
3078 | 3078 | // case FILE_X509_FORMAT_PEM: |
3079 | 3079 | default: |
3080 | - return "-----BEGIN X509 CRL-----\r\n" . chunk_split(base64_encode($crl), 64) . '-----END X509 CRL-----'; |
|
3080 | + return "-----BEGIN X509 CRL-----\r\n".chunk_split(base64_encode($crl), 64).'-----END X509 CRL-----'; |
|
3081 | 3081 | } |
3082 | 3082 | } |
3083 | 3083 | |
@@ -3105,7 +3105,7 @@ discard block |
||
3105 | 3105 | } |
3106 | 3106 | |
3107 | 3107 | $currentCert = isset($this->currentCert) ? $this->currentCert : NULL; |
3108 | - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: NULL; |
|
3108 | + $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : NULL; |
|
3109 | 3109 | |
3110 | 3110 | if (isset($subject->currentCert) && is_array($subject->currentCert) && isset($subject->currentCert['tbsCertificate'])) { |
3111 | 3111 | $this->currentCert = $subject->currentCert; |
@@ -3258,7 +3258,7 @@ discard block |
||
3258 | 3258 | $this->publicKey = $origPublicKey; |
3259 | 3259 | |
3260 | 3260 | $currentCert = isset($this->currentCert) ? $this->currentCert : NULL; |
3261 | - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: NULL; |
|
3261 | + $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : NULL; |
|
3262 | 3262 | |
3263 | 3263 | if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['certificationRequestInfo'])) { |
3264 | 3264 | $this->currentCert['signatureAlgorithm']['algorithm'] = |
@@ -3447,7 +3447,7 @@ discard block |
||
3447 | 3447 | $key->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm)); |
3448 | 3448 | $key->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); |
3449 | 3449 | |
3450 | - $this->currentCert['signature'] = base64_encode("\0" . $key->sign($this->signatureSubject)); |
|
3450 | + $this->currentCert['signature'] = base64_encode("\0".$key->sign($this->signatureSubject)); |
|
3451 | 3451 | return $this->currentCert; |
3452 | 3452 | } |
3453 | 3453 | default: |
@@ -3484,7 +3484,7 @@ discard block |
||
3484 | 3484 | if (strtolower($date) == 'lifetime') { |
3485 | 3485 | $temp = '99991231235959Z'; |
3486 | 3486 | $asn1 = new File_ASN1(); |
3487 | - $temp = chr(FILE_ASN1_TYPE_GENERALIZED_TIME) . $asn1->_encodeLength(strlen($temp)) . $temp; |
|
3487 | + $temp = chr(FILE_ASN1_TYPE_GENERALIZED_TIME).$asn1->_encodeLength(strlen($temp)).$temp; |
|
3488 | 3488 | $this->endDate = new File_ASN1_Element($temp); |
3489 | 3489 | } else { |
3490 | 3490 | $this->endDate = @date('D, d M y H:i:s O', @strtotime($date)); |
@@ -3938,7 +3938,7 @@ discard block |
||
3938 | 3938 | $attributes[$last]['value'][] = $value; |
3939 | 3939 | break; |
3940 | 3940 | default: |
3941 | - $attributes[] = array('type' => $id, 'value' => $disposition == FILE_X509_ATTR_ALL ? $value: array($value)); |
|
3941 | + $attributes[] = array('type' => $id, 'value' => $disposition == FILE_X509_ATTR_ALL ? $value : array($value)); |
|
3942 | 3942 | break; |
3943 | 3943 | } |
3944 | 3944 | |
@@ -4013,12 +4013,12 @@ discard block |
||
4013 | 4013 | } |
4014 | 4014 | $key = new Crypt_RSA(); |
4015 | 4015 | if (!$key->loadKey($raw)) { |
4016 | - return false; // Not an unencrypted RSA key. |
|
4016 | + return false; // Not an unencrypted RSA key. |
|
4017 | 4017 | } |
4018 | 4018 | if ($key->getPrivateKey() !== false) { // If private. |
4019 | 4019 | return $this->computeKeyIdentifier($key, $method); |
4020 | 4020 | } |
4021 | - $key = $raw; // Is a public key. |
|
4021 | + $key = $raw; // Is a public key. |
|
4022 | 4022 | break; |
4023 | 4023 | case strtolower(get_class($key)) == 'file_x509': |
4024 | 4024 | if (isset($key->publicKey)) { |
@@ -4268,7 +4268,7 @@ discard block |
||
4268 | 4268 | |
4269 | 4269 | if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) { |
4270 | 4270 | if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) { |
4271 | - return $this->_getExtension($id, $crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); |
|
4271 | + return $this->_getExtension($id, $crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); |
|
4272 | 4272 | } |
4273 | 4273 | } |
4274 | 4274 |
@@ -1711,8 +1711,7 @@ discard block |
||
1711 | 1711 | if ($map === false) { |
1712 | 1712 | user_error($id . ' is not a currently supported attribute', E_USER_NOTICE); |
1713 | 1713 | unset($attributes[$i]); |
1714 | - } |
|
1715 | - elseif (is_array($attributes[$i]['value'])) { |
|
1714 | + } elseif (is_array($attributes[$i]['value'])) { |
|
1716 | 1715 | $values = &$attributes[$i]['value']; |
1717 | 1716 | for ($j = 0; $j < count($values); $j++) { |
1718 | 1717 | switch ($id) { |
@@ -3345,8 +3344,7 @@ discard block |
||
3345 | 3344 | |
3346 | 3345 | if (!empty($this->serialNumber)) { |
3347 | 3346 | $crlNumber = $this->serialNumber; |
3348 | - } |
|
3349 | - else { |
|
3347 | + } else { |
|
3350 | 3348 | $crlNumber = $this->getExtension('id-ce-cRLNumber'); |
3351 | 3349 | $crlNumber = $crlNumber !== false ? $crlNumber->add(new Math_BigInteger(1)) : NULL; |
3352 | 3350 | } |
@@ -3359,8 +3357,7 @@ discard block |
||
3359 | 3357 | if (!$version) { |
3360 | 3358 | if (!empty($tbsCertList['crlExtensions'])) { |
3361 | 3359 | $version = 1; // v2. |
3362 | - } |
|
3363 | - elseif (!empty($tbsCertList['revokedCertificates'])) { |
|
3360 | + } elseif (!empty($tbsCertList['revokedCertificates'])) { |
|
3364 | 3361 | foreach ($tbsCertList['revokedCertificates'] as $cert) { |
3365 | 3362 | if (!empty($cert['crlEntryExtensions'])) { |
3366 | 3363 | $version = 1; // v2. |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * ?> |
252 | 252 | * </code> |
253 | 253 | * |
254 | - * @param optional $x base-10 number or base-$base number if $base set. |
|
254 | + * @param integer $x base-10 number or base-$base number if $base set. |
|
255 | 255 | * @param optional integer $base |
256 | 256 | * @return Math_BigInteger |
257 | 257 | * @access public |
@@ -1368,7 +1368,7 @@ discard block |
||
1368 | 1368 | * </code> |
1369 | 1369 | * |
1370 | 1370 | * @param Math_BigInteger $y |
1371 | - * @return Array |
|
1371 | + * @return Math_BigInteger[] |
|
1372 | 1372 | * @access public |
1373 | 1373 | * @internal This function is based off of {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=9 HAC 14.20}. |
1374 | 1374 | */ |
@@ -3520,8 +3520,8 @@ discard block |
||
3520 | 3520 | /** |
3521 | 3521 | * Array Repeat |
3522 | 3522 | * |
3523 | - * @param $input Array |
|
3524 | - * @param $multiplier mixed |
|
3523 | + * @param integer $input Array |
|
3524 | + * @param integer $multiplier mixed |
|
3525 | 3525 | * @return Array |
3526 | 3526 | * @access private |
3527 | 3527 | */ |
@@ -3536,7 +3536,7 @@ discard block |
||
3536 | 3536 | * Shifts binary strings $shift bits, essentially multiplying by 2**$shift. |
3537 | 3537 | * |
3538 | 3538 | * @param $x String |
3539 | - * @param $shift Integer |
|
3539 | + * @param integer $shift Integer |
|
3540 | 3540 | * @return String |
3541 | 3541 | * @access private |
3542 | 3542 | */ |
@@ -3565,7 +3565,7 @@ discard block |
||
3565 | 3565 | * Shifts binary strings $shift bits, essentially dividing by 2**$shift and returning the remainder. |
3566 | 3566 | * |
3567 | 3567 | * @param $x String |
3568 | - * @param $shift Integer |
|
3568 | + * @param integer $shift Integer |
|
3569 | 3569 | * @return String |
3570 | 3570 | * @access private |
3571 | 3571 | */ |
@@ -1662,8 +1662,8 @@ discard block |
||
1662 | 1662 | ); |
1663 | 1663 | |
1664 | 1664 | $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . |
1665 | - chunk_split(base64_encode($encapsulated)) . |
|
1666 | - '-----END PUBLIC KEY-----'; |
|
1665 | + chunk_split(base64_encode($encapsulated)) . |
|
1666 | + '-----END PUBLIC KEY-----'; |
|
1667 | 1667 | |
1668 | 1668 | $plaintext = str_pad($this->toBytes(), strlen($n->toBytes(true)) - 1, "\0", STR_PAD_LEFT); |
1669 | 1669 | |
@@ -3245,7 +3245,7 @@ discard block |
||
3245 | 3245 | |
3246 | 3246 | if (!$t) { |
3247 | 3247 | // see HAC 4.49 "Note (controlling the error probability)" |
3248 | - if ($length >= 163) { $t = 2; } // floor(1300 / 8) |
|
3248 | + if ($length >= 163) { $t = 2; } // floor(1300 / 8) |
|
3249 | 3249 | else if ($length >= 106) { $t = 3; } // floor( 850 / 8) |
3250 | 3250 | else if ($length >= 81 ) { $t = 4; } // floor( 650 / 8) |
3251 | 3251 | else if ($length >= 68 ) { $t = 5; } // floor( 550 / 8) |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | function Math_BigInteger($x = 0, $base = 10) |
260 | 260 | { |
261 | - if ( !defined('MATH_BIGINTEGER_MODE') ) { |
|
261 | + if (!defined('MATH_BIGINTEGER_MODE')) { |
|
262 | 262 | switch (true) { |
263 | 263 | case extension_loaded('gmp'): |
264 | 264 | define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP); |
@@ -282,25 +282,25 @@ discard block |
||
282 | 282 | if (!defined('MATH_BIGINTEGER_BASE') && MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_INTERNAL) { |
283 | 283 | switch (PHP_INT_SIZE) { |
284 | 284 | case 8: // use 64-bit integers if int size is 8 bytes |
285 | - define('MATH_BIGINTEGER_BASE', 31); |
|
286 | - define('MATH_BIGINTEGER_BASE_FULL', 0x80000000); |
|
287 | - define('MATH_BIGINTEGER_MAX_DIGIT', 0x7FFFFFFF); |
|
288 | - define('MATH_BIGINTEGER_MSB', 0x40000000); |
|
285 | + define('MATH_BIGINTEGER_BASE', 31); |
|
286 | + define('MATH_BIGINTEGER_BASE_FULL', 0x80000000); |
|
287 | + define('MATH_BIGINTEGER_MAX_DIGIT', 0x7FFFFFFF); |
|
288 | + define('MATH_BIGINTEGER_MSB', 0x40000000); |
|
289 | 289 | // 10**9 is the closest we can get to 2**31 without passing it |
290 | - define('MATH_BIGINTEGER_MAX10', 1000000000); |
|
291 | - define('MATH_BIGINTEGER_MAX10_LEN', 9); |
|
290 | + define('MATH_BIGINTEGER_MAX10', 1000000000); |
|
291 | + define('MATH_BIGINTEGER_MAX10_LEN', 9); |
|
292 | 292 | // the largest digit that may be used in addition / subtraction |
293 | 293 | define('MATH_BIGINTEGER_MAX_DIGIT2', pow(2, 62)); |
294 | 294 | break; |
295 | 295 | //case 4: // use 64-bit floats if int size is 4 bytes |
296 | 296 | default: |
297 | - define('MATH_BIGINTEGER_BASE', 26); |
|
298 | - define('MATH_BIGINTEGER_BASE_FULL', 0x4000000); |
|
299 | - define('MATH_BIGINTEGER_MAX_DIGIT', 0x3FFFFFF); |
|
300 | - define('MATH_BIGINTEGER_MSB', 0x2000000); |
|
297 | + define('MATH_BIGINTEGER_BASE', 26); |
|
298 | + define('MATH_BIGINTEGER_BASE_FULL', 0x4000000); |
|
299 | + define('MATH_BIGINTEGER_MAX_DIGIT', 0x3FFFFFF); |
|
300 | + define('MATH_BIGINTEGER_MSB', 0x2000000); |
|
301 | 301 | // 10**7 is the closest to 2**26 without passing it |
302 | - define('MATH_BIGINTEGER_MAX10', 10000000); |
|
303 | - define('MATH_BIGINTEGER_MAX10_LEN', 7); |
|
302 | + define('MATH_BIGINTEGER_MAX10', 10000000); |
|
303 | + define('MATH_BIGINTEGER_MAX10_LEN', 7); |
|
304 | 304 | // the largest digit that may be used in addition / subtraction |
305 | 305 | // we do pow(2, 52) instead of using 4503599627370496 directly because some |
306 | 306 | // PHP installations will truncate 4503599627370496. |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
311 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
311 | + switch (MATH_BIGINTEGER_MODE) { |
|
312 | 312 | case MATH_BIGINTEGER_MODE_GMP: |
313 | 313 | if (is_resource($x) && get_resource_type($x) == 'GMP integer') { |
314 | 314 | $this->value = $x; |
@@ -336,10 +336,10 @@ discard block |
||
336 | 336 | $this->is_negative = true; |
337 | 337 | } |
338 | 338 | case 256: |
339 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
339 | + switch (MATH_BIGINTEGER_MODE) { |
|
340 | 340 | case MATH_BIGINTEGER_MODE_GMP: |
341 | 341 | $sign = $this->is_negative ? '-' : ''; |
342 | - $this->value = gmp_init($sign . '0x' . bin2hex($x)); |
|
342 | + $this->value = gmp_init($sign.'0x'.bin2hex($x)); |
|
343 | 343 | break; |
344 | 344 | case MATH_BIGINTEGER_MODE_BCMATH: |
345 | 345 | // round $len to the nearest 4 (thanks, DavidMJ!) |
@@ -347,13 +347,13 @@ discard block |
||
347 | 347 | |
348 | 348 | $x = str_pad($x, $len, chr(0), STR_PAD_LEFT); |
349 | 349 | |
350 | - for ($i = 0; $i < $len; $i+= 4) { |
|
350 | + for ($i = 0; $i < $len; $i += 4) { |
|
351 | 351 | $this->value = bcmul($this->value, '4294967296', 0); // 4294967296 == 2**32 |
352 | 352 | $this->value = bcadd($this->value, 0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord($x[$i + 2]) << 8) | ord($x[$i + 3])), 0); |
353 | 353 | } |
354 | 354 | |
355 | 355 | if ($this->is_negative) { |
356 | - $this->value = '-' . $this->value; |
|
356 | + $this->value = '-'.$this->value; |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | break; |
@@ -387,20 +387,20 @@ discard block |
||
387 | 387 | $x = bin2hex(~pack('H*', $x)); |
388 | 388 | } |
389 | 389 | |
390 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
390 | + switch (MATH_BIGINTEGER_MODE) { |
|
391 | 391 | case MATH_BIGINTEGER_MODE_GMP: |
392 | - $temp = $this->is_negative ? '-0x' . $x : '0x' . $x; |
|
392 | + $temp = $this->is_negative ? '-0x'.$x : '0x'.$x; |
|
393 | 393 | $this->value = gmp_init($temp); |
394 | 394 | $this->is_negative = false; |
395 | 395 | break; |
396 | 396 | case MATH_BIGINTEGER_MODE_BCMATH: |
397 | - $x = ( strlen($x) & 1 ) ? '0' . $x : $x; |
|
397 | + $x = (strlen($x) & 1) ? '0'.$x : $x; |
|
398 | 398 | $temp = new Math_BigInteger(pack('H*', $x), 256); |
399 | - $this->value = $this->is_negative ? '-' . $temp->value : $temp->value; |
|
399 | + $this->value = $this->is_negative ? '-'.$temp->value : $temp->value; |
|
400 | 400 | $this->is_negative = false; |
401 | 401 | break; |
402 | 402 | default: |
403 | - $x = ( strlen($x) & 1 ) ? '0' . $x : $x; |
|
403 | + $x = (strlen($x) & 1) ? '0'.$x : $x; |
|
404 | 404 | $temp = new Math_BigInteger(pack('H*', $x), 256); |
405 | 405 | $this->value = $temp->value; |
406 | 406 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | // [^-0-9].*: find any non-numeric characters and then any characters that follow that |
418 | 418 | $x = preg_replace('#(?<!^)(?:-).*|(?<=^|-)0*|[^-0-9].*#', '', $x); |
419 | 419 | |
420 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
420 | + switch (MATH_BIGINTEGER_MODE) { |
|
421 | 421 | case MATH_BIGINTEGER_MODE_GMP: |
422 | 422 | $this->value = gmp_init($x); |
423 | 423 | break; |
@@ -461,12 +461,12 @@ discard block |
||
461 | 461 | $str = '0x'; |
462 | 462 | while (strlen($x)) { |
463 | 463 | $part = substr($x, 0, 4); |
464 | - $str.= dechex(bindec($part)); |
|
464 | + $str .= dechex(bindec($part)); |
|
465 | 465 | $x = substr($x, 4); |
466 | 466 | } |
467 | 467 | |
468 | 468 | if ($this->is_negative) { |
469 | - $str = '-' . $str; |
|
469 | + $str = '-'.$str; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | $temp = new Math_BigInteger($str, 8 * $base); // ie. either -16 or +16 |
@@ -517,25 +517,24 @@ discard block |
||
517 | 517 | } |
518 | 518 | |
519 | 519 | if (ord($bytes[0]) & 0x80) { |
520 | - $bytes = chr(0) . $bytes; |
|
520 | + $bytes = chr(0).$bytes; |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | return $comparison < 0 ? ~$bytes : $bytes; |
524 | 524 | } |
525 | 525 | |
526 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
526 | + switch (MATH_BIGINTEGER_MODE) { |
|
527 | 527 | case MATH_BIGINTEGER_MODE_GMP: |
528 | 528 | if (gmp_cmp($this->value, gmp_init(0)) == 0) { |
529 | 529 | return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : ''; |
530 | 530 | } |
531 | 531 | |
532 | 532 | $temp = gmp_strval(gmp_abs($this->value), 16); |
533 | - $temp = ( strlen($temp) & 1 ) ? '0' . $temp : $temp; |
|
533 | + $temp = (strlen($temp) & 1) ? '0'.$temp : $temp; |
|
534 | 534 | $temp = pack('H*', $temp); |
535 | 535 | |
536 | 536 | return $this->precision > 0 ? |
537 | - substr(str_pad($temp, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) : |
|
538 | - ltrim($temp, chr(0)); |
|
537 | + substr(str_pad($temp, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) : ltrim($temp, chr(0)); |
|
539 | 538 | case MATH_BIGINTEGER_MODE_BCMATH: |
540 | 539 | if ($this->value === '0') { |
541 | 540 | return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : ''; |
@@ -550,13 +549,12 @@ discard block |
||
550 | 549 | |
551 | 550 | while (bccomp($current, '0', 0) > 0) { |
552 | 551 | $temp = bcmod($current, '16777216'); |
553 | - $value = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $value; |
|
552 | + $value = chr($temp >> 16).chr($temp >> 8).chr($temp).$value; |
|
554 | 553 | $current = bcdiv($current, '16777216', 0); |
555 | 554 | } |
556 | 555 | |
557 | 556 | return $this->precision > 0 ? |
558 | - substr(str_pad($value, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) : |
|
559 | - ltrim($value, chr(0)); |
|
557 | + substr(str_pad($value, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) : ltrim($value, chr(0)); |
|
560 | 558 | } |
561 | 559 | |
562 | 560 | if (!count($this->value)) { |
@@ -572,8 +570,7 @@ discard block |
||
572 | 570 | } |
573 | 571 | |
574 | 572 | return $this->precision > 0 ? |
575 | - str_pad(substr($result, -(($this->precision + 7) >> 3)), ($this->precision + 7) >> 3, chr(0), STR_PAD_LEFT) : |
|
576 | - $result; |
|
573 | + str_pad(substr($result, -(($this->precision + 7) >> 3)), ($this->precision + 7) >> 3, chr(0), STR_PAD_LEFT) : $result; |
|
577 | 574 | } |
578 | 575 | |
579 | 576 | /** |
@@ -629,16 +626,16 @@ discard block |
||
629 | 626 | { |
630 | 627 | $hex = $this->toHex($twos_compliment); |
631 | 628 | $bits = ''; |
632 | - for ($i = strlen($hex) - 8, $start = strlen($hex) & 7; $i >= $start; $i-=8) { |
|
633 | - $bits = str_pad(decbin(hexdec(substr($hex, $i, 8))), 32, '0', STR_PAD_LEFT) . $bits; |
|
629 | + for ($i = strlen($hex) - 8, $start = strlen($hex) & 7; $i >= $start; $i -= 8) { |
|
630 | + $bits = str_pad(decbin(hexdec(substr($hex, $i, 8))), 32, '0', STR_PAD_LEFT).$bits; |
|
634 | 631 | } |
635 | 632 | if ($start) { // hexdec('') == 0 |
636 | - $bits = str_pad(decbin(hexdec(substr($hex, 0, $start))), 8, '0', STR_PAD_LEFT) . $bits; |
|
633 | + $bits = str_pad(decbin(hexdec(substr($hex, 0, $start))), 8, '0', STR_PAD_LEFT).$bits; |
|
637 | 634 | } |
638 | 635 | $result = $this->precision > 0 ? substr($bits, -$this->precision) : ltrim($bits, '0'); |
639 | 636 | |
640 | 637 | if ($twos_compliment && $this->compare(new Math_BigInteger()) > 0 && $this->precision <= 0) { |
641 | - return '0' . $result; |
|
638 | + return '0'.$result; |
|
642 | 639 | } |
643 | 640 | |
644 | 641 | return $result; |
@@ -664,7 +661,7 @@ discard block |
||
664 | 661 | */ |
665 | 662 | function toString() |
666 | 663 | { |
667 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
664 | + switch (MATH_BIGINTEGER_MODE) { |
|
668 | 665 | case MATH_BIGINTEGER_MODE_GMP: |
669 | 666 | return gmp_strval($this->value); |
670 | 667 | case MATH_BIGINTEGER_MODE_BCMATH: |
@@ -687,7 +684,7 @@ discard block |
||
687 | 684 | $result = ''; |
688 | 685 | while (count($temp->value)) { |
689 | 686 | list($temp, $mod) = $temp->divide($divisor); |
690 | - $result = str_pad(isset($mod->value[0]) ? $mod->value[0] : '', MATH_BIGINTEGER_MAX10_LEN, '0', STR_PAD_LEFT) . $result; |
|
687 | + $result = str_pad(isset($mod->value[0]) ? $mod->value[0] : '', MATH_BIGINTEGER_MAX10_LEN, '0', STR_PAD_LEFT).$result; |
|
691 | 688 | } |
692 | 689 | $result = ltrim($result, '0'); |
693 | 690 | if (empty($result)) { |
@@ -695,7 +692,7 @@ discard block |
||
695 | 692 | } |
696 | 693 | |
697 | 694 | if ($this->is_negative) { |
698 | - $result = '-' . $result; |
|
695 | + $result = '-'.$result; |
|
699 | 696 | } |
700 | 697 | |
701 | 698 | return $result; |
@@ -821,7 +818,7 @@ discard block |
||
821 | 818 | */ |
822 | 819 | function add($y) |
823 | 820 | { |
824 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
821 | + switch (MATH_BIGINTEGER_MODE) { |
|
825 | 822 | case MATH_BIGINTEGER_MODE_GMP: |
826 | 823 | $temp = new Math_BigInteger(); |
827 | 824 | $temp->value = gmp_add($this->value, $y->value); |
@@ -871,8 +868,8 @@ discard block |
||
871 | 868 | } |
872 | 869 | |
873 | 870 | // subtract, if appropriate |
874 | - if ( $x_negative != $y_negative ) { |
|
875 | - if ( $x_value == $y_value ) { |
|
871 | + if ($x_negative != $y_negative) { |
|
872 | + if ($x_value == $y_value) { |
|
876 | 873 | return array( |
877 | 874 | MATH_BIGINTEGER_VALUE => array(), |
878 | 875 | MATH_BIGINTEGER_SIGN => false |
@@ -897,7 +894,7 @@ discard block |
||
897 | 894 | $value[] = 0; // just in case the carry adds an extra digit |
898 | 895 | |
899 | 896 | $carry = 0; |
900 | - for ($i = 0, $j = 1; $j < $size; $i+=2, $j+=2) { |
|
897 | + for ($i = 0, $j = 1; $j < $size; $i += 2, $j += 2) { |
|
901 | 898 | $sum = $x_value[$j] * MATH_BIGINTEGER_BASE_FULL + $x_value[$i] + $y_value[$j] * MATH_BIGINTEGER_BASE_FULL + $y_value[$i] + $carry; |
902 | 899 | $carry = $sum >= MATH_BIGINTEGER_MAX_DIGIT2; // eg. floor($sum / 2**52); only possible values (in any base) are 0 and 1 |
903 | 900 | $sum = $carry ? $sum - MATH_BIGINTEGER_MAX_DIGIT2 : $sum; |
@@ -952,7 +949,7 @@ discard block |
||
952 | 949 | */ |
953 | 950 | function subtract($y) |
954 | 951 | { |
955 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
952 | + switch (MATH_BIGINTEGER_MODE) { |
|
956 | 953 | case MATH_BIGINTEGER_MODE_GMP: |
957 | 954 | $temp = new Math_BigInteger(); |
958 | 955 | $temp->value = gmp_sub($this->value, $y->value); |
@@ -1002,7 +999,7 @@ discard block |
||
1002 | 999 | } |
1003 | 1000 | |
1004 | 1001 | // add, if appropriate (ie. -$x - +$y or +$x - -$y) |
1005 | - if ( $x_negative != $y_negative ) { |
|
1002 | + if ($x_negative != $y_negative) { |
|
1006 | 1003 | $temp = $this->_add($x_value, false, $y_value, false); |
1007 | 1004 | $temp[MATH_BIGINTEGER_SIGN] = $x_negative; |
1008 | 1005 | |
@@ -1011,7 +1008,7 @@ discard block |
||
1011 | 1008 | |
1012 | 1009 | $diff = $this->_compare($x_value, $x_negative, $y_value, $y_negative); |
1013 | 1010 | |
1014 | - if ( !$diff ) { |
|
1011 | + if (!$diff) { |
|
1015 | 1012 | return array( |
1016 | 1013 | MATH_BIGINTEGER_VALUE => array(), |
1017 | 1014 | MATH_BIGINTEGER_SIGN => false |
@@ -1019,7 +1016,7 @@ discard block |
||
1019 | 1016 | } |
1020 | 1017 | |
1021 | 1018 | // switch $x and $y around, if appropriate. |
1022 | - if ( (!$x_negative && $diff < 0) || ($x_negative && $diff > 0) ) { |
|
1019 | + if ((!$x_negative && $diff < 0) || ($x_negative && $diff > 0)) { |
|
1023 | 1020 | $temp = $x_value; |
1024 | 1021 | $x_value = $y_value; |
1025 | 1022 | $y_value = $temp; |
@@ -1033,7 +1030,7 @@ discard block |
||
1033 | 1030 | // at this point, $x_value should be at least as big as - if not bigger than - $y_value |
1034 | 1031 | |
1035 | 1032 | $carry = 0; |
1036 | - for ($i = 0, $j = 1; $j < $y_size; $i+=2, $j+=2) { |
|
1033 | + for ($i = 0, $j = 1; $j < $y_size; $i += 2, $j += 2) { |
|
1037 | 1034 | $sum = $x_value[$j] * MATH_BIGINTEGER_BASE_FULL + $x_value[$i] - $y_value[$j] * MATH_BIGINTEGER_BASE_FULL - $y_value[$i] - $carry; |
1038 | 1035 | $carry = $sum < 0; // eg. floor($sum / 2**52); only possible values (in any base) are 0 and 1 |
1039 | 1036 | $sum = $carry ? $sum + MATH_BIGINTEGER_MAX_DIGIT2 : $sum; |
@@ -1087,7 +1084,7 @@ discard block |
||
1087 | 1084 | */ |
1088 | 1085 | function multiply($x) |
1089 | 1086 | { |
1090 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
1087 | + switch (MATH_BIGINTEGER_MODE) { |
|
1091 | 1088 | case MATH_BIGINTEGER_MODE_GMP: |
1092 | 1089 | $temp = new Math_BigInteger(); |
1093 | 1090 | $temp->value = gmp_mul($this->value, $x->value); |
@@ -1131,7 +1128,7 @@ discard block |
||
1131 | 1128 | $x_length = count($x_value); |
1132 | 1129 | $y_length = count($y_value); |
1133 | 1130 | |
1134 | - if ( !$x_length || !$y_length ) { // a 0 is being multiplied |
|
1131 | + if (!$x_length || !$y_length) { // a 0 is being multiplied |
|
1135 | 1132 | return array( |
1136 | 1133 | MATH_BIGINTEGER_VALUE => array(), |
1137 | 1134 | MATH_BIGINTEGER_SIGN => false |
@@ -1140,8 +1137,7 @@ discard block |
||
1140 | 1137 | |
1141 | 1138 | return array( |
1142 | 1139 | MATH_BIGINTEGER_VALUE => min($x_length, $y_length) < 2 * MATH_BIGINTEGER_KARATSUBA_CUTOFF ? |
1143 | - $this->_trim($this->_regularMultiply($x_value, $y_value)) : |
|
1144 | - $this->_trim($this->_karatsuba($x_value, $y_value)), |
|
1140 | + $this->_trim($this->_regularMultiply($x_value, $y_value)) : $this->_trim($this->_karatsuba($x_value, $y_value)), |
|
1145 | 1141 | MATH_BIGINTEGER_SIGN => $x_negative != $y_negative |
1146 | 1142 | ); |
1147 | 1143 | } |
@@ -1161,11 +1157,11 @@ discard block |
||
1161 | 1157 | $x_length = count($x_value); |
1162 | 1158 | $y_length = count($y_value); |
1163 | 1159 | |
1164 | - if ( !$x_length || !$y_length ) { // a 0 is being multiplied |
|
1160 | + if (!$x_length || !$y_length) { // a 0 is being multiplied |
|
1165 | 1161 | return array(); |
1166 | 1162 | } |
1167 | 1163 | |
1168 | - if ( $x_length < $y_length ) { |
|
1164 | + if ($x_length < $y_length) { |
|
1169 | 1165 | $temp = $x_value; |
1170 | 1166 | $x_value = $y_value; |
1171 | 1167 | $y_value = $temp; |
@@ -1261,8 +1257,7 @@ discard block |
||
1261 | 1257 | function _square($x = false) |
1262 | 1258 | { |
1263 | 1259 | return count($x) < 2 * MATH_BIGINTEGER_KARATSUBA_CUTOFF ? |
1264 | - $this->_trim($this->_baseSquare($x)) : |
|
1265 | - $this->_trim($this->_karatsubaSquare($x)); |
|
1260 | + $this->_trim($this->_baseSquare($x)) : $this->_trim($this->_karatsubaSquare($x)); |
|
1266 | 1261 | } |
1267 | 1262 | |
1268 | 1263 | /** |
@@ -1278,7 +1273,7 @@ discard block |
||
1278 | 1273 | */ |
1279 | 1274 | function _baseSquare($value) |
1280 | 1275 | { |
1281 | - if ( empty($value) ) { |
|
1276 | + if (empty($value)) { |
|
1282 | 1277 | return array(); |
1283 | 1278 | } |
1284 | 1279 | $square_value = $this->_array_repeat(0, 2 * count($value)); |
@@ -1374,7 +1369,7 @@ discard block |
||
1374 | 1369 | */ |
1375 | 1370 | function divide($y) |
1376 | 1371 | { |
1377 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
1372 | + switch (MATH_BIGINTEGER_MODE) { |
|
1378 | 1373 | case MATH_BIGINTEGER_MODE_GMP: |
1379 | 1374 | $quotient = new Math_BigInteger(); |
1380 | 1375 | $remainder = new Math_BigInteger(); |
@@ -1411,7 +1406,7 @@ discard block |
||
1411 | 1406 | } |
1412 | 1407 | |
1413 | 1408 | static $zero; |
1414 | - if ( !isset($zero) ) { |
|
1409 | + if (!isset($zero)) { |
|
1415 | 1410 | $zero = new Math_BigInteger(); |
1416 | 1411 | } |
1417 | 1412 | |
@@ -1425,16 +1420,16 @@ discard block |
||
1425 | 1420 | |
1426 | 1421 | $diff = $x->compare($y); |
1427 | 1422 | |
1428 | - if ( !$diff ) { |
|
1423 | + if (!$diff) { |
|
1429 | 1424 | $temp = new Math_BigInteger(); |
1430 | 1425 | $temp->value = array(1); |
1431 | 1426 | $temp->is_negative = $x_sign != $y_sign; |
1432 | 1427 | return array($this->_normalize($temp), $this->_normalize(new Math_BigInteger())); |
1433 | 1428 | } |
1434 | 1429 | |
1435 | - if ( $diff < 0 ) { |
|
1430 | + if ($diff < 0) { |
|
1436 | 1431 | // if $x is negative, "add" $y. |
1437 | - if ( $x_sign ) { |
|
1432 | + if ($x_sign) { |
|
1438 | 1433 | $x = $y->subtract($x); |
1439 | 1434 | } |
1440 | 1435 | return array($this->_normalize(new Math_BigInteger()), $this->_normalize($x)); |
@@ -1459,16 +1454,16 @@ discard block |
||
1459 | 1454 | static $temp, $lhs, $rhs; |
1460 | 1455 | if (!isset($temp)) { |
1461 | 1456 | $temp = new Math_BigInteger(); |
1462 | - $lhs = new Math_BigInteger(); |
|
1463 | - $rhs = new Math_BigInteger(); |
|
1457 | + $lhs = new Math_BigInteger(); |
|
1458 | + $rhs = new Math_BigInteger(); |
|
1464 | 1459 | } |
1465 | 1460 | $temp_value = &$temp->value; |
1466 | - $rhs_value = &$rhs->value; |
|
1461 | + $rhs_value = &$rhs->value; |
|
1467 | 1462 | |
1468 | 1463 | // $temp = $y << ($x_max - $y_max-1) in base 2**26 |
1469 | 1464 | $temp_value = array_merge($this->_array_repeat(0, $x_max - $y_max), $y_value); |
1470 | 1465 | |
1471 | - while ( $x->compare($temp) >= 0 ) { |
|
1466 | + while ($x->compare($temp) >= 0) { |
|
1472 | 1467 | // calculate the "common residue" |
1473 | 1468 | ++$quotient_value[$x_max - $y_max]; |
1474 | 1469 | $x = $x->subtract($temp); |
@@ -1484,7 +1479,7 @@ discard block |
||
1484 | 1479 | ); |
1485 | 1480 | $y_window = array( |
1486 | 1481 | $y_value[$y_max], |
1487 | - ( $y_max > 0 ) ? $y_value[$y_max - 1] : 0 |
|
1482 | + ($y_max > 0) ? $y_value[$y_max - 1] : 0 |
|
1488 | 1483 | ); |
1489 | 1484 | |
1490 | 1485 | $q_index = $i - $y_max - 1; |
@@ -1505,7 +1500,7 @@ discard block |
||
1505 | 1500 | |
1506 | 1501 | $rhs_value = array($x_window[2], $x_window[1], $x_window[0]); |
1507 | 1502 | |
1508 | - while ( $lhs->compare($rhs) > 0 ) { |
|
1503 | + while ($lhs->compare($rhs) > 0) { |
|
1509 | 1504 | --$quotient_value[$q_index]; |
1510 | 1505 | |
1511 | 1506 | $lhs->value = array($quotient_value[$q_index]); |
@@ -1536,7 +1531,7 @@ discard block |
||
1536 | 1531 | $quotient->is_negative = $x_sign != $y_sign; |
1537 | 1532 | |
1538 | 1533 | // calculate the "common residue", if appropriate |
1539 | - if ( $x_sign ) { |
|
1534 | + if ($x_sign) { |
|
1540 | 1535 | $y->_rshift($shift); |
1541 | 1536 | $x = $y->subtract($x); |
1542 | 1537 | } |
@@ -1625,7 +1620,7 @@ discard block |
||
1625 | 1620 | return $this->_normalize($temp->modPow($e, $n)); |
1626 | 1621 | } |
1627 | 1622 | |
1628 | - if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_GMP ) { |
|
1623 | + if (MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_GMP) { |
|
1629 | 1624 | $temp = new Math_BigInteger(); |
1630 | 1625 | $temp->value = gmp_powm($this->value, $e->value, $n->value); |
1631 | 1626 | |
@@ -1654,15 +1649,15 @@ discard block |
||
1654 | 1649 | ); |
1655 | 1650 | |
1656 | 1651 | $rsaOID = pack('H*', '300d06092a864886f70d0101010500'); // hex version of MA0GCSqGSIb3DQEBAQUA |
1657 | - $RSAPublicKey = chr(0) . $RSAPublicKey; |
|
1658 | - $RSAPublicKey = chr(3) . $this->_encodeASN1Length(strlen($RSAPublicKey)) . $RSAPublicKey; |
|
1652 | + $RSAPublicKey = chr(0).$RSAPublicKey; |
|
1653 | + $RSAPublicKey = chr(3).$this->_encodeASN1Length(strlen($RSAPublicKey)).$RSAPublicKey; |
|
1659 | 1654 | |
1660 | 1655 | $encapsulated = pack('Ca*a*', |
1661 | - 48, $this->_encodeASN1Length(strlen($rsaOID . $RSAPublicKey)), $rsaOID . $RSAPublicKey |
|
1656 | + 48, $this->_encodeASN1Length(strlen($rsaOID.$RSAPublicKey)), $rsaOID.$RSAPublicKey |
|
1662 | 1657 | ); |
1663 | 1658 | |
1664 | - $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . |
|
1665 | - chunk_split(base64_encode($encapsulated)) . |
|
1659 | + $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n". |
|
1660 | + chunk_split(base64_encode($encapsulated)). |
|
1666 | 1661 | '-----END PUBLIC KEY-----'; |
1667 | 1662 | |
1668 | 1663 | $plaintext = str_pad($this->toBytes(), strlen($n->toBytes(true)) - 1, "\0", STR_PAD_LEFT); |
@@ -1672,25 +1667,25 @@ discard block |
||
1672 | 1667 | } |
1673 | 1668 | } |
1674 | 1669 | |
1675 | - if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH ) { |
|
1670 | + if (MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH) { |
|
1676 | 1671 | $temp = new Math_BigInteger(); |
1677 | 1672 | $temp->value = bcpowmod($this->value, $e->value, $n->value, 0); |
1678 | 1673 | |
1679 | 1674 | return $this->_normalize($temp); |
1680 | 1675 | } |
1681 | 1676 | |
1682 | - if ( empty($e->value) ) { |
|
1677 | + if (empty($e->value)) { |
|
1683 | 1678 | $temp = new Math_BigInteger(); |
1684 | 1679 | $temp->value = array(1); |
1685 | 1680 | return $this->_normalize($temp); |
1686 | 1681 | } |
1687 | 1682 | |
1688 | - if ( $e->value == array(1) ) { |
|
1683 | + if ($e->value == array(1)) { |
|
1689 | 1684 | list(, $temp) = $this->divide($n); |
1690 | 1685 | return $this->_normalize($temp); |
1691 | 1686 | } |
1692 | 1687 | |
1693 | - if ( $e->value == array(2) ) { |
|
1688 | + if ($e->value == array(2)) { |
|
1694 | 1689 | $temp = new Math_BigInteger(); |
1695 | 1690 | $temp->value = $this->_square($this->value); |
1696 | 1691 | list(, $temp) = $temp->divide($n); |
@@ -1700,17 +1695,17 @@ discard block |
||
1700 | 1695 | return $this->_normalize($this->_slidingWindow($e, $n, MATH_BIGINTEGER_BARRETT)); |
1701 | 1696 | |
1702 | 1697 | // is the modulo odd? |
1703 | - if ( $n->value[0] & 1 ) { |
|
1698 | + if ($n->value[0] & 1) { |
|
1704 | 1699 | return $this->_normalize($this->_slidingWindow($e, $n, MATH_BIGINTEGER_MONTGOMERY)); |
1705 | 1700 | } |
1706 | 1701 | // if it's not, it's even |
1707 | 1702 | |
1708 | 1703 | // find the lowest set bit (eg. the max pow of 2 that divides $n) |
1709 | 1704 | for ($i = 0; $i < count($n->value); ++$i) { |
1710 | - if ( $n->value[$i] ) { |
|
1705 | + if ($n->value[$i]) { |
|
1711 | 1706 | $temp = decbin($n->value[$i]); |
1712 | 1707 | $j = strlen($temp) - strrpos($temp, '1') - 1; |
1713 | - $j+= 26 * $i; |
|
1708 | + $j += 26 * $i; |
|
1714 | 1709 | break; |
1715 | 1710 | } |
1716 | 1711 | } |
@@ -1722,7 +1717,7 @@ discard block |
||
1722 | 1717 | $mod2->value = array(1); |
1723 | 1718 | $mod2->_lshift($j); |
1724 | 1719 | |
1725 | - $part1 = ( $mod1->value != array(1) ) ? $this->_slidingWindow($e, $mod1, MATH_BIGINTEGER_MONTGOMERY) : new Math_BigInteger(); |
|
1720 | + $part1 = ($mod1->value != array(1)) ? $this->_slidingWindow($e, $mod1, MATH_BIGINTEGER_MONTGOMERY) : new Math_BigInteger(); |
|
1726 | 1721 | $part2 = $this->_slidingWindow($e, $mod2, MATH_BIGINTEGER_POWEROF2); |
1727 | 1722 | |
1728 | 1723 | $y1 = $mod2->modInverse($mod1); |
@@ -1778,7 +1773,7 @@ discard block |
||
1778 | 1773 | $e_length = count($e_value) - 1; |
1779 | 1774 | $e_bits = decbin($e_value[$e_length]); |
1780 | 1775 | for ($i = $e_length - 1; $i >= 0; --$i) { |
1781 | - $e_bits.= str_pad(decbin($e_value[$i]), MATH_BIGINTEGER_BASE, '0', STR_PAD_LEFT); |
|
1776 | + $e_bits .= str_pad(decbin($e_value[$i]), MATH_BIGINTEGER_BASE, '0', STR_PAD_LEFT); |
|
1782 | 1777 | } |
1783 | 1778 | |
1784 | 1779 | $e_length = strlen($e_bits); |
@@ -1805,13 +1800,13 @@ discard block |
||
1805 | 1800 | $result = array(1); |
1806 | 1801 | $result = $this->_prepareReduce($result, $n_value, $mode); |
1807 | 1802 | |
1808 | - for ($i = 0; $i < $e_length; ) { |
|
1809 | - if ( !$e_bits[$i] ) { |
|
1803 | + for ($i = 0; $i < $e_length;) { |
|
1804 | + if (!$e_bits[$i]) { |
|
1810 | 1805 | $result = $this->_squareReduce($result, $n_value, $mode); |
1811 | 1806 | ++$i; |
1812 | 1807 | } else { |
1813 | 1808 | for ($j = $window_size - 1; $j > 0; --$j) { |
1814 | - if ( !empty($e_bits[$i + $j]) ) { |
|
1809 | + if (!empty($e_bits[$i + $j])) { |
|
1815 | 1810 | break; |
1816 | 1811 | } |
1817 | 1812 | } |
@@ -1822,7 +1817,7 @@ discard block |
||
1822 | 1817 | |
1823 | 1818 | $result = $this->_multiplyReduce($result, $powers[bindec(substr($e_bits, $i, $j + 1))], $n_value, $mode); |
1824 | 1819 | |
1825 | - $i+=$j + 1; |
|
1820 | + $i += $j + 1; |
|
1826 | 1821 | } |
1827 | 1822 | } |
1828 | 1823 | |
@@ -1995,7 +1990,7 @@ discard block |
||
1995 | 1990 | |
1996 | 1991 | // n = 2 * m.length |
1997 | 1992 | |
1998 | - if ( ($key = array_search($m, $cache[MATH_BIGINTEGER_VARIABLE])) === false ) { |
|
1993 | + if (($key = array_search($m, $cache[MATH_BIGINTEGER_VARIABLE])) === false) { |
|
1999 | 1994 | $key = count($cache[MATH_BIGINTEGER_VARIABLE]); |
2000 | 1995 | $cache[MATH_BIGINTEGER_VARIABLE][] = $m; |
2001 | 1996 | |
@@ -2020,7 +2015,7 @@ discard block |
||
2020 | 2015 | |
2021 | 2016 | $cutoff = $m_length + ($m_length >> 1); |
2022 | 2017 | $lsd = array_slice($n, 0, $cutoff); // m.length + (m.length >> 1) |
2023 | - $msd = array_slice($n, $cutoff); // m.length >> 1 |
|
2018 | + $msd = array_slice($n, $cutoff); // m.length >> 1 |
|
2024 | 2019 | $lsd = $this->_trim($lsd); |
2025 | 2020 | $temp = $this->_multiply($msd, false, $m1, false); |
2026 | 2021 | $n = $this->_add($lsd, false, $temp[MATH_BIGINTEGER_VALUE], false); // m.length + (m.length >> 1) + 1 |
@@ -2084,7 +2079,7 @@ discard block |
||
2084 | 2079 | return $temp->value; |
2085 | 2080 | } |
2086 | 2081 | |
2087 | - if ( ($key = array_search($n, $cache[MATH_BIGINTEGER_VARIABLE])) === false ) { |
|
2082 | + if (($key = array_search($n, $cache[MATH_BIGINTEGER_VARIABLE])) === false) { |
|
2088 | 2083 | $key = count($cache[MATH_BIGINTEGER_VARIABLE]); |
2089 | 2084 | $cache[MATH_BIGINTEGER_VARIABLE][] = $n; |
2090 | 2085 | $lhs = new Math_BigInteger(); |
@@ -2093,7 +2088,7 @@ discard block |
||
2093 | 2088 | $lhs_value[] = 1; |
2094 | 2089 | $rhs = new Math_BigInteger(); |
2095 | 2090 | $rhs->value = $n; |
2096 | - list($temp, ) = $lhs->divide($rhs); // m.length |
|
2091 | + list($temp,) = $lhs->divide($rhs); // m.length |
|
2097 | 2092 | $cache[MATH_BIGINTEGER_DATA][] = $temp->value; |
2098 | 2093 | } |
2099 | 2094 | |
@@ -2145,14 +2140,14 @@ discard block |
||
2145 | 2140 | $x_length = count($x_value); |
2146 | 2141 | $y_length = count($y_value); |
2147 | 2142 | |
2148 | - if ( !$x_length || !$y_length ) { // a 0 is being multiplied |
|
2143 | + if (!$x_length || !$y_length) { // a 0 is being multiplied |
|
2149 | 2144 | return array( |
2150 | 2145 | MATH_BIGINTEGER_VALUE => array(), |
2151 | 2146 | MATH_BIGINTEGER_SIGN => false |
2152 | 2147 | ); |
2153 | 2148 | } |
2154 | 2149 | |
2155 | - if ( $x_length < $y_length ) { |
|
2150 | + if ($x_length < $y_length) { |
|
2156 | 2151 | $temp = $x_value; |
2157 | 2152 | $x_value = $y_value; |
2158 | 2153 | $y_value = $temp; |
@@ -2226,7 +2221,7 @@ discard block |
||
2226 | 2221 | MATH_BIGINTEGER_DATA => array() |
2227 | 2222 | ); |
2228 | 2223 | |
2229 | - if ( ($key = array_search($n, $cache[MATH_BIGINTEGER_VARIABLE])) === false ) { |
|
2224 | + if (($key = array_search($n, $cache[MATH_BIGINTEGER_VARIABLE])) === false) { |
|
2230 | 2225 | $key = count($cache[MATH_BIGINTEGER_VARIABLE]); |
2231 | 2226 | $cache[MATH_BIGINTEGER_VARIABLE][] = $x; |
2232 | 2227 | $cache[MATH_BIGINTEGER_DATA][] = $this->_modInverse67108864($n); |
@@ -2277,7 +2272,7 @@ discard block |
||
2277 | 2272 | MATH_BIGINTEGER_DATA => array() |
2278 | 2273 | ); |
2279 | 2274 | |
2280 | - if ( ($key = array_search($m, $cache[MATH_BIGINTEGER_VARIABLE])) === false ) { |
|
2275 | + if (($key = array_search($m, $cache[MATH_BIGINTEGER_VARIABLE])) === false) { |
|
2281 | 2276 | $key = count($cache[MATH_BIGINTEGER_VARIABLE]); |
2282 | 2277 | $cache[MATH_BIGINTEGER_VARIABLE][] = $m; |
2283 | 2278 | $cache[MATH_BIGINTEGER_DATA][] = $this->_modInverse67108864($m); |
@@ -2355,7 +2350,7 @@ discard block |
||
2355 | 2350 | $x = -$x[0]; |
2356 | 2351 | $result = $x & 0x3; // x**-1 mod 2**2 |
2357 | 2352 | $result = ($result * (2 - $x * $result)) & 0xF; // x**-1 mod 2**4 |
2358 | - $result = ($result * (2 - ($x & 0xFF) * $result)) & 0xFF; // x**-1 mod 2**8 |
|
2353 | + $result = ($result * (2 - ($x & 0xFF) * $result)) & 0xFF; // x**-1 mod 2**8 |
|
2359 | 2354 | $result = ($result * ((2 - ($x & 0xFFFF) * $result) & 0xFFFF)) & 0xFFFF; // x**-1 mod 2**16 |
2360 | 2355 | $result = fmod($result * (2 - fmod($x * $result, MATH_BIGINTEGER_BASE_FULL)), MATH_BIGINTEGER_BASE_FULL); // x**-1 mod 2**26 |
2361 | 2356 | return $result & MATH_BIGINTEGER_MAX_DIGIT; |
@@ -2392,12 +2387,12 @@ discard block |
||
2392 | 2387 | */ |
2393 | 2388 | function modInverse($n) |
2394 | 2389 | { |
2395 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
2390 | + switch (MATH_BIGINTEGER_MODE) { |
|
2396 | 2391 | case MATH_BIGINTEGER_MODE_GMP: |
2397 | 2392 | $temp = new Math_BigInteger(); |
2398 | 2393 | $temp->value = gmp_invert($this->value, $n->value); |
2399 | 2394 | |
2400 | - return ( $temp->value === false ) ? false : $this->_normalize($temp); |
|
2395 | + return ($temp->value === false) ? false : $this->_normalize($temp); |
|
2401 | 2396 | } |
2402 | 2397 | |
2403 | 2398 | static $zero, $one; |
@@ -2458,7 +2453,7 @@ discard block |
||
2458 | 2453 | */ |
2459 | 2454 | function extendedGCD($n) |
2460 | 2455 | { |
2461 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
2456 | + switch (MATH_BIGINTEGER_MODE) { |
|
2462 | 2457 | case MATH_BIGINTEGER_MODE_GMP: |
2463 | 2458 | extract(gmp_gcdext($this->value, $n->value)); |
2464 | 2459 | |
@@ -2508,7 +2503,7 @@ discard block |
||
2508 | 2503 | $g = new Math_BigInteger(); |
2509 | 2504 | $g->value = array(1); |
2510 | 2505 | |
2511 | - while ( !(($x->value[0] & 1)|| ($y->value[0] & 1)) ) { |
|
2506 | + while (!(($x->value[0] & 1) || ($y->value[0] & 1))) { |
|
2512 | 2507 | $x->_rshift(1); |
2513 | 2508 | $y->_rshift(1); |
2514 | 2509 | $g->_lshift(1); |
@@ -2525,10 +2520,10 @@ discard block |
||
2525 | 2520 | $a->value = $d->value = $g->value = array(1); |
2526 | 2521 | $b->value = $c->value = array(); |
2527 | 2522 | |
2528 | - while ( !empty($u->value) ) { |
|
2529 | - while ( !($u->value[0] & 1) ) { |
|
2523 | + while (!empty($u->value)) { |
|
2524 | + while (!($u->value[0] & 1)) { |
|
2530 | 2525 | $u->_rshift(1); |
2531 | - if ( (!empty($a->value) && ($a->value[0] & 1)) || (!empty($b->value) && ($b->value[0] & 1)) ) { |
|
2526 | + if ((!empty($a->value) && ($a->value[0] & 1)) || (!empty($b->value) && ($b->value[0] & 1))) { |
|
2532 | 2527 | $a = $a->add($y); |
2533 | 2528 | $b = $b->subtract($x); |
2534 | 2529 | } |
@@ -2536,9 +2531,9 @@ discard block |
||
2536 | 2531 | $b->_rshift(1); |
2537 | 2532 | } |
2538 | 2533 | |
2539 | - while ( !($v->value[0] & 1) ) { |
|
2534 | + while (!($v->value[0] & 1)) { |
|
2540 | 2535 | $v->_rshift(1); |
2541 | - if ( (!empty($d->value) && ($d->value[0] & 1)) || (!empty($c->value) && ($c->value[0] & 1)) ) { |
|
2536 | + if ((!empty($d->value) && ($d->value[0] & 1)) || (!empty($c->value) && ($c->value[0] & 1))) { |
|
2542 | 2537 | $c = $c->add($y); |
2543 | 2538 | $d = $d->subtract($x); |
2544 | 2539 | } |
@@ -2603,7 +2598,7 @@ discard block |
||
2603 | 2598 | { |
2604 | 2599 | $temp = new Math_BigInteger(); |
2605 | 2600 | |
2606 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
2601 | + switch (MATH_BIGINTEGER_MODE) { |
|
2607 | 2602 | case MATH_BIGINTEGER_MODE_GMP: |
2608 | 2603 | $temp->value = gmp_abs($this->value); |
2609 | 2604 | break; |
@@ -2637,7 +2632,7 @@ discard block |
||
2637 | 2632 | */ |
2638 | 2633 | function compare($y) |
2639 | 2634 | { |
2640 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
2635 | + switch (MATH_BIGINTEGER_MODE) { |
|
2641 | 2636 | case MATH_BIGINTEGER_MODE_GMP: |
2642 | 2637 | return gmp_cmp($this->value, $y->value); |
2643 | 2638 | case MATH_BIGINTEGER_MODE_BCMATH: |
@@ -2660,14 +2655,14 @@ discard block |
||
2660 | 2655 | */ |
2661 | 2656 | function _compare($x_value, $x_negative, $y_value, $y_negative) |
2662 | 2657 | { |
2663 | - if ( $x_negative != $y_negative ) { |
|
2664 | - return ( !$x_negative && $y_negative ) ? 1 : -1; |
|
2658 | + if ($x_negative != $y_negative) { |
|
2659 | + return (!$x_negative && $y_negative) ? 1 : -1; |
|
2665 | 2660 | } |
2666 | 2661 | |
2667 | 2662 | $result = $x_negative ? -1 : 1; |
2668 | 2663 | |
2669 | - if ( count($x_value) != count($y_value) ) { |
|
2670 | - return ( count($x_value) > count($y_value) ) ? $result : -$result; |
|
2664 | + if (count($x_value) != count($y_value)) { |
|
2665 | + return (count($x_value) > count($y_value)) ? $result : -$result; |
|
2671 | 2666 | } |
2672 | 2667 | $size = max(count($x_value), count($y_value)); |
2673 | 2668 | |
@@ -2676,7 +2671,7 @@ discard block |
||
2676 | 2671 | |
2677 | 2672 | for ($i = count($x_value) - 1; $i >= 0; --$i) { |
2678 | 2673 | if ($x_value[$i] != $y_value[$i]) { |
2679 | - return ( $x_value[$i] > $y_value[$i] ) ? $result : -$result; |
|
2674 | + return ($x_value[$i] > $y_value[$i]) ? $result : -$result; |
|
2680 | 2675 | } |
2681 | 2676 | } |
2682 | 2677 | |
@@ -2695,7 +2690,7 @@ discard block |
||
2695 | 2690 | */ |
2696 | 2691 | function equals($x) |
2697 | 2692 | { |
2698 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
2693 | + switch (MATH_BIGINTEGER_MODE) { |
|
2699 | 2694 | case MATH_BIGINTEGER_MODE_GMP: |
2700 | 2695 | return gmp_cmp($this->value, $x->value) == 0; |
2701 | 2696 | default: |
@@ -2715,8 +2710,8 @@ discard block |
||
2715 | 2710 | function setPrecision($bits) |
2716 | 2711 | { |
2717 | 2712 | $this->precision = $bits; |
2718 | - if ( MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_BCMATH ) { |
|
2719 | - $this->bitmask = new Math_BigInteger(chr((1 << ($bits & 0x7)) - 1) . str_repeat(chr(0xFF), $bits >> 3), 256); |
|
2713 | + if (MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_BCMATH) { |
|
2714 | + $this->bitmask = new Math_BigInteger(chr((1 << ($bits & 0x7)) - 1).str_repeat(chr(0xFF), $bits >> 3), 256); |
|
2720 | 2715 | } else { |
2721 | 2716 | $this->bitmask = new Math_BigInteger(bcpow('2', $bits, 0)); |
2722 | 2717 | } |
@@ -2735,7 +2730,7 @@ discard block |
||
2735 | 2730 | */ |
2736 | 2731 | function bitwise_and($x) |
2737 | 2732 | { |
2738 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
2733 | + switch (MATH_BIGINTEGER_MODE) { |
|
2739 | 2734 | case MATH_BIGINTEGER_MODE_GMP: |
2740 | 2735 | $temp = new Math_BigInteger(); |
2741 | 2736 | $temp->value = gmp_and($this->value, $x->value); |
@@ -2760,7 +2755,7 @@ discard block |
||
2760 | 2755 | $result->value = array_slice($result->value, 0, $length); |
2761 | 2756 | |
2762 | 2757 | for ($i = 0; $i < $length; ++$i) { |
2763 | - $result->value[$i]&= $x->value[$i]; |
|
2758 | + $result->value[$i] &= $x->value[$i]; |
|
2764 | 2759 | } |
2765 | 2760 | |
2766 | 2761 | return $this->_normalize($result); |
@@ -2776,7 +2771,7 @@ discard block |
||
2776 | 2771 | */ |
2777 | 2772 | function bitwise_or($x) |
2778 | 2773 | { |
2779 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
2774 | + switch (MATH_BIGINTEGER_MODE) { |
|
2780 | 2775 | case MATH_BIGINTEGER_MODE_GMP: |
2781 | 2776 | $temp = new Math_BigInteger(); |
2782 | 2777 | $temp->value = gmp_or($this->value, $x->value); |
@@ -2800,7 +2795,7 @@ discard block |
||
2800 | 2795 | $x->value = array_pad($x->value, $length, 0); |
2801 | 2796 | |
2802 | 2797 | for ($i = 0; $i < $length; ++$i) { |
2803 | - $result->value[$i]|= $x->value[$i]; |
|
2798 | + $result->value[$i] |= $x->value[$i]; |
|
2804 | 2799 | } |
2805 | 2800 | |
2806 | 2801 | return $this->_normalize($result); |
@@ -2816,7 +2811,7 @@ discard block |
||
2816 | 2811 | */ |
2817 | 2812 | function bitwise_xor($x) |
2818 | 2813 | { |
2819 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
2814 | + switch (MATH_BIGINTEGER_MODE) { |
|
2820 | 2815 | case MATH_BIGINTEGER_MODE_GMP: |
2821 | 2816 | $temp = new Math_BigInteger(); |
2822 | 2817 | $temp->value = gmp_xor($this->value, $x->value); |
@@ -2840,7 +2835,7 @@ discard block |
||
2840 | 2835 | $x->value = array_pad($x->value, $length, 0); |
2841 | 2836 | |
2842 | 2837 | for ($i = 0; $i < $length; ++$i) { |
2843 | - $result->value[$i]^= $x->value[$i]; |
|
2838 | + $result->value[$i] ^= $x->value[$i]; |
|
2844 | 2839 | } |
2845 | 2840 | |
2846 | 2841 | return $this->_normalize($result); |
@@ -2874,7 +2869,7 @@ discard block |
||
2874 | 2869 | } |
2875 | 2870 | |
2876 | 2871 | // generate as many leading 1's as we need to. |
2877 | - $leading_ones = chr((1 << ($new_bits & 0x7)) - 1) . str_repeat(chr(0xFF), $new_bits >> 3); |
|
2872 | + $leading_ones = chr((1 << ($new_bits & 0x7)) - 1).str_repeat(chr(0xFF), $new_bits >> 3); |
|
2878 | 2873 | $this->_base256_lshift($leading_ones, $current_bits); |
2879 | 2874 | |
2880 | 2875 | $temp = str_pad($temp, ceil($this->bits / 8), chr(0), STR_PAD_LEFT); |
@@ -2896,7 +2891,7 @@ discard block |
||
2896 | 2891 | { |
2897 | 2892 | $temp = new Math_BigInteger(); |
2898 | 2893 | |
2899 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
2894 | + switch (MATH_BIGINTEGER_MODE) { |
|
2900 | 2895 | case MATH_BIGINTEGER_MODE_GMP: |
2901 | 2896 | static $two; |
2902 | 2897 | |
@@ -2934,7 +2929,7 @@ discard block |
||
2934 | 2929 | { |
2935 | 2930 | $temp = new Math_BigInteger(); |
2936 | 2931 | |
2937 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
2932 | + switch (MATH_BIGINTEGER_MODE) { |
|
2938 | 2933 | case MATH_BIGINTEGER_MODE_GMP: |
2939 | 2934 | static $two; |
2940 | 2935 | |
@@ -2973,7 +2968,7 @@ discard block |
||
2973 | 2968 | |
2974 | 2969 | if ($this->precision > 0) { |
2975 | 2970 | $precision = $this->precision; |
2976 | - if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH ) { |
|
2971 | + if (MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH) { |
|
2977 | 2972 | $mask = $this->bitmask->subtract(new Math_BigInteger(1)); |
2978 | 2973 | $mask = $mask->toBytes(); |
2979 | 2974 | } else { |
@@ -2983,13 +2978,13 @@ discard block |
||
2983 | 2978 | $temp = ord($bits[0]); |
2984 | 2979 | for ($i = 0; $temp >> $i; ++$i); |
2985 | 2980 | $precision = 8 * strlen($bits) - 8 + $i; |
2986 | - $mask = chr((1 << ($precision & 0x7)) - 1) . str_repeat(chr(0xFF), $precision >> 3); |
|
2981 | + $mask = chr((1 << ($precision & 0x7)) - 1).str_repeat(chr(0xFF), $precision >> 3); |
|
2987 | 2982 | } |
2988 | 2983 | |
2989 | 2984 | if ($shift < 0) { |
2990 | - $shift+= $precision; |
|
2985 | + $shift += $precision; |
|
2991 | 2986 | } |
2992 | - $shift%= $precision; |
|
2987 | + $shift %= $precision; |
|
2993 | 2988 | |
2994 | 2989 | if (!$shift) { |
2995 | 2990 | return $this->copy(); |
@@ -3068,13 +3063,13 @@ discard block |
||
3068 | 3063 | $random = ''; |
3069 | 3064 | |
3070 | 3065 | if ($size & 1) { |
3071 | - $random.= chr(mt_rand(0, 255)); |
|
3066 | + $random .= chr(mt_rand(0, 255)); |
|
3072 | 3067 | } |
3073 | 3068 | |
3074 | 3069 | $blocks = $size >> 1; |
3075 | 3070 | for ($i = 0; $i < $blocks; ++$i) { |
3076 | 3071 | // mt_rand(-2147483648, 0x7FFFFFFF) always produces -2147483648 on some systems |
3077 | - $random.= pack('n', mt_rand(0, 0xFFFF)); |
|
3072 | + $random .= pack('n', mt_rand(0, 0xFFFF)); |
|
3078 | 3073 | } |
3079 | 3074 | } |
3080 | 3075 | |
@@ -3089,14 +3084,14 @@ discard block |
||
3089 | 3084 | while (true) { |
3090 | 3085 | $msb = ord(crypt_random_string(1)); |
3091 | 3086 | if ($msb <= $cutoff) { |
3092 | - $msb%= $leading; |
|
3087 | + $msb %= $leading; |
|
3093 | 3088 | break; |
3094 | 3089 | } |
3095 | 3090 | } |
3096 | 3091 | $msb = chr($msb); |
3097 | 3092 | } |
3098 | 3093 | |
3099 | - $random = new Math_BigInteger($msb . $random, 256); |
|
3094 | + $random = new Math_BigInteger($msb.$random, 256); |
|
3100 | 3095 | |
3101 | 3096 | return $this->_normalize($random->add($min)); |
3102 | 3097 | } |
@@ -3146,7 +3141,7 @@ discard block |
||
3146 | 3141 | $x = $this->random($min, $max); |
3147 | 3142 | |
3148 | 3143 | // gmp_nextprime() requires PHP 5 >= 5.2.0 per <http://php.net/gmp-nextprime>. |
3149 | - if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_GMP && function_exists('gmp_nextprime') ) { |
|
3144 | + if (MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_GMP && function_exists('gmp_nextprime')) { |
|
3150 | 3145 | $p->value = gmp_nextprime($x->value); |
3151 | 3146 | |
3152 | 3147 | if ($p->compare($max) <= 0) { |
@@ -3211,7 +3206,7 @@ discard block |
||
3211 | 3206 | */ |
3212 | 3207 | function _make_odd() |
3213 | 3208 | { |
3214 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
3209 | + switch (MATH_BIGINTEGER_MODE) { |
|
3215 | 3210 | case MATH_BIGINTEGER_MODE_GMP: |
3216 | 3211 | gmp_setbit($this->value, 0); |
3217 | 3212 | break; |
@@ -3245,23 +3240,23 @@ discard block |
||
3245 | 3240 | |
3246 | 3241 | if (!$t) { |
3247 | 3242 | // see HAC 4.49 "Note (controlling the error probability)" |
3248 | - if ($length >= 163) { $t = 2; } // floor(1300 / 8) |
|
3249 | - else if ($length >= 106) { $t = 3; } // floor( 850 / 8) |
|
3250 | - else if ($length >= 81 ) { $t = 4; } // floor( 650 / 8) |
|
3251 | - else if ($length >= 68 ) { $t = 5; } // floor( 550 / 8) |
|
3252 | - else if ($length >= 56 ) { $t = 6; } // floor( 450 / 8) |
|
3253 | - else if ($length >= 50 ) { $t = 7; } // floor( 400 / 8) |
|
3254 | - else if ($length >= 43 ) { $t = 8; } // floor( 350 / 8) |
|
3255 | - else if ($length >= 37 ) { $t = 9; } // floor( 300 / 8) |
|
3256 | - else if ($length >= 31 ) { $t = 12; } // floor( 250 / 8) |
|
3257 | - else if ($length >= 25 ) { $t = 15; } // floor( 200 / 8) |
|
3258 | - else if ($length >= 18 ) { $t = 18; } // floor( 150 / 8) |
|
3259 | - else { $t = 27; } |
|
3243 | + if ($length >= 163) { $t = 2; } // floor(1300 / 8) |
|
3244 | + else if ($length >= 106) { $t = 3; } // floor( 850 / 8) |
|
3245 | + else if ($length >= 81) { $t = 4; } // floor( 650 / 8) |
|
3246 | + else if ($length >= 68) { $t = 5; } // floor( 550 / 8) |
|
3247 | + else if ($length >= 56) { $t = 6; } // floor( 450 / 8) |
|
3248 | + else if ($length >= 50) { $t = 7; } // floor( 400 / 8) |
|
3249 | + else if ($length >= 43) { $t = 8; } // floor( 350 / 8) |
|
3250 | + else if ($length >= 37) { $t = 9; } // floor( 300 / 8) |
|
3251 | + else if ($length >= 31) { $t = 12; } // floor( 250 / 8) |
|
3252 | + else if ($length >= 25) { $t = 15; } // floor( 200 / 8) |
|
3253 | + else if ($length >= 18) { $t = 18; } // floor( 150 / 8) |
|
3254 | + else { $t = 27; } |
|
3260 | 3255 | } |
3261 | 3256 | |
3262 | 3257 | // ie. gmp_testbit($this, 0) |
3263 | 3258 | // ie. isEven() or !isOdd() |
3264 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
3259 | + switch (MATH_BIGINTEGER_MODE) { |
|
3265 | 3260 | case MATH_BIGINTEGER_MODE_GMP: |
3266 | 3261 | return gmp_prob_prime($this->value, $t) != 0; |
3267 | 3262 | case MATH_BIGINTEGER_MODE_BCMATH: |
@@ -3285,20 +3280,20 @@ discard block |
||
3285 | 3280 | |
3286 | 3281 | if (!isset($primes)) { |
3287 | 3282 | $primes = array( |
3288 | - 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, |
|
3289 | - 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, |
|
3290 | - 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, |
|
3291 | - 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, |
|
3292 | - 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, |
|
3293 | - 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, |
|
3294 | - 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, |
|
3295 | - 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, |
|
3296 | - 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, |
|
3297 | - 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, |
|
3298 | - 953, 967, 971, 977, 983, 991, 997 |
|
3283 | + 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, |
|
3284 | + 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, |
|
3285 | + 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, |
|
3286 | + 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, |
|
3287 | + 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, |
|
3288 | + 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, |
|
3289 | + 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, |
|
3290 | + 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, |
|
3291 | + 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, |
|
3292 | + 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, |
|
3293 | + 953, 967, 971, 977, 983, 991, 997 |
|
3299 | 3294 | ); |
3300 | 3295 | |
3301 | - if ( MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_INTERNAL ) { |
|
3296 | + if (MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_INTERNAL) { |
|
3302 | 3297 | for ($i = 0; $i < count($primes); ++$i) { |
3303 | 3298 | $primes[$i] = new Math_BigInteger($primes[$i]); |
3304 | 3299 | } |
@@ -3314,7 +3309,7 @@ discard block |
||
3314 | 3309 | } |
3315 | 3310 | |
3316 | 3311 | // see HAC 4.4.1 "Random search for probable primes" |
3317 | - if ( MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_INTERNAL ) { |
|
3312 | + if (MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_INTERNAL) { |
|
3318 | 3313 | foreach ($primes as $prime) { |
3319 | 3314 | list(, $r) = $this->divide($prime); |
3320 | 3315 | if ($r->equals($zero)) { |
@@ -3338,7 +3333,7 @@ discard block |
||
3338 | 3333 | $r = $n_1->copy(); |
3339 | 3334 | $r_value = $r->value; |
3340 | 3335 | // ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s)); |
3341 | - if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH ) { |
|
3336 | + if (MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH) { |
|
3342 | 3337 | $s = 0; |
3343 | 3338 | // if $n was 1, $r would be 0 and this would be an infinite loop, hence our $this->equals($one) check earlier |
3344 | 3339 | while ($r->value[strlen($r->value) - 1] % 2 == 0) { |
@@ -3387,7 +3382,7 @@ discard block |
||
3387 | 3382 | */ |
3388 | 3383 | function _lshift($shift) |
3389 | 3384 | { |
3390 | - if ( $shift == 0 ) { |
|
3385 | + if ($shift == 0) { |
|
3391 | 3386 | return; |
3392 | 3387 | } |
3393 | 3388 | |
@@ -3403,7 +3398,7 @@ discard block |
||
3403 | 3398 | $this->value[$i] = (int) ($temp - $carry * MATH_BIGINTEGER_BASE_FULL); |
3404 | 3399 | } |
3405 | 3400 | |
3406 | - if ( $carry ) { |
|
3401 | + if ($carry) { |
|
3407 | 3402 | $this->value[] = $carry; |
3408 | 3403 | } |
3409 | 3404 | |
@@ -3431,7 +3426,7 @@ discard block |
||
3431 | 3426 | $carry_shift = MATH_BIGINTEGER_BASE - $shift; |
3432 | 3427 | $carry_mask = (1 << $shift) - 1; |
3433 | 3428 | |
3434 | - if ( $num_digits ) { |
|
3429 | + if ($num_digits) { |
|
3435 | 3430 | $this->value = array_slice($this->value, $num_digits); |
3436 | 3431 | } |
3437 | 3432 | |
@@ -3461,7 +3456,7 @@ discard block |
||
3461 | 3456 | $result->precision = $this->precision; |
3462 | 3457 | $result->bitmask = $this->bitmask; |
3463 | 3458 | |
3464 | - switch ( MATH_BIGINTEGER_MODE ) { |
|
3459 | + switch (MATH_BIGINTEGER_MODE) { |
|
3465 | 3460 | case MATH_BIGINTEGER_MODE_GMP: |
3466 | 3461 | if (!empty($result->bitmask->value)) { |
3467 | 3462 | $result->value = gmp_and($result->value, $result->bitmask->value); |
@@ -3478,7 +3473,7 @@ discard block |
||
3478 | 3473 | |
3479 | 3474 | $value = &$result->value; |
3480 | 3475 | |
3481 | - if ( !count($value) ) { |
|
3476 | + if (!count($value)) { |
|
3482 | 3477 | return $result; |
3483 | 3478 | } |
3484 | 3479 | |
@@ -3508,7 +3503,7 @@ discard block |
||
3508 | 3503 | function _trim($value) |
3509 | 3504 | { |
3510 | 3505 | for ($i = count($value) - 1; $i >= 0; --$i) { |
3511 | - if ( $value[$i] ) { |
|
3506 | + if ($value[$i]) { |
|
3512 | 3507 | break; |
3513 | 3508 | } |
3514 | 3509 | unset($value[$i]); |
@@ -3556,7 +3551,7 @@ discard block |
||
3556 | 3551 | $carry = $temp >> 8; |
3557 | 3552 | } |
3558 | 3553 | $carry = ($carry != 0) ? chr($carry) : ''; |
3559 | - $x = $carry . $x . str_repeat(chr(0), $num_bytes); |
|
3554 | + $x = $carry.$x.str_repeat(chr(0), $num_bytes); |
|
3560 | 3555 | } |
3561 | 3556 | |
3562 | 3557 | /** |
@@ -3595,7 +3590,7 @@ discard block |
||
3595 | 3590 | } |
3596 | 3591 | $x = ltrim($x, chr(0)); |
3597 | 3592 | |
3598 | - $remainder = chr($carry >> $carry_shift) . $remainder; |
|
3593 | + $remainder = chr($carry >> $carry_shift).$remainder; |
|
3599 | 3594 | |
3600 | 3595 | return ltrim($remainder, chr(0)); |
3601 | 3596 | } |
@@ -117,7 +117,6 @@ discard block |
||
117 | 117 | * |
118 | 118 | * Connects to an SSH server |
119 | 119 | * |
120 | - * @param String $host |
|
121 | 120 | * @param optional Integer $port |
122 | 121 | * @param optional Integer $timeout |
123 | 122 | * @return Net_SCP |
@@ -161,7 +160,7 @@ discard block |
||
161 | 160 | * @param String $remote_file |
162 | 161 | * @param String $data |
163 | 162 | * @param optional Integer $mode |
164 | - * @return Boolean |
|
163 | + * @return false|null |
|
165 | 164 | * @access public |
166 | 165 | */ |
167 | 166 | function put($remote_file, $data, $mode = NET_SCP_STRING) |
@@ -218,7 +217,7 @@ discard block |
||
218 | 217 | * |
219 | 218 | * @param String $remote_file |
220 | 219 | * @param optional String $local_file |
221 | - * @return Mixed |
|
220 | + * @return boolean|string |
|
222 | 221 | * @access public |
223 | 222 | */ |
224 | 223 | function get($remote_file, $local_file = false) |
@@ -18,7 +18,6 @@ discard block |
||
18 | 18 | * if (!$ssh->login('username', 'password')) { |
19 | 19 | * exit('bad login'); |
20 | 20 | * } |
21 | - |
|
22 | 21 | * $scp = new Net_SCP($ssh); |
23 | 22 | * $scp->put('abcd', str_repeat('x', 1024*1024)); |
24 | 23 | * ?> |
@@ -284,7 +283,7 @@ discard block |
||
284 | 283 | case NET_SCP_SSH1: |
285 | 284 | $data = pack('CNa*', NET_SSH1_CMSG_STDIN_DATA, strlen($data), $data); |
286 | 285 | $this->ssh->_send_binary_packet($data); |
287 | - } |
|
286 | + } |
|
288 | 287 | } |
289 | 288 | |
290 | 289 | /** |
@@ -320,7 +319,7 @@ discard block |
||
320 | 319 | return false; |
321 | 320 | } |
322 | 321 | } |
323 | - } |
|
322 | + } |
|
324 | 323 | } |
325 | 324 | |
326 | 325 | /** |
@@ -336,6 +335,6 @@ discard block |
||
336 | 335 | break; |
337 | 336 | case NET_SCP_SSH1: |
338 | 337 | $this->ssh->disconnect(); |
339 | - } |
|
338 | + } |
|
340 | 339 | } |
341 | 340 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * Reads data from a string. |
63 | 63 | */ |
64 | -define('NET_SCP_STRING', 2); |
|
64 | +define('NET_SCP_STRING', 2); |
|
65 | 65 | /**#@-*/ |
66 | 66 | |
67 | 67 | /**#@+ |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | /** |
77 | 77 | * SSH2 is being used. |
78 | 78 | */ |
79 | -define('NET_SCP_SSH2', 2); |
|
79 | +define('NET_SCP_SSH2', 2); |
|
80 | 80 | /**#@-*/ |
81 | 81 | |
82 | 82 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
173 | - $this->ssh->exec('scp -t ' . $remote_file, false); // -t = to |
|
173 | + $this->ssh->exec('scp -t '.$remote_file, false); // -t = to |
|
174 | 174 | |
175 | 175 | $temp = $this->_receive(); |
176 | 176 | if ($temp !== chr(0)) { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | $remote_file = basename($remote_file); |
185 | - $this->_send('C0644 ' . strlen($data) . ' ' . $remote_file . "\n"); |
|
185 | + $this->_send('C0644 '.strlen($data).' '.$remote_file."\n"); |
|
186 | 186 | |
187 | 187 | $temp = $this->_receive(); |
188 | 188 | if ($temp !== chr(0)) { |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
230 | - $this->ssh->exec('scp -f ' . $remote_file, false); // -f = from |
|
230 | + $this->ssh->exec('scp -f '.$remote_file, false); // -f = from |
|
231 | 231 | |
232 | 232 | $this->_send("\0"); |
233 | 233 | |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | while ($size < $info['size']) { |
251 | 251 | $data = $this->_receive(); |
252 | 252 | // SCP usually seems to split stuff out into 16k chunks |
253 | - $size+= strlen($data); |
|
253 | + $size += strlen($data); |
|
254 | 254 | |
255 | 255 | if ($local_file === false) { |
256 | - $content.= $data; |
|
256 | + $content .= $data; |
|
257 | 257 | } else { |
258 | 258 | fputs($fp, $data); |
259 | 259 | } |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | /** |
511 | 511 | * Returns the current directory name |
512 | 512 | * |
513 | - * @return Mixed |
|
513 | + * @return string |
|
514 | 514 | * @access public |
515 | 515 | */ |
516 | 516 | function pwd() |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * |
550 | 550 | * @see Net_SFTP::chdir() |
551 | 551 | * @param String $path |
552 | - * @return Mixed |
|
552 | + * @return false|string |
|
553 | 553 | * @access private |
554 | 554 | */ |
555 | 555 | function _realpath($path) |
@@ -1374,6 +1374,7 @@ discard block |
||
1374 | 1374 | * Helper function for directory creation |
1375 | 1375 | * |
1376 | 1376 | * @param String $dir |
1377 | + * @param string $attr |
|
1377 | 1378 | * @return Boolean |
1378 | 1379 | * @access private |
1379 | 1380 | */ |
@@ -1626,7 +1627,7 @@ discard block |
||
1626 | 1627 | * @param optional String $local_file |
1627 | 1628 | * @param optional Integer $offset |
1628 | 1629 | * @param optional Integer $length |
1629 | - * @return Mixed |
|
1630 | + * @return string|boolean |
|
1630 | 1631 | * @access public |
1631 | 1632 | */ |
1632 | 1633 | function get($remote_file, $local_file = false, $offset = 0, $length = -1) |
@@ -2212,7 +2213,7 @@ discard block |
||
2212 | 2213 | * Disconnect |
2213 | 2214 | * |
2214 | 2215 | * @param Integer $reason |
2215 | - * @return Boolean |
|
2216 | + * @return boolean|null |
|
2216 | 2217 | * @access private |
2217 | 2218 | */ |
2218 | 2219 | function _disconnect($reason) |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | if ($response === false) { |
414 | 414 | // from PuTTY's psftp.exe |
415 | 415 | $command = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n" . |
416 | - "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n" . |
|
417 | - "exec sftp-server"; |
|
416 | + "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n" . |
|
417 | + "exec sftp-server"; |
|
418 | 418 | // 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 |
419 | 419 | // is redundant |
420 | 420 | $packet = pack('CNNa*CNa*', |
@@ -2055,7 +2055,7 @@ discard block |
||
2055 | 2055 | |
2056 | 2056 | if (defined('NET_SFTP_LOGGING')) { |
2057 | 2057 | $packet_type = '-> ' . $this->packet_types[$type] . |
2058 | - ' (' . round($stop - $start, 4) . 's)'; |
|
2058 | + ' (' . round($stop - $start, 4) . 's)'; |
|
2059 | 2059 | if (NET_SFTP_LOGGING == NET_SFTP_LOG_REALTIME) { |
2060 | 2060 | echo "<pre>\r\n" . $this->_format_log(array($data), array($packet_type)) . "\r\n</pre>\r\n"; |
2061 | 2061 | flush(); |
@@ -2131,7 +2131,7 @@ discard block |
||
2131 | 2131 | |
2132 | 2132 | if (defined('NET_SFTP_LOGGING')) { |
2133 | 2133 | $packet_type = '<- ' . $this->packet_types[$this->packet_type] . |
2134 | - ' (' . round($stop - $start, 4) . 's)'; |
|
2134 | + ' (' . round($stop - $start, 4) . 's)'; |
|
2135 | 2135 | if (NET_SFTP_LOGGING == NET_SFTP_LOG_REALTIME) { |
2136 | 2136 | echo "<pre>\r\n" . $this->_format_log(array($packet), array($packet_type)) . "\r\n</pre>\r\n"; |
2137 | 2137 | flush(); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * Returns the message numbers |
70 | 70 | */ |
71 | -define('NET_SFTP_LOG_SIMPLE', NET_SSH2_LOG_SIMPLE); |
|
71 | +define('NET_SFTP_LOG_SIMPLE', NET_SSH2_LOG_SIMPLE); |
|
72 | 72 | /** |
73 | 73 | * Returns the message content |
74 | 74 | */ |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | * Reads data from a string. |
103 | 103 | */ |
104 | 104 | // this value isn't really used anymore but i'm keeping it reserved for historical reasons |
105 | -define('NET_SFTP_STRING', 2); |
|
105 | +define('NET_SFTP_STRING', 2); |
|
106 | 106 | /** |
107 | 107 | * Resumes an upload |
108 | 108 | */ |
109 | -define('NET_SFTP_RESUME', 4); |
|
109 | +define('NET_SFTP_RESUME', 4); |
|
110 | 110 | /**#@-*/ |
111 | 111 | |
112 | 112 | /** |
@@ -412,8 +412,8 @@ discard block |
||
412 | 412 | $response = $this->_get_channel_packet(NET_SFTP_CHANNEL); |
413 | 413 | if ($response === false) { |
414 | 414 | // from PuTTY's psftp.exe |
415 | - $command = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n" . |
|
416 | - "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n" . |
|
415 | + $command = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n". |
|
416 | + "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n". |
|
417 | 417 | "exec sftp-server"; |
418 | 418 | // 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 |
419 | 419 | // is redundant |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | |
536 | 536 | if ($this->version > 2) { |
537 | 537 | extract(unpack('Nlength', $this->_string_shift($response, 4))); |
538 | - $this->sftp_errors[] = $error . ': ' . $this->_string_shift($response, $length); |
|
538 | + $this->sftp_errors[] = $error.': '.$this->_string_shift($response, $length); |
|
539 | 539 | } else { |
540 | 540 | $this->sftp_errors[] = $error; |
541 | 541 | } |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | } |
580 | 580 | |
581 | 581 | if ($path[0] != '/') { |
582 | - $path = $this->pwd . '/' . $path; |
|
582 | + $path = $this->pwd.'/'.$path; |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | $path = explode('/', $path); |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | } |
599 | 599 | } |
600 | 600 | |
601 | - return '/' . implode('/', $new); |
|
601 | + return '/'.implode('/', $new); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | /** |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | } |
616 | 616 | |
617 | 617 | if ($dir[strlen($dir) - 1] != '/') { |
618 | - $dir.= '/'; |
|
618 | + $dir .= '/'; |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | $dir = $this->_realpath($dir); |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | return false; |
714 | 714 | } |
715 | 715 | |
716 | - $dir = $this->_realpath($dir . '/'); |
|
716 | + $dir = $this->_realpath($dir.'/'); |
|
717 | 717 | if ($dir === false) { |
718 | 718 | return false; |
719 | 719 | } |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | } |
775 | 775 | |
776 | 776 | if (isset($attributes['type']) && $attributes['type'] == NET_SFTP_TYPE_DIRECTORY && ($shortname != '.' && $shortname != '..')) { |
777 | - $this->_save_dir($dir . '/' . $shortname); |
|
777 | + $this->_save_dir($dir.'/'.$shortname); |
|
778 | 778 | } |
779 | 779 | // SFTPv6 has an optional boolean end-of-list field, but we'll ignore that, since the |
780 | 780 | // final SSH_FXP_STATUS packet should tell us that, already. |
@@ -933,8 +933,7 @@ discard block |
||
933 | 933 | |
934 | 934 | $pwd = $this->pwd; |
935 | 935 | $stat['type'] = $this->chdir($filename) ? |
936 | - NET_SFTP_TYPE_DIRECTORY : |
|
937 | - NET_SFTP_TYPE_REGULAR; |
|
936 | + NET_SFTP_TYPE_DIRECTORY : NET_SFTP_TYPE_REGULAR; |
|
938 | 937 | $this->pwd = $pwd; |
939 | 938 | |
940 | 939 | return $stat; |
@@ -976,8 +975,7 @@ discard block |
||
976 | 975 | |
977 | 976 | $pwd = $this->pwd; |
978 | 977 | $lstat['type'] = $this->chdir($filename) ? |
979 | - NET_SFTP_TYPE_DIRECTORY : |
|
980 | - NET_SFTP_TYPE_REGULAR; |
|
978 | + NET_SFTP_TYPE_DIRECTORY : NET_SFTP_TYPE_REGULAR; |
|
981 | 979 | $this->pwd = $pwd; |
982 | 980 | |
983 | 981 | return $lstat; |
@@ -1298,7 +1296,7 @@ discard block |
||
1298 | 1296 | return false; |
1299 | 1297 | } |
1300 | 1298 | |
1301 | - $temp = $path . '/' . $filename; |
|
1299 | + $temp = $path.'/'.$filename; |
|
1302 | 1300 | if ($props['type'] == NET_SFTP_TYPE_DIRECTORY) { |
1303 | 1301 | if (!$this->_setstat_recursive($temp, $attr, $i)) { |
1304 | 1302 | return false; |
@@ -1357,7 +1355,7 @@ discard block |
||
1357 | 1355 | $dirs = explode('/', preg_replace('#/(?=/)|/$#', '', $dir)); |
1358 | 1356 | if (empty($dirs[0])) { |
1359 | 1357 | array_shift($dirs); |
1360 | - $dirs[0] = '/' . $dirs[0]; |
|
1358 | + $dirs[0] = '/'.$dirs[0]; |
|
1361 | 1359 | } |
1362 | 1360 | for ($i = 0; $i < count($dirs); $i++) { |
1363 | 1361 | $temp = array_slice($dirs, 0, $i + 1); |
@@ -1492,7 +1490,7 @@ discard block |
||
1492 | 1490 | $offset = $size !== false ? $size : 0; |
1493 | 1491 | } |
1494 | 1492 | } else { |
1495 | - $flags|= NET_SFTP_OPEN_TRUNCATE; |
|
1493 | + $flags |= NET_SFTP_OPEN_TRUNCATE; |
|
1496 | 1494 | } |
1497 | 1495 | // -------------- |
1498 | 1496 | |
@@ -1544,7 +1542,7 @@ discard block |
||
1544 | 1542 | fclose($fp); |
1545 | 1543 | return false; |
1546 | 1544 | } |
1547 | - $sent+= strlen($temp); |
|
1545 | + $sent += strlen($temp); |
|
1548 | 1546 | |
1549 | 1547 | $i++; |
1550 | 1548 | |
@@ -1681,9 +1679,9 @@ discard block |
||
1681 | 1679 | switch ($this->packet_type) { |
1682 | 1680 | case NET_SFTP_DATA: |
1683 | 1681 | $temp = substr($response, 4); |
1684 | - $offset+= strlen($temp); |
|
1682 | + $offset += strlen($temp); |
|
1685 | 1683 | if ($local_file === false) { |
1686 | - $content.= $temp; |
|
1684 | + $content .= $temp; |
|
1687 | 1685 | } else { |
1688 | 1686 | fputs($fp, $temp); |
1689 | 1687 | } |
@@ -1820,7 +1818,7 @@ discard block |
||
1820 | 1818 | return false; |
1821 | 1819 | } |
1822 | 1820 | |
1823 | - $temp = $path . '/' . $filename; |
|
1821 | + $temp = $path.'/'.$filename; |
|
1824 | 1822 | if ($props['type'] == NET_SFTP_TYPE_DIRECTORY) { |
1825 | 1823 | if (!$this->_delete_recursive($temp, $i)) { |
1826 | 1824 | return false; |
@@ -1924,23 +1922,23 @@ discard block |
||
1924 | 1922 | // 4GB as being 4GB. |
1925 | 1923 | extract(unpack('Nupper/Nsize', $this->_string_shift($response, 8))); |
1926 | 1924 | $attr['size'] = $upper ? 0x100000000 * $upper : 0; |
1927 | - $attr['size']+= $size < 0 ? ($size & 0x7FFFFFFF) + 0x80000000 : $size; |
|
1925 | + $attr['size'] += $size < 0 ? ($size & 0x7FFFFFFF) + 0x80000000 : $size; |
|
1928 | 1926 | break; |
1929 | 1927 | case NET_SFTP_ATTR_UIDGID: // 0x00000002 (SFTPv3 only) |
1930 | - $attr+= unpack('Nuid/Ngid', $this->_string_shift($response, 8)); |
|
1928 | + $attr += unpack('Nuid/Ngid', $this->_string_shift($response, 8)); |
|
1931 | 1929 | break; |
1932 | 1930 | case NET_SFTP_ATTR_PERMISSIONS: // 0x00000004 |
1933 | - $attr+= unpack('Npermissions', $this->_string_shift($response, 4)); |
|
1931 | + $attr += unpack('Npermissions', $this->_string_shift($response, 4)); |
|
1934 | 1932 | // mode == permissions; permissions was the original array key and is retained for bc purposes. |
1935 | 1933 | // mode was added because that's the more industry standard terminology |
1936 | - $attr+= array('mode' => $attr['permissions']); |
|
1934 | + $attr += array('mode' => $attr['permissions']); |
|
1937 | 1935 | $fileType = $this->_parseMode($attr['permissions']); |
1938 | 1936 | if ($fileType !== false) { |
1939 | - $attr+= array('type' => $fileType); |
|
1937 | + $attr += array('type' => $fileType); |
|
1940 | 1938 | } |
1941 | 1939 | break; |
1942 | 1940 | case NET_SFTP_ATTR_ACCESSTIME: // 0x00000008 |
1943 | - $attr+= unpack('Natime/Nmtime', $this->_string_shift($response, 8)); |
|
1941 | + $attr += unpack('Natime/Nmtime', $this->_string_shift($response, 8)); |
|
1944 | 1942 | break; |
1945 | 1943 | case NET_SFTP_ATTR_EXTENDED: // 0x80000000 |
1946 | 1944 | extract(unpack('Ncount', $this->_string_shift($response, 4))); |
@@ -2046,18 +2044,17 @@ discard block |
||
2046 | 2044 | function _send_sftp_packet($type, $data) |
2047 | 2045 | { |
2048 | 2046 | $packet = $this->request_id !== false ? |
2049 | - pack('NCNa*', strlen($data) + 5, $type, $this->request_id, $data) : |
|
2050 | - pack('NCa*', strlen($data) + 1, $type, $data); |
|
2047 | + pack('NCNa*', strlen($data) + 5, $type, $this->request_id, $data) : pack('NCa*', strlen($data) + 1, $type, $data); |
|
2051 | 2048 | |
2052 | 2049 | $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 |
2053 | 2050 | $result = $this->_send_channel_packet(NET_SFTP_CHANNEL, $packet); |
2054 | 2051 | $stop = strtok(microtime(), ' ') + strtok(''); |
2055 | 2052 | |
2056 | 2053 | if (defined('NET_SFTP_LOGGING')) { |
2057 | - $packet_type = '-> ' . $this->packet_types[$type] . |
|
2058 | - ' (' . round($stop - $start, 4) . 's)'; |
|
2054 | + $packet_type = '-> '.$this->packet_types[$type]. |
|
2055 | + ' ('.round($stop - $start, 4).'s)'; |
|
2059 | 2056 | if (NET_SFTP_LOGGING == NET_SFTP_LOG_REALTIME) { |
2060 | - echo "<pre>\r\n" . $this->_format_log(array($data), array($packet_type)) . "\r\n</pre>\r\n"; |
|
2057 | + echo "<pre>\r\n".$this->_format_log(array($data), array($packet_type))."\r\n</pre>\r\n"; |
|
2061 | 2058 | flush(); |
2062 | 2059 | ob_flush(); |
2063 | 2060 | } else { |
@@ -2098,11 +2095,11 @@ discard block |
||
2098 | 2095 | $this->packet_buffer = ''; |
2099 | 2096 | return false; |
2100 | 2097 | } |
2101 | - $this->packet_buffer.= $temp; |
|
2098 | + $this->packet_buffer .= $temp; |
|
2102 | 2099 | } |
2103 | 2100 | extract(unpack('Nlength', $this->_string_shift($this->packet_buffer, 4))); |
2104 | 2101 | $tempLength = $length; |
2105 | - $tempLength-= strlen($this->packet_buffer); |
|
2102 | + $tempLength -= strlen($this->packet_buffer); |
|
2106 | 2103 | |
2107 | 2104 | // SFTP packet type and data payload |
2108 | 2105 | while ($tempLength > 0) { |
@@ -2112,8 +2109,8 @@ discard block |
||
2112 | 2109 | $this->packet_buffer = ''; |
2113 | 2110 | return false; |
2114 | 2111 | } |
2115 | - $this->packet_buffer.= $temp; |
|
2116 | - $tempLength-= strlen($temp); |
|
2112 | + $this->packet_buffer .= $temp; |
|
2113 | + $tempLength -= strlen($temp); |
|
2117 | 2114 | } |
2118 | 2115 | |
2119 | 2116 | $stop = strtok(microtime(), ' ') + strtok(''); |
@@ -2122,18 +2119,18 @@ discard block |
||
2122 | 2119 | |
2123 | 2120 | if ($this->request_id !== false) { |
2124 | 2121 | $this->_string_shift($this->packet_buffer, 4); // remove the request id |
2125 | - $length-= 5; // account for the request id and the packet type |
|
2122 | + $length -= 5; // account for the request id and the packet type |
|
2126 | 2123 | } else { |
2127 | - $length-= 1; // account for the packet type |
|
2124 | + $length -= 1; // account for the packet type |
|
2128 | 2125 | } |
2129 | 2126 | |
2130 | 2127 | $packet = $this->_string_shift($this->packet_buffer, $length); |
2131 | 2128 | |
2132 | 2129 | if (defined('NET_SFTP_LOGGING')) { |
2133 | - $packet_type = '<- ' . $this->packet_types[$this->packet_type] . |
|
2134 | - ' (' . round($stop - $start, 4) . 's)'; |
|
2130 | + $packet_type = '<- '.$this->packet_types[$this->packet_type]. |
|
2131 | + ' ('.round($stop - $start, 4).'s)'; |
|
2135 | 2132 | if (NET_SFTP_LOGGING == NET_SFTP_LOG_REALTIME) { |
2136 | - echo "<pre>\r\n" . $this->_format_log(array($packet), array($packet_type)) . "\r\n</pre>\r\n"; |
|
2133 | + echo "<pre>\r\n".$this->_format_log(array($packet), array($packet_type))."\r\n</pre>\r\n"; |
|
2137 | 2134 | flush(); |
2138 | 2135 | ob_flush(); |
2139 | 2136 | } else { |