Exemplo n.º 1
0
 /**
  * Parses a private key from the given PEM content
  *
  * @param Key $key
  *
  * @return \Mdanter\Ecc\Crypto\Key\PrivateKeyInterface
  */
 public function getPrivateKey(Key $key)
 {
     return $this->privateKeySerializer->parse($this->getKeyContent($key, 'EC PRIVATE KEY'));
 }
Exemplo n.º 2
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.');
     }
 }