Exemplo n.º 1
0
Arquivo: Csr.php Projeto: phpecc/x509
 /**
  * @param EcDomain $domain
  * @param CertificateSubject $subject
  * @param $sigAlgorithm
  * @param NamedCurveFp $curve
  * @param PublicKeyInterface $publicKey
  * @param SignatureInterface $signature
  */
 public function __construct(EcDomain $domain, CertificateSubject $subject, PublicKeyInterface $publicKey, SignatureInterface $signature)
 {
     $this->sigAlgorithm = $domain->getSigAlgorithm();
     $this->curve = $domain->getCurve();
     $this->publicKey = $publicKey;
     $this->signature = $signature;
     $this->subject = $subject;
 }
Exemplo n.º 2
0
 /**
  * @param CertificateSerializer $subjectSerializer
  * @param CertificateInfo $certificateInfo
  * @param PrivateKeyInterface $privateKey
  * @return Certificate
  */
 public function createCertificate(CertificateSerializer $subjectSerializer, CertificateInfo $certificateInfo, PrivateKeyInterface $privateKey)
 {
     $domain = $this->domain;
     $dataHex = $subjectSerializer->getSignatureData($certificateInfo);
     $hash = $domain->getHasher()->hashDec($dataHex);
     $rng = RandomGeneratorFactory::getUrandomGenerator();
     $k = $rng->generate($domain->getGenerator()->getOrder());
     $signature = $this->domain->getSigner()->sign($privateKey, $hash, $k);
     return new Certificate($certificateInfo, $this->domain->getSigAlgorithm(), $signature);
 }
Exemplo n.º 3
0
 /**
  * @param EcDomain $domain
  * @param CertificateSubject $subject
  * @param PrivateKeyInterface $privateKey
  * @return Csr
  */
 public static function getCsr(EcDomain $domain, CertificateSubject $subject, PrivateKeyInterface $privateKey)
 {
     $subjectSerializer = new CertificateSubjectSerializer();
     $serialized = $subjectSerializer->serialize($subject);
     return new Csr($domain, $subject, $privateKey->getPublicKey(), $domain->getSigner()->sign($privateKey, $domain->getHasher()->hashDec($serialized), RandomGeneratorFactory::getUrandomGenerator()->generate($domain->getGenerator()->getOrder())));
 }