mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-26 00:28:27 +00:00
ASN1: tweaks to tag decoding
This commit is contained in:
parent
b90c33200e
commit
95f597cfb3
@ -317,7 +317,7 @@ class File_ASN1
|
|||||||
$current = array('start' => $start);
|
$current = array('start' => $start);
|
||||||
|
|
||||||
$type = ord($encoded[$encoded_pos++]);
|
$type = ord($encoded[$encoded_pos++]);
|
||||||
$start++;
|
$startOffset = 1;
|
||||||
|
|
||||||
$constructed = ($type >> 5) & 1;
|
$constructed = ($type >> 5) & 1;
|
||||||
|
|
||||||
@ -327,13 +327,20 @@ class File_ASN1
|
|||||||
// process septets (since the eighth bit is ignored, it's not an octet)
|
// process septets (since the eighth bit is ignored, it's not an octet)
|
||||||
do {
|
do {
|
||||||
$temp = ord($encoded[$encoded_pos++]);
|
$temp = ord($encoded[$encoded_pos++]);
|
||||||
|
$startOffset++;
|
||||||
$loop = $temp >> 7;
|
$loop = $temp >> 7;
|
||||||
$tag <<= 7;
|
$tag <<= 7;
|
||||||
$tag |= $temp & 0x7F;
|
$temp &= 0x7F;
|
||||||
$start++;
|
// "bits 7 to 1 of the first subsequent octet shall not all be zero"
|
||||||
|
if ($startOffset == 2 && $temp == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$tag |= $temp;
|
||||||
} while ($loop);
|
} while ($loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$start+= $startOffset;
|
||||||
|
|
||||||
// Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13
|
// Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13
|
||||||
$length = ord($encoded[$encoded_pos++]);
|
$length = ord($encoded[$encoded_pos++]);
|
||||||
$start++;
|
$start++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user