• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/web/jwt.php
  • Класс: BitrixMainWebJWT
  • Вызов: JWT::readDER
static function readDER($der, $offset = 0)
{
	$pos = $offset;
	$size = strlen($der);
	$constructed = (ord($der[$pos]) >> 5) & 0x01;
	$type = ord($der[$pos++]) & 0x1f;

	// Length
	$len = ord($der[$pos++]);
	if ($len & 0x80) {
		$n = $len & 0x1f;
		$len = 0;
		while ($n-- && $pos < $size) {
			$len = ($len << 8) | ord($der[$pos++]);
		}
	}

	// Value
	if ($type == self::ASN1_BIT_STRING) {
		$pos++; // Skip the first contents octet (padding indicator)
		$data = substr($der, $pos, $len - 1);
		$pos += $len - 1;
	} elseif (!$constructed) {
		$data = substr($der, $pos, $len);
		$pos += $len;
	} else {
		$data = null;
	}

	return array($pos, $data);
}