mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-28 20:12:44 +00:00
Merge branch 'pre-1157-changes'
This commit is contained in:
commit
93a3139475
@ -1348,27 +1348,6 @@ abstract class ASN1
|
|||||||
return $temp != false ? $temp : $str;
|
return $temp != false ? $temp : $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* DER-decode the length
|
|
||||||
*
|
|
||||||
* DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See
|
|
||||||
* {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param string $string
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public static function decodeLength(&$string)
|
|
||||||
{
|
|
||||||
$length = ord(Strings::shift($string));
|
|
||||||
if ($length & 0x80) { // definite length, long form
|
|
||||||
$length&= 0x7F;
|
|
||||||
$temp = Strings::shift($string, $length);
|
|
||||||
list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4));
|
|
||||||
}
|
|
||||||
return $length;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DER-encode the length
|
* DER-encode the length
|
||||||
*
|
*
|
||||||
|
@ -3129,12 +3129,13 @@ class X509
|
|||||||
* Returns a list of all extensions in use in certificate, CSR or CRL
|
* Returns a list of all extensions in use in certificate, CSR or CRL
|
||||||
*
|
*
|
||||||
* @param array $cert optional
|
* @param array $cert optional
|
||||||
|
* @param string $path optional
|
||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getExtensions($cert = null)
|
public function getExtensions($cert = null, $path = null)
|
||||||
{
|
{
|
||||||
return $this->getExtensionsHelper($cert);
|
return $this->getExtensionsHelper($cert, $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3686,7 +3687,7 @@ class X509
|
|||||||
|
|
||||||
if (is_array($rclist = $this->subArray($crl, 'tbsCertList/revokedCertificates'))) {
|
if (is_array($rclist = $this->subArray($crl, 'tbsCertList/revokedCertificates'))) {
|
||||||
if (($i = $this->revokedCertificate($rclist, $serial)) !== false) {
|
if (($i = $this->revokedCertificate($rclist, $serial)) !== false) {
|
||||||
return $this->getExtensionsHelper($crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions");
|
return $this->getExtensions($crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4333,7 +4333,7 @@ class SSH2
|
|||||||
case $r->compare($q) >= 0:
|
case $r->compare($q) >= 0:
|
||||||
case $s->equals($zero):
|
case $s->equals($zero):
|
||||||
case $s->compare($q) >= 0:
|
case $s->compare($q) >= 0:
|
||||||
$this->disconnectHepler(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED);
|
$this->disconnect_helper(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED);
|
||||||
throw new \RuntimeException('Invalid signature');
|
throw new \RuntimeException('Invalid signature');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
tests/Unit/File/X509/CRLTest.php
Normal file
24
tests/Unit/File/X509/CRLTest.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
|
* @copyright 2017 Jim Wigginton
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
|
*/
|
||||||
|
|
||||||
|
use phpseclib\File\X509;
|
||||||
|
|
||||||
|
class Unit_File_X509_CRLTest extends PhpseclibTestCase
|
||||||
|
{
|
||||||
|
public function testLoadCRL()
|
||||||
|
{
|
||||||
|
$test = file_get_contents('crl.bin');
|
||||||
|
|
||||||
|
$x509 = new X509();
|
||||||
|
|
||||||
|
$x509->loadCRL($test);
|
||||||
|
|
||||||
|
$reason = $x509->getRevokedCertificateExtension('9048354325167497831898969642461237543', 'id-ce-cRLReasons');
|
||||||
|
|
||||||
|
$this->assertSame('unspecified', $reason);
|
||||||
|
}
|
||||||
|
}
|
@ -181,6 +181,7 @@ aBtsWpliLSex/HHhtRW9AkBGcq67zKmEpJ9kXcYLEjJii3flFS+Ct/rNm+Hhm1l7
|
|||||||
$issuer->setDN($subject->getDN());
|
$issuer->setDN($subject->getDN());
|
||||||
|
|
||||||
$x509 = new X509();
|
$x509 = new X509();
|
||||||
|
$x509->setEndDate('lifetime');
|
||||||
|
|
||||||
$result = $x509->sign($issuer, $subject);
|
$result = $x509->sign($issuer, $subject);
|
||||||
$cert = $x509->saveX509($result);
|
$cert = $x509->saveX509($result);
|
||||||
|
BIN
tests/Unit/File/X509/crl.bin
Normal file
BIN
tests/Unit/File/X509/crl.bin
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user