From a3e3682feb24c64d02a0b89fa41f90608027f2a2 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 23 Mar 2013 12:12:29 -0500 Subject: [PATCH] ASN.1: Add headerlength and fix start --- phpseclib/File/ASN1.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 49a25e4c..6bc1e93d 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -319,8 +319,12 @@ class File_ASN1 { // support it up to four. $length&= 0x7F; $temp = $this->_string_shift($encoded, $length); + // tags of indefinte length don't really have a header length; this length includes the tag + $current+= array('headerlength' => $length + 2); $start+= $length; extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4))); + } else { + $current+= array('headerlength' => 2); } // End-of-content, see paragraphs 8.1.1.3, 8.1.3.2, 8.1.3.6, 8.1.5, and (for an example) 8.6.4.2 @@ -349,6 +353,7 @@ class File_ASN1 { 'content' => $constructed ? $this->_decode_ber($content, $start) : $content, 'length' => $length + $start - $current['start'] ) + $current; + $start+= $length; continue 2; }