From 5a4595ab567fcbf96e28038808e0d67bc52e78f8 Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Sun, 13 May 2012 17:52:12 +0000 Subject: [PATCH] - 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 --- phpseclib/File/ASN1.php | 12 ++++-------- phpseclib/File/X509.php | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 56bf8787..f5a752c1 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -438,14 +438,15 @@ class File_ASN1 { */ function asn1map($decoded, $mapping, $idx = NULL) { + if (isset($mapping['explicit'])) { + $decoded = $decoded['content'][0]; + } + switch (true) { case $mapping['type'] == FILE_ASN1_TYPE_CHOICE: foreach ($mapping['children'] as $key => $option) { switch (true) { 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']: $value = $this->asn1map($decoded, $option); } @@ -463,10 +464,6 @@ class File_ASN1 { return NULL; } - if (isset($mapping['explicit'])) { - $decoded = $decoded['content'][0]; - } - if (isset($mapping['implicit'])) { $decoded['type'] = $mapping['type']; } @@ -1131,4 +1128,3 @@ class File_ASN1 { return $substr; } } - diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 12a079fa..57674516 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -660,7 +660,7 @@ class File_X509 { 'directoryName' => array( 'constant' => 4, 'optional' => true, - 'implicit' => true + 'explicit' => true ) + $Name, 'ediPartyName' => array( 'constant' => 5, @@ -734,7 +734,7 @@ class File_X509 { 'distributionPoint' => array( 'constant' => 0, 'optional' => true, - 'implicit' => true + 'explicit' => true ) + $DistributionPointName, 'reasons' => array( 'constant' => 1,