Merge branch 'master' into rsa-plugins

Conflicts:
	phpseclib/Crypt/RSA.php
This commit is contained in:
terrafrost 2015-10-22 10:16:52 -05:00
commit efe36d67ce
5 changed files with 73 additions and 8 deletions

View File

@ -408,7 +408,7 @@ abstract class PKCS
* subject=/O=organization/OU=org unit/CN=common name * subject=/O=organization/OU=org unit/CN=common name
* issuer=/O=organization/CN=common name * issuer=/O=organization/CN=common name
*/ */
$temp = preg_replace('#.*?^-+[^-]+-+#ms', '', $str, 1); $temp = preg_replace('#.*?^-+[^-]+-+[\r\n ]*$#ms', '', $str, 1);
// remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff // remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff
$temp = preg_replace('#-+[^-]+-+#', '', $temp); $temp = preg_replace('#-+[^-]+-+#', '', $temp);
// remove new lines // remove new lines

View File

@ -104,6 +104,12 @@ class X509
* Only works on CSRs. Not currently supported. * Only works on CSRs. Not currently supported.
*/ */
const FORMAT_SPKAC = 2; const FORMAT_SPKAC = 2;
/**
* Auto-detect the format
*
* Used only by the load*() functions
*/
const FORMAT_AUTO_DETECT = 3;
/**#@-*/ /**#@-*/
/** /**
@ -1404,10 +1410,11 @@ class X509
* Returns an associative array describing the X.509 cert or a false if the cert failed to load * Returns an associative array describing the X.509 cert or a false if the cert failed to load
* *
* @param string $cert * @param string $cert
* @param int $mode
* @access public * @access public
* @return mixed * @return mixed
*/ */
function loadX509($cert) function loadX509($cert, $mode = self::FORMAT_AUTO_DETECT)
{ {
if (is_array($cert) && isset($cert['tbsCertificate'])) { if (is_array($cert) && isset($cert['tbsCertificate'])) {
unset($this->currentCert); unset($this->currentCert);
@ -1428,7 +1435,13 @@ class X509
$asn1 = new ASN1(); $asn1 = new ASN1();
$cert = $this->_extractBER($cert); if ($mode != self::FORMAT_DER) {
$newcert = $this->_extractBER($cert);
if ($mode == self::FORMAT_PEM && $cert == $newcert) {
return false;
}
$cert = $newcert;
}
if ($cert === false) { if ($cert === false) {
$this->currentCert = false; $this->currentCert = false;
@ -2820,7 +2833,7 @@ class X509
* @access public * @access public
* @return mixed * @return mixed
*/ */
function loadCSR($csr) function loadCSR($csr, $mode = self::FORMAT_AUTO_DETECT)
{ {
if (is_array($csr) && isset($csr['certificationRequestInfo'])) { if (is_array($csr) && isset($csr['certificationRequestInfo'])) {
unset($this->currentCert); unset($this->currentCert);
@ -2839,7 +2852,13 @@ class X509
$asn1 = new ASN1(); $asn1 = new ASN1();
$csr = $this->_extractBER($csr); if ($mode != self::FORMAT_DER) {
$newcsr = $this->_extractBER($csr);
if ($mode == self::FORMAT_PEM && $csr == $newcsr) {
return false;
}
$csr = $newcsr;
}
$orig = $csr; $orig = $csr;
if ($csr === false) { if ($csr === false) {
@ -3059,7 +3078,7 @@ class X509
* @access public * @access public
* @return mixed * @return mixed
*/ */
function loadCRL($crl) function loadCRL($crl, $mode = self::FORMAT_AUTO_DETECT)
{ {
if (is_array($crl) && isset($crl['tbsCertList'])) { if (is_array($crl) && isset($crl['tbsCertList'])) {
$this->currentCert = $crl; $this->currentCert = $crl;
@ -3069,7 +3088,13 @@ class X509
$asn1 = new ASN1(); $asn1 = new ASN1();
$crl = $this->_extractBER($crl); if ($mode != self::FORMAT_DER) {
$newcrl = $this->_extractBER($crl);
if ($mode == self::FORMAT_PEM && $crl == $newcrl) {
return false;
}
$crl = $newcrl;
}
$orig = $crl; $orig = $crl;
if ($crl === false) { if ($crl === false) {
@ -4560,7 +4585,7 @@ class X509
* subject=/O=organization/OU=org unit/CN=common name * subject=/O=organization/OU=org unit/CN=common name
* issuer=/O=organization/CN=common name * issuer=/O=organization/CN=common name
*/ */
$temp = preg_replace('#.*?^-+[^-]+-+#ms', '', $str, 1); $temp = preg_replace('#.*?^-+[^-]+-+[\r\n ]*$#ms', '', $str, 1);
// remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff // remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff
$temp = preg_replace('#-+[^-]+-+#', '', $temp); $temp = preg_replace('#-+[^-]+-+#', '', $temp);
// remove new lines // remove new lines

View File

@ -1416,6 +1416,7 @@ class SFTP extends SSH2
return true; return true;
} }
$filename = $this->_realPath($filename);
// rather than return what the permissions *should* be, we'll return what they actually are. this will also // rather than return what the permissions *should* be, we'll return what they actually are. this will also
// tell us if the file actually exists. // tell us if the file actually exists.
// incidentally, SFTPv4+ adds an additional 32-bit integer field - flags - to the following: // incidentally, SFTPv4+ adds an additional 32-bit integer field - flags - to the following:

View File

@ -240,6 +240,20 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
/** /**
* @depends testTruncate * @depends testTruncate
* @group github850
*/
public function testChModOnFile($sftp)
{
$this->assertNotFalse(
$sftp->chmod(0755, 'file1.txt'),
'Failed asserting that chmod() was successful.'
);
return $sftp;
}
/**
* @depends testChModOnFile
*/ */
public function testChDirOnFile($sftp) public function testChDirOnFile($sftp)
{ {

View File

@ -68,4 +68,29 @@ draiRBZruwMPwPIP
$this->assertInternalType('array', $csr); $this->assertInternalType('array', $csr);
} }
public function testCSRDER()
{
$csr = 'MIICdzCCAV8CAQEwDDEKMAgGA1UEAwwBeDCCASIwDQYJKoZIhvcNAQEBBQADggEP' .
'ADCCAQoCggEBALtcrFDD2AHe3x2bR00wPDsPH6FJLxr5uc1ybb+ldDB5xNVImC8P' .
'LU6VXDZ5z68KjSovs1q0OWJWfCjlAuGLzqO35s86LI1CFuTFdkScVHMwh8zUVFoP' .
'pG7/9rKaNxCgaHs4evxjxQP2+Ny7tBqPLb/KV0exm6Twocf963jC/Tyn57G5erRf' .
'zpFrfK7DozhxY7znumJ4FuSn0TVkD6PPwZFn9VoTjv2ZoJmacGK+0r5yNKG799F5' .
'K8EgDrOCfbzCZjX6GJctyn2SNPTeBuXS9piH21FGnJAryv80zG+zUqFdEyoLUGJt' .
'4Vy6+tDP9cW68fiwTZS1Oc1VeFdL1G/CrjkCAwEAAaAmMCQGCSqGSIb3DQEJDjEX' .
'MBUwEwYKKwYBBAGCqlsBCQQFMAOCAQEwDQYJKoZIhvcNAQELBQADggEBAF4XOd+1' .
'jkJOYRInNpHfhzSD/ktDY50gpLPuDvl4f/ZBlKrb1eDYQG5F3bnYzoZWHN4n+6Zs' .
'CkljXs5ZPUZ5LuVpASumoG/aHXGz8c8NC3asJ1V73ljEPAfIXwqoIUoaP9jLL+Ee' .
'zy/ZCi2NKWVo2D7ocnn79oblAem9ksSeQl4z3Gvhuug6MsMqn96NU/ZY/vjYzAjb' .
'MAvJIVRY0rbCxbFa0K+XNJtF7GLyBxyPNFWCvADhvm9C4uPmoypYg7MY6EewJInN' .
'xzMH7I4xDLjNu0VBa6lAxTvflp0joQHKlTYX0SDIKPbQivjZMuObPuxDtkVZ0rQl' .
'AjmgMowaN5otTXM=';
$csr = base64_decode($csr);
$x509 = new X509();
$csr = $x509->loadCSR($csr);
$this->assertInternalType('array', $csr);
}
} }