An X.509 certificate contains data from several sections (called triple Tag-Length-Value tags). Each section begins with a tag byte, which indicates the format of the section data. You can see a list of these data types here .
0x03 - BIT STRING 0x30 SEQUENCE.
, BIT STRING SEQUENCE. :
if($seq == 0x03)
{
return substr($bin,3 + $bytes, $len);
}
else // $seq == 0x30
{
$bin = substr($bin,2 + $bytes + $len);
}
, (0x30), - (0x03), .
, , 3 - 2 . , - , , . (, 13 , 2 = 16 , " " 3.)
: . 128 , ( 0). 128 , 7, 7 , ( ). . :
$len = ord($bin[1]);
$bytes = 0;
if ($len & 0x80)
{
// length is greater than 127!
$bytes = ($len & 0x0f);
$len = 0;
for ($i = 0; $i < $bytes; $i++)
{
$len = ($len << 8) | ord($bin[$i + 2]);
}
}
$bytes , , $len Value ( ).
? ,
128 , 7 set, 7 , .
$bytes = ($len & 0x0f), 4 ! :
$bytes = ($len & 0x7f);
, : , 0x0f = 15 , 256 ^ 15 . , .