src/BasePrivateKeyAsymmetricCrypt.php 1 location
|
@@ 22-36 (lines=15) @@
|
| 19 |
|
/** |
| 20 |
|
* @package Limoncello\Crypt |
| 21 |
|
*/ |
| 22 |
|
abstract class BasePrivateKeyAsymmetricCrypt extends BaseAsymmetricCrypt |
| 23 |
|
{ |
| 24 |
|
/** |
| 25 |
|
* @param string $privateKeyOrPath Could be either private key or path to file prefixed with 'file://'. |
| 26 |
|
*/ |
| 27 |
|
public function __construct($privateKeyOrPath) |
| 28 |
|
{ |
| 29 |
|
$this->clearErrors(); |
| 30 |
|
|
| 31 |
|
$privateKey = openssl_pkey_get_private($privateKeyOrPath); |
| 32 |
|
$privateKey !== false ?: $this->throwException(new CryptException($this->getErrorMessage())); |
| 33 |
|
|
| 34 |
|
$this->setKey($privateKey); |
| 35 |
|
} |
| 36 |
|
} |
| 37 |
|
|
src/BasePublicKeyAsymmetricCrypt.php 1 location
|
@@ 22-36 (lines=15) @@
|
| 19 |
|
/** |
| 20 |
|
* @package Limoncello\Crypt |
| 21 |
|
*/ |
| 22 |
|
abstract class BasePublicKeyAsymmetricCrypt extends BaseAsymmetricCrypt |
| 23 |
|
{ |
| 24 |
|
/** |
| 25 |
|
* @param string $publicKeyOrPath Could be either public key or path to file prefixed with 'file://'. |
| 26 |
|
*/ |
| 27 |
|
public function __construct($publicKeyOrPath) |
| 28 |
|
{ |
| 29 |
|
$this->clearErrors(); |
| 30 |
|
|
| 31 |
|
$publicKey = openssl_pkey_get_public($publicKeyOrPath); |
| 32 |
|
$publicKey !== false ?: $this->throwException(new CryptException($this->getErrorMessage())); |
| 33 |
|
|
| 34 |
|
$this->setKey($publicKey); |
| 35 |
|
} |
| 36 |
|
} |
| 37 |
|
|