mirror of
https://github.com/danog/phpseclib.git
synced 2024-12-12 09:09:39 +01:00
Merge branch '1.0' into 2.0
This commit is contained in:
commit
5a3e622c4d
@ -234,6 +234,9 @@ class ASN1
|
|||||||
{
|
{
|
||||||
$current = array('start' => $start);
|
$current = array('start' => $start);
|
||||||
|
|
||||||
|
if (!isset($encoded[$encoded_pos])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$type = ord($encoded[$encoded_pos++]);
|
$type = ord($encoded[$encoded_pos++]);
|
||||||
$startOffset = 1;
|
$startOffset = 1;
|
||||||
|
|
||||||
@ -244,6 +247,9 @@ class ASN1
|
|||||||
$tag = 0;
|
$tag = 0;
|
||||||
// process septets (since the eighth bit is ignored, it's not an octet)
|
// process septets (since the eighth bit is ignored, it's not an octet)
|
||||||
do {
|
do {
|
||||||
|
if (!isset($encoded[$encoded_pos])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$temp = ord($encoded[$encoded_pos++]);
|
$temp = ord($encoded[$encoded_pos++]);
|
||||||
$startOffset++;
|
$startOffset++;
|
||||||
$loop = $temp >> 7;
|
$loop = $temp >> 7;
|
||||||
@ -260,6 +266,9 @@ class ASN1
|
|||||||
$start+= $startOffset;
|
$start+= $startOffset;
|
||||||
|
|
||||||
// Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13
|
// Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13
|
||||||
|
if (!isset($encoded[$encoded_pos])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$length = ord($encoded[$encoded_pos++]);
|
$length = ord($encoded[$encoded_pos++]);
|
||||||
$start++;
|
$start++;
|
||||||
if ($length == 0x80) { // indefinite length
|
if ($length == 0x80) { // indefinite length
|
||||||
|
@ -1622,7 +1622,6 @@ class X509
|
|||||||
$id = $extensions[$i]['extnId'];
|
$id = $extensions[$i]['extnId'];
|
||||||
$value = &$extensions[$i]['extnValue'];
|
$value = &$extensions[$i]['extnValue'];
|
||||||
$value = base64_decode($value);
|
$value = base64_decode($value);
|
||||||
$decoded = $asn1->decodeBER($value);
|
|
||||||
/* [extnValue] contains the DER encoding of an ASN.1 value
|
/* [extnValue] contains the DER encoding of an ASN.1 value
|
||||||
corresponding to the extension type identified by extnID */
|
corresponding to the extension type identified by extnID */
|
||||||
$map = $this->_getMapping($id);
|
$map = $this->_getMapping($id);
|
||||||
@ -1630,6 +1629,7 @@ class X509
|
|||||||
$decoder = $id == 'id-ce-nameConstraints' ?
|
$decoder = $id == 'id-ce-nameConstraints' ?
|
||||||
array($this, '_decodeNameConstraintIP') :
|
array($this, '_decodeNameConstraintIP') :
|
||||||
array($this, '_decodeIP');
|
array($this, '_decodeIP');
|
||||||
|
$decoded = $asn1->decodeBER($value);
|
||||||
$mapped = $asn1->asn1map($decoded[0], $map, array('iPAddress' => $decoder));
|
$mapped = $asn1->asn1map($decoded[0], $map, array('iPAddress' => $decoder));
|
||||||
$value = $mapped === false ? $decoded[0] : $mapped;
|
$value = $mapped === false ? $decoded[0] : $mapped;
|
||||||
|
|
||||||
|
@ -926,4 +926,38 @@ qzFkAKWjJj4KjfrbZX4C0Spfxw==
|
|||||||
|
|
||||||
$this->assertIsArray($r);
|
$this->assertIsArray($r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group github1676
|
||||||
|
*/
|
||||||
|
public function testMalformedExt()
|
||||||
|
{
|
||||||
|
$a = '-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDtjCCAmmgAwIBAgIUOynecffcNv1/7oqCfu98x899PhwwQgYJKoZIhvcNAQEK
|
||||||
|
MDWgDTALBglghkgBZQMEAgGhGjAYBgkqhkiG9w0BAQgwCwYJYIZIAWUDBAIBogMC
|
||||||
|
ASCjAwIBATAcMRowGAYDVQQKDBFwaHBzZWNsaWIgQ0EgY2VydDAeFw0yMTA2MjUw
|
||||||
|
MTQ1MjlaFw0yMjA2MjUwMTQ1MjlaMBwxGjAYBgNVBAoMEXBocHNlY2xpYiBDQSBj
|
||||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RzpLgDCq3kpbaw6KvFzH9lfPP
|
||||||
|
BbNA6tFZAwLoX18R6yEmzHAQ+R2Eliiaz7mgQ+M2d0ec6qQJFoO7aJsX
|
||||||
|
-----END CERTIFICATE-----';
|
||||||
|
|
||||||
|
$x509 = new File_X509();
|
||||||
|
$r = $x509->loadX509($a);
|
||||||
|
|
||||||
|
$this->assertIsArray($r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user