@@ -15,60 +15,60 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class TargetName extends Target |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Name. |
|
| 20 | - * |
|
| 21 | - * @var GeneralName $_name |
|
| 22 | - */ |
|
| 23 | - protected $_name; |
|
| 18 | + /** |
|
| 19 | + * Name. |
|
| 20 | + * |
|
| 21 | + * @var GeneralName $_name |
|
| 22 | + */ |
|
| 23 | + protected $_name; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Constructor. |
|
| 27 | - * |
|
| 28 | - * @param GeneralName $name |
|
| 29 | - */ |
|
| 30 | - public function __construct(GeneralName $name) |
|
| 31 | - { |
|
| 32 | - $this->_name = $name; |
|
| 33 | - $this->_type = self::TYPE_NAME; |
|
| 34 | - } |
|
| 25 | + /** |
|
| 26 | + * Constructor. |
|
| 27 | + * |
|
| 28 | + * @param GeneralName $name |
|
| 29 | + */ |
|
| 30 | + public function __construct(GeneralName $name) |
|
| 31 | + { |
|
| 32 | + $this->_name = $name; |
|
| 33 | + $this->_type = self::TYPE_NAME; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * |
|
| 38 | - * @param TaggedType $el |
|
| 39 | - * @return self |
|
| 40 | - */ |
|
| 41 | - public static function fromChosenASN1(TaggedType $el): self |
|
| 42 | - { |
|
| 43 | - return new self(GeneralName::fromASN1($el)); |
|
| 44 | - } |
|
| 36 | + /** |
|
| 37 | + * |
|
| 38 | + * @param TaggedType $el |
|
| 39 | + * @return self |
|
| 40 | + */ |
|
| 41 | + public static function fromChosenASN1(TaggedType $el): self |
|
| 42 | + { |
|
| 43 | + return new self(GeneralName::fromASN1($el)); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * |
|
| 48 | - * {@inheritdoc} |
|
| 49 | - */ |
|
| 50 | - public function string(): string |
|
| 51 | - { |
|
| 52 | - return $this->_name->string(); |
|
| 53 | - } |
|
| 46 | + /** |
|
| 47 | + * |
|
| 48 | + * {@inheritdoc} |
|
| 49 | + */ |
|
| 50 | + public function string(): string |
|
| 51 | + { |
|
| 52 | + return $this->_name->string(); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Get name. |
|
| 57 | - * |
|
| 58 | - * @return GeneralName |
|
| 59 | - */ |
|
| 60 | - public function name(): GeneralName |
|
| 61 | - { |
|
| 62 | - return $this->_name; |
|
| 63 | - } |
|
| 55 | + /** |
|
| 56 | + * Get name. |
|
| 57 | + * |
|
| 58 | + * @return GeneralName |
|
| 59 | + */ |
|
| 60 | + public function name(): GeneralName |
|
| 61 | + { |
|
| 62 | + return $this->_name; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * |
|
| 67 | - * {@inheritdoc} |
|
| 68 | - * @return ExplicitlyTaggedType |
|
| 69 | - */ |
|
| 70 | - public function toASN1(): TaggedType |
|
| 71 | - { |
|
| 72 | - return new ExplicitlyTaggedType($this->_type, $this->_name->toASN1()); |
|
| 73 | - } |
|
| 65 | + /** |
|
| 66 | + * |
|
| 67 | + * {@inheritdoc} |
|
| 68 | + * @return ExplicitlyTaggedType |
|
| 69 | + */ |
|
| 70 | + public function toASN1(): TaggedType |
|
| 71 | + { |
|
| 72 | + return new ExplicitlyTaggedType($this->_type, $this->_name->toASN1()); |
|
| 73 | + } |
|
| 74 | 74 | } |
@@ -19,93 +19,93 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class DisplayText |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * Text. |
|
| 24 | - * |
|
| 25 | - * @var string $_text |
|
| 26 | - */ |
|
| 27 | - protected $_text; |
|
| 22 | + /** |
|
| 23 | + * Text. |
|
| 24 | + * |
|
| 25 | + * @var string $_text |
|
| 26 | + */ |
|
| 27 | + protected $_text; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Element tag. |
|
| 31 | - * |
|
| 32 | - * @var int $_tag |
|
| 33 | - */ |
|
| 34 | - protected $_tag; |
|
| 29 | + /** |
|
| 30 | + * Element tag. |
|
| 31 | + * |
|
| 32 | + * @var int $_tag |
|
| 33 | + */ |
|
| 34 | + protected $_tag; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Constructor. |
|
| 38 | - * |
|
| 39 | - * @param string $text |
|
| 40 | - * @param int $tag |
|
| 41 | - */ |
|
| 42 | - public function __construct(string $text, int $tag) |
|
| 43 | - { |
|
| 44 | - $this->_text = $text; |
|
| 45 | - $this->_tag = $tag; |
|
| 46 | - } |
|
| 36 | + /** |
|
| 37 | + * Constructor. |
|
| 38 | + * |
|
| 39 | + * @param string $text |
|
| 40 | + * @param int $tag |
|
| 41 | + */ |
|
| 42 | + public function __construct(string $text, int $tag) |
|
| 43 | + { |
|
| 44 | + $this->_text = $text; |
|
| 45 | + $this->_tag = $tag; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Initialize from ASN.1. |
|
| 50 | - * |
|
| 51 | - * @param StringType $el |
|
| 52 | - * @return self |
|
| 53 | - */ |
|
| 54 | - public static function fromASN1(StringType $el): self |
|
| 55 | - { |
|
| 56 | - return new self($el->string(), $el->tag()); |
|
| 57 | - } |
|
| 48 | + /** |
|
| 49 | + * Initialize from ASN.1. |
|
| 50 | + * |
|
| 51 | + * @param StringType $el |
|
| 52 | + * @return self |
|
| 53 | + */ |
|
| 54 | + public static function fromASN1(StringType $el): self |
|
| 55 | + { |
|
| 56 | + return new self($el->string(), $el->tag()); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Initialize from a UTF-8 string. |
|
| 61 | - * |
|
| 62 | - * @param string $str |
|
| 63 | - * @return self |
|
| 64 | - */ |
|
| 65 | - public static function fromString(string $str): self |
|
| 66 | - { |
|
| 67 | - return new self($str, Element::TYPE_UTF8_STRING); |
|
| 68 | - } |
|
| 59 | + /** |
|
| 60 | + * Initialize from a UTF-8 string. |
|
| 61 | + * |
|
| 62 | + * @param string $str |
|
| 63 | + * @return self |
|
| 64 | + */ |
|
| 65 | + public static function fromString(string $str): self |
|
| 66 | + { |
|
| 67 | + return new self($str, Element::TYPE_UTF8_STRING); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Get the text. |
|
| 72 | - * |
|
| 73 | - * @return string |
|
| 74 | - */ |
|
| 75 | - public function string(): string |
|
| 76 | - { |
|
| 77 | - return $this->_text; |
|
| 78 | - } |
|
| 70 | + /** |
|
| 71 | + * Get the text. |
|
| 72 | + * |
|
| 73 | + * @return string |
|
| 74 | + */ |
|
| 75 | + public function string(): string |
|
| 76 | + { |
|
| 77 | + return $this->_text; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Generate ASN.1 element. |
|
| 82 | - * |
|
| 83 | - * @throws \UnexpectedValueException |
|
| 84 | - * @return StringType |
|
| 85 | - */ |
|
| 86 | - public function toASN1(): StringType |
|
| 87 | - { |
|
| 88 | - switch ($this->_tag) { |
|
| 89 | - case Element::TYPE_IA5_STRING: |
|
| 90 | - return new IA5String($this->_text); |
|
| 91 | - case Element::TYPE_VISIBLE_STRING: |
|
| 92 | - return new VisibleString($this->_text); |
|
| 93 | - case Element::TYPE_BMP_STRING: |
|
| 94 | - return new BMPString($this->_text); |
|
| 95 | - case Element::TYPE_UTF8_STRING: |
|
| 96 | - return new UTF8String($this->_text); |
|
| 97 | - default: |
|
| 98 | - throw new \UnexpectedValueException( |
|
| 99 | - "Type " . Element::tagToName($this->_tag) . " not supported."); |
|
| 100 | - } |
|
| 101 | - } |
|
| 80 | + /** |
|
| 81 | + * Generate ASN.1 element. |
|
| 82 | + * |
|
| 83 | + * @throws \UnexpectedValueException |
|
| 84 | + * @return StringType |
|
| 85 | + */ |
|
| 86 | + public function toASN1(): StringType |
|
| 87 | + { |
|
| 88 | + switch ($this->_tag) { |
|
| 89 | + case Element::TYPE_IA5_STRING: |
|
| 90 | + return new IA5String($this->_text); |
|
| 91 | + case Element::TYPE_VISIBLE_STRING: |
|
| 92 | + return new VisibleString($this->_text); |
|
| 93 | + case Element::TYPE_BMP_STRING: |
|
| 94 | + return new BMPString($this->_text); |
|
| 95 | + case Element::TYPE_UTF8_STRING: |
|
| 96 | + return new UTF8String($this->_text); |
|
| 97 | + default: |
|
| 98 | + throw new \UnexpectedValueException( |
|
| 99 | + "Type " . Element::tagToName($this->_tag) . " not supported."); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * |
|
| 105 | - * @return string |
|
| 106 | - */ |
|
| 107 | - public function __toString() |
|
| 108 | - { |
|
| 109 | - return $this->string(); |
|
| 110 | - } |
|
| 103 | + /** |
|
| 104 | + * |
|
| 105 | + * @return string |
|
| 106 | + */ |
|
| 107 | + public function __toString() |
|
| 108 | + { |
|
| 109 | + return $this->string(); |
|
| 110 | + } |
|
| 111 | 111 | } |
@@ -86,17 +86,17 @@ |
||
| 86 | 86 | public function toASN1(): StringType |
| 87 | 87 | { |
| 88 | 88 | switch ($this->_tag) { |
| 89 | - case Element::TYPE_IA5_STRING: |
|
| 90 | - return new IA5String($this->_text); |
|
| 91 | - case Element::TYPE_VISIBLE_STRING: |
|
| 92 | - return new VisibleString($this->_text); |
|
| 93 | - case Element::TYPE_BMP_STRING: |
|
| 94 | - return new BMPString($this->_text); |
|
| 95 | - case Element::TYPE_UTF8_STRING: |
|
| 96 | - return new UTF8String($this->_text); |
|
| 97 | - default: |
|
| 98 | - throw new \UnexpectedValueException( |
|
| 99 | - "Type " . Element::tagToName($this->_tag) . " not supported."); |
|
| 89 | + case Element::TYPE_IA5_STRING: |
|
| 90 | + return new IA5String($this->_text); |
|
| 91 | + case Element::TYPE_VISIBLE_STRING: |
|
| 92 | + return new VisibleString($this->_text); |
|
| 93 | + case Element::TYPE_BMP_STRING: |
|
| 94 | + return new BMPString($this->_text); |
|
| 95 | + case Element::TYPE_UTF8_STRING: |
|
| 96 | + return new UTF8String($this->_text); |
|
| 97 | + default: |
|
| 98 | + throw new \UnexpectedValueException( |
|
| 99 | + "Type " . Element::tagToName($this->_tag) . " not supported."); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
@@ -15,51 +15,51 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class CPSQualifier extends PolicyQualifierInfo |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * URI. |
|
| 20 | - * |
|
| 21 | - * @var string $_uri |
|
| 22 | - */ |
|
| 23 | - protected $_uri; |
|
| 18 | + /** |
|
| 19 | + * URI. |
|
| 20 | + * |
|
| 21 | + * @var string $_uri |
|
| 22 | + */ |
|
| 23 | + protected $_uri; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Constructor. |
|
| 27 | - * |
|
| 28 | - * @param string $uri |
|
| 29 | - */ |
|
| 30 | - public function __construct(string $uri) |
|
| 31 | - { |
|
| 32 | - $this->_oid = self::OID_CPS; |
|
| 33 | - $this->_uri = $uri; |
|
| 34 | - } |
|
| 25 | + /** |
|
| 26 | + * Constructor. |
|
| 27 | + * |
|
| 28 | + * @param string $uri |
|
| 29 | + */ |
|
| 30 | + public function __construct(string $uri) |
|
| 31 | + { |
|
| 32 | + $this->_oid = self::OID_CPS; |
|
| 33 | + $this->_uri = $uri; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * |
|
| 38 | - * @param UnspecifiedType $el |
|
| 39 | - * @return self |
|
| 40 | - */ |
|
| 41 | - public static function fromQualifierASN1(UnspecifiedType $el): self |
|
| 42 | - { |
|
| 43 | - return new self($el->asString()->string()); |
|
| 44 | - } |
|
| 36 | + /** |
|
| 37 | + * |
|
| 38 | + * @param UnspecifiedType $el |
|
| 39 | + * @return self |
|
| 40 | + */ |
|
| 41 | + public static function fromQualifierASN1(UnspecifiedType $el): self |
|
| 42 | + { |
|
| 43 | + return new self($el->asString()->string()); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Get URI. |
|
| 48 | - * |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 51 | - public function uri(): string |
|
| 52 | - { |
|
| 53 | - return $this->_uri; |
|
| 54 | - } |
|
| 46 | + /** |
|
| 47 | + * Get URI. |
|
| 48 | + * |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | + public function uri(): string |
|
| 52 | + { |
|
| 53 | + return $this->_uri; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * |
|
| 58 | - * {@inheritdoc} |
|
| 59 | - * @return IA5String |
|
| 60 | - */ |
|
| 61 | - protected function _qualifierASN1(): IA5String |
|
| 62 | - { |
|
| 63 | - return new IA5String($this->_uri); |
|
| 64 | - } |
|
| 56 | + /** |
|
| 57 | + * |
|
| 58 | + * {@inheritdoc} |
|
| 59 | + * @return IA5String |
|
| 60 | + */ |
|
| 61 | + protected function _qualifierASN1(): IA5String |
|
| 62 | + { |
|
| 63 | + return new IA5String($this->_uri); |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -16,114 +16,114 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class UserNoticeQualifier extends PolicyQualifierInfo |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Explicit notice text. |
|
| 21 | - * |
|
| 22 | - * @var DisplayText $_text |
|
| 23 | - */ |
|
| 24 | - protected $_text; |
|
| 19 | + /** |
|
| 20 | + * Explicit notice text. |
|
| 21 | + * |
|
| 22 | + * @var DisplayText $_text |
|
| 23 | + */ |
|
| 24 | + protected $_text; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Notice reference. |
|
| 28 | - * |
|
| 29 | - * @var NoticeReference $_ref |
|
| 30 | - */ |
|
| 31 | - protected $_ref; |
|
| 26 | + /** |
|
| 27 | + * Notice reference. |
|
| 28 | + * |
|
| 29 | + * @var NoticeReference $_ref |
|
| 30 | + */ |
|
| 31 | + protected $_ref; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Constructor. |
|
| 35 | - * |
|
| 36 | - * @param DisplayText|null $text |
|
| 37 | - * @param NoticeReference|null $ref |
|
| 38 | - */ |
|
| 39 | - public function __construct(DisplayText $text = null, NoticeReference $ref = null) |
|
| 40 | - { |
|
| 41 | - $this->_oid = self::OID_UNOTICE; |
|
| 42 | - $this->_text = $text; |
|
| 43 | - $this->_ref = $ref; |
|
| 44 | - } |
|
| 33 | + /** |
|
| 34 | + * Constructor. |
|
| 35 | + * |
|
| 36 | + * @param DisplayText|null $text |
|
| 37 | + * @param NoticeReference|null $ref |
|
| 38 | + */ |
|
| 39 | + public function __construct(DisplayText $text = null, NoticeReference $ref = null) |
|
| 40 | + { |
|
| 41 | + $this->_oid = self::OID_UNOTICE; |
|
| 42 | + $this->_text = $text; |
|
| 43 | + $this->_ref = $ref; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * |
|
| 48 | - * @param UnspecifiedType $el |
|
| 49 | - * @return self |
|
| 50 | - */ |
|
| 51 | - public static function fromQualifierASN1(UnspecifiedType $el): self |
|
| 52 | - { |
|
| 53 | - $seq = $el->asSequence(); |
|
| 54 | - $ref = null; |
|
| 55 | - $text = null; |
|
| 56 | - $idx = 0; |
|
| 57 | - if ($seq->has($idx, Element::TYPE_SEQUENCE)) { |
|
| 58 | - $ref = NoticeReference::fromASN1($seq->at($idx++)->asSequence()); |
|
| 59 | - } |
|
| 60 | - if ($seq->has($idx, Element::TYPE_STRING)) { |
|
| 61 | - $text = DisplayText::fromASN1($seq->at($idx)->asString()); |
|
| 62 | - } |
|
| 63 | - return new self($text, $ref); |
|
| 64 | - } |
|
| 46 | + /** |
|
| 47 | + * |
|
| 48 | + * @param UnspecifiedType $el |
|
| 49 | + * @return self |
|
| 50 | + */ |
|
| 51 | + public static function fromQualifierASN1(UnspecifiedType $el): self |
|
| 52 | + { |
|
| 53 | + $seq = $el->asSequence(); |
|
| 54 | + $ref = null; |
|
| 55 | + $text = null; |
|
| 56 | + $idx = 0; |
|
| 57 | + if ($seq->has($idx, Element::TYPE_SEQUENCE)) { |
|
| 58 | + $ref = NoticeReference::fromASN1($seq->at($idx++)->asSequence()); |
|
| 59 | + } |
|
| 60 | + if ($seq->has($idx, Element::TYPE_STRING)) { |
|
| 61 | + $text = DisplayText::fromASN1($seq->at($idx)->asString()); |
|
| 62 | + } |
|
| 63 | + return new self($text, $ref); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Whether explicit text is present. |
|
| 68 | - * |
|
| 69 | - * @return bool |
|
| 70 | - */ |
|
| 71 | - public function hasExplicitText(): bool |
|
| 72 | - { |
|
| 73 | - return isset($this->_text); |
|
| 74 | - } |
|
| 66 | + /** |
|
| 67 | + * Whether explicit text is present. |
|
| 68 | + * |
|
| 69 | + * @return bool |
|
| 70 | + */ |
|
| 71 | + public function hasExplicitText(): bool |
|
| 72 | + { |
|
| 73 | + return isset($this->_text); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Get explicit text. |
|
| 78 | - * |
|
| 79 | - * @return DisplayText |
|
| 80 | - */ |
|
| 81 | - public function explicitText(): DisplayText |
|
| 82 | - { |
|
| 83 | - if (!$this->hasExplicitText()) { |
|
| 84 | - throw new \LogicException("explicitText not set."); |
|
| 85 | - } |
|
| 86 | - return $this->_text; |
|
| 87 | - } |
|
| 76 | + /** |
|
| 77 | + * Get explicit text. |
|
| 78 | + * |
|
| 79 | + * @return DisplayText |
|
| 80 | + */ |
|
| 81 | + public function explicitText(): DisplayText |
|
| 82 | + { |
|
| 83 | + if (!$this->hasExplicitText()) { |
|
| 84 | + throw new \LogicException("explicitText not set."); |
|
| 85 | + } |
|
| 86 | + return $this->_text; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Whether notice reference is present. |
|
| 91 | - * |
|
| 92 | - * @return bool |
|
| 93 | - */ |
|
| 94 | - public function hasNoticeRef(): bool |
|
| 95 | - { |
|
| 96 | - return isset($this->_ref); |
|
| 97 | - } |
|
| 89 | + /** |
|
| 90 | + * Whether notice reference is present. |
|
| 91 | + * |
|
| 92 | + * @return bool |
|
| 93 | + */ |
|
| 94 | + public function hasNoticeRef(): bool |
|
| 95 | + { |
|
| 96 | + return isset($this->_ref); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Get notice reference. |
|
| 101 | - * |
|
| 102 | - * @throws \RuntimeException |
|
| 103 | - * @return NoticeReference |
|
| 104 | - */ |
|
| 105 | - public function noticeRef(): NoticeReference |
|
| 106 | - { |
|
| 107 | - if (!$this->hasNoticeRef()) { |
|
| 108 | - throw new \LogicException("noticeRef not set."); |
|
| 109 | - } |
|
| 110 | - return $this->_ref; |
|
| 111 | - } |
|
| 99 | + /** |
|
| 100 | + * Get notice reference. |
|
| 101 | + * |
|
| 102 | + * @throws \RuntimeException |
|
| 103 | + * @return NoticeReference |
|
| 104 | + */ |
|
| 105 | + public function noticeRef(): NoticeReference |
|
| 106 | + { |
|
| 107 | + if (!$this->hasNoticeRef()) { |
|
| 108 | + throw new \LogicException("noticeRef not set."); |
|
| 109 | + } |
|
| 110 | + return $this->_ref; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * |
|
| 115 | - * {@inheritdoc} |
|
| 116 | - * @return Sequence |
|
| 117 | - */ |
|
| 118 | - protected function _qualifierASN1(): Sequence |
|
| 119 | - { |
|
| 120 | - $elements = array(); |
|
| 121 | - if (isset($this->_ref)) { |
|
| 122 | - $elements[] = $this->_ref->toASN1(); |
|
| 123 | - } |
|
| 124 | - if (isset($this->_text)) { |
|
| 125 | - $elements[] = $this->_text->toASN1(); |
|
| 126 | - } |
|
| 127 | - return new Sequence(...$elements); |
|
| 128 | - } |
|
| 113 | + /** |
|
| 114 | + * |
|
| 115 | + * {@inheritdoc} |
|
| 116 | + * @return Sequence |
|
| 117 | + */ |
|
| 118 | + protected function _qualifierASN1(): Sequence |
|
| 119 | + { |
|
| 120 | + $elements = array(); |
|
| 121 | + if (isset($this->_ref)) { |
|
| 122 | + $elements[] = $this->_ref->toASN1(); |
|
| 123 | + } |
|
| 124 | + if (isset($this->_text)) { |
|
| 125 | + $elements[] = $this->_text->toASN1(); |
|
| 126 | + } |
|
| 127 | + return new Sequence(...$elements); |
|
| 128 | + } |
|
| 129 | 129 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $org = DisplayText::fromASN1($seq->at(0)->asString()); |
| 54 | 54 | $numbers = array_map( |
| 55 | - function (UnspecifiedType $el) { |
|
| 55 | + function(UnspecifiedType $el) { |
|
| 56 | 56 | return $el->asInteger()->intNumber(); |
| 57 | 57 | }, |
| 58 | 58 | $seq->at(1) |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | $org = $this->_organization->toASN1(); |
| 92 | 92 | $nums = array_map( |
| 93 | - function ($number) { |
|
| 93 | + function($number) { |
|
| 94 | 94 | return new Integer($number); |
| 95 | 95 | }, $this->_numbers); |
| 96 | 96 | return new Sequence($org, new Sequence(...$nums)); |
@@ -16,83 +16,83 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class NoticeReference |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Organization. |
|
| 21 | - * |
|
| 22 | - * @var DisplayText $_organization |
|
| 23 | - */ |
|
| 24 | - protected $_organization; |
|
| 19 | + /** |
|
| 20 | + * Organization. |
|
| 21 | + * |
|
| 22 | + * @var DisplayText $_organization |
|
| 23 | + */ |
|
| 24 | + protected $_organization; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Notification reference numbers. |
|
| 28 | - * |
|
| 29 | - * @var int[] $_numbers |
|
| 30 | - */ |
|
| 31 | - protected $_numbers; |
|
| 26 | + /** |
|
| 27 | + * Notification reference numbers. |
|
| 28 | + * |
|
| 29 | + * @var int[] $_numbers |
|
| 30 | + */ |
|
| 31 | + protected $_numbers; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Constructor. |
|
| 35 | - * |
|
| 36 | - * @param DisplayText $organization |
|
| 37 | - * @param int ...$numbers |
|
| 38 | - */ |
|
| 39 | - public function __construct(DisplayText $organization, int ...$numbers) |
|
| 40 | - { |
|
| 41 | - $this->_organization = $organization; |
|
| 42 | - $this->_numbers = $numbers; |
|
| 43 | - } |
|
| 33 | + /** |
|
| 34 | + * Constructor. |
|
| 35 | + * |
|
| 36 | + * @param DisplayText $organization |
|
| 37 | + * @param int ...$numbers |
|
| 38 | + */ |
|
| 39 | + public function __construct(DisplayText $organization, int ...$numbers) |
|
| 40 | + { |
|
| 41 | + $this->_organization = $organization; |
|
| 42 | + $this->_numbers = $numbers; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Initialize from ASN.1. |
|
| 47 | - * |
|
| 48 | - * @param Sequence $seq |
|
| 49 | - * @return self |
|
| 50 | - */ |
|
| 51 | - public static function fromASN1(Sequence $seq): self |
|
| 52 | - { |
|
| 53 | - $org = DisplayText::fromASN1($seq->at(0)->asString()); |
|
| 54 | - $numbers = array_map( |
|
| 55 | - function (UnspecifiedType $el) { |
|
| 56 | - return $el->asInteger()->intNumber(); |
|
| 57 | - }, |
|
| 58 | - $seq->at(1) |
|
| 59 | - ->asSequence() |
|
| 60 | - ->elements()); |
|
| 61 | - return new self($org, ...$numbers); |
|
| 62 | - } |
|
| 45 | + /** |
|
| 46 | + * Initialize from ASN.1. |
|
| 47 | + * |
|
| 48 | + * @param Sequence $seq |
|
| 49 | + * @return self |
|
| 50 | + */ |
|
| 51 | + public static function fromASN1(Sequence $seq): self |
|
| 52 | + { |
|
| 53 | + $org = DisplayText::fromASN1($seq->at(0)->asString()); |
|
| 54 | + $numbers = array_map( |
|
| 55 | + function (UnspecifiedType $el) { |
|
| 56 | + return $el->asInteger()->intNumber(); |
|
| 57 | + }, |
|
| 58 | + $seq->at(1) |
|
| 59 | + ->asSequence() |
|
| 60 | + ->elements()); |
|
| 61 | + return new self($org, ...$numbers); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Get reference organization. |
|
| 66 | - * |
|
| 67 | - * @return DisplayText |
|
| 68 | - */ |
|
| 69 | - public function organization(): DisplayText |
|
| 70 | - { |
|
| 71 | - return $this->_organization; |
|
| 72 | - } |
|
| 64 | + /** |
|
| 65 | + * Get reference organization. |
|
| 66 | + * |
|
| 67 | + * @return DisplayText |
|
| 68 | + */ |
|
| 69 | + public function organization(): DisplayText |
|
| 70 | + { |
|
| 71 | + return $this->_organization; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Get reference numbers. |
|
| 76 | - * |
|
| 77 | - * @return int[] |
|
| 78 | - */ |
|
| 79 | - public function numbers(): array |
|
| 80 | - { |
|
| 81 | - return $this->_numbers; |
|
| 82 | - } |
|
| 74 | + /** |
|
| 75 | + * Get reference numbers. |
|
| 76 | + * |
|
| 77 | + * @return int[] |
|
| 78 | + */ |
|
| 79 | + public function numbers(): array |
|
| 80 | + { |
|
| 81 | + return $this->_numbers; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Generate ASN.1 structure. |
|
| 86 | - * |
|
| 87 | - * @return Sequence |
|
| 88 | - */ |
|
| 89 | - public function toASN1(): Sequence |
|
| 90 | - { |
|
| 91 | - $org = $this->_organization->toASN1(); |
|
| 92 | - $nums = array_map( |
|
| 93 | - function ($number) { |
|
| 94 | - return new Integer($number); |
|
| 95 | - }, $this->_numbers); |
|
| 96 | - return new Sequence($org, new Sequence(...$nums)); |
|
| 97 | - } |
|
| 84 | + /** |
|
| 85 | + * Generate ASN.1 structure. |
|
| 86 | + * |
|
| 87 | + * @return Sequence |
|
| 88 | + */ |
|
| 89 | + public function toASN1(): Sequence |
|
| 90 | + { |
|
| 91 | + $org = $this->_organization->toASN1(); |
|
| 92 | + $nums = array_map( |
|
| 93 | + function ($number) { |
|
| 94 | + return new Integer($number); |
|
| 95 | + }, $this->_numbers); |
|
| 96 | + return new Sequence($org, new Sequence(...$nums)); |
|
| 97 | + } |
|
| 98 | 98 | } |
@@ -13,34 +13,34 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class NoRevocationAvailableExtension extends Extension |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Constructor. |
|
| 18 | - * |
|
| 19 | - * @param bool $critical |
|
| 20 | - */ |
|
| 21 | - public function __construct(bool $critical) |
|
| 22 | - { |
|
| 23 | - parent::__construct(self::OID_NO_REV_AVAIL, $critical); |
|
| 24 | - } |
|
| 16 | + /** |
|
| 17 | + * Constructor. |
|
| 18 | + * |
|
| 19 | + * @param bool $critical |
|
| 20 | + */ |
|
| 21 | + public function __construct(bool $critical) |
|
| 22 | + { |
|
| 23 | + parent::__construct(self::OID_NO_REV_AVAIL, $critical); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * |
|
| 28 | - * {@inheritdoc} |
|
| 29 | - * @return self |
|
| 30 | - */ |
|
| 31 | - protected static function _fromDER(string $data, bool $critical): self |
|
| 32 | - { |
|
| 33 | - NullType::fromDER($data); |
|
| 34 | - return new self($critical); |
|
| 35 | - } |
|
| 26 | + /** |
|
| 27 | + * |
|
| 28 | + * {@inheritdoc} |
|
| 29 | + * @return self |
|
| 30 | + */ |
|
| 31 | + protected static function _fromDER(string $data, bool $critical): self |
|
| 32 | + { |
|
| 33 | + NullType::fromDER($data); |
|
| 34 | + return new self($critical); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * |
|
| 39 | - * {@inheritdoc} |
|
| 40 | - * @return NullType |
|
| 41 | - */ |
|
| 42 | - protected function _valueASN1(): NullType |
|
| 43 | - { |
|
| 44 | - return new NullType(); |
|
| 45 | - } |
|
| 37 | + /** |
|
| 38 | + * |
|
| 39 | + * {@inheritdoc} |
|
| 40 | + * @return NullType |
|
| 41 | + */ |
|
| 42 | + protected function _valueASN1(): NullType |
|
| 43 | + { |
|
| 44 | + return new NullType(); |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -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 | } |