mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-28 12:10:59 +00:00
ASN1: rm an alternative approach for dealing with ASN1\Element
This commit is contained in:
parent
4dc3b7ed43
commit
a4d05f8445
@ -234,32 +234,10 @@ class ASN1
|
||||
|
||||
$decoded = [self::_decode_ber($encoded)];
|
||||
|
||||
//self::_addEncodings($decoded[0], $encoded);
|
||||
|
||||
// encapsulate in an array for BC with the old decodeBER
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add encoded DER substrings to decoded array
|
||||
*
|
||||
* @param array $decoded
|
||||
* @param string $encoded
|
||||
* @return array
|
||||
* @access private
|
||||
*/
|
||||
static function _addEncodings(&$decoded, $encoded)
|
||||
{
|
||||
$decoded['encoded'] = substr($encoded, $decoded['start'], $decoded['length']);
|
||||
if (!is_array($decoded['content'])) {
|
||||
return $decoded;
|
||||
}
|
||||
for ($i = 0; $i < count($decoded['content']); $i++) {
|
||||
self::addEncodings($decoded['content'][$i], $encoded);
|
||||
}
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse BER-encoding (Helper function)
|
||||
*
|
||||
@ -548,9 +526,7 @@ class ASN1
|
||||
case $mapping['type'] == self::TYPE_ANY:
|
||||
$intype = $decoded['type'];
|
||||
// !isset(self::ANY_MAP[$intype]) produces a fatal error on PHP 5.6
|
||||
//if (isset($decoded['constant']) || !isset(self::ANY_MAP[$intype]) || (ord($decoded['encoded'][0]) & 0x20)) {
|
||||
if (isset($decoded['constant']) || !array_key_exists($intype, self::ANY_MAP) || (ord(self::$encoded[$decoded['start']]) & 0x20)) {
|
||||
//return new Element($decoded['encoded']);
|
||||
return new Element(substr(self::$encoded, $decoded['start'], $decoded['length']));
|
||||
}
|
||||
$inmap = self::ANY_MAP[$intype];
|
||||
|
Loading…
Reference in New Issue
Block a user