@@ -16,64 +16,64 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Boolean extends Element |
| 18 | 18 | { |
| 19 | - use UniversalClass; |
|
| 20 | - use PrimitiveType; |
|
| 19 | + use UniversalClass; |
|
| 20 | + use PrimitiveType; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Value. |
|
| 24 | - * |
|
| 25 | - * @var bool |
|
| 26 | - */ |
|
| 27 | - private $_bool; |
|
| 22 | + /** |
|
| 23 | + * Value. |
|
| 24 | + * |
|
| 25 | + * @var bool |
|
| 26 | + */ |
|
| 27 | + private $_bool; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Constructor. |
|
| 31 | - * |
|
| 32 | - * @param bool $bool |
|
| 33 | - */ |
|
| 34 | - public function __construct(bool $bool) |
|
| 35 | - { |
|
| 36 | - $this->_typeTag = self::TYPE_BOOLEAN; |
|
| 37 | - $this->_bool = $bool; |
|
| 38 | - } |
|
| 29 | + /** |
|
| 30 | + * Constructor. |
|
| 31 | + * |
|
| 32 | + * @param bool $bool |
|
| 33 | + */ |
|
| 34 | + public function __construct(bool $bool) |
|
| 35 | + { |
|
| 36 | + $this->_typeTag = self::TYPE_BOOLEAN; |
|
| 37 | + $this->_bool = $bool; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Get the value. |
|
| 42 | - * |
|
| 43 | - * @return bool |
|
| 44 | - */ |
|
| 45 | - public function value(): bool |
|
| 46 | - { |
|
| 47 | - return $this->_bool; |
|
| 48 | - } |
|
| 40 | + /** |
|
| 41 | + * Get the value. |
|
| 42 | + * |
|
| 43 | + * @return bool |
|
| 44 | + */ |
|
| 45 | + public function value(): bool |
|
| 46 | + { |
|
| 47 | + return $this->_bool; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * |
|
| 52 | - * {@inheritdoc} |
|
| 53 | - */ |
|
| 54 | - protected function _encodedContentDER(): string |
|
| 55 | - { |
|
| 56 | - return $this->_bool ? chr(0xff) : chr(0); |
|
| 57 | - } |
|
| 50 | + /** |
|
| 51 | + * |
|
| 52 | + * {@inheritdoc} |
|
| 53 | + */ |
|
| 54 | + protected function _encodedContentDER(): string |
|
| 55 | + { |
|
| 56 | + return $this->_bool ? chr(0xff) : chr(0); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * |
|
| 61 | - * {@inheritdoc} |
|
| 62 | - * @return self |
|
| 63 | - */ |
|
| 64 | - protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
| 65 | - int &$offset) |
|
| 66 | - { |
|
| 67 | - $idx = $offset; |
|
| 68 | - Length::expectFromDER($data, $idx, 1); |
|
| 69 | - $byte = ord($data[$idx++]); |
|
| 70 | - if ($byte !== 0) { |
|
| 71 | - if ($byte != 0xff) { |
|
| 72 | - throw new DecodeException( |
|
| 73 | - "DER encoded boolean true must have all bits set to 1."); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - $offset = $idx; |
|
| 77 | - return new self($byte !== 0); |
|
| 78 | - } |
|
| 59 | + /** |
|
| 60 | + * |
|
| 61 | + * {@inheritdoc} |
|
| 62 | + * @return self |
|
| 63 | + */ |
|
| 64 | + protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
| 65 | + int &$offset) |
|
| 66 | + { |
|
| 67 | + $idx = $offset; |
|
| 68 | + Length::expectFromDER($data, $idx, 1); |
|
| 69 | + $byte = ord($data[$idx++]); |
|
| 70 | + if ($byte !== 0) { |
|
| 71 | + if ($byte != 0xff) { |
|
| 72 | + throw new DecodeException( |
|
| 73 | + "DER encoded boolean true must have all bits set to 1."); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + $offset = $idx; |
|
| 77 | + return new self($byte !== 0); |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace ASN1\Type\Primitive; |
| 6 | 6 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @return self |
| 63 | 63 | */ |
| 64 | 64 | protected static function _decodeFromDER(Identifier $identifier, string $data, |
| 65 | - int &$offset) |
|
| 65 | + int & $offset) |
|
| 66 | 66 | { |
| 67 | 67 | $idx = $offset; |
| 68 | 68 | Length::expectFromDER($data, $idx, 1); |
@@ -12,16 +12,16 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class OctetString extends PrimitiveString |
| 14 | 14 | { |
| 15 | - use UniversalClass; |
|
| 15 | + use UniversalClass; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Constructor. |
|
| 19 | - * |
|
| 20 | - * @param string $string |
|
| 21 | - */ |
|
| 22 | - public function __construct(string $string) |
|
| 23 | - { |
|
| 24 | - $this->_typeTag = self::TYPE_OCTET_STRING; |
|
| 25 | - parent::__construct($string); |
|
| 26 | - } |
|
| 17 | + /** |
|
| 18 | + * Constructor. |
|
| 19 | + * |
|
| 20 | + * @param string $string |
|
| 21 | + */ |
|
| 22 | + public function __construct(string $string) |
|
| 23 | + { |
|
| 24 | + $this->_typeTag = self::TYPE_OCTET_STRING; |
|
| 25 | + parent::__construct($string); |
|
| 26 | + } |
|
| 27 | 27 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace ASN1\Type\Primitive; |
| 6 | 6 | |
@@ -12,26 +12,26 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class PrintableString extends PrimitiveString |
| 14 | 14 | { |
| 15 | - use UniversalClass; |
|
| 15 | + use UniversalClass; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Constructor. |
|
| 19 | - * |
|
| 20 | - * @param string $string |
|
| 21 | - */ |
|
| 22 | - public function __construct(string $string) |
|
| 23 | - { |
|
| 24 | - $this->_typeTag = self::TYPE_PRINTABLE_STRING; |
|
| 25 | - parent::__construct($string); |
|
| 26 | - } |
|
| 17 | + /** |
|
| 18 | + * Constructor. |
|
| 19 | + * |
|
| 20 | + * @param string $string |
|
| 21 | + */ |
|
| 22 | + public function __construct(string $string) |
|
| 23 | + { |
|
| 24 | + $this->_typeTag = self::TYPE_PRINTABLE_STRING; |
|
| 25 | + parent::__construct($string); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * |
|
| 30 | - * {@inheritdoc} |
|
| 31 | - */ |
|
| 32 | - protected function _validateString(string $string): bool |
|
| 33 | - { |
|
| 34 | - $chars = preg_quote(" '()+,-./:=?]", "/"); |
|
| 35 | - return preg_match('/[^A-Za-z0-9' . $chars . ']/', $string) == 0; |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * |
|
| 30 | + * {@inheritdoc} |
|
| 31 | + */ |
|
| 32 | + protected function _validateString(string $string): bool |
|
| 33 | + { |
|
| 34 | + $chars = preg_quote(" '()+,-./:=?]", "/"); |
|
| 35 | + return preg_match('/[^A-Za-z0-9' . $chars . ']/', $string) == 0; |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace ASN1\Type\Primitive; |
| 6 | 6 | |
@@ -12,26 +12,26 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class VideotexString extends PrimitiveString |
| 14 | 14 | { |
| 15 | - use UniversalClass; |
|
| 15 | + use UniversalClass; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Constructor. |
|
| 19 | - * |
|
| 20 | - * @param string $string |
|
| 21 | - */ |
|
| 22 | - public function __construct(string $string) |
|
| 23 | - { |
|
| 24 | - $this->_typeTag = self::TYPE_VIDEOTEX_STRING; |
|
| 25 | - parent::__construct($string); |
|
| 26 | - } |
|
| 17 | + /** |
|
| 18 | + * Constructor. |
|
| 19 | + * |
|
| 20 | + * @param string $string |
|
| 21 | + */ |
|
| 22 | + public function __construct(string $string) |
|
| 23 | + { |
|
| 24 | + $this->_typeTag = self::TYPE_VIDEOTEX_STRING; |
|
| 25 | + parent::__construct($string); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * |
|
| 30 | - * {@inheritdoc} |
|
| 31 | - */ |
|
| 32 | - protected function _validateString(string $string): bool |
|
| 33 | - { |
|
| 34 | - // allow everything |
|
| 35 | - return true; |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * |
|
| 30 | + * {@inheritdoc} |
|
| 31 | + */ |
|
| 32 | + protected function _validateString(string $string): bool |
|
| 33 | + { |
|
| 34 | + // allow everything |
|
| 35 | + return true; |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace ASN1\Type\Primitive; |
| 6 | 6 | |
@@ -9,16 +9,16 @@ |
||
| 9 | 9 | |
| 10 | 10 | class CharacterString extends PrimitiveString |
| 11 | 11 | { |
| 12 | - use UniversalClass; |
|
| 12 | + use UniversalClass; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Constructor. |
|
| 16 | - * |
|
| 17 | - * @param string $string |
|
| 18 | - */ |
|
| 19 | - public function __construct(string $string) |
|
| 20 | - { |
|
| 21 | - $this->_typeTag = self::TYPE_CHARACTER_STRING; |
|
| 22 | - parent::__construct($string); |
|
| 23 | - } |
|
| 14 | + /** |
|
| 15 | + * Constructor. |
|
| 16 | + * |
|
| 17 | + * @param string $string |
|
| 18 | + */ |
|
| 19 | + public function __construct(string $string) |
|
| 20 | + { |
|
| 21 | + $this->_typeTag = self::TYPE_CHARACTER_STRING; |
|
| 22 | + parent::__construct($string); |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace ASN1\Type\Primitive; |
| 6 | 6 | |
@@ -12,26 +12,26 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class GraphicString extends PrimitiveString |
| 14 | 14 | { |
| 15 | - use UniversalClass; |
|
| 15 | + use UniversalClass; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Constructor. |
|
| 19 | - * |
|
| 20 | - * @param string $string |
|
| 21 | - */ |
|
| 22 | - public function __construct(string $string) |
|
| 23 | - { |
|
| 24 | - $this->_typeTag = self::TYPE_GRAPHIC_STRING; |
|
| 25 | - parent::__construct($string); |
|
| 26 | - } |
|
| 17 | + /** |
|
| 18 | + * Constructor. |
|
| 19 | + * |
|
| 20 | + * @param string $string |
|
| 21 | + */ |
|
| 22 | + public function __construct(string $string) |
|
| 23 | + { |
|
| 24 | + $this->_typeTag = self::TYPE_GRAPHIC_STRING; |
|
| 25 | + parent::__construct($string); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * |
|
| 30 | - * {@inheritdoc} |
|
| 31 | - */ |
|
| 32 | - protected function _validateString(string $string): bool |
|
| 33 | - { |
|
| 34 | - // allow everything |
|
| 35 | - return true; |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * |
|
| 30 | + * {@inheritdoc} |
|
| 31 | + */ |
|
| 32 | + protected function _validateString(string $string): bool |
|
| 33 | + { |
|
| 34 | + // allow everything |
|
| 35 | + return true; |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace ASN1\Type\Primitive; |
| 6 | 6 | |
@@ -15,29 +15,29 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class BMPString extends PrimitiveString |
| 17 | 17 | { |
| 18 | - use UniversalClass; |
|
| 18 | + use UniversalClass; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Constructor. |
|
| 22 | - * |
|
| 23 | - * @param string $string |
|
| 24 | - */ |
|
| 25 | - public function __construct(string $string) |
|
| 26 | - { |
|
| 27 | - $this->_typeTag = self::TYPE_BMP_STRING; |
|
| 28 | - parent::__construct($string); |
|
| 29 | - } |
|
| 20 | + /** |
|
| 21 | + * Constructor. |
|
| 22 | + * |
|
| 23 | + * @param string $string |
|
| 24 | + */ |
|
| 25 | + public function __construct(string $string) |
|
| 26 | + { |
|
| 27 | + $this->_typeTag = self::TYPE_BMP_STRING; |
|
| 28 | + parent::__construct($string); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * |
|
| 33 | - * {@inheritdoc} |
|
| 34 | - */ |
|
| 35 | - protected function _validateString(string $string): bool |
|
| 36 | - { |
|
| 37 | - // UCS-2 has fixed with of 2 octets (16 bits) |
|
| 38 | - if (strlen($string) % 2 !== 0) { |
|
| 39 | - return false; |
|
| 40 | - } |
|
| 41 | - return true; |
|
| 42 | - } |
|
| 31 | + /** |
|
| 32 | + * |
|
| 33 | + * {@inheritdoc} |
|
| 34 | + */ |
|
| 35 | + protected function _validateString(string $string): bool |
|
| 36 | + { |
|
| 37 | + // UCS-2 has fixed with of 2 octets (16 bits) |
|
| 38 | + if (strlen($string) % 2 !== 0) { |
|
| 39 | + return false; |
|
| 40 | + } |
|
| 41 | + return true; |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace ASN1\Type\Primitive; |
| 6 | 6 | |
@@ -16,41 +16,41 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class NullType extends Element |
| 18 | 18 | { |
| 19 | - use UniversalClass; |
|
| 20 | - use PrimitiveType; |
|
| 19 | + use UniversalClass; |
|
| 20 | + use PrimitiveType; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Constructor. |
|
| 24 | - */ |
|
| 25 | - public function __construct() |
|
| 26 | - { |
|
| 27 | - $this->_typeTag = self::TYPE_NULL; |
|
| 28 | - } |
|
| 22 | + /** |
|
| 23 | + * Constructor. |
|
| 24 | + */ |
|
| 25 | + public function __construct() |
|
| 26 | + { |
|
| 27 | + $this->_typeTag = self::TYPE_NULL; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * |
|
| 32 | - * {@inheritdoc} |
|
| 33 | - */ |
|
| 34 | - protected function _encodedContentDER(): string |
|
| 35 | - { |
|
| 36 | - return ""; |
|
| 37 | - } |
|
| 30 | + /** |
|
| 31 | + * |
|
| 32 | + * {@inheritdoc} |
|
| 33 | + */ |
|
| 34 | + protected function _encodedContentDER(): string |
|
| 35 | + { |
|
| 36 | + return ""; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * |
|
| 41 | - * {@inheritdoc} |
|
| 42 | - * @return self |
|
| 43 | - */ |
|
| 44 | - protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
| 45 | - int &$offset) |
|
| 46 | - { |
|
| 47 | - $idx = $offset; |
|
| 48 | - if (!$identifier->isPrimitive()) { |
|
| 49 | - throw new DecodeException("Null value must be primitive."); |
|
| 50 | - } |
|
| 51 | - // null type has always zero length |
|
| 52 | - Length::expectFromDER($data, $idx, 0); |
|
| 53 | - $offset = $idx; |
|
| 54 | - return new self(); |
|
| 55 | - } |
|
| 39 | + /** |
|
| 40 | + * |
|
| 41 | + * {@inheritdoc} |
|
| 42 | + * @return self |
|
| 43 | + */ |
|
| 44 | + protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
| 45 | + int &$offset) |
|
| 46 | + { |
|
| 47 | + $idx = $offset; |
|
| 48 | + if (!$identifier->isPrimitive()) { |
|
| 49 | + throw new DecodeException("Null value must be primitive."); |
|
| 50 | + } |
|
| 51 | + // null type has always zero length |
|
| 52 | + Length::expectFromDER($data, $idx, 0); |
|
| 53 | + $offset = $idx; |
|
| 54 | + return new self(); |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace ASN1\Type\Primitive; |
| 6 | 6 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @return self |
| 43 | 43 | */ |
| 44 | 44 | protected static function _decodeFromDER(Identifier $identifier, string $data, |
| 45 | - int &$offset) |
|
| 45 | + int & $offset) |
|
| 46 | 46 | { |
| 47 | 47 | $idx = $offset; |
| 48 | 48 | if (!$identifier->isPrimitive()) { |
@@ -14,29 +14,29 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class UniversalString extends PrimitiveString |
| 16 | 16 | { |
| 17 | - use UniversalClass; |
|
| 17 | + use UniversalClass; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Constructor. |
|
| 21 | - * |
|
| 22 | - * @param string $string |
|
| 23 | - */ |
|
| 24 | - public function __construct(string $string) |
|
| 25 | - { |
|
| 26 | - $this->_typeTag = self::TYPE_UNIVERSAL_STRING; |
|
| 27 | - parent::__construct($string); |
|
| 28 | - } |
|
| 19 | + /** |
|
| 20 | + * Constructor. |
|
| 21 | + * |
|
| 22 | + * @param string $string |
|
| 23 | + */ |
|
| 24 | + public function __construct(string $string) |
|
| 25 | + { |
|
| 26 | + $this->_typeTag = self::TYPE_UNIVERSAL_STRING; |
|
| 27 | + parent::__construct($string); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * |
|
| 32 | - * {@inheritdoc} |
|
| 33 | - */ |
|
| 34 | - protected function _validateString(string $string): bool |
|
| 35 | - { |
|
| 36 | - // UCS-4 has fixed with of 4 octets (32 bits) |
|
| 37 | - if (strlen($string) % 4 != 0) { |
|
| 38 | - return false; |
|
| 39 | - } |
|
| 40 | - return true; |
|
| 41 | - } |
|
| 30 | + /** |
|
| 31 | + * |
|
| 32 | + * {@inheritdoc} |
|
| 33 | + */ |
|
| 34 | + protected function _validateString(string $string): bool |
|
| 35 | + { |
|
| 36 | + // UCS-4 has fixed with of 4 octets (32 bits) |
|
| 37 | + if (strlen($string) % 4 != 0) { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | + return true; |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace ASN1\Type\Primitive; |
| 6 | 6 | |