Merge branch '2.0'

This commit is contained in:
terrafrost 2019-08-02 23:41:40 -05:00
commit 2286c834bd
3 changed files with 71 additions and 1 deletions

View File

@ -739,7 +739,14 @@ abstract class ASN1
return isset(self::$oids[$decoded['content']]) ? self::$oids[$decoded['content']] : $decoded['content'];
case self::TYPE_UTC_TIME:
case self::TYPE_GENERALIZED_TIME:
if (isset($mapping['implicit'])) {
// for explicitly tagged optional stuff
if (is_array($decoded['content'])) {
$decoded['content'] = $decoded['content'][0]['content'];
}
// for implicitly tagged optional stuff
// in theory, doing isset($mapping['implicit']) would work but malformed certs do exist
// in the wild that OpenSSL decodes without issue so we'll support them as well
if (!is_object($decoded['content'])) {
$decoded['content'] = self::decodeTime($decoded['content'], $decoded['type']);
}
return $decoded['content'] ? $decoded['content']->format(self::$format) : false;

View File

@ -0,0 +1,35 @@
<?php
/**
* SubjectInfoAccessSyntax
*
* PHP version 5
*
* @category File
* @package ASN1
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2016 Jim Wigginton
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @link http://phpseclib.sourceforge.net
*/
namespace phpseclib\File\ASN1\Maps;
use phpseclib\File\ASN1;
/**
* SubjectInfoAccessSyntax
*
* @package ASN1
* @author Jim Wigginton <terrafrost@php.net>
* @access public
*/
abstract class SubjectInfoAccessSyntax
{
const MAP = [
'type' => ASN1::TYPE_SEQUENCE,
'min' => 1,
'max' => -1,
'children' => AccessDescription::MAP
];
}

View File

@ -364,4 +364,32 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
$this->assertSame(pack('H*', '6983f09da7ebcfdee0c7a1a7b2c0948cc8f9d776'), $new);
$this->assertSame($orig, ASN1::decodeOID($new));
}
/**
* @group github1388
*/
public function testExplicitImplicitDate()
{
$map = [
'type' => ASN1::TYPE_SEQUENCE,
'children' => [
'notBefore' => [
'constant' => 0,
'optional' => true,
'implicit' => true,
'type' => ASN1::TYPE_GENERALIZED_TIME],
'notAfter' => [
'constant' => 1,
'optional' => true,
'implicit' => true,
'type' => ASN1::TYPE_GENERALIZED_TIME]
]
];
$a = pack('H*', '3026a011180f32303137303432313039303535305aa111180f32303138303432313230353935395a');
$a = ASN1::decodeBER($a);
$a = ASN1::asn1map($a[0], $map);
$this->assertInternalType('array', $a);
}
}