1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-13 09:37:37 +01:00

ASN1: make developing new ASN.1 scripts a little easier

This commit is contained in:
terrafrost 2014-04-10 13:49:28 -05:00
parent c8bf68ac02
commit 61cd5e4f5a

View File

@ -509,7 +509,7 @@ class File_ASN1
*/ */
function asn1map($decoded, $mapping, $special = array()) function asn1map($decoded, $mapping, $special = array())
{ {
if (isset($mapping['explicit'])) { if (isset($mapping['explicit']) && is_array($decoded['content'])) {
$decoded = $decoded['content'][0]; $decoded = $decoded['content'][0];
} }
@ -550,8 +550,16 @@ class File_ASN1
case $decoded['type'] == $mapping['type']: case $decoded['type'] == $mapping['type']:
break; break;
default: default:
// 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; return null;
} }
}
if (isset($mapping['implicit'])) { if (isset($mapping['implicit'])) {
$decoded['type'] = $mapping['type']; $decoded['type'] = $mapping['type'];