Merge branch 'master' into php5

* master:
  ASN1: fix unit test
  ASN1: add unit test for non-constructed context-specific change
  ASN1: fix issue with non-constructed context-specific tags
  README: update download link to 0.3.8
This commit is contained in:
Andreas Fischer 2014-09-24 16:50:12 +02:00
commit eff5f64560
3 changed files with 21 additions and 6 deletions

View File

@ -6,7 +6,7 @@ MIT-licensed pure-PHP implementations of an arbitrary-precision integer
arithmetic library, fully PKCS#1 (v2.1) compliant RSA, DES, 3DES, RC4, Rijndael,
AES, Blowfish, Twofish, SSH-1, SSH-2, SFTP, and X.509
* [Download (0.3.7)](http://sourceforge.net/projects/phpseclib/files/phpseclib0.3.7.zip/download)
* [Download (0.3.8)](http://sourceforge.net/projects/phpseclib/files/phpseclib0.3.8.zip/download)
* [Browse Git](https://github.com/phpseclib/phpseclib)
* [Code Coverage Report](http://phpseclib.bantux.org/code_coverage/php5/latest/)

View File

@ -333,10 +333,15 @@ class File_ASN1
case FILE_ASN1_CLASS_APPLICATION:
case FILE_ASN1_CLASS_PRIVATE:
case FILE_ASN1_CLASS_CONTEXT_SPECIFIC:
$newcontent = $this->_decode_ber($content, $start);
$length = $newcontent['length'];
if (substr($content, $length, 2) == "\0\0") {
$length+= 2;
if ($constructed) {
$newcontent = $this->_decode_ber($content, $start);
$length = $newcontent['length'];
if (substr($content, $length, 2) == "\0\0") {
$length+= 2;
}
// the array encapsulation is for BC with the old format
$content = array($newcontent);
}
$start+= $length;
@ -345,7 +350,7 @@ class File_ASN1
'type' => $class,
'constant' => $tag,
// 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 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.

View File

@ -268,4 +268,14 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
$decoded = $asn1->decodeBER(base64_decode($str));
$this->assertCount(3, $decoded[0]['content']);
}
/**
* @group github477
*/
public function testContextSpecificNonConstructed()
{
$asn1 = new File_ASN1();
$decoded = $asn1->decodeBER(base64_decode('MBaAFJtUo7c00HsI5EPZ4bkICfkOY2Pv'));
$this->assertInternalType('string', $decoded[0]['content'][0]['content']);
}
}