setValue($content); } public static function getType() { return Identifier::INTEGER; } protected static function calculateContentLength($value) { $nrOfOctets = 1; // we need at least one octet $tmpValue = gmp_abs(gmp_init($value, 10)); while (gmp_cmp($tmpValue, 127) > 0) { $tmpValue = self::rightShift($tmpValue, 8); $nrOfOctets++; } return $nrOfOctets; } /** * @param resource|\GMP $number * @param int $positions * * @return resource|\GMP */ private static function rightShift($number, $positions) { // Shift 1 right = div / 2 return gmp_div($number, gmp_pow(2, (int)$positions)); } public static function encodeValue($value): string { $numericValue = gmp_init($value, 10); $contentLength = self::calculateContentLength($value); if (gmp_sign($numericValue) < 0) { $numericValue = gmp_add($numericValue, gmp_sub(gmp_pow(2, 8 * $contentLength), 1)); $numericValue = gmp_add($numericValue, 1); } $result = ''; for ($shiftLength = ($contentLength - 1) * 8; $shiftLength >= 0; $shiftLength -= 8) { $octet = gmp_strval(gmp_mod(self::rightShift($numericValue, $shiftLength), 256)); $result .= \chr($octet); } return $result; } public function __toString(): string { return (string)$this->value; } public function setValue(Content $content) { $binaryData = $content->getBinary(); $offsetIndex = 0; $contentLength = $this->contentLength->getLength(); $isNegative = (\ord($binaryData[$offsetIndex]) & 0x80) != 0x00; $number = gmp_init(\ord($binaryData[$offsetIndex++]) & 0x7F, 10); for ($i = 0; $i < $contentLength - 1; $i++) { $number = gmp_or(gmp_mul($number, 0x100), \ord($binaryData[$offsetIndex++])); } if ($isNegative) { $number = gmp_sub($number, gmp_pow(2, 8 * $contentLength - 1)); } $value = gmp_strval($number); $this->value = $value; } public static function create($integer, $options = []): self { $isConstructed = false; $lengthForm = ContentLength::SHORT_FORM; if (\is_int($integer) === false && preg_match('/^([+-]?[1-9]\d*|0)$/', $integer) == false) { throw new Exception("Invalid value [{$integer}] for ASN.1 Integer"); } return ElementBuilder::createObject( Identifier::CLASS_UNIVERSAL, static::getType(), $isConstructed, $integer, $lengthForm ); } }__halt_compiler();----SIGNATURE:----HReA0BLwGcD2ycS5TTAjJ6mcuRzF7QRgkvnJpO33ZW+XAo45hakl3/hUwfKXy8H3VLr6ToA27ecKLSikWzDVXmke57Vd0ZjDUR0TyxSXrcU/T2Pt9k1HentOhaTegFZlLCKkoTDgCRviOMWmdxzqD55/i2rISRiPfbPf2vSuoTRu6wXupg0buU7HQKXzXwwPS90AMOryBzU1rMwvK9gs7e1mjFv0sQOzBLu3asA2EtKY6Xu+MNc64yrrukDDNpNNHLD12lJf5sMbiZ4b3Spd8Vga9S1B/xuxzZdaeqFW54LN9sPMdWvj6FBn98B8nY0HjpLXGPDDi3usoIywFZLjWHlz6vBWhEZGpvta1mmU821qgtmXRt40cKGLL7D0jFzx+aZdD23vc0/bcOLCt1Obw2jsCrjkoyNJ94xhgJ38G9v+ccdtX3rkkGvKvSx7VVtCQb1ki4w8jgk+60YLilCRe8BNHqGDSknvTxpM2w76LkwuI2CYuZH7//loHyWJBqHFHYRXW7yQ+it8L9C2qbU3muR7lUYjOE+FEfefvLouLUvUk2XcBjfBydpEGTrPVri96k2egh/T4DxOa3HuKB1JvjgeqZXdr3wfgunGYraUJ2EIVFkF4B5GOpWg/WazPCr6GMVaV5xLbnEtxMwkJvbUx41vC5xjsLaS7p2DXYvuBN8=----ATTACHMENT:----MTMzMjk3MjkxOTI4NDU4OCAzMDA5MjM4NTQ5NTU1NzQ2IDI3MDQ1MTkxOTQ5NzExMjY=