Esempio n. 1
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()))));
 }
Esempio n. 2
0
 /**
  * @param Sequence $sigSection
  * @return string
  * @throws \Exception
  */
 public function parseSigAlg(Sequence $sigSection)
 {
     $sigInfo = $sigSection->getContent();
     if (!$sigInfo[0] instanceof ObjectIdentifier) {
         throw new \Exception('Invaid sig: object identfier');
     }
     return SigAlgorithmOidMapper::getAlgorithmFromOid($sigInfo[0]);
 }
Esempio n. 3
0
 /**
  * @param Certificate $cert
  * @return Sequence
  */
 public function getCertificateASN(Certificate $cert)
 {
     return new Sequence($this->getCertInfoASN($cert->getInfo()), new Sequence(SigAlgorithmOidMapper::getSigAlgorithmOid($cert->getSigAlgorithm())), new BitString(bin2hex($this->sigSer->serialize($cert->getSignature()))));
 }
Esempio n. 4
0
 /**
  * @param Csr $csr
  * @return Sequence
  */
 public function getCsrASN(Csr $csr)
 {
     return new Sequence($this->getCertRequestInfoASN($csr->getCurve(), $csr->getPublicKey(), $csr->getSubject()), new Sequence(SigAlgorithmOidMapper::getSigAlgorithmOid($csr->getSigAlgorithm())), new BitString(bin2hex($this->sigSer->serialize($csr->getSignature()))));
 }