1 | <?php |
||
14 | class CryptKey |
||
15 | { |
||
16 | const RSA_KEY_PATTERN = |
||
17 | '/^(-----BEGIN (RSA )?(PUBLIC|PRIVATE) KEY-----)\R.*(-----END (RSA )?(PUBLIC|PRIVATE) KEY-----)\R?$/s'; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $keyPath; |
||
23 | |||
24 | /** |
||
25 | * @var null|string |
||
26 | */ |
||
27 | protected $passPhrase; |
||
28 | |||
29 | /** |
||
30 | * @param string $keyPath |
||
31 | * @param null|string $passPhrase |
||
32 | * @param bool $keyPermissionsCheck |
||
33 | */ |
||
34 | 7 | public function __construct($keyPath, $passPhrase = null, $keyPermissionsCheck = true) |
|
63 | |||
64 | /** |
||
65 | * @param string $key |
||
66 | * |
||
67 | * @throws \RuntimeException |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | private function saveKeyToFile($key) |
||
100 | |||
101 | /** |
||
102 | * Retrieve key path. |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function getKeyPath() |
||
110 | |||
111 | /** |
||
112 | * Retrieve key pass phrase. |
||
113 | * |
||
114 | * @return null|string |
||
115 | */ |
||
116 | public function getPassPhrase() |
||
120 | } |
||
121 |