mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-26 03:27:31 +00:00
Merge branch '1.0' into 2.0
This commit is contained in:
commit
bbc651f0b6
@ -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) {
|
||||
|
@ -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(
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user