mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-24 07:38:26 +00:00
ASN1: add unit tests for indefinite length decoding
This commit is contained in:
parent
3bb123c3d5
commit
871e1a3070
@ -233,4 +233,39 @@ class Unit_File_ASN1_DevTest extends PhpseclibTestCase
|
||||
|
||||
$this->assertInternalType('array', $result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* older versions of File_ASN1 didn't handle indefinite length tags very well
|
||||
*/
|
||||
public function testIndefiniteLength()
|
||||
{
|
||||
$asn1 = new File_ASN1();
|
||||
$decoded = $asn1->decodeBER(file_get_contents('tests/Unit/File/FE.pdf.p7m'));
|
||||
$this->assertEquals(count($decoded[0]['content'][1]['content'][0]['content']), 5); // older versions would have returned 3
|
||||
}
|
||||
|
||||
public function testDefiniteLength()
|
||||
{
|
||||
// the following base64-encoded string is the X.509 cert from <http://phpseclib.sourceforge.net/x509/decoder.php>
|
||||
$str = 'MIIDITCCAoqgAwIBAgIQT52W2WawmStUwpV8tBV9TTANBgkqhkiG9w0BAQUFADBM' .
|
||||
'MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg' .
|
||||
'THRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBDQTAeFw0xMTEwMjYwMDAwMDBaFw0x' .
|
||||
'MzA5MzAyMzU5NTlaMGgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh' .
|
||||
'MRYwFAYDVQQHFA1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKFApHb29nbGUgSW5jMRcw' .
|
||||
'FQYDVQQDFA53d3cuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC' .
|
||||
'gYEA3rcmQ6aZhc04pxUJuc8PycNVjIjujI0oJyRLKl6g2Bb6YRhLz21ggNM1QDJy' .
|
||||
'wI8S2OVOj7my9tkVXlqGMaO6hqpryNlxjMzNJxMenUJdOPanrO/6YvMYgdQkRn8B' .
|
||||
'd3zGKokUmbuYOR2oGfs5AER9G5RqeC1prcB6LPrQ2iASmNMCAwEAAaOB5zCB5DAM' .
|
||||
'BgNVHRMBAf8EAjAAMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly9jcmwudGhhd3Rl' .
|
||||
'LmNvbS9UaGF3dGVTR0NDQS5jcmwwKAYDVR0lBCEwHwYIKwYBBQUHAwEGCCsGAQUF' .
|
||||
'BwMCBglghkgBhvhCBAEwcgYIKwYBBQUHAQEEZjBkMCIGCCsGAQUFBzABhhZodHRw' .
|
||||
'Oi8vb2NzcC50aGF3dGUuY29tMD4GCCsGAQUFBzAChjJodHRwOi8vd3d3LnRoYXd0' .
|
||||
'ZS5jb20vcmVwb3NpdG9yeS9UaGF3dGVfU0dDX0NBLmNydDANBgkqhkiG9w0BAQUF' .
|
||||
'AAOBgQAhrNWuyjSJWsKrUtKyNGadeqvu5nzVfsJcKLt0AMkQH0IT/GmKHiSgAgDp' .
|
||||
'ulvKGQSy068Bsn5fFNum21K5mvMSf3yinDtvmX3qUA12IxL/92ZzKbeVCq3Yi7Le' .
|
||||
'IOkKcGQRCMha8X2e7GmlpdWC1ycenlbN0nbVeSv3JUMcafC4+Q==';
|
||||
$asn1 = new File_ASN1();
|
||||
$decoded = $asn1->decodeBER(base64_decode($str));
|
||||
$this->assertEquals(count($decoded[0]['content']), 3);
|
||||
}
|
||||
}
|
BIN
tests/Unit/File/FE.pdf.p7m
Normal file
BIN
tests/Unit/File/FE.pdf.p7m
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user