mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-09-28 07:09:01 +00:00
Merge branch '2.0'
This commit is contained in:
commit
28b26b50df
@ -608,7 +608,7 @@ abstract 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'];
|
||||
@ -678,7 +678,7 @@ abstract 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) {
|
||||
|
@ -2579,7 +2579,7 @@ class X509
|
||||
'tbsCertificate' =>
|
||||
[
|
||||
'version' => 'v3',
|
||||
'serialNumber' => $serialNumber, // $this->setserialNumber()
|
||||
'serialNumber' => $serialNumber, // $this->setSerialNumber()
|
||||
'signature' => ['algorithm' => $signatureAlgorithm],
|
||||
'issuer' => false, // this is going to be overwritten later
|
||||
'validity' => [
|
||||
|
@ -304,4 +304,35 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
|
||||
constant('phpseclib\\File\\ASN1\\Maps\\' . basename($file, '.php') . '::MAP');
|
||||
}
|
||||
}
|
||||
|
||||
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');
|
||||
|
||||
$str = ASN1::encodeDER($data, $map);
|
||||
|
||||
$decoded = ASN1::decodeBER($str);
|
||||
$arr = ASN1::asn1map($decoded[0], $map);
|
||||
|
||||
$this->assertSame($data, $arr);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user