Example #1
0
 /**
  *
  * @param UnspecifiedType $el
  * @return self
  */
 public static function fromASN1(UnspecifiedType $el)
 {
     $seq = $el->asSequence();
     $authority = null;
     if ($seq->hasTagged(0)) {
         $authority = GeneralNames::fromASN1($seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
     }
     $name = GeneralName::fromASN1($seq->getTagged(1)->asExplicit()->asTagged());
     return new self($name, $authority);
 }
Example #2
0
 /**
  * Initialize from ASN.1.
  *
  * @param Sequence $seq
  * @return self
  */
 public static function fromASN1(Sequence $seq)
 {
     $issuer = GeneralNames::fromASN1($seq->at(0)->asSequence());
     $serial = $seq->at(1)->asInteger()->number();
     $uid = null;
     if ($seq->has(2, Element::TYPE_BIT_STRING)) {
         $uid = UniqueIdentifier::fromASN1($seq->at(2)->asBitString());
     }
     return new self($issuer, $serial, $uid);
 }
Example #3
0
 /**
  * Initialize from TaggedType.
  *
  * @param TaggedType $el
  * @throws \UnexpectedValueException
  * @return self
  */
 public static function fromTaggedType(TaggedType $el)
 {
     switch ($el->tag()) {
         case self::TAG_FULL_NAME:
             return new FullName(GeneralNames::fromASN1($el->asImplicit(Element::TYPE_SEQUENCE)->asSequence()));
         case self::TAG_RDN:
             return new RelativeName(RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet()));
         default:
             throw new \UnexpectedValueException("DistributionPointName tag " . $el->tag() . " not supported.");
     }
 }
Example #4
0
 /**
  *
  * @param UnspecifiedType $el
  * @return self
  */
 public static function fromASN1(UnspecifiedType $el)
 {
     $seq = $el->asSequence();
     $authority = null;
     $idx = 0;
     if ($seq->hasTagged(0)) {
         $authority = GeneralNames::fromASN1($seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
         ++$idx;
     }
     $values = array_map(function (UnspecifiedType $el) {
         return IetfAttrValue::fromASN1($el);
     }, $seq->at($idx)->asSequence()->elements());
     $obj = new static(...$values);
     $obj->_policyAuthority = $authority;
     return $obj;
 }
Example #5
0
 /**
  * Initialize from ASN.1.
  *
  * @param Sequence $seq
  * @return self
  */
 public static function fromASN1(Sequence $seq)
 {
     $name = null;
     $reasons = null;
     $issuer = null;
     if ($seq->hasTagged(0)) {
         // promoted to explicit tagging because underlying type is CHOICE
         $name = DistributionPointName::fromTaggedType($seq->getTagged(0)->asExplicit()->asTagged());
     }
     if ($seq->hasTagged(1)) {
         $reasons = ReasonFlags::fromASN1($seq->getTagged(1)->asImplicit(Element::TYPE_BIT_STRING)->asBitString());
     }
     if ($seq->hasTagged(2)) {
         $issuer = GeneralNames::fromASN1($seq->getTagged(2)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
     }
     return new self($name, $reasons, $issuer);
 }
Example #6
0
File: Holder.php Project: sop/x509
 /**
  * Initialize from ASN.1.
  *
  * @param Sequence $seq
  */
 public static function fromASN1(Sequence $seq)
 {
     $cert_id = null;
     $entity_name = null;
     $digest_info = null;
     if ($seq->hasTagged(0)) {
         $cert_id = IssuerSerial::fromASN1($seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
     }
     if ($seq->hasTagged(1)) {
         $entity_name = GeneralNames::fromASN1($seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
     }
     if ($seq->hasTagged(2)) {
         $digest_info = ObjectDigestInfo::fromASN1($seq->getTagged(2)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
     }
     $obj = new self($cert_id, $entity_name);
     $obj->_objectDigestInfo = $digest_info;
     return $obj;
 }
 protected static function _fromDER($data, $critical)
 {
     $seq = Sequence::fromDER($data);
     $keyIdentifier = null;
     $issuer = null;
     $serial = null;
     if ($seq->hasTagged(0)) {
         $keyIdentifier = $seq->getTagged(0)->asImplicit(Element::TYPE_OCTET_STRING)->asOctetString()->string();
     }
     if ($seq->hasTagged(1) || $seq->hasTagged(2)) {
         if (!$seq->hasTagged(1) || !$seq->hasTagged(2)) {
             throw new \UnexpectedValueException("AuthorityKeyIdentifier must have both" . " authorityCertIssuer and authorityCertSerialNumber" . " present or both absent.");
         }
         $issuer = GeneralNames::fromASN1($seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
         $serial = $seq->getTagged(2)->asImplicit(Element::TYPE_INTEGER)->asInteger()->number();
     }
     return new self($critical, $keyIdentifier, $issuer, $serial);
 }
Example #8
0
File: V2Form.php Project: sop/x509
 /**
  * Initialize from ASN.1.
  *
  * @param Sequence $seq
  * @return self
  */
 public static function fromV2ASN1(Sequence $seq)
 {
     $issuer = null;
     $cert_id = null;
     $digest_info = null;
     if ($seq->has(0, Element::TYPE_SEQUENCE)) {
         $issuer = GeneralNames::fromASN1($seq->at(0)->asSequence());
     }
     if ($seq->hasTagged(0)) {
         $cert_id = IssuerSerial::fromASN1($seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
     }
     if ($seq->hasTagged(1)) {
         $digest_info = ObjectDigestInfo::fromASN1($seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
     }
     $obj = new self($issuer);
     $obj->_baseCertificateID = $cert_id;
     $obj->_objectDigestInfo = $digest_info;
     return $obj;
 }
 protected static function _fromDER($data, $critical)
 {
     return new self($critical, GeneralNames::fromASN1(Sequence::fromDER($data)));
 }