From 61cd5e4f5afbf651dfd9feb7d1fa25b9eb91b88e Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 10 Apr 2014 13:49:28 -0500 Subject: [PATCH] ASN1: make developing new ASN.1 scripts a little easier --- phpseclib/File/ASN1.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index fce33fbd..346a0aa0 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -509,7 +509,7 @@ class File_ASN1 */ function asn1map($decoded, $mapping, $special = array()) { - if (isset($mapping['explicit'])) { + if (isset($mapping['explicit']) && is_array($decoded['content'])) { $decoded = $decoded['content'][0]; } @@ -550,7 +550,15 @@ class File_ASN1 case $decoded['type'] == $mapping['type']: break; default: - return null; + // if $decoded['type'] and $mapping['type'] are both strings, but different types of strings, + // let it through + switch (true) { + case $decoded['type'] < 18: // FILE_ASN1_TYPE_NUMERIC_STRING == 18 + case $decoded['type'] > 30: // FILE_ASN1_TYPE_BMP_STRING == 30 + case $mapping['type'] < 18: + case $mapping['type'] > 30: + return null; + } } if (isset($mapping['implicit'])) {