ASN1: fix issue with non-constructed context-specific tags

This commit is contained in:
terrafrost 2014-09-22 01:01:34 -05:00
parent 5085202f1f
commit c6ad2b69ba

View File

@ -347,10 +347,15 @@ class File_ASN1
case FILE_ASN1_CLASS_APPLICATION: case FILE_ASN1_CLASS_APPLICATION:
case FILE_ASN1_CLASS_PRIVATE: case FILE_ASN1_CLASS_PRIVATE:
case FILE_ASN1_CLASS_CONTEXT_SPECIFIC: case FILE_ASN1_CLASS_CONTEXT_SPECIFIC:
$newcontent = $this->_decode_ber($content, $start); if ($constructed) {
$length = $newcontent['length']; $newcontent = $this->_decode_ber($content, $start);
if (substr($content, $length, 2) == "\0\0") { $length = $newcontent['length'];
$length+= 2; if (substr($content, $length, 2) == "\0\0") {
$length+= 2;
}
// the array encapsulation is for BC with the old format
$content = array($newcontent);
} }
$start+= $length; $start+= $length;
@ -359,7 +364,7 @@ class File_ASN1
'type' => $class, 'type' => $class,
'constant' => $tag, 'constant' => $tag,
// the array encapsulation is for BC with the old format // the array encapsulation is for BC with the old format
'content' => array($newcontent), 'content' => $content,
// the only time when $content['headerlength'] isn't defined is when the length is indefinite. // the only time when $content['headerlength'] isn't defined is when the length is indefinite.
// the absence of $content['headerlength'] is how we know if something is indefinite or not. // the absence of $content['headerlength'] is how we know if something is indefinite or not.
// technically, it could be defined to be 2 and then another indicator could be used but whatever. // technically, it could be defined to be 2 and then another indicator could be used but whatever.
@ -1343,4 +1348,4 @@ class File_ASN1
} }
return $out; return $out;
} }
} }