Merge pull request #34 from terrafrost/master

a few changes
This commit is contained in:
terrafrost 2012-11-16 01:03:00 -08:00
commit 2a918a5bb5
4 changed files with 64 additions and 22 deletions

View File

@ -723,7 +723,7 @@ class Crypt_DES {
mcrypt_generic_init($this->demcrypt, $this->keys, $this->decryptIV); mcrypt_generic_init($this->demcrypt, $this->keys, $this->decryptIV);
} }
return $this->mode != 'ctr' ? $this->_unpad($plaintext) : $plaintext; return $this->paddable ? $this->_unpad($plaintext) : $plaintext;
} }
if (!is_array($this->keys)) { if (!is_array($this->keys)) {

View File

@ -265,6 +265,7 @@ class Crypt_TripleDES {
new Crypt_DES(CRYPT_DES_MODE_CBC), new Crypt_DES(CRYPT_DES_MODE_CBC),
new Crypt_DES(CRYPT_DES_MODE_CBC) new Crypt_DES(CRYPT_DES_MODE_CBC)
); );
$this->paddable = true;
// we're going to be doing the padding, ourselves, so disable it in the Crypt_DES objects // we're going to be doing the padding, ourselves, so disable it in the Crypt_DES objects
$this->des[0]->disablePadding(); $this->des[0]->disablePadding();

View File

@ -59,15 +59,35 @@ if (!class_exists('File_ASN1')) {
*/ */
define('FILE_X509_VALIDATE_SIGNATURE_BY_CA', 1); define('FILE_X509_VALIDATE_SIGNATURE_BY_CA', 1);
/**#@+
* @access public
* @see File_X509::getDN()
*/
/** /**
* Name format tokens for the getDN() method. * Return internal array representation
*/ */
define('FILE_X509_DN_ARRAY', 0); // Internal array representation. define('FILE_X509_DN_ARRAY', 0); // Internal array representation.
define('FILE_X509_DN_STRING', 1); // String. /**
define('FILE_X509_DN_ASN1', 2); // ASN.1 Name string. * Return string
define('FILE_X509_DN_OPENSSL', 3); // OpenSSL compatible array. */
define('FILE_X509_DN_CANON', 4); // Canonical ASN.1 RDNs string. define('FILE_X509_DN_STRING', 1);
define('FILE_X509_DN_HASH', 5); // Name hash for file indexing. /**
* Return ASN.1 name string
*/
define('FILE_X509_DN_ASN1', 2);
/**
* Return OpenSSL compatible array
*/
define('FILE_X509_DN_OPENSSL', 3);
/**
* Return canonical ASN.1 RDNs string
*/
define('FILE_X509_DN_CANON', 4);
/**
* Return name ash for file indexing
*/
define('FILE_X509_DN_HASH', 5);
/**#@-*/
/** /**
* Pure-PHP X.509 Parser * Pure-PHP X.509 Parser
@ -1346,8 +1366,11 @@ class File_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
*/ */
$cert = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]| #', '', $cert); $temp = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]| #', '', $cert);
$cert = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $cert) ? base64_decode($cert) : false; $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false;
if ($temp != false) {
$cert = $temp;
}
if ($cert === false) { if ($cert === false) {
$this->currentCert = false; $this->currentCert = false;
@ -1637,8 +1660,16 @@ class File_X509 {
*/ */
function loadCA($cert) function loadCA($cert)
{ {
$olddn = $this->dn;
$oldcert = $this->currentCert;
$oldsigsubj = $this->signatureSubject;
$cert = $this->loadX509($cert); $cert = $this->loadX509($cert);
if (!$cert) { if (!$cert) {
$this->dn = $olddn;
$this->currentCert = $oldcert;
$this->signatureSubject = $oldsigsubj;
return false; return false;
} }
@ -1667,8 +1698,10 @@ class File_X509 {
//} //}
$this->CAs[] = $cert; $this->CAs[] = $cert;
unset($this->currentCert);
unset($this->signatureSubject); $this->dn = $olddn;
$this->currentCert = $oldcert;
$this->signatureSubject = $oldsigsubj;
return true; return true;
} }
@ -2209,7 +2242,7 @@ class File_X509 {
function getDN($format = FILE_X509_DN_ARRAY, $dn = NULL) function getDN($format = FILE_X509_DN_ARRAY, $dn = NULL)
{ {
if (!isset($dn)) { if (!isset($dn)) {
$dn = $this->dn; $dn = isset($this->currentCert['tbsCertList']) ? $this->currentCert['tbsCertList']['issuer'] : $this->dn;
} }
switch ((int) $format) { switch ((int) $format) {
@ -2361,7 +2394,7 @@ class File_X509 {
return $this->getDN($format, $this->currentCert['tbsCertList']['issuer']); return $this->getDN($format, $this->currentCert['tbsCertList']['issuer']);
} }
return false; return false;
} }
/** /**
@ -2385,7 +2418,7 @@ class File_X509 {
return $this->getDN($format, $this->currentCert['certificationRequestInfo']['subject']); return $this->getDN($format, $this->currentCert['certificationRequestInfo']['subject']);
} }
return false; return false;
} }
/** /**
@ -2407,7 +2440,7 @@ class File_X509 {
return $this->getDNProp($propname, $this->currentCert['tbsCertList']['issuer'], $withType); return $this->getDNProp($propname, $this->currentCert['tbsCertList']['issuer'], $withType);
} }
return false; return false;
} }
/** /**
@ -2431,7 +2464,7 @@ class File_X509 {
return $this->getDNProp($propname, $this->currentCert['certificationRequestInfo']['subject'], $withType); return $this->getDNProp($propname, $this->currentCert['certificationRequestInfo']['subject'], $withType);
} }
return false; return false;
} }
/** /**
@ -2518,8 +2551,12 @@ class File_X509 {
$asn1 = new File_ASN1(); $asn1 = new File_ASN1();
$csr = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]| #', '', $csr); $temp = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]| #', '', $csr);
$orig = $csr = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $csr) ? base64_decode($csr) : false; $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false;
if ($temp != false) {
$csr = $temp;
}
$orig = $csr;
if ($csr === false) { if ($csr === false) {
$this->currentCert = false; $this->currentCert = false;
@ -2612,8 +2649,12 @@ class File_X509 {
{ {
$asn1 = new File_ASN1(); $asn1 = new File_ASN1();
$crl = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]#', '', $crl); $temp = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]| #', '', $csr);
$orig = $crl = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $crl) ? base64_decode($crl) : false; $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false;
if ($temp != false) {
$crl = $temp;
}
$orig = $crl;
if ($crl === false) { if ($crl === false) {
$this->currentCert = false; $this->currentCert = false;
@ -3625,7 +3666,7 @@ class File_X509 {
$result = array(); $result = array();
if (!is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) { if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) {
foreach ($rclist as $rc) { foreach ($rclist as $rc) {
$result[] = $rc['userCertificate']->toString(); $result[] = $rc['userCertificate']->toString();
} }

View File

@ -428,7 +428,7 @@ class Net_SSH1 {
* @var Array * @var Array
* @access private * @access private
*/ */
var $interactive_buffer = ''; var $interactiveBuffer = '';
/** /**
* Default Constructor. * Default Constructor.