mirror of
https://github.com/danog/phpseclib.git
synced 2025-01-22 04:51:19 +01:00
Merge branch '1.0' of https://github.com/terrafrost/phpseclib into 1.0
This commit is contained in:
commit
fadefe5594
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,5 +1,15 @@
|
||||
# Changelog
|
||||
|
||||
## 1.0.2 - 2016-05-07
|
||||
|
||||
- All Ciphers: fix issue with CBC mode / OpenSSL / continuous buffers / decryption (#938)
|
||||
- Random: fix issues with serialize() (#932)
|
||||
- RC2: fix issue with decrypting
|
||||
- RC4: fix issue with key not being truncated correctly
|
||||
- SFTP: nlist() on a non-existant directory resulted in error
|
||||
- SFTP: add is_writable, is_writeable, is_readable
|
||||
- RSA: fix PHP4 compatability issue
|
||||
|
||||
## 1.0.1 - 2016-01-18
|
||||
|
||||
- RSA: fix regression in PSS mode ([#769](https://github.com/phpseclib/phpseclib/pull/769))
|
||||
|
@ -6,7 +6,7 @@ MIT-licensed pure-PHP implementations of an arbitrary-precision integer
|
||||
arithmetic library, fully PKCS#1 (v2.1) compliant RSA, DES, 3DES, RC4, Rijndael,
|
||||
AES, Blowfish, Twofish, SSH-1, SSH-2, SFTP, and X.509
|
||||
|
||||
* [Download (1.0.1)](http://sourceforge.net/projects/phpseclib/files/phpseclib1.0.1.zip/download)
|
||||
* [Download (1.0.2)](http://sourceforge.net/projects/phpseclib/files/phpseclib1.0.2.zip/download)
|
||||
* [Browse Git](https://github.com/phpseclib/phpseclib)
|
||||
* [Code Coverage Report](http://phpseclib.bantux.org/code_coverage/1.0/latest/)
|
||||
|
||||
|
@ -539,6 +539,7 @@ class Crypt_RSA
|
||||
case !isset($versions['Header']):
|
||||
case !isset($versions['Library']):
|
||||
case $versions['Header'] == $versions['Library']:
|
||||
case version_compare($versions['Header'], '1.0.0') >= 0 && version_compare($versions['Library'], '1.0.0') >= 0:
|
||||
define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_OPENSSL);
|
||||
break;
|
||||
default:
|
||||
@ -1838,7 +1839,7 @@ class Crypt_RSA
|
||||
* for invalid values.
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPublicKeyFingerprint($algorithm = 'md5')
|
||||
function getPublicKeyFingerprint($algorithm = 'md5')
|
||||
{
|
||||
if (empty($this->modulus) || empty($this->publicExponent)) {
|
||||
return false;
|
||||
@ -2163,8 +2164,14 @@ class Crypt_RSA
|
||||
*/
|
||||
function _exponentiate($x)
|
||||
{
|
||||
if (empty($this->primes) || empty($this->coefficients) || empty($this->exponents)) {
|
||||
return $x->modPow($this->exponent, $this->modulus);
|
||||
switch (true) {
|
||||
case empty($this->primes):
|
||||
case $this->primes[1]->equals($this->zero):
|
||||
case empty($this->coefficients):
|
||||
case $this->coefficients[2]->equals($this->zero):
|
||||
case empty($this->exponents):
|
||||
case $this->exponents[1]->equals($this->zero):
|
||||
return $x->modPow($this->exponent, $this->modulus);
|
||||
}
|
||||
|
||||
$num_primes = count($this->primes);
|
||||
@ -2639,7 +2646,7 @@ class Crypt_RSA
|
||||
// be output.
|
||||
|
||||
$emLen = ($emBits + 1) >> 3; // ie. ceil($emBits / 8)
|
||||
$sLen = $this->sLen ? $this->sLen : $this->hLen;
|
||||
$sLen = $this->sLen !== null ? $this->sLen : $this->hLen;
|
||||
|
||||
$mHash = $this->hash->hash($m);
|
||||
if ($emLen < $this->hLen + $sLen + 2) {
|
||||
@ -2677,7 +2684,7 @@ class Crypt_RSA
|
||||
// be output.
|
||||
|
||||
$emLen = ($emBits + 1) >> 3; // ie. ceil($emBits / 8);
|
||||
$sLen = $this->sLen ? $this->sLen : $this->hLen;
|
||||
$sLen = $this->sLen !== null ? $this->sLen : $this->hLen;
|
||||
|
||||
$mHash = $this->hash->hash($m);
|
||||
if ($emLen < $this->hLen + $sLen + 2) {
|
||||
|
@ -161,6 +161,7 @@ class File_X509
|
||||
var $CertificatePolicies;
|
||||
var $AuthorityInfoAccessSyntax;
|
||||
var $SubjectAltName;
|
||||
var $SubjectDirectoryAttributes;
|
||||
var $PrivateKeyUsagePeriod;
|
||||
var $IssuerAltName;
|
||||
var $PolicyMappings;
|
||||
@ -184,6 +185,14 @@ class File_X509
|
||||
var $SignedPublicKeyAndChallenge;
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* ASN.1 syntax for various DN attributes
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $PostalAddress;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* ASN.1 syntax for Certificate Signing Requests (RFC2986)
|
||||
*
|
||||
@ -1090,6 +1099,13 @@ class File_X509
|
||||
)
|
||||
);
|
||||
|
||||
$this->SubjectDirectoryAttributes = array(
|
||||
'type' => FILE_ASN1_TYPE_SEQUENCE,
|
||||
'min' => 1,
|
||||
'max' => -1,
|
||||
'children' => $Attribute
|
||||
);
|
||||
|
||||
// adapted from <http://tools.ietf.org/html/rfc2986>
|
||||
|
||||
$Attributes = array(
|
||||
@ -1257,6 +1273,14 @@ class File_X509
|
||||
)
|
||||
);
|
||||
|
||||
$this->PostalAddress = array(
|
||||
'type' => FILE_ASN1_TYPE_SEQUENCE,
|
||||
'optional' => true,
|
||||
'min' => 1,
|
||||
'max' => -1,
|
||||
'children' => $this->DirectoryString
|
||||
);
|
||||
|
||||
// OIDs from RFC5280 and those RFCs mentioned in RFC5280#section-4.1.1.2
|
||||
$this->oids = array(
|
||||
'1.3.6.1.5.5.7' => 'id-pkix',
|
||||
@ -1291,6 +1315,7 @@ class File_X509
|
||||
'2.5.4.9' => 'id-at-streetAddress',
|
||||
'2.5.4.45' => 'id-at-uniqueIdentifier',
|
||||
'2.5.4.72' => 'id-at-role',
|
||||
'2.5.4.16' => 'id-at-postalAddress',
|
||||
|
||||
'0.9.2342.19200300.100.1.25' => 'id-domainComponent',
|
||||
'1.2.840.113549.1.9' => 'pkcs-9',
|
||||
@ -1481,6 +1506,8 @@ class File_X509
|
||||
$this->signatureSubject = substr($cert, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']);
|
||||
|
||||
$this->_mapInExtensions($x509, 'tbsCertificate/extensions', $asn1);
|
||||
$this->_mapInDNs($x509, 'tbsCertificate/issuer/rdnSequence', $asn1);
|
||||
$this->_mapInDNs($x509, 'tbsCertificate/subject/rdnSequence', $asn1);
|
||||
|
||||
$key = &$x509['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'];
|
||||
$key = $this->_reformatKey($x509['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['algorithm'], $key);
|
||||
@ -1557,6 +1584,8 @@ class File_X509
|
||||
$asn1->loadFilters($filters);
|
||||
|
||||
$this->_mapOutExtensions($cert, 'tbsCertificate/extensions', $asn1);
|
||||
$this->_mapOutDNs($cert, 'tbsCertificate/issuer/rdnSequence', $asn1);
|
||||
$this->_mapOutDNs($cert, 'tbsCertificate/subject/rdnSequence', $asn1);
|
||||
|
||||
$cert = $asn1->encodeDER($cert, $this->Certificate);
|
||||
|
||||
@ -1769,6 +1798,68 @@ class File_X509
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map DN values from ANY type to DN-specific internal
|
||||
* format.
|
||||
*
|
||||
* @param array ref $root
|
||||
* @param string $path
|
||||
* @param object $asn1
|
||||
* @access private
|
||||
*/
|
||||
function _mapInDNs(&$root, $path, $asn1)
|
||||
{
|
||||
$dns = &$this->_subArray($root, $path);
|
||||
|
||||
if (is_array($dns)) {
|
||||
for ($i = 0; $i < count($dns); $i++) {
|
||||
for ($j = 0; $j < count($dns[$i]); $j++) {
|
||||
$type = $dns[$i][$j]['type'];
|
||||
$value = &$dns[$i][$j]['value'];
|
||||
if (is_object($value) && strtolower(get_class($value)) == 'file_asn1_element') {
|
||||
$map = $this->_getMapping($type);
|
||||
if (!is_bool($map)) {
|
||||
$decoded = $asn1->decodeBER($value);
|
||||
$value = $asn1->asn1map($decoded[0], $map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map DN values from DN-specific internal format to
|
||||
* ANY type.
|
||||
*
|
||||
* @param array ref $root
|
||||
* @param string $path
|
||||
* @param object $asn1
|
||||
* @access private
|
||||
*/
|
||||
function _mapOutDNs(&$root, $path, $asn1)
|
||||
{
|
||||
$dns = &$this->_subArray($root, $path);
|
||||
|
||||
if (is_array($dns)) {
|
||||
$size = count($dns);
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
for ($j = 0; $j < count($dns[$i]); $j++) {
|
||||
$type = $dns[$i][$j]['type'];
|
||||
$value = &$dns[$i][$j]['value'];
|
||||
if (is_object($value) && strtolower(get_class($value)) == 'file_asn1_element') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$map = $this->_getMapping($type);
|
||||
if (!is_bool($map)) {
|
||||
$value = new File_ASN1_Element($asn1->encodeDER($value, $map));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate an extension ID to an extension mapping
|
||||
*
|
||||
@ -1801,6 +1892,8 @@ class File_X509
|
||||
return $this->AuthorityInfoAccessSyntax;
|
||||
case 'id-ce-subjectAltName':
|
||||
return $this->SubjectAltName;
|
||||
case 'id-ce-subjectDirectoryAttributes':
|
||||
return $this->SubjectDirectoryAttributes;
|
||||
case 'id-ce-privateKeyUsagePeriod':
|
||||
return $this->PrivateKeyUsagePeriod;
|
||||
case 'id-ce-issuerAltName':
|
||||
@ -1860,6 +1953,8 @@ class File_X509
|
||||
return $this->CertificateIssuer;
|
||||
case 'id-ce-holdInstructionCode':
|
||||
return $this->HoldInstructionCode;
|
||||
case 'id-at-postalAddress':
|
||||
return $this->PostalAddress;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -2051,14 +2146,16 @@ class File_X509
|
||||
switch (true) {
|
||||
case isset($this->currentCert['tbsCertificate']):
|
||||
// self-signed cert
|
||||
if ($this->currentCert['tbsCertificate']['issuer'] === $this->currentCert['tbsCertificate']['subject']) {
|
||||
$authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier');
|
||||
$subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier');
|
||||
switch (true) {
|
||||
case !is_array($authorityKey):
|
||||
case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID:
|
||||
$signingCert = $this->currentCert; // working cert
|
||||
}
|
||||
switch (true) {
|
||||
case !defined('FILE_X509_IGNORE_TYPE') && $this->currentCert['tbsCertificate']['issuer'] === $this->currentCert['tbsCertificate']['subject']:
|
||||
case defined('FILE_X509_IGNORE_TYPE') && $this->getIssuerDN(FILE_X509_DN_STRING) === $this->getDN(FILE_X509_DN_STRING):
|
||||
$authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier');
|
||||
$subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier');
|
||||
switch (true) {
|
||||
case !is_array($authorityKey):
|
||||
case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID:
|
||||
$signingCert = $this->currentCert; // working cert
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->CAs)) {
|
||||
@ -2066,15 +2163,17 @@ class File_X509
|
||||
// even if the cert is a self-signed one we still want to see if it's a CA;
|
||||
// if not, we'll conditionally return an error
|
||||
$ca = $this->CAs[$i];
|
||||
if ($this->currentCert['tbsCertificate']['issuer'] === $ca['tbsCertificate']['subject']) {
|
||||
$authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier');
|
||||
$subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier', $ca);
|
||||
switch (true) {
|
||||
case !is_array($authorityKey):
|
||||
case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID:
|
||||
$signingCert = $ca; // working cert
|
||||
break 2;
|
||||
}
|
||||
switch (true) {
|
||||
case !defined('FILE_X509_IGNORE_TYPE') && $this->currentCert['tbsCertificate']['issuer'] === $ca['tbsCertificate']['subject']:
|
||||
case defined('FILE_X509_IGNORE_TYPE') && $this->getDN(FILE_X509_DN_STRING, $this->currentCert['tbsCertificate']['issuer']) === $this->getDN(FILE_X509_DN_STRING, $ca['tbsCertificate']['subject']):
|
||||
$authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier');
|
||||
$subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier', $ca);
|
||||
switch (true) {
|
||||
case !is_array($authorityKey):
|
||||
case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID:
|
||||
$signingCert = $ca; // working cert
|
||||
break 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($this->CAs) == $i && $caonly) {
|
||||
@ -2110,15 +2209,17 @@ class File_X509
|
||||
if (!empty($this->CAs)) {
|
||||
for ($i = 0; $i < count($this->CAs); $i++) {
|
||||
$ca = $this->CAs[$i];
|
||||
if ($this->currentCert['tbsCertList']['issuer'] === $ca['tbsCertificate']['subject']) {
|
||||
$authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier');
|
||||
$subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier', $ca);
|
||||
switch (true) {
|
||||
case !is_array($authorityKey):
|
||||
case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID:
|
||||
$signingCert = $ca; // working cert
|
||||
break 2;
|
||||
}
|
||||
switch (true) {
|
||||
case !defined('FILE_X509_IGNORE_TYPE') && $this->currentCert['tbsCertList']['issuer'] === $ca['tbsCertificate']['subject']:
|
||||
case defined('FILE_X509_IGNORE_TYPE') && $this->getDN(FILE_X509_DN_STRING, $this->currentCert['tbsCertList']['issuer']) === $this->getDN(FILE_X509_DN_STRING, $ca['tbsCertificate']['subject']):
|
||||
$authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier');
|
||||
$subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier', $ca);
|
||||
switch (true) {
|
||||
case !is_array($authorityKey):
|
||||
case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID:
|
||||
$signingCert = $ca; // working cert
|
||||
break 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2325,6 +2426,9 @@ class File_X509
|
||||
case 'uniqueidentifier':
|
||||
case 'x500uniqueidentifier':
|
||||
return 'id-at-uniqueIdentifier';
|
||||
case 'postaladdress':
|
||||
case 'id-at-postaladdress':
|
||||
return 'id-at-postalAddress';
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -2414,25 +2518,38 @@ class File_X509
|
||||
return false;
|
||||
}
|
||||
|
||||
$asn1 = new File_ASN1();
|
||||
$asn1->loadOIDs($this->oids);
|
||||
$filters = array();
|
||||
$filters['value'] = array('type' => FILE_ASN1_TYPE_UTF8_STRING);
|
||||
$asn1->loadFilters($filters);
|
||||
$this->_mapOutDNs($dn, 'rdnSequence', $asn1);
|
||||
$dn = $dn['rdnSequence'];
|
||||
$result = array();
|
||||
$asn1 = new File_ASN1();
|
||||
for ($i = 0; $i < count($dn); $i++) {
|
||||
if ($dn[$i][0]['type'] == $propName) {
|
||||
$v = $dn[$i][0]['value'];
|
||||
if (!$withType && is_array($v)) {
|
||||
foreach ($v as $type => $s) {
|
||||
$type = array_search($type, $asn1->ANYmap, true);
|
||||
if ($type !== false && isset($asn1->stringTypeSize[$type])) {
|
||||
$s = $asn1->convert($s, $type);
|
||||
if ($s !== false) {
|
||||
$v = $s;
|
||||
break;
|
||||
if (!$withType) {
|
||||
if (is_array($v)) {
|
||||
foreach ($v as $type => $s) {
|
||||
$type = array_search($type, $asn1->ANYmap, true);
|
||||
if ($type !== false && isset($asn1->stringTypeSize[$type])) {
|
||||
$s = $asn1->convert($s, $type);
|
||||
if ($s !== false) {
|
||||
$v = $s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_array($v)) {
|
||||
$v = array_pop($v); // Always strip data type.
|
||||
if (is_array($v)) {
|
||||
$v = array_pop($v); // Always strip data type.
|
||||
}
|
||||
} elseif (is_object($v) && strtolower(get_class($v)) == 'file_asn1_element') {
|
||||
$map = $this->_getMapping($propName);
|
||||
if (!is_bool($map)) {
|
||||
$decoded = $asn1->decodeBER($v);
|
||||
$v = $asn1->asn1map($decoded[0], $map);
|
||||
}
|
||||
}
|
||||
}
|
||||
$result[] = $v;
|
||||
@ -2473,7 +2590,7 @@ class File_X509
|
||||
}
|
||||
|
||||
// handles everything else
|
||||
$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);
|
||||
$results = preg_split('#((?:^|, *|/)(?:C=|O=|OU=|CN=|L=|ST=|SN=|postalCode=|streetAddress=|emailAddress=|serialNumber=|organizationalUnitName=|title=|description=|role=|x500UniqueIdentifier=|postalAddress=))#', $dn, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
for ($i = 1; $i < count($results); $i+=2) {
|
||||
$prop = trim($results[$i], ', =/');
|
||||
$value = $results[$i + 1];
|
||||
@ -2508,33 +2625,19 @@ class File_X509
|
||||
$filters = array();
|
||||
$filters['rdnSequence']['value'] = array('type' => FILE_ASN1_TYPE_UTF8_STRING);
|
||||
$asn1->loadFilters($filters);
|
||||
$this->_mapOutDNs($dn, 'rdnSequence', $asn1);
|
||||
return $asn1->encodeDER($dn, $this->Name);
|
||||
case FILE_X509_DN_OPENSSL:
|
||||
$dn = $this->getDN(FILE_X509_DN_STRING, $dn);
|
||||
if ($dn === false) {
|
||||
return false;
|
||||
}
|
||||
$attrs = preg_split('#((?:^|, *|/)[a-z][a-z0-9]*=)#i', $dn, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
$dn = array();
|
||||
for ($i = 1; $i < count($attrs); $i += 2) {
|
||||
$prop = trim($attrs[$i], ', =/');
|
||||
$value = $attrs[$i + 1];
|
||||
if (!isset($dn[$prop])) {
|
||||
$dn[$prop] = $value;
|
||||
} else {
|
||||
$dn[$prop] = array_merge((array) $dn[$prop], array($value));
|
||||
}
|
||||
}
|
||||
return $dn;
|
||||
case FILE_X509_DN_CANON:
|
||||
// No SEQUENCE around RDNs and all string values normalized as
|
||||
// trimmed lowercase UTF-8 with all spacing as one blank.
|
||||
// trimmed lowercase UTF-8 with all spacing as one blank.
|
||||
// constructed RDNs will not be canonicalized
|
||||
$asn1 = new File_ASN1();
|
||||
$asn1->loadOIDs($this->oids);
|
||||
$filters = array();
|
||||
$filters['value'] = array('type' => FILE_ASN1_TYPE_UTF8_STRING);
|
||||
$asn1->loadFilters($filters);
|
||||
$result = '';
|
||||
$this->_mapOutDNs($dn, 'rdnSequence', $asn1);
|
||||
foreach ($dn['rdnSequence'] as $rdn) {
|
||||
foreach ($rdn as $i => $attr) {
|
||||
$attr = &$rdn[$i];
|
||||
@ -2569,7 +2672,13 @@ class File_X509
|
||||
// Default is to return a string.
|
||||
$start = true;
|
||||
$output = '';
|
||||
$result = array();
|
||||
$asn1 = new File_ASN1();
|
||||
$asn1->loadOIDs($this->oids);
|
||||
$filters = array();
|
||||
$filters['rdnSequence']['value'] = array('type' => FILE_ASN1_TYPE_UTF8_STRING);
|
||||
$asn1->loadFilters($filters);
|
||||
$this->_mapOutDNs($dn, 'rdnSequence', $asn1);
|
||||
foreach ($dn['rdnSequence'] as $field) {
|
||||
$prop = $field[0]['type'];
|
||||
$value = $field[0]['value'];
|
||||
@ -2577,33 +2686,37 @@ class File_X509
|
||||
$delim = ', ';
|
||||
switch ($prop) {
|
||||
case 'id-at-countryName':
|
||||
$desc = 'C=';
|
||||
$desc = 'C';
|
||||
break;
|
||||
case 'id-at-stateOrProvinceName':
|
||||
$desc = 'ST=';
|
||||
$desc = 'ST';
|
||||
break;
|
||||
case 'id-at-organizationName':
|
||||
$desc = 'O=';
|
||||
$desc = 'O';
|
||||
break;
|
||||
case 'id-at-organizationalUnitName':
|
||||
$desc = 'OU=';
|
||||
$desc = 'OU';
|
||||
break;
|
||||
case 'id-at-commonName':
|
||||
$desc = 'CN=';
|
||||
$desc = 'CN';
|
||||
break;
|
||||
case 'id-at-localityName':
|
||||
$desc = 'L=';
|
||||
$desc = 'L';
|
||||
break;
|
||||
case 'id-at-surname':
|
||||
$desc = 'SN=';
|
||||
$desc = 'SN';
|
||||
break;
|
||||
case 'id-at-uniqueIdentifier':
|
||||
$delim = '/';
|
||||
$desc = 'x500UniqueIdentifier=';
|
||||
$desc = 'x500UniqueIdentifier';
|
||||
break;
|
||||
case 'id-at-postalAddress':
|
||||
$delim = '/';
|
||||
$desc = 'postalAddress';
|
||||
break;
|
||||
default:
|
||||
$delim = '/';
|
||||
$desc = preg_replace('#.+-([^-]+)$#', '$1', $prop) . '=';
|
||||
$desc = preg_replace('#.+-([^-]+)$#', '$1', $prop);
|
||||
}
|
||||
|
||||
if (!$start) {
|
||||
@ -2623,12 +2736,18 @@ class File_X509
|
||||
if (is_array($value)) {
|
||||
$value = array_pop($value); // Always strip data type.
|
||||
}
|
||||
} elseif (is_object($value) && strtolower(get_class($value)) == 'file_asn1_element') {
|
||||
$callback = create_function('$x', 'return "\x" . bin2hex($x[0]);');
|
||||
$value = strtoupper(preg_replace_callback('#[^\x20-\x7E]#', $callback, $value->element));
|
||||
}
|
||||
$output.= $desc . $value;
|
||||
$output.= $desc . '=' . $value;
|
||||
$result[$desc] = isset($result[$desc]) ?
|
||||
array_merge((array) $dn[$prop], array($value)) :
|
||||
$value;
|
||||
$start = false;
|
||||
}
|
||||
|
||||
return $output;
|
||||
return $format == FILE_X509_DN_OPENSSL ? $result : $output;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2906,8 +3025,10 @@ class File_X509
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->dn = $csr['certificationRequestInfo']['subject'];
|
||||
$this->_mapInAttributes($csr, 'certificationRequestInfo/attributes', $asn1);
|
||||
$this->_mapInDNs($csr, 'certificationRequestInfo/subject/rdnSequence', $asn1);
|
||||
|
||||
$this->dn = $csr['certificationRequestInfo']['subject'];
|
||||
|
||||
$this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']);
|
||||
|
||||
@ -2957,6 +3078,9 @@ class File_X509
|
||||
case 'rsaEncryption':
|
||||
$csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']
|
||||
= base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'])));
|
||||
$csr['certificationRequestInfo']['subjectPKInfo']['algorithm']['parameters'] = null;
|
||||
$csr['signatureAlgorithm']['parameters'] = null;
|
||||
$csr['certificationRequestInfo']['signature']['parameters'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2970,6 +3094,7 @@ class File_X509
|
||||
|
||||
$asn1->loadFilters($filters);
|
||||
|
||||
$this->_mapOutDNs($csr, 'certificationRequestInfo/subject/rdnSequence', $asn1);
|
||||
$this->_mapOutAttributes($csr, 'certificationRequestInfo/attributes', $asn1);
|
||||
$csr = $asn1->encodeDER($csr, $this->CertificationRequest);
|
||||
|
||||
@ -3150,6 +3275,7 @@ class File_X509
|
||||
|
||||
$this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']);
|
||||
|
||||
$this->_mapInDNs($crl, 'tbsCertList/issuer/rdnSequence', $asn1);
|
||||
$this->_mapInExtensions($crl, 'tbsCertList/crlExtensions', $asn1);
|
||||
$rclist = &$this->_subArray($crl, 'tbsCertList/revokedCertificates');
|
||||
if (is_array($rclist)) {
|
||||
@ -3202,6 +3328,7 @@ class File_X509
|
||||
|
||||
$asn1->loadFilters($filters);
|
||||
|
||||
$this->_mapOutDNs($crl, 'tbsCertList/issuer/rdnSequence', $asn1);
|
||||
$this->_mapOutExtensions($crl, 'tbsCertList/crlExtensions', $asn1);
|
||||
$rclist = &$this->_subArray($crl, 'tbsCertList/revokedCertificates');
|
||||
if (is_array($rclist)) {
|
||||
|
@ -286,6 +286,7 @@ class Math_BigInteger
|
||||
case !isset($versions['Header']):
|
||||
case !isset($versions['Library']):
|
||||
case $versions['Header'] == $versions['Library']:
|
||||
case version_compare($versions['Header'], '1.0.0') >= 0 && version_compare($versions['Library'], '1.0.0') >= 0:
|
||||
define('MATH_BIGINTEGER_OPENSSL_ENABLED', true);
|
||||
break;
|
||||
default:
|
||||
|
@ -1933,7 +1933,7 @@ class Net_SFTP extends Net_SSH2
|
||||
// make the SFTP packet be exactly 4096 bytes by including the bytes in the NET_SFTP_WRITE packets "header"
|
||||
$sftp_packet_size-= strlen($handle) + 25;
|
||||
$i = 0;
|
||||
while ($dataCallback || ($sent < $size)) {
|
||||
while ($dataCallback || ($size === 0 || $sent < $size)) {
|
||||
if ($dataCallback) {
|
||||
$temp = call_user_func($dataCallback, $sftp_packet_size);
|
||||
if (is_null($temp)) {
|
||||
@ -1941,7 +1941,11 @@ class Net_SFTP extends Net_SSH2
|
||||
}
|
||||
} else {
|
||||
$temp = isset($fp) ? fread($fp, $sftp_packet_size) : substr($data, $sent, $sftp_packet_size);
|
||||
if ($temp === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$subtemp = $offset + $sent;
|
||||
$packet = pack('Na*N3a*', strlen($handle), $handle, $subtemp / 4294967296, $subtemp, strlen($temp), $temp);
|
||||
if (!$this->_send_sftp_packet(NET_SFTP_WRITE, $packet)) {
|
||||
@ -2350,6 +2354,76 @@ class Net_SFTP extends Net_SSH2
|
||||
return $result === NET_SFTP_TYPE_SYMLINK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether a file exists and is readable
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
* @access public
|
||||
*/
|
||||
function is_readable($path)
|
||||
{
|
||||
$path = $this->_realpath($path);
|
||||
|
||||
$packet = pack('Na*N2', strlen($path), $path, NET_SFTP_OPEN_READ, 0);
|
||||
if (!$this->_send_sftp_packet(NET_SFTP_OPEN, $packet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$response = $this->_get_sftp_packet();
|
||||
switch ($this->packet_type) {
|
||||
case NET_SFTP_HANDLE:
|
||||
return true;
|
||||
case NET_SFTP_STATUS: // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
|
||||
return false;
|
||||
default:
|
||||
user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether the filename is writable
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
* @access public
|
||||
*/
|
||||
function is_writable($path)
|
||||
{
|
||||
$path = $this->_realpath($path);
|
||||
|
||||
$packet = pack('Na*N2', strlen($path), $path, NET_SFTP_OPEN_WRITE, 0);
|
||||
if (!$this->_send_sftp_packet(NET_SFTP_OPEN, $packet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$response = $this->_get_sftp_packet();
|
||||
switch ($this->packet_type) {
|
||||
case NET_SFTP_HANDLE:
|
||||
return true;
|
||||
case NET_SFTP_STATUS: // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
|
||||
return false;
|
||||
default:
|
||||
user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether the filename is writeable
|
||||
*
|
||||
* Alias of is_writable
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
* @access public
|
||||
*/
|
||||
function is_writeable($path)
|
||||
{
|
||||
return $this->is_writable($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets last access time of file
|
||||
*
|
||||
|
@ -3875,7 +3875,7 @@ class Net_SSH2
|
||||
/**
|
||||
* Returns all errors
|
||||
*
|
||||
* @return string
|
||||
* @return string[]
|
||||
* @access public
|
||||
*/
|
||||
function getErrors()
|
||||
|
@ -686,5 +686,27 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
||||
$sftp->get('offset.txt'),
|
||||
'Failed asserting that you could upload into the middle of a file.'
|
||||
);
|
||||
|
||||
return $sftp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testUploadOffsets
|
||||
*/
|
||||
public function testReadableWritable($sftp)
|
||||
{
|
||||
$sftp->chmod(0000, 'offset.txt');
|
||||
$this->assertFalse($sftp->is_writable('offset.txt'));
|
||||
$this->assertFalse($sftp->is_writeable('offset.txt'));
|
||||
$this->assertFalse($sftp->is_readable('offset.txt'));
|
||||
|
||||
$sftp->chmod(0777, 'offset.txt');
|
||||
$this->assertTrue($sftp->is_writable('offset.txt'));
|
||||
$this->assertTrue($sftp->is_writeable('offset.txt'));
|
||||
$this->assertTrue($sftp->is_readable('offset.txt'));
|
||||
|
||||
$this->assertFalse($sftp->is_writable('nonexistantfile.ext'));
|
||||
$this->assertFalse($sftp->is_writeable('nonexistantfile.ext'));
|
||||
$this->assertFalse($sftp->is_readable('nonexistantfile.ext'));
|
||||
}
|
||||
}
|
||||
|
@ -379,4 +379,25 @@ Private-MAC: 35134b7434bf828b21404099861d455e660e8740';
|
||||
$rsa->setPrivateKey();
|
||||
$rsa->loadKey($rsa);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group github980
|
||||
*/
|
||||
public function testZeroComponents()
|
||||
{
|
||||
$key = '-----BEGIN RSA PRIVATE KEY-----
|
||||
MIGaAgEAAkEAt5yrcHAAjhglnCEn6yecMWPeUXcMyo0+itXrLlkpcKIIyqPw546b
|
||||
GThhlb1ppX1ySX/OUA4jSakHekNP5eWPawIBAAJAW6/aVD05qbsZHMvZuS2Aa5Fp
|
||||
NNj0BDlf38hOtkhDzz/hkYb+EBYLLvldhgsD0OvRNy8yhz7EjaUqLCB0juIN4QIB
|
||||
AAIBAAIBAAIBAAIBAA==
|
||||
-----END RSA PRIVATE KEY-----';
|
||||
|
||||
$rsa = new Crypt_RSA();
|
||||
$rsa->loadKey($key);
|
||||
$rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
|
||||
$rsa->setHash('md5');
|
||||
$rsa->setMGFHash('md5');
|
||||
|
||||
$rsa->sign('zzzz');
|
||||
}
|
||||
}
|
||||
|
@ -63,4 +63,35 @@ p0GbMJDyR4e9T04ZZwIDAQAB
|
||||
|
||||
$this->assertTrue($rsa->verify('zzzz', $sig));
|
||||
}
|
||||
|
||||
public function testZeroLengthSalt()
|
||||
{
|
||||
$plaintext = 'a';
|
||||
|
||||
$rsa = new Crypt_RSA();
|
||||
|
||||
$privatekey = '-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp
|
||||
wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5
|
||||
1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh
|
||||
3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2
|
||||
pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX
|
||||
GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il
|
||||
AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF
|
||||
L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k
|
||||
X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl
|
||||
U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
|
||||
37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=
|
||||
-----END RSA PRIVATE KEY-----';
|
||||
$rsa->loadKey($privatekey);
|
||||
$rsa->setSaltLength(0);
|
||||
|
||||
// Check we generate the correct signature.
|
||||
$sig = pack('H*', '0ddfc93548e21d015c0a289a640b3b79aecfdfae045f583c5925b91cc5c399bba181616ad6ae20d9662d966f0eb2fddb550f4733268e34d640f4c9dadcaf25b3c82c42130a5081c6ebad7883331c65b25b6a37ffa7c4233a468dae56180787e2718ed87c48d8d50b72f5850e4a40963b4f36710be250ecef6fe0bb91249261a3');
|
||||
$this->assertEquals($sig, $rsa->sign($plaintext));
|
||||
|
||||
// Check we can verify the signature correctly.
|
||||
$rsa->loadKey($rsa->getPublicKey());
|
||||
$this->assertTrue($rsa->verify($plaintext, $sig));
|
||||
}
|
||||
}
|
||||
|
@ -222,4 +222,198 @@ aBtsWpliLSex/HHhtRW9AkBGcq67zKmEpJ9kXcYLEjJii3flFS+Ct/rNm+Hhm1l7
|
||||
$this->assertEquals($x509->getOID('id-sha256'), '2.16.840.1.101.3.4.2.1');
|
||||
$this->assertEquals($x509->getOID('zzz'), 'zzz');
|
||||
}
|
||||
|
||||
public function testPostalAddress()
|
||||
{
|
||||
$x509 = new File_X509();
|
||||
$decoded = $x509->loadX509('-----BEGIN CERTIFICATE-----
|
||||
MIIFzzCCBLegAwIBAgIDAfdlMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAlBM
|
||||
MSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMSQwIgYD
|
||||
VQQDDBtDT1BFIFNaQUZJUiAtIEt3YWxpZmlrb3dhbnkxFDASBgNVBAUTC05yIHdw
|
||||
aXN1OiA2MB4XDTExMTEwOTA2MDAwMFoXDTEzMTEwOTA2MDAwMFowgdkxCzAJBgNV
|
||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QCMAAwIQYDVR0RBBowGIEWai5wcnpld29yc2tpQGdkeW5p
|
||||
YS5wbDAOBgNVHQ8BAf8EBAMCBkAwgZ4GA1UdIwSBljCBk4AU3TGldJXipN4oGS3Z
|
||||
YmnBDMFs8gKhd6R1MHMxCzAJBgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6
|
||||
YmEgUm96bGljemVuaW93YSBTLkEuMSQwIgYDVQQDDBtDT1BFIFNaQUZJUiAtIEt3
|
||||
YWxpZmlrb3dhbnkxFDASBgNVBAUTC05yIHdwaXN1OiA2ggJb9jBIBgNVHR8EQTA/
|
||||
MD2gO6A5hjdodHRwOi8vd3d3Lmtpci5jb20ucGwvY2VydHlmaWthY2phX2tsdWN6
|
||||
eS9DUkxfT1pLMzIuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQBYPIqnAreyeql7/opJ
|
||||
jcar/qWZy9ruhB2q0lZFsJOhwgMnbQXzp/4vv93YJqcHGAXdHP6EO8FQX47mjo2Z
|
||||
KQmi+cIHJHLONdX/3Im+M17V0iNAh7Z1lOSfTRT+iiwe/F8phcEaD5q2RmvYusR7
|
||||
zXZq/cLL0If0hXoPZ/EHQxjN8pxzxiUx6bJAgturnIMEfRNesxwghdr1dkUjOhGL
|
||||
f3kHVzgM6j3VAM7oFmMUb5y5s96Bzl10DodWitjOEH0vvnIcsppSxH1C1dCAi0o9
|
||||
f/1y2XuLNhBNHMAyTqpYPX8Yvav1c+Z50OMaSXHAnTa20zv8UtiHbaAhwlifCelU
|
||||
Mj93S
|
||||
-----END CERTIFICATE-----');
|
||||
$x509->loadX509($x509->saveX509($decoded));
|
||||
$expected = array(
|
||||
array(
|
||||
array('utf8String' => "Al. Marsza\xC5\x82ka Pi\xC5\x82sudskiego 52/54"),
|
||||
array('utf8String' => '81-382 Gdynia'),
|
||||
array('utf8String' => 'Polska'),
|
||||
array('utf8String' => 'pomorskie')
|
||||
)
|
||||
);
|
||||
$this->assertEquals($x509->getDNProp('id-at-postalAddress'), $expected);
|
||||
|
||||
$expected = "C=PL, O=Urz\xC4\x85d Miasta Gdyni/serialNumber=PESEL: 61060603118, CN=Jerzy Przeworski/postalAddress=" . '0F\X0C"AL. MARSZA\XC5\X82KA PI\XC5\X82SUDSKIEGO 52/54\X0C\X0D81-382 GDYNIA\X0C\X06POLSKA\X0C\X09POMORSKIE/givenName=Jerzy, SN=Przeworski';
|
||||
$this->assertEquals($x509->getDN(FILE_X509_DN_STRING), $expected);
|
||||
}
|
||||
|
||||
public function testStrictComparison()
|
||||
{
|
||||
$x509 = new File_X509();
|
||||
$x509->loadCA('-----BEGIN CERTIFICATE-----
|
||||
MIIEbDCCA1SgAwIBAgIUJguKOMpJm/yRMDlMOW04NV0YPXowDQYJKoZIhvcNAQEF
|
||||
BQAwYTELMAkGA1UEBhMCUEwxNzA1BgNVBAoTLkNaaUMgQ2VudHJhc3QgU0EgdyBp
|
||||
bWllbml1IE1pbmlzdHJhIEdvc3BvZGFya2kxGTAXBgNVBAMTEENaaUMgQ2VudHJh
|
||||
c3QgU0EwHhcNMDkwNDI5MTE1MzIxWhcNMTMxMjEzMjM1OTU5WjBzMQswCQYDVQQG
|
||||
EwJQTDEoMCYGA1UEChMfS3Jham93YSBJemJhIFJvemxpY3plbmlvd2EgUy5BLjEk
|
||||
MCIGA1UEAxMbQ09QRSBTWkFGSVIgLSBLd2FsaWZpa293YW55MRQwEgYDVQQFEwtO
|
||||
ciB3cGlzdTogNjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIjNy3EL
|
||||
oK0uKTqAJokiP8VIxER/0OfwhY4DBhJGW38W6Pfema8iUs4net0NgoIeDpMQ8IHj
|
||||
FDSKkSaRkyL5f7PgvqBwzKe0HD1Duf9G/Lr2lu/J4QUMF3rqKaMRipXKkkEoKrub
|
||||
Qe41/mPiPXeClNswNQUEyInqWpfWNncU8AIs2GKIFTfSNqK4PgWOY1kG9MYfoNVr
|
||||
74dhejv7yHexEw9eAIcM1fIkEE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$this->assertFalse($x509->validateSignature());
|
||||
}
|
||||
|
||||
public function testLooseComparison()
|
||||
{
|
||||
if (!extension_loaded('runkit')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
define('FILE_X509_IGNORE_TYPE', true);
|
||||
|
||||
$x509 = new File_X509();
|
||||
$x509->loadCA('-----BEGIN CERTIFICATE-----
|
||||
MIIEbDCCA1SgAwIBAgIUJguKOMpJm/yRMDlMOW04NV0YPXowDQYJKoZIhvcNAQEF
|
||||
BQAwYTELMAkGA1UEBhMCUEwxNzA1BgNVBAoTLkNaaUMgQ2VudHJhc3QgU0EgdyBp
|
||||
bWllbml1IE1pbmlzdHJhIEdvc3BvZGFya2kxGTAXBgNVBAMTEENaaUMgQ2VudHJh
|
||||
c3QgU0EwHhcNMDkwNDI5MTE1MzIxWhcNMTMxMjEzMjM1OTU5WjBzMQswCQYDVQQG
|
||||
EwJQTDEoMCYGA1UEChMfS3Jham93YSBJemJhIFJvemxpY3plbmlvd2EgUy5BLjEk
|
||||
MCIGA1UEAxMbQ09QRSBTWkFGSVIgLSBLd2FsaWZpa293YW55MRQwEgYDVQQFEwtO
|
||||
ciB3cGlzdTogNjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIjNy3EL
|
||||
oK0uKTqAJokiP8VIxER/0OfwhY4DBhJGW38W6Pfema8iUs4net0NgoIeDpMQ8IHj
|
||||
FDSKkSaRkyL5f7PgvqBwzKe0HD1Duf9G/Lr2lu/J4QUMF3rqKaMRipXKkkEoKrub
|
||||
Qe41/mPiPXeClNswNQUEyInqWpfWNncU8AIs2GKIFTfSNqK4PgWOY1kG9MYfoNVr
|
||||
74dhejv7yHexEw9eAIcM1fIkEEq0vWIOjRtBXBAuWtUyD8iSeBs4nIN+614pHIjv
|
||||
ncHxG7xTDbmOAVZFgGZ8Hk5CUseAtTpazQNdU66XRUuCj4km01L4wsfZ1X8tfYQA
|
||||
6msMRYj+F7hLtoECAwEAAaOCAQgwggEEMA8GA1UdEwEB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ydHlmaWthY2phX2tsdWN6eS9wb2xpdHlr
|
||||
YS5odG1sMAkGA1UdCQQCMAAwIQYDVR0RBBowGIEWai5wcnpld29yc2tpQGdkeW5p
|
||||
YS5wbDAOBgNVHQ8BAf8EBAMCBkAwgZ4GA1UdIwSBljCBk4AU3TGldJXipN4oGS3Z
|
||||
YmnBDMFs8gKhd6R1MHMxCzAJBgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6
|
||||
YmEgUm96bGljemVuaW93YSBTLkEuMSQwIgYDVQQDDBtDT1BFIFNaQUZJUiAtIEt3
|
||||
YWxpZmlrb3dhbnkxFDASBgNVBAUTC05yIHdwaXN1OiA2ggJb9jBIBgNVHR8EQTA/
|
||||
MD2gO6A5hjdodHRwOi8vd3d3Lmtpci5jb20ucGwvY2VydHlmaWthY2phX2tsdWN6
|
||||
eS9DUkxfT1pLMzIuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQBYPIqnAreyeql7/opJ
|
||||
jcar/qWZy9ruhB2q0lZFsJOhwgMnbQXzp/4vv93YJqcHGAXdHP6EO8FQX47mjo2Z
|
||||
KQmi+cIHJHLONdX/3Im+M17V0iNAh7Z1lOSfTRT+iiwe/F8phcEaD5q2RmvYusR7
|
||||
zXZq/cLL0If0hXoPZ/EHQxjN8pxzxiUx6bJAgturnIMEfRNesxwghdr1dkUjOhGL
|
||||
f3kHVzgM6j3VAM7oFmMUb5y5s96Bzl10DodWitjOEH0vvnIcsppSxH1C1dCAi0o9
|
||||
f/1y2XuLNhBNHMAyTqpYPX8Yvav1c+Z50OMaSXHAnTa20zv8UtiHbaAhwlifCelU
|
||||
Mj93S
|
||||
-----END CERTIFICATE-----');
|
||||
$this->assertTrue($x509->validateSignature());
|
||||
|
||||
runkit_constant_remove('FILE_X509_IGNORE_TYPE');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user