Example #1
0
 /**
  * Generate ASN.1 structure.
  *
  * @return Sequence
  */
 public function toASN1()
 {
     $elements = array(new Enumerated($this->_digestedObjectType));
     if (isset($this->_otherObjectTypeID)) {
         $elements[] = new ObjectIdentifier($this->_otherObjectTypeID);
     }
     $elements[] = $this->_digestAlgorithm->toASN1();
     $elements[] = $this->_objectDigest;
     return new Sequence(...$elements);
 }
Example #2
0
 /**
  * Get ASN.1 parameters from algorithm identifier.
  *
  * @param AlgorithmIdentifierType $algo
  * @return Element|null ASN.1 element or null if parameters are omitted
  */
 public static function getAlgorithmParameters(AlgorithmIdentifierType $algo)
 {
     $seq = $algo->toASN1();
     return $seq->has(1) ? $seq->at(1)->asElement() : null;
 }