Ejemplo n.º 1
0
 /**
  * @param CertificateInfo $info
  * @return Sequence
  */
 public function getCertInfoAsn(CertificateInfo $info)
 {
     $curve = EccFactory::getSecgCurves()->curve256k1();
     if ($this->extension === null) {
         return new Sequence(new Integer($info->getSerialNo()), new Sequence(SigAlgorithmOidMapper::getSigAlgorithmOid($info->getSigAlgorithm())), $this->subjectSer->toAsn($info->getIssuerInfo()), new Sequence(new UTCTime($info->getValidityStart()->format(CertificateSerializer::UTCTIME_FORMAT)), new UTCTime($info->getValidityEnd()->format(CertificateSerializer::UTCTIME_FORMAT))), $this->subjectSer->toAsn($info->getSubjectInfo()), $this->getSubjectKeyASN($curve, $info->getPublicKey()));
     }
     return new Sequence(new Integer($info->getSerialNo()), new Sequence(SigAlgorithmOidMapper::getSigAlgorithmOid($info->getSigAlgorithm())), $this->subjectSer->toAsn($info->getIssuerInfo()), new Sequence(new UTCTime($info->getValidityStart()->format(CertificateSerializer::UTCTIME_FORMAT)), new UTCTime($info->getValidityEnd()->format(CertificateSerializer::UTCTIME_FORMAT))), $this->subjectSer->toAsn($info->getSubjectInfo()), $this->getSubjectKeyASN($curve, $info->getPublicKey()), $this->extension->apply($info));
 }
Ejemplo n.º 2
0
 /**
  * @param CertificateInfo $certificateInfo
  * @return Sequence
  */
 public function apply(CertificateInfo $certificateInfo)
 {
     $caKey = $certificateInfo->getPublicKey();
     $caHasher = SigAlgorithmOidMapper::getHasher($certificateInfo->getSigAlgo());
     $hash = $this->keyIdentifier($caHasher, $caKey);
     $extensions = new CertificateExtensions();
     return new Sequence(new Sequence(new ObjectIdentifier('2.5.29.14'), new OctetString(bin2hex($hash->getBinary()))), new Sequence(new ObjectIdentifier('2.5.29.35'), new OctetString(bin2hex((new Sequence($hash))->getBinary()))), new Sequence(new ObjectIdentifier('2.5.29.19'), new OctetString(bin2hex((new Sequence(new Boolean(true)))->getBinary()))));
 }