Пример #1
0
 /**
  * Parses a public key from the given PEM content
  *
  * @param Key $key
  *
  * @return \Mdanter\Ecc\Crypto\Key\PublicKeyInterface
  */
 public function getPublicKey(Key $key)
 {
     return $this->publicKeySerializer->parse($this->getKeyContent($key, 'PUBLIC KEY'));
 }
Пример #2
0
 /**
  * @param Sequence $object
  * @return \Mdanter\Ecc\Crypto\Key\PublicKeyInterface
  */
 public function parseSubjectKeyInfo(Sequence $object)
 {
     $pubkey = $this->pubKeySer->parse($object->getBinary());
     return $pubkey;
 }
Пример #3
0
 /**
  * @param string $key
  * @param PrivateKeySerializerInterface|PublicKeySerializerInterface $serializer
  * @return PrivateKeyInterface|PublicKeyInterface
  * @throws \Exception
  */
 private function deserialize($key, $serializer)
 {
     try {
         return $serializer->parse($key);
     } catch (\Exception $e) {
         throw new \Exception('Invalid key.');
     }
 }