diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 1d66793a..6b3cc463 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -357,14 +357,21 @@ class File_ASN1 } $newcontent = array(); - if (strlen($content)) { - $newcontent = $this->_decode_ber($content, $start); - $length = $newcontent['length']; + $remainingLength = $length; + while ($remainingLength) { + $temp = $this->_decode_ber($content, $start); + $length = $temp['length']; + // end-of-content octets - see paragraph 8.1.5 if (substr($content, $length, 2) == "\0\0") { $length+= 2; + $start+= $length; + $newcontent[] = $temp; + break; } $start+= $length; - $newcontent = array($newcontent); + $remainingLength-= $length; + $newcontent[] = $temp; + $this->_string_shift($content, $length); } return array(