69 static function readDER($der, $offset, &$data, $ignore_bit_strings = FALSE) {
72 $size = mb_strlen($der);
74 if ($size < 2)
return 0;
77 $constructed = (ord($der[$pos]) >> 5) & 0x01;
78 $type = ord($der[$pos++]) & 0x1f;
79 if ($type == 0x1f)
return 0;
80 if ($pos >= $size)
return 0;
83 $len = ord($der[$pos++]);
87 while ($n-- && $pos < $size) {
88 $len = ($len << 8) | ord($der[$pos++]);
91 if ($pos >= $size || $len > $size - $pos)
return 0;
94 if ($type == self::BIT_STRING) {
96 $data = mb_substr($der, $pos, $len - 1);
97 if (!$ignore_bit_strings) $pos += $len - 1;
98 } elseif (!$constructed ) {
99 $data = mb_substr($der, $pos, $len);
103 return $pos - $offset;
160 $size = mb_strlen($oid);
163 $oct = ord($oid[$pos++]);
164 $str = floor($oct / 40) .
'.' . ($oct % 40);
167 while ($pos < $size) {
171 $oct = ord($oid[$pos++]);
172 $num = ($num << 7) + ($oct & 0x7F);
173 }
while (($oct & 0x80) && ($pos < $size));