summaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib/keymanager.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-03-26 14:13:39 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-07 13:30:27 +0200
commit2e00acda079644ce4eb61b8a3812b095df8d05e3 (patch)
treedb2651dc6c0dec1a2932e9fdd8ec158849e7a838 /apps/encryption/lib/keymanager.php
parent2244ea998da0b49ef76144979f4bce02393eac89 (diff)
downloadnextcloud-server-2e00acda079644ce4eb61b8a3812b095df8d05e3.tar.gz
nextcloud-server-2e00acda079644ce4eb61b8a3812b095df8d05e3.zip
read encrypted files
Diffstat (limited to 'apps/encryption/lib/keymanager.php')
-rw-r--r--apps/encryption/lib/keymanager.php38
1 files changed, 31 insertions, 7 deletions
diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php
index 59f904ecf17..4b898217d6a 100644
--- a/apps/encryption/lib/keymanager.php
+++ b/apps/encryption/lib/keymanager.php
@@ -32,6 +32,7 @@ use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\ILogger;
use OCP\IUserSession;
+use \OCP\ISession;
class KeyManager {
@@ -87,15 +88,23 @@ class KeyManager {
private $log;
/**
+ * @var \OCP\ISession
+ */
+ private $session;
+
+ /**
* @param IStorage $keyStorage
* @param Crypt $crypt
* @param IConfig $config
- * @param IUserSession $userSession
+ * @param Session $userSession
+ * @param \OCP\ISession $session
* @param ICacheFactory $cacheFactory
* @param ILogger $log
*/
- public function __construct(IStorage $keyStorage, Crypt $crypt, IConfig $config, IUserSession $userSession, ICacheFactory $cacheFactory, ILogger $log) {
+ public function __construct(IStorage $keyStorage, Crypt $crypt, IConfig $config,
+ IUserSession $userSession, ISession $session ,ICacheFactory $cacheFactory, ILogger $log) {
+ $this->session = $session;
$this->keyStorage = $keyStorage;
$this->crypt = $crypt;
$this->config = $config;
@@ -215,6 +224,9 @@ class KeyManager {
return false;
}
+
+ $this->session->set('privateKey', $privateKey);
+ $this->session->set('initStatus', true);
self::$cacheFactory->set('privateKey', $privateKey);
self::$cacheFactory->set('initStatus', true);
@@ -239,18 +251,30 @@ class KeyManager {
/**
* @param $path
- * @return mixed
+ * @param $uid
+ * @return string
*/
- public function getFileKey($path) {
- return $this->keyStorage->getFileKey($path, $this->fileKeyId);
+ public function getFileKey($path, $uid) {
+ $key = '';
+ $encryptedFileKey = $this->keyStorage->getFileKey($path, $this->fileKeyId);
+ $shareKey = $this->getShareKey($path, $uid);
+ $privateKey = $this->session->get('privateKey');
+
+ if ($encryptedFileKey && $shareKey && $privateKey) {
+ $key = $this->crypt->multiKeyDecrypt($encryptedFileKey, $shareKey, $privateKey);
+ }
+
+ return $key;
}
/**
* @param $path
+ * @param $uid
* @return mixed
*/
- public function getShareKey($path) {
- return $this->keyStorage->getFileKey($path, $this->keyId . $this->shareKeyId);
+ public function getShareKey($path, $uid) {
+ $keyId = $uid . '.' . $this->shareKeyId;
+ return $this->keyStorage->getFileKey($path, $keyId);
}
/**