Пример #1
0
 /**
  * change recovery key id
  *
  * @param string $newPassword
  * @param string $oldPassword
  * @return bool
  */
 public function changeRecoveryKeyPassword($newPassword, $oldPassword)
 {
     $recoveryKey = $this->keyManager->getSystemPrivateKey($this->keyManager->getRecoveryKeyId());
     $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $oldPassword);
     $encryptedRecoveryKey = $this->crypt->symmetricEncryptFileContent($decryptedRecoveryKey, $newPassword);
     if ($encryptedRecoveryKey) {
         $this->keyManager->setSystemPrivateKey($this->keyManager->getRecoveryKeyId(), $encryptedRecoveryKey);
         return true;
     }
     return false;
 }
Пример #2
0
 /**
  * change recovery key id
  *
  * @param string $newPassword
  * @param string $oldPassword
  * @return bool
  */
 public function changeRecoveryKeyPassword($newPassword, $oldPassword)
 {
     $recoveryKey = $this->keyManager->getSystemPrivateKey($this->keyManager->getRecoveryKeyId());
     $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $oldPassword);
     $encryptedRecoveryKey = $this->crypt->encryptPrivateKey($decryptedRecoveryKey, $newPassword);
     $header = $this->crypt->generateHeader();
     if ($encryptedRecoveryKey) {
         $this->keyManager->setSystemPrivateKey($this->keyManager->getRecoveryKeyId(), $header . $encryptedRecoveryKey);
         return true;
     }
     return false;
 }
Пример #3
0
 public function testSetSystemPrivateKey()
 {
     $this->keyStorageMock->expects($this->exactly(1))->method('setSystemUserKey')->with($this->equalTo('keyId.privateKey'), $this->equalTo('key'))->willReturn(true);
     $this->assertTrue($this->instance->setSystemPrivateKey('keyId', 'key'));
 }