Merge branch '1.0' into 2.0

This commit is contained in:
terrafrost 2018-04-15 10:27:46 -05:00
commit bbc651f0b6
3 changed files with 35 additions and 3 deletions

View File

@ -582,7 +582,7 @@ class ASN1
$childClass = $tempClass = self::CLASS_UNIVERSAL;
$constant = null;
if (isset($temp['constant'])) {
$tempClass = isset($temp['class']) ? $temp['class'] : self::CLASS_CONTEXT_SPECIFIC;
$tempClass = $temp['type'];
}
if (isset($child['class'])) {
$childClass = $child['class'];
@ -645,7 +645,7 @@ class ASN1
$temp = $decoded['content'][$i];
$tempClass = self::CLASS_UNIVERSAL;
if (isset($temp['constant'])) {
$tempClass = isset($temp['class']) ? $temp['class'] : self::CLASS_CONTEXT_SPECIFIC;
$tempClass = $temp['type'];
}
foreach ($mapping['children'] as $key => $child) {

View File

@ -3628,7 +3628,7 @@ class X509
'tbsCertificate' =>
array(
'version' => 'v3',
'serialNumber' => $serialNumber, // $this->setserialNumber()
'serialNumber' => $serialNumber, // $this->setSerialNumber()
'signature' => array('algorithm' => $signatureAlgorithm),
'issuer' => false, // this is going to be overwritten later
'validity' => array(

View File

@ -299,4 +299,36 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
$data = base64_decode('MD6gJQYKKwYBBAGCNxQCA6AXDBVvZmZpY2VAY2VydGRpZ2l0YWwucm+BFW9mZmljZUBjZXJ0ZGlnaXRhbC5ybw==');
$asn1->decodeBER($data);
}
public function testApplicationTag()
{
$map = array(
'type' => ASN1::TYPE_SEQUENCE,
'children' => array(
// technically, default implies optional, but we'll define it as being optional, none-the-less, just to
// reenforce that fact
'version' => array(
// if class isn't present it's assumed to be ASN1::CLASS_UNIVERSAL or
// (if constant is present) ASN1::CLASS_CONTEXT_SPECIFIC
'class' => ASN1::CLASS_APPLICATION,
'cast' => 2,
'optional' => true,
'explicit' => true,
'default' => 'v1',
'type' => ASN1::TYPE_INTEGER,
'mapping' => array('v1', 'v2', 'v3')
)
)
);
$data = array('version' => 'v3');
$asn1 = new ASN1();
$str = $asn1->encodeDER($data, $map);
$decoded = $asn1->decodeBER($str);
$arr = $asn1->asn1map($decoded[0], $map);
$this->assertSame($data, $arr);
}
}