@@ -16,91 +16,91 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class GeneralSubtree |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Constraint. |
|
| 21 | - * |
|
| 22 | - * @var GeneralName |
|
| 23 | - */ |
|
| 24 | - protected $_base; |
|
| 19 | + /** |
|
| 20 | + * Constraint. |
|
| 21 | + * |
|
| 22 | + * @var GeneralName |
|
| 23 | + */ |
|
| 24 | + protected $_base; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Not used, must be zero. |
|
| 28 | - * |
|
| 29 | - * @var int $_min |
|
| 30 | - */ |
|
| 31 | - protected $_min; |
|
| 26 | + /** |
|
| 27 | + * Not used, must be zero. |
|
| 28 | + * |
|
| 29 | + * @var int $_min |
|
| 30 | + */ |
|
| 31 | + protected $_min; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Not used, must be null. |
|
| 35 | - * |
|
| 36 | - * @var int|null $_max |
|
| 37 | - */ |
|
| 38 | - protected $_max; |
|
| 33 | + /** |
|
| 34 | + * Not used, must be null. |
|
| 35 | + * |
|
| 36 | + * @var int|null $_max |
|
| 37 | + */ |
|
| 38 | + protected $_max; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Constructor. |
|
| 42 | - * |
|
| 43 | - * @param GeneralName $base |
|
| 44 | - * @param int $min |
|
| 45 | - * @param int|null $max |
|
| 46 | - */ |
|
| 47 | - public function __construct(GeneralName $base, $min = 0, $max = null) |
|
| 48 | - { |
|
| 49 | - $this->_base = $base; |
|
| 50 | - $this->_min = $min; |
|
| 51 | - $this->_max = $max; |
|
| 52 | - } |
|
| 40 | + /** |
|
| 41 | + * Constructor. |
|
| 42 | + * |
|
| 43 | + * @param GeneralName $base |
|
| 44 | + * @param int $min |
|
| 45 | + * @param int|null $max |
|
| 46 | + */ |
|
| 47 | + public function __construct(GeneralName $base, $min = 0, $max = null) |
|
| 48 | + { |
|
| 49 | + $this->_base = $base; |
|
| 50 | + $this->_min = $min; |
|
| 51 | + $this->_max = $max; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Initialize from ASN.1. |
|
| 56 | - * |
|
| 57 | - * @param Sequence $seq |
|
| 58 | - * @return self |
|
| 59 | - */ |
|
| 60 | - public static function fromASN1(Sequence $seq) |
|
| 61 | - { |
|
| 62 | - $base = GeneralName::fromASN1($seq->at(0)->asTagged()); |
|
| 63 | - $min = 0; |
|
| 64 | - $max = null; |
|
| 65 | - if ($seq->hasTagged(0)) { |
|
| 66 | - $min = $seq->getTagged(0) |
|
| 67 | - ->asImplicit(Element::TYPE_INTEGER) |
|
| 68 | - ->asInteger() |
|
| 69 | - ->number(); |
|
| 70 | - } |
|
| 71 | - if ($seq->hasTagged(1)) { |
|
| 72 | - $max = $seq->getTagged(1) |
|
| 73 | - ->asImplicit(Element::TYPE_INTEGER) |
|
| 74 | - ->asInteger() |
|
| 75 | - ->number(); |
|
| 76 | - } |
|
| 77 | - return new self($base, $min, $max); |
|
| 78 | - } |
|
| 54 | + /** |
|
| 55 | + * Initialize from ASN.1. |
|
| 56 | + * |
|
| 57 | + * @param Sequence $seq |
|
| 58 | + * @return self |
|
| 59 | + */ |
|
| 60 | + public static function fromASN1(Sequence $seq) |
|
| 61 | + { |
|
| 62 | + $base = GeneralName::fromASN1($seq->at(0)->asTagged()); |
|
| 63 | + $min = 0; |
|
| 64 | + $max = null; |
|
| 65 | + if ($seq->hasTagged(0)) { |
|
| 66 | + $min = $seq->getTagged(0) |
|
| 67 | + ->asImplicit(Element::TYPE_INTEGER) |
|
| 68 | + ->asInteger() |
|
| 69 | + ->number(); |
|
| 70 | + } |
|
| 71 | + if ($seq->hasTagged(1)) { |
|
| 72 | + $max = $seq->getTagged(1) |
|
| 73 | + ->asImplicit(Element::TYPE_INTEGER) |
|
| 74 | + ->asInteger() |
|
| 75 | + ->number(); |
|
| 76 | + } |
|
| 77 | + return new self($base, $min, $max); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Get constraint. |
|
| 82 | - * |
|
| 83 | - * @return GeneralName |
|
| 84 | - */ |
|
| 85 | - public function base() |
|
| 86 | - { |
|
| 87 | - return $this->_base; |
|
| 88 | - } |
|
| 80 | + /** |
|
| 81 | + * Get constraint. |
|
| 82 | + * |
|
| 83 | + * @return GeneralName |
|
| 84 | + */ |
|
| 85 | + public function base() |
|
| 86 | + { |
|
| 87 | + return $this->_base; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Generate ASN.1 structure. |
|
| 92 | - * |
|
| 93 | - * @return Sequence |
|
| 94 | - */ |
|
| 95 | - public function toASN1() |
|
| 96 | - { |
|
| 97 | - $elements = array($this->_base->toASN1()); |
|
| 98 | - if (isset($this->_min) && $this->_min != 0) { |
|
| 99 | - $elements[] = new ImplicitlyTaggedType(0, new Integer($this->_min)); |
|
| 100 | - } |
|
| 101 | - if (isset($this->_max)) { |
|
| 102 | - $elements[] = new ImplicitlyTaggedType(1, new Integer($this->_max)); |
|
| 103 | - } |
|
| 104 | - return new Sequence(...$elements); |
|
| 105 | - } |
|
| 90 | + /** |
|
| 91 | + * Generate ASN.1 structure. |
|
| 92 | + * |
|
| 93 | + * @return Sequence |
|
| 94 | + */ |
|
| 95 | + public function toASN1() |
|
| 96 | + { |
|
| 97 | + $elements = array($this->_base->toASN1()); |
|
| 98 | + if (isset($this->_min) && $this->_min != 0) { |
|
| 99 | + $elements[] = new ImplicitlyTaggedType(0, new Integer($this->_min)); |
|
| 100 | + } |
|
| 101 | + if (isset($this->_max)) { |
|
| 102 | + $elements[] = new ImplicitlyTaggedType(1, new Integer($this->_max)); |
|
| 103 | + } |
|
| 104 | + return new Sequence(...$elements); |
|
| 105 | + } |
|
| 106 | 106 | } |
@@ -17,214 +17,214 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | abstract class Extension |
| 19 | 19 | { |
| 20 | - // OID's from standard certificate extensions |
|
| 21 | - const OID_OBSOLETE_AUTHORITY_KEY_IDENTIFIER = "2.5.29.1"; |
|
| 22 | - const OID_OBSOLETE_KEY_ATTRIBUTES = "2.5.29.2"; |
|
| 23 | - const OID_OBSOLETE_CERTIFICATE_POLICIES = "2.5.29.3"; |
|
| 24 | - const OID_OBSOLETE_KEY_USAGE_RESTRICTION = "2.5.29.4"; |
|
| 25 | - const OID_OBSOLETE_POLICY_MAPPING = "2.5.29.5"; |
|
| 26 | - const OID_OBSOLETE_SUBTREES_CONSTRAINT = "2.5.29.6"; |
|
| 27 | - const OID_OBSOLETE_SUBJECT_ALT_NAME = "2.5.29.7"; |
|
| 28 | - const OID_OBSOLETE_ISSUER_ALT_NAME = "2.5.29.8"; |
|
| 29 | - const OID_SUBJECT_DIRECTORY_ATTRIBUTES = "2.5.29.9"; |
|
| 30 | - const OID_OBSOLETE_BASIC_CONSTRAINTS = "2.5.29.10"; |
|
| 31 | - const OID_SUBJECT_KEY_IDENTIFIER = "2.5.29.14"; |
|
| 32 | - const OID_KEY_USAGE = "2.5.29.15"; |
|
| 33 | - const OID_PRIVATE_KEY_USAGE_PERIOD = "2.5.29.16"; |
|
| 34 | - const OID_SUBJECT_ALT_NAME = "2.5.29.17"; |
|
| 35 | - const OID_ISSUER_ALT_NAME = "2.5.29.18"; |
|
| 36 | - const OID_BASIC_CONSTRAINTS = "2.5.29.19"; |
|
| 37 | - const OID_CRL_NUMBER = "2.5.29.20"; |
|
| 38 | - const OID_REASON_CODE = "2.5.29.21"; |
|
| 39 | - const OID_OBSOLETE_EXPIRATION_DATE = "2.5.29.22"; |
|
| 40 | - const OID_INSTRUCTION_CODE = "2.5.29.23"; |
|
| 41 | - const OID_INVALIDITY_DATE = "2.5.29.24"; |
|
| 42 | - const OID_OBSOLETE_CRL_DISTRIBUTION_POINTS = "2.5.29.25"; |
|
| 43 | - const OID_OBSOLETE_ISSUING_DISTRIBUTION_POINT = "2.5.29.26"; |
|
| 44 | - const OID_DELTA_CRL_INDICATOR = "2.5.29.27"; |
|
| 45 | - const OID_ISSUING_DISTRIBUTION_POINT = "2.5.29.28"; |
|
| 46 | - const OID_CERTIFICATE_ISSUER = "2.5.29.29"; |
|
| 47 | - const OID_NAME_CONSTRAINTS = "2.5.29.30"; |
|
| 48 | - const OID_CRL_DISTRIBUTION_POINTS = "2.5.29.31"; |
|
| 49 | - const OID_CERTIFICATE_POLICIES = "2.5.29.32"; |
|
| 50 | - const OID_POLICY_MAPPINGS = "2.5.29.33"; |
|
| 51 | - const OID_OBSOLETE_POLICY_CONSTRAINTS = "2.5.29.34"; |
|
| 52 | - const OID_AUTHORITY_KEY_IDENTIFIER = "2.5.29.35"; |
|
| 53 | - const OID_POLICY_CONSTRAINTS = "2.5.29.36"; |
|
| 54 | - const OID_EXT_KEY_USAGE = "2.5.29.37"; |
|
| 55 | - const OID_AUTHORITY_ATTRIBUTE_IDENTIFIER = "2.5.29.38"; |
|
| 56 | - const OID_ROLE_SPEC_CERT_IDENTIFIER = "2.5.29.39"; |
|
| 57 | - const OID_CRL_STREAM_IDENTIFIER = "2.5.29.40"; |
|
| 58 | - const OID_BASIC_ATT_CONSTRAINTS = "2.5.29.41"; |
|
| 59 | - const OID_DELEGATED_NAME_CONSTRAINTS = "2.5.29.42"; |
|
| 60 | - const OID_TIME_SPECIFICATION = "2.5.29.43"; |
|
| 61 | - const OID_CRL_SCOPE = "2.5.29.44"; |
|
| 62 | - const OID_STATUS_REFERRALS = "2.5.29.45"; |
|
| 63 | - const OID_FRESHEST_CRL = "2.5.29.46"; |
|
| 64 | - const OID_ORDERED_LIST = "2.5.29.47"; |
|
| 65 | - const OID_ATTRIBUTE_DESCRIPTOR = "2.5.29.48"; |
|
| 66 | - const OID_USER_NOTICE = "2.5.29.49"; |
|
| 67 | - const OID_SOA_IDENTIFIER = "2.5.29.50"; |
|
| 68 | - const OID_BASE_UPDATE_TIME = "2.5.29.51"; |
|
| 69 | - const OID_ACCEPTABLE_CERT_POLICIES = "2.5.29.52"; |
|
| 70 | - const OID_DELTA_INFO = "2.5.29.53"; |
|
| 71 | - const OID_INHIBIT_ANY_POLICY = "2.5.29.54"; |
|
| 72 | - const OID_TARGET_INFORMATION = "2.5.29.55"; |
|
| 73 | - const OID_NO_REV_AVAIL = "2.5.29.56"; |
|
| 74 | - const OID_ACCEPTABLE_PRIVILEGE_POLICIES = "2.5.29.57"; |
|
| 75 | - const OID_TO_BE_REVOKED = "2.5.29.58"; |
|
| 76 | - const OID_REVOKED_GROUPS = "2.5.29.59"; |
|
| 77 | - const OID_EXPIRED_CERTS_ON_CRL = "2.5.29.60"; |
|
| 78 | - const OID_INDIRECT_ISSUER = "2.5.29.61"; |
|
| 79 | - const OID_NO_ASSERTION = "2.5.29.62"; |
|
| 80 | - const OID_AA_ISSUING_DISTRIBUTION_POINT = "2.5.29.63"; |
|
| 81 | - const OID_ISSUED_ON_BEHALF_OF = "2.5.29.64"; |
|
| 82 | - const OID_SINGLE_USE = "2.5.29.65"; |
|
| 83 | - const OID_GROUP_AC = "2.5.29.66"; |
|
| 84 | - const OID_ALLOWED_ATT_ASS = "2.5.29.67"; |
|
| 85 | - const OID_ATTRIBUTE_MAPPINGS = "2.5.29.68"; |
|
| 86 | - const OID_HOLDER_NAME_CONSTRAINTS = "2.5.29.69"; |
|
| 20 | + // OID's from standard certificate extensions |
|
| 21 | + const OID_OBSOLETE_AUTHORITY_KEY_IDENTIFIER = "2.5.29.1"; |
|
| 22 | + const OID_OBSOLETE_KEY_ATTRIBUTES = "2.5.29.2"; |
|
| 23 | + const OID_OBSOLETE_CERTIFICATE_POLICIES = "2.5.29.3"; |
|
| 24 | + const OID_OBSOLETE_KEY_USAGE_RESTRICTION = "2.5.29.4"; |
|
| 25 | + const OID_OBSOLETE_POLICY_MAPPING = "2.5.29.5"; |
|
| 26 | + const OID_OBSOLETE_SUBTREES_CONSTRAINT = "2.5.29.6"; |
|
| 27 | + const OID_OBSOLETE_SUBJECT_ALT_NAME = "2.5.29.7"; |
|
| 28 | + const OID_OBSOLETE_ISSUER_ALT_NAME = "2.5.29.8"; |
|
| 29 | + const OID_SUBJECT_DIRECTORY_ATTRIBUTES = "2.5.29.9"; |
|
| 30 | + const OID_OBSOLETE_BASIC_CONSTRAINTS = "2.5.29.10"; |
|
| 31 | + const OID_SUBJECT_KEY_IDENTIFIER = "2.5.29.14"; |
|
| 32 | + const OID_KEY_USAGE = "2.5.29.15"; |
|
| 33 | + const OID_PRIVATE_KEY_USAGE_PERIOD = "2.5.29.16"; |
|
| 34 | + const OID_SUBJECT_ALT_NAME = "2.5.29.17"; |
|
| 35 | + const OID_ISSUER_ALT_NAME = "2.5.29.18"; |
|
| 36 | + const OID_BASIC_CONSTRAINTS = "2.5.29.19"; |
|
| 37 | + const OID_CRL_NUMBER = "2.5.29.20"; |
|
| 38 | + const OID_REASON_CODE = "2.5.29.21"; |
|
| 39 | + const OID_OBSOLETE_EXPIRATION_DATE = "2.5.29.22"; |
|
| 40 | + const OID_INSTRUCTION_CODE = "2.5.29.23"; |
|
| 41 | + const OID_INVALIDITY_DATE = "2.5.29.24"; |
|
| 42 | + const OID_OBSOLETE_CRL_DISTRIBUTION_POINTS = "2.5.29.25"; |
|
| 43 | + const OID_OBSOLETE_ISSUING_DISTRIBUTION_POINT = "2.5.29.26"; |
|
| 44 | + const OID_DELTA_CRL_INDICATOR = "2.5.29.27"; |
|
| 45 | + const OID_ISSUING_DISTRIBUTION_POINT = "2.5.29.28"; |
|
| 46 | + const OID_CERTIFICATE_ISSUER = "2.5.29.29"; |
|
| 47 | + const OID_NAME_CONSTRAINTS = "2.5.29.30"; |
|
| 48 | + const OID_CRL_DISTRIBUTION_POINTS = "2.5.29.31"; |
|
| 49 | + const OID_CERTIFICATE_POLICIES = "2.5.29.32"; |
|
| 50 | + const OID_POLICY_MAPPINGS = "2.5.29.33"; |
|
| 51 | + const OID_OBSOLETE_POLICY_CONSTRAINTS = "2.5.29.34"; |
|
| 52 | + const OID_AUTHORITY_KEY_IDENTIFIER = "2.5.29.35"; |
|
| 53 | + const OID_POLICY_CONSTRAINTS = "2.5.29.36"; |
|
| 54 | + const OID_EXT_KEY_USAGE = "2.5.29.37"; |
|
| 55 | + const OID_AUTHORITY_ATTRIBUTE_IDENTIFIER = "2.5.29.38"; |
|
| 56 | + const OID_ROLE_SPEC_CERT_IDENTIFIER = "2.5.29.39"; |
|
| 57 | + const OID_CRL_STREAM_IDENTIFIER = "2.5.29.40"; |
|
| 58 | + const OID_BASIC_ATT_CONSTRAINTS = "2.5.29.41"; |
|
| 59 | + const OID_DELEGATED_NAME_CONSTRAINTS = "2.5.29.42"; |
|
| 60 | + const OID_TIME_SPECIFICATION = "2.5.29.43"; |
|
| 61 | + const OID_CRL_SCOPE = "2.5.29.44"; |
|
| 62 | + const OID_STATUS_REFERRALS = "2.5.29.45"; |
|
| 63 | + const OID_FRESHEST_CRL = "2.5.29.46"; |
|
| 64 | + const OID_ORDERED_LIST = "2.5.29.47"; |
|
| 65 | + const OID_ATTRIBUTE_DESCRIPTOR = "2.5.29.48"; |
|
| 66 | + const OID_USER_NOTICE = "2.5.29.49"; |
|
| 67 | + const OID_SOA_IDENTIFIER = "2.5.29.50"; |
|
| 68 | + const OID_BASE_UPDATE_TIME = "2.5.29.51"; |
|
| 69 | + const OID_ACCEPTABLE_CERT_POLICIES = "2.5.29.52"; |
|
| 70 | + const OID_DELTA_INFO = "2.5.29.53"; |
|
| 71 | + const OID_INHIBIT_ANY_POLICY = "2.5.29.54"; |
|
| 72 | + const OID_TARGET_INFORMATION = "2.5.29.55"; |
|
| 73 | + const OID_NO_REV_AVAIL = "2.5.29.56"; |
|
| 74 | + const OID_ACCEPTABLE_PRIVILEGE_POLICIES = "2.5.29.57"; |
|
| 75 | + const OID_TO_BE_REVOKED = "2.5.29.58"; |
|
| 76 | + const OID_REVOKED_GROUPS = "2.5.29.59"; |
|
| 77 | + const OID_EXPIRED_CERTS_ON_CRL = "2.5.29.60"; |
|
| 78 | + const OID_INDIRECT_ISSUER = "2.5.29.61"; |
|
| 79 | + const OID_NO_ASSERTION = "2.5.29.62"; |
|
| 80 | + const OID_AA_ISSUING_DISTRIBUTION_POINT = "2.5.29.63"; |
|
| 81 | + const OID_ISSUED_ON_BEHALF_OF = "2.5.29.64"; |
|
| 82 | + const OID_SINGLE_USE = "2.5.29.65"; |
|
| 83 | + const OID_GROUP_AC = "2.5.29.66"; |
|
| 84 | + const OID_ALLOWED_ATT_ASS = "2.5.29.67"; |
|
| 85 | + const OID_ATTRIBUTE_MAPPINGS = "2.5.29.68"; |
|
| 86 | + const OID_HOLDER_NAME_CONSTRAINTS = "2.5.29.69"; |
|
| 87 | 87 | |
| 88 | - // OID's from private certificate extensions arc |
|
| 89 | - const OID_AA_CONTROLS = "1.3.6.1.5.5.7.1.6"; |
|
| 88 | + // OID's from private certificate extensions arc |
|
| 89 | + const OID_AA_CONTROLS = "1.3.6.1.5.5.7.1.6"; |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Mapping from extension ID to implementation class name. |
|
| 93 | - * |
|
| 94 | - * @internal |
|
| 95 | - * |
|
| 96 | - * @var array |
|
| 97 | - */ |
|
| 98 | - const MAP_OID_TO_CLASS = array( |
|
| 99 | - /* @formatter:off */ |
|
| 100 | - self::OID_AUTHORITY_KEY_IDENTIFIER => AuthorityKeyIdentifierExtension::class, |
|
| 101 | - self::OID_SUBJECT_KEY_IDENTIFIER => SubjectKeyIdentifierExtension::class, |
|
| 102 | - self::OID_KEY_USAGE => KeyUsageExtension::class, |
|
| 103 | - self::OID_CERTIFICATE_POLICIES => CertificatePoliciesExtension::class, |
|
| 104 | - self::OID_POLICY_MAPPINGS => PolicyMappingsExtension::class, |
|
| 105 | - self::OID_SUBJECT_ALT_NAME => SubjectAlternativeNameExtension::class, |
|
| 106 | - self::OID_ISSUER_ALT_NAME => IssuerAlternativeNameExtension::class, |
|
| 107 | - self::OID_SUBJECT_DIRECTORY_ATTRIBUTES => SubjectDirectoryAttributesExtension::class, |
|
| 108 | - self::OID_BASIC_CONSTRAINTS => BasicConstraintsExtension::class, |
|
| 109 | - self::OID_NAME_CONSTRAINTS => NameConstraintsExtension::class, |
|
| 110 | - self::OID_POLICY_CONSTRAINTS => PolicyConstraintsExtension::class, |
|
| 111 | - self::OID_EXT_KEY_USAGE => ExtendedKeyUsageExtension::class, |
|
| 112 | - self::OID_CRL_DISTRIBUTION_POINTS => CRLDistributionPointsExtension::class, |
|
| 113 | - self::OID_INHIBIT_ANY_POLICY => InhibitAnyPolicyExtension::class, |
|
| 114 | - self::OID_FRESHEST_CRL => FreshestCRLExtension::class, |
|
| 115 | - self::OID_NO_REV_AVAIL => NoRevocationAvailableExtension::class, |
|
| 116 | - self::OID_TARGET_INFORMATION => TargetInformationExtension::class, |
|
| 117 | - self::OID_AA_CONTROLS => AAControlsExtension::class |
|
| 118 | - /* @formatter:on */ |
|
| 119 | - ); |
|
| 91 | + /** |
|
| 92 | + * Mapping from extension ID to implementation class name. |
|
| 93 | + * |
|
| 94 | + * @internal |
|
| 95 | + * |
|
| 96 | + * @var array |
|
| 97 | + */ |
|
| 98 | + const MAP_OID_TO_CLASS = array( |
|
| 99 | + /* @formatter:off */ |
|
| 100 | + self::OID_AUTHORITY_KEY_IDENTIFIER => AuthorityKeyIdentifierExtension::class, |
|
| 101 | + self::OID_SUBJECT_KEY_IDENTIFIER => SubjectKeyIdentifierExtension::class, |
|
| 102 | + self::OID_KEY_USAGE => KeyUsageExtension::class, |
|
| 103 | + self::OID_CERTIFICATE_POLICIES => CertificatePoliciesExtension::class, |
|
| 104 | + self::OID_POLICY_MAPPINGS => PolicyMappingsExtension::class, |
|
| 105 | + self::OID_SUBJECT_ALT_NAME => SubjectAlternativeNameExtension::class, |
|
| 106 | + self::OID_ISSUER_ALT_NAME => IssuerAlternativeNameExtension::class, |
|
| 107 | + self::OID_SUBJECT_DIRECTORY_ATTRIBUTES => SubjectDirectoryAttributesExtension::class, |
|
| 108 | + self::OID_BASIC_CONSTRAINTS => BasicConstraintsExtension::class, |
|
| 109 | + self::OID_NAME_CONSTRAINTS => NameConstraintsExtension::class, |
|
| 110 | + self::OID_POLICY_CONSTRAINTS => PolicyConstraintsExtension::class, |
|
| 111 | + self::OID_EXT_KEY_USAGE => ExtendedKeyUsageExtension::class, |
|
| 112 | + self::OID_CRL_DISTRIBUTION_POINTS => CRLDistributionPointsExtension::class, |
|
| 113 | + self::OID_INHIBIT_ANY_POLICY => InhibitAnyPolicyExtension::class, |
|
| 114 | + self::OID_FRESHEST_CRL => FreshestCRLExtension::class, |
|
| 115 | + self::OID_NO_REV_AVAIL => NoRevocationAvailableExtension::class, |
|
| 116 | + self::OID_TARGET_INFORMATION => TargetInformationExtension::class, |
|
| 117 | + self::OID_AA_CONTROLS => AAControlsExtension::class |
|
| 118 | + /* @formatter:on */ |
|
| 119 | + ); |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Extension's OID. |
|
| 123 | - * |
|
| 124 | - * @var string $_oid |
|
| 125 | - */ |
|
| 126 | - protected $_oid; |
|
| 121 | + /** |
|
| 122 | + * Extension's OID. |
|
| 123 | + * |
|
| 124 | + * @var string $_oid |
|
| 125 | + */ |
|
| 126 | + protected $_oid; |
|
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * Whether extension is critical. |
|
| 130 | - * |
|
| 131 | - * @var bool $_critical |
|
| 132 | - */ |
|
| 133 | - protected $_critical; |
|
| 128 | + /** |
|
| 129 | + * Whether extension is critical. |
|
| 130 | + * |
|
| 131 | + * @var bool $_critical |
|
| 132 | + */ |
|
| 133 | + protected $_critical; |
|
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * Get ASN.1 structure of the extension value. |
|
| 137 | - * |
|
| 138 | - * @return Element |
|
| 139 | - */ |
|
| 140 | - abstract protected function _valueASN1(); |
|
| 135 | + /** |
|
| 136 | + * Get ASN.1 structure of the extension value. |
|
| 137 | + * |
|
| 138 | + * @return Element |
|
| 139 | + */ |
|
| 140 | + abstract protected function _valueASN1(); |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Parse extension value from DER. |
|
| 144 | - * |
|
| 145 | - * @param string $data DER data |
|
| 146 | - * @param bool $critical Whether extension is critical |
|
| 147 | - * @throws \BadMethodCallException |
|
| 148 | - * @return self |
|
| 149 | - */ |
|
| 150 | - protected static function _fromDER($data, $critical) |
|
| 151 | - { |
|
| 152 | - throw new \BadMethodCallException( |
|
| 153 | - __FUNCTION__ . " must be implemented in derived class."); |
|
| 154 | - } |
|
| 142 | + /** |
|
| 143 | + * Parse extension value from DER. |
|
| 144 | + * |
|
| 145 | + * @param string $data DER data |
|
| 146 | + * @param bool $critical Whether extension is critical |
|
| 147 | + * @throws \BadMethodCallException |
|
| 148 | + * @return self |
|
| 149 | + */ |
|
| 150 | + protected static function _fromDER($data, $critical) |
|
| 151 | + { |
|
| 152 | + throw new \BadMethodCallException( |
|
| 153 | + __FUNCTION__ . " must be implemented in derived class."); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - /** |
|
| 157 | - * Constructor. |
|
| 158 | - * |
|
| 159 | - * @param string $oid Extension OID |
|
| 160 | - * @param bool $critical Whether extension is critical |
|
| 161 | - */ |
|
| 162 | - public function __construct($oid, $critical) |
|
| 163 | - { |
|
| 164 | - $this->_oid = $oid; |
|
| 165 | - $this->_critical = $critical; |
|
| 166 | - } |
|
| 156 | + /** |
|
| 157 | + * Constructor. |
|
| 158 | + * |
|
| 159 | + * @param string $oid Extension OID |
|
| 160 | + * @param bool $critical Whether extension is critical |
|
| 161 | + */ |
|
| 162 | + public function __construct($oid, $critical) |
|
| 163 | + { |
|
| 164 | + $this->_oid = $oid; |
|
| 165 | + $this->_critical = $critical; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Initialize from ASN.1. |
|
| 170 | - * |
|
| 171 | - * @param Sequence $seq |
|
| 172 | - * @return self |
|
| 173 | - */ |
|
| 174 | - public static function fromASN1(Sequence $seq) |
|
| 175 | - { |
|
| 176 | - $extnID = $seq->at(0) |
|
| 177 | - ->asObjectIdentifier() |
|
| 178 | - ->oid(); |
|
| 179 | - $critical = false; |
|
| 180 | - $idx = 1; |
|
| 181 | - if ($seq->has($idx, Element::TYPE_BOOLEAN)) { |
|
| 182 | - $critical = $seq->at($idx++) |
|
| 183 | - ->asBoolean() |
|
| 184 | - ->value(); |
|
| 185 | - } |
|
| 186 | - $data = $seq->at($idx) |
|
| 187 | - ->asOctetString() |
|
| 188 | - ->string(); |
|
| 189 | - if (array_key_exists($extnID, self::MAP_OID_TO_CLASS)) { |
|
| 190 | - $cls = self::MAP_OID_TO_CLASS[$extnID]; |
|
| 191 | - return $cls::_fromDER($data, $critical); |
|
| 192 | - } |
|
| 193 | - return new UnknownExtension($extnID, $critical, new DERData($data)); |
|
| 194 | - } |
|
| 168 | + /** |
|
| 169 | + * Initialize from ASN.1. |
|
| 170 | + * |
|
| 171 | + * @param Sequence $seq |
|
| 172 | + * @return self |
|
| 173 | + */ |
|
| 174 | + public static function fromASN1(Sequence $seq) |
|
| 175 | + { |
|
| 176 | + $extnID = $seq->at(0) |
|
| 177 | + ->asObjectIdentifier() |
|
| 178 | + ->oid(); |
|
| 179 | + $critical = false; |
|
| 180 | + $idx = 1; |
|
| 181 | + if ($seq->has($idx, Element::TYPE_BOOLEAN)) { |
|
| 182 | + $critical = $seq->at($idx++) |
|
| 183 | + ->asBoolean() |
|
| 184 | + ->value(); |
|
| 185 | + } |
|
| 186 | + $data = $seq->at($idx) |
|
| 187 | + ->asOctetString() |
|
| 188 | + ->string(); |
|
| 189 | + if (array_key_exists($extnID, self::MAP_OID_TO_CLASS)) { |
|
| 190 | + $cls = self::MAP_OID_TO_CLASS[$extnID]; |
|
| 191 | + return $cls::_fromDER($data, $critical); |
|
| 192 | + } |
|
| 193 | + return new UnknownExtension($extnID, $critical, new DERData($data)); |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - /** |
|
| 197 | - * Get extension OID. |
|
| 198 | - * |
|
| 199 | - * @return string |
|
| 200 | - */ |
|
| 201 | - public function oid() |
|
| 202 | - { |
|
| 203 | - return $this->_oid; |
|
| 204 | - } |
|
| 196 | + /** |
|
| 197 | + * Get extension OID. |
|
| 198 | + * |
|
| 199 | + * @return string |
|
| 200 | + */ |
|
| 201 | + public function oid() |
|
| 202 | + { |
|
| 203 | + return $this->_oid; |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - /** |
|
| 207 | - * Check whether extension is critical. |
|
| 208 | - * |
|
| 209 | - * @return bool |
|
| 210 | - */ |
|
| 211 | - public function isCritical() |
|
| 212 | - { |
|
| 213 | - return $this->_critical; |
|
| 214 | - } |
|
| 206 | + /** |
|
| 207 | + * Check whether extension is critical. |
|
| 208 | + * |
|
| 209 | + * @return bool |
|
| 210 | + */ |
|
| 211 | + public function isCritical() |
|
| 212 | + { |
|
| 213 | + return $this->_critical; |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - /** |
|
| 217 | - * Generate ASN.1 structure. |
|
| 218 | - * |
|
| 219 | - * @return Sequence |
|
| 220 | - */ |
|
| 221 | - public function toASN1() |
|
| 222 | - { |
|
| 223 | - $elements = array(new ObjectIdentifier($this->_oid)); |
|
| 224 | - if ($this->_critical) { |
|
| 225 | - $elements[] = new Boolean(true); |
|
| 226 | - } |
|
| 227 | - $elements[] = new OctetString($this->_valueASN1()->toDER()); |
|
| 228 | - return new Sequence(...$elements); |
|
| 229 | - } |
|
| 216 | + /** |
|
| 217 | + * Generate ASN.1 structure. |
|
| 218 | + * |
|
| 219 | + * @return Sequence |
|
| 220 | + */ |
|
| 221 | + public function toASN1() |
|
| 222 | + { |
|
| 223 | + $elements = array(new ObjectIdentifier($this->_oid)); |
|
| 224 | + if ($this->_critical) { |
|
| 225 | + $elements[] = new Boolean(true); |
|
| 226 | + } |
|
| 227 | + $elements[] = new OctetString($this->_valueASN1()->toDER()); |
|
| 228 | + return new Sequence(...$elements); |
|
| 229 | + } |
|
| 230 | 230 | } |
@@ -13,55 +13,55 @@ |
||
| 13 | 13 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.8 |
| 14 | 14 | */ |
| 15 | 15 | class SubjectDirectoryAttributesExtension extends Extension implements |
| 16 | - \Countable, |
|
| 17 | - \IteratorAggregate |
|
| 16 | + \Countable, |
|
| 17 | + \IteratorAggregate |
|
| 18 | 18 | { |
| 19 | - use AttributeContainer; |
|
| 19 | + use AttributeContainer; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Constructor. |
|
| 23 | - * |
|
| 24 | - * @param bool $critical |
|
| 25 | - * @param Attribute ...$attribs One or more Attribute objects |
|
| 26 | - */ |
|
| 27 | - public function __construct($critical, Attribute ...$attribs) |
|
| 28 | - { |
|
| 29 | - parent::__construct(self::OID_SUBJECT_DIRECTORY_ATTRIBUTES, $critical); |
|
| 30 | - $this->_attributes = $attribs; |
|
| 31 | - } |
|
| 21 | + /** |
|
| 22 | + * Constructor. |
|
| 23 | + * |
|
| 24 | + * @param bool $critical |
|
| 25 | + * @param Attribute ...$attribs One or more Attribute objects |
|
| 26 | + */ |
|
| 27 | + public function __construct($critical, Attribute ...$attribs) |
|
| 28 | + { |
|
| 29 | + parent::__construct(self::OID_SUBJECT_DIRECTORY_ATTRIBUTES, $critical); |
|
| 30 | + $this->_attributes = $attribs; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * |
|
| 35 | - * {@inheritdoc} |
|
| 36 | - * @return self |
|
| 37 | - */ |
|
| 38 | - protected static function _fromDER($data, $critical) |
|
| 39 | - { |
|
| 40 | - $attribs = array_map( |
|
| 41 | - function (UnspecifiedType $el) { |
|
| 42 | - return Attribute::fromASN1($el->asSequence()); |
|
| 43 | - }, Sequence::fromDER($data)->elements()); |
|
| 44 | - if (!count($attribs)) { |
|
| 45 | - throw new \UnexpectedValueException( |
|
| 46 | - "SubjectDirectoryAttributes must have at least one Attribute."); |
|
| 47 | - } |
|
| 48 | - return new self($critical, ...$attribs); |
|
| 49 | - } |
|
| 33 | + /** |
|
| 34 | + * |
|
| 35 | + * {@inheritdoc} |
|
| 36 | + * @return self |
|
| 37 | + */ |
|
| 38 | + protected static function _fromDER($data, $critical) |
|
| 39 | + { |
|
| 40 | + $attribs = array_map( |
|
| 41 | + function (UnspecifiedType $el) { |
|
| 42 | + return Attribute::fromASN1($el->asSequence()); |
|
| 43 | + }, Sequence::fromDER($data)->elements()); |
|
| 44 | + if (!count($attribs)) { |
|
| 45 | + throw new \UnexpectedValueException( |
|
| 46 | + "SubjectDirectoryAttributes must have at least one Attribute."); |
|
| 47 | + } |
|
| 48 | + return new self($critical, ...$attribs); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * |
|
| 53 | - * {@inheritdoc} |
|
| 54 | - * @return Sequence |
|
| 55 | - */ |
|
| 56 | - protected function _valueASN1() |
|
| 57 | - { |
|
| 58 | - if (!count($this->_attributes)) { |
|
| 59 | - throw new \LogicException("No attributes"); |
|
| 60 | - } |
|
| 61 | - $elements = array_map( |
|
| 62 | - function (Attribute $attr) { |
|
| 63 | - return $attr->toASN1(); |
|
| 64 | - }, array_values($this->_attributes)); |
|
| 65 | - return new Sequence(...$elements); |
|
| 66 | - } |
|
| 51 | + /** |
|
| 52 | + * |
|
| 53 | + * {@inheritdoc} |
|
| 54 | + * @return Sequence |
|
| 55 | + */ |
|
| 56 | + protected function _valueASN1() |
|
| 57 | + { |
|
| 58 | + if (!count($this->_attributes)) { |
|
| 59 | + throw new \LogicException("No attributes"); |
|
| 60 | + } |
|
| 61 | + $elements = array_map( |
|
| 62 | + function (Attribute $attr) { |
|
| 63 | + return $attr->toASN1(); |
|
| 64 | + }, array_values($this->_attributes)); |
|
| 65 | + return new Sequence(...$elements); |
|
| 66 | + } |
|
| 67 | 67 | } |
@@ -14,106 +14,106 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class BasicConstraintsExtension extends Extension |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Whether certificate is a CA. |
|
| 19 | - * |
|
| 20 | - * @var boolean $_ca |
|
| 21 | - */ |
|
| 22 | - protected $_ca; |
|
| 17 | + /** |
|
| 18 | + * Whether certificate is a CA. |
|
| 19 | + * |
|
| 20 | + * @var boolean $_ca |
|
| 21 | + */ |
|
| 22 | + protected $_ca; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Maximum certification path length. |
|
| 26 | - * |
|
| 27 | - * @var int|null $_pathLen |
|
| 28 | - */ |
|
| 29 | - protected $_pathLen; |
|
| 24 | + /** |
|
| 25 | + * Maximum certification path length. |
|
| 26 | + * |
|
| 27 | + * @var int|null $_pathLen |
|
| 28 | + */ |
|
| 29 | + protected $_pathLen; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Constructor. |
|
| 33 | - * |
|
| 34 | - * @param bool $critical |
|
| 35 | - * @param bool $ca |
|
| 36 | - * @param int|null $path_len |
|
| 37 | - */ |
|
| 38 | - public function __construct($critical, $ca, $path_len = null) |
|
| 39 | - { |
|
| 40 | - parent::__construct(self::OID_BASIC_CONSTRAINTS, $critical); |
|
| 41 | - $this->_ca = (bool) $ca; |
|
| 42 | - $this->_pathLen = $path_len; |
|
| 43 | - } |
|
| 31 | + /** |
|
| 32 | + * Constructor. |
|
| 33 | + * |
|
| 34 | + * @param bool $critical |
|
| 35 | + * @param bool $ca |
|
| 36 | + * @param int|null $path_len |
|
| 37 | + */ |
|
| 38 | + public function __construct($critical, $ca, $path_len = null) |
|
| 39 | + { |
|
| 40 | + parent::__construct(self::OID_BASIC_CONSTRAINTS, $critical); |
|
| 41 | + $this->_ca = (bool) $ca; |
|
| 42 | + $this->_pathLen = $path_len; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * |
|
| 47 | - * {@inheritdoc} |
|
| 48 | - * @return self |
|
| 49 | - */ |
|
| 50 | - protected static function _fromDER($data, $critical) |
|
| 51 | - { |
|
| 52 | - $seq = Sequence::fromDER($data); |
|
| 53 | - $ca = false; |
|
| 54 | - $path_len = null; |
|
| 55 | - $idx = 0; |
|
| 56 | - if ($seq->has($idx, Element::TYPE_BOOLEAN)) { |
|
| 57 | - $ca = $seq->at($idx++) |
|
| 58 | - ->asBoolean() |
|
| 59 | - ->value(); |
|
| 60 | - } |
|
| 61 | - if ($seq->has($idx, Element::TYPE_INTEGER)) { |
|
| 62 | - $path_len = $seq->at($idx) |
|
| 63 | - ->asInteger() |
|
| 64 | - ->number(); |
|
| 65 | - } |
|
| 66 | - return new self($critical, $ca, $path_len); |
|
| 67 | - } |
|
| 45 | + /** |
|
| 46 | + * |
|
| 47 | + * {@inheritdoc} |
|
| 48 | + * @return self |
|
| 49 | + */ |
|
| 50 | + protected static function _fromDER($data, $critical) |
|
| 51 | + { |
|
| 52 | + $seq = Sequence::fromDER($data); |
|
| 53 | + $ca = false; |
|
| 54 | + $path_len = null; |
|
| 55 | + $idx = 0; |
|
| 56 | + if ($seq->has($idx, Element::TYPE_BOOLEAN)) { |
|
| 57 | + $ca = $seq->at($idx++) |
|
| 58 | + ->asBoolean() |
|
| 59 | + ->value(); |
|
| 60 | + } |
|
| 61 | + if ($seq->has($idx, Element::TYPE_INTEGER)) { |
|
| 62 | + $path_len = $seq->at($idx) |
|
| 63 | + ->asInteger() |
|
| 64 | + ->number(); |
|
| 65 | + } |
|
| 66 | + return new self($critical, $ca, $path_len); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Whether certificate is a CA. |
|
| 71 | - * |
|
| 72 | - * @return bool |
|
| 73 | - */ |
|
| 74 | - public function isCA() |
|
| 75 | - { |
|
| 76 | - return $this->_ca; |
|
| 77 | - } |
|
| 69 | + /** |
|
| 70 | + * Whether certificate is a CA. |
|
| 71 | + * |
|
| 72 | + * @return bool |
|
| 73 | + */ |
|
| 74 | + public function isCA() |
|
| 75 | + { |
|
| 76 | + return $this->_ca; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Whether path length is present. |
|
| 81 | - * |
|
| 82 | - * @return bool |
|
| 83 | - */ |
|
| 84 | - public function hasPathLen() |
|
| 85 | - { |
|
| 86 | - return isset($this->_pathLen); |
|
| 87 | - } |
|
| 79 | + /** |
|
| 80 | + * Whether path length is present. |
|
| 81 | + * |
|
| 82 | + * @return bool |
|
| 83 | + */ |
|
| 84 | + public function hasPathLen() |
|
| 85 | + { |
|
| 86 | + return isset($this->_pathLen); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Get path length. |
|
| 91 | - * |
|
| 92 | - * @throws \LogicException |
|
| 93 | - * @return int |
|
| 94 | - */ |
|
| 95 | - public function pathLen() |
|
| 96 | - { |
|
| 97 | - if (!$this->hasPathLen()) { |
|
| 98 | - throw new \LogicException("pathLenConstraint not set."); |
|
| 99 | - } |
|
| 100 | - return $this->_pathLen; |
|
| 101 | - } |
|
| 89 | + /** |
|
| 90 | + * Get path length. |
|
| 91 | + * |
|
| 92 | + * @throws \LogicException |
|
| 93 | + * @return int |
|
| 94 | + */ |
|
| 95 | + public function pathLen() |
|
| 96 | + { |
|
| 97 | + if (!$this->hasPathLen()) { |
|
| 98 | + throw new \LogicException("pathLenConstraint not set."); |
|
| 99 | + } |
|
| 100 | + return $this->_pathLen; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * |
|
| 105 | - * {@inheritdoc} |
|
| 106 | - * @return Sequence |
|
| 107 | - */ |
|
| 108 | - protected function _valueASN1() |
|
| 109 | - { |
|
| 110 | - $elements = array(); |
|
| 111 | - if ($this->_ca) { |
|
| 112 | - $elements[] = new Boolean(true); |
|
| 113 | - } |
|
| 114 | - if (isset($this->_pathLen)) { |
|
| 115 | - $elements[] = new Integer($this->_pathLen); |
|
| 116 | - } |
|
| 117 | - return new Sequence(...$elements); |
|
| 118 | - } |
|
| 103 | + /** |
|
| 104 | + * |
|
| 105 | + * {@inheritdoc} |
|
| 106 | + * @return Sequence |
|
| 107 | + */ |
|
| 108 | + protected function _valueASN1() |
|
| 109 | + { |
|
| 110 | + $elements = array(); |
|
| 111 | + if ($this->_ca) { |
|
| 112 | + $elements[] = new Boolean(true); |
|
| 113 | + } |
|
| 114 | + if (isset($this->_pathLen)) { |
|
| 115 | + $elements[] = new Integer($this->_pathLen); |
|
| 116 | + } |
|
| 117 | + return new Sequence(...$elements); |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -13,52 +13,52 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class FullName extends DistributionPointName |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Names. |
|
| 18 | - * |
|
| 19 | - * @var GeneralNames $_names |
|
| 20 | - */ |
|
| 21 | - protected $_names; |
|
| 16 | + /** |
|
| 17 | + * Names. |
|
| 18 | + * |
|
| 19 | + * @var GeneralNames $_names |
|
| 20 | + */ |
|
| 21 | + protected $_names; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Constructor. |
|
| 25 | - * |
|
| 26 | - * @param GeneralNames $names |
|
| 27 | - */ |
|
| 28 | - public function __construct(GeneralNames $names) |
|
| 29 | - { |
|
| 30 | - $this->_tag = self::TAG_FULL_NAME; |
|
| 31 | - $this->_names = $names; |
|
| 32 | - } |
|
| 23 | + /** |
|
| 24 | + * Constructor. |
|
| 25 | + * |
|
| 26 | + * @param GeneralNames $names |
|
| 27 | + */ |
|
| 28 | + public function __construct(GeneralNames $names) |
|
| 29 | + { |
|
| 30 | + $this->_tag = self::TAG_FULL_NAME; |
|
| 31 | + $this->_names = $names; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Initialize with a single URI. |
|
| 36 | - * |
|
| 37 | - * @param string $uri |
|
| 38 | - * @return self |
|
| 39 | - */ |
|
| 40 | - public static function fromURI($uri) |
|
| 41 | - { |
|
| 42 | - return new self(new GeneralNames(new UniformResourceIdentifier($uri))); |
|
| 43 | - } |
|
| 34 | + /** |
|
| 35 | + * Initialize with a single URI. |
|
| 36 | + * |
|
| 37 | + * @param string $uri |
|
| 38 | + * @return self |
|
| 39 | + */ |
|
| 40 | + public static function fromURI($uri) |
|
| 41 | + { |
|
| 42 | + return new self(new GeneralNames(new UniformResourceIdentifier($uri))); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Get names. |
|
| 47 | - * |
|
| 48 | - * @return GeneralNames |
|
| 49 | - */ |
|
| 50 | - public function names() |
|
| 51 | - { |
|
| 52 | - return $this->_names; |
|
| 53 | - } |
|
| 45 | + /** |
|
| 46 | + * Get names. |
|
| 47 | + * |
|
| 48 | + * @return GeneralNames |
|
| 49 | + */ |
|
| 50 | + public function names() |
|
| 51 | + { |
|
| 52 | + return $this->_names; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * |
|
| 57 | - * {@inheritdoc} |
|
| 58 | - * @return \ASN1\Type\Constructed\Sequence |
|
| 59 | - */ |
|
| 60 | - protected function _valueASN1() |
|
| 61 | - { |
|
| 62 | - return $this->_names->toASN1(); |
|
| 63 | - } |
|
| 55 | + /** |
|
| 56 | + * |
|
| 57 | + * {@inheritdoc} |
|
| 58 | + * @return \ASN1\Type\Constructed\Sequence |
|
| 59 | + */ |
|
| 60 | + protected function _valueASN1() |
|
| 61 | + { |
|
| 62 | + return $this->_names->toASN1(); |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -16,215 +16,215 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class DistributionPoint |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Distribution point name. |
|
| 21 | - * |
|
| 22 | - * @var DistributionPointName $_distributionPoint |
|
| 23 | - */ |
|
| 24 | - protected $_distributionPoint; |
|
| 19 | + /** |
|
| 20 | + * Distribution point name. |
|
| 21 | + * |
|
| 22 | + * @var DistributionPointName $_distributionPoint |
|
| 23 | + */ |
|
| 24 | + protected $_distributionPoint; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Revocation reason. |
|
| 28 | - * |
|
| 29 | - * @var ReasonFlags $_reasons |
|
| 30 | - */ |
|
| 31 | - protected $_reasons; |
|
| 26 | + /** |
|
| 27 | + * Revocation reason. |
|
| 28 | + * |
|
| 29 | + * @var ReasonFlags $_reasons |
|
| 30 | + */ |
|
| 31 | + protected $_reasons; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * CRL issuer. |
|
| 35 | - * |
|
| 36 | - * @var GeneralNames $_issuer |
|
| 37 | - */ |
|
| 38 | - protected $_issuer; |
|
| 33 | + /** |
|
| 34 | + * CRL issuer. |
|
| 35 | + * |
|
| 36 | + * @var GeneralNames $_issuer |
|
| 37 | + */ |
|
| 38 | + protected $_issuer; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Constructor. |
|
| 42 | - * |
|
| 43 | - * @param DistributionPointName $name |
|
| 44 | - * @param ReasonFlags $reasons |
|
| 45 | - * @param GeneralNames $issuer |
|
| 46 | - */ |
|
| 47 | - public function __construct(DistributionPointName $name = null, |
|
| 48 | - ReasonFlags $reasons = null, GeneralNames $issuer = null) |
|
| 49 | - { |
|
| 50 | - $this->_distributionPoint = $name; |
|
| 51 | - $this->_reasons = $reasons; |
|
| 52 | - $this->_issuer = $issuer; |
|
| 53 | - } |
|
| 40 | + /** |
|
| 41 | + * Constructor. |
|
| 42 | + * |
|
| 43 | + * @param DistributionPointName $name |
|
| 44 | + * @param ReasonFlags $reasons |
|
| 45 | + * @param GeneralNames $issuer |
|
| 46 | + */ |
|
| 47 | + public function __construct(DistributionPointName $name = null, |
|
| 48 | + ReasonFlags $reasons = null, GeneralNames $issuer = null) |
|
| 49 | + { |
|
| 50 | + $this->_distributionPoint = $name; |
|
| 51 | + $this->_reasons = $reasons; |
|
| 52 | + $this->_issuer = $issuer; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Initialize from ASN.1. |
|
| 57 | - * |
|
| 58 | - * @param Sequence $seq |
|
| 59 | - * @return self |
|
| 60 | - */ |
|
| 61 | - public static function fromASN1(Sequence $seq) |
|
| 62 | - { |
|
| 63 | - $name = null; |
|
| 64 | - $reasons = null; |
|
| 65 | - $issuer = null; |
|
| 66 | - if ($seq->hasTagged(0)) { |
|
| 67 | - // promoted to explicit tagging because underlying type is CHOICE |
|
| 68 | - $name = DistributionPointName::fromTaggedType( |
|
| 69 | - $seq->getTagged(0) |
|
| 70 | - ->asExplicit() |
|
| 71 | - ->asTagged()); |
|
| 72 | - } |
|
| 73 | - if ($seq->hasTagged(1)) { |
|
| 74 | - $reasons = ReasonFlags::fromASN1( |
|
| 75 | - $seq->getTagged(1) |
|
| 76 | - ->asImplicit(Element::TYPE_BIT_STRING) |
|
| 77 | - ->asBitString()); |
|
| 78 | - } |
|
| 79 | - if ($seq->hasTagged(2)) { |
|
| 80 | - $issuer = GeneralNames::fromASN1( |
|
| 81 | - $seq->getTagged(2) |
|
| 82 | - ->asImplicit(Element::TYPE_SEQUENCE) |
|
| 83 | - ->asSequence()); |
|
| 84 | - } |
|
| 85 | - return new self($name, $reasons, $issuer); |
|
| 86 | - } |
|
| 55 | + /** |
|
| 56 | + * Initialize from ASN.1. |
|
| 57 | + * |
|
| 58 | + * @param Sequence $seq |
|
| 59 | + * @return self |
|
| 60 | + */ |
|
| 61 | + public static function fromASN1(Sequence $seq) |
|
| 62 | + { |
|
| 63 | + $name = null; |
|
| 64 | + $reasons = null; |
|
| 65 | + $issuer = null; |
|
| 66 | + if ($seq->hasTagged(0)) { |
|
| 67 | + // promoted to explicit tagging because underlying type is CHOICE |
|
| 68 | + $name = DistributionPointName::fromTaggedType( |
|
| 69 | + $seq->getTagged(0) |
|
| 70 | + ->asExplicit() |
|
| 71 | + ->asTagged()); |
|
| 72 | + } |
|
| 73 | + if ($seq->hasTagged(1)) { |
|
| 74 | + $reasons = ReasonFlags::fromASN1( |
|
| 75 | + $seq->getTagged(1) |
|
| 76 | + ->asImplicit(Element::TYPE_BIT_STRING) |
|
| 77 | + ->asBitString()); |
|
| 78 | + } |
|
| 79 | + if ($seq->hasTagged(2)) { |
|
| 80 | + $issuer = GeneralNames::fromASN1( |
|
| 81 | + $seq->getTagged(2) |
|
| 82 | + ->asImplicit(Element::TYPE_SEQUENCE) |
|
| 83 | + ->asSequence()); |
|
| 84 | + } |
|
| 85 | + return new self($name, $reasons, $issuer); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Check whether distribution point name is set. |
|
| 90 | - * |
|
| 91 | - * @return bool |
|
| 92 | - */ |
|
| 93 | - public function hasDistributionPointName() |
|
| 94 | - { |
|
| 95 | - return isset($this->_distributionPoint); |
|
| 96 | - } |
|
| 88 | + /** |
|
| 89 | + * Check whether distribution point name is set. |
|
| 90 | + * |
|
| 91 | + * @return bool |
|
| 92 | + */ |
|
| 93 | + public function hasDistributionPointName() |
|
| 94 | + { |
|
| 95 | + return isset($this->_distributionPoint); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Get distribution point name. |
|
| 100 | - * |
|
| 101 | - * @throws \LogicException |
|
| 102 | - * @return DistributionPointName |
|
| 103 | - */ |
|
| 104 | - public function distributionPointName() |
|
| 105 | - { |
|
| 106 | - if (!$this->hasDistributionPointName()) { |
|
| 107 | - throw new \LogicException("distributionPoint not set."); |
|
| 108 | - } |
|
| 109 | - return $this->_distributionPoint; |
|
| 110 | - } |
|
| 98 | + /** |
|
| 99 | + * Get distribution point name. |
|
| 100 | + * |
|
| 101 | + * @throws \LogicException |
|
| 102 | + * @return DistributionPointName |
|
| 103 | + */ |
|
| 104 | + public function distributionPointName() |
|
| 105 | + { |
|
| 106 | + if (!$this->hasDistributionPointName()) { |
|
| 107 | + throw new \LogicException("distributionPoint not set."); |
|
| 108 | + } |
|
| 109 | + return $this->_distributionPoint; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * Check whether distribution point name is set and it's a full name. |
|
| 114 | - * |
|
| 115 | - * @return bool |
|
| 116 | - */ |
|
| 117 | - public function hasFullName() |
|
| 118 | - { |
|
| 119 | - return $this->distributionPointName()->tag() == |
|
| 120 | - DistributionPointName::TAG_FULL_NAME; |
|
| 121 | - } |
|
| 112 | + /** |
|
| 113 | + * Check whether distribution point name is set and it's a full name. |
|
| 114 | + * |
|
| 115 | + * @return bool |
|
| 116 | + */ |
|
| 117 | + public function hasFullName() |
|
| 118 | + { |
|
| 119 | + return $this->distributionPointName()->tag() == |
|
| 120 | + DistributionPointName::TAG_FULL_NAME; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Get full distribution point name. |
|
| 125 | - * |
|
| 126 | - * @throws \LogicException |
|
| 127 | - * @return FullName |
|
| 128 | - */ |
|
| 129 | - public function fullName() |
|
| 130 | - { |
|
| 131 | - if (!$this->hasFullName()) { |
|
| 132 | - throw new \LogicException("fullName not set."); |
|
| 133 | - } |
|
| 134 | - return $this->_distributionPoint; |
|
| 135 | - } |
|
| 123 | + /** |
|
| 124 | + * Get full distribution point name. |
|
| 125 | + * |
|
| 126 | + * @throws \LogicException |
|
| 127 | + * @return FullName |
|
| 128 | + */ |
|
| 129 | + public function fullName() |
|
| 130 | + { |
|
| 131 | + if (!$this->hasFullName()) { |
|
| 132 | + throw new \LogicException("fullName not set."); |
|
| 133 | + } |
|
| 134 | + return $this->_distributionPoint; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Check whether distribution point name is set and it's a relative name. |
|
| 139 | - * |
|
| 140 | - * @return bool |
|
| 141 | - */ |
|
| 142 | - public function hasRelativeName() |
|
| 143 | - { |
|
| 144 | - return $this->distributionPointName()->tag() == |
|
| 145 | - DistributionPointName::TAG_RDN; |
|
| 146 | - } |
|
| 137 | + /** |
|
| 138 | + * Check whether distribution point name is set and it's a relative name. |
|
| 139 | + * |
|
| 140 | + * @return bool |
|
| 141 | + */ |
|
| 142 | + public function hasRelativeName() |
|
| 143 | + { |
|
| 144 | + return $this->distributionPointName()->tag() == |
|
| 145 | + DistributionPointName::TAG_RDN; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Get relative distribution point name. |
|
| 150 | - * |
|
| 151 | - * @throws \LogicException |
|
| 152 | - * @return RelativeName |
|
| 153 | - */ |
|
| 154 | - public function relativeName() |
|
| 155 | - { |
|
| 156 | - if (!$this->hasRelativeName()) { |
|
| 157 | - throw new \LogicException("nameRelativeToCRLIssuer not set."); |
|
| 158 | - } |
|
| 159 | - return $this->_distributionPoint; |
|
| 160 | - } |
|
| 148 | + /** |
|
| 149 | + * Get relative distribution point name. |
|
| 150 | + * |
|
| 151 | + * @throws \LogicException |
|
| 152 | + * @return RelativeName |
|
| 153 | + */ |
|
| 154 | + public function relativeName() |
|
| 155 | + { |
|
| 156 | + if (!$this->hasRelativeName()) { |
|
| 157 | + throw new \LogicException("nameRelativeToCRLIssuer not set."); |
|
| 158 | + } |
|
| 159 | + return $this->_distributionPoint; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * Check whether reasons flags is set. |
|
| 164 | - * |
|
| 165 | - * @return bool |
|
| 166 | - */ |
|
| 167 | - public function hasReasons() |
|
| 168 | - { |
|
| 169 | - return isset($this->_reasons); |
|
| 170 | - } |
|
| 162 | + /** |
|
| 163 | + * Check whether reasons flags is set. |
|
| 164 | + * |
|
| 165 | + * @return bool |
|
| 166 | + */ |
|
| 167 | + public function hasReasons() |
|
| 168 | + { |
|
| 169 | + return isset($this->_reasons); |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - /** |
|
| 173 | - * Get revocation reason flags. |
|
| 174 | - * |
|
| 175 | - * @throws \LogicException |
|
| 176 | - * @return ReasonFlags |
|
| 177 | - */ |
|
| 178 | - public function reasons() |
|
| 179 | - { |
|
| 180 | - if (!$this->hasReasons()) { |
|
| 181 | - throw new \LogicException("reasons not set."); |
|
| 182 | - } |
|
| 183 | - return $this->_reasons; |
|
| 184 | - } |
|
| 172 | + /** |
|
| 173 | + * Get revocation reason flags. |
|
| 174 | + * |
|
| 175 | + * @throws \LogicException |
|
| 176 | + * @return ReasonFlags |
|
| 177 | + */ |
|
| 178 | + public function reasons() |
|
| 179 | + { |
|
| 180 | + if (!$this->hasReasons()) { |
|
| 181 | + throw new \LogicException("reasons not set."); |
|
| 182 | + } |
|
| 183 | + return $this->_reasons; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - /** |
|
| 187 | - * Check whether cRLIssuer is set. |
|
| 188 | - * |
|
| 189 | - * @return bool |
|
| 190 | - */ |
|
| 191 | - public function hasCRLIssuer() |
|
| 192 | - { |
|
| 193 | - return isset($this->_issuer); |
|
| 194 | - } |
|
| 186 | + /** |
|
| 187 | + * Check whether cRLIssuer is set. |
|
| 188 | + * |
|
| 189 | + * @return bool |
|
| 190 | + */ |
|
| 191 | + public function hasCRLIssuer() |
|
| 192 | + { |
|
| 193 | + return isset($this->_issuer); |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - /** |
|
| 197 | - * Get CRL issuer. |
|
| 198 | - * |
|
| 199 | - * @throws \LogicException |
|
| 200 | - * @return GeneralNames |
|
| 201 | - */ |
|
| 202 | - public function crlIssuer() |
|
| 203 | - { |
|
| 204 | - if (!$this->hasCRLIssuer()) { |
|
| 205 | - throw new \LogicException("crlIssuer not set."); |
|
| 206 | - } |
|
| 207 | - return $this->_issuer; |
|
| 208 | - } |
|
| 196 | + /** |
|
| 197 | + * Get CRL issuer. |
|
| 198 | + * |
|
| 199 | + * @throws \LogicException |
|
| 200 | + * @return GeneralNames |
|
| 201 | + */ |
|
| 202 | + public function crlIssuer() |
|
| 203 | + { |
|
| 204 | + if (!$this->hasCRLIssuer()) { |
|
| 205 | + throw new \LogicException("crlIssuer not set."); |
|
| 206 | + } |
|
| 207 | + return $this->_issuer; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * Generate ASN.1 structure. |
|
| 212 | - * |
|
| 213 | - * @return Sequence |
|
| 214 | - */ |
|
| 215 | - public function toASN1() |
|
| 216 | - { |
|
| 217 | - $elements = array(); |
|
| 218 | - if (isset($this->_distributionPoint)) { |
|
| 219 | - $elements[] = new ExplicitlyTaggedType(0, |
|
| 220 | - $this->_distributionPoint->toASN1()); |
|
| 221 | - } |
|
| 222 | - if (isset($this->_reasons)) { |
|
| 223 | - $elements[] = new ImplicitlyTaggedType(1, $this->_reasons->toASN1()); |
|
| 224 | - } |
|
| 225 | - if (isset($this->_issuer)) { |
|
| 226 | - $elements[] = new ImplicitlyTaggedType(2, $this->_issuer->toASN1()); |
|
| 227 | - } |
|
| 228 | - return new Sequence(...$elements); |
|
| 229 | - } |
|
| 210 | + /** |
|
| 211 | + * Generate ASN.1 structure. |
|
| 212 | + * |
|
| 213 | + * @return Sequence |
|
| 214 | + */ |
|
| 215 | + public function toASN1() |
|
| 216 | + { |
|
| 217 | + $elements = array(); |
|
| 218 | + if (isset($this->_distributionPoint)) { |
|
| 219 | + $elements[] = new ExplicitlyTaggedType(0, |
|
| 220 | + $this->_distributionPoint->toASN1()); |
|
| 221 | + } |
|
| 222 | + if (isset($this->_reasons)) { |
|
| 223 | + $elements[] = new ImplicitlyTaggedType(1, $this->_reasons->toASN1()); |
|
| 224 | + } |
|
| 225 | + if (isset($this->_issuer)) { |
|
| 226 | + $elements[] = new ImplicitlyTaggedType(2, $this->_issuer->toASN1()); |
|
| 227 | + } |
|
| 228 | + return new Sequence(...$elements); |
|
| 229 | + } |
|
| 230 | 230 | } |
@@ -13,41 +13,41 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class RelativeName extends DistributionPointName |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Relative distinguished name. |
|
| 18 | - * |
|
| 19 | - * @var RDN $_rdn |
|
| 20 | - */ |
|
| 21 | - protected $_rdn; |
|
| 16 | + /** |
|
| 17 | + * Relative distinguished name. |
|
| 18 | + * |
|
| 19 | + * @var RDN $_rdn |
|
| 20 | + */ |
|
| 21 | + protected $_rdn; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Constructor. |
|
| 25 | - * |
|
| 26 | - * @param RDN $rdn |
|
| 27 | - */ |
|
| 28 | - public function __construct(RDN $rdn) |
|
| 29 | - { |
|
| 30 | - $this->_tag = self::TAG_RDN; |
|
| 31 | - $this->_rdn = $rdn; |
|
| 32 | - } |
|
| 23 | + /** |
|
| 24 | + * Constructor. |
|
| 25 | + * |
|
| 26 | + * @param RDN $rdn |
|
| 27 | + */ |
|
| 28 | + public function __construct(RDN $rdn) |
|
| 29 | + { |
|
| 30 | + $this->_tag = self::TAG_RDN; |
|
| 31 | + $this->_rdn = $rdn; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Get RDN. |
|
| 36 | - * |
|
| 37 | - * @return RDN |
|
| 38 | - */ |
|
| 39 | - public function rdn() |
|
| 40 | - { |
|
| 41 | - return $this->_rdn; |
|
| 42 | - } |
|
| 34 | + /** |
|
| 35 | + * Get RDN. |
|
| 36 | + * |
|
| 37 | + * @return RDN |
|
| 38 | + */ |
|
| 39 | + public function rdn() |
|
| 40 | + { |
|
| 41 | + return $this->_rdn; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * |
|
| 46 | - * {@inheritdoc} |
|
| 47 | - * @return \ASN1\Type\Constructed\Set |
|
| 48 | - */ |
|
| 49 | - protected function _valueASN1() |
|
| 50 | - { |
|
| 51 | - return $this->_rdn->toASN1(); |
|
| 52 | - } |
|
| 44 | + /** |
|
| 45 | + * |
|
| 46 | + * {@inheritdoc} |
|
| 47 | + * @return \ASN1\Type\Constructed\Set |
|
| 48 | + */ |
|
| 49 | + protected function _valueASN1() |
|
| 50 | + { |
|
| 51 | + return $this->_rdn->toASN1(); |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -16,64 +16,64 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | abstract class DistributionPointName |
| 18 | 18 | { |
| 19 | - const TAG_FULL_NAME = 0; |
|
| 20 | - const TAG_RDN = 1; |
|
| 19 | + const TAG_FULL_NAME = 0; |
|
| 20 | + const TAG_RDN = 1; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Type. |
|
| 24 | - * |
|
| 25 | - * @var int $_tag |
|
| 26 | - */ |
|
| 27 | - protected $_tag; |
|
| 22 | + /** |
|
| 23 | + * Type. |
|
| 24 | + * |
|
| 25 | + * @var int $_tag |
|
| 26 | + */ |
|
| 27 | + protected $_tag; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Generate ASN.1 element. |
|
| 31 | - * |
|
| 32 | - * @return Element |
|
| 33 | - */ |
|
| 34 | - abstract protected function _valueASN1(); |
|
| 29 | + /** |
|
| 30 | + * Generate ASN.1 element. |
|
| 31 | + * |
|
| 32 | + * @return Element |
|
| 33 | + */ |
|
| 34 | + abstract protected function _valueASN1(); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Initialize from TaggedType. |
|
| 38 | - * |
|
| 39 | - * @param TaggedType $el |
|
| 40 | - * @throws \UnexpectedValueException |
|
| 41 | - * @return self |
|
| 42 | - */ |
|
| 43 | - public static function fromTaggedType(TaggedType $el) |
|
| 44 | - { |
|
| 45 | - switch ($el->tag()) { |
|
| 46 | - case self::TAG_FULL_NAME: |
|
| 47 | - return new FullName( |
|
| 48 | - GeneralNames::fromASN1( |
|
| 49 | - $el->asImplicit(Element::TYPE_SEQUENCE)->asSequence())); |
|
| 50 | - case self::TAG_RDN: |
|
| 51 | - return new RelativeName( |
|
| 52 | - RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet())); |
|
| 53 | - default: |
|
| 54 | - throw new \UnexpectedValueException( |
|
| 55 | - "DistributionPointName tag " . $el->tag() . " not supported."); |
|
| 56 | - } |
|
| 57 | - } |
|
| 36 | + /** |
|
| 37 | + * Initialize from TaggedType. |
|
| 38 | + * |
|
| 39 | + * @param TaggedType $el |
|
| 40 | + * @throws \UnexpectedValueException |
|
| 41 | + * @return self |
|
| 42 | + */ |
|
| 43 | + public static function fromTaggedType(TaggedType $el) |
|
| 44 | + { |
|
| 45 | + switch ($el->tag()) { |
|
| 46 | + case self::TAG_FULL_NAME: |
|
| 47 | + return new FullName( |
|
| 48 | + GeneralNames::fromASN1( |
|
| 49 | + $el->asImplicit(Element::TYPE_SEQUENCE)->asSequence())); |
|
| 50 | + case self::TAG_RDN: |
|
| 51 | + return new RelativeName( |
|
| 52 | + RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet())); |
|
| 53 | + default: |
|
| 54 | + throw new \UnexpectedValueException( |
|
| 55 | + "DistributionPointName tag " . $el->tag() . " not supported."); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Get type tag. |
|
| 61 | - * |
|
| 62 | - * @return int |
|
| 63 | - */ |
|
| 64 | - public function tag() |
|
| 65 | - { |
|
| 66 | - return $this->_tag; |
|
| 67 | - } |
|
| 59 | + /** |
|
| 60 | + * Get type tag. |
|
| 61 | + * |
|
| 62 | + * @return int |
|
| 63 | + */ |
|
| 64 | + public function tag() |
|
| 65 | + { |
|
| 66 | + return $this->_tag; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Generate ASN.1 structure. |
|
| 71 | - * |
|
| 72 | - * @return ImplicitlyTaggedType |
|
| 73 | - */ |
|
| 74 | - public function toASN1() |
|
| 75 | - { |
|
| 76 | - $element = $this->_valueASN1(); |
|
| 77 | - return new ImplicitlyTaggedType($this->_tag, $element); |
|
| 78 | - } |
|
| 69 | + /** |
|
| 70 | + * Generate ASN.1 structure. |
|
| 71 | + * |
|
| 72 | + * @return ImplicitlyTaggedType |
|
| 73 | + */ |
|
| 74 | + public function toASN1() |
|
| 75 | + { |
|
| 76 | + $element = $this->_valueASN1(); |
|
| 77 | + return new ImplicitlyTaggedType($this->_tag, $element); |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -13,143 +13,143 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class ReasonFlags |
| 15 | 15 | { |
| 16 | - // const UNUSED = 0x100; |
|
| 17 | - const KEY_COMPROMISE = 0x080; |
|
| 18 | - const CA_COMPROMISE = 0x040; |
|
| 19 | - const AFFILIATION_CHANGED = 0x020; |
|
| 20 | - const SUPERSEDED = 0x010; |
|
| 21 | - const CESSATION_OF_OPERATION = 0x008; |
|
| 22 | - const CERTIFICATE_HOLD = 0x004; |
|
| 23 | - const PRIVILEGE_WITHDRAWN = 0x002; |
|
| 24 | - const AA_COMPROMISE = 0x001; |
|
| 16 | + // const UNUSED = 0x100; |
|
| 17 | + const KEY_COMPROMISE = 0x080; |
|
| 18 | + const CA_COMPROMISE = 0x040; |
|
| 19 | + const AFFILIATION_CHANGED = 0x020; |
|
| 20 | + const SUPERSEDED = 0x010; |
|
| 21 | + const CESSATION_OF_OPERATION = 0x008; |
|
| 22 | + const CERTIFICATE_HOLD = 0x004; |
|
| 23 | + const PRIVILEGE_WITHDRAWN = 0x002; |
|
| 24 | + const AA_COMPROMISE = 0x001; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Flags. |
|
| 28 | - * |
|
| 29 | - * @var int $_flags |
|
| 30 | - */ |
|
| 31 | - protected $_flags; |
|
| 26 | + /** |
|
| 27 | + * Flags. |
|
| 28 | + * |
|
| 29 | + * @var int $_flags |
|
| 30 | + */ |
|
| 31 | + protected $_flags; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Constructor. |
|
| 35 | - * |
|
| 36 | - * @param int $flags |
|
| 37 | - */ |
|
| 38 | - public function __construct($flags) |
|
| 39 | - { |
|
| 40 | - $this->_flags = (int) $flags; |
|
| 41 | - } |
|
| 33 | + /** |
|
| 34 | + * Constructor. |
|
| 35 | + * |
|
| 36 | + * @param int $flags |
|
| 37 | + */ |
|
| 38 | + public function __construct($flags) |
|
| 39 | + { |
|
| 40 | + $this->_flags = (int) $flags; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Initialize from ASN.1. |
|
| 45 | - * |
|
| 46 | - * @param BitString $bs |
|
| 47 | - * @return self |
|
| 48 | - */ |
|
| 49 | - public static function fromASN1(BitString $bs) |
|
| 50 | - { |
|
| 51 | - return new self(Flags::fromBitString($bs, 9)->number()); |
|
| 52 | - } |
|
| 43 | + /** |
|
| 44 | + * Initialize from ASN.1. |
|
| 45 | + * |
|
| 46 | + * @param BitString $bs |
|
| 47 | + * @return self |
|
| 48 | + */ |
|
| 49 | + public static function fromASN1(BitString $bs) |
|
| 50 | + { |
|
| 51 | + return new self(Flags::fromBitString($bs, 9)->number()); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Check whether keyCompromise flag is set. |
|
| 56 | - * |
|
| 57 | - * @return bool |
|
| 58 | - */ |
|
| 59 | - public function isKeyCompromise() |
|
| 60 | - { |
|
| 61 | - return $this->_flagSet(self::KEY_COMPROMISE); |
|
| 62 | - } |
|
| 54 | + /** |
|
| 55 | + * Check whether keyCompromise flag is set. |
|
| 56 | + * |
|
| 57 | + * @return bool |
|
| 58 | + */ |
|
| 59 | + public function isKeyCompromise() |
|
| 60 | + { |
|
| 61 | + return $this->_flagSet(self::KEY_COMPROMISE); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Check whether cACompromise flag is set. |
|
| 66 | - * |
|
| 67 | - * @return bool |
|
| 68 | - */ |
|
| 69 | - public function isCACompromise() |
|
| 70 | - { |
|
| 71 | - return $this->_flagSet(self::CA_COMPROMISE); |
|
| 72 | - } |
|
| 64 | + /** |
|
| 65 | + * Check whether cACompromise flag is set. |
|
| 66 | + * |
|
| 67 | + * @return bool |
|
| 68 | + */ |
|
| 69 | + public function isCACompromise() |
|
| 70 | + { |
|
| 71 | + return $this->_flagSet(self::CA_COMPROMISE); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Check whether affiliationChanged flag is set. |
|
| 76 | - * |
|
| 77 | - * @return bool |
|
| 78 | - */ |
|
| 79 | - public function isAffiliationChanged() |
|
| 80 | - { |
|
| 81 | - return $this->_flagSet(self::AFFILIATION_CHANGED); |
|
| 82 | - } |
|
| 74 | + /** |
|
| 75 | + * Check whether affiliationChanged flag is set. |
|
| 76 | + * |
|
| 77 | + * @return bool |
|
| 78 | + */ |
|
| 79 | + public function isAffiliationChanged() |
|
| 80 | + { |
|
| 81 | + return $this->_flagSet(self::AFFILIATION_CHANGED); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Check whether superseded flag is set. |
|
| 86 | - * |
|
| 87 | - * @return bool |
|
| 88 | - */ |
|
| 89 | - public function isSuperseded() |
|
| 90 | - { |
|
| 91 | - return $this->_flagSet(self::SUPERSEDED); |
|
| 92 | - } |
|
| 84 | + /** |
|
| 85 | + * Check whether superseded flag is set. |
|
| 86 | + * |
|
| 87 | + * @return bool |
|
| 88 | + */ |
|
| 89 | + public function isSuperseded() |
|
| 90 | + { |
|
| 91 | + return $this->_flagSet(self::SUPERSEDED); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Check whether cessationOfOperation flag is set. |
|
| 96 | - * |
|
| 97 | - * @return bool |
|
| 98 | - */ |
|
| 99 | - public function isCessationOfOperation() |
|
| 100 | - { |
|
| 101 | - return $this->_flagSet(self::CESSATION_OF_OPERATION); |
|
| 102 | - } |
|
| 94 | + /** |
|
| 95 | + * Check whether cessationOfOperation flag is set. |
|
| 96 | + * |
|
| 97 | + * @return bool |
|
| 98 | + */ |
|
| 99 | + public function isCessationOfOperation() |
|
| 100 | + { |
|
| 101 | + return $this->_flagSet(self::CESSATION_OF_OPERATION); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * Check whether certificateHold flag is set. |
|
| 106 | - * |
|
| 107 | - * @return bool |
|
| 108 | - */ |
|
| 109 | - public function isCertificateHold() |
|
| 110 | - { |
|
| 111 | - return $this->_flagSet(self::CERTIFICATE_HOLD); |
|
| 112 | - } |
|
| 104 | + /** |
|
| 105 | + * Check whether certificateHold flag is set. |
|
| 106 | + * |
|
| 107 | + * @return bool |
|
| 108 | + */ |
|
| 109 | + public function isCertificateHold() |
|
| 110 | + { |
|
| 111 | + return $this->_flagSet(self::CERTIFICATE_HOLD); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Check whether privilegeWithdrawn flag is set. |
|
| 116 | - * |
|
| 117 | - * @return bool |
|
| 118 | - */ |
|
| 119 | - public function isPrivilegeWithdrawn() |
|
| 120 | - { |
|
| 121 | - return $this->_flagSet(self::PRIVILEGE_WITHDRAWN); |
|
| 122 | - } |
|
| 114 | + /** |
|
| 115 | + * Check whether privilegeWithdrawn flag is set. |
|
| 116 | + * |
|
| 117 | + * @return bool |
|
| 118 | + */ |
|
| 119 | + public function isPrivilegeWithdrawn() |
|
| 120 | + { |
|
| 121 | + return $this->_flagSet(self::PRIVILEGE_WITHDRAWN); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Check whether aACompromise flag is set. |
|
| 126 | - * |
|
| 127 | - * @return bool |
|
| 128 | - */ |
|
| 129 | - public function isAACompromise() |
|
| 130 | - { |
|
| 131 | - return $this->_flagSet(self::AA_COMPROMISE); |
|
| 132 | - } |
|
| 124 | + /** |
|
| 125 | + * Check whether aACompromise flag is set. |
|
| 126 | + * |
|
| 127 | + * @return bool |
|
| 128 | + */ |
|
| 129 | + public function isAACompromise() |
|
| 130 | + { |
|
| 131 | + return $this->_flagSet(self::AA_COMPROMISE); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * Generate ASN.1 element. |
|
| 136 | - * |
|
| 137 | - * @return BitString |
|
| 138 | - */ |
|
| 139 | - public function toASN1() |
|
| 140 | - { |
|
| 141 | - $flags = new Flags($this->_flags, 9); |
|
| 142 | - return $flags->bitString()->withoutTrailingZeroes(); |
|
| 143 | - } |
|
| 134 | + /** |
|
| 135 | + * Generate ASN.1 element. |
|
| 136 | + * |
|
| 137 | + * @return BitString |
|
| 138 | + */ |
|
| 139 | + public function toASN1() |
|
| 140 | + { |
|
| 141 | + $flags = new Flags($this->_flags, 9); |
|
| 142 | + return $flags->bitString()->withoutTrailingZeroes(); |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * Check whether given flag is set. |
|
| 147 | - * |
|
| 148 | - * @param int $flag |
|
| 149 | - * @return boolean |
|
| 150 | - */ |
|
| 151 | - protected function _flagSet($flag) |
|
| 152 | - { |
|
| 153 | - return (bool) ($this->_flags & $flag); |
|
| 154 | - } |
|
| 145 | + /** |
|
| 146 | + * Check whether given flag is set. |
|
| 147 | + * |
|
| 148 | + * @param int $flag |
|
| 149 | + * @return boolean |
|
| 150 | + */ |
|
| 151 | + protected function _flagSet($flag) |
|
| 152 | + { |
|
| 153 | + return (bool) ($this->_flags & $flag); |
|
| 154 | + } |
|
| 155 | 155 | } |