Beispiel #1
0
 /**
  * @param Binary $key
  * @return Binary
  */
 public function getAddress(Binary $key)
 {
     $math = MathAdapterFactory::getAdapter();
     $inflatedPrivateKey = $this->deserializePrivate($key->getData(), $math);
     $publicKey = $inflatedPrivateKey->getPublicKey();
     $publicSerializer = new DerPublicKeySerializer();
     $serialized = $publicSerializer->serialize($publicKey);
     return new Binary($serialized);
 }
Beispiel #2
0
 /**
  * @param NamedCurveFp $curve
  * @param PublicKeyInterface $publicKey
  * @return Sequence
  */
 public function getSubjectKeyASN(NamedCurveFp $curve, PublicKeyInterface $publicKey)
 {
     return new Sequence(new Sequence(new ObjectIdentifier(CertificateSerializer::ECPUBKEY_OID), CurveOidMapper::getCurveOid($curve)), new BitString($this->pubKeySer->getUncompressedKey($publicKey)));
 }
Beispiel #3
0
 /**
  * @param Hasher $hasher
  * @param PublicKeyInterface $publicKey
  * @return OctetString
  */
 private function keyIdentifier(Hasher $hasher, PublicKeyInterface $publicKey)
 {
     $binary = $this->pubKeySerializer->serialize($publicKey);
     $hash = $hasher->hash($binary);
     return new OctetString($hash);
 }
Beispiel #4
0
 /**
  * @param NamedCurveFp $curve
  * @param PublicKeyInterface $publicKey
  * @return Sequence
  */
 public function getSubjectKeyASN(NamedCurveFp $curve, PublicKeyInterface $publicKey)
 {
     return new Sequence(new Sequence(new ObjectIdentifier('1.2.840.10045.2.1'), CurveOidMapper::getCurveOid($curve)), new BitString($this->pubKeySer->getUncompressedKey($publicKey)));
 }
 private static function calculateSecret($clientP256dh, $serverPrivateKey)
 {
     $publicKeySerializer = new DerPublicKeySerializer();
     $publicKey = $publicKeySerializer->parse($clientP256dh);
     var_dump($publicKey);
 }
 /**
  * @param PrivateKeyInterface $key
  * @return BitString
  */
 private function encodePubKey(PrivateKeyInterface $key)
 {
     return new BitString($this->pubKeySerializer->getUncompressedKey($key->getPublicKey()));
 }