@@ -18,170 +18,170 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class AuthorityKeyIdentifierExtension extends Extension |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Key identifier. |
|
| 23 | - * |
|
| 24 | - * @var string|null $_keyIdentifier |
|
| 25 | - */ |
|
| 26 | - protected $_keyIdentifier; |
|
| 21 | + /** |
|
| 22 | + * Key identifier. |
|
| 23 | + * |
|
| 24 | + * @var string|null $_keyIdentifier |
|
| 25 | + */ |
|
| 26 | + protected $_keyIdentifier; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Issuer name. |
|
| 30 | - * |
|
| 31 | - * @var GeneralNames|null $_authorityCertIssuer |
|
| 32 | - */ |
|
| 33 | - protected $_authorityCertIssuer; |
|
| 28 | + /** |
|
| 29 | + * Issuer name. |
|
| 30 | + * |
|
| 31 | + * @var GeneralNames|null $_authorityCertIssuer |
|
| 32 | + */ |
|
| 33 | + protected $_authorityCertIssuer; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Issuer serial number. |
|
| 37 | - * |
|
| 38 | - * @var string|null $_authorityCertSerialNumber |
|
| 39 | - */ |
|
| 40 | - protected $_authorityCertSerialNumber; |
|
| 35 | + /** |
|
| 36 | + * Issuer serial number. |
|
| 37 | + * |
|
| 38 | + * @var string|null $_authorityCertSerialNumber |
|
| 39 | + */ |
|
| 40 | + protected $_authorityCertSerialNumber; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Constructor. |
|
| 44 | - * |
|
| 45 | - * @param bool $critical Conforming CA's must mark as non-critical (false) |
|
| 46 | - * @param string|null $keyIdentifier |
|
| 47 | - * @param GeneralNames|null $issuer |
|
| 48 | - * @param string|null $serial |
|
| 49 | - */ |
|
| 50 | - public function __construct(bool $critical, $keyIdentifier, |
|
| 51 | - GeneralNames $issuer = null, $serial = null) |
|
| 52 | - { |
|
| 53 | - parent::__construct(self::OID_AUTHORITY_KEY_IDENTIFIER, $critical); |
|
| 54 | - $this->_keyIdentifier = $keyIdentifier; |
|
| 55 | - $this->_authorityCertIssuer = $issuer; |
|
| 56 | - $this->_authorityCertSerialNumber = isset($serial) ? strval($serial) : null; |
|
| 57 | - } |
|
| 42 | + /** |
|
| 43 | + * Constructor. |
|
| 44 | + * |
|
| 45 | + * @param bool $critical Conforming CA's must mark as non-critical (false) |
|
| 46 | + * @param string|null $keyIdentifier |
|
| 47 | + * @param GeneralNames|null $issuer |
|
| 48 | + * @param string|null $serial |
|
| 49 | + */ |
|
| 50 | + public function __construct(bool $critical, $keyIdentifier, |
|
| 51 | + GeneralNames $issuer = null, $serial = null) |
|
| 52 | + { |
|
| 53 | + parent::__construct(self::OID_AUTHORITY_KEY_IDENTIFIER, $critical); |
|
| 54 | + $this->_keyIdentifier = $keyIdentifier; |
|
| 55 | + $this->_authorityCertIssuer = $issuer; |
|
| 56 | + $this->_authorityCertSerialNumber = isset($serial) ? strval($serial) : null; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * |
|
| 61 | - * {@inheritdoc} |
|
| 62 | - * @return self |
|
| 63 | - */ |
|
| 64 | - protected static function _fromDER(string $data, bool $critical): self |
|
| 65 | - { |
|
| 66 | - $seq = Sequence::fromDER($data); |
|
| 67 | - $keyIdentifier = null; |
|
| 68 | - $issuer = null; |
|
| 69 | - $serial = null; |
|
| 70 | - if ($seq->hasTagged(0)) { |
|
| 71 | - $keyIdentifier = $seq->getTagged(0) |
|
| 72 | - ->asImplicit(Element::TYPE_OCTET_STRING) |
|
| 73 | - ->asOctetString() |
|
| 74 | - ->string(); |
|
| 75 | - } |
|
| 76 | - if ($seq->hasTagged(1) || $seq->hasTagged(2)) { |
|
| 77 | - if (!$seq->hasTagged(1) || !$seq->hasTagged(2)) { |
|
| 78 | - throw new \UnexpectedValueException( |
|
| 79 | - "AuthorityKeyIdentifier must have both" . |
|
| 80 | - " authorityCertIssuer and authorityCertSerialNumber" . |
|
| 81 | - " present or both absent."); |
|
| 82 | - } |
|
| 83 | - $issuer = GeneralNames::fromASN1( |
|
| 84 | - $seq->getTagged(1) |
|
| 85 | - ->asImplicit(Element::TYPE_SEQUENCE) |
|
| 86 | - ->asSequence()); |
|
| 87 | - $serial = $seq->getTagged(2) |
|
| 88 | - ->asImplicit(Element::TYPE_INTEGER) |
|
| 89 | - ->asInteger() |
|
| 90 | - ->number(); |
|
| 91 | - } |
|
| 92 | - return new self($critical, $keyIdentifier, $issuer, $serial); |
|
| 93 | - } |
|
| 59 | + /** |
|
| 60 | + * |
|
| 61 | + * {@inheritdoc} |
|
| 62 | + * @return self |
|
| 63 | + */ |
|
| 64 | + protected static function _fromDER(string $data, bool $critical): self |
|
| 65 | + { |
|
| 66 | + $seq = Sequence::fromDER($data); |
|
| 67 | + $keyIdentifier = null; |
|
| 68 | + $issuer = null; |
|
| 69 | + $serial = null; |
|
| 70 | + if ($seq->hasTagged(0)) { |
|
| 71 | + $keyIdentifier = $seq->getTagged(0) |
|
| 72 | + ->asImplicit(Element::TYPE_OCTET_STRING) |
|
| 73 | + ->asOctetString() |
|
| 74 | + ->string(); |
|
| 75 | + } |
|
| 76 | + if ($seq->hasTagged(1) || $seq->hasTagged(2)) { |
|
| 77 | + if (!$seq->hasTagged(1) || !$seq->hasTagged(2)) { |
|
| 78 | + throw new \UnexpectedValueException( |
|
| 79 | + "AuthorityKeyIdentifier must have both" . |
|
| 80 | + " authorityCertIssuer and authorityCertSerialNumber" . |
|
| 81 | + " present or both absent."); |
|
| 82 | + } |
|
| 83 | + $issuer = GeneralNames::fromASN1( |
|
| 84 | + $seq->getTagged(1) |
|
| 85 | + ->asImplicit(Element::TYPE_SEQUENCE) |
|
| 86 | + ->asSequence()); |
|
| 87 | + $serial = $seq->getTagged(2) |
|
| 88 | + ->asImplicit(Element::TYPE_INTEGER) |
|
| 89 | + ->asInteger() |
|
| 90 | + ->number(); |
|
| 91 | + } |
|
| 92 | + return new self($critical, $keyIdentifier, $issuer, $serial); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Whether key identifier is present. |
|
| 97 | - * |
|
| 98 | - * @return bool |
|
| 99 | - */ |
|
| 100 | - public function hasKeyIdentifier(): bool |
|
| 101 | - { |
|
| 102 | - return isset($this->_keyIdentifier); |
|
| 103 | - } |
|
| 95 | + /** |
|
| 96 | + * Whether key identifier is present. |
|
| 97 | + * |
|
| 98 | + * @return bool |
|
| 99 | + */ |
|
| 100 | + public function hasKeyIdentifier(): bool |
|
| 101 | + { |
|
| 102 | + return isset($this->_keyIdentifier); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Get key identifier. |
|
| 107 | - * |
|
| 108 | - * @throws \LogicException |
|
| 109 | - * @return string |
|
| 110 | - */ |
|
| 111 | - public function keyIdentifier(): string |
|
| 112 | - { |
|
| 113 | - if (!$this->hasKeyIdentifier()) { |
|
| 114 | - throw new \LogicException("keyIdentifier not set."); |
|
| 115 | - } |
|
| 116 | - return $this->_keyIdentifier; |
|
| 117 | - } |
|
| 105 | + /** |
|
| 106 | + * Get key identifier. |
|
| 107 | + * |
|
| 108 | + * @throws \LogicException |
|
| 109 | + * @return string |
|
| 110 | + */ |
|
| 111 | + public function keyIdentifier(): string |
|
| 112 | + { |
|
| 113 | + if (!$this->hasKeyIdentifier()) { |
|
| 114 | + throw new \LogicException("keyIdentifier not set."); |
|
| 115 | + } |
|
| 116 | + return $this->_keyIdentifier; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Whether issuer is present. |
|
| 121 | - * |
|
| 122 | - * @return bool |
|
| 123 | - */ |
|
| 124 | - public function hasIssuer(): bool |
|
| 125 | - { |
|
| 126 | - return isset($this->_authorityCertIssuer); |
|
| 127 | - } |
|
| 119 | + /** |
|
| 120 | + * Whether issuer is present. |
|
| 121 | + * |
|
| 122 | + * @return bool |
|
| 123 | + */ |
|
| 124 | + public function hasIssuer(): bool |
|
| 125 | + { |
|
| 126 | + return isset($this->_authorityCertIssuer); |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Get issuer. |
|
| 131 | - * |
|
| 132 | - * @throws \LogicException |
|
| 133 | - * @return GeneralNames |
|
| 134 | - */ |
|
| 135 | - public function issuer(): GeneralNames |
|
| 136 | - { |
|
| 137 | - if (!$this->hasIssuer()) { |
|
| 138 | - throw new \LogicException("authorityCertIssuer not set."); |
|
| 139 | - } |
|
| 140 | - return $this->_authorityCertIssuer; |
|
| 141 | - } |
|
| 129 | + /** |
|
| 130 | + * Get issuer. |
|
| 131 | + * |
|
| 132 | + * @throws \LogicException |
|
| 133 | + * @return GeneralNames |
|
| 134 | + */ |
|
| 135 | + public function issuer(): GeneralNames |
|
| 136 | + { |
|
| 137 | + if (!$this->hasIssuer()) { |
|
| 138 | + throw new \LogicException("authorityCertIssuer not set."); |
|
| 139 | + } |
|
| 140 | + return $this->_authorityCertIssuer; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * Get serial number. |
|
| 145 | - * |
|
| 146 | - * @throws \LogicException |
|
| 147 | - * @return string Base 10 integer string |
|
| 148 | - */ |
|
| 149 | - public function serial(): string |
|
| 150 | - { |
|
| 151 | - // both issuer and serial must be present or both absent |
|
| 152 | - if (!$this->hasIssuer()) { |
|
| 153 | - throw new \LogicException("authorityCertSerialNumber not set."); |
|
| 154 | - } |
|
| 155 | - return $this->_authorityCertSerialNumber; |
|
| 156 | - } |
|
| 143 | + /** |
|
| 144 | + * Get serial number. |
|
| 145 | + * |
|
| 146 | + * @throws \LogicException |
|
| 147 | + * @return string Base 10 integer string |
|
| 148 | + */ |
|
| 149 | + public function serial(): string |
|
| 150 | + { |
|
| 151 | + // both issuer and serial must be present or both absent |
|
| 152 | + if (!$this->hasIssuer()) { |
|
| 153 | + throw new \LogicException("authorityCertSerialNumber not set."); |
|
| 154 | + } |
|
| 155 | + return $this->_authorityCertSerialNumber; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * |
|
| 160 | - * {@inheritdoc} |
|
| 161 | - * @return Sequence |
|
| 162 | - */ |
|
| 163 | - protected function _valueASN1(): Sequence |
|
| 164 | - { |
|
| 165 | - $elements = array(); |
|
| 166 | - if (isset($this->_keyIdentifier)) { |
|
| 167 | - $elements[] = new ImplicitlyTaggedType(0, |
|
| 168 | - new OctetString($this->_keyIdentifier)); |
|
| 169 | - } |
|
| 170 | - // if either issuer or serial is set, both must be set |
|
| 171 | - if (isset($this->_authorityCertIssuer) || |
|
| 172 | - isset($this->_authorityCertSerialNumber)) { |
|
| 173 | - if (!isset($this->_authorityCertIssuer, |
|
| 174 | - $this->_authorityCertSerialNumber)) { |
|
| 175 | - throw new \LogicException( |
|
| 176 | - "AuthorityKeyIdentifier must have both" . |
|
| 177 | - " authorityCertIssuer and authorityCertSerialNumber" . |
|
| 178 | - " present or both absent."); |
|
| 179 | - } |
|
| 180 | - $elements[] = new ImplicitlyTaggedType(1, |
|
| 181 | - $this->_authorityCertIssuer->toASN1()); |
|
| 182 | - $elements[] = new ImplicitlyTaggedType(2, |
|
| 183 | - new Integer($this->_authorityCertSerialNumber)); |
|
| 184 | - } |
|
| 185 | - return new Sequence(...$elements); |
|
| 186 | - } |
|
| 158 | + /** |
|
| 159 | + * |
|
| 160 | + * {@inheritdoc} |
|
| 161 | + * @return Sequence |
|
| 162 | + */ |
|
| 163 | + protected function _valueASN1(): Sequence |
|
| 164 | + { |
|
| 165 | + $elements = array(); |
|
| 166 | + if (isset($this->_keyIdentifier)) { |
|
| 167 | + $elements[] = new ImplicitlyTaggedType(0, |
|
| 168 | + new OctetString($this->_keyIdentifier)); |
|
| 169 | + } |
|
| 170 | + // if either issuer or serial is set, both must be set |
|
| 171 | + if (isset($this->_authorityCertIssuer) || |
|
| 172 | + isset($this->_authorityCertSerialNumber)) { |
|
| 173 | + if (!isset($this->_authorityCertIssuer, |
|
| 174 | + $this->_authorityCertSerialNumber)) { |
|
| 175 | + throw new \LogicException( |
|
| 176 | + "AuthorityKeyIdentifier must have both" . |
|
| 177 | + " authorityCertIssuer and authorityCertSerialNumber" . |
|
| 178 | + " present or both absent."); |
|
| 179 | + } |
|
| 180 | + $elements[] = new ImplicitlyTaggedType(1, |
|
| 181 | + $this->_authorityCertIssuer->toASN1()); |
|
| 182 | + $elements[] = new ImplicitlyTaggedType(2, |
|
| 183 | + new Integer($this->_authorityCertSerialNumber)); |
|
| 184 | + } |
|
| 185 | + return new Sequence(...$elements); |
|
| 186 | + } |
|
| 187 | 187 | } |
@@ -14,53 +14,53 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class IssuerAlternativeNameExtension extends Extension |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Names. |
|
| 19 | - * |
|
| 20 | - * @var GeneralNames |
|
| 21 | - */ |
|
| 22 | - protected $_names; |
|
| 17 | + /** |
|
| 18 | + * Names. |
|
| 19 | + * |
|
| 20 | + * @var GeneralNames |
|
| 21 | + */ |
|
| 22 | + protected $_names; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Constructor. |
|
| 26 | - * |
|
| 27 | - * @param bool $critical |
|
| 28 | - * @param GeneralNames $names |
|
| 29 | - */ |
|
| 30 | - public function __construct(bool $critical, GeneralNames $names) |
|
| 31 | - { |
|
| 32 | - parent::__construct(self::OID_ISSUER_ALT_NAME, $critical); |
|
| 33 | - $this->_names = $names; |
|
| 34 | - } |
|
| 24 | + /** |
|
| 25 | + * Constructor. |
|
| 26 | + * |
|
| 27 | + * @param bool $critical |
|
| 28 | + * @param GeneralNames $names |
|
| 29 | + */ |
|
| 30 | + public function __construct(bool $critical, GeneralNames $names) |
|
| 31 | + { |
|
| 32 | + parent::__construct(self::OID_ISSUER_ALT_NAME, $critical); |
|
| 33 | + $this->_names = $names; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * |
|
| 38 | - * {@inheritdoc} |
|
| 39 | - * @return self |
|
| 40 | - */ |
|
| 41 | - protected static function _fromDER(string $data, bool $critical) |
|
| 42 | - { |
|
| 43 | - return new self($critical, |
|
| 44 | - GeneralNames::fromASN1(Sequence::fromDER($data))); |
|
| 45 | - } |
|
| 36 | + /** |
|
| 37 | + * |
|
| 38 | + * {@inheritdoc} |
|
| 39 | + * @return self |
|
| 40 | + */ |
|
| 41 | + protected static function _fromDER(string $data, bool $critical) |
|
| 42 | + { |
|
| 43 | + return new self($critical, |
|
| 44 | + GeneralNames::fromASN1(Sequence::fromDER($data))); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Get names. |
|
| 49 | - * |
|
| 50 | - * @return GeneralNames |
|
| 51 | - */ |
|
| 52 | - public function names(): GeneralNames |
|
| 53 | - { |
|
| 54 | - return $this->_names; |
|
| 55 | - } |
|
| 47 | + /** |
|
| 48 | + * Get names. |
|
| 49 | + * |
|
| 50 | + * @return GeneralNames |
|
| 51 | + */ |
|
| 52 | + public function names(): GeneralNames |
|
| 53 | + { |
|
| 54 | + return $this->_names; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * |
|
| 59 | - * {@inheritdoc} |
|
| 60 | - * @return Sequence |
|
| 61 | - */ |
|
| 62 | - protected function _valueASN1(): Sequence |
|
| 63 | - { |
|
| 64 | - return $this->_names->toASN1(); |
|
| 65 | - } |
|
| 57 | + /** |
|
| 58 | + * |
|
| 59 | + * {@inheritdoc} |
|
| 60 | + * @return Sequence |
|
| 61 | + */ |
|
| 62 | + protected function _valueASN1(): Sequence |
|
| 63 | + { |
|
| 64 | + return $this->_names->toASN1(); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -15,77 +15,77 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class PolicyMapping |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * OID of the issuer policy. |
|
| 20 | - * |
|
| 21 | - * @var string $_issuerDomainPolicy |
|
| 22 | - */ |
|
| 23 | - protected $_issuerDomainPolicy; |
|
| 18 | + /** |
|
| 19 | + * OID of the issuer policy. |
|
| 20 | + * |
|
| 21 | + * @var string $_issuerDomainPolicy |
|
| 22 | + */ |
|
| 23 | + protected $_issuerDomainPolicy; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * OID of the subject policy. |
|
| 27 | - * |
|
| 28 | - * @var string $_subjectDomainPolicy |
|
| 29 | - */ |
|
| 30 | - protected $_subjectDomainPolicy; |
|
| 25 | + /** |
|
| 26 | + * OID of the subject policy. |
|
| 27 | + * |
|
| 28 | + * @var string $_subjectDomainPolicy |
|
| 29 | + */ |
|
| 30 | + protected $_subjectDomainPolicy; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Constructor. |
|
| 34 | - * |
|
| 35 | - * @param string $issuer_policy OID of the issuer policy |
|
| 36 | - * @param string $subject_policy OID of the subject policy |
|
| 37 | - */ |
|
| 38 | - public function __construct(string $issuer_policy, string $subject_policy) |
|
| 39 | - { |
|
| 40 | - $this->_issuerDomainPolicy = $issuer_policy; |
|
| 41 | - $this->_subjectDomainPolicy = $subject_policy; |
|
| 42 | - } |
|
| 32 | + /** |
|
| 33 | + * Constructor. |
|
| 34 | + * |
|
| 35 | + * @param string $issuer_policy OID of the issuer policy |
|
| 36 | + * @param string $subject_policy OID of the subject policy |
|
| 37 | + */ |
|
| 38 | + public function __construct(string $issuer_policy, string $subject_policy) |
|
| 39 | + { |
|
| 40 | + $this->_issuerDomainPolicy = $issuer_policy; |
|
| 41 | + $this->_subjectDomainPolicy = $subject_policy; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Initialize from ASN.1. |
|
| 46 | - * |
|
| 47 | - * @param Sequence $seq |
|
| 48 | - * @return self |
|
| 49 | - */ |
|
| 50 | - public static function fromASN1(Sequence $seq): self |
|
| 51 | - { |
|
| 52 | - $issuer_policy = $seq->at(0) |
|
| 53 | - ->asObjectIdentifier() |
|
| 54 | - ->oid(); |
|
| 55 | - $subject_policy = $seq->at(1) |
|
| 56 | - ->asObjectIdentifier() |
|
| 57 | - ->oid(); |
|
| 58 | - return new self($issuer_policy, $subject_policy); |
|
| 59 | - } |
|
| 44 | + /** |
|
| 45 | + * Initialize from ASN.1. |
|
| 46 | + * |
|
| 47 | + * @param Sequence $seq |
|
| 48 | + * @return self |
|
| 49 | + */ |
|
| 50 | + public static function fromASN1(Sequence $seq): self |
|
| 51 | + { |
|
| 52 | + $issuer_policy = $seq->at(0) |
|
| 53 | + ->asObjectIdentifier() |
|
| 54 | + ->oid(); |
|
| 55 | + $subject_policy = $seq->at(1) |
|
| 56 | + ->asObjectIdentifier() |
|
| 57 | + ->oid(); |
|
| 58 | + return new self($issuer_policy, $subject_policy); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Get issuer domain policy. |
|
| 63 | - * |
|
| 64 | - * @return string OID in dotted format |
|
| 65 | - */ |
|
| 66 | - public function issuerDomainPolicy(): string |
|
| 67 | - { |
|
| 68 | - return $this->_issuerDomainPolicy; |
|
| 69 | - } |
|
| 61 | + /** |
|
| 62 | + * Get issuer domain policy. |
|
| 63 | + * |
|
| 64 | + * @return string OID in dotted format |
|
| 65 | + */ |
|
| 66 | + public function issuerDomainPolicy(): string |
|
| 67 | + { |
|
| 68 | + return $this->_issuerDomainPolicy; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Get subject domain policy. |
|
| 73 | - * |
|
| 74 | - * @return string OID in dotted format |
|
| 75 | - */ |
|
| 76 | - public function subjectDomainPolicy(): string |
|
| 77 | - { |
|
| 78 | - return $this->_subjectDomainPolicy; |
|
| 79 | - } |
|
| 71 | + /** |
|
| 72 | + * Get subject domain policy. |
|
| 73 | + * |
|
| 74 | + * @return string OID in dotted format |
|
| 75 | + */ |
|
| 76 | + public function subjectDomainPolicy(): string |
|
| 77 | + { |
|
| 78 | + return $this->_subjectDomainPolicy; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Generate ASN.1 structure. |
|
| 83 | - * |
|
| 84 | - * @return Sequence |
|
| 85 | - */ |
|
| 86 | - public function toASN1(): Sequence |
|
| 87 | - { |
|
| 88 | - return new Sequence(new ObjectIdentifier($this->_issuerDomainPolicy), |
|
| 89 | - new ObjectIdentifier($this->_subjectDomainPolicy)); |
|
| 90 | - } |
|
| 81 | + /** |
|
| 82 | + * Generate ASN.1 structure. |
|
| 83 | + * |
|
| 84 | + * @return Sequence |
|
| 85 | + */ |
|
| 86 | + public function toASN1(): Sequence |
|
| 87 | + { |
|
| 88 | + return new Sequence(new ObjectIdentifier($this->_issuerDomainPolicy), |
|
| 89 | + new ObjectIdentifier($this->_subjectDomainPolicy)); |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -14,53 +14,53 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class SubjectAlternativeNameExtension extends Extension |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Names. |
|
| 19 | - * |
|
| 20 | - * @var GeneralNames $_names |
|
| 21 | - */ |
|
| 22 | - protected $_names; |
|
| 17 | + /** |
|
| 18 | + * Names. |
|
| 19 | + * |
|
| 20 | + * @var GeneralNames $_names |
|
| 21 | + */ |
|
| 22 | + protected $_names; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Constructor. |
|
| 26 | - * |
|
| 27 | - * @param bool $critical |
|
| 28 | - * @param GeneralNames $names |
|
| 29 | - */ |
|
| 30 | - public function __construct(bool $critical, GeneralNames $names) |
|
| 31 | - { |
|
| 32 | - parent::__construct(self::OID_SUBJECT_ALT_NAME, $critical); |
|
| 33 | - $this->_names = $names; |
|
| 34 | - } |
|
| 24 | + /** |
|
| 25 | + * Constructor. |
|
| 26 | + * |
|
| 27 | + * @param bool $critical |
|
| 28 | + * @param GeneralNames $names |
|
| 29 | + */ |
|
| 30 | + public function __construct(bool $critical, GeneralNames $names) |
|
| 31 | + { |
|
| 32 | + parent::__construct(self::OID_SUBJECT_ALT_NAME, $critical); |
|
| 33 | + $this->_names = $names; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * |
|
| 38 | - * {@inheritdoc} |
|
| 39 | - * @return self |
|
| 40 | - */ |
|
| 41 | - protected static function _fromDER(string $data, bool $critical): self |
|
| 42 | - { |
|
| 43 | - return new self($critical, |
|
| 44 | - GeneralNames::fromASN1(Sequence::fromDER($data))); |
|
| 45 | - } |
|
| 36 | + /** |
|
| 37 | + * |
|
| 38 | + * {@inheritdoc} |
|
| 39 | + * @return self |
|
| 40 | + */ |
|
| 41 | + protected static function _fromDER(string $data, bool $critical): self |
|
| 42 | + { |
|
| 43 | + return new self($critical, |
|
| 44 | + GeneralNames::fromASN1(Sequence::fromDER($data))); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Get names. |
|
| 49 | - * |
|
| 50 | - * @return GeneralNames |
|
| 51 | - */ |
|
| 52 | - public function names(): GeneralNames |
|
| 53 | - { |
|
| 54 | - return $this->_names; |
|
| 55 | - } |
|
| 47 | + /** |
|
| 48 | + * Get names. |
|
| 49 | + * |
|
| 50 | + * @return GeneralNames |
|
| 51 | + */ |
|
| 52 | + public function names(): GeneralNames |
|
| 53 | + { |
|
| 54 | + return $this->_names; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * |
|
| 59 | - * {@inheritdoc} |
|
| 60 | - * @return Sequence |
|
| 61 | - */ |
|
| 62 | - protected function _valueASN1(): Sequence |
|
| 63 | - { |
|
| 64 | - return $this->_names->toASN1(); |
|
| 65 | - } |
|
| 57 | + /** |
|
| 58 | + * |
|
| 59 | + * {@inheritdoc} |
|
| 60 | + * @return Sequence |
|
| 61 | + */ |
|
| 62 | + protected function _valueASN1(): Sequence |
|
| 63 | + { |
|
| 64 | + return $this->_names->toASN1(); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -14,133 +14,133 @@ |
||
| 14 | 14 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.12 |
| 15 | 15 | */ |
| 16 | 16 | class ExtendedKeyUsageExtension extends Extension implements |
| 17 | - \Countable, |
|
| 18 | - \IteratorAggregate |
|
| 17 | + \Countable, |
|
| 18 | + \IteratorAggregate |
|
| 19 | 19 | { |
| 20 | - const OID_SERVER_AUTH = "1.3.6.1.5.5.7.3.1"; |
|
| 21 | - const OID_CLIENT_AUTH = "1.3.6.1.5.5.7.3.2"; |
|
| 22 | - const OID_CODE_SIGNING = "1.3.6.1.5.5.7.3.3"; |
|
| 23 | - const OID_EMAIL_PROTECTION = "1.3.6.1.5.5.7.3.4"; |
|
| 24 | - const OID_IPSEC_END_SYSTEM = "1.3.6.1.5.5.7.3.5"; |
|
| 25 | - const OID_IPSEC_TUNNEL = "1.3.6.1.5.5.7.3.6"; |
|
| 26 | - const OID_IPSEC_USER = "1.3.6.1.5.5.7.3.7"; |
|
| 27 | - const OID_TIME_STAMPING = "1.3.6.1.5.5.7.3.8"; |
|
| 28 | - const OID_OCSP_SIGNING = "1.3.6.1.5.5.7.3.9"; |
|
| 29 | - const OID_DVCS = "1.3.6.1.5.5.7.3.10"; |
|
| 30 | - const OID_SBGP_CERT_AA_SERVER_AUTH = "1.3.6.1.5.5.7.3.11"; |
|
| 31 | - const OID_SCVP_RESPONDER = "1.3.6.1.5.5.7.3.12"; |
|
| 32 | - const OID_EAP_OVER_PPP = "1.3.6.1.5.5.7.3.13"; |
|
| 33 | - const OID_EAP_OVER_LAN = "1.3.6.1.5.5.7.3.14"; |
|
| 34 | - const OID_SCVP_SERVER = "1.3.6.1.5.5.7.3.15"; |
|
| 35 | - const OID_SCVP_CLIENT = "1.3.6.1.5.5.7.3.16"; |
|
| 36 | - const OID_IPSEC_IKE = "1.3.6.1.5.5.7.3.17"; |
|
| 37 | - const OID_CAPWAP_AC = "1.3.6.1.5.5.7.3.18"; |
|
| 38 | - const OID_CAPWAP_WTP = "1.3.6.1.5.5.7.3.19"; |
|
| 39 | - const OID_SIP_DOMAIN = "1.3.6.1.5.5.7.3.20"; |
|
| 40 | - const OID_SECURE_SHELL_CLIENT = "1.3.6.1.5.5.7.3.21"; |
|
| 41 | - const OID_SECURE_SHELL_SERVER = "1.3.6.1.5.5.7.3.22"; |
|
| 42 | - const OID_SEND_ROUTER = "1.3.6.1.5.5.7.3.23"; |
|
| 43 | - const OID_SEND_PROXY = "1.3.6.1.5.5.7.3.24"; |
|
| 44 | - const OID_SEND_OWNER = "1.3.6.1.5.5.7.3.25"; |
|
| 45 | - const OID_SEND_PROXIED_OWNER = "1.3.6.1.5.5.7.3.26"; |
|
| 46 | - const OID_CMC_CA = "1.3.6.1.5.5.7.3.27"; |
|
| 47 | - const OID_CMC_RA = "1.3.6.1.5.5.7.3.28"; |
|
| 48 | - const OID_CMC_ARCHIVE = "1.3.6.1.5.5.7.3.29"; |
|
| 20 | + const OID_SERVER_AUTH = "1.3.6.1.5.5.7.3.1"; |
|
| 21 | + const OID_CLIENT_AUTH = "1.3.6.1.5.5.7.3.2"; |
|
| 22 | + const OID_CODE_SIGNING = "1.3.6.1.5.5.7.3.3"; |
|
| 23 | + const OID_EMAIL_PROTECTION = "1.3.6.1.5.5.7.3.4"; |
|
| 24 | + const OID_IPSEC_END_SYSTEM = "1.3.6.1.5.5.7.3.5"; |
|
| 25 | + const OID_IPSEC_TUNNEL = "1.3.6.1.5.5.7.3.6"; |
|
| 26 | + const OID_IPSEC_USER = "1.3.6.1.5.5.7.3.7"; |
|
| 27 | + const OID_TIME_STAMPING = "1.3.6.1.5.5.7.3.8"; |
|
| 28 | + const OID_OCSP_SIGNING = "1.3.6.1.5.5.7.3.9"; |
|
| 29 | + const OID_DVCS = "1.3.6.1.5.5.7.3.10"; |
|
| 30 | + const OID_SBGP_CERT_AA_SERVER_AUTH = "1.3.6.1.5.5.7.3.11"; |
|
| 31 | + const OID_SCVP_RESPONDER = "1.3.6.1.5.5.7.3.12"; |
|
| 32 | + const OID_EAP_OVER_PPP = "1.3.6.1.5.5.7.3.13"; |
|
| 33 | + const OID_EAP_OVER_LAN = "1.3.6.1.5.5.7.3.14"; |
|
| 34 | + const OID_SCVP_SERVER = "1.3.6.1.5.5.7.3.15"; |
|
| 35 | + const OID_SCVP_CLIENT = "1.3.6.1.5.5.7.3.16"; |
|
| 36 | + const OID_IPSEC_IKE = "1.3.6.1.5.5.7.3.17"; |
|
| 37 | + const OID_CAPWAP_AC = "1.3.6.1.5.5.7.3.18"; |
|
| 38 | + const OID_CAPWAP_WTP = "1.3.6.1.5.5.7.3.19"; |
|
| 39 | + const OID_SIP_DOMAIN = "1.3.6.1.5.5.7.3.20"; |
|
| 40 | + const OID_SECURE_SHELL_CLIENT = "1.3.6.1.5.5.7.3.21"; |
|
| 41 | + const OID_SECURE_SHELL_SERVER = "1.3.6.1.5.5.7.3.22"; |
|
| 42 | + const OID_SEND_ROUTER = "1.3.6.1.5.5.7.3.23"; |
|
| 43 | + const OID_SEND_PROXY = "1.3.6.1.5.5.7.3.24"; |
|
| 44 | + const OID_SEND_OWNER = "1.3.6.1.5.5.7.3.25"; |
|
| 45 | + const OID_SEND_PROXIED_OWNER = "1.3.6.1.5.5.7.3.26"; |
|
| 46 | + const OID_CMC_CA = "1.3.6.1.5.5.7.3.27"; |
|
| 47 | + const OID_CMC_RA = "1.3.6.1.5.5.7.3.28"; |
|
| 48 | + const OID_CMC_ARCHIVE = "1.3.6.1.5.5.7.3.29"; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Purpose OID's. |
|
| 52 | - * |
|
| 53 | - * @var string[] $_purposes |
|
| 54 | - */ |
|
| 55 | - protected $_purposes; |
|
| 50 | + /** |
|
| 51 | + * Purpose OID's. |
|
| 52 | + * |
|
| 53 | + * @var string[] $_purposes |
|
| 54 | + */ |
|
| 55 | + protected $_purposes; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Constructor. |
|
| 59 | - * |
|
| 60 | - * @param bool $critical |
|
| 61 | - * @param string[] $purposes |
|
| 62 | - */ |
|
| 63 | - public function __construct(bool $critical, string ...$purposes) |
|
| 64 | - { |
|
| 65 | - parent::__construct(self::OID_EXT_KEY_USAGE, $critical); |
|
| 66 | - $this->_purposes = $purposes; |
|
| 67 | - } |
|
| 57 | + /** |
|
| 58 | + * Constructor. |
|
| 59 | + * |
|
| 60 | + * @param bool $critical |
|
| 61 | + * @param string[] $purposes |
|
| 62 | + */ |
|
| 63 | + public function __construct(bool $critical, string ...$purposes) |
|
| 64 | + { |
|
| 65 | + parent::__construct(self::OID_EXT_KEY_USAGE, $critical); |
|
| 66 | + $this->_purposes = $purposes; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * |
|
| 71 | - * {@inheritdoc} |
|
| 72 | - * @return self |
|
| 73 | - */ |
|
| 74 | - protected static function _fromDER(string $data, bool $critical): self |
|
| 75 | - { |
|
| 76 | - $purposes = array_map( |
|
| 77 | - function (UnspecifiedType $el) { |
|
| 78 | - return $el->asObjectIdentifier()->oid(); |
|
| 79 | - }, Sequence::fromDER($data)->elements()); |
|
| 80 | - return new self($critical, ...$purposes); |
|
| 81 | - } |
|
| 69 | + /** |
|
| 70 | + * |
|
| 71 | + * {@inheritdoc} |
|
| 72 | + * @return self |
|
| 73 | + */ |
|
| 74 | + protected static function _fromDER(string $data, bool $critical): self |
|
| 75 | + { |
|
| 76 | + $purposes = array_map( |
|
| 77 | + function (UnspecifiedType $el) { |
|
| 78 | + return $el->asObjectIdentifier()->oid(); |
|
| 79 | + }, Sequence::fromDER($data)->elements()); |
|
| 80 | + return new self($critical, ...$purposes); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Whether purposes are present. |
|
| 85 | - * |
|
| 86 | - * If multiple purposes are checked, all must be present. |
|
| 87 | - * |
|
| 88 | - * @param string[] $oids |
|
| 89 | - * @return bool |
|
| 90 | - */ |
|
| 91 | - public function has(string ...$oids): bool |
|
| 92 | - { |
|
| 93 | - foreach ($oids as $oid) { |
|
| 94 | - if (!in_array($oid, $this->_purposes)) { |
|
| 95 | - return false; |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - return true; |
|
| 99 | - } |
|
| 83 | + /** |
|
| 84 | + * Whether purposes are present. |
|
| 85 | + * |
|
| 86 | + * If multiple purposes are checked, all must be present. |
|
| 87 | + * |
|
| 88 | + * @param string[] $oids |
|
| 89 | + * @return bool |
|
| 90 | + */ |
|
| 91 | + public function has(string ...$oids): bool |
|
| 92 | + { |
|
| 93 | + foreach ($oids as $oid) { |
|
| 94 | + if (!in_array($oid, $this->_purposes)) { |
|
| 95 | + return false; |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + return true; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Get key usage purpose OID's. |
|
| 103 | - * |
|
| 104 | - * @return string[] |
|
| 105 | - */ |
|
| 106 | - public function purposes(): array |
|
| 107 | - { |
|
| 108 | - return $this->_purposes; |
|
| 109 | - } |
|
| 101 | + /** |
|
| 102 | + * Get key usage purpose OID's. |
|
| 103 | + * |
|
| 104 | + * @return string[] |
|
| 105 | + */ |
|
| 106 | + public function purposes(): array |
|
| 107 | + { |
|
| 108 | + return $this->_purposes; |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * |
|
| 113 | - * {@inheritdoc} |
|
| 114 | - * @return Sequence |
|
| 115 | - */ |
|
| 116 | - protected function _valueASN1(): Sequence |
|
| 117 | - { |
|
| 118 | - $elements = array_map( |
|
| 119 | - function ($oid) { |
|
| 120 | - return new ObjectIdentifier($oid); |
|
| 121 | - }, $this->_purposes); |
|
| 122 | - return new Sequence(...$elements); |
|
| 123 | - } |
|
| 111 | + /** |
|
| 112 | + * |
|
| 113 | + * {@inheritdoc} |
|
| 114 | + * @return Sequence |
|
| 115 | + */ |
|
| 116 | + protected function _valueASN1(): Sequence |
|
| 117 | + { |
|
| 118 | + $elements = array_map( |
|
| 119 | + function ($oid) { |
|
| 120 | + return new ObjectIdentifier($oid); |
|
| 121 | + }, $this->_purposes); |
|
| 122 | + return new Sequence(...$elements); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Get the number of purposes. |
|
| 127 | - * |
|
| 128 | - * @see \Countable::count() |
|
| 129 | - * @return int |
|
| 130 | - */ |
|
| 131 | - public function count(): int |
|
| 132 | - { |
|
| 133 | - return count($this->_purposes); |
|
| 134 | - } |
|
| 125 | + /** |
|
| 126 | + * Get the number of purposes. |
|
| 127 | + * |
|
| 128 | + * @see \Countable::count() |
|
| 129 | + * @return int |
|
| 130 | + */ |
|
| 131 | + public function count(): int |
|
| 132 | + { |
|
| 133 | + return count($this->_purposes); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * Get iterator for usage purposes. |
|
| 138 | - * |
|
| 139 | - * @see \IteratorAggregate::getIterator() |
|
| 140 | - * @return \ArrayIterator |
|
| 141 | - */ |
|
| 142 | - public function getIterator(): \ArrayIterator |
|
| 143 | - { |
|
| 144 | - return new \ArrayIterator($this->_purposes); |
|
| 145 | - } |
|
| 136 | + /** |
|
| 137 | + * Get iterator for usage purposes. |
|
| 138 | + * |
|
| 139 | + * @see \IteratorAggregate::getIterator() |
|
| 140 | + * @return \ArrayIterator |
|
| 141 | + */ |
|
| 142 | + public function getIterator(): \ArrayIterator |
|
| 143 | + { |
|
| 144 | + return new \ArrayIterator($this->_purposes); |
|
| 145 | + } |
|
| 146 | 146 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | protected static function _fromDER(string $data, bool $critical): self |
| 75 | 75 | { |
| 76 | 76 | $purposes = array_map( |
| 77 | - function (UnspecifiedType $el) { |
|
| 77 | + function(UnspecifiedType $el) { |
|
| 78 | 78 | return $el->asObjectIdentifier()->oid(); |
| 79 | 79 | }, Sequence::fromDER($data)->elements()); |
| 80 | 80 | return new self($critical, ...$purposes); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | protected function _valueASN1(): Sequence |
| 117 | 117 | { |
| 118 | 118 | $elements = array_map( |
| 119 | - function ($oid) { |
|
| 119 | + function($oid) { |
|
| 120 | 120 | return new ObjectIdentifier($oid); |
| 121 | 121 | }, $this->_purposes); |
| 122 | 122 | return new Sequence(...$elements); |
@@ -14,95 +14,95 @@ |
||
| 14 | 14 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.13 |
| 15 | 15 | */ |
| 16 | 16 | class CRLDistributionPointsExtension extends Extension implements |
| 17 | - \Countable, |
|
| 18 | - \IteratorAggregate |
|
| 17 | + \Countable, |
|
| 18 | + \IteratorAggregate |
|
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Distribution points. |
|
| 22 | - * |
|
| 23 | - * @var DistributionPoint[] $_distributionPoints |
|
| 24 | - */ |
|
| 25 | - protected $_distributionPoints; |
|
| 20 | + /** |
|
| 21 | + * Distribution points. |
|
| 22 | + * |
|
| 23 | + * @var DistributionPoint[] $_distributionPoints |
|
| 24 | + */ |
|
| 25 | + protected $_distributionPoints; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Constructor. |
|
| 29 | - * |
|
| 30 | - * @param bool $critical |
|
| 31 | - * @param DistributionPoint[] $distribution_points |
|
| 32 | - */ |
|
| 33 | - public function __construct(bool $critical, |
|
| 34 | - DistributionPoint ...$distribution_points) |
|
| 35 | - { |
|
| 36 | - parent::__construct(self::OID_CRL_DISTRIBUTION_POINTS, $critical); |
|
| 37 | - $this->_distributionPoints = $distribution_points; |
|
| 38 | - } |
|
| 27 | + /** |
|
| 28 | + * Constructor. |
|
| 29 | + * |
|
| 30 | + * @param bool $critical |
|
| 31 | + * @param DistributionPoint[] $distribution_points |
|
| 32 | + */ |
|
| 33 | + public function __construct(bool $critical, |
|
| 34 | + DistributionPoint ...$distribution_points) |
|
| 35 | + { |
|
| 36 | + parent::__construct(self::OID_CRL_DISTRIBUTION_POINTS, $critical); |
|
| 37 | + $this->_distributionPoints = $distribution_points; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * |
|
| 42 | - * {@inheritdoc} |
|
| 43 | - * @return self |
|
| 44 | - */ |
|
| 45 | - protected static function _fromDER(string $data, bool $critical): self |
|
| 46 | - { |
|
| 47 | - $dps = array_map( |
|
| 48 | - function (UnspecifiedType $el) { |
|
| 49 | - return DistributionPoint::fromASN1($el->asSequence()); |
|
| 50 | - }, Sequence::fromDER($data)->elements()); |
|
| 51 | - if (!count($dps)) { |
|
| 52 | - throw new \UnexpectedValueException( |
|
| 53 | - "CRLDistributionPoints must have" . |
|
| 54 | - " at least one DistributionPoint."); |
|
| 55 | - } |
|
| 56 | - // late static bound, extended by Freshest CRL extension |
|
| 57 | - return new static($critical, ...$dps); |
|
| 58 | - } |
|
| 40 | + /** |
|
| 41 | + * |
|
| 42 | + * {@inheritdoc} |
|
| 43 | + * @return self |
|
| 44 | + */ |
|
| 45 | + protected static function _fromDER(string $data, bool $critical): self |
|
| 46 | + { |
|
| 47 | + $dps = array_map( |
|
| 48 | + function (UnspecifiedType $el) { |
|
| 49 | + return DistributionPoint::fromASN1($el->asSequence()); |
|
| 50 | + }, Sequence::fromDER($data)->elements()); |
|
| 51 | + if (!count($dps)) { |
|
| 52 | + throw new \UnexpectedValueException( |
|
| 53 | + "CRLDistributionPoints must have" . |
|
| 54 | + " at least one DistributionPoint."); |
|
| 55 | + } |
|
| 56 | + // late static bound, extended by Freshest CRL extension |
|
| 57 | + return new static($critical, ...$dps); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * |
|
| 62 | - * {@inheritdoc} |
|
| 63 | - * @return Sequence |
|
| 64 | - */ |
|
| 65 | - protected function _valueASN1(): Sequence |
|
| 66 | - { |
|
| 67 | - if (!count($this->_distributionPoints)) { |
|
| 68 | - throw new \LogicException("No distribution points."); |
|
| 69 | - } |
|
| 70 | - $elements = array_map( |
|
| 71 | - function (DistributionPoint $dp) { |
|
| 72 | - return $dp->toASN1(); |
|
| 73 | - }, $this->_distributionPoints); |
|
| 74 | - return new Sequence(...$elements); |
|
| 75 | - } |
|
| 60 | + /** |
|
| 61 | + * |
|
| 62 | + * {@inheritdoc} |
|
| 63 | + * @return Sequence |
|
| 64 | + */ |
|
| 65 | + protected function _valueASN1(): Sequence |
|
| 66 | + { |
|
| 67 | + if (!count($this->_distributionPoints)) { |
|
| 68 | + throw new \LogicException("No distribution points."); |
|
| 69 | + } |
|
| 70 | + $elements = array_map( |
|
| 71 | + function (DistributionPoint $dp) { |
|
| 72 | + return $dp->toASN1(); |
|
| 73 | + }, $this->_distributionPoints); |
|
| 74 | + return new Sequence(...$elements); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Get distribution points. |
|
| 79 | - * |
|
| 80 | - * @return DistributionPoint[] |
|
| 81 | - */ |
|
| 82 | - public function distributionPoints(): array |
|
| 83 | - { |
|
| 84 | - return $this->_distributionPoints; |
|
| 85 | - } |
|
| 77 | + /** |
|
| 78 | + * Get distribution points. |
|
| 79 | + * |
|
| 80 | + * @return DistributionPoint[] |
|
| 81 | + */ |
|
| 82 | + public function distributionPoints(): array |
|
| 83 | + { |
|
| 84 | + return $this->_distributionPoints; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * Get the number of distribution points. |
|
| 89 | - * |
|
| 90 | - * @see \Countable::count() |
|
| 91 | - * @return int |
|
| 92 | - */ |
|
| 93 | - public function count(): int |
|
| 94 | - { |
|
| 95 | - return count($this->_distributionPoints); |
|
| 96 | - } |
|
| 87 | + /** |
|
| 88 | + * Get the number of distribution points. |
|
| 89 | + * |
|
| 90 | + * @see \Countable::count() |
|
| 91 | + * @return int |
|
| 92 | + */ |
|
| 93 | + public function count(): int |
|
| 94 | + { |
|
| 95 | + return count($this->_distributionPoints); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Get iterator for distribution points. |
|
| 100 | - * |
|
| 101 | - * @see \IteratorAggregate::getIterator() |
|
| 102 | - * @return \ArrayIterator |
|
| 103 | - */ |
|
| 104 | - public function getIterator(): \ArrayIterator |
|
| 105 | - { |
|
| 106 | - return new \ArrayIterator($this->_distributionPoints); |
|
| 107 | - } |
|
| 98 | + /** |
|
| 99 | + * Get iterator for distribution points. |
|
| 100 | + * |
|
| 101 | + * @see \IteratorAggregate::getIterator() |
|
| 102 | + * @return \ArrayIterator |
|
| 103 | + */ |
|
| 104 | + public function getIterator(): \ArrayIterator |
|
| 105 | + { |
|
| 106 | + return new \ArrayIterator($this->_distributionPoints); |
|
| 107 | + } |
|
| 108 | 108 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | protected static function _fromDER(string $data, bool $critical): self |
| 46 | 46 | { |
| 47 | 47 | $dps = array_map( |
| 48 | - function (UnspecifiedType $el) { |
|
| 48 | + function(UnspecifiedType $el) { |
|
| 49 | 49 | return DistributionPoint::fromASN1($el->asSequence()); |
| 50 | 50 | }, Sequence::fromDER($data)->elements()); |
| 51 | 51 | if (!count($dps)) { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | throw new \LogicException("No distribution points."); |
| 69 | 69 | } |
| 70 | 70 | $elements = array_map( |
| 71 | - function (DistributionPoint $dp) { |
|
| 71 | + function(DistributionPoint $dp) { |
|
| 72 | 72 | return $dp->toASN1(); |
| 73 | 73 | }, $this->_distributionPoints); |
| 74 | 74 | return new Sequence(...$elements); |
@@ -15,87 +15,87 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class GeneralSubtrees implements \Countable, \IteratorAggregate |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Subtrees. |
|
| 20 | - * |
|
| 21 | - * @var GeneralSubtree[] $_subtrees |
|
| 22 | - */ |
|
| 23 | - protected $_subtrees; |
|
| 18 | + /** |
|
| 19 | + * Subtrees. |
|
| 20 | + * |
|
| 21 | + * @var GeneralSubtree[] $_subtrees |
|
| 22 | + */ |
|
| 23 | + protected $_subtrees; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Constructor. |
|
| 27 | - * |
|
| 28 | - * @param GeneralSubtree[] $subtrees |
|
| 29 | - */ |
|
| 30 | - public function __construct(GeneralSubtree ...$subtrees) |
|
| 31 | - { |
|
| 32 | - $this->_subtrees = $subtrees; |
|
| 33 | - } |
|
| 25 | + /** |
|
| 26 | + * Constructor. |
|
| 27 | + * |
|
| 28 | + * @param GeneralSubtree[] $subtrees |
|
| 29 | + */ |
|
| 30 | + public function __construct(GeneralSubtree ...$subtrees) |
|
| 31 | + { |
|
| 32 | + $this->_subtrees = $subtrees; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Initialize from ASN.1. |
|
| 37 | - * |
|
| 38 | - * @param Sequence $seq |
|
| 39 | - * @return self |
|
| 40 | - */ |
|
| 41 | - public static function fromASN1(Sequence $seq): self |
|
| 42 | - { |
|
| 43 | - $subtrees = array_map( |
|
| 44 | - function (UnspecifiedType $el) { |
|
| 45 | - return GeneralSubtree::fromASN1($el->asSequence()); |
|
| 46 | - }, $seq->elements()); |
|
| 47 | - if (!count($subtrees)) { |
|
| 48 | - throw new \UnexpectedValueException( |
|
| 49 | - "GeneralSubtrees must contain at least one GeneralSubtree."); |
|
| 50 | - } |
|
| 51 | - return new self(...$subtrees); |
|
| 52 | - } |
|
| 35 | + /** |
|
| 36 | + * Initialize from ASN.1. |
|
| 37 | + * |
|
| 38 | + * @param Sequence $seq |
|
| 39 | + * @return self |
|
| 40 | + */ |
|
| 41 | + public static function fromASN1(Sequence $seq): self |
|
| 42 | + { |
|
| 43 | + $subtrees = array_map( |
|
| 44 | + function (UnspecifiedType $el) { |
|
| 45 | + return GeneralSubtree::fromASN1($el->asSequence()); |
|
| 46 | + }, $seq->elements()); |
|
| 47 | + if (!count($subtrees)) { |
|
| 48 | + throw new \UnexpectedValueException( |
|
| 49 | + "GeneralSubtrees must contain at least one GeneralSubtree."); |
|
| 50 | + } |
|
| 51 | + return new self(...$subtrees); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Get all subtrees. |
|
| 56 | - * |
|
| 57 | - * @return GeneralSubtree[] |
|
| 58 | - */ |
|
| 59 | - public function all(): array |
|
| 60 | - { |
|
| 61 | - return $this->_subtrees; |
|
| 62 | - } |
|
| 54 | + /** |
|
| 55 | + * Get all subtrees. |
|
| 56 | + * |
|
| 57 | + * @return GeneralSubtree[] |
|
| 58 | + */ |
|
| 59 | + public function all(): array |
|
| 60 | + { |
|
| 61 | + return $this->_subtrees; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Generate ASN.1 structure. |
|
| 66 | - * |
|
| 67 | - * @return Sequence |
|
| 68 | - */ |
|
| 69 | - public function toASN1(): Sequence |
|
| 70 | - { |
|
| 71 | - if (!count($this->_subtrees)) { |
|
| 72 | - throw new \LogicException("No subtrees."); |
|
| 73 | - } |
|
| 74 | - $elements = array_map( |
|
| 75 | - function (GeneralSubtree $gs) { |
|
| 76 | - return $gs->toASN1(); |
|
| 77 | - }, $this->_subtrees); |
|
| 78 | - return new Sequence(...$elements); |
|
| 79 | - } |
|
| 64 | + /** |
|
| 65 | + * Generate ASN.1 structure. |
|
| 66 | + * |
|
| 67 | + * @return Sequence |
|
| 68 | + */ |
|
| 69 | + public function toASN1(): Sequence |
|
| 70 | + { |
|
| 71 | + if (!count($this->_subtrees)) { |
|
| 72 | + throw new \LogicException("No subtrees."); |
|
| 73 | + } |
|
| 74 | + $elements = array_map( |
|
| 75 | + function (GeneralSubtree $gs) { |
|
| 76 | + return $gs->toASN1(); |
|
| 77 | + }, $this->_subtrees); |
|
| 78 | + return new Sequence(...$elements); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * |
|
| 83 | - * @see \Countable::count() |
|
| 84 | - * @return int |
|
| 85 | - */ |
|
| 86 | - public function count(): int |
|
| 87 | - { |
|
| 88 | - return count($this->_subtrees); |
|
| 89 | - } |
|
| 81 | + /** |
|
| 82 | + * |
|
| 83 | + * @see \Countable::count() |
|
| 84 | + * @return int |
|
| 85 | + */ |
|
| 86 | + public function count(): int |
|
| 87 | + { |
|
| 88 | + return count($this->_subtrees); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Get iterator for subtrees. |
|
| 93 | - * |
|
| 94 | - * @see \IteratorAggregate::getIterator() |
|
| 95 | - * @return \ArrayIterator |
|
| 96 | - */ |
|
| 97 | - public function getIterator(): \ArrayIterator |
|
| 98 | - { |
|
| 99 | - return new \ArrayIterator($this->_subtrees); |
|
| 100 | - } |
|
| 91 | + /** |
|
| 92 | + * Get iterator for subtrees. |
|
| 93 | + * |
|
| 94 | + * @see \IteratorAggregate::getIterator() |
|
| 95 | + * @return \ArrayIterator |
|
| 96 | + */ |
|
| 97 | + public function getIterator(): \ArrayIterator |
|
| 98 | + { |
|
| 99 | + return new \ArrayIterator($this->_subtrees); |
|
| 100 | + } |
|
| 101 | 101 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | public static function fromASN1(Sequence $seq): self |
| 42 | 42 | { |
| 43 | 43 | $subtrees = array_map( |
| 44 | - function (UnspecifiedType $el) { |
|
| 44 | + function(UnspecifiedType $el) { |
|
| 45 | 45 | return GeneralSubtree::fromASN1($el->asSequence()); |
| 46 | 46 | }, $seq->elements()); |
| 47 | 47 | if (!count($subtrees)) { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | throw new \LogicException("No subtrees."); |
| 73 | 73 | } |
| 74 | 74 | $elements = array_map( |
| 75 | - function (GeneralSubtree $gs) { |
|
| 75 | + function(GeneralSubtree $gs) { |
|
| 76 | 76 | return $gs->toASN1(); |
| 77 | 77 | }, $this->_subtrees); |
| 78 | 78 | return new Sequence(...$elements); |
@@ -18,91 +18,91 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class GeneralSubtree |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Constraint. |
|
| 23 | - * |
|
| 24 | - * @var GeneralName |
|
| 25 | - */ |
|
| 26 | - protected $_base; |
|
| 21 | + /** |
|
| 22 | + * Constraint. |
|
| 23 | + * |
|
| 24 | + * @var GeneralName |
|
| 25 | + */ |
|
| 26 | + protected $_base; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Not used, must be zero. |
|
| 30 | - * |
|
| 31 | - * @var int $_min |
|
| 32 | - */ |
|
| 33 | - protected $_min; |
|
| 28 | + /** |
|
| 29 | + * Not used, must be zero. |
|
| 30 | + * |
|
| 31 | + * @var int $_min |
|
| 32 | + */ |
|
| 33 | + protected $_min; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Not used, must be null. |
|
| 37 | - * |
|
| 38 | - * @var int|null $_max |
|
| 39 | - */ |
|
| 40 | - protected $_max; |
|
| 35 | + /** |
|
| 36 | + * Not used, must be null. |
|
| 37 | + * |
|
| 38 | + * @var int|null $_max |
|
| 39 | + */ |
|
| 40 | + protected $_max; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Constructor. |
|
| 44 | - * |
|
| 45 | - * @param GeneralName $base |
|
| 46 | - * @param int $min |
|
| 47 | - * @param int|null $max |
|
| 48 | - */ |
|
| 49 | - public function __construct(GeneralName $base, int $min = 0, $max = null) |
|
| 50 | - { |
|
| 51 | - $this->_base = $base; |
|
| 52 | - $this->_min = $min; |
|
| 53 | - $this->_max = $max; |
|
| 54 | - } |
|
| 42 | + /** |
|
| 43 | + * Constructor. |
|
| 44 | + * |
|
| 45 | + * @param GeneralName $base |
|
| 46 | + * @param int $min |
|
| 47 | + * @param int|null $max |
|
| 48 | + */ |
|
| 49 | + public function __construct(GeneralName $base, int $min = 0, $max = null) |
|
| 50 | + { |
|
| 51 | + $this->_base = $base; |
|
| 52 | + $this->_min = $min; |
|
| 53 | + $this->_max = $max; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Initialize from ASN.1. |
|
| 58 | - * |
|
| 59 | - * @param Sequence $seq |
|
| 60 | - * @return self |
|
| 61 | - */ |
|
| 62 | - public static function fromASN1(Sequence $seq): self |
|
| 63 | - { |
|
| 64 | - $base = GeneralName::fromASN1($seq->at(0)->asTagged()); |
|
| 65 | - $min = 0; |
|
| 66 | - $max = null; |
|
| 67 | - if ($seq->hasTagged(0)) { |
|
| 68 | - $min = $seq->getTagged(0) |
|
| 69 | - ->asImplicit(Element::TYPE_INTEGER) |
|
| 70 | - ->asInteger() |
|
| 71 | - ->intNumber(); |
|
| 72 | - } |
|
| 73 | - if ($seq->hasTagged(1)) { |
|
| 74 | - $max = $seq->getTagged(1) |
|
| 75 | - ->asImplicit(Element::TYPE_INTEGER) |
|
| 76 | - ->asInteger() |
|
| 77 | - ->intNumber(); |
|
| 78 | - } |
|
| 79 | - return new self($base, $min, $max); |
|
| 80 | - } |
|
| 56 | + /** |
|
| 57 | + * Initialize from ASN.1. |
|
| 58 | + * |
|
| 59 | + * @param Sequence $seq |
|
| 60 | + * @return self |
|
| 61 | + */ |
|
| 62 | + public static function fromASN1(Sequence $seq): self |
|
| 63 | + { |
|
| 64 | + $base = GeneralName::fromASN1($seq->at(0)->asTagged()); |
|
| 65 | + $min = 0; |
|
| 66 | + $max = null; |
|
| 67 | + if ($seq->hasTagged(0)) { |
|
| 68 | + $min = $seq->getTagged(0) |
|
| 69 | + ->asImplicit(Element::TYPE_INTEGER) |
|
| 70 | + ->asInteger() |
|
| 71 | + ->intNumber(); |
|
| 72 | + } |
|
| 73 | + if ($seq->hasTagged(1)) { |
|
| 74 | + $max = $seq->getTagged(1) |
|
| 75 | + ->asImplicit(Element::TYPE_INTEGER) |
|
| 76 | + ->asInteger() |
|
| 77 | + ->intNumber(); |
|
| 78 | + } |
|
| 79 | + return new self($base, $min, $max); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Get constraint. |
|
| 84 | - * |
|
| 85 | - * @return GeneralName |
|
| 86 | - */ |
|
| 87 | - public function base(): GeneralName |
|
| 88 | - { |
|
| 89 | - return $this->_base; |
|
| 90 | - } |
|
| 82 | + /** |
|
| 83 | + * Get constraint. |
|
| 84 | + * |
|
| 85 | + * @return GeneralName |
|
| 86 | + */ |
|
| 87 | + public function base(): GeneralName |
|
| 88 | + { |
|
| 89 | + return $this->_base; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Generate ASN.1 structure. |
|
| 94 | - * |
|
| 95 | - * @return Sequence |
|
| 96 | - */ |
|
| 97 | - public function toASN1(): Sequence |
|
| 98 | - { |
|
| 99 | - $elements = array($this->_base->toASN1()); |
|
| 100 | - if (isset($this->_min) && $this->_min != 0) { |
|
| 101 | - $elements[] = new ImplicitlyTaggedType(0, new Integer($this->_min)); |
|
| 102 | - } |
|
| 103 | - if (isset($this->_max)) { |
|
| 104 | - $elements[] = new ImplicitlyTaggedType(1, new Integer($this->_max)); |
|
| 105 | - } |
|
| 106 | - return new Sequence(...$elements); |
|
| 107 | - } |
|
| 92 | + /** |
|
| 93 | + * Generate ASN.1 structure. |
|
| 94 | + * |
|
| 95 | + * @return Sequence |
|
| 96 | + */ |
|
| 97 | + public function toASN1(): Sequence |
|
| 98 | + { |
|
| 99 | + $elements = array($this->_base->toASN1()); |
|
| 100 | + if (isset($this->_min) && $this->_min != 0) { |
|
| 101 | + $elements[] = new ImplicitlyTaggedType(0, new Integer($this->_min)); |
|
| 102 | + } |
|
| 103 | + if (isset($this->_max)) { |
|
| 104 | + $elements[] = new ImplicitlyTaggedType(1, new Integer($this->_max)); |
|
| 105 | + } |
|
| 106 | + return new Sequence(...$elements); |
|
| 107 | + } |
|
| 108 | 108 | } |
@@ -11,32 +11,32 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class UnknownExtension extends Extension |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Extension value. |
|
| 16 | - * |
|
| 17 | - * @var Element $_element |
|
| 18 | - */ |
|
| 19 | - protected $_element; |
|
| 14 | + /** |
|
| 15 | + * Extension value. |
|
| 16 | + * |
|
| 17 | + * @var Element $_element |
|
| 18 | + */ |
|
| 19 | + protected $_element; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Constructor. |
|
| 23 | - * |
|
| 24 | - * @param string $oid |
|
| 25 | - * @param bool $critical |
|
| 26 | - * @param Element $data |
|
| 27 | - */ |
|
| 28 | - public function __construct(string $oid, bool $critical, Element $data) |
|
| 29 | - { |
|
| 30 | - parent::__construct($oid, $critical); |
|
| 31 | - $this->_element = $data; |
|
| 32 | - } |
|
| 21 | + /** |
|
| 22 | + * Constructor. |
|
| 23 | + * |
|
| 24 | + * @param string $oid |
|
| 25 | + * @param bool $critical |
|
| 26 | + * @param Element $data |
|
| 27 | + */ |
|
| 28 | + public function __construct(string $oid, bool $critical, Element $data) |
|
| 29 | + { |
|
| 30 | + parent::__construct($oid, $critical); |
|
| 31 | + $this->_element = $data; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * |
|
| 36 | - * {@inheritdoc} |
|
| 37 | - */ |
|
| 38 | - protected function _valueASN1(): Element |
|
| 39 | - { |
|
| 40 | - return $this->_element; |
|
| 41 | - } |
|
| 34 | + /** |
|
| 35 | + * |
|
| 36 | + * {@inheritdoc} |
|
| 37 | + */ |
|
| 38 | + protected function _valueASN1(): Element |
|
| 39 | + { |
|
| 40 | + return $this->_element; |
|
| 41 | + } |
|
| 42 | 42 | } |