/**
  * Generate ASN.1 structure.
  *
  * @return Sequence
  */
 public function toASN1()
 {
     $elements = array(new Integer($this->_version), $this->_subject->toASN1(), $this->_subjectPKInfo->toASN1());
     if (isset($this->_attributes)) {
         $elements[] = new ImplicitlyTaggedType(0, $this->_attributes->toASN1());
     }
     return new Sequence(...$elements);
 }
Exemple #2
0
 /**
  * Generate ASN.1 structure.
  *
  * @return Sequence
  */
 public function toASN1()
 {
     $elements = array();
     $version = $this->version();
     // if version is not default
     if ($version != self::VERSION_1) {
         $elements[] = new ExplicitlyTaggedType(0, new Integer($version));
     }
     $serial = $this->serialNumber();
     $signature = $this->signature();
     // add required elements
     array_push($elements, new Integer($serial), $signature->toASN1(), $this->_issuer->toASN1(), $this->_validity->toASN1(), $this->_subject->toASN1(), $this->_subjectPublicKeyInfo->toASN1());
     if (isset($this->_issuerUniqueID)) {
         $elements[] = new ImplicitlyTaggedType(1, $this->_issuerUniqueID->toASN1());
     }
     if (isset($this->_subjectUniqueID)) {
         $elements[] = new ImplicitlyTaggedType(2, $this->_subjectUniqueID->toASN1());
     }
     if (count($this->_extensions)) {
         $elements[] = new ExplicitlyTaggedType(3, $this->_extensions->toASN1());
     }
     return new Sequence(...$elements);
 }
Exemple #3
0
 protected function _choiceASN1()
 {
     // Name type is itself a CHOICE, so explicit tagging must be
     // employed to avoid ambiguities
     return new ExplicitlyTaggedType($this->_tag, $this->_dn->toASN1());
 }