From d3a5398fe4a84ab3dd6f36e2bdee7c6ab1534f05 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Wed, 3 Jun 2015 23:48:43 -0500 Subject: [PATCH] ASN1: constructed context-specific tags can have x sub elements previously it only worked for when there was one sub element. --- phpseclib/File/ASN1.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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(