mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-05 21:17:53 +00:00
commit
2a918a5bb5
@ -723,7 +723,7 @@ class Crypt_DES {
|
||||
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)) {
|
||||
|
@ -265,6 +265,7 @@ class Crypt_TripleDES {
|
||||
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
|
||||
$this->des[0]->disablePadding();
|
||||
|
@ -59,15 +59,35 @@ if (!class_exists('File_ASN1')) {
|
||||
*/
|
||||
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_STRING', 1); // String.
|
||||
define('FILE_X509_DN_ASN1', 2); // ASN.1 Name 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_HASH', 5); // Name hash for file indexing.
|
||||
/**
|
||||
* Return string
|
||||
*/
|
||||
define('FILE_X509_DN_STRING', 1);
|
||||
/**
|
||||
* 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
|
||||
@ -1346,8 +1366,11 @@ class File_X509 {
|
||||
subject=/O=organization/OU=org unit/CN=common name
|
||||
issuer=/O=organization/CN=common name
|
||||
*/
|
||||
$cert = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]| #', '', $cert);
|
||||
$cert = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $cert) ? base64_decode($cert) : false;
|
||||
$temp = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]| #', '', $cert);
|
||||
$temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false;
|
||||
if ($temp != false) {
|
||||
$cert = $temp;
|
||||
}
|
||||
|
||||
if ($cert === false) {
|
||||
$this->currentCert = false;
|
||||
@ -1637,8 +1660,16 @@ class File_X509 {
|
||||
*/
|
||||
function loadCA($cert)
|
||||
{
|
||||
$olddn = $this->dn;
|
||||
$oldcert = $this->currentCert;
|
||||
$oldsigsubj = $this->signatureSubject;
|
||||
|
||||
$cert = $this->loadX509($cert);
|
||||
if (!$cert) {
|
||||
$this->dn = $olddn;
|
||||
$this->currentCert = $oldcert;
|
||||
$this->signatureSubject = $oldsigsubj;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1667,8 +1698,10 @@ class File_X509 {
|
||||
//}
|
||||
|
||||
$this->CAs[] = $cert;
|
||||
unset($this->currentCert);
|
||||
unset($this->signatureSubject);
|
||||
|
||||
$this->dn = $olddn;
|
||||
$this->currentCert = $oldcert;
|
||||
$this->signatureSubject = $oldsigsubj;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2209,7 +2242,7 @@ class File_X509 {
|
||||
function getDN($format = FILE_X509_DN_ARRAY, $dn = NULL)
|
||||
{
|
||||
if (!isset($dn)) {
|
||||
$dn = $this->dn;
|
||||
$dn = isset($this->currentCert['tbsCertList']) ? $this->currentCert['tbsCertList']['issuer'] : $this->dn;
|
||||
}
|
||||
|
||||
switch ((int) $format) {
|
||||
@ -2518,8 +2551,12 @@ class File_X509 {
|
||||
|
||||
$asn1 = new File_ASN1();
|
||||
|
||||
$csr = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]| #', '', $csr);
|
||||
$orig = $csr = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $csr) ? base64_decode($csr) : false;
|
||||
$temp = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]| #', '', $csr);
|
||||
$temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false;
|
||||
if ($temp != false) {
|
||||
$csr = $temp;
|
||||
}
|
||||
$orig = $csr;
|
||||
|
||||
if ($csr === false) {
|
||||
$this->currentCert = false;
|
||||
@ -2612,8 +2649,12 @@ class File_X509 {
|
||||
{
|
||||
$asn1 = new File_ASN1();
|
||||
|
||||
$crl = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]#', '', $crl);
|
||||
$orig = $crl = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $crl) ? base64_decode($crl) : false;
|
||||
$temp = preg_replace('#^(?:[^-].+[\r\n]+)+|-.+-|[\r\n]| #', '', $csr);
|
||||
$temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false;
|
||||
if ($temp != false) {
|
||||
$crl = $temp;
|
||||
}
|
||||
$orig = $crl;
|
||||
|
||||
if ($crl === false) {
|
||||
$this->currentCert = false;
|
||||
@ -3625,7 +3666,7 @@ class File_X509 {
|
||||
|
||||
$result = array();
|
||||
|
||||
if (!is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) {
|
||||
if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) {
|
||||
foreach ($rclist as $rc) {
|
||||
$result[] = $rc['userCertificate']->toString();
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ class Net_SSH1 {
|
||||
* @var Array
|
||||
* @access private
|
||||
*/
|
||||
var $interactive_buffer = '';
|
||||
var $interactiveBuffer = '';
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
|
Loading…
Reference in New Issue
Block a user