- when the child is an optional CHOICE it needs to be explicit and not implicit

- make asn1map more accurate

git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@219 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
Jim Wigginton 2012-05-13 17:52:12 +00:00
parent 5db0f88218
commit 5a4595ab56
2 changed files with 6 additions and 10 deletions

View File

@ -438,14 +438,15 @@ class File_ASN1 {
*/ */
function asn1map($decoded, $mapping, $idx = NULL) function asn1map($decoded, $mapping, $idx = NULL)
{ {
if (isset($mapping['explicit'])) {
$decoded = $decoded['content'][0];
}
switch (true) { switch (true) {
case $mapping['type'] == FILE_ASN1_TYPE_CHOICE: case $mapping['type'] == FILE_ASN1_TYPE_CHOICE:
foreach ($mapping['children'] as $key => $option) { foreach ($mapping['children'] as $key => $option) {
switch (true) { switch (true) {
case isset($option['constant']) && $option['constant'] == $decoded['constant']: case isset($option['constant']) && $option['constant'] == $decoded['constant']:
// $decoded['content'] is only an array if the type is constructed
$value = is_array($decoded['content']) ? $this->asn1map($decoded['content'][0], $option) : $this->asn1map($decoded, $option);
break;
case !isset($option['constant']) && $option['type'] == $decoded['type']: case !isset($option['constant']) && $option['type'] == $decoded['type']:
$value = $this->asn1map($decoded, $option); $value = $this->asn1map($decoded, $option);
} }
@ -463,10 +464,6 @@ class File_ASN1 {
return NULL; return NULL;
} }
if (isset($mapping['explicit'])) {
$decoded = $decoded['content'][0];
}
if (isset($mapping['implicit'])) { if (isset($mapping['implicit'])) {
$decoded['type'] = $mapping['type']; $decoded['type'] = $mapping['type'];
} }
@ -1131,4 +1128,3 @@ class File_ASN1 {
return $substr; return $substr;
} }
} }

View File

@ -660,7 +660,7 @@ class File_X509 {
'directoryName' => array( 'directoryName' => array(
'constant' => 4, 'constant' => 4,
'optional' => true, 'optional' => true,
'implicit' => true 'explicit' => true
) + $Name, ) + $Name,
'ediPartyName' => array( 'ediPartyName' => array(
'constant' => 5, 'constant' => 5,
@ -734,7 +734,7 @@ class File_X509 {
'distributionPoint' => array( 'distributionPoint' => array(
'constant' => 0, 'constant' => 0,
'optional' => true, 'optional' => true,
'implicit' => true 'explicit' => true
) + $DistributionPointName, ) + $DistributionPointName,
'reasons' => array( 'reasons' => array(
'constant' => 1, 'constant' => 1,