Beispiel #1
0
 /**
  * decrypt data
  *
  * @param string $data you want to decrypt
  * @return mixed decrypted data
  */
 public function decrypt($data)
 {
     $result = '';
     if (!empty($data)) {
         $result = $this->crypt->symmetricDecryptFileContent($data, $this->fileKey);
     }
     return $result;
 }
Beispiel #2
0
 /**
  * decrypt data
  *
  * @param string $data you want to decrypt
  * @param int $position
  * @return string decrypted data
  * @throws DecryptionFailedException
  */
 public function decrypt($data, $position = 0)
 {
     if (empty($this->fileKey)) {
         $msg = 'Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.';
         $hint = $this->l->t('Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.');
         $this->logger->error($msg);
         throw new DecryptionFailedException($msg, $hint);
     }
     return $this->crypt->symmetricDecryptFileContent($data, $this->fileKey, $this->cipher, $this->version, $position);
 }
Beispiel #3
0
 /**
  * @param $path
  * @param $uid
  * @return string
  */
 public function getFileKey($path, $uid)
 {
     $encryptedFileKey = $this->keyStorage->getFileKey($path, $this->fileKeyId);
     if (is_null($uid)) {
         $uid = $this->getPublicShareKeyId();
         $shareKey = $this->getShareKey($path, $uid);
         $privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.privateKey');
         $privateKey = $this->crypt->symmetricDecryptFileContent($privateKey);
     } else {
         $shareKey = $this->getShareKey($path, $uid);
         $privateKey = $this->session->getPrivateKey();
     }
     if ($encryptedFileKey && $shareKey && $privateKey) {
         return $this->crypt->multiKeyDecrypt($encryptedFileKey, $shareKey, $privateKey);
     }
     return '';
 }