@@ -89,16 +89,16 @@ |
||
89 | 89 | { |
90 | 90 | $dt = $this->_dt; |
91 | 91 | switch ($this->_type) { |
92 | - case Element::TYPE_UTC_TIME: |
|
93 | - return new UTCTime($dt); |
|
94 | - case Element::TYPE_GENERALIZED_TIME: |
|
95 | - // GeneralizedTime must not contain fractional seconds |
|
96 | - // (rfc5280 4.1.2.5.2) |
|
97 | - if ($dt->format("u") != 0) { |
|
98 | - // remove fractional seconds (round down) |
|
99 | - $dt = self::_roundDownFractionalSeconds($dt); |
|
100 | - } |
|
101 | - return new GeneralizedTime($dt); |
|
92 | + case Element::TYPE_UTC_TIME: |
|
93 | + return new UTCTime($dt); |
|
94 | + case Element::TYPE_GENERALIZED_TIME: |
|
95 | + // GeneralizedTime must not contain fractional seconds |
|
96 | + // (rfc5280 4.1.2.5.2) |
|
97 | + if ($dt->format("u") != 0) { |
|
98 | + // remove fractional seconds (round down) |
|
99 | + $dt = self::_roundDownFractionalSeconds($dt); |
|
100 | + } |
|
101 | + return new GeneralizedTime($dt); |
|
102 | 102 | } |
103 | 103 | throw new \UnexpectedValueException( |
104 | 104 | "Time type " . Element::tagToName($this->_type) . " not supported."); |
@@ -60,13 +60,13 @@ |
||
60 | 60 | public static function fromASN1(TaggedType $el): self |
61 | 61 | { |
62 | 62 | switch ($el->tag()) { |
63 | - case self::TYPE_NAME: |
|
64 | - return TargetName::fromChosenASN1($el->asExplicit()->asTagged()); |
|
65 | - case self::TYPE_GROUP: |
|
66 | - return TargetGroup::fromChosenASN1( |
|
67 | - $el->asExplicit()->asTagged()); |
|
68 | - case self::TYPE_CERT: |
|
69 | - throw new \RuntimeException("targetCert not supported."); |
|
63 | + case self::TYPE_NAME: |
|
64 | + return TargetName::fromChosenASN1($el->asExplicit()->asTagged()); |
|
65 | + case self::TYPE_GROUP: |
|
66 | + return TargetGroup::fromChosenASN1( |
|
67 | + $el->asExplicit()->asTagged()); |
|
68 | + case self::TYPE_CERT: |
|
69 | + throw new \RuntimeException("targetCert not supported."); |
|
70 | 70 | } |
71 | 71 | throw new \UnexpectedValueException( |
72 | 72 | "Target type " . $el->tag() . " not supported."); |
@@ -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 |
@@ -45,16 +45,16 @@ |
||
45 | 45 | public static function fromTaggedType(TaggedType $el): self |
46 | 46 | { |
47 | 47 | switch ($el->tag()) { |
48 | - case self::TAG_FULL_NAME: |
|
49 | - return new FullName( |
|
50 | - GeneralNames::fromASN1( |
|
51 | - $el->asImplicit(Element::TYPE_SEQUENCE)->asSequence())); |
|
52 | - case self::TAG_RDN: |
|
53 | - return new RelativeName( |
|
54 | - RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet())); |
|
55 | - default: |
|
56 | - throw new \UnexpectedValueException( |
|
57 | - "DistributionPointName tag " . $el->tag() . " not supported."); |
|
48 | + case self::TAG_FULL_NAME: |
|
49 | + return new FullName( |
|
50 | + GeneralNames::fromASN1( |
|
51 | + $el->asImplicit(Element::TYPE_SEQUENCE)->asSequence())); |
|
52 | + case self::TAG_RDN: |
|
53 | + return new RelativeName( |
|
54 | + RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet())); |
|
55 | + default: |
|
56 | + throw new \UnexpectedValueException( |
|
57 | + "DistributionPointName tag " . $el->tag() . " not supported."); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | public static function fromASN1(UnspecifiedType $el): self |
54 | 54 | { |
55 | 55 | switch ($el->tag()) { |
56 | - case Element::TYPE_OCTET_STRING: |
|
57 | - case Element::TYPE_UTF8_STRING: |
|
58 | - return new self($el->asString()->string(), $el->tag()); |
|
59 | - case Element::TYPE_OBJECT_IDENTIFIER: |
|
60 | - return new self($el->asObjectIdentifier()->oid(), $el->tag()); |
|
56 | + case Element::TYPE_OCTET_STRING: |
|
57 | + case Element::TYPE_UTF8_STRING: |
|
58 | + return new self($el->asString()->string(), $el->tag()); |
|
59 | + case Element::TYPE_OBJECT_IDENTIFIER: |
|
60 | + return new self($el->asObjectIdentifier()->oid(), $el->tag()); |
|
61 | 61 | } |
62 | 62 | throw new \UnexpectedValueException( |
63 | 63 | "Type " . Element::tagToName($el->tag()) . " not supported."); |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | public function toASN1(): Element |
156 | 156 | { |
157 | 157 | switch ($this->_type) { |
158 | - case Element::TYPE_OCTET_STRING: |
|
159 | - return new OctetString($this->_value); |
|
160 | - case Element::TYPE_UTF8_STRING: |
|
161 | - return new UTF8String($this->_value); |
|
162 | - case Element::TYPE_OBJECT_IDENTIFIER: |
|
163 | - return new ObjectIdentifier($this->_value); |
|
158 | + case Element::TYPE_OCTET_STRING: |
|
159 | + return new OctetString($this->_value); |
|
160 | + case Element::TYPE_UTF8_STRING: |
|
161 | + return new UTF8String($this->_value); |
|
162 | + case Element::TYPE_OBJECT_IDENTIFIER: |
|
163 | + return new ObjectIdentifier($this->_value); |
|
164 | 164 | } |
165 | 165 | throw new \LogicException( |
166 | 166 | "Type " . Element::tagToName($this->_type) . " not supported."); |