|
@@ 158-170 (lines=13) @@
|
| 155 |
|
*/ |
| 156 |
|
public function validateShareKey() { |
| 157 |
|
$shareKey = $this->getPublicShareKey(); |
| 158 |
|
if (empty($shareKey)) { |
| 159 |
|
$keyPair = $this->crypt->createKeyPair(); |
| 160 |
|
|
| 161 |
|
// Save public key |
| 162 |
|
$this->keyStorage->setSystemUserKey( |
| 163 |
|
$this->publicShareKeyId . '.publicKey', $keyPair['publicKey'], |
| 164 |
|
Encryption::ID); |
| 165 |
|
|
| 166 |
|
// Encrypt private key empty passphrase |
| 167 |
|
$encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], ''); |
| 168 |
|
$header = $this->crypt->generateHeader(); |
| 169 |
|
$this->setSystemPrivateKey($this->publicShareKeyId, $header . $encryptedKey); |
| 170 |
|
} |
| 171 |
|
} |
| 172 |
|
|
| 173 |
|
/** |
|
@@ 183-195 (lines=13) @@
|
| 180 |
|
} |
| 181 |
|
|
| 182 |
|
$publicMasterKey = $this->getPublicMasterKey(); |
| 183 |
|
if (empty($publicMasterKey)) { |
| 184 |
|
$keyPair = $this->crypt->createKeyPair(); |
| 185 |
|
|
| 186 |
|
// Save public key |
| 187 |
|
$this->keyStorage->setSystemUserKey( |
| 188 |
|
$this->masterKeyId . '.publicKey', $keyPair['publicKey'], |
| 189 |
|
Encryption::ID); |
| 190 |
|
|
| 191 |
|
// Encrypt private key with system password |
| 192 |
|
$encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $this->getMasterKeyPassword(), $this->masterKeyId); |
| 193 |
|
$header = $this->crypt->generateHeader(); |
| 194 |
|
$this->setSystemPrivateKey($this->masterKeyId, $header . $encryptedKey); |
| 195 |
|
} |
| 196 |
|
|
| 197 |
|
if (!$this->session->isPrivateKeySet()) { |
| 198 |
|
$masterKey = $this->getSystemPrivateKey($this->masterKeyId); |