diff options
Diffstat (limited to 'vendor/fgrosse/phpasn1/lib/X509')
-rw-r--r-- | vendor/fgrosse/phpasn1/lib/X509/AlgorithmIdentifier.php | 44 | ||||
-rw-r--r-- | vendor/fgrosse/phpasn1/lib/X509/CSR/Attributes.php | 136 | ||||
-rw-r--r-- | vendor/fgrosse/phpasn1/lib/X509/CertificateExtensions.php | 200 | ||||
-rw-r--r-- | vendor/fgrosse/phpasn1/lib/X509/CertificateSubject.php | 216 | ||||
-rw-r--r-- | vendor/fgrosse/phpasn1/lib/X509/PrivateKey.php | 70 | ||||
-rw-r--r-- | vendor/fgrosse/phpasn1/lib/X509/PublicKey.php | 70 | ||||
-rw-r--r-- | vendor/fgrosse/phpasn1/lib/X509/SAN/DNSName.php | 56 | ||||
-rw-r--r-- | vendor/fgrosse/phpasn1/lib/X509/SAN/IPAddress.php | 146 | ||||
-rw-r--r-- | vendor/fgrosse/phpasn1/lib/X509/SAN/SubjectAlternativeNames.php | 192 |
9 files changed, 565 insertions, 565 deletions
diff --git a/vendor/fgrosse/phpasn1/lib/X509/AlgorithmIdentifier.php b/vendor/fgrosse/phpasn1/lib/X509/AlgorithmIdentifier.php index a06b56f..3a6f7ea 100644 --- a/vendor/fgrosse/phpasn1/lib/X509/AlgorithmIdentifier.php +++ b/vendor/fgrosse/phpasn1/lib/X509/AlgorithmIdentifier.php @@ -1,22 +1,22 @@ -<?php -/* - * This file is part of the PHPASN1 library. - * - * Copyright © Friedrich Große <friedrich.grosse@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FG\X509; - -use FG\ASN1\Universal\NullObject; -use FG\ASN1\Composite\AttributeTypeAndValue; - -class AlgorithmIdentifier extends AttributeTypeAndValue -{ - public function __construct($objectIdentifierString) - { - parent::__construct($objectIdentifierString, new NullObject()); - } -} +<?php
+/*
+ * This file is part of the PHPASN1 library.
+ *
+ * Copyright © Friedrich Große <friedrich.grosse@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace FG\X509;
+
+use FG\ASN1\Universal\NullObject;
+use FG\ASN1\Composite\AttributeTypeAndValue;
+
+class AlgorithmIdentifier extends AttributeTypeAndValue
+{
+ public function __construct($objectIdentifierString)
+ {
+ parent::__construct($objectIdentifierString, new NullObject());
+ }
+}
diff --git a/vendor/fgrosse/phpasn1/lib/X509/CSR/Attributes.php b/vendor/fgrosse/phpasn1/lib/X509/CSR/Attributes.php index 5a965e2..0b53419 100644 --- a/vendor/fgrosse/phpasn1/lib/X509/CSR/Attributes.php +++ b/vendor/fgrosse/phpasn1/lib/X509/CSR/Attributes.php @@ -1,68 +1,68 @@ -<?php -/* - * This file is part of the PHPASN1 library. - * - * Copyright © Friedrich Große <friedrich.grosse@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FG\X509\CSR; - -use FG\ASN1\ASNObject; -use FG\X509\CertificateExtensions; -use FG\ASN1\OID; -use FG\ASN1\Parsable; -use FG\ASN1\Construct; -use FG\ASN1\Identifier; -use FG\ASN1\Universal\Set; -use FG\ASN1\Universal\Sequence; -use FG\ASN1\Universal\ObjectIdentifier; - -class Attributes extends Construct implements Parsable -{ - public function getType() - { - return 0xA0; - } - - public function addAttribute($objectIdentifier, Set $attribute) - { - if (is_string($objectIdentifier)) { - $objectIdentifier = new ObjectIdentifier($objectIdentifier); - } - $attributeSequence = new Sequence($objectIdentifier, $attribute); - $attributeSequence->getNumberOfLengthOctets(); // length and number of length octets is calculated - $this->addChild($attributeSequence); - } - - public static function fromBinary(&$binaryData, &$offsetIndex = 0) - { - self::parseIdentifier($binaryData[$offsetIndex], 0xA0, $offsetIndex++); - $contentLength = self::parseContentLength($binaryData, $offsetIndex); - $octetsToRead = $contentLength; - - $parsedObject = new self(); - while ($octetsToRead > 0) { - $initialOffset = $offsetIndex; // used to calculate how much bits have been read - self::parseIdentifier($binaryData[$offsetIndex], Identifier::SEQUENCE, $offsetIndex++); - self::parseContentLength($binaryData, $offsetIndex); - - $objectIdentifier = ObjectIdentifier::fromBinary($binaryData, $offsetIndex); - $oidString = $objectIdentifier->getContent(); - if ($oidString == OID::PKCS9_EXTENSION_REQUEST) { - $attribute = CertificateExtensions::fromBinary($binaryData, $offsetIndex); - } else { - $attribute = ASNObject::fromBinary($binaryData, $offsetIndex); - } - - $parsedObject->addAttribute($objectIdentifier, $attribute); - $octetsToRead -= ($offsetIndex - $initialOffset); - } - - $parsedObject->setContentLength($contentLength); - - return $parsedObject; - } -} +<?php
+/*
+ * This file is part of the PHPASN1 library.
+ *
+ * Copyright © Friedrich Große <friedrich.grosse@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace FG\X509\CSR;
+
+use FG\ASN1\ASNObject;
+use FG\X509\CertificateExtensions;
+use FG\ASN1\OID;
+use FG\ASN1\Parsable;
+use FG\ASN1\Construct;
+use FG\ASN1\Identifier;
+use FG\ASN1\Universal\Set;
+use FG\ASN1\Universal\Sequence;
+use FG\ASN1\Universal\ObjectIdentifier;
+
+class Attributes extends Construct implements Parsable
+{
+ public function getType()
+ {
+ return 0xA0;
+ }
+
+ public function addAttribute($objectIdentifier, Set $attribute)
+ {
+ if (is_string($objectIdentifier)) {
+ $objectIdentifier = new ObjectIdentifier($objectIdentifier);
+ }
+ $attributeSequence = new Sequence($objectIdentifier, $attribute);
+ $attributeSequence->getNumberOfLengthOctets(); // length and number of length octets is calculated
+ $this->addChild($attributeSequence);
+ }
+
+ public static function fromBinary(&$binaryData, &$offsetIndex = 0)
+ {
+ self::parseIdentifier($binaryData[$offsetIndex], 0xA0, $offsetIndex++);
+ $contentLength = self::parseContentLength($binaryData, $offsetIndex);
+ $octetsToRead = $contentLength;
+
+ $parsedObject = new self();
+ while ($octetsToRead > 0) {
+ $initialOffset = $offsetIndex; // used to calculate how much bits have been read
+ self::parseIdentifier($binaryData[$offsetIndex], Identifier::SEQUENCE, $offsetIndex++);
+ self::parseContentLength($binaryData, $offsetIndex);
+
+ $objectIdentifier = ObjectIdentifier::fromBinary($binaryData, $offsetIndex);
+ $oidString = $objectIdentifier->getContent();
+ if ($oidString == OID::PKCS9_EXTENSION_REQUEST) {
+ $attribute = CertificateExtensions::fromBinary($binaryData, $offsetIndex);
+ } else {
+ $attribute = ASNObject::fromBinary($binaryData, $offsetIndex);
+ }
+
+ $parsedObject->addAttribute($objectIdentifier, $attribute);
+ $octetsToRead -= ($offsetIndex - $initialOffset);
+ }
+
+ $parsedObject->setContentLength($contentLength);
+
+ return $parsedObject;
+ }
+}
diff --git a/vendor/fgrosse/phpasn1/lib/X509/CertificateExtensions.php b/vendor/fgrosse/phpasn1/lib/X509/CertificateExtensions.php index 6ed1c6a..66bc35d 100644 --- a/vendor/fgrosse/phpasn1/lib/X509/CertificateExtensions.php +++ b/vendor/fgrosse/phpasn1/lib/X509/CertificateExtensions.php @@ -1,100 +1,100 @@ -<?php -/* - * This file is part of the PHPASN1 library. - * - * Copyright © Friedrich Große <friedrich.grosse@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FG\X509; - -use FG\ASN1\Exception\ParserException; -use FG\ASN1\OID; -use FG\ASN1\ASNObject; -use FG\ASN1\Parsable; -use FG\ASN1\Identifier; -use FG\ASN1\Universal\OctetString; -use FG\ASN1\Universal\Set; -use FG\ASN1\Universal\Sequence; -use FG\ASN1\Universal\ObjectIdentifier; -use FG\X509\SAN\SubjectAlternativeNames; - -class CertificateExtensions extends Set implements Parsable -{ - private $innerSequence; - private $extensions = []; - - public function __construct() - { - $this->innerSequence = new Sequence(); - parent::__construct($this->innerSequence); - } - - public function addSubjectAlternativeNames(SubjectAlternativeNames $sans) - { - $this->addExtension(OID::CERT_EXT_SUBJECT_ALT_NAME, $sans); - } - - private function addExtension($oidString, ASNObject $extension) - { - $sequence = new Sequence(); - $sequence->addChild(new ObjectIdentifier($oidString)); - $sequence->addChild($extension); - - $this->innerSequence->addChild($sequence); - $this->extensions[] = $extension; - } - - public function getContent() - { - return $this->extensions; - } - - public static function fromBinary(&$binaryData, &$offsetIndex = 0) - { - self::parseIdentifier($binaryData[$offsetIndex], Identifier::SET, $offsetIndex++); - self::parseContentLength($binaryData, $offsetIndex); - - $tmpOffset = $offsetIndex; - $extensions = Sequence::fromBinary($binaryData, $offsetIndex); - $tmpOffset += 1 + $extensions->getNumberOfLengthOctets(); - - $parsedObject = new self(); - foreach ($extensions as $extension) { - if ($extension->getType() != Identifier::SEQUENCE) { - //FIXME wrong offset index - throw new ParserException('Could not parse Certificate Extensions: Expected ASN.1 Sequence but got '.$extension->getTypeName(), $offsetIndex); - } - - $tmpOffset += 1 + $extension->getNumberOfLengthOctets(); - $children = $extension->getChildren(); - if (count($children) < 2) { - throw new ParserException('Could not parse Certificate Extensions: Needs at least two child elements per extension sequence (object identifier and octet string)', $tmpOffset); - } - /** @var \FG\ASN1\ASNObject $objectIdentifier */ - $objectIdentifier = $children[0]; - - /** @var OctetString $octetString */ - $octetString = $children[1]; - - if ($objectIdentifier->getType() != Identifier::OBJECT_IDENTIFIER) { - throw new ParserException('Could not parse Certificate Extensions: Expected ASN.1 Object Identifier but got '.$extension->getTypeName(), $tmpOffset); - } - - $tmpOffset += $objectIdentifier->getObjectLength(); - - if ($objectIdentifier->getContent() == OID::CERT_EXT_SUBJECT_ALT_NAME) { - $sans = SubjectAlternativeNames::fromBinary($binaryData, $tmpOffset); - $parsedObject->addSubjectAlternativeNames($sans); - } else { - // can now only parse SANs. There might be more in the future - $tmpOffset += $octetString->getObjectLength(); - } - } - - $parsedObject->getBinary(); // Determine the number of content octets and object sizes once (just to let the equality unit tests pass :/ ) - return $parsedObject; - } -} +<?php
+/*
+ * This file is part of the PHPASN1 library.
+ *
+ * Copyright © Friedrich Große <friedrich.grosse@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace FG\X509;
+
+use FG\ASN1\Exception\ParserException;
+use FG\ASN1\OID;
+use FG\ASN1\ASNObject;
+use FG\ASN1\Parsable;
+use FG\ASN1\Identifier;
+use FG\ASN1\Universal\OctetString;
+use FG\ASN1\Universal\Set;
+use FG\ASN1\Universal\Sequence;
+use FG\ASN1\Universal\ObjectIdentifier;
+use FG\X509\SAN\SubjectAlternativeNames;
+
+class CertificateExtensions extends Set implements Parsable
+{
+ private $innerSequence;
+ private $extensions = [];
+
+ public function __construct()
+ {
+ $this->innerSequence = new Sequence();
+ parent::__construct($this->innerSequence);
+ }
+
+ public function addSubjectAlternativeNames(SubjectAlternativeNames $sans)
+ {
+ $this->addExtension(OID::CERT_EXT_SUBJECT_ALT_NAME, $sans);
+ }
+
+ private function addExtension($oidString, ASNObject $extension)
+ {
+ $sequence = new Sequence();
+ $sequence->addChild(new ObjectIdentifier($oidString));
+ $sequence->addChild($extension);
+
+ $this->innerSequence->addChild($sequence);
+ $this->extensions[] = $extension;
+ }
+
+ public function getContent()
+ {
+ return $this->extensions;
+ }
+
+ public static function fromBinary(&$binaryData, &$offsetIndex = 0)
+ {
+ self::parseIdentifier($binaryData[$offsetIndex], Identifier::SET, $offsetIndex++);
+ self::parseContentLength($binaryData, $offsetIndex);
+
+ $tmpOffset = $offsetIndex;
+ $extensions = Sequence::fromBinary($binaryData, $offsetIndex);
+ $tmpOffset += 1 + $extensions->getNumberOfLengthOctets();
+
+ $parsedObject = new self();
+ foreach ($extensions as $extension) {
+ if ($extension->getType() != Identifier::SEQUENCE) {
+ //FIXME wrong offset index
+ throw new ParserException('Could not parse Certificate Extensions: Expected ASN.1 Sequence but got '.$extension->getTypeName(), $offsetIndex);
+ }
+
+ $tmpOffset += 1 + $extension->getNumberOfLengthOctets();
+ $children = $extension->getChildren();
+ if (count($children) < 2) {
+ throw new ParserException('Could not parse Certificate Extensions: Needs at least two child elements per extension sequence (object identifier and octet string)', $tmpOffset);
+ }
+ /** @var \FG\ASN1\ASNObject $objectIdentifier */
+ $objectIdentifier = $children[0];
+
+ /** @var OctetString $octetString */
+ $octetString = $children[1];
+
+ if ($objectIdentifier->getType() != Identifier::OBJECT_IDENTIFIER) {
+ throw new ParserException('Could not parse Certificate Extensions: Expected ASN.1 Object Identifier but got '.$extension->getTypeName(), $tmpOffset);
+ }
+
+ $tmpOffset += $objectIdentifier->getObjectLength();
+
+ if ($objectIdentifier->getContent() == OID::CERT_EXT_SUBJECT_ALT_NAME) {
+ $sans = SubjectAlternativeNames::fromBinary($binaryData, $tmpOffset);
+ $parsedObject->addSubjectAlternativeNames($sans);
+ } else {
+ // can now only parse SANs. There might be more in the future
+ $tmpOffset += $octetString->getObjectLength();
+ }
+ }
+
+ $parsedObject->getBinary(); // Determine the number of content octets and object sizes once (just to let the equality unit tests pass :/ )
+ return $parsedObject;
+ }
+}
diff --git a/vendor/fgrosse/phpasn1/lib/X509/CertificateSubject.php b/vendor/fgrosse/phpasn1/lib/X509/CertificateSubject.php index 0a04d57..37e4bfa 100644 --- a/vendor/fgrosse/phpasn1/lib/X509/CertificateSubject.php +++ b/vendor/fgrosse/phpasn1/lib/X509/CertificateSubject.php @@ -1,108 +1,108 @@ -<?php -/* - * This file is part of the PHPASN1 library. - * - * Copyright © Friedrich Große <friedrich.grosse@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FG\X509; - -use FG\ASN1\Composite\RelativeDistinguishedName; -use FG\ASN1\Identifier; -use FG\ASN1\OID; -use FG\ASN1\Parsable; -use FG\ASN1\Composite\RDNString; -use FG\ASN1\Universal\Sequence; - -class CertificateSubject extends Sequence implements Parsable -{ - private $commonName; - private $email; - private $organization; - private $locality; - private $state; - private $country; - private $organizationalUnit; - - /** - * @param string $commonName - * @param string $email - * @param string $organization - * @param string $locality - * @param string $state - * @param string $country - * @param string $organizationalUnit - */ - public function __construct($commonName, $email, $organization, $locality, $state, $country, $organizationalUnit) - { - parent::__construct( - new RDNString(OID::COUNTRY_NAME, $country), - new RDNString(OID::STATE_OR_PROVINCE_NAME, $state), - new RDNString(OID::LOCALITY_NAME, $locality), - new RDNString(OID::ORGANIZATION_NAME, $organization), - new RDNString(OID::OU_NAME, $organizationalUnit), - new RDNString(OID::COMMON_NAME, $commonName), - new RDNString(OID::PKCS9_EMAIL, $email) - ); - - $this->commonName = $commonName; - $this->email = $email; - $this->organization = $organization; - $this->locality = $locality; - $this->state = $state; - $this->country = $country; - $this->organizationalUnit = $organizationalUnit; - } - - public function getCommonName() - { - return $this->commonName; - } - - public function getEmail() - { - return $this->email; - } - - public function getOrganization() - { - return $this->organization; - } - - public function getLocality() - { - return $this->locality; - } - - public function getState() - { - return $this->state; - } - - public function getCountry() - { - return $this->country; - } - - public function getOrganizationalUnit() - { - return $this->organizationalUnit; - } - - public static function fromBinary(&$binaryData, &$offsetIndex = 0) - { - self::parseIdentifier($binaryData[$offsetIndex], Identifier::SEQUENCE, $offsetIndex++); - $contentLength = self::parseContentLength($binaryData, $offsetIndex); - - $names = []; - $octetsToRead = $contentLength; - while ($octetsToRead > 0) { - $relativeDistinguishedName = RelativeDistinguishedName::fromBinary($binaryData, $offsetIndex); - $octetsToRead -= $relativeDistinguishedName->getObjectLength(); - $names[] = $relativeDistinguishedName; - } - } -} +<?php
+/*
+ * This file is part of the PHPASN1 library.
+ *
+ * Copyright © Friedrich Große <friedrich.grosse@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace FG\X509;
+
+use FG\ASN1\Composite\RelativeDistinguishedName;
+use FG\ASN1\Identifier;
+use FG\ASN1\OID;
+use FG\ASN1\Parsable;
+use FG\ASN1\Composite\RDNString;
+use FG\ASN1\Universal\Sequence;
+
+class CertificateSubject extends Sequence implements Parsable
+{
+ private $commonName;
+ private $email;
+ private $organization;
+ private $locality;
+ private $state;
+ private $country;
+ private $organizationalUnit;
+
+ /**
+ * @param string $commonName
+ * @param string $email
+ * @param string $organization
+ * @param string $locality
+ * @param string $state
+ * @param string $country
+ * @param string $organizationalUnit
+ */
+ public function __construct($commonName, $email, $organization, $locality, $state, $country, $organizationalUnit)
+ {
+ parent::__construct(
+ new RDNString(OID::COUNTRY_NAME, $country),
+ new RDNString(OID::STATE_OR_PROVINCE_NAME, $state),
+ new RDNString(OID::LOCALITY_NAME, $locality),
+ new RDNString(OID::ORGANIZATION_NAME, $organization),
+ new RDNString(OID::OU_NAME, $organizationalUnit),
+ new RDNString(OID::COMMON_NAME, $commonName),
+ new RDNString(OID::PKCS9_EMAIL, $email)
+ );
+
+ $this->commonName = $commonName;
+ $this->email = $email;
+ $this->organization = $organization;
+ $this->locality = $locality;
+ $this->state = $state;
+ $this->country = $country;
+ $this->organizationalUnit = $organizationalUnit;
+ }
+
+ public function getCommonName()
+ {
+ return $this->commonName;
+ }
+
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ public function getOrganization()
+ {
+ return $this->organization;
+ }
+
+ public function getLocality()
+ {
+ return $this->locality;
+ }
+
+ public function getState()
+ {
+ return $this->state;
+ }
+
+ public function getCountry()
+ {
+ return $this->country;
+ }
+
+ public function getOrganizationalUnit()
+ {
+ return $this->organizationalUnit;
+ }
+
+ public static function fromBinary(&$binaryData, &$offsetIndex = 0)
+ {
+ self::parseIdentifier($binaryData[$offsetIndex], Identifier::SEQUENCE, $offsetIndex++);
+ $contentLength = self::parseContentLength($binaryData, $offsetIndex);
+
+ $names = [];
+ $octetsToRead = $contentLength;
+ while ($octetsToRead > 0) {
+ $relativeDistinguishedName = RelativeDistinguishedName::fromBinary($binaryData, $offsetIndex);
+ $octetsToRead -= $relativeDistinguishedName->getObjectLength();
+ $names[] = $relativeDistinguishedName;
+ }
+ }
+}
diff --git a/vendor/fgrosse/phpasn1/lib/X509/PrivateKey.php b/vendor/fgrosse/phpasn1/lib/X509/PrivateKey.php index d57ad86..b352f7e 100644 --- a/vendor/fgrosse/phpasn1/lib/X509/PrivateKey.php +++ b/vendor/fgrosse/phpasn1/lib/X509/PrivateKey.php @@ -1,35 +1,35 @@ -<?php -/* - * This file is part of the PHPASN1 library. - * - * Copyright © Friedrich Große <friedrich.grosse@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FG\X509; - -use FG\ASN1\OID; -use FG\ASN1\Universal\NullObject; -use FG\ASN1\Universal\Sequence; -use FG\ASN1\Universal\BitString; -use FG\ASN1\Universal\ObjectIdentifier; - -class PrivateKey extends Sequence -{ - /** - * @param string $hexKey - * @param \FG\ASN1\ASNObject|string $algorithmIdentifierString - */ - public function __construct($hexKey, $algorithmIdentifierString = OID::RSA_ENCRYPTION) - { - parent::__construct( - new Sequence( - new ObjectIdentifier($algorithmIdentifierString), - new NullObject() - ), - new BitString($hexKey) - ); - } -} +<?php
+/*
+ * This file is part of the PHPASN1 library.
+ *
+ * Copyright © Friedrich Große <friedrich.grosse@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace FG\X509;
+
+use FG\ASN1\OID;
+use FG\ASN1\Universal\NullObject;
+use FG\ASN1\Universal\Sequence;
+use FG\ASN1\Universal\BitString;
+use FG\ASN1\Universal\ObjectIdentifier;
+
+class PrivateKey extends Sequence
+{
+ /**
+ * @param string $hexKey
+ * @param \FG\ASN1\ASNObject|string $algorithmIdentifierString
+ */
+ public function __construct($hexKey, $algorithmIdentifierString = OID::RSA_ENCRYPTION)
+ {
+ parent::__construct(
+ new Sequence(
+ new ObjectIdentifier($algorithmIdentifierString),
+ new NullObject()
+ ),
+ new BitString($hexKey)
+ );
+ }
+}
diff --git a/vendor/fgrosse/phpasn1/lib/X509/PublicKey.php b/vendor/fgrosse/phpasn1/lib/X509/PublicKey.php index ab8b451..c0b1c37 100644 --- a/vendor/fgrosse/phpasn1/lib/X509/PublicKey.php +++ b/vendor/fgrosse/phpasn1/lib/X509/PublicKey.php @@ -1,35 +1,35 @@ -<?php -/* - * This file is part of the PHPASN1 library. - * - * Copyright © Friedrich Große <friedrich.grosse@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FG\X509; - -use FG\ASN1\OID; -use FG\ASN1\Universal\NullObject; -use FG\ASN1\Universal\Sequence; -use FG\ASN1\Universal\BitString; -use FG\ASN1\Universal\ObjectIdentifier; - -class PublicKey extends Sequence -{ - /** - * @param string $hexKey - * @param \FG\ASN1\ASNObject|string $algorithmIdentifierString - */ - public function __construct($hexKey, $algorithmIdentifierString = OID::RSA_ENCRYPTION) - { - parent::__construct( - new Sequence( - new ObjectIdentifier($algorithmIdentifierString), - new NullObject() - ), - new BitString($hexKey) - ); - } -} +<?php
+/*
+ * This file is part of the PHPASN1 library.
+ *
+ * Copyright © Friedrich Große <friedrich.grosse@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace FG\X509;
+
+use FG\ASN1\OID;
+use FG\ASN1\Universal\NullObject;
+use FG\ASN1\Universal\Sequence;
+use FG\ASN1\Universal\BitString;
+use FG\ASN1\Universal\ObjectIdentifier;
+
+class PublicKey extends Sequence
+{
+ /**
+ * @param string $hexKey
+ * @param \FG\ASN1\ASNObject|string $algorithmIdentifierString
+ */
+ public function __construct($hexKey, $algorithmIdentifierString = OID::RSA_ENCRYPTION)
+ {
+ parent::__construct(
+ new Sequence(
+ new ObjectIdentifier($algorithmIdentifierString),
+ new NullObject()
+ ),
+ new BitString($hexKey)
+ );
+ }
+}
diff --git a/vendor/fgrosse/phpasn1/lib/X509/SAN/DNSName.php b/vendor/fgrosse/phpasn1/lib/X509/SAN/DNSName.php index 502738b..76e6199 100644 --- a/vendor/fgrosse/phpasn1/lib/X509/SAN/DNSName.php +++ b/vendor/fgrosse/phpasn1/lib/X509/SAN/DNSName.php @@ -1,28 +1,28 @@ -<?php -/* - * This file is part of the PHPASN1 library. - * - * Copyright © Friedrich Große <friedrich.grosse@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FG\X509\SAN; - -use FG\ASN1\Universal\GeneralString; - -class DNSName extends GeneralString -{ - const IDENTIFIER = 0x82; // not sure yet why this is the identifier used in SAN extensions - - public function __construct($dnsNameString) - { - parent::__construct($dnsNameString); - } - - public function getType() - { - return self::IDENTIFIER; - } -} +<?php
+/*
+ * This file is part of the PHPASN1 library.
+ *
+ * Copyright © Friedrich Große <friedrich.grosse@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace FG\X509\SAN;
+
+use FG\ASN1\Universal\GeneralString;
+
+class DNSName extends GeneralString
+{
+ const IDENTIFIER = 0x82; // not sure yet why this is the identifier used in SAN extensions
+
+ public function __construct($dnsNameString)
+ {
+ parent::__construct($dnsNameString);
+ }
+
+ public function getType()
+ {
+ return self::IDENTIFIER;
+ }
+}
diff --git a/vendor/fgrosse/phpasn1/lib/X509/SAN/IPAddress.php b/vendor/fgrosse/phpasn1/lib/X509/SAN/IPAddress.php index f55be95..e967903 100644 --- a/vendor/fgrosse/phpasn1/lib/X509/SAN/IPAddress.php +++ b/vendor/fgrosse/phpasn1/lib/X509/SAN/IPAddress.php @@ -1,73 +1,73 @@ -<?php -/* - * This file is part of the PHPASN1 library. - * - * Copyright © Friedrich Große <friedrich.grosse@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FG\X509\SAN; - -use FG\ASN1\ASNObject; -use FG\ASN1\Parsable; -use FG\ASN1\Exception\ParserException; - -class IPAddress extends ASNObject implements Parsable -{ - const IDENTIFIER = 0x87; // not sure yet why this is the identifier used in SAN extensions - - /** @var string */ - private $value; - - public function __construct($ipAddressString) - { - $this->value = $ipAddressString; - } - - public function getType() - { - return self::IDENTIFIER; - } - - public function getContent() - { - return $this->value; - } - - protected function calculateContentLength() - { - return 4; - } - - protected function getEncodedValue() - { - $ipParts = explode('.', $this->value); - $binary = chr($ipParts[0]); - $binary .= chr($ipParts[1]); - $binary .= chr($ipParts[2]); - $binary .= chr($ipParts[3]); - - return $binary; - } - - public static function fromBinary(&$binaryData, &$offsetIndex = 0) - { - self::parseIdentifier($binaryData[$offsetIndex], self::IDENTIFIER, $offsetIndex++); - $contentLength = self::parseContentLength($binaryData, $offsetIndex); - if ($contentLength != 4) { - throw new ParserException("A FG\\X509\SAN\IPAddress should have a content length of 4. Extracted length was {$contentLength}", $offsetIndex); - } - - $ipAddressString = ord($binaryData[$offsetIndex++]).'.'; - $ipAddressString .= ord($binaryData[$offsetIndex++]).'.'; - $ipAddressString .= ord($binaryData[$offsetIndex++]).'.'; - $ipAddressString .= ord($binaryData[$offsetIndex++]); - - $parsedObject = new self($ipAddressString); - $parsedObject->getObjectLength(); - - return $parsedObject; - } -} +<?php
+/*
+ * This file is part of the PHPASN1 library.
+ *
+ * Copyright © Friedrich Große <friedrich.grosse@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace FG\X509\SAN;
+
+use FG\ASN1\ASNObject;
+use FG\ASN1\Parsable;
+use FG\ASN1\Exception\ParserException;
+
+class IPAddress extends ASNObject implements Parsable
+{
+ const IDENTIFIER = 0x87; // not sure yet why this is the identifier used in SAN extensions
+
+ /** @var string */
+ private $value;
+
+ public function __construct($ipAddressString)
+ {
+ $this->value = $ipAddressString;
+ }
+
+ public function getType()
+ {
+ return self::IDENTIFIER;
+ }
+
+ public function getContent()
+ {
+ return $this->value;
+ }
+
+ protected function calculateContentLength()
+ {
+ return 4;
+ }
+
+ protected function getEncodedValue()
+ {
+ $ipParts = explode('.', $this->value);
+ $binary = chr($ipParts[0]);
+ $binary .= chr($ipParts[1]);
+ $binary .= chr($ipParts[2]);
+ $binary .= chr($ipParts[3]);
+
+ return $binary;
+ }
+
+ public static function fromBinary(&$binaryData, &$offsetIndex = 0)
+ {
+ self::parseIdentifier($binaryData[$offsetIndex], self::IDENTIFIER, $offsetIndex++);
+ $contentLength = self::parseContentLength($binaryData, $offsetIndex);
+ if ($contentLength != 4) {
+ throw new ParserException("A FG\\X509\SAN\IPAddress should have a content length of 4. Extracted length was {$contentLength}", $offsetIndex);
+ }
+
+ $ipAddressString = ord($binaryData[$offsetIndex++]).'.';
+ $ipAddressString .= ord($binaryData[$offsetIndex++]).'.';
+ $ipAddressString .= ord($binaryData[$offsetIndex++]).'.';
+ $ipAddressString .= ord($binaryData[$offsetIndex++]);
+
+ $parsedObject = new self($ipAddressString);
+ $parsedObject->getObjectLength();
+
+ return $parsedObject;
+ }
+}
diff --git a/vendor/fgrosse/phpasn1/lib/X509/SAN/SubjectAlternativeNames.php b/vendor/fgrosse/phpasn1/lib/X509/SAN/SubjectAlternativeNames.php index 271ddde..45257d9 100644 --- a/vendor/fgrosse/phpasn1/lib/X509/SAN/SubjectAlternativeNames.php +++ b/vendor/fgrosse/phpasn1/lib/X509/SAN/SubjectAlternativeNames.php @@ -1,96 +1,96 @@ -<?php -/* - * This file is part of the PHPASN1 library. - * - * Copyright © Friedrich Große <friedrich.grosse@gmail.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FG\X509\SAN; - -use FG\ASN1\Exception\ParserException; -use FG\ASN1\ASNObject; -use FG\ASN1\OID; -use FG\ASN1\Parsable; -use FG\ASN1\Identifier; -use FG\ASN1\Universal\Sequence; - -/** - * See section 8.3.2.1 of ITU-T X.509. - */ -class SubjectAlternativeNames extends ASNObject implements Parsable -{ - private $alternativeNamesSequence; - - public function __construct() - { - $this->alternativeNamesSequence = new Sequence(); - } - - protected function calculateContentLength() - { - return $this->alternativeNamesSequence->getObjectLength(); - } - - public function getType() - { - return Identifier::OCTETSTRING; - } - - public function addDomainName(DNSName $domainName) - { - $this->alternativeNamesSequence->addChild($domainName); - } - - public function addIP(IPAddress $ip) - { - $this->alternativeNamesSequence->addChild($ip); - } - - public function getContent() - { - return $this->alternativeNamesSequence->getContent(); - } - - protected function getEncodedValue() - { - return $this->alternativeNamesSequence->getBinary(); - } - - public static function fromBinary(&$binaryData, &$offsetIndex = 0) - { - self::parseIdentifier($binaryData[$offsetIndex], Identifier::OCTETSTRING, $offsetIndex++); - $contentLength = self::parseContentLength($binaryData, $offsetIndex); - - if ($contentLength < 2) { - throw new ParserException('Can not parse Subject Alternative Names: The Sequence within the octet string after the Object identifier '.OID::CERT_EXT_SUBJECT_ALT_NAME." is too short ({$contentLength} octets)", $offsetIndex); - } - - $offsetOfSequence = $offsetIndex; - $sequence = Sequence::fromBinary($binaryData, $offsetIndex); - $offsetOfSequence += $sequence->getNumberOfLengthOctets() + 1; - - if ($sequence->getObjectLength() != $contentLength) { - throw new ParserException('Can not parse Subject Alternative Names: The Sequence length does not match the length of the surrounding octet string', $offsetIndex); - } - - $parsedObject = new self(); - /** @var \FG\ASN1\ASNObject $object */ - foreach ($sequence as $object) { - if ($object->getType() == DNSName::IDENTIFIER) { - $domainName = DNSName::fromBinary($binaryData, $offsetOfSequence); - $parsedObject->addDomainName($domainName); - } elseif ($object->getType() == IPAddress::IDENTIFIER) { - $ip = IPAddress::fromBinary($binaryData, $offsetOfSequence); - $parsedObject->addIP($ip); - } else { - throw new ParserException('Could not parse Subject Alternative Name: Only DNSName and IP SANs are currently supported', $offsetIndex); - } - } - - $parsedObject->getBinary(); // Determine the number of content octets and object sizes once (just to let the equality unit tests pass :/ ) - return $parsedObject; - } -} +<?php
+/*
+ * This file is part of the PHPASN1 library.
+ *
+ * Copyright © Friedrich Große <friedrich.grosse@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace FG\X509\SAN;
+
+use FG\ASN1\Exception\ParserException;
+use FG\ASN1\ASNObject;
+use FG\ASN1\OID;
+use FG\ASN1\Parsable;
+use FG\ASN1\Identifier;
+use FG\ASN1\Universal\Sequence;
+
+/**
+ * See section 8.3.2.1 of ITU-T X.509.
+ */
+class SubjectAlternativeNames extends ASNObject implements Parsable
+{
+ private $alternativeNamesSequence;
+
+ public function __construct()
+ {
+ $this->alternativeNamesSequence = new Sequence();
+ }
+
+ protected function calculateContentLength()
+ {
+ return $this->alternativeNamesSequence->getObjectLength();
+ }
+
+ public function getType()
+ {
+ return Identifier::OCTETSTRING;
+ }
+
+ public function addDomainName(DNSName $domainName)
+ {
+ $this->alternativeNamesSequence->addChild($domainName);
+ }
+
+ public function addIP(IPAddress $ip)
+ {
+ $this->alternativeNamesSequence->addChild($ip);
+ }
+
+ public function getContent()
+ {
+ return $this->alternativeNamesSequence->getContent();
+ }
+
+ protected function getEncodedValue()
+ {
+ return $this->alternativeNamesSequence->getBinary();
+ }
+
+ public static function fromBinary(&$binaryData, &$offsetIndex = 0)
+ {
+ self::parseIdentifier($binaryData[$offsetIndex], Identifier::OCTETSTRING, $offsetIndex++);
+ $contentLength = self::parseContentLength($binaryData, $offsetIndex);
+
+ if ($contentLength < 2) {
+ throw new ParserException('Can not parse Subject Alternative Names: The Sequence within the octet string after the Object identifier '.OID::CERT_EXT_SUBJECT_ALT_NAME." is too short ({$contentLength} octets)", $offsetIndex);
+ }
+
+ $offsetOfSequence = $offsetIndex;
+ $sequence = Sequence::fromBinary($binaryData, $offsetIndex);
+ $offsetOfSequence += $sequence->getNumberOfLengthOctets() + 1;
+
+ if ($sequence->getObjectLength() != $contentLength) {
+ throw new ParserException('Can not parse Subject Alternative Names: The Sequence length does not match the length of the surrounding octet string', $offsetIndex);
+ }
+
+ $parsedObject = new self();
+ /** @var \FG\ASN1\ASNObject $object */
+ foreach ($sequence as $object) {
+ if ($object->getType() == DNSName::IDENTIFIER) {
+ $domainName = DNSName::fromBinary($binaryData, $offsetOfSequence);
+ $parsedObject->addDomainName($domainName);
+ } elseif ($object->getType() == IPAddress::IDENTIFIER) {
+ $ip = IPAddress::fromBinary($binaryData, $offsetOfSequence);
+ $parsedObject->addIP($ip);
+ } else {
+ throw new ParserException('Could not parse Subject Alternative Name: Only DNSName and IP SANs are currently supported', $offsetIndex);
+ }
+ }
+
+ $parsedObject->getBinary(); // Determine the number of content octets and object sizes once (just to let the equality unit tests pass :/ )
+ return $parsedObject;
+ }
+}
|