mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-25 03:16:02 +00:00
Namespaced classes
This commit is contained in:
parent
651b6346a3
commit
cea5e317b6
@ -8,24 +8,26 @@
|
|||||||
* If you call read() in Net_SSH2 you may get {@link http://en.wikipedia.org/wiki/ANSI_escape_code ANSI escape codes} back.
|
* If you call read() in Net_SSH2 you may get {@link http://en.wikipedia.org/wiki/ANSI_escape_code ANSI escape codes} back.
|
||||||
* They'd look like chr(0x1B) . '[00m' or whatever (0x1B = ESC). They tell a
|
* They'd look like chr(0x1B) . '[00m' or whatever (0x1B = ESC). They tell a
|
||||||
* {@link http://en.wikipedia.org/wiki/Terminal_emulator terminal emulator} how to format the characters, what
|
* {@link http://en.wikipedia.org/wiki/Terminal_emulator terminal emulator} how to format the characters, what
|
||||||
* color to display them in, etc. File_ANSI is a {@link http://en.wikipedia.org/wiki/VT100 VT100} terminal emulator.
|
* color to display them in, etc. \phpseclib\File\ANSI is a {@link http://en.wikipedia.org/wiki/VT100 VT100} terminal emulator.
|
||||||
*
|
*
|
||||||
* @category File
|
* @category File
|
||||||
* @package File_ANSI
|
* @package ANSI
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @copyright MMXII Jim Wigginton
|
* @copyright MMXII Jim Wigginton
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace phpseclib\File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pure-PHP ANSI Decoder
|
* Pure-PHP ANSI Decoder
|
||||||
*
|
*
|
||||||
* @package File_ANSI
|
* @package ANSI
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
class File_ANSI
|
class ANSI
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Max Width
|
* Max Width
|
||||||
@ -190,7 +192,7 @@ class File_ANSI
|
|||||||
/**
|
/**
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
*
|
*
|
||||||
* @return File_ANSI
|
* @return \phpseclib\File\ANSI
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function __construct()
|
function __construct()
|
||||||
|
@ -9,35 +9,31 @@
|
|||||||
* utilized scheme is DER or the "Distinguished Encoding Rules". PEM's are base64 encoded
|
* utilized scheme is DER or the "Distinguished Encoding Rules". PEM's are base64 encoded
|
||||||
* DER blobs.
|
* DER blobs.
|
||||||
*
|
*
|
||||||
* File_ASN1 decodes and encodes DER formatted messages and places them in a semantic context.
|
* \phpseclib\File\ASN1 decodes and encodes DER formatted messages and places them in a semantic context.
|
||||||
*
|
*
|
||||||
* Uses the 1988 ASN.1 syntax.
|
* Uses the 1988 ASN.1 syntax.
|
||||||
*
|
*
|
||||||
* @category File
|
* @category File
|
||||||
* @package File_ASN1
|
* @package ASN1
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @copyright MMXII Jim Wigginton
|
* @copyright MMXII Jim Wigginton
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \phpseclib\Math\BigInteger;
|
namespace phpseclib\File;
|
||||||
|
|
||||||
/**
|
use phpseclib\File\ASN1\Element;
|
||||||
* Include File_ASN1_Element
|
use phpseclib\Math\BigInteger;
|
||||||
*/
|
|
||||||
if (!class_exists('File_ASN1_Element')) {
|
|
||||||
include_once 'ASN1/Element.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pure-PHP ASN.1 Parser
|
* Pure-PHP ASN.1 Parser
|
||||||
*
|
*
|
||||||
* @package File_ASN1
|
* @package ASN1
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
class File_ASN1
|
class ASN1
|
||||||
{
|
{
|
||||||
/**#@+
|
/**#@+
|
||||||
* Tag Classes
|
* Tag Classes
|
||||||
@ -128,8 +124,8 @@ class File_ASN1
|
|||||||
*
|
*
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
* @see File_ASN1::setTimeFormat()
|
* @see \phpseclib\File\ASN1::setTimeFormat()
|
||||||
* @see File_ASN1::asn1map()
|
* @see \phpseclib\File\ASN1::asn1map()
|
||||||
* @link http://php.net/class.datetime
|
* @link http://php.net/class.datetime
|
||||||
*/
|
*/
|
||||||
var $encoded;
|
var $encoded;
|
||||||
@ -141,14 +137,14 @@ class File_ASN1
|
|||||||
*
|
*
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
* @see File_ASN1::_encode_der()
|
* @see \phpseclib\File\ASN1::_encode_der()
|
||||||
*/
|
*/
|
||||||
var $filters;
|
var $filters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type mapping table for the ANY type.
|
* Type mapping table for the ANY type.
|
||||||
*
|
*
|
||||||
* Structured or unknown types are mapped to a File_ASN1_Element.
|
* Structured or unknown types are mapped to a \phpseclib\File\ASN1\Element.
|
||||||
* Unambiguous types get the direct mapping (int/real/bool).
|
* Unambiguous types get the direct mapping (int/real/bool).
|
||||||
* Others are mapped as a choice, with an extra indexing level.
|
* Others are mapped as a choice, with an extra indexing level.
|
||||||
*
|
*
|
||||||
@ -484,7 +480,7 @@ class File_ASN1
|
|||||||
case $mapping['type'] == self::TYPE_ANY:
|
case $mapping['type'] == self::TYPE_ANY:
|
||||||
$intype = $decoded['type'];
|
$intype = $decoded['type'];
|
||||||
if (isset($decoded['constant']) || !isset($this->ANYmap[$intype]) || ($this->encoded[$decoded['start']] & 0x20)) {
|
if (isset($decoded['constant']) || !isset($this->ANYmap[$intype]) || ($this->encoded[$decoded['start']] & 0x20)) {
|
||||||
return new File_ASN1_Element(substr($this->encoded, $decoded['start'], $decoded['length']));
|
return new Element(substr($this->encoded, $decoded['start'], $decoded['length']));
|
||||||
}
|
}
|
||||||
$inmap = $this->ANYmap[$intype];
|
$inmap = $this->ANYmap[$intype];
|
||||||
if (is_string($inmap)) {
|
if (is_string($inmap)) {
|
||||||
@ -1166,7 +1162,7 @@ class File_ASN1
|
|||||||
/**
|
/**
|
||||||
* Load filters
|
* Load filters
|
||||||
*
|
*
|
||||||
* See File_X509, etc, for an example.
|
* See \phpseclib\File\X509, etc, for an example.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param Array $filters
|
* @param Array $filters
|
||||||
|
@ -5,23 +5,25 @@
|
|||||||
* PHP versions 4 and 5
|
* PHP versions 4 and 5
|
||||||
*
|
*
|
||||||
* @category File
|
* @category File
|
||||||
* @package File_ASN1
|
* @package ASN1
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @copyright MMXII Jim Wigginton
|
* @copyright MMXII Jim Wigginton
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace phpseclib\File\ASN1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ASN.1 Element
|
* ASN.1 Element
|
||||||
*
|
*
|
||||||
* Bypass normal encoding rules in File_ASN1::encodeDER()
|
* Bypass normal encoding rules in phpseclib\File\ASN1::encodeDER()
|
||||||
*
|
*
|
||||||
* @package File_ASN1
|
* @package ASN1
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
class File_ASN1_Element
|
class Element
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Raw element value
|
* Raw element value
|
||||||
@ -35,7 +37,7 @@ class File_ASN1_Element
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param String $encoded
|
* @param String $encoded
|
||||||
* @return File_ASN1_Element
|
* @return \phpseclib\File\ASN1\Element
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function __construct($encoded)
|
function __construct($encoded)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -5,59 +5,59 @@
|
|||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once 'File/ASN1.php';
|
use phpseclib\File\ASN1;
|
||||||
|
|
||||||
class Unit_File_ASN1Test extends PhpseclibTestCase
|
class Unit_File_ASN1Test extends PhpseclibTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* on older versions of File_ASN1 this would yield a PHP Warning
|
* on older versions of \phpseclib\File\ASN1 this would yield a PHP Warning
|
||||||
* @group github275
|
* @group github275
|
||||||
*/
|
*/
|
||||||
public function testAnyString()
|
public function testAnyString()
|
||||||
{
|
{
|
||||||
$KDC_REP = array(
|
$KDC_REP = array(
|
||||||
'type' => File_ASN1::TYPE_SEQUENCE,
|
'type' => ASN1::TYPE_SEQUENCE,
|
||||||
'children' => array(
|
'children' => array(
|
||||||
'pvno' => array(
|
'pvno' => array(
|
||||||
'constant' => 0,
|
'constant' => 0,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_ANY),
|
'type' => ASN1::TYPE_ANY),
|
||||||
'msg-type' => array(
|
'msg-type' => array(
|
||||||
'constant' => 1,
|
'constant' => 1,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_ANY),
|
'type' => ASN1::TYPE_ANY),
|
||||||
'padata' => array(
|
'padata' => array(
|
||||||
'constant' => 2,
|
'constant' => 2,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_ANY),
|
'type' => ASN1::TYPE_ANY),
|
||||||
'crealm' => array(
|
'crealm' => array(
|
||||||
'constant' => 3,
|
'constant' => 3,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_ANY),
|
'type' => ASN1::TYPE_ANY),
|
||||||
'cname' => array(
|
'cname' => array(
|
||||||
'constant' => 4,
|
'constant' => 4,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_ANY),
|
'type' => ASN1::TYPE_ANY),
|
||||||
'ticket' => array(
|
'ticket' => array(
|
||||||
'constant' => 5,
|
'constant' => 5,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_ANY),
|
'type' => ASN1::TYPE_ANY),
|
||||||
'enc-part' => array(
|
'enc-part' => array(
|
||||||
'constant' => 6,
|
'constant' => 6,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_ANY)
|
'type' => ASN1::TYPE_ANY)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$AS_REP = array(
|
$AS_REP = array(
|
||||||
'class' => File_ASN1::CLASS_APPLICATION,
|
'class' => ASN1::CLASS_APPLICATION,
|
||||||
'cast' => 11,
|
'cast' => 11,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true
|
'explicit' => true
|
||||||
@ -75,7 +75,7 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
|
|||||||
'4P3wep6uNMLnLzXJmUaAMaopjE+MOcai/t6T9Vg4pERF5Waqwg5ibAbVGK19HuS4LiKiaY3JsyYBuNkEDwiqM7i1Ekw3V+' .
|
'4P3wep6uNMLnLzXJmUaAMaopjE+MOcai/t6T9Vg4pERF5Waqwg5ibAbVGK19HuS4LiKiaY3JsyYBuNkEDwiqM7i1Ekw3V+' .
|
||||||
'+zoEIxqgXjGgPdrWkzU/H6rnXiqMtiZZqUXwWY0zkCmy';
|
'+zoEIxqgXjGgPdrWkzU/H6rnXiqMtiZZqUXwWY0zkCmy';
|
||||||
|
|
||||||
$asn1 = new File_ASN1();
|
$asn1 = new ASN1();
|
||||||
$decoded = $asn1->decodeBER(base64_decode($str));
|
$decoded = $asn1->decodeBER(base64_decode($str));
|
||||||
$result = $asn1->asn1map($decoded[0], $AS_REP);
|
$result = $asn1->asn1map($decoded[0], $AS_REP);
|
||||||
|
|
||||||
@ -83,37 +83,37 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* on older versions of File_ASN1 this would produce a null instead of an array
|
* on older versions of \phpseclib\File\ASN1 this would produce a null instead of an array
|
||||||
* @group github275
|
* @group github275
|
||||||
*/
|
*/
|
||||||
public function testIncorrectString()
|
public function testIncorrectString()
|
||||||
{
|
{
|
||||||
$PA_DATA = array(
|
$PA_DATA = array(
|
||||||
'type' => File_ASN1::TYPE_SEQUENCE,
|
'type' => ASN1::TYPE_SEQUENCE,
|
||||||
'children' => array(
|
'children' => array(
|
||||||
'padata-type' => array(
|
'padata-type' => array(
|
||||||
'constant' => 1,
|
'constant' => 1,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_INTEGER
|
'type' => ASN1::TYPE_INTEGER
|
||||||
),
|
),
|
||||||
'padata-value' => array(
|
'padata-value' => array(
|
||||||
'constant' => 2,
|
'constant' => 2,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_OCTET_STRING
|
'type' => ASN1::TYPE_OCTET_STRING
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$PrincipalName = array(
|
$PrincipalName = array(
|
||||||
'type' => File_ASN1::TYPE_SEQUENCE,
|
'type' => ASN1::TYPE_SEQUENCE,
|
||||||
'children' => array(
|
'children' => array(
|
||||||
'name-type' => array(
|
'name-type' => array(
|
||||||
'constant' => 0,
|
'constant' => 0,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_INTEGER
|
'type' => ASN1::TYPE_INTEGER
|
||||||
),
|
),
|
||||||
'name-string' => array(
|
'name-string' => array(
|
||||||
'constant' => 1,
|
'constant' => 1,
|
||||||
@ -121,95 +121,95 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
|
|||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'min' => 0,
|
'min' => 0,
|
||||||
'max' => -1,
|
'max' => -1,
|
||||||
'type' => File_ASN1::TYPE_SEQUENCE,
|
'type' => ASN1::TYPE_SEQUENCE,
|
||||||
'children' => array('type' => File_ASN1::TYPE_IA5_STRING) // should be File_ASN1::TYPE_GENERAL_STRING
|
'children' => array('type' => ASN1::TYPE_IA5_STRING) // should be \phpseclib\File\ASN1::TYPE_GENERAL_STRING
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$Ticket = array(
|
$Ticket = array(
|
||||||
'class' => File_ASN1::CLASS_APPLICATION,
|
'class' => ASN1::CLASS_APPLICATION,
|
||||||
'cast' => 1,
|
'cast' => 1,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_SEQUENCE,
|
'type' => ASN1::TYPE_SEQUENCE,
|
||||||
'children' => array(
|
'children' => array(
|
||||||
'tkt-vno' => array(
|
'tkt-vno' => array(
|
||||||
'constant' => 0,
|
'constant' => 0,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_INTEGER
|
'type' => ASN1::TYPE_INTEGER
|
||||||
),
|
),
|
||||||
'realm' => array(
|
'realm' => array(
|
||||||
'constant' => 1,
|
'constant' => 1,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_ANY
|
'type' => ASN1::TYPE_ANY
|
||||||
),
|
),
|
||||||
'sname' => array(
|
'sname' => array(
|
||||||
'constant' => 2,
|
'constant' => 2,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_ANY
|
'type' => ASN1::TYPE_ANY
|
||||||
),
|
),
|
||||||
'enc-part' => array(
|
'enc-part' => array(
|
||||||
'constant' => 3,
|
'constant' => 3,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_ANY
|
'type' => ASN1::TYPE_ANY
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$KDC_REP = array(
|
$KDC_REP = array(
|
||||||
'type' => File_ASN1::TYPE_SEQUENCE,
|
'type' => ASN1::TYPE_SEQUENCE,
|
||||||
'children' => array(
|
'children' => array(
|
||||||
'pvno' => array(
|
'pvno' => array(
|
||||||
'constant' => 0,
|
'constant' => 0,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_INTEGER),
|
'type' => ASN1::TYPE_INTEGER),
|
||||||
'msg-type' => array(
|
'msg-type' => array(
|
||||||
'constant' => 1,
|
'constant' => 1,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_INTEGER),
|
'type' => ASN1::TYPE_INTEGER),
|
||||||
'padata' => array(
|
'padata' => array(
|
||||||
'constant' => 2,
|
'constant' => 2,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'min' => 0,
|
'min' => 0,
|
||||||
'max' => -1,
|
'max' => -1,
|
||||||
'type' => File_ASN1::TYPE_SEQUENCE,
|
'type' => ASN1::TYPE_SEQUENCE,
|
||||||
'children' => $PA_DATA),
|
'children' => $PA_DATA),
|
||||||
'crealm' => array(
|
'crealm' => array(
|
||||||
'constant' => 3,
|
'constant' => 3,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_OCTET_STRING),
|
'type' => ASN1::TYPE_OCTET_STRING),
|
||||||
'cname' => array(
|
'cname' => array(
|
||||||
'constant' => 4,
|
'constant' => 4,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true) + $PrincipalName,
|
'explicit' => true) + $PrincipalName,
|
||||||
//'type' => File_ASN1::TYPE_ANY),
|
//'type' => ASN1::TYPE_ANY),
|
||||||
'ticket' => array(
|
'ticket' => array(
|
||||||
'constant' => 5,
|
'constant' => 5,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'implicit' => true,
|
'implicit' => true,
|
||||||
'min' => 0,
|
'min' => 0,
|
||||||
'max' => 1,
|
'max' => 1,
|
||||||
'type' => File_ASN1::TYPE_SEQUENCE,
|
'type' => ASN1::TYPE_SEQUENCE,
|
||||||
'children' => $Ticket),
|
'children' => $Ticket),
|
||||||
'enc-part' => array(
|
'enc-part' => array(
|
||||||
'constant' => 6,
|
'constant' => 6,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true,
|
'explicit' => true,
|
||||||
'type' => File_ASN1::TYPE_ANY)
|
'type' => ASN1::TYPE_ANY)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$AS_REP = array(
|
$AS_REP = array(
|
||||||
'class' => File_ASN1::CLASS_APPLICATION,
|
'class' => ASN1::CLASS_APPLICATION,
|
||||||
'cast' => 11,
|
'cast' => 11,
|
||||||
'optional' => true,
|
'optional' => true,
|
||||||
'explicit' => true
|
'explicit' => true
|
||||||
@ -227,7 +227,7 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
|
|||||||
'4P3wep6uNMLnLzXJmUaAMaopjE+MOcai/t6T9Vg4pERF5Waqwg5ibAbVGK19HuS4LiKiaY3JsyYBuNkEDwiqM7i1Ekw3V+' .
|
'4P3wep6uNMLnLzXJmUaAMaopjE+MOcai/t6T9Vg4pERF5Waqwg5ibAbVGK19HuS4LiKiaY3JsyYBuNkEDwiqM7i1Ekw3V+' .
|
||||||
'+zoEIxqgXjGgPdrWkzU/H6rnXiqMtiZZqUXwWY0zkCmy';
|
'+zoEIxqgXjGgPdrWkzU/H6rnXiqMtiZZqUXwWY0zkCmy';
|
||||||
|
|
||||||
$asn1 = new File_ASN1();
|
$asn1 = new ASN1();
|
||||||
$decoded = $asn1->decodeBER(base64_decode($str));
|
$decoded = $asn1->decodeBER(base64_decode($str));
|
||||||
$result = $asn1->asn1map($decoded[0], $AS_REP);
|
$result = $asn1->asn1map($decoded[0], $AS_REP);
|
||||||
|
|
||||||
@ -235,11 +235,11 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* older versions of File_ASN1 didn't handle indefinite length tags very well
|
* older versions of ASN1 didn't handle indefinite length tags very well
|
||||||
*/
|
*/
|
||||||
public function testIndefiniteLength()
|
public function testIndefiniteLength()
|
||||||
{
|
{
|
||||||
$asn1 = new File_ASN1();
|
$asn1 = new ASN1();
|
||||||
$decoded = $asn1->decodeBER(file_get_contents(dirname(__FILE__) . '/ASN1/FE.pdf.p7m'));
|
$decoded = $asn1->decodeBER(file_get_contents(dirname(__FILE__) . '/ASN1/FE.pdf.p7m'));
|
||||||
$this->assertCount(5, $decoded[0]['content'][1]['content'][0]['content']); // older versions would have returned 3
|
$this->assertCount(5, $decoded[0]['content'][1]['content'][0]['content']); // older versions would have returned 3
|
||||||
}
|
}
|
||||||
@ -264,7 +264,7 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
|
|||||||
'AAOBgQAhrNWuyjSJWsKrUtKyNGadeqvu5nzVfsJcKLt0AMkQH0IT/GmKHiSgAgDp' .
|
'AAOBgQAhrNWuyjSJWsKrUtKyNGadeqvu5nzVfsJcKLt0AMkQH0IT/GmKHiSgAgDp' .
|
||||||
'ulvKGQSy068Bsn5fFNum21K5mvMSf3yinDtvmX3qUA12IxL/92ZzKbeVCq3Yi7Le' .
|
'ulvKGQSy068Bsn5fFNum21K5mvMSf3yinDtvmX3qUA12IxL/92ZzKbeVCq3Yi7Le' .
|
||||||
'IOkKcGQRCMha8X2e7GmlpdWC1ycenlbN0nbVeSv3JUMcafC4+Q==';
|
'IOkKcGQRCMha8X2e7GmlpdWC1ycenlbN0nbVeSv3JUMcafC4+Q==';
|
||||||
$asn1 = new File_ASN1();
|
$asn1 = new ASN1();
|
||||||
$decoded = $asn1->decodeBER(base64_decode($str));
|
$decoded = $asn1->decodeBER(base64_decode($str));
|
||||||
$this->assertCount(3, $decoded[0]['content']);
|
$this->assertCount(3, $decoded[0]['content']);
|
||||||
}
|
}
|
||||||
@ -274,7 +274,7 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
|
|||||||
*/
|
*/
|
||||||
public function testContextSpecificNonConstructed()
|
public function testContextSpecificNonConstructed()
|
||||||
{
|
{
|
||||||
$asn1 = new File_ASN1();
|
$asn1 = new ASN1();
|
||||||
$decoded = $asn1->decodeBER(base64_decode('MBaAFJtUo7c00HsI5EPZ4bkICfkOY2Pv'));
|
$decoded = $asn1->decodeBER(base64_decode('MBaAFJtUo7c00HsI5EPZ4bkICfkOY2Pv'));
|
||||||
$this->assertInternalType('string', $decoded[0]['content'][0]['content']);
|
$this->assertInternalType('string', $decoded[0]['content'][0]['content']);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once 'File/X509.php';
|
use phpseclib\File\X509;
|
||||||
|
|
||||||
require_once 'Crypt/RSA.php';
|
require_once 'Crypt/RSA.php';
|
||||||
|
|
||||||
class Unit_File_X509_SPKACTest extends PhpseclibTestCase
|
class Unit_File_X509_SPKACTest extends PhpseclibTestCase
|
||||||
@ -24,7 +25,7 @@ class Unit_File_X509_SPKACTest extends PhpseclibTestCase
|
|||||||
'dmeL7aWrpP+3x3L0A9cATksracQX676XogdAEXJ59fcr/S5AGw1TFErbyBbfyeAWvzDZIXeMXpb9h' .
|
'dmeL7aWrpP+3x3L0A9cATksracQX676XogdAEXJ59fcr/S5AGw1TFErbyBbfyeAWvzDZIXeMXpb9h' .
|
||||||
'yNtA==';
|
'yNtA==';
|
||||||
|
|
||||||
$x509 = new File_X509();
|
$x509 = new X509();
|
||||||
|
|
||||||
$spkac = $x509->loadSPKAC($test);
|
$spkac = $x509->loadSPKAC($test);
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ class Unit_File_X509_SPKACTest extends PhpseclibTestCase
|
|||||||
extract($privKey->createKey());
|
extract($privKey->createKey());
|
||||||
$privKey->loadKey($privatekey);
|
$privKey->loadKey($privatekey);
|
||||||
|
|
||||||
$x509 = new File_X509();
|
$x509 = new X509();
|
||||||
$x509->setPrivateKey($privKey);
|
$x509->setPrivateKey($privKey);
|
||||||
$x509->setChallenge('...');
|
$x509->setChallenge('...');
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ class Unit_File_X509_SPKACTest extends PhpseclibTestCase
|
|||||||
|
|
||||||
$this->assertInternalType('string', $x509->saveSPKAC($spkac));
|
$this->assertInternalType('string', $x509->saveSPKAC($spkac));
|
||||||
|
|
||||||
$x509 = new File_X509();
|
$x509 = new X509();
|
||||||
$x509->setPrivateKey($privKey);
|
$x509->setPrivateKey($privKey);
|
||||||
|
|
||||||
$spkac = $x509->signSPKAC();
|
$spkac = $x509->signSPKAC();
|
||||||
@ -82,7 +83,7 @@ class Unit_File_X509_SPKACTest extends PhpseclibTestCase
|
|||||||
'dmeL7aWrpP+3x3L0A9cATksracQX676XogdAEXJ59fcr/S5AGw1TFErbyBbfyeAWvzDZIXeMXpb9h' .
|
'dmeL7aWrpP+3x3L0A9cATksracQX676XogdAEXJ59fcr/S5AGw1TFErbyBbfyeAWvzDZIXeMXpb9h' .
|
||||||
'yNtA==';
|
'yNtA==';
|
||||||
|
|
||||||
$x509 = new File_X509();
|
$x509 = new X509();
|
||||||
|
|
||||||
$spkac = $x509->loadSPKAC($test);
|
$spkac = $x509->loadSPKAC($test);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user