Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions apps/encryption/lib/Crypto/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class Encryption implements IEncryptionModule {
/** @var string */
private $user;

/** @var array */
private $owner;

/** @var string */
private $fileKey;

Expand Down Expand Up @@ -136,6 +139,7 @@ public function __construct(Crypt $crypt,
$this->decryptAll = $decryptAll;
$this->logger = $logger;
$this->l = $il10n;
$this->owner = [];
$this->useMasterPassword = $util->isMasterKeyEnabled();
}

Expand Down Expand Up @@ -280,13 +284,15 @@ public function end($path, $position = 0) {
}
}

$publicKeys = $this->keyManager->addSystemKeys($this->accessList, $publicKeys, $this->user);
$publicKeys = $this->keyManager->addSystemKeys($this->accessList, $publicKeys, $this->getOwner($path));
$encryptedKeyfiles = $this->crypt->multiKeyEncrypt($this->fileKey, $publicKeys);
$this->keyManager->setAllFileKeys($this->path, $encryptedKeyfiles);
}
return $result;
}



/**
* encrypt data
*
Expand Down Expand Up @@ -407,7 +413,7 @@ public function update($path, $uid, array $accessList) {
}
}

$publicKeys = $this->keyManager->addSystemKeys($accessList, $publicKeys, $uid);
$publicKeys = $this->keyManager->addSystemKeys($accessList, $publicKeys, $this->getOwner($path));

$encryptedFileKey = $this->crypt->multiKeyEncrypt($fileKey, $publicKeys);

Expand Down Expand Up @@ -556,6 +562,19 @@ protected function stripPartFileExtension($path) {
return $path;
}

/**
* get owner of a file
*
* @param string $path
* @return string
*/
protected function getOwner($path) {
if (!isset($this->owner[$path])) {
$this->owner[$path] = $this->util->getOwner($path);
}
return $this->owner[$path];
}

/**
* Check if the module is ready to be used by that specific user.
* In case a module is not ready - because e.g. key pairs have not been generated
Expand Down