summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-11-07 11:19:04 +0100
committerLukas Reschke <lukas@owncloud.com>2014-11-07 11:19:04 +0100
commite345697cabd6670e652f4bba7b91269e4efcd794 (patch)
treec4007ac3f50f13941eec34209e2e0979146b9d84 /apps/files_encryption
parent88c329b394e9a8cddda65b6e3645f7d6dcff279f (diff)
parentc2a45c1238c63ad97dbbfd1ef29fb70a45a93d09 (diff)
downloadnextcloud-server-e345697cabd6670e652f4bba7b91269e4efcd794.tar.gz
nextcloud-server-e345697cabd6670e652f4bba7b91269e4efcd794.zip
Merge pull request #11954 from owncloud/enc_stop_uploading_if_private_key_is_missing
Enc stop uploading if private key is missing
Diffstat (limited to 'apps/files_encryption')
-rw-r--r--apps/files_encryption/appinfo/app.php1
-rw-r--r--apps/files_encryption/lib/exceptions.php8
-rw-r--r--apps/files_encryption/lib/proxy.php3
-rw-r--r--apps/files_encryption/lib/stream.php5
4 files changed, 15 insertions, 2 deletions
diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php
index aa709fbac65..4f301f48b39 100644
--- a/apps/files_encryption/appinfo/app.php
+++ b/apps/files_encryption/appinfo/app.php
@@ -13,6 +13,7 @@ OC::$CLASSPATH['OCA\Encryption\Helper'] = 'files_encryption/lib/helper.php';
// Exceptions
OC::$CLASSPATH['OCA\Encryption\Exceptions\MultiKeyEncryptException'] = 'files_encryption/lib/exceptions.php';
OC::$CLASSPATH['OCA\Encryption\Exceptions\MultiKeyDecryptException'] = 'files_encryption/lib/exceptions.php';
+OC::$CLASSPATH['OCA\Encryption\Exceptions\EncryptionException'] = 'files_encryption/lib/exceptions.php';
\OCP\Util::addTranslations('files_encryption');
\OCP\Util::addscript('files_encryption', 'encryption');
diff --git a/apps/files_encryption/lib/exceptions.php b/apps/files_encryption/lib/exceptions.php
index 3ea27faf406..5b92f4afe74 100644
--- a/apps/files_encryption/lib/exceptions.php
+++ b/apps/files_encryption/lib/exceptions.php
@@ -30,8 +30,16 @@ namespace OCA\Encryption\Exceptions;
* 30 - encryption header to large
* 40 - unknown cipher
* 50 - encryption failed
+ * 60 - no private key available
*/
class EncryptionException extends \Exception {
+ const UNEXPECTED_END_OF_ENCRTYPTION_HEADER = 10;
+ const UNEXPECTED_BLOG_SIZE = 20;
+ const ENCRYPTION_HEADER_TO_LARGE = 30;
+ const UNKNOWN_CIPHER = 40;
+ const ENCRYPTION_FAILED = 50;
+ const NO_PRIVATE_KEY_AVAILABLE = 60;
+
}
/**
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 3b9dcbe7767..31723ae7647 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -95,8 +95,7 @@ class Proxy extends \OC_FileProxy {
// don't call the crypt stream wrapper, if...
if (
- $session->getInitialized() !== Session::INIT_SUCCESSFUL // encryption successful initialized
- || Crypt::mode() !== 'server' // we are not in server-side-encryption mode
+ Crypt::mode() !== 'server' // we are not in server-side-encryption mode
|| $this->isExcludedPath($path, $userId) // if path is excluded from encryption
|| substr($path, 0, 8) === 'crypt://' // we are already in crypt mode
) {
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index f74812a7253..046c38152b8 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -30,6 +30,7 @@
*/
namespace OCA\Encryption;
+use OCA\Encryption\Exceptions\EncryptionException;
/**
* Provides 'crypt://' stream wrapper protocol.
@@ -106,6 +107,10 @@ class Stream {
$this->session = new \OCA\Encryption\Session($this->rootView);
$this->privateKey = $this->session->getPrivateKey();
+ if ($this->privateKey === false) {
+ throw new EncryptionException('Session does not contain a private key, maybe your login password changed?',
+ EncryptionException::NO_PRIVATE_KEY_AVAILABLE);
+ }
$normalizedPath = \OC\Files\Filesystem::normalizePath(str_replace('crypt://', '', $path));
if ($originalFile = Helper::getPathFromTmpFile($normalizedPath)) {