@@ -15,50 +15,50 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class SubjectAlternativeNameExtension extends Extension |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Names. |
|
| 20 | - * |
|
| 21 | - * @var GeneralNames |
|
| 22 | - */ |
|
| 23 | - protected $_names; |
|
| 18 | + /** |
|
| 19 | + * Names. |
|
| 20 | + * |
|
| 21 | + * @var GeneralNames |
|
| 22 | + */ |
|
| 23 | + protected $_names; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Constructor. |
|
| 27 | - * |
|
| 28 | - * @param bool $critical |
|
| 29 | - * @param GeneralNames $names |
|
| 30 | - */ |
|
| 31 | - public function __construct(bool $critical, GeneralNames $names) |
|
| 32 | - { |
|
| 33 | - parent::__construct(self::OID_SUBJECT_ALT_NAME, $critical); |
|
| 34 | - $this->_names = $names; |
|
| 35 | - } |
|
| 25 | + /** |
|
| 26 | + * Constructor. |
|
| 27 | + * |
|
| 28 | + * @param bool $critical |
|
| 29 | + * @param GeneralNames $names |
|
| 30 | + */ |
|
| 31 | + public function __construct(bool $critical, GeneralNames $names) |
|
| 32 | + { |
|
| 33 | + parent::__construct(self::OID_SUBJECT_ALT_NAME, $critical); |
|
| 34 | + $this->_names = $names; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Get names. |
|
| 39 | - * |
|
| 40 | - * @return GeneralNames |
|
| 41 | - */ |
|
| 42 | - public function names(): GeneralNames |
|
| 43 | - { |
|
| 44 | - return $this->_names; |
|
| 45 | - } |
|
| 37 | + /** |
|
| 38 | + * Get names. |
|
| 39 | + * |
|
| 40 | + * @return GeneralNames |
|
| 41 | + */ |
|
| 42 | + public function names(): GeneralNames |
|
| 43 | + { |
|
| 44 | + return $this->_names; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * {@inheritdoc} |
|
| 49 | - */ |
|
| 50 | - protected static function _fromDER(string $data, bool $critical): Extension |
|
| 51 | - { |
|
| 52 | - return new self($critical, |
|
| 53 | - GeneralNames::fromASN1( |
|
| 54 | - UnspecifiedType::fromDER($data)->asSequence())); |
|
| 55 | - } |
|
| 47 | + /** |
|
| 48 | + * {@inheritdoc} |
|
| 49 | + */ |
|
| 50 | + protected static function _fromDER(string $data, bool $critical): Extension |
|
| 51 | + { |
|
| 52 | + return new self($critical, |
|
| 53 | + GeneralNames::fromASN1( |
|
| 54 | + UnspecifiedType::fromDER($data)->asSequence())); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * {@inheritdoc} |
|
| 59 | - */ |
|
| 60 | - protected function _valueASN1(): Element |
|
| 61 | - { |
|
| 62 | - return $this->_names->toASN1(); |
|
| 63 | - } |
|
| 57 | + /** |
|
| 58 | + * {@inheritdoc} |
|
| 59 | + */ |
|
| 60 | + protected function _valueASN1(): Element |
|
| 61 | + { |
|
| 62 | + return $this->_names->toASN1(); |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -17,48 +17,48 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class SubjectDirectoryAttributesExtension extends Extension implements \Countable, \IteratorAggregate |
| 19 | 19 | { |
| 20 | - use AttributeContainer; |
|
| 20 | + use AttributeContainer; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Constructor. |
|
| 24 | - * |
|
| 25 | - * @param bool $critical |
|
| 26 | - * @param Attribute ...$attribs One or more Attribute objects |
|
| 27 | - */ |
|
| 28 | - public function __construct(bool $critical, Attribute ...$attribs) |
|
| 29 | - { |
|
| 30 | - parent::__construct(self::OID_SUBJECT_DIRECTORY_ATTRIBUTES, $critical); |
|
| 31 | - $this->_attributes = $attribs; |
|
| 32 | - } |
|
| 22 | + /** |
|
| 23 | + * Constructor. |
|
| 24 | + * |
|
| 25 | + * @param bool $critical |
|
| 26 | + * @param Attribute ...$attribs One or more Attribute objects |
|
| 27 | + */ |
|
| 28 | + public function __construct(bool $critical, Attribute ...$attribs) |
|
| 29 | + { |
|
| 30 | + parent::__construct(self::OID_SUBJECT_DIRECTORY_ATTRIBUTES, $critical); |
|
| 31 | + $this->_attributes = $attribs; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * {@inheritdoc} |
|
| 36 | - */ |
|
| 37 | - protected static function _fromDER(string $data, bool $critical): Extension |
|
| 38 | - { |
|
| 39 | - $attribs = array_map( |
|
| 40 | - function (UnspecifiedType $el) { |
|
| 41 | - return Attribute::fromASN1($el->asSequence()); |
|
| 42 | - }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
| 43 | - if (!count($attribs)) { |
|
| 44 | - throw new \UnexpectedValueException( |
|
| 45 | - 'SubjectDirectoryAttributes must have at least one Attribute.'); |
|
| 46 | - } |
|
| 47 | - return new self($critical, ...$attribs); |
|
| 48 | - } |
|
| 34 | + /** |
|
| 35 | + * {@inheritdoc} |
|
| 36 | + */ |
|
| 37 | + protected static function _fromDER(string $data, bool $critical): Extension |
|
| 38 | + { |
|
| 39 | + $attribs = array_map( |
|
| 40 | + function (UnspecifiedType $el) { |
|
| 41 | + return Attribute::fromASN1($el->asSequence()); |
|
| 42 | + }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
| 43 | + if (!count($attribs)) { |
|
| 44 | + throw new \UnexpectedValueException( |
|
| 45 | + 'SubjectDirectoryAttributes must have at least one Attribute.'); |
|
| 46 | + } |
|
| 47 | + return new self($critical, ...$attribs); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * {@inheritdoc} |
|
| 52 | - */ |
|
| 53 | - protected function _valueASN1(): Element |
|
| 54 | - { |
|
| 55 | - if (!count($this->_attributes)) { |
|
| 56 | - throw new \LogicException('No attributes'); |
|
| 57 | - } |
|
| 58 | - $elements = array_map( |
|
| 59 | - function (Attribute $attr) { |
|
| 60 | - return $attr->toASN1(); |
|
| 61 | - }, array_values($this->_attributes)); |
|
| 62 | - return new Sequence(...$elements); |
|
| 63 | - } |
|
| 50 | + /** |
|
| 51 | + * {@inheritdoc} |
|
| 52 | + */ |
|
| 53 | + protected function _valueASN1(): Element |
|
| 54 | + { |
|
| 55 | + if (!count($this->_attributes)) { |
|
| 56 | + throw new \LogicException('No attributes'); |
|
| 57 | + } |
|
| 58 | + $elements = array_map( |
|
| 59 | + function (Attribute $attr) { |
|
| 60 | + return $attr->toASN1(); |
|
| 61 | + }, array_values($this->_attributes)); |
|
| 62 | + return new Sequence(...$elements); |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -17,80 +17,80 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class AuthorityInformationAccessExtension extends Extension implements \Countable, \IteratorAggregate |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Access descriptions. |
|
| 22 | - * |
|
| 23 | - * @var AuthorityAccessDescription[] |
|
| 24 | - */ |
|
| 25 | - private $_accessDescriptions; |
|
| 20 | + /** |
|
| 21 | + * Access descriptions. |
|
| 22 | + * |
|
| 23 | + * @var AuthorityAccessDescription[] |
|
| 24 | + */ |
|
| 25 | + private $_accessDescriptions; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Constructor. |
|
| 29 | - * |
|
| 30 | - * @param bool $critical |
|
| 31 | - * @param AuthorityAccessDescription ...$access |
|
| 32 | - */ |
|
| 33 | - public function __construct(bool $critical, AuthorityAccessDescription ...$access) |
|
| 34 | - { |
|
| 35 | - parent::__construct(self::OID_AUTHORITY_INFORMATION_ACCESS, $critical); |
|
| 36 | - $this->_accessDescriptions = $access; |
|
| 37 | - } |
|
| 27 | + /** |
|
| 28 | + * Constructor. |
|
| 29 | + * |
|
| 30 | + * @param bool $critical |
|
| 31 | + * @param AuthorityAccessDescription ...$access |
|
| 32 | + */ |
|
| 33 | + public function __construct(bool $critical, AuthorityAccessDescription ...$access) |
|
| 34 | + { |
|
| 35 | + parent::__construct(self::OID_AUTHORITY_INFORMATION_ACCESS, $critical); |
|
| 36 | + $this->_accessDescriptions = $access; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Get the access descriptions. |
|
| 41 | - * |
|
| 42 | - * @return AuthorityAccessDescription[] |
|
| 43 | - */ |
|
| 44 | - public function accessDescriptions(): array |
|
| 45 | - { |
|
| 46 | - return $this->_accessDescriptions; |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * Get the access descriptions. |
|
| 41 | + * |
|
| 42 | + * @return AuthorityAccessDescription[] |
|
| 43 | + */ |
|
| 44 | + public function accessDescriptions(): array |
|
| 45 | + { |
|
| 46 | + return $this->_accessDescriptions; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Get the number of access descriptions. |
|
| 51 | - * |
|
| 52 | - * @see \Countable::count() |
|
| 53 | - * |
|
| 54 | - * @return int |
|
| 55 | - */ |
|
| 56 | - public function count(): int |
|
| 57 | - { |
|
| 58 | - return count($this->_accessDescriptions); |
|
| 59 | - } |
|
| 49 | + /** |
|
| 50 | + * Get the number of access descriptions. |
|
| 51 | + * |
|
| 52 | + * @see \Countable::count() |
|
| 53 | + * |
|
| 54 | + * @return int |
|
| 55 | + */ |
|
| 56 | + public function count(): int |
|
| 57 | + { |
|
| 58 | + return count($this->_accessDescriptions); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Get iterator for access descriptions. |
|
| 63 | - * |
|
| 64 | - * @see \IteratorAggregate::getIterator() |
|
| 65 | - * |
|
| 66 | - * @return \ArrayIterator List of AuthorityAccessDescription objects |
|
| 67 | - */ |
|
| 68 | - public function getIterator(): \ArrayIterator |
|
| 69 | - { |
|
| 70 | - return new \ArrayIterator($this->_accessDescriptions); |
|
| 71 | - } |
|
| 61 | + /** |
|
| 62 | + * Get iterator for access descriptions. |
|
| 63 | + * |
|
| 64 | + * @see \IteratorAggregate::getIterator() |
|
| 65 | + * |
|
| 66 | + * @return \ArrayIterator List of AuthorityAccessDescription objects |
|
| 67 | + */ |
|
| 68 | + public function getIterator(): \ArrayIterator |
|
| 69 | + { |
|
| 70 | + return new \ArrayIterator($this->_accessDescriptions); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * {@inheritdoc} |
|
| 75 | - */ |
|
| 76 | - protected static function _fromDER(string $data, bool $critical): Extension |
|
| 77 | - { |
|
| 78 | - $access = array_map( |
|
| 79 | - function (UnspecifiedType $el) { |
|
| 80 | - return AuthorityAccessDescription::fromASN1($el->asSequence()); |
|
| 81 | - }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
| 82 | - return new self($critical, ...$access); |
|
| 83 | - } |
|
| 73 | + /** |
|
| 74 | + * {@inheritdoc} |
|
| 75 | + */ |
|
| 76 | + protected static function _fromDER(string $data, bool $critical): Extension |
|
| 77 | + { |
|
| 78 | + $access = array_map( |
|
| 79 | + function (UnspecifiedType $el) { |
|
| 80 | + return AuthorityAccessDescription::fromASN1($el->asSequence()); |
|
| 81 | + }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
| 82 | + return new self($critical, ...$access); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * {@inheritdoc} |
|
| 87 | - */ |
|
| 88 | - protected function _valueASN1(): Element |
|
| 89 | - { |
|
| 90 | - $elements = array_map( |
|
| 91 | - function (AccessDescription $access) { |
|
| 92 | - return $access->toASN1(); |
|
| 93 | - }, $this->_accessDescriptions); |
|
| 94 | - return new Sequence(...$elements); |
|
| 95 | - } |
|
| 85 | + /** |
|
| 86 | + * {@inheritdoc} |
|
| 87 | + */ |
|
| 88 | + protected function _valueASN1(): Element |
|
| 89 | + { |
|
| 90 | + $elements = array_map( |
|
| 91 | + function (AccessDescription $access) { |
|
| 92 | + return $access->toASN1(); |
|
| 93 | + }, $this->_accessDescriptions); |
|
| 94 | + return new Sequence(...$elements); |
|
| 95 | + } |
|
| 96 | 96 | } |
@@ -16,129 +16,129 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class ExtendedKeyUsageExtension extends Extension implements \Countable, \IteratorAggregate |
| 18 | 18 | { |
| 19 | - const OID_SERVER_AUTH = '1.3.6.1.5.5.7.3.1'; |
|
| 20 | - const OID_CLIENT_AUTH = '1.3.6.1.5.5.7.3.2'; |
|
| 21 | - const OID_CODE_SIGNING = '1.3.6.1.5.5.7.3.3'; |
|
| 22 | - const OID_EMAIL_PROTECTION = '1.3.6.1.5.5.7.3.4'; |
|
| 23 | - const OID_IPSEC_END_SYSTEM = '1.3.6.1.5.5.7.3.5'; |
|
| 24 | - const OID_IPSEC_TUNNEL = '1.3.6.1.5.5.7.3.6'; |
|
| 25 | - const OID_IPSEC_USER = '1.3.6.1.5.5.7.3.7'; |
|
| 26 | - const OID_TIME_STAMPING = '1.3.6.1.5.5.7.3.8'; |
|
| 27 | - const OID_OCSP_SIGNING = '1.3.6.1.5.5.7.3.9'; |
|
| 28 | - const OID_DVCS = '1.3.6.1.5.5.7.3.10'; |
|
| 29 | - const OID_SBGP_CERT_AA_SERVER_AUTH = '1.3.6.1.5.5.7.3.11'; |
|
| 30 | - const OID_SCVP_RESPONDER = '1.3.6.1.5.5.7.3.12'; |
|
| 31 | - const OID_EAP_OVER_PPP = '1.3.6.1.5.5.7.3.13'; |
|
| 32 | - const OID_EAP_OVER_LAN = '1.3.6.1.5.5.7.3.14'; |
|
| 33 | - const OID_SCVP_SERVER = '1.3.6.1.5.5.7.3.15'; |
|
| 34 | - const OID_SCVP_CLIENT = '1.3.6.1.5.5.7.3.16'; |
|
| 35 | - const OID_IPSEC_IKE = '1.3.6.1.5.5.7.3.17'; |
|
| 36 | - const OID_CAPWAP_AC = '1.3.6.1.5.5.7.3.18'; |
|
| 37 | - const OID_CAPWAP_WTP = '1.3.6.1.5.5.7.3.19'; |
|
| 38 | - const OID_SIP_DOMAIN = '1.3.6.1.5.5.7.3.20'; |
|
| 39 | - const OID_SECURE_SHELL_CLIENT = '1.3.6.1.5.5.7.3.21'; |
|
| 40 | - const OID_SECURE_SHELL_SERVER = '1.3.6.1.5.5.7.3.22'; |
|
| 41 | - const OID_SEND_ROUTER = '1.3.6.1.5.5.7.3.23'; |
|
| 42 | - const OID_SEND_PROXY = '1.3.6.1.5.5.7.3.24'; |
|
| 43 | - const OID_SEND_OWNER = '1.3.6.1.5.5.7.3.25'; |
|
| 44 | - const OID_SEND_PROXIED_OWNER = '1.3.6.1.5.5.7.3.26'; |
|
| 45 | - const OID_CMC_CA = '1.3.6.1.5.5.7.3.27'; |
|
| 46 | - const OID_CMC_RA = '1.3.6.1.5.5.7.3.28'; |
|
| 47 | - const OID_CMC_ARCHIVE = '1.3.6.1.5.5.7.3.29'; |
|
| 19 | + const OID_SERVER_AUTH = '1.3.6.1.5.5.7.3.1'; |
|
| 20 | + const OID_CLIENT_AUTH = '1.3.6.1.5.5.7.3.2'; |
|
| 21 | + const OID_CODE_SIGNING = '1.3.6.1.5.5.7.3.3'; |
|
| 22 | + const OID_EMAIL_PROTECTION = '1.3.6.1.5.5.7.3.4'; |
|
| 23 | + const OID_IPSEC_END_SYSTEM = '1.3.6.1.5.5.7.3.5'; |
|
| 24 | + const OID_IPSEC_TUNNEL = '1.3.6.1.5.5.7.3.6'; |
|
| 25 | + const OID_IPSEC_USER = '1.3.6.1.5.5.7.3.7'; |
|
| 26 | + const OID_TIME_STAMPING = '1.3.6.1.5.5.7.3.8'; |
|
| 27 | + const OID_OCSP_SIGNING = '1.3.6.1.5.5.7.3.9'; |
|
| 28 | + const OID_DVCS = '1.3.6.1.5.5.7.3.10'; |
|
| 29 | + const OID_SBGP_CERT_AA_SERVER_AUTH = '1.3.6.1.5.5.7.3.11'; |
|
| 30 | + const OID_SCVP_RESPONDER = '1.3.6.1.5.5.7.3.12'; |
|
| 31 | + const OID_EAP_OVER_PPP = '1.3.6.1.5.5.7.3.13'; |
|
| 32 | + const OID_EAP_OVER_LAN = '1.3.6.1.5.5.7.3.14'; |
|
| 33 | + const OID_SCVP_SERVER = '1.3.6.1.5.5.7.3.15'; |
|
| 34 | + const OID_SCVP_CLIENT = '1.3.6.1.5.5.7.3.16'; |
|
| 35 | + const OID_IPSEC_IKE = '1.3.6.1.5.5.7.3.17'; |
|
| 36 | + const OID_CAPWAP_AC = '1.3.6.1.5.5.7.3.18'; |
|
| 37 | + const OID_CAPWAP_WTP = '1.3.6.1.5.5.7.3.19'; |
|
| 38 | + const OID_SIP_DOMAIN = '1.3.6.1.5.5.7.3.20'; |
|
| 39 | + const OID_SECURE_SHELL_CLIENT = '1.3.6.1.5.5.7.3.21'; |
|
| 40 | + const OID_SECURE_SHELL_SERVER = '1.3.6.1.5.5.7.3.22'; |
|
| 41 | + const OID_SEND_ROUTER = '1.3.6.1.5.5.7.3.23'; |
|
| 42 | + const OID_SEND_PROXY = '1.3.6.1.5.5.7.3.24'; |
|
| 43 | + const OID_SEND_OWNER = '1.3.6.1.5.5.7.3.25'; |
|
| 44 | + const OID_SEND_PROXIED_OWNER = '1.3.6.1.5.5.7.3.26'; |
|
| 45 | + const OID_CMC_CA = '1.3.6.1.5.5.7.3.27'; |
|
| 46 | + const OID_CMC_RA = '1.3.6.1.5.5.7.3.28'; |
|
| 47 | + const OID_CMC_ARCHIVE = '1.3.6.1.5.5.7.3.29'; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Purpose OID's. |
|
| 51 | - * |
|
| 52 | - * @var string[] |
|
| 53 | - */ |
|
| 54 | - protected $_purposes; |
|
| 49 | + /** |
|
| 50 | + * Purpose OID's. |
|
| 51 | + * |
|
| 52 | + * @var string[] |
|
| 53 | + */ |
|
| 54 | + protected $_purposes; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Constructor. |
|
| 58 | - * |
|
| 59 | - * @param bool $critical |
|
| 60 | - * @param string ...$purposes |
|
| 61 | - */ |
|
| 62 | - public function __construct(bool $critical, string ...$purposes) |
|
| 63 | - { |
|
| 64 | - parent::__construct(self::OID_EXT_KEY_USAGE, $critical); |
|
| 65 | - $this->_purposes = $purposes; |
|
| 66 | - } |
|
| 56 | + /** |
|
| 57 | + * Constructor. |
|
| 58 | + * |
|
| 59 | + * @param bool $critical |
|
| 60 | + * @param string ...$purposes |
|
| 61 | + */ |
|
| 62 | + public function __construct(bool $critical, string ...$purposes) |
|
| 63 | + { |
|
| 64 | + parent::__construct(self::OID_EXT_KEY_USAGE, $critical); |
|
| 65 | + $this->_purposes = $purposes; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Whether purposes are present. |
|
| 70 | - * |
|
| 71 | - * If multiple purposes are checked, all must be present. |
|
| 72 | - * |
|
| 73 | - * @param string ...$oids |
|
| 74 | - * |
|
| 75 | - * @return bool |
|
| 76 | - */ |
|
| 77 | - public function has(string ...$oids): bool |
|
| 78 | - { |
|
| 79 | - foreach ($oids as $oid) { |
|
| 80 | - if (!in_array($oid, $this->_purposes)) { |
|
| 81 | - return false; |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - return true; |
|
| 85 | - } |
|
| 68 | + /** |
|
| 69 | + * Whether purposes are present. |
|
| 70 | + * |
|
| 71 | + * If multiple purposes are checked, all must be present. |
|
| 72 | + * |
|
| 73 | + * @param string ...$oids |
|
| 74 | + * |
|
| 75 | + * @return bool |
|
| 76 | + */ |
|
| 77 | + public function has(string ...$oids): bool |
|
| 78 | + { |
|
| 79 | + foreach ($oids as $oid) { |
|
| 80 | + if (!in_array($oid, $this->_purposes)) { |
|
| 81 | + return false; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + return true; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * Get key usage purpose OID's. |
|
| 89 | - * |
|
| 90 | - * @return string[] |
|
| 91 | - */ |
|
| 92 | - public function purposes(): array |
|
| 93 | - { |
|
| 94 | - return $this->_purposes; |
|
| 95 | - } |
|
| 87 | + /** |
|
| 88 | + * Get key usage purpose OID's. |
|
| 89 | + * |
|
| 90 | + * @return string[] |
|
| 91 | + */ |
|
| 92 | + public function purposes(): array |
|
| 93 | + { |
|
| 94 | + return $this->_purposes; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Get the number of purposes. |
|
| 99 | - * |
|
| 100 | - * @see \Countable::count() |
|
| 101 | - * |
|
| 102 | - * @return int |
|
| 103 | - */ |
|
| 104 | - public function count(): int |
|
| 105 | - { |
|
| 106 | - return count($this->_purposes); |
|
| 107 | - } |
|
| 97 | + /** |
|
| 98 | + * Get the number of purposes. |
|
| 99 | + * |
|
| 100 | + * @see \Countable::count() |
|
| 101 | + * |
|
| 102 | + * @return int |
|
| 103 | + */ |
|
| 104 | + public function count(): int |
|
| 105 | + { |
|
| 106 | + return count($this->_purposes); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Get iterator for usage purposes. |
|
| 111 | - * |
|
| 112 | - * @see \IteratorAggregate::getIterator() |
|
| 113 | - * |
|
| 114 | - * @return \ArrayIterator |
|
| 115 | - */ |
|
| 116 | - public function getIterator(): \ArrayIterator |
|
| 117 | - { |
|
| 118 | - return new \ArrayIterator($this->_purposes); |
|
| 119 | - } |
|
| 109 | + /** |
|
| 110 | + * Get iterator for usage purposes. |
|
| 111 | + * |
|
| 112 | + * @see \IteratorAggregate::getIterator() |
|
| 113 | + * |
|
| 114 | + * @return \ArrayIterator |
|
| 115 | + */ |
|
| 116 | + public function getIterator(): \ArrayIterator |
|
| 117 | + { |
|
| 118 | + return new \ArrayIterator($this->_purposes); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * {@inheritdoc} |
|
| 123 | - */ |
|
| 124 | - protected static function _fromDER(string $data, bool $critical): Extension |
|
| 125 | - { |
|
| 126 | - $purposes = array_map( |
|
| 127 | - function (UnspecifiedType $el) { |
|
| 128 | - return $el->asObjectIdentifier()->oid(); |
|
| 129 | - }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
| 130 | - return new self($critical, ...$purposes); |
|
| 131 | - } |
|
| 121 | + /** |
|
| 122 | + * {@inheritdoc} |
|
| 123 | + */ |
|
| 124 | + protected static function _fromDER(string $data, bool $critical): Extension |
|
| 125 | + { |
|
| 126 | + $purposes = array_map( |
|
| 127 | + function (UnspecifiedType $el) { |
|
| 128 | + return $el->asObjectIdentifier()->oid(); |
|
| 129 | + }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
| 130 | + return new self($critical, ...$purposes); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * {@inheritdoc} |
|
| 135 | - */ |
|
| 136 | - protected function _valueASN1(): Element |
|
| 137 | - { |
|
| 138 | - $elements = array_map( |
|
| 139 | - function ($oid) { |
|
| 140 | - return new ObjectIdentifier($oid); |
|
| 141 | - }, $this->_purposes); |
|
| 142 | - return new Sequence(...$elements); |
|
| 143 | - } |
|
| 133 | + /** |
|
| 134 | + * {@inheritdoc} |
|
| 135 | + */ |
|
| 136 | + protected function _valueASN1(): Element |
|
| 137 | + { |
|
| 138 | + $elements = array_map( |
|
| 139 | + function ($oid) { |
|
| 140 | + return new ObjectIdentifier($oid); |
|
| 141 | + }, $this->_purposes); |
|
| 142 | + return new Sequence(...$elements); |
|
| 143 | + } |
|
| 144 | 144 | } |
@@ -15,47 +15,47 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class InhibitAnyPolicyExtension extends Extension |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var int |
|
| 20 | - */ |
|
| 21 | - protected $_skipCerts; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Constructor. |
|
| 25 | - * |
|
| 26 | - * @param bool $critical |
|
| 27 | - * @param int $skip_certs |
|
| 28 | - */ |
|
| 29 | - public function __construct(bool $critical, int $skip_certs) |
|
| 30 | - { |
|
| 31 | - parent::__construct(self::OID_INHIBIT_ANY_POLICY, $critical); |
|
| 32 | - $this->_skipCerts = $skip_certs; |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Get value. |
|
| 37 | - * |
|
| 38 | - * @return int |
|
| 39 | - */ |
|
| 40 | - public function skipCerts(): int |
|
| 41 | - { |
|
| 42 | - return $this->_skipCerts; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * {@inheritdoc} |
|
| 47 | - */ |
|
| 48 | - protected static function _fromDER(string $data, bool $critical): Extension |
|
| 49 | - { |
|
| 50 | - return new self($critical, |
|
| 51 | - UnspecifiedType::fromDER($data)->asInteger()->intNumber()); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * {@inheritdoc} |
|
| 56 | - */ |
|
| 57 | - protected function _valueASN1(): Element |
|
| 58 | - { |
|
| 59 | - return new Integer($this->_skipCerts); |
|
| 60 | - } |
|
| 18 | + /** |
|
| 19 | + * @var int |
|
| 20 | + */ |
|
| 21 | + protected $_skipCerts; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Constructor. |
|
| 25 | + * |
|
| 26 | + * @param bool $critical |
|
| 27 | + * @param int $skip_certs |
|
| 28 | + */ |
|
| 29 | + public function __construct(bool $critical, int $skip_certs) |
|
| 30 | + { |
|
| 31 | + parent::__construct(self::OID_INHIBIT_ANY_POLICY, $critical); |
|
| 32 | + $this->_skipCerts = $skip_certs; |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Get value. |
|
| 37 | + * |
|
| 38 | + * @return int |
|
| 39 | + */ |
|
| 40 | + public function skipCerts(): int |
|
| 41 | + { |
|
| 42 | + return $this->_skipCerts; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * {@inheritdoc} |
|
| 47 | + */ |
|
| 48 | + protected static function _fromDER(string $data, bool $critical): Extension |
|
| 49 | + { |
|
| 50 | + return new self($critical, |
|
| 51 | + UnspecifiedType::fromDER($data)->asInteger()->intNumber()); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * {@inheritdoc} |
|
| 56 | + */ |
|
| 57 | + protected function _valueASN1(): Element |
|
| 58 | + { |
|
| 59 | + return new Integer($this->_skipCerts); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -17,116 +17,116 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class NameConstraintsExtension extends Extension |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Permitted subtrees. |
|
| 22 | - * |
|
| 23 | - * @var null|GeneralSubtrees |
|
| 24 | - */ |
|
| 25 | - protected $_permitted; |
|
| 20 | + /** |
|
| 21 | + * Permitted subtrees. |
|
| 22 | + * |
|
| 23 | + * @var null|GeneralSubtrees |
|
| 24 | + */ |
|
| 25 | + protected $_permitted; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Excluded subtrees. |
|
| 29 | - * |
|
| 30 | - * @var null|GeneralSubtrees |
|
| 31 | - */ |
|
| 32 | - protected $_excluded; |
|
| 27 | + /** |
|
| 28 | + * Excluded subtrees. |
|
| 29 | + * |
|
| 30 | + * @var null|GeneralSubtrees |
|
| 31 | + */ |
|
| 32 | + protected $_excluded; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Constructor. |
|
| 36 | - * |
|
| 37 | - * @param bool $critical |
|
| 38 | - * @param GeneralSubtrees $permitted |
|
| 39 | - * @param GeneralSubtrees $excluded |
|
| 40 | - */ |
|
| 41 | - public function __construct(bool $critical, ?GeneralSubtrees $permitted = null, |
|
| 42 | - ?GeneralSubtrees $excluded = null) |
|
| 43 | - { |
|
| 44 | - parent::__construct(self::OID_NAME_CONSTRAINTS, $critical); |
|
| 45 | - $this->_permitted = $permitted; |
|
| 46 | - $this->_excluded = $excluded; |
|
| 47 | - } |
|
| 34 | + /** |
|
| 35 | + * Constructor. |
|
| 36 | + * |
|
| 37 | + * @param bool $critical |
|
| 38 | + * @param GeneralSubtrees $permitted |
|
| 39 | + * @param GeneralSubtrees $excluded |
|
| 40 | + */ |
|
| 41 | + public function __construct(bool $critical, ?GeneralSubtrees $permitted = null, |
|
| 42 | + ?GeneralSubtrees $excluded = null) |
|
| 43 | + { |
|
| 44 | + parent::__construct(self::OID_NAME_CONSTRAINTS, $critical); |
|
| 45 | + $this->_permitted = $permitted; |
|
| 46 | + $this->_excluded = $excluded; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Whether permitted subtrees are present. |
|
| 51 | - * |
|
| 52 | - * @return bool |
|
| 53 | - */ |
|
| 54 | - public function hasPermittedSubtrees(): bool |
|
| 55 | - { |
|
| 56 | - return isset($this->_permitted); |
|
| 57 | - } |
|
| 49 | + /** |
|
| 50 | + * Whether permitted subtrees are present. |
|
| 51 | + * |
|
| 52 | + * @return bool |
|
| 53 | + */ |
|
| 54 | + public function hasPermittedSubtrees(): bool |
|
| 55 | + { |
|
| 56 | + return isset($this->_permitted); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Get permitted subtrees. |
|
| 61 | - * |
|
| 62 | - * @throws \LogicException If not set |
|
| 63 | - * |
|
| 64 | - * @return GeneralSubtrees |
|
| 65 | - */ |
|
| 66 | - public function permittedSubtrees(): GeneralSubtrees |
|
| 67 | - { |
|
| 68 | - if (!$this->hasPermittedSubtrees()) { |
|
| 69 | - throw new \LogicException('No permitted subtrees.'); |
|
| 70 | - } |
|
| 71 | - return $this->_permitted; |
|
| 72 | - } |
|
| 59 | + /** |
|
| 60 | + * Get permitted subtrees. |
|
| 61 | + * |
|
| 62 | + * @throws \LogicException If not set |
|
| 63 | + * |
|
| 64 | + * @return GeneralSubtrees |
|
| 65 | + */ |
|
| 66 | + public function permittedSubtrees(): GeneralSubtrees |
|
| 67 | + { |
|
| 68 | + if (!$this->hasPermittedSubtrees()) { |
|
| 69 | + throw new \LogicException('No permitted subtrees.'); |
|
| 70 | + } |
|
| 71 | + return $this->_permitted; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Whether excluded subtrees are present. |
|
| 76 | - * |
|
| 77 | - * @return bool |
|
| 78 | - */ |
|
| 79 | - public function hasExcludedSubtrees(): bool |
|
| 80 | - { |
|
| 81 | - return isset($this->_excluded); |
|
| 82 | - } |
|
| 74 | + /** |
|
| 75 | + * Whether excluded subtrees are present. |
|
| 76 | + * |
|
| 77 | + * @return bool |
|
| 78 | + */ |
|
| 79 | + public function hasExcludedSubtrees(): bool |
|
| 80 | + { |
|
| 81 | + return isset($this->_excluded); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Get excluded subtrees. |
|
| 86 | - * |
|
| 87 | - * @throws \LogicException If not set |
|
| 88 | - * |
|
| 89 | - * @return GeneralSubtrees |
|
| 90 | - */ |
|
| 91 | - public function excludedSubtrees(): GeneralSubtrees |
|
| 92 | - { |
|
| 93 | - if (!$this->hasExcludedSubtrees()) { |
|
| 94 | - throw new \LogicException('No excluded subtrees.'); |
|
| 95 | - } |
|
| 96 | - return $this->_excluded; |
|
| 97 | - } |
|
| 84 | + /** |
|
| 85 | + * Get excluded subtrees. |
|
| 86 | + * |
|
| 87 | + * @throws \LogicException If not set |
|
| 88 | + * |
|
| 89 | + * @return GeneralSubtrees |
|
| 90 | + */ |
|
| 91 | + public function excludedSubtrees(): GeneralSubtrees |
|
| 92 | + { |
|
| 93 | + if (!$this->hasExcludedSubtrees()) { |
|
| 94 | + throw new \LogicException('No excluded subtrees.'); |
|
| 95 | + } |
|
| 96 | + return $this->_excluded; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * {@inheritdoc} |
|
| 101 | - */ |
|
| 102 | - protected static function _fromDER(string $data, bool $critical): Extension |
|
| 103 | - { |
|
| 104 | - $seq = UnspecifiedType::fromDER($data)->asSequence(); |
|
| 105 | - $permitted = null; |
|
| 106 | - $excluded = null; |
|
| 107 | - if ($seq->hasTagged(0)) { |
|
| 108 | - $permitted = GeneralSubtrees::fromASN1( |
|
| 109 | - $seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)->asSequence()); |
|
| 110 | - } |
|
| 111 | - if ($seq->hasTagged(1)) { |
|
| 112 | - $excluded = GeneralSubtrees::fromASN1( |
|
| 113 | - $seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)->asSequence()); |
|
| 114 | - } |
|
| 115 | - return new self($critical, $permitted, $excluded); |
|
| 116 | - } |
|
| 99 | + /** |
|
| 100 | + * {@inheritdoc} |
|
| 101 | + */ |
|
| 102 | + protected static function _fromDER(string $data, bool $critical): Extension |
|
| 103 | + { |
|
| 104 | + $seq = UnspecifiedType::fromDER($data)->asSequence(); |
|
| 105 | + $permitted = null; |
|
| 106 | + $excluded = null; |
|
| 107 | + if ($seq->hasTagged(0)) { |
|
| 108 | + $permitted = GeneralSubtrees::fromASN1( |
|
| 109 | + $seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)->asSequence()); |
|
| 110 | + } |
|
| 111 | + if ($seq->hasTagged(1)) { |
|
| 112 | + $excluded = GeneralSubtrees::fromASN1( |
|
| 113 | + $seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)->asSequence()); |
|
| 114 | + } |
|
| 115 | + return new self($critical, $permitted, $excluded); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * {@inheritdoc} |
|
| 120 | - */ |
|
| 121 | - protected function _valueASN1(): Element |
|
| 122 | - { |
|
| 123 | - $elements = []; |
|
| 124 | - if (isset($this->_permitted)) { |
|
| 125 | - $elements[] = new ImplicitlyTaggedType(0, $this->_permitted->toASN1()); |
|
| 126 | - } |
|
| 127 | - if (isset($this->_excluded)) { |
|
| 128 | - $elements[] = new ImplicitlyTaggedType(1, $this->_excluded->toASN1()); |
|
| 129 | - } |
|
| 130 | - return new Sequence(...$elements); |
|
| 131 | - } |
|
| 118 | + /** |
|
| 119 | + * {@inheritdoc} |
|
| 120 | + */ |
|
| 121 | + protected function _valueASN1(): Element |
|
| 122 | + { |
|
| 123 | + $elements = []; |
|
| 124 | + if (isset($this->_permitted)) { |
|
| 125 | + $elements[] = new ImplicitlyTaggedType(0, $this->_permitted->toASN1()); |
|
| 126 | + } |
|
| 127 | + if (isset($this->_excluded)) { |
|
| 128 | + $elements[] = new ImplicitlyTaggedType(1, $this->_excluded->toASN1()); |
|
| 129 | + } |
|
| 130 | + return new Sequence(...$elements); |
|
| 131 | + } |
|
| 132 | 132 | } |
@@ -16,57 +16,57 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class TargetName extends Target |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Name. |
|
| 21 | - * |
|
| 22 | - * @var GeneralName |
|
| 23 | - */ |
|
| 24 | - protected $_name; |
|
| 19 | + /** |
|
| 20 | + * Name. |
|
| 21 | + * |
|
| 22 | + * @var GeneralName |
|
| 23 | + */ |
|
| 24 | + protected $_name; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Constructor. |
|
| 28 | - * |
|
| 29 | - * @param GeneralName $name |
|
| 30 | - */ |
|
| 31 | - public function __construct(GeneralName $name) |
|
| 32 | - { |
|
| 33 | - $this->_name = $name; |
|
| 34 | - $this->_type = self::TYPE_NAME; |
|
| 35 | - } |
|
| 26 | + /** |
|
| 27 | + * Constructor. |
|
| 28 | + * |
|
| 29 | + * @param GeneralName $name |
|
| 30 | + */ |
|
| 31 | + public function __construct(GeneralName $name) |
|
| 32 | + { |
|
| 33 | + $this->_name = $name; |
|
| 34 | + $this->_type = self::TYPE_NAME; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * {@inheritdoc} |
|
| 39 | - * |
|
| 40 | - * @return self |
|
| 41 | - */ |
|
| 42 | - public static function fromChosenASN1(TaggedType $el): Target |
|
| 43 | - { |
|
| 44 | - return new self(GeneralName::fromASN1($el)); |
|
| 45 | - } |
|
| 37 | + /** |
|
| 38 | + * {@inheritdoc} |
|
| 39 | + * |
|
| 40 | + * @return self |
|
| 41 | + */ |
|
| 42 | + public static function fromChosenASN1(TaggedType $el): Target |
|
| 43 | + { |
|
| 44 | + return new self(GeneralName::fromASN1($el)); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * {@inheritdoc} |
|
| 49 | - */ |
|
| 50 | - public function string(): string |
|
| 51 | - { |
|
| 52 | - return $this->_name->string(); |
|
| 53 | - } |
|
| 47 | + /** |
|
| 48 | + * {@inheritdoc} |
|
| 49 | + */ |
|
| 50 | + public function string(): string |
|
| 51 | + { |
|
| 52 | + return $this->_name->string(); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Get name. |
|
| 57 | - * |
|
| 58 | - * @return GeneralName |
|
| 59 | - */ |
|
| 60 | - public function name(): GeneralName |
|
| 61 | - { |
|
| 62 | - return $this->_name; |
|
| 63 | - } |
|
| 55 | + /** |
|
| 56 | + * Get name. |
|
| 57 | + * |
|
| 58 | + * @return GeneralName |
|
| 59 | + */ |
|
| 60 | + public function name(): GeneralName |
|
| 61 | + { |
|
| 62 | + return $this->_name; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * {@inheritdoc} |
|
| 67 | - */ |
|
| 68 | - public function toASN1(): Element |
|
| 69 | - { |
|
| 70 | - return new ExplicitlyTaggedType($this->_type, $this->_name->toASN1()); |
|
| 71 | - } |
|
| 65 | + /** |
|
| 66 | + * {@inheritdoc} |
|
| 67 | + */ |
|
| 68 | + public function toASN1(): Element |
|
| 69 | + { |
|
| 70 | + return new ExplicitlyTaggedType($this->_type, $this->_name->toASN1()); |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -16,57 +16,57 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class TargetGroup extends Target |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Group name. |
|
| 21 | - * |
|
| 22 | - * @var GeneralName |
|
| 23 | - */ |
|
| 24 | - protected $_name; |
|
| 19 | + /** |
|
| 20 | + * Group name. |
|
| 21 | + * |
|
| 22 | + * @var GeneralName |
|
| 23 | + */ |
|
| 24 | + protected $_name; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Constructor. |
|
| 28 | - * |
|
| 29 | - * @param GeneralName $name |
|
| 30 | - */ |
|
| 31 | - public function __construct(GeneralName $name) |
|
| 32 | - { |
|
| 33 | - $this->_name = $name; |
|
| 34 | - $this->_type = self::TYPE_GROUP; |
|
| 35 | - } |
|
| 26 | + /** |
|
| 27 | + * Constructor. |
|
| 28 | + * |
|
| 29 | + * @param GeneralName $name |
|
| 30 | + */ |
|
| 31 | + public function __construct(GeneralName $name) |
|
| 32 | + { |
|
| 33 | + $this->_name = $name; |
|
| 34 | + $this->_type = self::TYPE_GROUP; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * {@inheritdoc} |
|
| 39 | - * |
|
| 40 | - * @return self |
|
| 41 | - */ |
|
| 42 | - public static function fromChosenASN1(TaggedType $el): Target |
|
| 43 | - { |
|
| 44 | - return new self(GeneralName::fromASN1($el)); |
|
| 45 | - } |
|
| 37 | + /** |
|
| 38 | + * {@inheritdoc} |
|
| 39 | + * |
|
| 40 | + * @return self |
|
| 41 | + */ |
|
| 42 | + public static function fromChosenASN1(TaggedType $el): Target |
|
| 43 | + { |
|
| 44 | + return new self(GeneralName::fromASN1($el)); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * {@inheritdoc} |
|
| 49 | - */ |
|
| 50 | - public function string(): string |
|
| 51 | - { |
|
| 52 | - return $this->_name->string(); |
|
| 53 | - } |
|
| 47 | + /** |
|
| 48 | + * {@inheritdoc} |
|
| 49 | + */ |
|
| 50 | + public function string(): string |
|
| 51 | + { |
|
| 52 | + return $this->_name->string(); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Get group name. |
|
| 57 | - * |
|
| 58 | - * @return GeneralName |
|
| 59 | - */ |
|
| 60 | - public function name(): GeneralName |
|
| 61 | - { |
|
| 62 | - return $this->_name; |
|
| 63 | - } |
|
| 55 | + /** |
|
| 56 | + * Get group name. |
|
| 57 | + * |
|
| 58 | + * @return GeneralName |
|
| 59 | + */ |
|
| 60 | + public function name(): GeneralName |
|
| 61 | + { |
|
| 62 | + return $this->_name; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * {@inheritdoc} |
|
| 67 | - */ |
|
| 68 | - public function toASN1(): Element |
|
| 69 | - { |
|
| 70 | - return new ExplicitlyTaggedType($this->_type, $this->_name->toASN1()); |
|
| 71 | - } |
|
| 65 | + /** |
|
| 66 | + * {@inheritdoc} |
|
| 67 | + */ |
|
| 68 | + public function toASN1(): Element |
|
| 69 | + { |
|
| 70 | + return new ExplicitlyTaggedType($this->_type, $this->_name->toASN1()); |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -14,92 +14,92 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | abstract class Target |
| 16 | 16 | { |
| 17 | - const TYPE_NAME = 0; |
|
| 18 | - const TYPE_GROUP = 1; |
|
| 19 | - const TYPE_CERT = 2; |
|
| 17 | + const TYPE_NAME = 0; |
|
| 18 | + const TYPE_GROUP = 1; |
|
| 19 | + const TYPE_CERT = 2; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Type tag. |
|
| 23 | - * |
|
| 24 | - * @var int |
|
| 25 | - */ |
|
| 26 | - protected $_type; |
|
| 21 | + /** |
|
| 22 | + * Type tag. |
|
| 23 | + * |
|
| 24 | + * @var int |
|
| 25 | + */ |
|
| 26 | + protected $_type; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Generate ASN.1 element. |
|
| 30 | - * |
|
| 31 | - * @return Element |
|
| 32 | - */ |
|
| 33 | - abstract public function toASN1(): Element; |
|
| 28 | + /** |
|
| 29 | + * Generate ASN.1 element. |
|
| 30 | + * |
|
| 31 | + * @return Element |
|
| 32 | + */ |
|
| 33 | + abstract public function toASN1(): Element; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Get string value of the target. |
|
| 37 | - * |
|
| 38 | - * @return string |
|
| 39 | - */ |
|
| 40 | - abstract public function string(): string; |
|
| 35 | + /** |
|
| 36 | + * Get string value of the target. |
|
| 37 | + * |
|
| 38 | + * @return string |
|
| 39 | + */ |
|
| 40 | + abstract public function string(): string; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Initialize concrete object from the chosen ASN.1 element. |
|
| 44 | - * |
|
| 45 | - * @param TaggedType $el |
|
| 46 | - * |
|
| 47 | - * @return self |
|
| 48 | - */ |
|
| 49 | - public static function fromChosenASN1(TaggedType $el): Target |
|
| 50 | - { |
|
| 51 | - throw new \BadMethodCallException( |
|
| 52 | - __FUNCTION__ . ' must be implemented in the derived class.'); |
|
| 53 | - } |
|
| 42 | + /** |
|
| 43 | + * Initialize concrete object from the chosen ASN.1 element. |
|
| 44 | + * |
|
| 45 | + * @param TaggedType $el |
|
| 46 | + * |
|
| 47 | + * @return self |
|
| 48 | + */ |
|
| 49 | + public static function fromChosenASN1(TaggedType $el): Target |
|
| 50 | + { |
|
| 51 | + throw new \BadMethodCallException( |
|
| 52 | + __FUNCTION__ . ' must be implemented in the derived class.'); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Parse from ASN.1. |
|
| 57 | - * |
|
| 58 | - * @param TaggedType $el |
|
| 59 | - * |
|
| 60 | - * @throws \UnexpectedValueException |
|
| 61 | - * |
|
| 62 | - * @return self |
|
| 63 | - */ |
|
| 64 | - public static function fromASN1(TaggedType $el): self |
|
| 65 | - { |
|
| 66 | - switch ($el->tag()) { |
|
| 67 | - case self::TYPE_NAME: |
|
| 68 | - return TargetName::fromChosenASN1($el->asExplicit()->asTagged()); |
|
| 69 | - case self::TYPE_GROUP: |
|
| 70 | - return TargetGroup::fromChosenASN1($el->asExplicit()->asTagged()); |
|
| 71 | - case self::TYPE_CERT: |
|
| 72 | - throw new \RuntimeException('targetCert not supported.'); |
|
| 73 | - } |
|
| 74 | - throw new \UnexpectedValueException( |
|
| 75 | - 'Target type ' . $el->tag() . ' not supported.'); |
|
| 76 | - } |
|
| 55 | + /** |
|
| 56 | + * Parse from ASN.1. |
|
| 57 | + * |
|
| 58 | + * @param TaggedType $el |
|
| 59 | + * |
|
| 60 | + * @throws \UnexpectedValueException |
|
| 61 | + * |
|
| 62 | + * @return self |
|
| 63 | + */ |
|
| 64 | + public static function fromASN1(TaggedType $el): self |
|
| 65 | + { |
|
| 66 | + switch ($el->tag()) { |
|
| 67 | + case self::TYPE_NAME: |
|
| 68 | + return TargetName::fromChosenASN1($el->asExplicit()->asTagged()); |
|
| 69 | + case self::TYPE_GROUP: |
|
| 70 | + return TargetGroup::fromChosenASN1($el->asExplicit()->asTagged()); |
|
| 71 | + case self::TYPE_CERT: |
|
| 72 | + throw new \RuntimeException('targetCert not supported.'); |
|
| 73 | + } |
|
| 74 | + throw new \UnexpectedValueException( |
|
| 75 | + 'Target type ' . $el->tag() . ' not supported.'); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Get type tag. |
|
| 80 | - * |
|
| 81 | - * @return int |
|
| 82 | - */ |
|
| 83 | - public function type(): int |
|
| 84 | - { |
|
| 85 | - return $this->_type; |
|
| 86 | - } |
|
| 78 | + /** |
|
| 79 | + * Get type tag. |
|
| 80 | + * |
|
| 81 | + * @return int |
|
| 82 | + */ |
|
| 83 | + public function type(): int |
|
| 84 | + { |
|
| 85 | + return $this->_type; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Check whether target is equal to another. |
|
| 90 | - * |
|
| 91 | - * @param Target $other |
|
| 92 | - * |
|
| 93 | - * @return bool |
|
| 94 | - */ |
|
| 95 | - public function equals(Target $other): bool |
|
| 96 | - { |
|
| 97 | - if ($this->_type !== $other->_type) { |
|
| 98 | - return false; |
|
| 99 | - } |
|
| 100 | - if ($this->toASN1()->toDER() !== $other->toASN1()->toDER()) { |
|
| 101 | - return false; |
|
| 102 | - } |
|
| 103 | - return true; |
|
| 104 | - } |
|
| 88 | + /** |
|
| 89 | + * Check whether target is equal to another. |
|
| 90 | + * |
|
| 91 | + * @param Target $other |
|
| 92 | + * |
|
| 93 | + * @return bool |
|
| 94 | + */ |
|
| 95 | + public function equals(Target $other): bool |
|
| 96 | + { |
|
| 97 | + if ($this->_type !== $other->_type) { |
|
| 98 | + return false; |
|
| 99 | + } |
|
| 100 | + if ($this->toASN1()->toDER() !== $other->toASN1()->toDER()) { |
|
| 101 | + return false; |
|
| 102 | + } |
|
| 103 | + return true; |
|
| 104 | + } |
|
| 105 | 105 | } |